基于jeecgboot框架
需求:实现部门层级之间的联动
方法:通过jeecg数据库的字段实现,id与对应的parent_id
代码如下:
<a-col :span="24">
<a-form-model-item label="部门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="deprtId">
<j-dict-select-tag v-model="model.deprtId" dictCode="sys_depart,depart_name,id,(org_type = '2')" />
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="所在班组" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wcgId">
<j-dict-select-tag v-model="model.wcgId" :dictCode="`sys_depart,depart_name,id,(parent_id = '${model.deprtId}' )`" />
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="岗位名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="postId">
<j-dict-select-tag v-model="model.postId" :dictCode="`sys_depart,depart_name,id,(parent_id = '${model.wcgId}' )`" />
</a-form-model-item>
</a-col>
解释:
-
j-dict-select-tag :封装过的部门组件
-
dictCode :用来匹配规则
-
sys_depart,depart_name,id,(org_type = ‘2’) :匹配到想要的表。再根据括号内数据表字段的判断匹配想要的数据,,这个就是匹配 org_type 为 2 的数据。
-
关键代码:
:dictCode="`sys_depart,depart_name,id,(parent_id = '${model.deprtId}' )` `"
jeecg中数据表根据parent_id和id区分层级,所以根据parent_id匹配数据
写法:注意冒号和 ` 以及${ }