提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
前言
。
点击列表某一行进行新增,传入改行部门id进行表单,表单对应字段默认选中该选项。
代码如下(示例):
下拉选择:
<el-select v-model="form.parentId" placeholder="请选择" size="mini">
<el-option
v-for="(item, index) in orgList"
:key="index"
:label="item.deptName"
:value="item.deptId"
></el-option>
</el-select>
获取数据:
listPartyOrg().then(res => {
this.orgList = res.data
this.orgList.push({deptName: '无', deptId: 0})
this.form.parentId = (this.orgList.find(item => item.deptId == (this.$route.query['deptId'] || '')) || '').deptId
})
总结
先获取选项列表,再选中列表中对应id的对象value,el-select会自动展示对应的lable。