|
|
@@ -16,7 +16,7 @@
|
|
|
</el-col>
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
@@ -43,12 +43,7 @@
|
|
|
<el-input placeholder="请输入" readonly :value="row.code || row.salesOrderCode"></el-input>
|
|
|
</template>
|
|
|
|
|
|
-
|
|
|
|
|
|
- <template v-slot:productionPlanId="{ row }">
|
|
|
- <el-link type="primary" v-if="!row.productionPlanId" :underline="false"
|
|
|
- @click.native="openVersion(row)">获取物料</el-link>
|
|
|
- </template>
|
|
|
|
|
|
|
|
|
|
|
|
@@ -70,11 +65,27 @@
|
|
|
|
|
|
<!-- 展开内容 -->
|
|
|
<template v-slot:expand="{ row }">
|
|
|
- <div style="width:100%; min-height: 60px" v-if="row.materialList.length > 0">
|
|
|
+ <div style="width:calc(100% - 95px); min-height: 60px; margin-left: 95px;" v-if="row.materialList.length > 0">
|
|
|
<ele-pro-table :toolbar="false" toolsTheme="none" ref="table2" :need-page="false"
|
|
|
:datasource="row.materialList" :columns="columns2" row-key="id">
|
|
|
|
|
|
|
|
|
+ <template v-slot:sort="{ $index }">
|
|
|
+ {{ $index }}
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template v-slot:taskName="{ row }">
|
|
|
+ <div v-if="row.produceSelect">
|
|
|
+ <el-select v-model="row.taskId" placeholder="请选择工序">
|
|
|
+ <el-option v-for="item in row.produceRoutingList" :key="item.id" :label="item.name" :value="item.id"
|
|
|
+ @click.native="row.taskName = item.name">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+ <div v-if="!row.produceSelect">
|
|
|
+ {{ row.taskName }}
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
|
|
|
|
|
|
<template v-slot:demandQuantity="{ row }">
|
|
|
@@ -87,6 +98,11 @@
|
|
|
</template>
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
<template v-slot:purchaseQuantity="{ row }">
|
|
|
<el-input v-model="row.purchaseQuantity" placeholder="请输入" @input="(value) =>
|
|
|
(row.purchaseQuantity = value.replace(
|
|
|
@@ -125,10 +141,8 @@
|
|
|
<workOrderPop ref="workOrderRef" @chooseOrder="chooseOrder"></workOrderPop>
|
|
|
|
|
|
|
|
|
-
|
|
|
<ProductModal ref="productRefs" @chooseModal="chooseModal" />
|
|
|
|
|
|
- <ProductionVersion ref="versionRefs" @changeProduct="changeProduct"></ProductionVersion>
|
|
|
|
|
|
</ele-modal>
|
|
|
</template>
|
|
|
@@ -136,14 +150,13 @@
|
|
|
<script>
|
|
|
|
|
|
import workOrderPop from './workOrderPop.vue'
|
|
|
-import ProductModal from './ProductModal.vue'
|
|
|
-import {listBomByWorkOrderIds, save, getById } from '@/api/materialPlan/index';
|
|
|
-import ProductionVersion from '@/components/CreatePlan/ProductionVersion2.vue';
|
|
|
+import ProductModal from './ProductModal2.vue'
|
|
|
+import { listBomByWorkOrderIds, save, getById } from '@/api/materialPlan/index';
|
|
|
+
|
|
|
export default {
|
|
|
components: {
|
|
|
workOrderPop,
|
|
|
ProductModal,
|
|
|
- ProductionVersion
|
|
|
|
|
|
|
|
|
},
|
|
|
@@ -168,6 +181,14 @@ export default {
|
|
|
slot: 'expand'
|
|
|
},
|
|
|
|
|
|
+ {
|
|
|
+ width: 50,
|
|
|
+ label: '序号',
|
|
|
+ type: 'index',
|
|
|
+ align: 'center',
|
|
|
+ slot: 'index'
|
|
|
+ },
|
|
|
+
|
|
|
{
|
|
|
prop: 'code',
|
|
|
label: '生产订单号',
|
|
|
@@ -238,13 +259,11 @@ export default {
|
|
|
label: '欠交数量',
|
|
|
align: 'center'
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
|
|
|
{
|
|
|
- prop: 'productionPlanId',
|
|
|
+ prop: 'produceRoutingName',
|
|
|
label: '工序',
|
|
|
- slot: 'productionPlanId',
|
|
|
-
|
|
|
align: 'center',
|
|
|
minWidth: 110
|
|
|
},
|
|
|
@@ -264,6 +283,22 @@ export default {
|
|
|
|
|
|
columns2: [
|
|
|
|
|
|
+ {
|
|
|
+ width: 50,
|
|
|
+ label: '序号',
|
|
|
+ prop: 'sort',
|
|
|
+ slot: 'sort',
|
|
|
+ align: 'center',
|
|
|
+ },
|
|
|
+
|
|
|
+ {
|
|
|
+ label: '工序',
|
|
|
+ slot: 'taskName',
|
|
|
+ prop: 'taskName',
|
|
|
+ width: 150,
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
{
|
|
|
label: '物料名称',
|
|
|
prop: 'name',
|
|
|
@@ -364,10 +399,21 @@ export default {
|
|
|
this.$set(this.formData, 'remark', res.remark)
|
|
|
this.formData['id'] = res.id
|
|
|
this.$refs.table.setData([...res.salesOrderList]);
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.table.toggleRowExpansionAll()
|
|
|
+ })
|
|
|
|
|
|
})
|
|
|
},
|
|
|
|
|
|
+ isEverySubArrayRequiredFieldPresent(nestedArray, requiredFields) {
|
|
|
+ return nestedArray.every(subArray =>
|
|
|
+ requiredFields.every(field =>
|
|
|
+ subArray.materialList.some(item => item[field] !== '')
|
|
|
+ )
|
|
|
+ );
|
|
|
+ },
|
|
|
+
|
|
|
confirm() {
|
|
|
this.$refs.formRef.validate(async (value) => {
|
|
|
if (value) {
|
|
|
@@ -378,24 +424,55 @@ export default {
|
|
|
this.$message.info('请添加生产订单');
|
|
|
return false
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const requiredFields = ['taskId']; // 必填字段
|
|
|
+
|
|
|
+ const result = await this.isEverySubArrayRequiredFieldPresent(_arr, requiredFields);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (!result) {
|
|
|
+ this.$message.info('请选择工序!');
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
let _arr2 = []
|
|
|
|
|
|
+
|
|
|
_arr2 = _arr.map(m => {
|
|
|
- if (Object.prototype.hasOwnProperty.call(m, "salesOrderId") && m.salesOrderId) {
|
|
|
+ if (Object.prototype.hasOwnProperty.call(m, "workOrderId") && m.workOrderId) {
|
|
|
} else {
|
|
|
- m.salesOrderId = m.id
|
|
|
- m.salesOrderCode = m.code
|
|
|
+
|
|
|
+ m.workOrderId = m.id
|
|
|
+ m.workOrderCode = m.code
|
|
|
delete m.id
|
|
|
delete m.code
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+ m.materialList.forEach(f => {
|
|
|
+ if (f.categoryId.includes('-')) {
|
|
|
+ f.categoryId = f.categoryId.split('-')[0]
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
return {
|
|
|
...m,
|
|
|
}
|
|
|
})
|
|
|
|
|
|
- this.formData['type'] = 1
|
|
|
- this.formData['salesOrderList'] = _arr2
|
|
|
+ console.log(_arr2)
|
|
|
+
|
|
|
+
|
|
|
+ this.formData['type'] = 2
|
|
|
+ this.formData['workOrderList'] = _arr2
|
|
|
await save(this.formData);
|
|
|
this.$message.success('保存成功!');
|
|
|
this.$emit('success');
|
|
|
@@ -427,22 +504,33 @@ export default {
|
|
|
},
|
|
|
|
|
|
chooseOrder(list) {
|
|
|
- let workOrderList = []
|
|
|
+ let workOrderIds = []
|
|
|
list.map((m => {
|
|
|
- workOrderList.push(m.id)
|
|
|
+ workOrderIds.push(m.id)
|
|
|
return {
|
|
|
...m,
|
|
|
}
|
|
|
}))
|
|
|
- // this.$refs.table.setData([...this.tableData, ...list]);
|
|
|
-
|
|
|
|
|
|
|
|
|
- if (workOrderList.length > 0) {
|
|
|
- listBomByWorkOrderIds({ workOrderList: workOrderList }).then((res) => {
|
|
|
+
|
|
|
+ if (workOrderIds.length > 0) {
|
|
|
+ listBomByWorkOrderIds({ workOrderIds: workOrderIds }).then((res) => {
|
|
|
+ res.forEach(m => {
|
|
|
+ if (m.materialList.length > 0) {
|
|
|
+ m.materialList.forEach(p => {
|
|
|
+ p.detailId = m.id
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
this.$refs.table.setData([...this.tableData, ...res]);
|
|
|
|
|
|
- this.$refs.table.toggleRowExpansionAll()
|
|
|
+
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.table.toggleRowExpansionAll()
|
|
|
+ })
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
@@ -455,7 +543,7 @@ export default {
|
|
|
},
|
|
|
|
|
|
categorySelect(row) {
|
|
|
- this.$refs.productRefs.open(row.materialList, row)
|
|
|
+ this.$refs.productRefs.open(row.materialList, row, this.type)
|
|
|
},
|
|
|
|
|
|
chooseModal(data, current) {
|
|
|
@@ -494,7 +582,7 @@ export default {
|
|
|
this.formData.materialRemoveIds.push(row.id)
|
|
|
data.forEach((e) => {
|
|
|
if (row.detailId == e.id) {
|
|
|
- e.materialList = e.materialList.filter((d) => d.id !== row.id);
|
|
|
+ e.materialList = e.materialList.filter((d) => d.categoryId !== row.categoryId);
|
|
|
}
|
|
|
})
|
|
|
|
|
|
@@ -508,44 +596,6 @@ export default {
|
|
|
|
|
|
|
|
|
|
|
|
- openVersion(row) {
|
|
|
- this.xsId = row.id
|
|
|
- this.$refs.versionRefs.open();
|
|
|
- },
|
|
|
- changeProduct(data) {
|
|
|
- let param = {
|
|
|
- salesOrderIds: [this.xsId],
|
|
|
- produceRoutingId: data.id
|
|
|
- }
|
|
|
-
|
|
|
- listBomBySalesOrderId(param).then((res) => {
|
|
|
-
|
|
|
-
|
|
|
- let tableList = []
|
|
|
- tableList = this.$refs.table.getData()
|
|
|
-
|
|
|
- tableList.forEach(e => {
|
|
|
- if (e.id == this.xsId) {
|
|
|
-
|
|
|
- res.map(m => {
|
|
|
- m.detailId = this.xsId
|
|
|
- return {
|
|
|
- ...m,
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- e.materialList = res
|
|
|
-
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs.table.setData([...tableList]);
|
|
|
- this.$refs.table.toggleRowExpansionAll()
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- })
|
|
|
-
|
|
|
- },
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
@@ -553,6 +603,8 @@ export default {
|
|
|
<style lang="scss" scoped>
|
|
|
:deep(.el-table__expanded-cell) {
|
|
|
|
|
|
- padding-bottom: 120px !important;
|
|
|
+ padding-bottom: 30px !important;
|
|
|
+ border-bottom: 12px solid #CCFFCC !important;
|
|
|
}
|
|
|
</style>
|
|
|
+
|