refactor(ui): 将BOM相关术语统一修改为参数

修改所有界面中的BOM、SKU等术语为"参数",包括标签、提示信息、表格列名等。涉及多个组件和视图文件,确保术语一致性。
This commit is contained in:
砂糖
2025-11-13 13:29:19 +08:00
parent 6bde071842
commit 754d6d762a
37 changed files with 812 additions and 124 deletions

View File

@@ -81,7 +81,7 @@
@pagination="getList"
/>
<!-- 添加或修改BOM 明细存放属性值对话框 -->
<!-- 添加或修改参数 明细存放属性值对话框 -->
<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">
@@ -127,7 +127,7 @@ export default {
showSearch: true,
// 总条数
total: 0,
// BOM 明细,存放属性–值表格数据
// 参数 明细,存放属性–值表格数据
bomItemList: [],
// 弹出层标题
title: "",
@@ -152,7 +152,7 @@ export default {
this.getList();
},
methods: {
/** 查询BOM 明细,存放属性–值列表 */
/** 查询参数 明细,存放属性–值列表 */
getList() {
this.loading = true;
listBomItem(this.queryParams).then(response => {
@@ -197,7 +197,7 @@ export default {
handleAdd() {
this.reset();
this.open = true;
this.title = "添加BOM 明细,存放属性–值";
this.title = "添加参数 明细,存放属性–值";
},
/** 修改按钮操作 */
handleUpdate(row) {
@@ -208,7 +208,7 @@ export default {
this.loading = false;
this.form = response.data;
this.open = true;
this.title = "修改BOM 明细,存放属性–值";
this.title = "修改参数 明细,存放属性–值";
});
},
/** 提交按钮 */
@@ -239,7 +239,7 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const itemIds = row.itemId || this.ids;
this.$modal.confirm('是否确认删除BOM 明细,存放属性–值编号为"' + itemIds + '"的数据项?').then(() => {
this.$modal.confirm('是否确认删除参数 明细,存放属性–值编号为"' + itemIds + '"的数据项?').then(() => {
this.loading = true;
return delBomItem(itemIds);
}).then(() => {

View File

@@ -10,7 +10,7 @@
class="create-button"
>
<template v-if="!createLoading">
<i class="el-icon-plus"></i> 创建BOM
<i class="el-icon-plus"></i> 创建参数
</template>
<template v-else>
创建中...
@@ -32,10 +32,10 @@
<div v-if="data && !loading">
<el-form label-width="100px">
<el-form-item label="BOM名称">
<el-form-item label="参数名称">
<el-input v-model="info.bomName" @blur="handleUpdateBom"/>
</el-form-item>
<el-form-item label="BOM编码">
<el-form-item label="参数编码">
<el-input v-model="info.bomCode" @blur="handleUpdateBom"/>
</el-form-item>
</el-form>
@@ -102,7 +102,7 @@ export default {
this.info = response2.data;
} catch (err) {
this.error = err.message || '请求失败,请重试';
console.error('获取BOM详情失败:', err);
console.error('获取参数详情失败:', err);
} finally {
this.loading = false;
}
@@ -115,11 +115,11 @@ export default {
try {
this.createLoading = true;
const bomResponse = await addBom({
bomName: (this.type == 'product' ? '产品BOM' : '原材料BOM') + new Date().getTime(),
bomName: (this.type == 'product' ? '产品参数' : '原材料参数') + new Date().getTime(),
bomCode: (this.type == 'product' ? 'P' : 'R') + new Date().getTime()
});
this.$message.success('创建BOM成功');
this.$message.success('创建参数成功');
const bomData = bomResponse.data;
// 根据类型更新产品/原材料
@@ -147,13 +147,13 @@ export default {
},
handleUpdateBom() {
this.$message.warning('正在更新BOM...');
this.$message.warning('正在更新参数...');
updateBom({
bomId: this.id,
bomName: this.info.bomName,
bomCode: this.info.bomCode
}).then(_ => {
this.$message.success('更新BOM成功');
this.$message.success('更新参数成功');
this.$store.dispatch('category/getBomMap');
})
},

View File

@@ -60,9 +60,9 @@
<span class="detail-value">{{ item.specification }}</span>
</div>
<!-- BOM参数展示 -->
<!-- 参数参数展示 -->
<template v-if="item.bomItems && item.bomItems.length > 0">
<div class="source-detail-divider">BOM参数</div>
<div class="source-detail-divider">参数参数</div>
<div class="source-bom-params">
<div class="source-bom-item" v-for="(param, idx) in item.bomItems.slice(0, 3)" :key="idx">
<span class="bom-key">{{ param.attrKey }}</span>
@@ -556,7 +556,7 @@ export default {
return `${month}-${day} ${hour}:${minute}`;
},
// 格式化物品名称(添加规格和BOM信息)
// 格式化物品名称(添加规格和参数信息)
formatItemName(item) {
if (!item) return '';
@@ -572,11 +572,11 @@ export default {
specs.push(item.specification);
}
// 2. 添加BOM参数最多2个
// 2. 添加参数参数最多2个
if (item.bomItems && item.bomItems.length > 0) {
const bomParams = item.bomItems
.filter(bomItem => bomItem.attrKey && bomItem.attrValue)
.slice(0, 2); // 最多2个BOM参数
.slice(0, 2); // 最多2个参数参数
bomParams.forEach(param => {
specs.push(`${param.attrKey}:${param.attrValue}`);
@@ -687,7 +687,7 @@ export default {
const nameMatch = item.rawMaterialName && item.rawMaterialName.toLowerCase().includes(searchQuery);
// 搜索规格
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
// 搜索 BOM 参数
// 搜索 参数 参数
const bomMatch = item.bomItems && item.bomItems.some(bom =>
(bom.attrKey && bom.attrKey.toLowerCase().includes(searchQuery)) ||
(bom.attrValue && bom.attrValue.toLowerCase().includes(searchQuery))
@@ -702,7 +702,7 @@ export default {
const nameMatch = item.productName && item.productName.toLowerCase().includes(searchQuery);
// 搜索规格
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
// 搜索 BOM 参数
// 搜索 参数 参数
const bomMatch = item.bomItems && item.bomItems.some(bom =>
(bom.attrKey && bom.attrKey.toLowerCase().includes(searchQuery)) ||
(bom.attrValue && bom.attrValue.toLowerCase().includes(searchQuery))

View File

@@ -0,0 +1,688 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
<el-form-item label="入场钢卷号" prop="enterCoilNo">
<el-input v-model="queryParams.enterCoilNo" placeholder="请输入入场钢卷号" clearable
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="当前钢卷号" prop="currentCoilNo">
<el-input v-model="queryParams.currentCoilNo" placeholder="请输入当前钢卷号" clearable
@keyup.enter.native="handleQuery" />
</el-form-item>
<!-- <el-form-item label="数据状态">
<el-select v-model="queryParams.dataType" placeholder="请选择数据状态" clearable>
<el-option :value="0" label="历史数据">历史数据</el-option>
<el-option :value="1" label="当前数据">当前数据</el-option>
</el-select>
</el-form-item> -->
<el-form-item label="所在库位" prop="warehouseId" v-if="!hideWarehouseQuery">
<warehouse-select v-model="queryParams.warehouseId" placeholder="请选择仓库/库区/库位" style="width: 100%; display: inline-block;" clearable />
</el-form-item>
<el-form-item label="实际库区" prop="actualWarehouseId" v-if="!hideWarehouseQuery">
<actual-warehouse-select v-model="queryParams.actualWarehouseId" placeholder="请选择实际库位" style="width: 100%; display: inline-block;" clearable />
</el-form-item>
<el-form-item label="厂家卷号" prop="supplierCoilNo">
<el-input v-model="queryParams.supplierCoilNo" placeholder="请输入厂家原料卷号" clearable
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
<el-option v-for="item in dict.type.product_coil_status" :key="item.value" :value="parseInt(item.value)" :label="item.label" />
</el-select>
</el-form-item>
<MaterialSelect :hideType="hideType" :itemId.sync="queryParams.itemIds" :itemType.sync="queryParams.itemType" :multiple="true"/>
<el-form-item label="班组" prop="team">
<el-input v-model="queryParams.team" placeholder="请输入班组" clearable
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="更新时间" prop="updateTime">
<el-date-picker size="mini" v-model="queryParams.updateTime" type="daterange" value-format="yyyy-MM-dd HH:mm:ss"
range-separator="" start-placeholder="开始日期" end-placeholder="结束日期" />
</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>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single"
@click="handleCheck">修正</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>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="materialCoilList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo" />
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo" />
<el-table-column label="厂家卷号" align="center" prop="supplierCoilNo" />
<el-table-column label="逻辑库位" align="center" prop="warehouseName" v-if="!hideWarehouseQuery"/>
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" v-if="!hideWarehouseQuery"/>
<!-- <el-table-column label="物料类型" align="center" prop="itemType">
<template slot-scope="scope">
{{ scope.row.itemType == 'raw_material' ? '原料' : '产品' }}
</template>
</el-table-column> -->
<el-table-column label="物料类型" align="center" prop="materialType"/>
<el-table-column label="产品类型" align="center" prop="itemName">
<template slot-scope="scope">
<ProductInfo v-if="scope.row.itemType == 'product'" :productId="scope.row.itemId">
<template slot-scope="{ product }">
{{ product.productName }}({{ product.productCode }})
</template>
</ProductInfo>
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :materialId="scope.row.itemId">
<template slot-scope="{ material }">
{{ material.rawMaterialName }}({{ material.rawMaterialCode }})
</template>
</RawMaterialInfo>
</template>
</el-table-column>
<!-- <el-table-column label="数据类型" align="center" prop="dataType">
<template slot-scope="scope">
{{ scope.row.dataType == 0 ? '历史数据' : '当前数据' }}
</template>
</el-table-column> -->
<el-table-column label="更新时间" align="center" prop="updateTime" />
<el-table-column label="更新人" align="center" prop="updateBy" />
<el-table-column label="二维码" v-if="qrcode">
<template slot-scope="scope">
<QRCode :content="scope.row.qrcodeRecordId" :size="50" />
</template>
</el-table-column>
<el-table-column label="状态" v-if="showStatus" align="center" prop="status">
<template slot-scope="scope">
<el-select v-model="scope.row.status" placeholder="请选择状态" @change="handleStatusChange(scope.row)">
<el-option v-for="item in dict.type.product_coil_status" :key="item.value" :value="parseInt(item.value)" :label="item.label" />
</el-select>
</template>
</el-table-column>
<el-table-column label="班组" align="center" prop="team" />
<el-table-column label="毛重" align="center" prop="grossWeight" />
<el-table-column label="净重" align="center" prop="netWeight" />
<el-table-column label="关联信息" align="center" prop="parentCoilNos" :show-overflow-tooltip="true">
<template slot-scope="scope">
<span v-if="scope.row.parentCoilNos && scope.row.hasMergeSplit === 1 && scope.row.dataType === 1">
<el-tag type="warning" size="mini">来自母卷{{ scope.row.parentCoilNos }}</el-tag>
</span>
<span v-else-if="scope.row.parentCoilNos && scope.row.dataType === 0">
<el-tag type="info" size="mini">分为子卷{{ scope.row.parentCoilNos }}</el-tag>
</span>
<span v-else-if="scope.row.parentCoilNos && scope.row.hasMergeSplit === 2">
<el-tag type="success" size="mini">合并自{{ scope.row.parentCoilNos }}</el-tag>
</span>
<span v-else></span>
</template>
</el-table-column>
<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-view" @click="handlePreviewLabel(scope.row)">
导出标签
</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleCheck(scope.row)">修正</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
<el-button size="mini" type="text" icon="el-icon-search" @click="handleTrace(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="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="入场钢卷号" prop="enterCoilNo">
<el-input v-model="form.enterCoilNo" placeholder="请输入入场钢卷号" disabled />
</el-form-item>
<el-form-item label="当前钢卷号" prop="currentCoilNo">
<el-input v-model="form.currentCoilNo" placeholder="请输入当前钢卷号" />
</el-form-item>
<el-form-item v-if="!form.coilId" label="厂家原料卷号" prop="supplierCoilNo">
<el-input v-model="form.supplierCoilNo" placeholder="请输入厂家原料卷号" />
</el-form-item>
<el-form-item label="所在库位" prop="warehouseId">
<warehouse-select v-model="form.warehouseId" placeholder="请选择仓库/库区/库位" style="width: 100%;" clearable />
</el-form-item>
<el-form-item label="实际库区" prop="actualWarehouseId">
<actual-warehouse-select v-model="form.actualWarehouseId" placeholder="请选择实际库区" style="width: 100%;" clearable />
</el-form-item>
<el-form-item label="班组" prop="team">
<el-input v-model="form.team" placeholder="请输入班组" />
</el-form-item>
<!-- <el-form-item label="材料类型" prop="materialType">
<el-select v-model="form.materialType" placeholder="请选择材料类型" @change="handleMaterialTypeChange">
<el-option label="成品" value="成品" />
<el-option label="原料" value="原料" />
<el-option label="废品" value="废品" />
</el-select>
</el-form-item>
<el-form-item :label="getItemLabel" prop="itemId">
<product-select v-if="form.itemType == 'product'" v-model="form.itemId" placeholder="请选择成品"
style="width: 100%;" clearable />
<raw-material-select v-else-if="form.itemType == 'raw_material'" v-model="form.itemId" placeholder="请选择原料"
style="width: 100%;" clearable />
<div v-else>请先选择材料类型</div>
</el-form-item> -->
<el-form-item label="毛重" prop="grossWeight">
<el-input v-model="form.grossWeight" placeholder="请输入毛重" />
</el-form-item>
<el-form-item label="净重" prop="netWeight">
<el-input v-model="form.netWeight" 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>
<!-- 钢卷追溯对话框使用封装的组件 -->
<el-dialog title="钢卷追溯" :visible.sync="traceOpen" width="90%" append-to-body>
<coil-trace-result :trace-result="traceResult"></coil-trace-result>
</el-dialog>
<!-- 标签预览弹窗 -->
<el-dialog title="标签预览" :visible.sync="labelRender.visible" append-to-body>
<label-render :content="labelRender.data" :labelType="labelType" />
</el-dialog>
</div>
</template>
<script>
import { listMaterialCoil, getMaterialCoil, delMaterialCoil, addMaterialCoil, updateMaterialCoilSimple, getMaterialCoilTrace } from "@/api/wms/coil";
import WarehouseSelect from "@/components/KLPService/WarehouseSelect";
import QRCode from "../../print/components/QRCode.vue";
import * as XLSX from 'xlsx'
import { saveAsImage } from '@/utils/klp';
import ProductSelect from "@/components/KLPService/ProductSelect";
import RawMaterialSelect from "@/components/KLPService/RawMaterialSelect";
// import MaterialSelect from "@/components/KLPService/ProductSelect";
import ProductInfo from "@/components/KLPService/Renderer/ProductInfo";
import BomInfoMini from "@/components/KLPService/Renderer/BomInfoMini";
import RawMaterialInfo from "@/components/KLPService/Renderer/RawMaterialInfo";
// 引入封装的追溯结果组件
import CoilTraceResult from "./CoilTraceResult.vue"; // 路径根据实际存放位置调整
import LabelRender from './LabelRender/index.vue'
import MaterialSelect from "@/components/KLPService/MaterialSelect";
import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect";
import { findItemWithBom } from "@/store/modules/category";
export default {
name: "MaterialCoil",
components: {
WarehouseSelect,
QRCode,
MaterialSelect,
ProductSelect,
RawMaterialSelect,
ProductInfo,
RawMaterialInfo,
BomInfoMini,
CoilTraceResult,
LabelRender,
ActualWarehouseSelect
},
dicts: ['product_coil_status'],
props: {
qrcode: {
type: Boolean,
default: false,
},
querys: {
type: Object,
default: () => { },
},
labelType: {
type: String,
default: '2'
},
hideWarehouseQuery: {
type: Boolean,
default: false,
},
showStatus: {
type: Boolean,
default: false,
},
hideType: {
type: Boolean,
default: false,
}
},
data() {
return {
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 钢卷物料表格数据
materialCoilList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 追溯对话框显示
traceOpen: false,
// 追溯结果数据(传递给组件)
traceResult: null,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
enterCoilNo: undefined,
currentCoilNo: undefined,
supplierCoilNo: undefined,
warehouseId: undefined,
nextWarehouseId: undefined,
actualWarehouseId: undefined,
qrcodeRecordId: undefined,
team: undefined,
hasMergeSplit: undefined,
parentCoilNos: undefined,
itemId: undefined,
itemIds: undefined,
status: undefined,
updateTime: undefined,
...this.querys,
},
// 表单参数
form: {},
transferCoilForm: {},
// 表单校验
rules: {
enterCoilNo: [
{ required: true, message: "入场钢卷号不能为空", trigger: "blur" }
],
currentCoilNo: [
{ required: true, message: "当前钢卷号不能为空", trigger: "blur" }
],
itemId: [
{ required: true, message: "物品ID不能为空", trigger: "blur" }
],
itemType: [
{ required: true, message: "物品类型不能为空", trigger: "change" }
],
// 净重和毛重
netWeight: [
{ required: true, message: "净重不能为空", trigger: "blur" }
],
grossWeight: [
{ required: true, message: "毛重不能为空", trigger: "blur" }
],
},
labelRender: {
visible: false,
data: {},
type: '2'
}
};
},
computed: {
// 动态显示标签
getItemLabel() {
if (this.form.materialType === '成品') {
return '产品类型';
} else if (this.form.materialType === '原料' || this.form.materialType === '废品') {
return '原料类型';
}
return '物品类型';
}
},
created() {
this.getList();
},
methods: {
// 处理材料类型变化
handleMaterialTypeChange(value) {
// 清空物品选择
this.form.itemId = null;
// 根据材料类型设置物品类型
if (value === '成品') {
this.form.itemType = 'product';
} else if (value === '原料' || value === '废品') {
this.form.itemType = 'raw_material';
}
},
/** 查询钢卷物料列表 */
getList() {
this.loading = true;
const { updateTime ,...query } = {
...this.queryParams,
startTime: this.queryParams.updateTime?.[0],
endTime: this.queryParams.updateTime?.[1],
}
listMaterialCoil(query).then(response => {
if (this.querys.warehouseId != 111) {
// 排除掉111仓库的
this.materialCoilList = response.rows.filter(item => item.warehouseId != 111)
} else {
this.materialCoilList = response.rows;
}
this.total = response.total;
this.loading = false;
});
},
/** 状态改变时触发 */
handleStatusChange(row) {
updateMaterialCoilSimple(row).then(res => {
this.$message.success('状态更新成功');
this.getList(); // 刷新列表
}).catch(err => {
console.error('状态更新失败:', err);
this.$message.error('状态更新失败,请重试');
});
},
/** 追溯按钮操作 */
handleTrace(row) {
this.traceOpen = true;
this.traceResult = null; // 清空历史数据
getMaterialCoilTrace({
enterCoilNo: row.enterCoilNo,
currentCoilNo: row.currentCoilNo,
}).then(res => {
this.traceResult = res.data; // 将结果传递给组件
}).catch(err => {
console.error('溯源查询失败:', err);
this.$message.error('溯源查询失败,请重试');
});
},
/** 预览标签 */
handlePreviewLabel(row) {
this.labelRender.visible = true;
const item = findItemWithBom(row.itemType, row.itemId)
// 寻找boms中bom键名为'材质'的
const material = item?.boms?.find(bom => bom.attrKey === '材质')
// 查找boms中bom键名为'规格'的
const specification = item?.boms?.find(bom => bom.attrKey === '规格')
this.labelRender.data = {
...row,
itemName: item?.itemName || '',
material: material?.attrValue || '',
specification: specification?.attrValue || item?.specification || '',
};
},
/** 下载二维码 */
handleDownloadQRCode(row) {
try {
saveAsImage(
row.qrcodeRecordId,
'',
1,
{
barcodeWidth: 200,
barcodeHeight: 200
}
);
this.$message.success('图片保存成功');
} catch (error) {
console.error('保存图片失败', error);
this.$message.error('保存图片失败,请稍后重试');
}
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
coilId: undefined,
enterCoilNo: undefined,
currentCoilNo: undefined,
supplierCoilNo: undefined,
dataType: undefined,
warehouseId: undefined,
nextWarehouseId: undefined,
qrcodeRecordId: undefined,
actualWarehouseId: undefined,
team: undefined,
hasMergeSplit: undefined,
parentCoilNos: undefined,
itemId: undefined,
itemType: undefined,
status: undefined,
remark: undefined,
delFlag: undefined,
createTime: undefined,
createBy: undefined,
updateTime: undefined,
updateBy: undefined,
materialType: '原料',
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.coilId)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.isCheck = false;
this.reset();
// 如果父组件传入了 materialType使用它作为默认值
if (this.querys.materialType) {
this.form.materialType = this.querys.materialType;
// 同时设置对应的 itemType
if (this.querys.materialType === '成品') {
this.form.itemType = 'product';
} else if (this.querys.materialType === '原料' || this.querys.materialType === '废品') {
this.form.itemType = 'raw_material';
}
}
this.open = true;
this.title = "添加钢卷物料";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.isCheck = false;
this.loading = true;
this.reset();
const coilId = row.coilId || this.ids
getMaterialCoil(coilId).then(response => {
this.loading = false;
this.form = response.data;
// 设置 materialType优先级后端返回 > itemType推断 > 父组件传入)
if (!this.form.materialType) {
if (this.form.itemType) {
// 根据 itemType 推断
if (this.form.itemType === 'product') {
this.form.materialType = '成品';
} else if (this.form.itemType === 'raw_material') {
this.form.materialType = '原料';
}
} else if (this.querys.materialType) {
// 使用父组件传入的默认值
this.form.materialType = this.querys.materialType;
// 同时设置对应的 itemType
if (this.querys.materialType === '成品') {
this.form.itemType = 'product';
} else if (this.querys.materialType === '原料' || this.querys.materialType === '废品') {
this.form.itemType = 'raw_material';
}
}
}
this.open = true;
this.title = "修改钢卷物料";
});
},
handleCheck(row) {
this.isCheck = true;
this.loading = true;
this.reset();
const coilId = row.coilId || this.ids
getMaterialCoil(coilId).then(response => {
this.loading = false;
this.form = response.data;
// 设置 materialType优先级后端返回 > itemType推断 > 父组件传入)
if (!this.form.materialType) {
if (this.form.itemType) {
// 根据 itemType 推断
if (this.form.itemType === 'product') {
this.form.materialType = '成品';
} else if (this.form.itemType === 'raw_material') {
this.form.materialType = '原料';
}
} else if (this.querys.materialType) {
// 使用父组件传入的默认值
this.form.materialType = this.querys.materialType;
// 同时设置对应的 itemType
if (this.querys.materialType === '成品') {
this.form.itemType = 'product';
} else if (this.querys.materialType === '原料' || this.querys.materialType === '废品') {
this.form.itemType = 'raw_material';
}
}
}
this.open = true;
this.title = "修改钢卷物料";
});
},
transferCoil() { },
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
if (this.form.coilId != null) {
updateMaterialCoilSimple(this.form).then(_ => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
} else {
addMaterialCoil(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const coilIds = row.coilId || this.ids;
this.$modal.confirm('是否确认删除钢卷物料编号为"' + coilIds + '"的数据项?').then(() => {
this.loading = true;
return delMaterialCoil(coilIds);
}).then(() => {
this.loading = false;
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
/** 导出选中数据操作 */
handleExport() {
// 1. 判断是否有选中数据
if (this.ids.length === 0) {
this.$message.warning('请先选中要导出的数据');
return;
}
// 2. 筛选选中的数据通过ids匹配表格数据
const selectedData = this.materialCoilList.filter(item =>
this.ids.includes(item.coilId) // 用选中的coilId匹配表格数据
);
// 3. 处理导出数据格式(和之前一致,转换枚举值)
const exportData = selectedData.map(item => {
return {
'入场钢卷号': item.enterCoilNo || '',
'当前钢卷号': item.currentCoilNo || '',
'厂家原料卷号': item.supplierCoilNo || '',
'物料类型': item.itemType === 'product' ? '成品' : '原料',
'仓区': item.warehouseName || '',
'实际库区': item.actualWarehouseName || '',
'物品': findItemWithBom(item.itemType, item.itemId)?.itemName || '',
'数据类型': item.dataType === 0 ? '历史数据' : '当前数据',
'班组': item.team || '',
'毛重': item.grossWeight || '',
'净重': item.netWeight || '',
'备注': item.remark || ''
};
});
// 4. 生成Excel并下载复用之前的逻辑
const worksheet = XLSX.utils.json_to_sheet(exportData);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, '选中钢卷物料');
const excelBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' });
this.saveExcelFile(excelBuffer, '选中钢卷物料数据');
},
/** 保存Excel文件到本地 */
saveExcelFile(buffer, fileName) {
const blob = new Blob([buffer], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8'
});
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `${fileName}_${new Date().getTime()}.xlsx`; // 文件名带时间戳
document.body.appendChild(a);
a.click(); // 触发下载
document.body.removeChild(a); // 清理DOM
URL.revokeObjectURL(url); // 释放URL对象
}
}
};
</script>

View File

@@ -54,7 +54,7 @@
<span class="value">{{ motherCoil.netWeight ? motherCoil.netWeight + ' t' : '—' }}</span>
</div>
<!-- BOM参数展示 -->
<!-- 参数参数展示 -->
<template v-if="motherCoil.bomItems && motherCoil.bomItems.length > 0">
<el-divider content-position="left" style="margin: 15px 0 10px;">参数信息</el-divider>
<div class="bom-params">
@@ -368,7 +368,7 @@ export default {
return [];
},
// 格式化物品名称(添加规格和BOM信息)
// 格式化物品名称(添加规格和参数信息)
formatItemName(item) {
if (!item) return '';
@@ -384,11 +384,11 @@ export default {
specs.push(item.specification);
}
// 2. 添加BOM参数最多2个
// 2. 添加参数参数最多2个
if (item.bomItems && item.bomItems.length > 0) {
const bomParams = item.bomItems
.filter(bomItem => bomItem.attrKey && bomItem.attrValue)
.slice(0, 2); // 最多2个BOM参数
.slice(0, 2); // 最多2个参数参数
bomParams.forEach(param => {
specs.push(`${param.attrKey}:${param.attrValue}`);
@@ -439,7 +439,7 @@ export default {
const nameMatch = item.rawMaterialName && item.rawMaterialName.toLowerCase().includes(searchQuery);
// 搜索规格
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
// 搜索 BOM 参数
// 搜索 参数 参数
const bomMatch = item.bomItems && item.bomItems.some(bom =>
(bom.attrKey && bom.attrKey.toLowerCase().includes(searchQuery)) ||
(bom.attrValue && bom.attrValue.toLowerCase().includes(searchQuery))
@@ -454,7 +454,7 @@ export default {
const nameMatch = item.productName && item.productName.toLowerCase().includes(searchQuery);
// 搜索规格
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
// 搜索 BOM 参数
// 搜索 参数 参数
const bomMatch = item.bomItems && item.bomItems.some(bom =>
(bom.attrKey && bom.attrKey.toLowerCase().includes(searchQuery)) ||
(bom.attrValue && bom.attrValue.toLowerCase().includes(searchQuery))
@@ -900,7 +900,7 @@ export default {
}
}
/* BOM参数展示 */
/* 参数参数展示 */
.bom-params {
display: grid;
grid-template-columns: repeat(2, 1fr);

View File

@@ -448,7 +448,7 @@ export default {
return warehouse ? warehouse.warehouseName : '';
},
// 格式化物品名称(添加规格和BOM信息)
// 格式化物品名称(添加规格和参数信息)
formatItemName(item) {
if (!item) return '';
@@ -464,11 +464,11 @@ export default {
specs.push(item.specification);
}
// 2. 添加BOM参数最多2个
// 2. 添加参数参数最多2个
if (item.bomItems && item.bomItems.length > 0) {
const bomParams = item.bomItems
.filter(bomItem => bomItem.attrKey && bomItem.attrValue)
.slice(0, 2); // 最多2个BOM参数
.slice(0, 2); // 最多2个参数参数
bomParams.forEach(param => {
specs.push(`${param.attrKey}:${param.attrValue}`);
@@ -527,21 +527,21 @@ export default {
try {
this.itemSearchLoading = true;
if (itemType === 'raw_material') {
// 使用带BOM的接口
// 使用带参数的接口
const response = await listRawMaterial({
pageNum: 1,
pageSize: 100,
withBom: true // 请求包含BOM信息
withBom: true // 请求包含参数信息
});
if (response.code === 200) {
this.rawMaterialList = response.rows || [];
}
} else if (itemType === 'product') {
// 使用带BOM的接口
// 使用带参数的接口
const response = await listProduct({
pageNum: 1,
pageSize: 100,
withBom: true // 请求包含BOM信息
withBom: true // 请求包含参数信息
});
if (response.code === 200) {
this.productList = response.rows || [];
@@ -581,7 +581,7 @@ export default {
const nameMatch = item.rawMaterialName && item.rawMaterialName.toLowerCase().includes(searchQuery);
// 搜索规格
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
// 搜索 BOM 参数
// 搜索 参数 参数
const bomMatch = item.bomItems && item.bomItems.some(bom =>
(bom.attrKey && bom.attrKey.toLowerCase().includes(searchQuery)) ||
(bom.attrValue && bom.attrValue.toLowerCase().includes(searchQuery))
@@ -596,7 +596,7 @@ export default {
const nameMatch = item.productName && item.productName.toLowerCase().includes(searchQuery);
// 搜索规格
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
// 搜索 BOM 参数
// 搜索 参数 参数
const bomMatch = item.bomItems && item.bomItems.some(bom =>
(bom.attrKey && bom.attrKey.toLowerCase().includes(searchQuery)) ||
(bom.attrValue && bom.attrValue.toLowerCase().includes(searchQuery))

View File

@@ -30,11 +30,11 @@
</el-card>
</el-col>
<!-- 根据BOM计算的原料需求 -->
<!-- 根据参数计算的原料需求 -->
<el-col :span="8">
<el-card shadow="hover" class="situation-card">
<div slot="header" class="card-header">
<span>BOM原料需求</span>
<span>参数原料需求</span>
</div>
<div class="table-container">
<KLPTable :data="productMaterialRequirements" size="small" height="320"

View File

@@ -27,7 +27,7 @@
<el-col :span="24">
<div class="section-title">
<h2>情况区</h2>
<p>订单所需的产品统计根据BOM计算的原料需求原料库存和需求情况</p>
<p>订单所需的产品统计根据参数计算的原料需求原料库存和需求情况</p>
</div>
<CurrentSituationArea :current-situation-area="dashboardData.currentSituationArea" />
</el-col>

View File

@@ -64,7 +64,7 @@
</ProductInfo>
</template>
</el-table-column>
<el-table-column label="SKU" align="center">
<el-table-column label="参数" align="center">
<template slot-scope="scope">
<BomInfoMini item-type="product" :item-id="scope.row.productId" />
</template>

View File

@@ -129,7 +129,7 @@
<dict-tag :options="dict.type.common_swicth" :value="scope.row.isEnabled"/>
</template>
</el-table-column>
<el-table-column label="SKU" align="center">
<el-table-column label="参数" align="center">
<template slot-scope="scope">
<BomInfoMini :bomId="scope.row.bomId" />
</template>
@@ -159,7 +159,7 @@
type="text"
icon="el-icon-data-analysis"
@click="handleBom(scope.row)"
>SKU</el-button>
>参数</el-button>
</template>
</el-table-column>
</KLPTable>
@@ -264,7 +264,7 @@
</div>
</el-dialog>
<el-dialog title="SKU" @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>
</div>

View File

@@ -128,7 +128,7 @@
<dict-tag :options="dict.type.common_swicth" :value="scope.row.isEnabled"/>
</template>
</el-table-column> -->
<el-table-column label="SKU" align="center">
<el-table-column label="参数" align="center">
<template slot-scope="scope">
<BomInfoMini :bomId="scope.row.bomId" />
</template>
@@ -158,7 +158,7 @@
type="text"
icon="el-icon-data-analysis"
@click="handleBom(scope.row)"
>SKU</el-button>
>参数</el-button>
</template>
</el-table-column>
</KLPTable>
@@ -259,7 +259,7 @@
</div>
</el-dialog>
<el-dialog title="SKU" @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>
</div>

View File

@@ -104,7 +104,7 @@
@pagination="getList"
/>
<!-- 添加或修改产品BOM产品-原材料清单对话框 -->
<!-- 添加或修改产品参数产品-原材料清单对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="产品" prop="productId">
@@ -162,7 +162,7 @@ export default {
showSearch: true,
// 总条数
total: 0,
// 产品BOM(产品-原材料清单)表格数据
// 产品参数(产品-原材料清单)表格数据
productBomList: [],
// 弹出层标题
title: "",
@@ -200,7 +200,7 @@ export default {
this.getList();
},
methods: {
/** 查询产品BOM(产品-原材料清单)列表 */
/** 查询产品参数(产品-原材料清单)列表 */
getList() {
this.loading = true;
listProductBom(this.queryParams).then(response => {
@@ -246,7 +246,7 @@ export default {
handleAdd() {
this.reset();
this.open = true;
this.title = "添加产品BOM(产品-原材料清单)";
this.title = "添加产品参数(产品-原材料清单)";
},
/** 修改按钮操作 */
handleUpdate(row) {
@@ -257,7 +257,7 @@ export default {
this.loading = false;
this.form = response.data;
this.open = true;
this.title = "修改产品BOM(产品-原材料清单)";
this.title = "修改产品参数(产品-原材料清单)";
});
},
/** 提交按钮 */
@@ -288,7 +288,7 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const bomIds = row.bomId || this.ids;
this.$modal.confirm('是否确认删除产品BOM(产品-原材料清单)编号为"' + bomIds + '"的数据项?').then(() => {
this.$modal.confirm('是否确认删除产品参数(产品-原材料清单)编号为"' + bomIds + '"的数据项?').then(() => {
this.loading = true;
return delProductBom(bomIds);
}).then(() => {

View File

@@ -59,7 +59,7 @@
</RawMaterialInfo>
</template>
</el-table-column>
<el-table-column label="SKU" align="center">
<el-table-column label="参数" align="center">
<template slot-scope="scope">
<BomInfoMini item-type="raw_material" :item-id="scope.row.rawMaterialId" />
</template>

View File

@@ -32,7 +32,7 @@
<RawMaterialSelect v-model="scope.row.rawMaterialId" placeholder="请选择原材料" />
</template>
</el-table-column>
<el-table-column label="SKU" align="center">
<el-table-column label="参数" align="center">
<template #default="scope">
<BomInfoMini item-type="raw_material" :item-id="scope.row.rawMaterialId" />
</template>

View File

@@ -65,7 +65,7 @@
</RawMaterialInfo>
</template>
</el-table-column>
<el-table-column label="SKU" align="center">
<el-table-column label="参数" align="center">
<template slot-scope="scope">
<BomInfoMini item-type="raw_material" :item-id="scope.row.rawMaterialId" />
</template>

View File

@@ -101,17 +101,17 @@ export default {
console.log('使用旧的质保单');
}
else if (this.uploadQualityCertificateForm.qualityCertificateType === 2) {
// 创建一个新的BOM
// 创建一个新的参数
const bom = await addBom({
bomName: 'N' + new Date().getTime(),
bomCode: 'N' + new Date().getTime(),
})
// 将BOMID赋值给对应的materialId
// 将参数ID赋值给对应的materialId
await updateRawMaterial({
rawMaterialId: this.info.rawMaterialId,
bomId: bom.data.bomId,
})
// 逐项创建BOMItem, 只创建选中的
// 逐项创建参数Item, 只创建选中的
for (let i = 0; i < this.selection.length; i++) {
await addBomItem({
bomId: bom.data.bomId,
@@ -122,12 +122,12 @@ export default {
this.$store.dispatch('category/getBomMap');
this.$store.dispatch('category/getRawMaterialMap');
} else if (this.uploadQualityCertificateForm.qualityCertificateType === 3) {
// 创建一个新的BOM
// 创建一个新的参数
const bom = await addBom({
bomName: 'N' + new Date().getTime(),
bomCode: 'N' + new Date().getTime(),
})
// 逐项创建BOMItem
// 逐项创建参数Item
for (let i = 0; i < this.selection.length; i++) {
await addBomItem({
bomId: bom.data.bomId,

View File

@@ -203,7 +203,7 @@ const so = {
}
},
bom: {
loading: '正在处理BOM'
loading: '正在处理参数'
},
oss: {
loading: '正在获取质保单',
@@ -336,7 +336,7 @@ export default {
handleMergerConfirm(res) {
if (res.status === 'start') {
this.loading = true;
this.loadingText = '正在处理产品BOM';
this.loadingText = '正在处理产品参数';
} else if (res.status === 'success') {
this.loading = false;
this.active = 3;

View File

@@ -64,7 +64,7 @@
style="width: 100%"
>
<el-table-column label="原材料" align="center" prop="rawMaterialName" />
<el-table-column label="SKU" align="center">
<el-table-column label="参数" align="center">
<template slot-scope="scope">
<BomInfoMini item-type="raw_material" :item-id="scope.row.rawMaterialId" />
</template>

View File

@@ -26,7 +26,7 @@
<RawMaterialInfo :materialId="scope.row.rawMaterialId" />
</template>
</el-table-column>
<el-table-column label="SKU" align="center">
<el-table-column label="参数" align="center">
<template #default="scope">
<BomInfoMini item-type="raw_material" :item-id="scope.row.rawMaterialId" />
</template>
@@ -70,7 +70,7 @@
<RawMaterialInfo :materialId="scope.row.rawMaterialId" />
</template>
</el-table-column>
<el-table-column label="SKU" align="center">
<el-table-column label="参数" align="center">
<template #default="scope">
<BomInfoMini item-type="raw_material" :item-id="scope.row.rawMaterialId" />
</template>

View File

@@ -135,7 +135,7 @@
<dict-tag :options="dict.type.common_swicth" :value="scope.row.isEnabled"/>
</template>
</el-table-column> -->
<el-table-column label="SKU" align="center">
<el-table-column label="参数" align="center">
<template slot-scope="scope">
<BomInfoMini :bomId="scope.row.bomId" />
</template>
@@ -144,7 +144,7 @@
<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-info" @click="showParamDetail(scope.row)">参数详情</el-button> -->
<el-button size="mini" type="text" icon="el-icon-plus" @click="handleBom(scope.row)">SKU</el-button>
<el-button size="mini" type="text" icon="el-icon-plus" @click="handleBom(scope.row)">参数</el-button>
<el-button
size="mini"
type="text"
@@ -297,7 +297,7 @@
</el-descriptions>
</el-dialog>
<el-dialog title="SKU" @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="raw_material" @addBom="handleAddBom" :itemId="itemId" />
</el-dialog>
</div>

View File

@@ -50,7 +50,7 @@
</RawMaterialInfo>
</template>
</el-table-column>
<el-table-column label="SKU">
<el-table-column label="参数">
<template slot-scope="scope">
<BomInfoMini :itemType="scope.row.itemType" :itemId="scope.row.itemId" />
</template>

View File

@@ -124,7 +124,7 @@
<span v-else>{{ scope.row.itemId }}</span>
</template>
</el-table-column>
<el-table-column label="SKU" align="center">
<el-table-column label="参数" align="center">
<template slot-scope="scope">
<BomInfoMini :item-type="scope.row.itemType" :item-id="scope.row.itemId" />
</template>

View File

@@ -39,7 +39,7 @@
<span v-else>{{ scope.row.itemId }}</span>
</template>
</el-table-column>
<el-table-column label="SKU" align="center">
<el-table-column label="参数" align="center">
<template slot-scope="scope">
<BomInfoMini :item-type="scope.row.itemType" :item-id="scope.row.itemId" />
</template>

View File

@@ -15,7 +15,7 @@
</ProductInfo>
</template>
</el-table-column>
<el-table-column label="SKU" align="center">
<el-table-column label="参数" align="center">
<template slot-scope="scope">
<BomInfoMini item-type="product" :item-id="scope.row.productId" />
</template>