<el-table-column prop="createTime" label="编辑店铺分类">
<template slot-scope="scope">
<el-cascader
ref="cascader"
v-model="scope.row.shoptypeone"
:options="commoditylist"
placeholder="请选择商品分类"
@change="shoptypeoneChange(scope.row, $event)"
></el-cascader>
</template>
</el-table-column>
shoptypeoneChange(row,selectedNodes) {
console.log(row,)
// let nodesObj = this.$refs['cascader'].getCheckedNodes()
// console.log('===>val', val)
console.log('===>val', selectedNodes)
// let parmas={
// proId:val.id,
// oneTypeId:1
// }
// updateElectronicProductOneSelfType().then(({ code, data }) => {
// if (code !== 200) return;
// this.commoditylist=data
// });
// this.shopinfo.oneTypeId=value[0]
// this.shopinfo.twoTypeId=value[1]
},
效果:
补充:
1,设置对应字段为label ,value
:props="{label:'name',value:'name',children:'items' }"
<el-cascader
v-model="shopinfo.shoptypeone"
:options="commoditytype"
placeholder="请选择门店分类"
:props="{label:'name',value:'name',children:'items' }"
@change="shoptypeoneChange"
></el-cascader>
ps:当设置字段不生效时候可使用下面方法替换,
this.shoptype.forEach(option => {
option.label = option.name; // 修改 name 为 label
option.value = option.id; // 修改 id 为 value
delete option.name; // 删除原始的 name 字段
delete option.id; // 删除原始的 name 字段
if (option.electronicProductTypeTwos) {
option.children = option.electronicProductTypeTwos.map(child => ({
label: child.name, // 修改 name 为 label
value: child.typeOneId, // 修改 typeOneId 为 value
}));
delete option.electronicProductTypeTwos; // 删除原始的 electronicProductTypeTwos 字段
}
});