|
|
@@ -12,7 +12,7 @@
|
|
|
>
|
|
|
<div class="form-wrapper">
|
|
|
<el-form :model="requestData" label-width="0" :show-message="false">
|
|
|
- <el-descriptions title="" :column="2" border>
|
|
|
+ <el-descriptions title="" :column="3" border>
|
|
|
<el-descriptions-item label="计划编号">
|
|
|
{{ formData.code }}</el-descriptions-item
|
|
|
>
|
|
|
@@ -44,7 +44,7 @@
|
|
|
formData.reqMoldTime
|
|
|
}}</el-descriptions-item>
|
|
|
|
|
|
- <el-descriptions-item label="生产方式">
|
|
|
+ <el-descriptions-item label="生产类型" class="produceType">
|
|
|
<el-select v-model="formData.produceType" @change="getBomList">
|
|
|
<el-option
|
|
|
v-for="item of producedList"
|
|
|
@@ -56,14 +56,13 @@
|
|
|
</el-descriptions-item>
|
|
|
</el-descriptions>
|
|
|
<headerTitle title="BOM信息" class="mt20"> </headerTitle>
|
|
|
-
|
|
|
+ <!-- @update:selection="handleSelectionChange" -->
|
|
|
<ele-pro-table
|
|
|
ref="table"
|
|
|
:needPage="false"
|
|
|
:columns="columns"
|
|
|
:datasource="bomList"
|
|
|
:selection.sync="selection"
|
|
|
- @update:selection="handleSelectionChange"
|
|
|
tool-class="ele-toolbar-actions"
|
|
|
max-height="360px"
|
|
|
@select-all="selectAll"
|
|
|
@@ -81,10 +80,6 @@
|
|
|
</el-input>
|
|
|
<DictSelection dictName="计量单位" v-model="unit" disabled
|
|
|
/></div>
|
|
|
-
|
|
|
- <el-button type="primary" size="mini" @click="handleAdd"
|
|
|
- >新增</el-button
|
|
|
- >
|
|
|
</div>
|
|
|
</template>
|
|
|
</ele-pro-table>
|
|
|
@@ -99,8 +94,20 @@
|
|
|
tool-class="ele-toolbar-actions"
|
|
|
max-height="360px"
|
|
|
>
|
|
|
- <template v-slot:produceRoutingName="{ row }">
|
|
|
- <el-select v-model="row.produceRoutingId" filterable size="mini">
|
|
|
+ <template v-slot:toolbar>
|
|
|
+ <div class="toolbar_box">
|
|
|
+ <el-button type="primary" size="mini" @click="handleAdd"
|
|
|
+ >新增</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <template v-slot:produceRoutingId="{ row }">
|
|
|
+ <el-select
|
|
|
+ v-model="row.produceRoutingId"
|
|
|
+ filterable
|
|
|
+ size="mini"
|
|
|
+ @change="(e) => selectRout(e, row)"
|
|
|
+ >
|
|
|
<el-option
|
|
|
v-for="item of routingList"
|
|
|
:key="item.id"
|
|
|
@@ -114,10 +121,25 @@
|
|
|
<el-input
|
|
|
v-if="row.resourceType"
|
|
|
size="mini"
|
|
|
- v-model.number="row.requiredFormingNum"
|
|
|
+ type="number"
|
|
|
+ v-model="row.requiredFormingNum"
|
|
|
+ @input="(e) => handleQuantityInput(e, row)"
|
|
|
></el-input>
|
|
|
<span v-else>{{ row.requiredFormingNum }}</span>
|
|
|
</template>
|
|
|
+ <template v-slot:action="{ row, $index }">
|
|
|
+ <el-popconfirm
|
|
|
+ class="ele-action"
|
|
|
+ title="确定要删除这条数据吗?"
|
|
|
+ @confirm="removeRow(row, $index)"
|
|
|
+ >
|
|
|
+ <template v-slot:reference>
|
|
|
+ <el-link type="danger" :underline="false" icon="el-icon-delete">
|
|
|
+ 删除
|
|
|
+ </el-link>
|
|
|
+ </template>
|
|
|
+ </el-popconfirm>
|
|
|
+ </template>
|
|
|
</ele-pro-table>
|
|
|
</el-form>
|
|
|
</div>
|
|
|
@@ -165,6 +187,11 @@
|
|
|
},
|
|
|
{
|
|
|
prop: 'code',
|
|
|
+ label: 'BOM编码',
|
|
|
+ showOverflowTooltip: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'productCode',
|
|
|
label: '编码',
|
|
|
showOverflowTooltip: true
|
|
|
},
|
|
|
@@ -209,7 +236,13 @@
|
|
|
},
|
|
|
{
|
|
|
prop: 'versions',
|
|
|
- label: '版本'
|
|
|
+ label: '版本',
|
|
|
+ formatter: (row) => {
|
|
|
+ if (row.versions) {
|
|
|
+ return `V${row.versions}.0`;
|
|
|
+ }
|
|
|
+ return '';
|
|
|
+ }
|
|
|
},
|
|
|
{
|
|
|
prop: 'status ',
|
|
|
@@ -235,11 +268,17 @@
|
|
|
1: '已发布'
|
|
|
},
|
|
|
jsColumns: [
|
|
|
+ {
|
|
|
+ columnKey: 'index',
|
|
|
+ label: '序号',
|
|
|
+ type: 'index',
|
|
|
+ width: 55,
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
{
|
|
|
prop: 'productCode',
|
|
|
label: '编码',
|
|
|
align: 'center',
|
|
|
-
|
|
|
minWidth: 140
|
|
|
},
|
|
|
{
|
|
|
@@ -271,8 +310,8 @@
|
|
|
},
|
|
|
|
|
|
{
|
|
|
- prop: 'produceRoutingName',
|
|
|
- slot: 'produceRoutingName',
|
|
|
+ prop: 'produceRoutingId',
|
|
|
+ slot: 'produceRoutingId',
|
|
|
label: '工艺路线',
|
|
|
align: 'center',
|
|
|
minWidth: 120
|
|
|
@@ -288,6 +327,14 @@
|
|
|
prop: 'unit',
|
|
|
label: '计量单位',
|
|
|
showOverflowTooltip: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ columnKey: 'action',
|
|
|
+ label: '操作',
|
|
|
+ width: 90,
|
|
|
+ align: 'center',
|
|
|
+ fixed: 'right',
|
|
|
+ slot: 'action'
|
|
|
}
|
|
|
],
|
|
|
// bom信息map数据存储
|
|
|
@@ -296,8 +343,8 @@
|
|
|
},
|
|
|
methods: {
|
|
|
open(row) {
|
|
|
+ this.unit = row.measuringUnit;
|
|
|
this.formData = deepClone(row);
|
|
|
-
|
|
|
this.getBomList();
|
|
|
this.getRouteListFn();
|
|
|
},
|
|
|
@@ -308,15 +355,15 @@
|
|
|
if (selection.length > 0) {
|
|
|
this.bomList.forEach((el) => {
|
|
|
this.bomListMap[el.id] = true;
|
|
|
+ this.handleSelectionChange(el);
|
|
|
});
|
|
|
} else {
|
|
|
// 取消全选
|
|
|
this.bomList.forEach((el) => {
|
|
|
delete this.bomListMap[el.id];
|
|
|
+ this.deleteJhData(el.id);
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- console.log(this.bomListMap, '看你数据');
|
|
|
},
|
|
|
|
|
|
// 勾选 取消勾选
|
|
|
@@ -324,9 +371,97 @@
|
|
|
// 存在说明已勾选
|
|
|
if (this.bomListMap[row.id]) {
|
|
|
delete this.bomListMap[row.id];
|
|
|
- }else{
|
|
|
+ this.deleteJhData(row.id);
|
|
|
+ } else {
|
|
|
this.bomListMap[row.id] = true;
|
|
|
+ this.handleSelectionChange(row);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 计划列表数据 BOM信息删除
|
|
|
+ deleteJhData(id) {
|
|
|
+ let index = this.jhList.findIndex((el) => el.id === id);
|
|
|
+ if (index != -1) {
|
|
|
+ this.jhList.splice(index, 1);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 计划列表数据 BOM信息添加
|
|
|
+ handleSelectionChange(m) {
|
|
|
+ for (let i = 0; i < this.jhList.length; i++) {
|
|
|
+ let item = this.jhList[i];
|
|
|
+ if (item.id == m.id) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let row = {};
|
|
|
+ if (
|
|
|
+ m.processRoute &&
|
|
|
+ m.processRoute.list &&
|
|
|
+ m.processRoute.list.length > 0
|
|
|
+ ) {
|
|
|
+ row = m.processRoute.list[0];
|
|
|
+ }
|
|
|
+ let _num =
|
|
|
+ ((this.formData.requiredFormingNum || 0) / (this.baseCount || 0)) *
|
|
|
+ m.dosage;
|
|
|
+ // _num = _num.toFixed(3);
|
|
|
+ _num = this.formattedNum(_num);
|
|
|
+ let data = {
|
|
|
+ id: m.id,
|
|
|
+ categoryId: m.categoryId,
|
|
|
+ productCode: m.productCode,
|
|
|
+ productName: m.name,
|
|
|
+ brandNo: m.brandNo,
|
|
|
+ specification: m.specification,
|
|
|
+ model: m.model,
|
|
|
+ produceRoutingId: row.id || '',
|
|
|
+ produceRoutingName: row.name || '',
|
|
|
+ requiredFormingNum: _num,
|
|
|
+ productUnitWeight: m.productUnitWeight,
|
|
|
+ unit: this.unit,
|
|
|
+ resourceType: 0
|
|
|
+ };
|
|
|
+ this.jhList.push(data);
|
|
|
+ // this.jhList = _arr;
|
|
|
+ },
|
|
|
+ // 数量正则
|
|
|
+ handleQuantityInput(e, row) {
|
|
|
+ // 过滤非数字和非小数点字符(包括负号)
|
|
|
+ let value = e.replace(/[^\d.]/g, '');
|
|
|
+ // 限制只能有一个小数点
|
|
|
+ const dotCount = (value.match(/\./g) || []).length;
|
|
|
+ if (dotCount > 1) {
|
|
|
+ value = value.slice(0, value.lastIndexOf('.'));
|
|
|
+ }
|
|
|
+ // 限制不能以小数点开头
|
|
|
+ if (value.startsWith('.')) {
|
|
|
+ value = '0' + value;
|
|
|
+ }
|
|
|
+ // 更新绑定值
|
|
|
+ row.requiredFormingNum = value;
|
|
|
+ },
|
|
|
+ // 格式化后的结果
|
|
|
+ formattedNum(num) {
|
|
|
+ // 检查是否为整数(小数部分为0)
|
|
|
+ if (Number.isInteger(num)) {
|
|
|
+ return num; // 整数直接返回
|
|
|
+ } else {
|
|
|
+ // 保留小数点后有效数字(可根据需求调整保留位数)
|
|
|
+ return num.toFixed(3);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 删除计划信息
|
|
|
+ removeRow(row, index) {
|
|
|
+ // 如果删除的是当前列表BOM信息的数据 就将它的勾选去掉
|
|
|
+ let data = this.bomList.find((el) => el.id == row.id);
|
|
|
+ if (data && data.id) {
|
|
|
+ this.$refs.table.toggleRowSelection(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 删除对应的存储数据
|
|
|
+ if (this.bomListMap[row.id]) {
|
|
|
+ delete this.bomListMap[row.id];
|
|
|
}
|
|
|
+ this.jhList.splice(index, 1);
|
|
|
},
|
|
|
|
|
|
getBomList() {
|
|
|
@@ -338,45 +473,42 @@
|
|
|
size: -1
|
|
|
};
|
|
|
getBom(params).then((res) => {
|
|
|
- console.log(res, 'res 切换数据');
|
|
|
this.bomList = res?.bomList || [];
|
|
|
+ let ids = Object.keys(this.bomListMap);
|
|
|
+ if (ids.length > 0) {
|
|
|
+ this.checkBoxData();
|
|
|
+ }
|
|
|
(this.baseCount = res.baseCount),
|
|
|
- (this.unit = res.unit),
|
|
|
+ // (this.unit = res.unit),
|
|
|
(this.visible = true);
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- handleSelectionChange() {
|
|
|
- let _arr = [];
|
|
|
- _arr = this.selection.map((m) => {
|
|
|
- let _num =
|
|
|
- ((this.formData.requiredFormingNum || 0) / (this.baseCount || 0)) *
|
|
|
- m.dosage;
|
|
|
- _num = _num.toFixed(3);
|
|
|
- return {
|
|
|
- id: m.id,
|
|
|
- categoryId: m.categoryId,
|
|
|
- productCode: m.code,
|
|
|
- productName: m.name,
|
|
|
- brandNo: m.brandNo,
|
|
|
- specification: m.specification,
|
|
|
- model: m.model,
|
|
|
- produceRoutingId: '',
|
|
|
- produceRoutingName: '',
|
|
|
- requiredFormingNum: _num,
|
|
|
- productUnitWeight: m.productUnitWeight,
|
|
|
- unit: this.unit,
|
|
|
- resourceType: 0
|
|
|
- };
|
|
|
- });
|
|
|
- this.jhList.push(..._arr);
|
|
|
- // this.jhList = _arr;
|
|
|
+ // 数据回显勾选
|
|
|
+ checkBoxData() {
|
|
|
+ let arr = Object.keys(this.bomListMap);
|
|
|
+ setTimeout(() => {
|
|
|
+ if (arr.length == 0) {
|
|
|
+ this.$refs.table.clearSelection();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.bomList.forEach((row) => {
|
|
|
+ if (this.bomListMap[row.id]) {
|
|
|
+ this.$refs.table.toggleRowSelection(row);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }, 10);
|
|
|
+ },
|
|
|
+
|
|
|
+ // 选择工艺路线
|
|
|
+ selectRout(e, row) {
|
|
|
+ let data = this.routingList.find((el) => el.id == e);
|
|
|
+ this.$set(row, 'produceRoutingName', data.name);
|
|
|
},
|
|
|
|
|
|
handleAdd() {
|
|
|
let ids = [];
|
|
|
ids = this.jhList.map((m) => m.id);
|
|
|
-
|
|
|
// 打开设备选择弹窗
|
|
|
this.$refs.equipmentRefs.open(ids);
|
|
|
},
|
|
|
@@ -417,7 +549,6 @@
|
|
|
pageNum: 1,
|
|
|
size: -1
|
|
|
};
|
|
|
-
|
|
|
routeList(params).then((res) => {
|
|
|
this.routingList = res?.list || [];
|
|
|
});
|
|
|
@@ -433,6 +564,14 @@
|
|
|
if (!bol2) {
|
|
|
return this.$message.warning('请填写生产数量');
|
|
|
}
|
|
|
+ // 检查是否存在 requiredFormingNum 为 0 的元素
|
|
|
+ const hasZeroNum = this.jhList.some((item) => {
|
|
|
+ // 确保元素有 requiredFormingNum 属性,且值为 0
|
|
|
+ return item.requiredFormingNum == 0;
|
|
|
+ });
|
|
|
+ if (hasZeroNum) {
|
|
|
+ return this.$message.warning('不能有生产数量为0的数据');
|
|
|
+ }
|
|
|
|
|
|
let param = {
|
|
|
addPOList: this.jhList,
|
|
|
@@ -473,4 +612,13 @@
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ ::v-deep .is-bordered-label{
|
|
|
+ background-color: #fff;
|
|
|
+ }
|
|
|
+
|
|
|
+ .produceType{
|
|
|
+ // background: #e3fbdd;
|
|
|
+ // color: #000;
|
|
|
+ }
|
|
|
</style>
|