This commit is contained in:
lb 2023-11-21 11:48:17 +08:00
parent 32a43fbc3b
commit 847e34fcc6
2 changed files with 42 additions and 14 deletions

View File

@ -27,10 +27,10 @@ export default {
// event: 'update',
// },
props: {
// selected: {
// type: String,
// default: '',
// },
currentSelect: {
type: String,
default: null,
},
list: {
type: Array,
default: () => [],
@ -44,7 +44,7 @@ export default {
return {
list__inner: [],
selected: null,
randomKey: Math.random()
randomKey: Math.random(),
};
},
watch: {
@ -57,6 +57,12 @@ export default {
deep: true,
immediate: true,
},
currentSelect: {
handler(val) {
this.selected = val;
},
immediate: true,
},
},
methods: {
handleChange(bomItem, selected) {
@ -76,7 +82,7 @@ export default {
clearSelected() {
console.log('clearSelected');
this.selected = null;
this.randomKey = Math.random()
this.randomKey = Math.random();
// this.$emit('update', null);
// this.$nextTick(() => {
// this.$forceUpdate();

View File

@ -29,13 +29,21 @@
</span>
</div>
<div class="sl__body">
<el-checkbox
<div
class="sl__body-item"
v-for="eq in filteredBomList"
:key="eq.id + refreshKey"
:label="eq.name"
:checked="selectedEquipments.includes(eq.id)"
@change="(e) => handleEquipmentChange(eq, e)"
class="sl__body-item"></el-checkbox>
:key="eq.id + refreshKey">
<el-checkbox
:key="refreshKey"
:checked="selectedEquipments.includes(eq.id)"
@change="(e) => handleEquipmentChange(eq, e)"
class=""></el-checkbox>
<span
:key="'label' + refreshKey"
@click.stop="() => handleLoadDom(eq)">
{{ eq.name }}
</span>
</div>
</div>
</div>
</el-col>
@ -47,9 +55,10 @@
<BomSelection
ref="materialsBomList"
key="materialsBomList"
:key="materialsBomList.equipmentId + 'materialsBomList'"
:list="materialsBomList"
:equipment-id="materialsBomList.equipmentId"
:current-select="currentSelectedMaterialBomId"
@change="handleMaterialBomChange" />
</div>
</el-col>
@ -61,9 +70,10 @@
<BomSelection
ref="valuesBomList"
key="valuesBomList"
:key="valuesBomList.equipmentId + 'valuesBomList'"
:list="valuesBomList"
:equipment-id="valuesBomList.equipmentId"
:current-select="currentSelectedValueBomId"
@change="handleValueBomChange" />
</div>
</el-col>
@ -98,6 +108,8 @@ export default {
materialsBomList: [],
valuesBomList: [],
refreshKey: Math.random(),
currentSelectedMaterialBomId: null,
currentSelectedValueBomId: null,
};
},
watch: {
@ -124,6 +136,14 @@ export default {
commit() {
this.$emit('update', this.selected);
},
handleLoadDom(eq) {
// dom
this.currentEquipment = eq.id;
this.materialsBomList = eq.materialsBom;
this.valuesBomList = eq.valuesBom;
},
handleEquipmentChange(eq, selected) {
this.currentEquipment = eq.id;
this.materialsBomList = eq.materialsBom;
@ -169,6 +189,7 @@ export default {
return;
}
selectedItem && (selectedItem.equMaterialBomId = selected ? bomId : null);
this.currentSelectedMaterialBomId = selected ? bomId : null;
// this.$emit('update', this.selected);
},
@ -189,6 +210,7 @@ export default {
return;
}
selectedItem && (selectedItem.equValueBomId = selected ? bomId : null);
this.currentSelectedValueBomId = selected ? bomId : null;
// this.$emit('update', this.selected);
},
},