This commit is contained in:
“hhk” 2024-08-06 17:20:19 +08:00
parent 8453a68898
commit 857d522b82
2 changed files with 105 additions and 1 deletions

View File

@ -0,0 +1,104 @@
<template>
<div>
<el-cascader
:options="options"
:props="cascaderProps"
v-model="selectedOptions"
@visible-change="handleVisibleChange"
:filter-method="handleFilter"
placeholder="请选择"
filterable
:show-all-levels="false"
/>
</div>
</template>
<script>
export default {
props: {
brandId: {
type: String,
required: true
},
},
data() {
return {
options: [], //
selectedOptions: [], //
loading: false, //
};
},
computed: {
cascaderProps() {
return {
lazy: true, //
lazyLoad: this.loadData, //
value: 'value',
label: 'label',
children: 'children',
emitPath: false,
multiple: false //
};
},
},
methods: {
//
handleVisibleChange(visible) {
if (visible && this.options.length === 0) {
this.loadData(null, [], (options) => {
this.options = options;
});
}
},
//
loadData(node, resolve) {
if (node) {
//
setTimeout(() => {
const children = [
{ value: 'child1', label: '子节点 1' },
{ value: 'child2', label: '子节点 2' },
];
resolve(children);
}, 100);
} else {
//
setTimeout(() => {
const root = [
{ value: 'root1', label: '根节点 1' },
{ value: 'root2', label: '根节点 2' },
];
resolve(root);
}, 100);
}
},
//
handleFilter(inputValue, path) {
console.log('Filtering:', inputValue);
//
setTimeout(() => {
const filteredOptions = [
{
value: 'filtered1',
label: `Filtered ${inputValue} 1`,
children: [
{ value: 'filtered1-1', label: `Filtered ${inputValue} 1-1` },
{ value: 'filtered1-2', label: `Filtered ${inputValue} 1-2` },
],
},
{
value: 'filtered2',
label: `Filtered ${inputValue} 2`,
children: [
{ value: 'filtered2-1', label: `Filtered ${inputValue} 2-1` },
{ value: 'filtered2-2', label: `Filtered ${inputValue} 2-2` },
],
},
];
this.options = filteredOptions;
}, 1000); //
},
},
};
</script>

View File

@ -73,7 +73,7 @@
</div>
<el-row>
<el-empty v-if="formData.cusList.length == 0" description="暂无客户信息" :image-size="100"></el-empty>
<el-col v-for="item in formData.cusList" :span="8">
<el-col v-for="item in formData.cusList" :span="8" :key="item.id">
<el-card shadow="hover">
<el-descriptions>
<template slot="title">