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> <template>
<el-select <div class="check-item-transfer">
v-model="selected" <!-- Element-UI穿梭框核心组件 -->
multiple <el-transfer v-model="internalValue" :data="transferData" :titles="['待选检查项', '已选检查项']" :props="transferProps"
filterable @change="handleTransferChange" filterable filter-placeholder="请输入检查项名称搜索" v-loading="loading" :disabled="loading">
placeholder="请选择检查项" <!-- 自定义选项内容单根节点包裹解决Vue2警告 -->
@change="handleChange" <template slot-scope="{ option }">
size="mini" <span class="transfer-option-content">
style="width: 100%;" <span>{{ option.itemName }}</span>
> <span style="margin-left: 8px; color: #999; font-size: 12px">
<el-option ({{ option.qualitativeQuantitative === 0 ? '定性' : '定量' }})
v-for="item in checkItems" </span>
:key="item.itemId" </span>
:label="item.itemName" </template>
:value="item.itemId" <div class="transfer-footer" style="display: flex; justify-content: center; align-items: center; height: 40px;"
/> slot="right-footer">
</el-select> <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> </template>
<script> <script>
import { listCheckItem } from '@/api/mes/qc/checkItem' import { listCheckItem } from "@/api/mes/qc/checkItem";
import { listInspectionItemTemplate } from "@/api/mes/qc/inspectionItemTemplate";
export default { export default {
name: 'CheckItemSelect', name: "CheckItemTransfer",
// 接收外部v-model绑定的itemIds字符串逗号分隔
props: { props: {
modelValue: { value: {
type: Array, type: String,
default: () => [] default: ""
} }
}, },
emits: ['update:modelValue'],
data() { data() {
return { 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: { watch: {
modelValue(val) { // 监听外部传入的value变化同步到内部选中值
this.selected = val.slice() value: {
} immediate: true, // 初始化时立即执行
}, handler(newVal) {
methods: { if (newVal && typeof newVal === "string") {
handleChange(val) { // 字符串转数字数组(过滤空值,统一类型)
this.$emit('input', val) this.internalValue = newVal
}, .split(",")
async fetchCheckItems() { .filter(Boolean) // 过滤空字符串
try { .map(id => id.toString()); // 统一转为字符串类型
const res = await listCheckItem({ pageSize: 1000 }) } else {
this.checkItems = res.rows this.internalValue = [];
} catch (e) { }
this.checkItems = []
} }
} }
}, },
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() { // 修复1统一itemId为字符串类型避免字符串/数字不匹配)
this.fetchCheckItems() 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> </script>
<style scoped> <style scoped>
.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> </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> </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 ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="任务名称" prop="taskName"> <el-form-item label="任务名称" prop="taskName">
<el-input v-model="form.taskName" placeholder="请输入任务名称" /> <el-input v-model="form.taskName" placeholder="请输入任务名称" />

View File

@@ -122,7 +122,7 @@
</div> </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 ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="任务名称" prop="taskName"> <el-form-item label="任务名称" prop="taskName">
<el-input v-model="form.taskName" placeholder="请输入任务名称" /> <el-input v-model="form.taskName" placeholder="请输入任务名称" />

View File

@@ -128,7 +128,7 @@
</div> </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 ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="任务名称" prop="taskName"> <el-form-item label="任务名称" prop="taskName">
<el-input v-model="form.taskName" placeholder="请输入任务名称" /> <el-input v-model="form.taskName" placeholder="请输入任务名称" />

View File

@@ -122,7 +122,7 @@
</div> </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 ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="任务名称" prop="taskName"> <el-form-item label="任务名称" prop="taskName">
<el-input v-model="form.taskName" placeholder="请输入任务名称" /> <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>
<el-form-item label="位置" prop="position"> <el-form-item label="位置" prop="position">
<el-radio-group v-model="form.position"> <el-radio-group v-model="form.position">
<el-radio-button v-for="dict in dict.type.coil_abnormal_position" :key="dict.value" <el-radio-button v-for="dict in dict.type.coil_abnormal_position" :key="dict.value" :label="dict.value">{{
:label="dict.value">{{ dict.label }}</el-radio-button> dict.label }}</el-radio-button>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="长度坐标" prop="lengthCoord"> <el-form-item label="长度坐标" prop="lengthCoord">
@@ -102,14 +102,14 @@
</el-form-item> </el-form-item>
<el-form-item label="缺陷代码" prop="defectCode"> <el-form-item label="缺陷代码" prop="defectCode">
<el-radio-group v-model="form.defectCode"> <el-radio-group v-model="form.defectCode">
<el-radio-button v-for="dict in dict.type.coil_abnormal_code" :key="dict.value" <el-radio-button v-for="dict in dict.type.coil_abnormal_code" :key="dict.value" :label="dict.value">{{
:label="dict.value">{{ dict.label }}</el-radio-button> dict.label }}</el-radio-button>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="程度" prop="degree"> <el-form-item label="程度" prop="degree">
<el-radio-group v-model="form.degree"> <el-radio-group v-model="form.degree">
<el-radio-button v-for="dict in dict.type.coil_abnormal_degree" :key="dict.value" <el-radio-button v-for="dict in dict.type.coil_abnormal_degree" :key="dict.value" :label="dict.value">{{
:label="dict.value">{{ dict.label }}</el-radio-button> dict.label }}</el-radio-button>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remark">
@@ -127,8 +127,8 @@
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="判级" prop="judgeLevel"> <el-form-item label="判级" prop="judgeLevel">
<el-radio-group v-model="form.judgeLevel"> <el-radio-group v-model="form.judgeLevel">
<el-radio-button v-for="dict in dict.type.coil_abnormal_level" :key="dict.value" <el-radio-button v-for="dict in dict.type.coil_abnormal_level" :key="dict.value" :label="dict.value">{{
:label="dict.value">{{ dict.label }}</el-radio-button> dict.label }}</el-radio-button>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-form> </el-form>
@@ -198,10 +198,10 @@ export default {
watch: { watch: {
'$route.query.coilId': { '$route.query.coilId': {
handler(newVal, oldVal) { handler(newVal, oldVal) {
if (newVal !== oldVal) { // if (newVal !== oldVal) {
this.queryParams.coilId = newVal this.queryParams.coilId = newVal
this.handleQuery() this.handleQuery()
} // }
}, },
immediate: true 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 :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
<el-form-item label="钢卷号" prop="currentCoilNo"> <el-form-item label="钢卷号" prop="currentCoilNo">
<el-input <el-input v-model="queryParams.currentCoilNo" placeholder="请输入钢卷号" clearable
v-model="queryParams.currentCoilNo" @keyup.enter.native="handleQuery" />
placeholder="请输入钢卷号" </el-form-item>
clearable <el-form-item label="操作类型" prop="actionType">
@keyup.enter.native="handleQuery" <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-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-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <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-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
@@ -27,45 +23,22 @@
<!-- 工具栏 --> <!-- 工具栏 -->
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple"
type="danger" @click="handleDelete">删除</el-button>
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
>删除</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button type="warning" plain icon="el-icon-refresh" size="mini" @click="handleRefresh"
type="warning" :disabled="buttonLoading" v-loading="buttonLoading">刷新</el-button>
plain
icon="el-icon-refresh"
size="mini"
@click="handleRefresh"
:disabled="buttonLoading"
v-loading="buttonLoading"
>刷新</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<!-- 数据表格 --> <!-- 数据表格 -->
<el-table <el-table v-loading="loading" :data="actionList" @selection-change="handleSelectionChange"
v-loading="loading" :row-class-name="tableRowClassName">
:data="actionList"
@selection-change="handleSelectionChange"
:row-class-name="tableRowClassName"
>
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" type="index" width="60" align="center" /> <el-table-column label="序号" type="index" width="60" align="center" />
@@ -75,15 +48,15 @@
</template> </template>
</el-table-column> </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"> <template slot-scope="scope">
<span v-if="scope.row.actionType===5">移库操作已在移动端完成</span> <span v-if="scope.row.actionType === 5">移库操作已在移动端完成</span>
<span v-else-if="scope.row.actionType===4">发货操作已在移动端完成</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 === 401">入库操作</span>
<span v-else-if="scope.row.actionType===402">发货操作</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 === 403">移库操作</span>
<span v-else-if="scope.row.actionType===404">通过库区编辑钢卷</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> <dict-tag v-else :options='dict.type.action_type' :value="scope.row.actionType"></dict-tag>
</template> </template>
</el-table-column> </el-table-column>
@@ -136,59 +109,27 @@
<template slot-scope="scope"> <template slot-scope="scope">
<!-- 待处理状态显示操作按钮 --> <!-- 待处理状态显示操作按钮 -->
<template v-if="scope.row.actionStatus === 0"> <template v-if="scope.row.actionStatus === 0">
<el-button <el-button size="mini" type="primary" icon="el-icon-edit" @click="handleProcess(scope.row)"
size="mini" v-loading="buttonLoading" :disabled="buttonLoading">操作</el-button>
type="primary" <el-button size="mini" type="danger" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
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>
<!-- 处理中状态显示继续按钮 --> <!-- 处理中状态显示继续按钮 -->
<template v-else-if="scope.row.actionStatus === 1"> <template v-else-if="scope.row.actionStatus === 1">
<el-button <el-button size="mini" type="warning" icon="el-icon-edit" @click="handleProcess(scope.row)"
size="mini" :disabled="buttonLoading" v-loading="buttonLoading">继续</el-button>
type="warning" <el-button size="mini" type="info" icon="el-icon-close" @click="handleCancel(scope.row)">取消</el-button>
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>
<!-- 已完成或已取消状态显示删除按钮 --> <!-- 已完成或已取消状态显示删除按钮 -->
<template v-else> <template v-else>
<el-button <el-button size="mini" type="danger" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
size="mini"
type="danger"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</el-button>
</template> </template>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 分页 --> <!-- 分页 -->
<pagination <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
v-show="total>0" @pagination="getList" />
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改对话框 --> <!-- 添加或修改对话框 -->
<el-dialog :title="title" :visible.sync="open" width="1200px" append-to-body> <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="card-section" v-if="splitTypes.length > 0">
<div class="section-title">分条操作</div> <div class="section-title">分条操作</div>
<div class="action-cards-row"> <div class="action-cards-row">
<div <div v-for="item in splitTypes" :key="item.value" class="action-card split-card"
v-for="item in splitTypes" :class="{ 'active': form.actionType == item.value }" @click="form.actionType = parseInt(item.value)">
:key="item.value"
class="action-card split-card"
:class="{ 'active': form.actionType == item.value }"
@click="form.actionType = parseInt(item.value)">
<div class="card-icon"> <div class="card-icon">
<i :class="getActionIcon(item.value)"></i> <i :class="getActionIcon(item.value)"></i>
</div> </div>
@@ -223,12 +160,8 @@
<div class="card-section" v-if="otherTypes.length > 0"> <div class="card-section" v-if="otherTypes.length > 0">
<div class="section-title">其他操作</div> <div class="section-title">其他操作</div>
<div class="action-cards-row"> <div class="action-cards-row">
<div <div v-for="item in otherTypes" :key="item.value" class="action-card"
v-for="item in otherTypes" :class="{ 'active': form.actionType == item.value }" @click="form.actionType = parseInt(item.value)">
:key="item.value"
class="action-card"
:class="{ 'active': form.actionType == item.value }"
@click="form.actionType = parseInt(item.value)">
<div class="card-icon"> <div class="card-icon">
<i :class="getActionIcon(item.value)"></i> <i :class="getActionIcon(item.value)"></i>
</div> </div>
@@ -253,7 +186,8 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <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> <el-button @click="cancel"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
@@ -464,7 +398,7 @@ export default {
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.$message.success('删除成功'); this.$message.success('删除成功');
}).catch(() => {}); }).catch(() => { });
}, },
/** 处理操作 - 跳转到对应页面 */ /** 处理操作 - 跳转到对应页面 */
handleProcess(row) { handleProcess(row) {
@@ -495,7 +429,7 @@ export default {
path = '/wms/merge'; path = '/wms/merge';
} }
// 其他操作类型 // 其他操作类型
else{ else {
path = '/wms/typing'; path = '/wms/typing';
} }
@@ -540,7 +474,7 @@ export default {
}).then(() => { }).then(() => {
this.$message.success('操作已取消'); this.$message.success('操作已取消');
this.getList(); this.getList();
}).catch(() => {}); }).catch(() => { });
}, },
/** 刷新列表 */ /** 刷新列表 */
handleRefresh() { handleRefresh() {
@@ -552,8 +486,8 @@ export default {
// 每30秒自动刷新一次用于移动端扫码后自动更新列表 // 每30秒自动刷新一次用于移动端扫码后自动更新列表
this.refreshTimer = setInterval(() => { this.refreshTimer = setInterval(() => {
// 只在查看待处理状态时自动刷新 // 只在查看待处理状态时自动刷新
this.getList(); this.getList();
}, 30000); }, 30000);
}, },
/** 表格行样式 */ /** 表格行样式 */

View File

@@ -259,9 +259,9 @@
</div> </div>
</el-dialog> </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" /> <BomPanel :id="bomId" type="product" @addBom="handleAddBom" :itemId="itemId" />
</el-dialog> </el-dialog> -->
</div> </div>
</template> </template>
@@ -270,7 +270,7 @@ import { listProduct, getProduct, delProduct, addProduct, updateProduct } from "
import CategorySelect from '@/components/KLPService/CategorySelect'; import CategorySelect from '@/components/KLPService/CategorySelect';
import CategoryRenderer from '@/components/KLPService/Renderer/CategoryRenderer.vue'; import CategoryRenderer from '@/components/KLPService/Renderer/CategoryRenderer.vue';
import UserSelect from '@/components/KLPService/UserSelect'; 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'; import BomInfoMini from '@/components/KLPService/Renderer/BomInfoMini.vue';
export default { export default {
@@ -279,7 +279,7 @@ export default {
CategorySelect, CategorySelect,
CategoryRenderer, CategoryRenderer,
UserSelect, UserSelect,
BomPanel, // BomPanel,
BomInfoMini BomInfoMini
}, },
dicts: ['common_swicth'], dicts: ['common_swicth'],

View File

@@ -240,7 +240,7 @@ export default {
} }
.occupied { .occupied {
background-color: #c0c4cc; background-color: #eeff6f;
} }
.legend-text { .legend-text {
@@ -253,6 +253,7 @@ export default {
// 分层容器样式 // 分层容器样式
.layers-container { .layers-container {
display: flex; display: flex;
.layer-section { .layer-section {
flex: 1; flex: 1;
max-width: 50%; max-width: 50%;

View File

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

View File

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