<el-form-item
label="部门"
prop="departments"
>
<el-cascader
v-model="form.departments"
:options="departOptions"
:show-all-levels="false"
:props="{
label: 'name',
value: 'id',
children: 'child',
multiple: true,
emitPath: false
}"
clearable
size="mini"
style="width:100%"
>
</el-cascader>
</el-form-item>
departments: [{ type: 'array', required: true, validator: checkDepartments}]
const checkDepartments = (rule, value, cb) => {
if (this.form.departments.length === 0) {
cb(new Error('请选择部门'));
} else {
cb();
}
}
//回显
this.form.departments = res.data.departments.map(item => item.id)