Merge remote-tracking branch 'origin/0.8.X' into 0.8.X

This commit is contained in:
2025-12-06 10:28:36 +08:00
17 changed files with 800 additions and 829 deletions

View File

@@ -0,0 +1,55 @@
import request from '@/utils/request'
// 查询待检项模板列表
export function listInspectionItemTemplate(query) {
return request({
url: '/qc/inspectionItemTemplate/list',
method: 'get',
params: query
})
}
// 查询待检项模板详细
export function getInspectionItemTemplate(templateId) {
return request({
url: '/qc/inspectionItemTemplate/' + templateId,
method: 'get'
})
}
// 新增待检项模板
export function addInspectionItemTemplate(data) {
return request({
url: '/qc/inspectionItemTemplate',
method: 'post',
data: data
})
}
// 修改待检项模板
export function updateInspectionItemTemplate(data) {
return request({
url: '/qc/inspectionItemTemplate',
method: 'put',
data: data
})
}
// 删除待检项模板
export function delInspectionItemTemplate(templateId) {
return request({
url: '/qc/inspectionItemTemplate/' + templateId,
method: 'delete'
})
}
// 查询模版详情
export function getInfoByInspectionItem(inspectionItemIds) {
return request({
url: '/qc/inspectionItemTemplate/getInfoByInspectionItem',
method: 'post',
params: {
inspectionItemIds
}
})
}

View File

@@ -1,64 +1,186 @@
<template>
<el-select
v-model="selected"
multiple
filterable
placeholder="请选择检查项"
@change="handleChange"
size="mini"
style="width: 100%;"
>
<el-option
v-for="item in checkItems"
:key="item.itemId"
:label="item.itemName"
:value="item.itemId"
/>
</el-select>
<div class="check-item-transfer">
<!-- Element-UI穿梭框核心组件 -->
<el-transfer v-model="internalValue" :data="transferData" :titles="['待选检查项', '已选检查项']" :props="transferProps"
@change="handleTransferChange" filterable filter-placeholder="请输入检查项名称搜索" v-loading="loading" :disabled="loading">
<!-- 自定义选项内容单根节点包裹解决Vue2警告 -->
<template slot-scope="{ option }">
<span class="transfer-option-content">
<span>{{ option.itemName }}</span>
<span style="margin-left: 8px; color: #999; font-size: 12px">
({{ option.qualitativeQuantitative === 0 ? '定性' : '定量' }})
</span>
</span>
</template>
<div class="transfer-footer" style="display: flex; justify-content: center; align-items: center; height: 40px;"
slot="right-footer">
<el-button size="small" @click="loadInspectionItemTemplateList">选择预设检验方案</el-button>
</div>
</el-transfer>
<el-dialog title="选择待检项方案" :visible.sync="open" width="400px" append-to-body>
<el-input v-model="queryParams.templateName" placeholder="请输入任务名称" @change="loadInspectionItemTemplateList" />
<el-table highlight-current-row border @row-click="handleRowClick" v-loading="loading"
:data="inspectionItemTemplateList" @selection-change="handleSelectionChange">
<el-table-column label="方案名称" align="center" prop="templateName" />
<el-table-column label="方案描述" align="center" prop="templateDesc" />
</el-table>
<pagination v-show="total > queryParams.pageSize" :total="total" :page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize" @pagination="loadInspectionItemTemplateList" />
</el-dialog>
</div>
</template>
<script>
import { listCheckItem } from '@/api/mes/qc/checkItem'
import { listCheckItem } from "@/api/mes/qc/checkItem";
import { listInspectionItemTemplate } from "@/api/mes/qc/inspectionItemTemplate";
export default {
name: 'CheckItemSelect',
name: "CheckItemTransfer",
// 接收外部v-model绑定的itemIds字符串逗号分隔
props: {
modelValue: {
type: Array,
default: () => []
value: {
type: String,
default: ""
}
},
emits: ['update:modelValue'],
data() {
return {
checkItems: [],
selected: this.modelValue.slice()
}
// 穿梭框数据源(去重后的检查项列表)
transferData: [],
// 内部选中值数组与v-model的字符串双向同步
internalValue: [],
// 穿梭框字段映射key必须唯一
transferProps: {
key: "itemId", // 唯一标识字段
label: "itemName" // 显示文本字段
},
total: 0,
// 数据加载状态
loading: false,
templateList: [],
open: false,
queryParams: {
pageNum: 1,
pageSize: 10,
templateName: undefined,
},
};
},
watch: {
modelValue(val) {
this.selected = val.slice()
}
},
methods: {
handleChange(val) {
this.$emit('input', val)
},
async fetchCheckItems() {
try {
const res = await listCheckItem({ pageSize: 1000 })
this.checkItems = res.rows
} catch (e) {
this.checkItems = []
// 监听外部传入的value变化同步到内部选中值
value: {
immediate: true, // 初始化时立即执行
handler(newVal) {
if (newVal && typeof newVal === "string") {
// 字符串转数字数组(过滤空值,统一类型)
this.internalValue = newVal
.split(",")
.filter(Boolean) // 过滤空字符串
.map(id => id.toString()); // 统一转为字符串类型
} else {
this.internalValue = [];
}
}
}
},
created() {
// 组件创建时加载检查项列表
this.loadCheckItemList();
},
methods: {
/** 加载检查项列表(核心修复:去重+类型统一) */
async loadCheckItemList() {
try {
this.loading = true;
// 查询全部检查项(不分页)
const queryParams = { pageNum: 1, pageSize: 9999 };
const response = await listCheckItem(queryParams);
let rawList = response.rows || [];
mounted() {
this.fetchCheckItems()
// 修复1统一itemId为字符串类型避免字符串/数字不匹配)
rawList = rawList.map(item => ({
...item,
itemId: item.itemId.toString() // 强制转为字符串类型
}));
// 修复2按itemId去重解决重复key导致穿梭无效的核心问题
this.transferData = [...new Map(
rawList.map(item => [item.itemId, item]) // Map的key唯一自动去重
).values()];
} catch (error) {
// 兼容不同的提示方式
if (this.$modal) {
this.$modal.msgError("加载检查项列表失败");
} else if (this.$message) {
this.$message.error("加载检查项列表失败");
}
console.error("检查项列表加载异常:", error);
} finally {
this.loading = false;
}
},
handleRowClick(row) {
this.$emit("input", row.inspectionItem);
this.open = false;
},
/** 加载待检项方案列表 */
async loadInspectionItemTemplateList() {
try {
this.loading = true;
this.open = true;
const response = await listInspectionItemTemplate(this.queryParams);
this.inspectionItemTemplateList = response.rows || [];
this.total = response.total || 0;
} catch (error) {
if (this.$modal) {
this.$modal.msgError("加载待检项方案列表失败");
} else if (this.$message) {
this.$message.error("加载待检项方案列表失败");
}
console.error("待检项方案列表加载异常:", error);
} finally {
this.loading = false;
}
},
/** 穿梭框选中状态变化处理(双向绑定核心逻辑) */
handleTransferChange(newVal) {
// 过滤空值后转逗号分隔的字符串
const itemIdsStr = newVal
.filter(Boolean)
.join(",");
// 触发input事件实现v-model双向绑定
this.$emit("input", itemIdsStr);
// 向外暴露change事件返回数组和字符串两种格式
this.$emit("change", newVal, itemIdsStr);
}
}
}
};
</script>
<style scoped>
</style>
.check-item-transfer {
width: 100%;
box-sizing: border-box;
}
/* 自定义选项样式,确保显示完整 */
.transfer-option-content {
display: inline-block;
width: 100%;
padding: 2px 0;
box-sizing: border-box;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>

View File

@@ -0,0 +1,143 @@
<template>
<div class="check-item-transfer">
<!-- Element-UI穿梭框核心组件 -->
<el-transfer
v-model="internalValue"
:data="transferData"
:titles="['待选检查项', '已选检查项']"
:props="transferProps"
@change="handleTransferChange"
filterable
filter-placeholder="请输入检查项名称搜索"
v-loading="loading"
:disabled="loading"
>
<!-- 自定义选项内容单根节点包裹解决Vue2警告 -->
<template slot-scope="{ option }">
<span class="transfer-option-content">
<span>{{ option.itemName }}</span>
<span style="margin-left: 8px; color: #999; font-size: 12px">
({{ option.qualitativeQuantitative === 0 ? '定性' : '定量' }})
</span>
</span>
</template>
</el-transfer>
</div>
</template>
<script>
import { listCheckItem } from "@/api/mes/qc/checkItem";
export default {
name: "CheckItemTransfer",
// 接收外部v-model绑定的itemIds字符串逗号分隔
props: {
value: {
type: String,
default: ""
}
},
data() {
return {
// 穿梭框数据源(去重后的检查项列表)
transferData: [],
// 内部选中值数组与v-model的字符串双向同步
internalValue: [],
// 穿梭框字段映射key必须唯一
transferProps: {
key: "itemId", // 唯一标识字段
label: "itemName" // 显示文本字段
},
// 数据加载状态
loading: false
};
},
watch: {
// 监听外部传入的value变化同步到内部选中值
value: {
immediate: true, // 初始化时立即执行
handler(newVal) {
if (newVal && typeof newVal === "string") {
// 字符串转数字数组(过滤空值,统一类型)
this.internalValue = newVal
.split(",")
.filter(Boolean) // 过滤空字符串
.map(id => id.toString()); // 统一转为字符串类型
} else {
this.internalValue = [];
}
}
}
},
created() {
// 组件创建时加载检查项列表
this.loadCheckItemList();
},
methods: {
/** 加载检查项列表(核心修复:去重+类型统一) */
async loadCheckItemList() {
try {
this.loading = true;
// 查询全部检查项(不分页)
const queryParams = { pageNum: 1, pageSize: 9999 };
const response = await listCheckItem(queryParams);
let rawList = response.rows || [];
// 修复1统一itemId为字符串类型避免字符串/数字不匹配)
rawList = rawList.map(item => ({
...item,
itemId: item.itemId.toString() // 强制转为字符串类型
}));
// 修复2按itemId去重解决重复key导致穿梭无效的核心问题
this.transferData = [...new Map(
rawList.map(item => [item.itemId, item]) // Map的key唯一自动去重
).values()];
} catch (error) {
// 兼容不同的提示方式
if (this.$modal) {
this.$modal.msgError("加载检查项列表失败");
} else if (this.$message) {
this.$message.error("加载检查项列表失败");
}
console.error("检查项列表加载异常:", error);
} finally {
this.loading = false;
}
},
/** 穿梭框选中状态变化处理(双向绑定核心逻辑) */
handleTransferChange(newVal) {
// 过滤空值后转逗号分隔的字符串
const itemIdsStr = newVal
.filter(Boolean)
.join(",");
// 触发input事件实现v-model双向绑定
this.$emit("input", itemIdsStr);
// 向外暴露change事件返回数组和字符串两种格式
this.$emit("change", newVal, itemIdsStr);
}
}
};
</script>
<style scoped>
.check-item-transfer {
width: 100%;
min-height: 400px;
box-sizing: border-box;
}
/* 自定义选项样式,确保显示完整 */
.transfer-option-content {
display: inline-block;
width: 100%;
padding: 2px 0;
box-sizing: border-box;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>

View File

@@ -126,7 +126,7 @@
</div>
<!-- 添加或修改检查任务对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="任务名称" prop="taskName">
<el-input v-model="form.taskName" placeholder="请输入任务名称" />

View File

@@ -122,7 +122,7 @@
</div>
<!-- 添加或修改检查任务对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="任务名称" prop="taskName">
<el-input v-model="form.taskName" placeholder="请输入任务名称" />

View File

@@ -128,7 +128,7 @@
</div>
<!-- 添加或修改检查任务对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="任务名称" prop="taskName">
<el-input v-model="form.taskName" placeholder="请输入任务名称" />

View File

@@ -122,7 +122,7 @@
</div>
<!-- 添加或修改检查任务对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="任务名称" prop="taskName">
<el-input v-model="form.taskName" placeholder="请输入任务名称" />

View File

@@ -0,0 +1,254 @@
<template>
<div class="app-container">
<el-row :gutter="20">
<el-col :span="8">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
label-width="68px">
<el-form-item label="方案名称" prop="templateName">
<el-input v-model="queryParams.templateName" placeholder="请输入方案名称" clearable
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table highlight-current-row border @row-click="handleRowClick" v-loading="loading"
:data="inspectionItemTemplateList" @selection-change="handleSelectionChange">
<el-table-column label="方案名称" align="center" prop="templateName" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize" @pagination="getList" />
<!-- 添加或修改待检项方案对话框 -->
<el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="方案名称" prop="templateName">
<el-input v-model="form.templateName" placeholder="请输入方案名称" />
</el-form-item>
<el-form-item label="方案描述" prop="templateDesc">
<el-input v-model="form.templateDesc" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="待检项" prop="inspectionItem">
<CheckItemTransfer v-model="form.inspectionItem" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</el-col>
<el-col :span="16" v-loading="rightLoading">
<KLPTable v-if="checkItemList.length > 0" v-loading="loading" :data="checkItemList"
@selection-change="handleSelectionChange">
<el-table-column label="检查项名称" align="center" prop="itemName" />
<el-table-column label="标准目标" align="center" prop="standardTarget" />
<el-table-column label="目标上限" align="center" prop="targetUpper" />
<el-table-column label="目标下限" align="center" prop="targetLower" />
<el-table-column label="单位" align="center" prop="unit" />
<el-table-column label="定性定量" align="center" prop="qualitativeQuantitative">
<template slot-scope="scope">
{{ scope.row.qualitativeQuantitative === 0 ? '定性' : '定量' }}
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
</KLPTable>
<el-empty v-else description="暂无数据" />
</el-col>
</el-row>
</div>
</template>
<script>
import { listInspectionItemTemplate, getInspectionItemTemplate, delInspectionItemTemplate, addInspectionItemTemplate, updateInspectionItemTemplate, getInfoByInspectionItem } from "@/api/mes/qc/inspectionItemTemplate";
import CheckItemTransfer from '@/components/KLPService/CheckItemSelect/index'
export default {
name: "InspectionItemTemplate",
components: {
CheckItemTransfer,
},
data() {
return {
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 待检项方案表格数据
inspectionItemTemplateList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
templateName: undefined,
templateDesc: undefined,
inspectionItem: undefined,
},
// 表单参数
form: {},
// 表单校验
rules: {
},
checkItemList: [],
rightLoading: false,
};
},
created() {
this.getList();
},
methods: {
/** 查询待检项方案列表 */
getList() {
this.loading = true;
listInspectionItemTemplate(this.queryParams).then(response => {
this.inspectionItemTemplateList = response.rows;
this.total = response.total;
this.loading = false;
});
},
handleRowClick(row) {
this.rightLoading = true;
getInfoByInspectionItem(row.inspectionItem).then(response => {
this.checkItemList = response.data || [];
this.rightLoading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
templateId: undefined,
templateName: undefined,
templateDesc: undefined,
inspectionItem: undefined,
createBy: undefined,
createTime: undefined,
updateBy: undefined,
updateTime: undefined,
delFlag: undefined,
remark: undefined
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.templateId)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加待检项方案";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.loading = true;
this.reset();
const templateId = row.templateId || this.ids
getInspectionItemTemplate(templateId).then(response => {
this.loading = false;
this.form = response.data;
this.open = true;
this.title = "修改待检项方案";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
if (this.form.templateId != null) {
updateInspectionItemTemplate(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
} else {
addInspectionItemTemplate(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const templateIds = row.templateId || this.ids;
this.$modal.confirm('是否确认删除待检项方案编号为"' + templateIds + '"的数据项?').then(() => {
this.loading = true;
return delInspectionItemTemplate(templateIds);
}).then(() => {
this.loading = false;
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
/** 导出按钮操作 */
handleExport() {
this.download('qc/inspectionItemTemplate/export', {
...this.queryParams
}, `inspectionItemTemplate_${new Date().getTime()}.xlsx`)
}
}
};
</script>

View File

@@ -1,263 +0,0 @@
<template>
<div class="app-container">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
>导出</el-button>
</el-col>
</el-row>
<KLPTable v-loading="loading" :data="bomItemList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="属性名称" align="center" prop="attrKey">
<template slot-scope="scope">
<span>{{ scope.row.attrKey }}</span>
<span v-if="scope.row.remark">
<el-tooltip :content="scope.row.remark" placement="top">
<i class="el-icon-info"></i>
</el-tooltip>
</span>
</template>
</el-table-column>
<el-table-column label="属性值" align="center" prop="attrValue" />
<!-- <el-table-column label="备注" align="center" prop="remark" /> -->
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</KLPTable>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改参数 明细存放属性值对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="属性名称" prop="attrKey">
<el-input v-model="form.attrKey" placeholder="请输入属性名称" />
</el-form-item>
<el-form-item label="属性值" prop="attrValue">
<el-input v-model="form.attrValue" placeholder="请输入属性值" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listBomItem, getBomItem, delBomItem, addBomItem, updateBomItem } from "@/api/wms/bomItem";
export default {
name: "BomItem",
dicts: ['common_swicth'],
props: {
bomId: [String, Number],
},
data() {
return {
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 参数 明细,存放属性–值表格数据
bomItemList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 20,
bomId: this.bomId,
attrKey: undefined,
attrValue: undefined,
isEnabled: undefined,
},
// 表单参数
form: {
bomId: this.bomId,
},
};
},
created() {
this.getList();
},
methods: {
/** 查询参数 明细,存放属性–值列表 */
getList() {
this.loading = true;
listBomItem(this.queryParams).then(response => {
this.bomItemList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
itemId: undefined,
bomId: this.bomId,
attrKey: undefined,
attrValue: undefined,
remark: undefined
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.itemId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加参数 明细,存放属性–值";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.loading = true;
this.reset();
const itemId = row.itemId || this.ids
getBomItem(itemId).then(response => {
this.loading = false;
this.form = response.data;
this.open = true;
this.title = "修改参数 明细,存放属性–值";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
if (this.form.itemId != null) {
updateBomItem(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
} else {
addBomItem(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const itemIds = row.itemId || this.ids;
this.$modal.confirm('是否确认删除参数 明细,存放属性–值编号为"' + itemIds + '"的数据项?').then(() => {
this.loading = true;
return delBomItem(itemIds);
}).then(() => {
this.loading = false;
this.getList();
this.$modal.msgSuccess("删除成功");
this.$store.dispatch('category/getBomMap');
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
/** 导出按钮操作 */
handleExport() {
this.download('wms/bomItem/export', {
...this.queryParams
}, `bomItem_${new Date().getTime()}.xlsx`)
}
}
};
</script>

View File

@@ -1,243 +0,0 @@
<template>
<div class="bom-container">
<!-- 当没有传入id时显示创建按钮 -->
<div v-if="!id" class="create-bom">
<el-button
type="primary"
:loading="createLoading"
:disabled="createLoading"
@click="handleCreate"
class="create-button"
>
<template v-if="!createLoading">
<i class="el-icon-plus"></i> 创建参数
</template>
<template v-else>
创建中...
</template>
</el-button>
</div>
<!-- 当传入id时显示数据区域 -->
<div v-else class="bom-details">
<div v-if="loading" class="loading-indicator">
加载中...
<div class="spinner"></div>
</div>
<div v-if="error" class="error-message">
加载失败: {{ error }}
<button @click="fetchData" class="retry-button">重试</button>
</div>
<div v-if="data && !loading">
<el-form label-width="100px">
<el-form-item label="参数名称">
<el-input v-model="info.bomName" @blur="handleUpdateBom"/>
</el-form-item>
<el-form-item label="参数编码">
<el-input v-model="info.bomCode" @blur="handleUpdateBom"/>
</el-form-item>
</el-form>
<BomItem :bomId="id" />
</div>
</div>
</div>
</template>
<script>
import { addBom, updateBom, getBom } from '@/api/wms/bom';
import { listBomItem } from '@/api/wms/bomItem';
import { updateProduct } from '@/api/wms/product';
import { updateRawMaterial } from '@/api/wms/rawMaterial';
import BomItem from './BomItem.vue';
export default {
props: {
id: [String, Number], // 支持字符串或数字类型的ID
itemId: [String, Number],
type: String // 可选类型参数
},
components: {
BomItem
},
data() {
return {
loading: false,
error: null,
data: null,
info: {},
createLoading: false,
};
},
watch: {
id: {
immediate: true, // 组件创建时立即执行
handler(newVal) {
if (newVal) {
console.log('侦听到变化')
this.fetchBomDetails();
} else {
// 没有ID时重置数据
this.data = null;
this.error = null;
}
}
}
},
methods: {
async fetchBomDetails() {
try {
this.loading = true;
this.error = null;
// 实际项目中替换为真实API调用
const response = await listBomItem({
bomId: this.id
})
this.data = response.rows;
const response2 = await getBom(this.id)
this.info = response2.data;
} catch (err) {
this.error = err.message || '请求失败,请重试';
console.error('获取参数详情失败:', err);
} finally {
this.loading = false;
}
},
async handleCreate() {
// 防止重复点击
if (this.createLoading) return;
try {
this.createLoading = true;
const bomResponse = await addBom({
bomName: (this.type == 'product' ? '产品参数' : '原材料参数') + new Date().getTime(),
bomCode: (this.type == 'product' ? 'P' : 'R') + new Date().getTime()
});
this.$message.success('创建参数成功');
const bomData = bomResponse.data;
// 根据类型更新产品/原材料
if (this.type == 'product' && this.itemId) {
await updateProduct({
productId: this.itemId,
bomId: bomData.bomId
});
} else if (this.type == 'raw_material' && this.itemId) {
await updateRawMaterial({
rawMaterialId: this.itemId,
bomId: bomData.bomId
});
}
this.$store.dispatch('category/getBomMap');
// 触发事件
this.$emit('addBom', bomData);
} catch (error) {
console.error('创建失败:', error);
this.$message.error(`创建失败: ${error.message || '未知错误'}`);
} finally {
this.createLoading = false;
}
},
handleUpdateBom() {
this.$message.warning('正在更新参数...');
updateBom({
bomId: this.id,
bomName: this.info.bomName,
bomCode: this.info.bomCode
}).then(_ => {
this.$message.success('更新参数成功');
this.$store.dispatch('category/getBomMap');
})
},
fetchData() {
// 重试获取数据
if (this.id) this.fetchBomDetails();
}
}
};
</script>
<style scoped>
.create-bom {
text-align: center;
padding: 40px 0;
}
.create-button {
background-color: #4CAF50;
color: white;
border: none;
padding: 12px 24px;
font-size: 16px;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s;
}
.create-button:hover {
background-color: #388E3C;
}
.loading-indicator {
display: flex;
align-items: center;
justify-content: center;
gap: 12px;
padding: 20px;
color: #666;
}
.spinner {
width: 20px;
height: 20px;
border: 3px solid rgba(0,0,0,0.1);
border-radius: 50%;
border-top-color: #3498db;
animation: spin 1s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.error-message {
padding: 20px;
background-color: #ffebee;
color: #d32f2f;
border-radius: 4px;
display: flex;
flex-direction: column;
gap: 12px;
}
.retry-button {
padding: 8px 16px;
background-color: #f44336;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
width: 120px;
}
.bom-info {
margin-top: 20px;
padding: 15px;
background-color: #f9f9f9;
border-radius: 4px;
border-left: 4px solid #2196F3;
}
.bom-info p {
margin: 10px 0;
}
</style>

View File

@@ -93,8 +93,8 @@
</el-form-item>
<el-form-item label="位置" prop="position">
<el-radio-group v-model="form.position">
<el-radio-button v-for="dict in dict.type.coil_abnormal_position" :key="dict.value"
:label="dict.value">{{ dict.label }}</el-radio-button>
<el-radio-button v-for="dict in dict.type.coil_abnormal_position" :key="dict.value" :label="dict.value">{{
dict.label }}</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item label="长度坐标" prop="lengthCoord">
@@ -102,14 +102,14 @@
</el-form-item>
<el-form-item label="缺陷代码" prop="defectCode">
<el-radio-group v-model="form.defectCode">
<el-radio-button v-for="dict in dict.type.coil_abnormal_code" :key="dict.value"
:label="dict.value">{{ dict.label }}</el-radio-button>
<el-radio-button v-for="dict in dict.type.coil_abnormal_code" :key="dict.value" :label="dict.value">{{
dict.label }}</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item label="程度" prop="degree">
<el-radio-group v-model="form.degree">
<el-radio-button v-for="dict in dict.type.coil_abnormal_degree" :key="dict.value"
:label="dict.value">{{ dict.label }}</el-radio-button>
<el-radio-button v-for="dict in dict.type.coil_abnormal_degree" :key="dict.value" :label="dict.value">{{
dict.label }}</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item label="备注" prop="remark">
@@ -127,8 +127,8 @@
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="判级" prop="judgeLevel">
<el-radio-group v-model="form.judgeLevel">
<el-radio-button v-for="dict in dict.type.coil_abnormal_level" :key="dict.value"
:label="dict.value">{{ dict.label }}</el-radio-button>
<el-radio-button v-for="dict in dict.type.coil_abnormal_level" :key="dict.value" :label="dict.value">{{
dict.label }}</el-radio-button>
</el-radio-group>
</el-form-item>
</el-form>
@@ -198,10 +198,10 @@ export default {
watch: {
'$route.query.coilId': {
handler(newVal, oldVal) {
if (newVal !== oldVal) {
// if (newVal !== oldVal) {
this.queryParams.coilId = newVal
this.handleQuery()
}
// }
},
immediate: true
}

View File

@@ -3,21 +3,17 @@
<!-- 搜索栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
<el-form-item label="钢卷号" prop="currentCoilNo">
<el-input
v-model="queryParams.currentCoilNo"
placeholder="请输入钢卷号"
clearable
@keyup.enter.native="handleQuery"
/>
<el-input v-model="queryParams.currentCoilNo" placeholder="请输入钢卷号" clearable
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="操作类型" prop="actionType">
<el-select v-model="queryParams.actionType" placeholder="请选择操作类型">
<el-option v-for="item in dict.type.action_type" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="只看待操作" prop="actionStatus">
<el-switch @change="switchActionStatus" v-model="queryParams.actionSwitch" />
</el-form-item>
<el-form-item label="操作类型" prop="actionType">
<el-select v-model="queryParams.actionType" placeholder="请选择操作类型">
<el-option v-for="item in dict.type.action_type" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="只看待操作" prop="actionStatus">
<el-switch @change="switchActionStatus" v-model="queryParams.actionSwitch"/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
@@ -27,45 +23,22 @@
<!-- 工具栏 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增</el-button>
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
>删除</el-button>
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple"
@click="handleDelete">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-refresh"
size="mini"
@click="handleRefresh"
:disabled="buttonLoading"
v-loading="buttonLoading"
>刷新</el-button>
<el-button type="warning" plain icon="el-icon-refresh" size="mini" @click="handleRefresh"
:disabled="buttonLoading" v-loading="buttonLoading">刷新</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<!-- 数据表格 -->
<el-table
v-loading="loading"
:data="actionList"
@selection-change="handleSelectionChange"
:row-class-name="tableRowClassName"
>
<el-table v-loading="loading" :data="actionList" @selection-change="handleSelectionChange"
:row-class-name="tableRowClassName">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" type="index" width="60" align="center" />
@@ -75,15 +48,15 @@
</template>
</el-table-column>
<el-table-column label="操作类型" align="center" prop="actionType" width="160" >
<el-table-column label="操作类型" align="center" prop="actionType" width="160">
<template slot-scope="scope">
<span v-if="scope.row.actionType===5">移库操作已在移动端完成</span>
<span v-else-if="scope.row.actionType===4">发货操作已在移动端完成</span>
<span v-else-if="scope.row.actionType===401">入库操作</span>
<span v-else-if="scope.row.actionType===402">发货操作</span>
<span v-else-if="scope.row.actionType===403">移库操作</span>
<span v-else-if="scope.row.actionType===404">通过库区编辑钢卷</span>
<dict-tag v-else :options='dict.type.action_type' :value="scope.row.actionType "></dict-tag>
<span v-if="scope.row.actionType === 5">移库操作已在移动端完成</span>
<span v-else-if="scope.row.actionType === 4">发货操作已在移动端完成</span>
<span v-else-if="scope.row.actionType === 401">入库操作</span>
<span v-else-if="scope.row.actionType === 402">发货操作</span>
<span v-else-if="scope.row.actionType === 403">移库操作</span>
<span v-else-if="scope.row.actionType === 404">通过库区编辑钢卷</span>
<dict-tag v-else :options='dict.type.action_type' :value="scope.row.actionType"></dict-tag>
</template>
</el-table-column>
@@ -136,59 +109,27 @@
<template slot-scope="scope">
<!-- 待处理状态显示操作按钮 -->
<template v-if="scope.row.actionStatus === 0">
<el-button
size="mini"
type="primary"
icon="el-icon-edit"
@click="handleProcess(scope.row)"
v-loading="buttonLoading"
:disabled="buttonLoading"
>操作</el-button>
<el-button
size="mini"
type="danger"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</el-button>
<el-button size="mini" type="primary" icon="el-icon-edit" @click="handleProcess(scope.row)"
v-loading="buttonLoading" :disabled="buttonLoading">操作</el-button>
<el-button size="mini" type="danger" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
</template>
<!-- 处理中状态显示继续按钮 -->
<template v-else-if="scope.row.actionStatus === 1">
<el-button
size="mini"
type="warning"
icon="el-icon-edit"
@click="handleProcess(scope.row)"
:disabled="buttonLoading"
v-loading="buttonLoading"
>继续</el-button>
<el-button
size="mini"
type="info"
icon="el-icon-close"
@click="handleCancel(scope.row)"
>取消</el-button>
<el-button size="mini" type="warning" icon="el-icon-edit" @click="handleProcess(scope.row)"
:disabled="buttonLoading" v-loading="buttonLoading">继续</el-button>
<el-button size="mini" type="info" icon="el-icon-close" @click="handleCancel(scope.row)">取消</el-button>
</template>
<!-- 已完成或已取消状态显示删除按钮 -->
<template v-else>
<el-button
size="mini"
type="danger"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</el-button>
<el-button size="mini" type="danger" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
</template>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="getList" />
<!-- 添加或修改对话框 -->
<el-dialog :title="title" :visible.sync="open" width="1200px" append-to-body>
@@ -202,12 +143,8 @@
<div class="card-section" v-if="splitTypes.length > 0">
<div class="section-title">分条操作</div>
<div class="action-cards-row">
<div
v-for="item in splitTypes"
:key="item.value"
class="action-card split-card"
:class="{ 'active': form.actionType == item.value }"
@click="form.actionType = parseInt(item.value)">
<div v-for="item in splitTypes" :key="item.value" class="action-card split-card"
:class="{ 'active': form.actionType == item.value }" @click="form.actionType = parseInt(item.value)">
<div class="card-icon">
<i :class="getActionIcon(item.value)"></i>
</div>
@@ -218,17 +155,13 @@
</div>
</div>
</div>
<!-- 其他操作区 -->
<div class="card-section" v-if="otherTypes.length > 0">
<div class="section-title">其他操作</div>
<div class="action-cards-row">
<div
v-for="item in otherTypes"
:key="item.value"
class="action-card"
:class="{ 'active': form.actionType == item.value }"
@click="form.actionType = parseInt(item.value)">
<div v-for="item in otherTypes" :key="item.value" class="action-card"
:class="{ 'active': form.actionType == item.value }" @click="form.actionType = parseInt(item.value)">
<div class="card-icon">
<i :class="getActionIcon(item.value)"></i>
</div>
@@ -253,7 +186,8 @@
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm" :disabled="buttonLoading" v-loading="buttonLoading"> </el-button>
<el-button type="primary" @click="submitForm" :disabled="buttonLoading" v-loading="buttonLoading">
</el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
@@ -464,7 +398,7 @@ export default {
}).then(() => {
this.getList();
this.$message.success('删除成功');
}).catch(() => {});
}).catch(() => { });
},
/** 处理操作 - 跳转到对应页面 */
handleProcess(row) {
@@ -485,17 +419,17 @@ export default {
// 根据操作类型跳转到不同页面
let path = '';
// 分条操作100-199
if (actionType >= 100 && actionType <= 199) {
path = '/wms/split';
}
}
// 合卷操作200-299
else if (actionType == 200) {
path = '/wms/merge';
}
// 其他操作类型
else{
else {
path = '/wms/typing';
}
@@ -540,7 +474,7 @@ export default {
}).then(() => {
this.$message.success('操作已取消');
this.getList();
}).catch(() => {});
}).catch(() => { });
},
/** 刷新列表 */
handleRefresh() {
@@ -552,8 +486,8 @@ export default {
// 每30秒自动刷新一次用于移动端扫码后自动更新列表
this.refreshTimer = setInterval(() => {
// 只在查看待处理状态时自动刷新
this.getList();
// 只在查看待处理状态时自动刷新
this.getList();
}, 30000);
},
/** 表格行样式 */
@@ -653,15 +587,15 @@ export default {
/* 操作类型卡片样式 */
.action-type-cards {
width: 100%;
.card-section {
margin-bottom: 24px;
&:last-child {
margin-bottom: 0;
}
}
.section-title {
font-size: 14px;
font-weight: 600;
@@ -670,18 +604,18 @@ export default {
padding-left: 8px;
border-left: 3px solid #409eff;
}
// 分条操作区域的特殊样式
.card-section:first-child .section-title {
border-left-color: #e6a23c;
}
.action-cards-row {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
gap: 12px;
}
.action-card {
min-width: 0;
padding: 16px;
@@ -693,50 +627,50 @@ export default {
display: flex;
align-items: center;
gap: 12px;
&:hover {
border-color: #409eff;
box-shadow: 0 2px 12px 0 rgba(64, 158, 255, 0.15);
transform: translateY(-2px);
}
&.active {
border-color: #409eff;
background: linear-gradient(135deg, #e3f2fd 0%, #f0f7ff 100%);
box-shadow: 0 2px 12px 0 rgba(64, 158, 255, 0.3);
.card-icon {
background: linear-gradient(135deg, #409eff 0%, #66b1ff 100%);
color: #fff;
}
.card-title {
color: #409eff;
font-weight: 600;
}
}
&.split-card {
&.active {
background: linear-gradient(135deg, #fff3e0 0%, #fff8f0 100%);
border-color: #e6a23c;
.card-icon {
background: linear-gradient(135deg, #e6a23c 0%, #f0ad4e 100%);
}
.card-title {
color: #e6a23c;
}
}
&:hover {
border-color: #e6a23c;
box-shadow: 0 2px 12px 0 rgba(230, 162, 60, 0.15);
}
}
}
.card-icon {
width: 48px;
height: 48px;
@@ -750,11 +684,11 @@ export default {
transition: all 0.3s ease;
flex-shrink: 0;
}
.card-content {
flex: 1;
}
.card-title {
font-size: 16px;
font-weight: 500;
@@ -762,7 +696,7 @@ export default {
margin-bottom: 4px;
transition: all 0.3s ease;
}
.card-desc {
font-size: 13px;
color: #909399;

View File

@@ -259,9 +259,9 @@
</div>
</el-dialog>
<el-dialog title="参数" @close="bomDialogVisible = false" :visible.sync="bomDialogVisible" width="600px" append-to-body>
<!-- <el-dialog title="参数" @close="bomDialogVisible = false" :visible.sync="bomDialogVisible" width="600px" append-to-body>
<BomPanel :id="bomId" type="product" @addBom="handleAddBom" :itemId="itemId" />
</el-dialog>
</el-dialog> -->
</div>
</template>
@@ -270,7 +270,7 @@ import { listProduct, getProduct, delProduct, addProduct, updateProduct } from "
import CategorySelect from '@/components/KLPService/CategorySelect';
import CategoryRenderer from '@/components/KLPService/Renderer/CategoryRenderer.vue';
import UserSelect from '@/components/KLPService/UserSelect';
import BomPanel from '../bom/components/BomPanel.vue';
// import BomPanel from '../bom/components/BomPanel.vue';
import BomInfoMini from '@/components/KLPService/Renderer/BomInfoMini.vue';
export default {
@@ -279,7 +279,7 @@ export default {
CategorySelect,
CategoryRenderer,
UserSelect,
BomPanel,
// BomPanel,
BomInfoMini
},
dicts: ['common_swicth'],

View File

@@ -148,7 +148,7 @@ export default {
const layerData = layerMap[layer];
const totalGrid = layerData.maxRow * layerData.maxColumn;
layerData.emptyCount = Math.max(0, totalGrid - layerData.warehouses.length);
// 按行号+列号排序
layerData.warehouses.sort((a, b) => {
if (a.parsedInfo.row !== b.parsedInfo.row) {
@@ -240,7 +240,7 @@ export default {
}
.occupied {
background-color: #c0c4cc;
background-color: #eeff6f;
}
.legend-text {
@@ -253,6 +253,7 @@ export default {
// 分层容器样式
.layers-container {
display: flex;
.layer-section {
flex: 1;
max-width: 50%;

View File

@@ -2,18 +2,15 @@
<div>
<div style="display: flex; align-items: center;">
<el-divider content-position="left">{{ layer }}层库位</el-divider>
<!-- 转置按钮 -->
<el-button type="text" icon="el-icon-refresh-left" size="mini" @click="toggleTranspose">
{{ isTransposed ? '恢复行列' : '行列转置' }}
</el-button>
</div>
<div class="grid-wrapper">
<!-- 核心滚动容器列标尺 + 网格区域共享滚动条 -->
<div class="grid-scroll-container" ref="scrollContainerRef">
<!-- 滚动内容容器列标尺 + 行标尺+网格 -->
<div class="scroll-content">
<div class="scroll-content" ref="contentRef">
<!-- 列标尺顶部 -->
<div class="col-ruler">
<div class="col-ruler" :style="{ '--cell-width': `${cellWidth}px` }">
<div class="ruler-empty"></div>
<div v-for="col in transposedLayerData.maxColumn" :key="`col-${layer}-${col}`" class="ruler-item">
{{ col }}
@@ -29,9 +26,12 @@
</div>
</div>
<!-- 库位网格 -->
<div class="grid-container"
:style="{ gridTemplateColumns: `repeat(${transposedLayerData.maxColumn}, 60px)` }">
<!-- 库位网格 - 修复伪元素遮挡问题 -->
<div class="grid-container"
:style="{
'--cell-width': `${cellWidth}px`,
'--column-count': transposedLayerData.maxColumn
}">
<!-- 库位格子 -->
<div v-for="warehouse in transposedLayerData.warehouses" :key="warehouse.actualWarehouseId"
class="warehouse-cell" :class="{ disabled: warehouse.isEnabled === 0 }"
@@ -49,23 +49,20 @@
</div>
</div>
<!-- 库位详情弹窗 -->
<!-- 弹窗修复改回 .sync 绑定恢复 footer 插槽写法 -->
<el-dialog title="库位详情" :visible.sync="dialogVisible" width="600px" destroy-on-close append-to-body center>
<el-descriptions :column="2" border size="small" v-if="currentWarehouse">
<el-descriptions-item label="库位编码">{{ currentWarehouse.actualWarehouseCode }}</el-descriptions-item>
<el-descriptions-item label="库位名称">{{ currentWarehouse.actualWarehouseName || '无' }}</el-descriptions-item>
<el-descriptions-item label="所属层级">{{ currentWarehouse.parsedInfo.layer || '未知' }}</el-descriptions-item>
<!-- 弹窗内行列显示适配转置状态 -->
<el-descriptions-item label="行号">
{{ isTransposed ? currentWarehouse.parsedInfo.column : currentWarehouse.parsedInfo.row || '未知' }}
</el-descriptions-item>
<el-descriptions-item label="列号">
{{ isTransposed ? currentWarehouse.parsedInfo.row : currentWarehouse.parsedInfo.column || '未知' }}
</el-descriptions-item>
<el-descriptions-item label="一级编码">{{ currentWarehouse.parsedInfo.warehouseFirst || '未知'
}}</el-descriptions-item>
<el-descriptions-item label="二级编码">{{ currentWarehouse.parsedInfo.warehouseSecond || '未知'
}}</el-descriptions-item>
<el-descriptions-item label="一级编码">{{ currentWarehouse.parsedInfo.warehouseFirst || '未知' }}</el-descriptions-item>
<el-descriptions-item label="二级编码">{{ currentWarehouse.parsedInfo.warehouseSecond || '未知' }}</el-descriptions-item>
<el-descriptions-item label="启用状态">
<el-tag :type="currentWarehouse.isEnabled === 1 ? 'success' : 'danger'">
{{ currentWarehouse.isEnabled === 1 ? '启用' : '禁用' }}
@@ -83,7 +80,6 @@
</el-dialog>
</div>
</div>
</template>
<script>
@@ -93,12 +89,10 @@ export default {
name: "WarehouseGrid",
components: { QRCode },
props: {
// 层号
layer: {
type: [String, Number],
required: true
},
// 层数据
layerData: {
type: Object,
required: true,
@@ -112,27 +106,21 @@ export default {
},
data() {
return {
// 弹窗状态
dialogVisible: false,
currentWarehouse: null,
// 转置状态false-原始布局 | true-行列转置
isTransposed: false
isTransposed: false,
containerWidth: 0,
resizeTimer: null
};
},
computed: {
/**
* 处理转置后的层数据(视图层映射,不修改原数据)
*/
transposedLayerData() {
const { maxRow, maxColumn, warehouses } = this.layerData;
// 转置后的基础行列数
const transMaxRow = this.isTransposed ? maxColumn : maxRow;
const transMaxColumn = this.isTransposed ? maxRow : maxColumn;
// 深拷贝库位数据,避免修改原数据
// 深拷贝避免修改原数据
const transWarehouses = JSON.parse(JSON.stringify(warehouses)).map(item => {
// 转置时互换行列解析值
if (this.isTransposed && item.parsedInfo) {
const { row, column } = item.parsedInfo;
item.parsedInfo.row = column;
@@ -141,7 +129,7 @@ export default {
return item;
});
// 转置后重新排序(原:行→列 | 转置:列→行)
// 排序保证网格展示顺序正确
transWarehouses.sort((a, b) => {
if (a.parsedInfo.row !== b.parsedInfo.row) {
return a.parsedInfo.row - b.parsedInfo.row;
@@ -149,7 +137,6 @@ export default {
return a.parsedInfo.column - b.parsedInfo.column;
});
// 转置后重新计算空占位数量
const totalGrid = transMaxRow * transMaxColumn;
const emptyCount = Math.max(0, totalGrid - transWarehouses.length);
@@ -159,23 +146,55 @@ export default {
warehouses: transWarehouses,
emptyCount
};
},
cellWidth() {
if (!this.containerWidth || this.transposedLayerData.maxColumn === 0) return 60;
// 容器可用宽度 = 滚动容器宽度 - 行标尺宽度(30px)
const availableWidth = Math.max(0, this.containerWidth - 30);
// 均分宽度最小60px
const averageWidth = availableWidth / this.transposedLayerData.maxColumn;
return Math.max(60, averageWidth);
}
},
watch: {
isTransposed() {
this.calcContainerWidth();
},
layerData: {
deep: true,
handler() {
this.calcContainerWidth();
}
}
},
mounted() {
this.calcContainerWidth();
window.addEventListener('resize', this.handleResize);
},
beforeUnmount() {
window.removeEventListener('resize', this.handleResize);
clearTimeout(this.resizeTimer);
},
methods: {
/**
* 切换转置状态
*/
calcContainerWidth() {
if (this.$refs.scrollContainerRef) {
this.containerWidth = this.$refs.scrollContainerRef.clientWidth;
}
},
handleResize() {
clearTimeout(this.resizeTimer);
this.resizeTimer = setTimeout(() => {
this.calcContainerWidth();
}, 100);
},
toggleTranspose() {
this.isTransposed = !this.isTransposed;
// 重置弹窗选中状态(可选)
this.dialogVisible = false;
this.currentWarehouse = null;
},
/**
* 点击库位格子展示详情
*/
// 修复点击事件:增加日志便于调试,确保赋值正确
handleCellClick(warehouse) {
console.log('点击库位:', warehouse); // 调试用
this.currentWarehouse = warehouse;
this.dialogVisible = true;
}
@@ -189,68 +208,41 @@ export default {
border-radius: 8px;
overflow: hidden;
width: 100%;
position: relative; // 为转置按钮提供定位上下文
min-height: 100px; // 防止空数据时高度为0
position: relative;
min-height: 100px;
}
// 转置按钮(固定位置)
.transpose-btn {
position: absolute;
top: 8px;
right: 8px;
z-index: 20; // 高于滚动容器
color: #409eff;
height: 30px;
line-height: 30px;
padding: 0 8px;
background: rgba(255, 255, 255, 0.9);
border-radius: 4px;
&:hover {
color: #1e88e5;
background: #e8f4ff;
}
}
// 核心滚动容器:横向滚动,列标尺+网格共享滚动条
.grid-scroll-container {
width: 100%;
overflow-x: auto;
overflow-y: hidden;
position: relative;
padding-bottom: 8px; // 给滚动条留空间
padding-bottom: 8px;
// 优化滚动条样式
&::-webkit-scrollbar {
height: 8px;
}
&::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 4px;
}
&::-webkit-scrollbar-thumb {
background: #c1c1c1;
border-radius: 4px;
&:hover {
background: #a8a8a8;
}
}
// 兼容非webkit浏览器
scrollbar-width: thin;
scrollbar-color: #c1c1c1 #f1f1f1;
}
// 滚动内容容器:列标尺 + 行标尺+网格
.scroll-content {
display: inline-block;
background: #fff;
min-width: 100%;
}
// 列标尺样式
.col-ruler {
display: flex;
height: 30px;
@@ -268,7 +260,8 @@ export default {
}
.ruler-item {
width: 60px;
width: var(--cell-width);
min-width: 60px;
text-align: center;
font-weight: 600;
color: #606266;
@@ -278,13 +271,11 @@ export default {
}
}
// 行标尺 + 网格容器
.row-grid-wrapper {
display: flex;
width: 100%;
}
// 行标尺样式
.row-ruler {
width: 30px;
background: #eef2f7;
@@ -302,16 +293,26 @@ export default {
}
}
// 库位网格容器
.grid-container {
display: grid;
gap: 0;
display: flex;
flex-wrap: wrap;
width: 100%;
box-sizing: border-box;
// 库位格子
// 修复伪元素遮挡点击事件:添加 pointer-events: none
&::before {
content: '';
width: calc(var(--cell-width) * var(--column-count));
display: block;
height: 0;
visibility: hidden;
pointer-events: none; // 关键:让伪元素不拦截点击事件
}
.warehouse-cell {
width: var(--cell-width);
min-width: 60px;
height: 60px;
width: 60px;
border: 1px solid #e6e6e6;
border-radius: 0;
display: flex;
@@ -322,51 +323,44 @@ export default {
transition: all 0.2s;
box-sizing: border-box;
margin: 0;
flex-shrink: 0;
position: relative; // 确保层级正常
z-index: 1; // 高于伪元素
&:hover {
border-color: #409eff;
background: #e8f4ff;
z-index: 1;
z-index: 2;
}
&.disabled {
background: #f5f5f5;
background: #eeff6f;
color: #909399;
cursor: not-allowed;
&:hover {
border-color: #e6e6e6;
background: #f5f5f5;
background: #eeff6f;
}
}
.cell-name {
font-size: 12px;
color: #606266;
word-break: break-all;
text-align: center;
padding: 0 2px;
}
}
// 空占位格子
.empty-cell {
background: #fafafa;
border-style: solid;
border-color: #e6e6e6;
pointer-events: none; // 空格子不需要点击事件
.cell-code {
color: #c0c4cc;
}
}
}
// 弹窗样式优化
::v-deep(.el-descriptions) {
.el-descriptions-item__label {
font-weight: 500;
color: #606266;
}
.el-descriptions-item__content {
color: #303133;
}
}
</style>

View File

@@ -4,23 +4,15 @@
<div class="layout-container">
<!-- 左侧树形结构 -->
<div class="tree-container" v-loading="treeLoading">
<el-tree
ref="warehouseTreeRef"
:data="warehouseTree"
:props="treeProps"
node-key="actualWarehouseId"
@node-click="handleNodeClick"
:expand-on-click-node="false"
highlight-current
class="warehouse-tree"
:disabled="isSwitching"
>
<el-tree ref="warehouseTreeRef" :data="warehouseTree" :props="treeProps" node-key="actualWarehouseId"
@node-click="handleNodeClick" :expand-on-click-node="false" highlight-current class="warehouse-tree"
:disabled="isSwitching">
</el-tree>
</div>
<!-- 右侧仓库信息区域 - 替换为 Bird 组件 -->
<div class="warehouse-container" v-if="selectedNodeId" v-loading="rightLoading"
element-loading-text="加载中..." element-loading-spinner="el-icon-loading">
<div class="warehouse-container" v-if="selectedNodeId" v-loading="rightLoading" element-loading-text="加载中..."
element-loading-spinner="el-icon-loading">
<WarehouseBird :warehouse-list="warehouseList" @open-init-dialog="openInitDialog" />
</div>
@@ -39,16 +31,10 @@
<div class="selector-tip">
拖动/点击选择网格范围当前{{ initForm.rowCount || 0 }} × {{ initForm.columnCount || 0 }}
</div>
<div class="grid-selector"
@mousemove="handleGridHover"
@click="confirmGridSelect"
@mouseleave="resetGridHover">
<div class="grid-selector" @mousemove="handleGridHover" @click="confirmGridSelect"
@mouseleave="resetGridHover">
<div v-for="row in 40" :key="`grid-row-${row}`" class="grid-selector-row">
<div
v-for="col in 10"
:key="`grid-col-${col}`"
class="grid-selector-cell"
:class="{
<div v-for="col in 10" :key="`grid-col-${col}`" class="grid-selector-cell" :class="{
hovered: row <= hoverRow && col <= hoverCol,
selected: row <= initForm.rowCount && col <= initForm.columnCount
}">
@@ -154,7 +140,7 @@ export default {
this.rightLoading = true;
this.selectedNodeId = node.actualWarehouseId;
this.selectedNode = node;
this.getWarehouseList(node.actualWarehouseId)
.finally(() => {
this.rightLoading = false;
@@ -308,13 +294,6 @@ export default {
padding: 16px;
box-sizing: border-box;
overflow-y: auto;
.warehouse-tree {
--el-tree-text-color: #303133;
--el-tree-node-hover-bg-color: #e8f4ff;
--el-tree-current-bg-color: #409eff;
--el-tree-current-text-color: #fff;
}
}
.warehouse-container {
@@ -354,7 +333,6 @@ export default {
overflow: auto;
border: 1px solid #e6e6e6;
background: #fafafa;
cursor: crosshair;
.grid-selector-row {
display: flex;
@@ -384,8 +362,4 @@ export default {
}
}
}
::v-deep(.el-form-item) {
margin-bottom: 16px;
}
</style>