|
|
@@ -67,22 +67,32 @@
|
|
|
|
|
|
<el-row>
|
|
|
<div class="ele-body">
|
|
|
- <ele-pro-table ref="table" :datasource="form.subDetailList" row-key="id" :columns="columns">
|
|
|
+ <ele-pro-table ref="table" :columns="columns" :datasource="tableData" height="calc(100vh - 550px)"
|
|
|
+ :need-page="false">
|
|
|
<!-- 表头工具栏 -->
|
|
|
<template v-slot:toolbar>
|
|
|
- <el-button size="small" icon="el-icon-plus" class="ele-btn-icon" type="primary"
|
|
|
- @click.native="openParam()">添加物料</el-button>
|
|
|
+ <el-button type="primary" @click="add">添加</el-button>
|
|
|
</template>
|
|
|
-
|
|
|
- <!-- 操作列 -->
|
|
|
- <template v-slot:action="{ row }">
|
|
|
- <el-popconfirm class="ele-action" title="确定要删除当前物料吗?" @confirm="remove(row)">
|
|
|
- <template v-slot:reference>
|
|
|
- <el-link type="danger" :underline="false" icon="el-icon-delete">
|
|
|
- 删除
|
|
|
- </el-link>
|
|
|
- </template>
|
|
|
- </el-popconfirm>
|
|
|
+ <template v-slot:action="{ row, $index }">
|
|
|
+ <el-link type="primary" @click="handleDel(row, $index)">删除</el-link>
|
|
|
+ </template>
|
|
|
+ <template v-slot:subCode="{ row }">
|
|
|
+ <el-input v-model="row.subCode" placeholder="请输入"></el-input>
|
|
|
+ </template>
|
|
|
+ <template v-slot:unit="{ row }">
|
|
|
+ <DictSelection dictName="计量单位" v-model="row.unit"></DictSelection>
|
|
|
+ </template>
|
|
|
+ <template v-slot:count="{ row }">
|
|
|
+ <el-input v-model="row.count" placeholder="请输入" @input="(value) =>
|
|
|
+ (row.count = value.replace(
|
|
|
+ /^(-)*(\d+)\.(\d\d\d\d\d\d).*$/,
|
|
|
+ '$1$2.$3'
|
|
|
+ ))
|
|
|
+ "></el-input>
|
|
|
+ </template>
|
|
|
+ <template v-slot:categoryName="{ row, $index }">
|
|
|
+ <el-input :value="row.categoryName" placeholder="请选择"
|
|
|
+ @click.native="categorySelect(row, $index)"></el-input>
|
|
|
</template>
|
|
|
</ele-pro-table>
|
|
|
</div>
|
|
|
@@ -94,28 +104,28 @@
|
|
|
</el-button>
|
|
|
</el-row>
|
|
|
</el-form>
|
|
|
-
|
|
|
- <!-- 选择物料弹窗 -->
|
|
|
- <materialDialog ref="materiaRef" @chooseModal="chooseModal"></materialDialog>
|
|
|
+ <ProductModal ref="productRefs" @changeProduct='determineChoose' />
|
|
|
</ele-modal>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import materialDialog from '@/components/material';
|
|
|
+
|
|
|
import factorySelect from '@/components/CommomSelect/factory-select.vue';
|
|
|
import { pageList } from '@/api/technology/version/version.js';
|
|
|
import { getCode } from '@/api/codeManagement/index.js';
|
|
|
import { bomSave, bomUpdate } from '@/api/material/BOM';
|
|
|
+import ProductModal from '@/views/technology/productParam/components/ProductModal.vue'
|
|
|
export default {
|
|
|
components: {
|
|
|
- materialDialog,
|
|
|
- factorySelect
|
|
|
+ factorySelect,
|
|
|
+ ProductModal
|
|
|
},
|
|
|
props: {
|
|
|
// 弹窗是否打开
|
|
|
visible: Boolean,
|
|
|
// 修改回显的数据
|
|
|
- categoryId: [String, Number]
|
|
|
+ categoryId: [String, Number],
|
|
|
+ data: Object,
|
|
|
},
|
|
|
data() {
|
|
|
|
|
|
@@ -141,7 +151,8 @@ export default {
|
|
|
produceVersionId: '',
|
|
|
baseCount: '',
|
|
|
baseCountUnit: '',
|
|
|
- subDetailList: []
|
|
|
+
|
|
|
+
|
|
|
};
|
|
|
return {
|
|
|
defaultForm,
|
|
|
@@ -150,6 +161,7 @@ export default {
|
|
|
...defaultForm
|
|
|
},
|
|
|
|
|
|
+ removeSubBomIdList: [],
|
|
|
versionList: [],
|
|
|
|
|
|
// 表单验证规则
|
|
|
@@ -184,45 +196,54 @@ export default {
|
|
|
]
|
|
|
|
|
|
},
|
|
|
-
|
|
|
columns: [
|
|
|
{
|
|
|
- prop: 'code',
|
|
|
- label: '编码'
|
|
|
+ type: 'index',
|
|
|
+ width: 55,
|
|
|
+ align: 'center'
|
|
|
},
|
|
|
{
|
|
|
- prop: 'name',
|
|
|
- label: '名称',
|
|
|
- showOverflowTooltip: true
|
|
|
+ label: '子项编号',
|
|
|
+ prop: 'subCode',
|
|
|
+ slot: 'subCode',
|
|
|
+ action: 'subCode'
|
|
|
},
|
|
|
{
|
|
|
- prop: 'brandNum',
|
|
|
- label: '牌号'
|
|
|
+ label: '物料名称',
|
|
|
+ prop: 'categoryName',
|
|
|
+ slot: 'categoryName',
|
|
|
+ action: 'categoryName'
|
|
|
},
|
|
|
{
|
|
|
- prop: 'modelType',
|
|
|
- label: '型号'
|
|
|
+ label: '物料编码',
|
|
|
+ prop: 'categoryCode'
|
|
|
},
|
|
|
{
|
|
|
- prop: 'weightUnit',
|
|
|
- label: '重量单位'
|
|
|
+ label: '牌号',
|
|
|
+ prop: 'brandNum'
|
|
|
},
|
|
|
{
|
|
|
- prop: 'netWeight',
|
|
|
- label: '净重'
|
|
|
+ label: '型号',
|
|
|
+ prop: 'modelType'
|
|
|
},
|
|
|
-
|
|
|
{
|
|
|
- columnKey: 'action',
|
|
|
- label: '操作',
|
|
|
-
|
|
|
- align: 'center',
|
|
|
- resizable: false,
|
|
|
+ label: '净重',
|
|
|
+ slot: 'count',
|
|
|
+ action: 'count'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '重量单位',
|
|
|
+ slot: 'unit',
|
|
|
+ action: 'unit'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ action: 'action',
|
|
|
slot: 'action',
|
|
|
- showOverflowTooltip: true
|
|
|
+ label: '操作'
|
|
|
}
|
|
|
],
|
|
|
|
|
|
+ tableData: [],
|
|
|
statusList: [
|
|
|
{ label: '草稿', value: -1 },
|
|
|
{ label: '失效', value: 0 },
|
|
|
@@ -244,26 +265,39 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- openParam() {
|
|
|
- this.$refs.materiaRef.open(this.form.subDetailList, '选择物料', '1');
|
|
|
- },
|
|
|
|
|
|
- chooseModal(data) {
|
|
|
- this.$set(this.form, 'subDetailList', data);
|
|
|
- },
|
|
|
|
|
|
- /* 删除 */
|
|
|
- remove(row) {
|
|
|
- this.form.subDetailList = this.form.subDetailList.filter(
|
|
|
- (d) => d.id !== row.id
|
|
|
- );
|
|
|
+ handleDel(row, index) {
|
|
|
+ this.tableData.splice(index, 1);
|
|
|
+ if (row?.id) {
|
|
|
+ this.removeSubBomIdList.push(row.id)
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
- /* 表格数据源 */
|
|
|
- datasource({ page, limit, where }) {
|
|
|
- return [];
|
|
|
+ add() {
|
|
|
+ let subCode = '0010';
|
|
|
+ if (this.tableData.length) {
|
|
|
+ let max = Math.max(...this.tableData.map((i) => i.subCode)) + 10 + '';
|
|
|
+
|
|
|
+ if (max.length < 4) {
|
|
|
+ max = new Array(4 - max.length).fill('0').join('') + max;
|
|
|
+ }
|
|
|
+ subCode = max.substring(0, max.length - 1) + '0';
|
|
|
+ }
|
|
|
+
|
|
|
+ this.tableData.push({
|
|
|
+ subCode,
|
|
|
+ categoryId: '',
|
|
|
+ categoryName: '',
|
|
|
+ brandNum: '',
|
|
|
+ count: '',
|
|
|
+ modelType: '',
|
|
|
+ unit: ''
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
+
|
|
|
+
|
|
|
async _getCode() {
|
|
|
const code = await getCode('bom_code');
|
|
|
this.form.code = code;
|
|
|
@@ -285,21 +319,10 @@ export default {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- let _arr = []
|
|
|
- _arr = this.form.subDetailList.map((m) => {
|
|
|
- return{
|
|
|
- bomId: '',
|
|
|
- categoryId: m.id,
|
|
|
- count: '',
|
|
|
- id: m.id,
|
|
|
- sortNum: '',
|
|
|
- subCode: m.code,
|
|
|
- unit: m.measuringUnit
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- if (_arr.length == 0) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (this.tableData.length == 0) {
|
|
|
this.$message.info('请至少添加一条物料');
|
|
|
return;
|
|
|
}
|
|
|
@@ -310,7 +333,8 @@ export default {
|
|
|
|
|
|
const data = {
|
|
|
...this.form,
|
|
|
- subDetailList: _arr,
|
|
|
+ removeSubBomIdList: this.removeSubBomIdList,
|
|
|
+ subDetailList: this.tableData,
|
|
|
categoryId: this.categoryId,
|
|
|
};
|
|
|
|
|
|
@@ -321,8 +345,8 @@ export default {
|
|
|
.then((msg) => {
|
|
|
this.loading = false;
|
|
|
this.$message.success(msg);
|
|
|
- this.visible = false
|
|
|
this.$emit('done');
|
|
|
+ this.visible = false
|
|
|
})
|
|
|
.catch((e) => {
|
|
|
this.loading = false;
|
|
|
@@ -330,6 +354,28 @@ export default {
|
|
|
|
|
|
});
|
|
|
},
|
|
|
+
|
|
|
+
|
|
|
+ categorySelect(row, idx) {
|
|
|
+ this.$refs.productRefs.open(row, '选择物料', '1', idx)
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ determineChoose(title, row, idx) {
|
|
|
+ if (title == '选择物料') {
|
|
|
+ this.$set(this.tableData[idx], 'categoryName', row.name)
|
|
|
+ this.$set(this.tableData[idx], 'categoryId', row.id)
|
|
|
+ this.$set(this.tableData[idx], 'categoryCode', row.code)
|
|
|
+ this.$set(this.tableData[idx], 'unit', row.measuringUnit)
|
|
|
+ this.$set(this.tableData[idx], 'brandNum', row.brandNum)
|
|
|
+ this.$set(this.tableData[idx], 'modelType', row.modelType)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/* 更新visible */
|
|
|
updateVisible(value) {
|
|
|
this.$emit('update:visible', value);
|
|
|
@@ -341,11 +387,13 @@ export default {
|
|
|
if (visible) {
|
|
|
this._getCode()
|
|
|
this.getVersionList();
|
|
|
+ this.removeSubBomIdList = []
|
|
|
if (this.data) {
|
|
|
- this.isUpdate = true
|
|
|
+ this.tableData = this.data.subDetailList
|
|
|
this.$util.assignObject(this.form, {
|
|
|
...this.data
|
|
|
});
|
|
|
+ this.isUpdate = true
|
|
|
} else {
|
|
|
this.isUpdate = false
|
|
|
}
|