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

View File

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