update process equipment relation

This commit is contained in:
lb 2023-11-21 09:13:28 +08:00
parent 20975948ef
commit 32a43fbc3b
2 changed files with 40 additions and 27 deletions

View File

@ -121,6 +121,9 @@ export default {
}, },
}, },
methods: { methods: {
commit() {
this.$emit('update', this.selected);
},
handleEquipmentChange(eq, selected) { handleEquipmentChange(eq, selected) {
this.currentEquipment = eq.id; this.currentEquipment = eq.id;
this.materialsBomList = eq.materialsBom; this.materialsBomList = eq.materialsBom;
@ -133,7 +136,7 @@ export default {
equValueBomId: null, equValueBomId: null,
equMaterialBomId: null, equMaterialBomId: null,
}); });
this.$emit('update', this.selected); // this.$emit('update', this.selected);
} else { } else {
// //
this.selectedEquipments = this.selectedEquipments.filter( this.selectedEquipments = this.selectedEquipments.filter(
@ -144,7 +147,7 @@ export default {
this.selected = this.selected.filter( this.selected = this.selected.filter(
(item) => item.equipmentId !== eq.id (item) => item.equipmentId !== eq.id
); );
this.$emit('update', this.selected); // this.$emit('update', this.selected);
} }
}, },
@ -162,11 +165,11 @@ export default {
}); });
// '' // ''
this.refreshKey = Math.random(); this.refreshKey = Math.random();
this.$emit('update', this.selected); // this.$emit('update', this.selected);
return; return;
} }
selectedItem && (selectedItem.equMaterialBomId = selected ? bomId : null); selectedItem && (selectedItem.equMaterialBomId = selected ? bomId : null);
this.$emit('update', this.selected); // this.$emit('update', this.selected);
}, },
handleValueBomChange(equipmentId, bomId, selected) { handleValueBomChange(equipmentId, bomId, selected) {
@ -182,11 +185,11 @@ export default {
equMaterialBomId: null, equMaterialBomId: null,
}); });
this.refreshKey = Math.random(); this.refreshKey = Math.random();
this.$emit('update', this.selected); // this.$emit('update', this.selected);
return; return;
} }
selectedItem && (selectedItem.equValueBomId = selected ? bomId : null); selectedItem && (selectedItem.equValueBomId = selected ? bomId : null);
this.$emit('update', this.selected); // this.$emit('update', this.selected);
}, },
}, },
}; };

View File

@ -68,7 +68,12 @@
@cancel="cancel" @cancel="cancel"
@confirm="submitForm"> @confirm="submitForm">
<!-- <CustomTransfer /> --> <!-- <CustomTransfer /> -->
<BomSelector :bom-list="bomList" v-model="selectedBoms" /> <BomSelector
ref="bomSelector"
v-if="open"
:bom-list="bomList"
:value="selectedBoms"
@update="selectedBoms = $event" />
</base-dialog> </base-dialog>
</section> </section>
</template> </template>
@ -146,27 +151,32 @@ export default {
data: method !== 'get' ? payload : null, data: method !== 'get' ? payload : null,
}); });
}, },
async submitForm() { submitForm() {
console.log('selectedBoms', this.selectedBoms); //
if (this.selectedBoms.length) { this.$refs.bomSelector.commit();
const { code, data } = await this.http( //
'/extend/process-flow-det-equipment/createList', this.$nextTick(async () => {
'post', console.log('selectedBoms', this.selectedBoms);
this.selectedBoms.map((item) => ({ if (this.selectedBoms.length) {
...item, const { code, data } = await this.http(
flowDetId: this.currentDet.detId, '/extend/process-flow-det-equipment/createList',
})) 'post',
); this.selectedBoms.map((item) => ({
if (code == 0) { ...item,
this.$message.success('操作成功'); flowDetId: this.currentDet.detId,
this.getList(this.currentDet); }))
this.cancel(); );
if (code == 0) {
this.$message.success('操作成功');
this.getList(this.currentDet);
this.cancel();
} else {
this.$message.error('操作失败');
}
} else { } else {
this.$message.error('操作失败'); this.$message.info('请选择设备');
} }
} else { });
this.$message.info('请选择设备');
}
}, },
async getList({ async getList({
detId, detId,
@ -202,7 +212,7 @@ export default {
// //
eq.materialsBom.chosen = eq.materialsBomChoseId ?? null; eq.materialsBom.chosen = eq.materialsBomChoseId ?? null;
eq.valuesBom.chosen = eq.valuesBomChoseId ?? null; eq.valuesBom.chosen = eq.valuesBomChoseId ?? null;
if (eq.materialsBom.chosen || eq.valuesBom.chosen) { if (eq.equChose || eq.materialsBom.chosen || eq.valuesBom.chosen) {
this.selectedBoms.push({ this.selectedBoms.push({
equipmentId: eq.id, equipmentId: eq.id,
equMaterialBomId: eq.materialsBom.chosen, equMaterialBomId: eq.materialsBom.chosen,