1.后端

直接在service里面查到所有数据

//查出所有的数据       
 ajax.put("posts", positionService.selectSysPositionAll());
// 根据id查出对应的
ajax.put("postIds", positionService.selectPositionListByUserId(userId));
    <select id="selectPositionListByUserId" parameterType="Long" resultType="Long">
        select p.position_id
        from sys_position p
                 left join sys_user_post up on up.position_id = p.position_id
                 left join sys_user u on u.user_id = up.user_id
        where u.user_id = #{userId}
    </select>


前端

            <el-form-item label="岗位">
              <el-select v-model="form.positions" multiple placeholder="请选择岗位">
                <el-option
                  v-for="item in positionOptions"
                  :key="item.positionId"
                  :label="item.positionName"
                  :value="item.positionId"
                  :disabled="item.status == 1"
                ></el-option>
              </el-select>
            </el-form-item>

export default {
  name: "User",
  dicts: ['sys_normal_disable', 'sys_user_sex'],
  components: { Treeselect },
  data() {
    return {
      positionOptions:[],
}

Logo

快速构建 Web 应用程序

更多推荐