1:
<el-cascader
style="width: 100%"
:options="scheduleOptions"
v-model="form.scheduleId"
:show-all-levels="false"
:props="cascaderProps"
>
</el-cascader>
使用 el-cascader 必须有这三个属性
scheduleOptions: [{
value: 'zhinan',
label: '指南',
children: [{
value: 'shejiyuanze',
label: '设计原则',
}]
]}
如果没有就需要配置:
// 级联选择器配置
cascaderProps: { emitPath: false, value: "id", label: "items" },
获取 scheduleOptions 的相关代码
async listAllActivity() {
const { data } = await listScheduleByConditonsApi(
0,
0,
this.projectId,
0,
"",
"",
"",
"",
{},
{},
{},
{},
"",
[["sort", "asc"]]
);
const schedules = data.data.list;
const stages = schedules.filter((o) => o.category === "Stage");
const activities = schedules.filter((o) => o.category === "Activity");
this.scheduleOptions = stages.map((item) => {
const children = activities.filter((o) => o.parentId === item.id);
return {
...item,
children,
};
});
},