diff --git a/src/views/extend/processFlowView/components/BomSelection.vue b/src/views/extend/processFlowView/components/BomSelection.vue index 86991023..f5c2f02b 100644 --- a/src/views/extend/processFlowView/components/BomSelection.vue +++ b/src/views/extend/processFlowView/components/BomSelection.vue @@ -9,9 +9,10 @@
@@ -21,7 +22,15 @@ export default { name: 'BomSelection', components: {}, + // model: { + // prop: 'selected', + // event: 'update', + // }, props: { + // selected: { + // type: String, + // default: '', + // }, list: { type: Array, default: () => [], @@ -34,7 +43,8 @@ export default { data() { return { list__inner: [], - selected: '', + selected: null, + randomKey: Math.random() }; }, watch: { @@ -54,11 +64,24 @@ export default { ...item, disabled: selected ? item.id !== bomItem.id : false, })); + + if (selected) this.selected = null; + else this.clearSelected(); + this.$emit('change', this.equipmentId, bomItem.id, selected); this.$nextTick(() => { this.$forceUpdate(); }); }, + clearSelected() { + console.log('clearSelected'); + this.selected = null; + this.randomKey = Math.random() + // this.$emit('update', null); + // this.$nextTick(() => { + // this.$forceUpdate(); + // }); + }, }, }; diff --git a/src/views/extend/processFlowView/components/BomSelector.vue b/src/views/extend/processFlowView/components/BomSelector.vue index 39ab1710..9927f7b1 100644 --- a/src/views/extend/processFlowView/components/BomSelector.vue +++ b/src/views/extend/processFlowView/components/BomSelector.vue @@ -12,6 +12,7 @@ @@ -23,16 +24,19 @@
可分配设备 - {{ selectedEquipments.length }}/{{ bomList.length }} + + {{ selectedEquipments.length }}/{{ filteredBomList.length }} +
- +
- +
@@ -42,6 +46,7 @@ [], }, + value: { + type: Array, + default: () => [], + }, }, data() { return { @@ -83,8 +97,29 @@ export default { selected: [], materialsBomList: [], valuesBomList: [], + refreshKey: Math.random(), }; }, + watch: { + value: { + handler(val) { + console.log('value', val); + if (val) { + this.selectedEquipments = val.map((item) => item.equipmentId); + this.selected = val; + } + }, + deep: true, + immediate: true, + }, + }, + computed: { + filteredBomList() { + return this.bomList.filter((item) => { + return item.name.includes(this.searchText); + }); + }, + }, methods: { handleEquipmentChange(eq, selected) { this.currentEquipment = eq.id; @@ -92,16 +127,24 @@ export default { this.valuesBomList = eq.valuesBom; if (selected) { + this.selectedEquipments.push(eq.id); this.selected.push({ equipmentId: eq.id, equValueBomId: null, equMaterialBomId: null, }); + this.$emit('update', this.selected); } else { // 清空选择状态 + this.selectedEquipments = this.selectedEquipments.filter( + (id) => id !== eq.id + ); + this.$refs.materialsBomList.clearSelected(); + this.$refs.valuesBomList.clearSelected(); this.selected = this.selected.filter( (item) => item.equipmentId !== eq.id ); + this.$emit('update', this.selected); } }, @@ -109,14 +152,41 @@ export default { const selectedItem = this.selected.find( (item) => item.equipmentId == equipmentId ); - selectedItem.equMaterialBomId = selected ? bomId : null; + if (selected && !selectedItem) { + // 如果没找到这个 + this.selectedEquipments.push(equipmentId); + this.selected.push({ + equipmentId, + equValueBomId: null, + equMaterialBomId: bomId, + }); + // 强制更新'设备'一栏 + this.refreshKey = Math.random(); + this.$emit('update', this.selected); + return; + } + selectedItem && (selectedItem.equMaterialBomId = selected ? bomId : null); + this.$emit('update', this.selected); }, handleValueBomChange(equipmentId, bomId, selected) { const selectedItem = this.selected.find( (item) => item.equipmentId == equipmentId ); - selectedItem.equValueBomId = selected ? bomId : null; + if (selected && !selectedItem) { + // 如果没找到这个 + this.selectedEquipments.push(equipmentId); + this.selected.push({ + equipmentId, + equValueBomId: bomId, + equMaterialBomId: null, + }); + this.refreshKey = Math.random(); + this.$emit('update', this.selected); + return; + } + selectedItem && (selectedItem.equValueBomId = selected ? bomId : null); + this.$emit('update', this.selected); }, }, }; diff --git a/src/views/extend/processFlowView/components/CustomBomList.vue b/src/views/extend/processFlowView/components/CustomBomList.vue deleted file mode 100644 index 5f25fadb..00000000 --- a/src/views/extend/processFlowView/components/CustomBomList.vue +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - diff --git a/src/views/extend/processFlowView/components/CustomTransfer.vue b/src/views/extend/processFlowView/components/CustomTransfer.vue deleted file mode 100644 index 173c6c5a..00000000 --- a/src/views/extend/processFlowView/components/CustomTransfer.vue +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - diff --git a/src/views/extend/processFlowView/components/CustomTransferBox.vue b/src/views/extend/processFlowView/components/CustomTransferBox.vue deleted file mode 100644 index 95098dee..00000000 --- a/src/views/extend/processFlowView/components/CustomTransferBox.vue +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - diff --git a/src/views/extend/processFlowView/components/CustomTree.vue b/src/views/extend/processFlowView/components/CustomTree.vue deleted file mode 100644 index 6fd4e3e7..00000000 --- a/src/views/extend/processFlowView/components/CustomTree.vue +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - diff --git a/src/views/extend/processFlowView/components/ProcessBomList.vue b/src/views/extend/processFlowView/components/ProcessBomList.vue index 0e4e334f..8522f904 100644 --- a/src/views/extend/processFlowView/components/ProcessBomList.vue +++ b/src/views/extend/processFlowView/components/ProcessBomList.vue @@ -68,13 +68,12 @@ @cancel="cancel" @confirm="submitForm"> - +