update bom-selector v1

This commit is contained in:
lb
2023-11-20 15:51:47 +08:00
parent dd23c49ba0
commit ac041c2f4a
7 changed files with 126 additions and 457 deletions

View File

@@ -9,9 +9,10 @@
<div class="bom-selection">
<el-checkbox
v-for="item in list__inner"
:key="item.id"
:key="item.id + randomKey"
:label="item.name"
:disabled="item.disabled"
:checked="item.id === selected"
@change="(e) => handleChange(item, e)"
class="sl__body-item"></el-checkbox>
</div>
@@ -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();
// });
},
},
};
</script>