From 9a7521e691198a521ce383e3e8abfd4993a9d9e6 Mon Sep 17 00:00:00 2001 From: lb Date: Fri, 17 Nov 2023 11:15:18 +0800 Subject: [PATCH 01/13] add CustomTrasfer --- .../components/CustomTransfer.vue | 112 ++++++++++++++++++ .../components/CustomTransferBox.vue | 78 ++++++++++++ .../components/ProcessBomList.vue | 12 +- 3 files changed, 195 insertions(+), 7 deletions(-) create mode 100644 src/views/extend/processFlowView/components/CustomTransfer.vue create mode 100644 src/views/extend/processFlowView/components/CustomTransferBox.vue diff --git a/src/views/extend/processFlowView/components/CustomTransfer.vue b/src/views/extend/processFlowView/components/CustomTransfer.vue new file mode 100644 index 00000000..08d0fc0d --- /dev/null +++ b/src/views/extend/processFlowView/components/CustomTransfer.vue @@ -0,0 +1,112 @@ + + + + + + + diff --git a/src/views/extend/processFlowView/components/CustomTransferBox.vue b/src/views/extend/processFlowView/components/CustomTransferBox.vue new file mode 100644 index 00000000..d4f9f7d2 --- /dev/null +++ b/src/views/extend/processFlowView/components/CustomTransferBox.vue @@ -0,0 +1,78 @@ + + + + + + + diff --git a/src/views/extend/processFlowView/components/ProcessBomList.vue b/src/views/extend/processFlowView/components/ProcessBomList.vue index 69bf868c..5908eba4 100644 --- a/src/views/extend/processFlowView/components/ProcessBomList.vue +++ b/src/views/extend/processFlowView/components/ProcessBomList.vue @@ -66,19 +66,17 @@ @close="cancel" @cancel="cancel" @confirm="submitForm"> - - - + From bb731dfcd43886ff1d73c4f4f5172a939f8eb908 Mon Sep 17 00:00:00 2001 From: lb Date: Fri, 17 Nov 2023 14:56:43 +0800 Subject: [PATCH 03/13] add custom tree --- .../components/CustomBomList.vue | 109 ++++++++++++++++++ .../components/CustomTransfer.vue | 7 +- .../components/CustomTransferBox.vue | 42 ++++++- .../processFlowView/components/CustomTree.vue | 65 +++++++++++ 4 files changed, 215 insertions(+), 8 deletions(-) create mode 100644 src/views/extend/processFlowView/components/CustomBomList.vue create mode 100644 src/views/extend/processFlowView/components/CustomTree.vue diff --git a/src/views/extend/processFlowView/components/CustomBomList.vue b/src/views/extend/processFlowView/components/CustomBomList.vue new file mode 100644 index 00000000..d1243363 --- /dev/null +++ b/src/views/extend/processFlowView/components/CustomBomList.vue @@ -0,0 +1,109 @@ + + + + + + + diff --git a/src/views/extend/processFlowView/components/CustomTransfer.vue b/src/views/extend/processFlowView/components/CustomTransfer.vue index 9c8bb234..52498647 100644 --- a/src/views/extend/processFlowView/components/CustomTransfer.vue +++ b/src/views/extend/processFlowView/components/CustomTransfer.vue @@ -11,8 +11,8 @@ key="left" class="left-ctb" title="设备列表" - :candidate-list="[]" - :selected-list="[]" + :candidate-list="candidateList" + :selected-list="selectedList" @selected-list-change="handleChange" />
-
- +
+ + + + + +
+ @@ -70,7 +100,9 @@ export default { flex: 1; padding: 12px; } + .ctb-footer { + user-select: none; min-height: 12px; padding: 12px; border-top: 1px solid #ccc; diff --git a/src/views/extend/processFlowView/components/CustomTree.vue b/src/views/extend/processFlowView/components/CustomTree.vue new file mode 100644 index 00000000..ecf7ee37 --- /dev/null +++ b/src/views/extend/processFlowView/components/CustomTree.vue @@ -0,0 +1,65 @@ + + + + + + + From 76f5385140db08e835f5733553ffbef5f17e5bac Mon Sep 17 00:00:00 2001 From: lb Date: Fri, 17 Nov 2023 16:05:57 +0800 Subject: [PATCH 04/13] add Candidate --- .../components/CustomBomList.vue | 16 +++-- .../components/CustomTransfer.vue | 66 +++++++++++++++++-- .../components/CustomTransferBox.vue | 2 +- .../processFlowView/components/CustomTree.vue | 30 +++------ .../processFlowView/components/candidate.js | 43 ++++++++++++ 5 files changed, 124 insertions(+), 33 deletions(-) create mode 100644 src/views/extend/processFlowView/components/candidate.js diff --git a/src/views/extend/processFlowView/components/CustomBomList.vue b/src/views/extend/processFlowView/components/CustomBomList.vue index d1243363..5f25fadb 100644 --- a/src/views/extend/processFlowView/components/CustomBomList.vue +++ b/src/views/extend/processFlowView/components/CustomBomList.vue @@ -18,7 +18,9 @@
+ :class="{ + hidden: active && bomListLength > 0 ? false : true, + }">
  • {{ bom.name }} @@ -94,16 +96,16 @@ li { } ul { - display: flex; - flex-direction: column; - gap: 4px; - margin-top: 4px; + display: flex; + flex-direction: column; + gap: 4px; + margin-top: 4px; } .material-bom > li, .param-bom > li { padding: 4px 24px; - background: #0001; - border-radius: 4px; + background: #0001; + border-radius: 4px; } diff --git a/src/views/extend/processFlowView/components/CustomTransfer.vue b/src/views/extend/processFlowView/components/CustomTransfer.vue index 52498647..7d78ee22 100644 --- a/src/views/extend/processFlowView/components/CustomTransfer.vue +++ b/src/views/extend/processFlowView/components/CustomTransfer.vue @@ -51,8 +51,66 @@ export default { pageNo: 1, pageSize: 100, }, - candidateList: [], - selectedList: [], + candidate: { + total: 0, + tree: [ + { + id: 1, + name: '设备1', + paramBomList: [ + { name: '参数BOM1', type: 'param', id: 1 }, + { name: '参数BOM2', type: 'param', id: 2 }, + { name: '参数BOM3', type: 'param', id: 3 }, + { name: '参数BOM4', type: 'param', id: 4 }, + { name: '参数BOM5', type: 'param', id: 5 }, + ], + materialBomList: [ + { name: '物料BOM1', type: 'material', id: 1 }, + { name: '物料BOM2', type: 'material', id: 2 }, + { name: '物料BOM3', type: 'material', id: 3 }, + { name: '物料BOM4', type: 'material', id: 4 }, + { name: '物料BOM5', type: 'material', id: 5 }, + ], + }, + { + id: 2, + name: '设备2', + paramBomList: [ + { name: '参数BOM1', type: 'param', id: 1 }, + { name: '参数BOM2', type: 'param', id: 2 }, + { name: '参数BOM3', type: 'param', id: 3 }, + { name: '参数BOM4', type: 'param', id: 4 }, + { name: '参数BOM5', type: 'param', id: 5 }, + ], + materialBomList: [ + { name: '物料BOM1', type: 'material', id: 1 }, + { name: '物料BOM2', type: 'material', id: 2 }, + { name: '物料BOM3', type: 'material', id: 3 }, + { name: '物料BOM4', type: 'material', id: 4 }, + { name: '物料BOM5', type: 'material', id: 5 }, + ], + }, + { + id: 3, + name: '设备3', + paramBomList: [ + { name: '参数BOM1', type: 'param', id: 1 }, + { name: '参数BOM2', type: 'param', id: 2 }, + { name: '参数BOM3', type: 'param', id: 3 }, + { name: '参数BOM4', type: 'param', id: 4 }, + { name: '参数BOM5', type: 'param', id: 5 }, + ], + materialBomList: [ + { name: '物料BOM1', type: 'material', id: 1 }, + { name: '物料BOM2', type: 'material', id: 2 }, + { name: '物料BOM3', type: 'material', id: 3 }, + { name: '物料BOM4', type: 'material', id: 4 }, + { name: '物料BOM5', type: 'material', id: 5 }, + ], + }, + ], + }, + selectedList: [], }; }, computed: {}, @@ -101,8 +159,8 @@ export default { } this.bomLoading = false; }, - // - handleChange() {} + // + handleChange() {}, }, }; diff --git a/src/views/extend/processFlowView/components/CustomTransferBox.vue b/src/views/extend/processFlowView/components/CustomTransferBox.vue index ca4a3574..95098dee 100644 --- a/src/views/extend/processFlowView/components/CustomTransferBox.vue +++ b/src/views/extend/processFlowView/components/CustomTransferBox.vue @@ -26,7 +26,7 @@ - +
@@ -64,19 +53,12 @@
参数BOM
- - - + +
@@ -84,9 +66,10 @@ ; 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"> - +