gaoshp
2024-11-19 f29900986f01cf5d39b5755cec674825cef27961
src/views/console/system/add-scope-manager.vue
@@ -14,9 +14,18 @@
            </el-col>
            <el-col :span="12">
               <el-form-item label="上级权限">
                  <el-select v-model="addDictForm.parentId" placeholder="请选择上级权限" style="width: 100%" @change="parentIdChange" :disabled="mode=='add'">
                     <el-option v-for="item in parentIdList" :key="item.parentId" :label="item.title" :value="item.parentId"/>
                  </el-select>
                  <el-tree-select
                     @change = "parentIdChange"
                      v-model="addDictForm.parentId"
                      clearable
                     node-key="id"
                      placeholder="上级权限"
                     ref="parentTree"
                      :data="parentIdList"
                      check-strictly
                      :props="{ label: 'title' }"
                      style="width:100%;"
                      :render-after-expand="false" />
               </el-form-item>
            </el-col>
            <el-col :span="12">
@@ -100,11 +109,8 @@
      },
      methods: {
         parentIdChange(value) {
            this.parentIdList.forEach(item=> {
               if(item.parentId == value) {
                  this.addDictForm.$parentId = item.title;
               }
            })
            var $parentId = this.$refs.parentTree.getCurrentNode().title;
            this.addDictForm.$parentId = $parentId;
         },
         deptCategoryChange(value) {
            this.deptCategoryList.forEach(item=> {
@@ -114,8 +120,10 @@
            })
         },
         //显示
         open(mode='add'){
         open(parentIdList,deptCategoryList,mode='add'){
            this.mode = mode;
            this.parentIdList = parentIdList;
            this.deptCategoryList = deptCategoryList;
            this.visible = true;
            return this
         },
@@ -128,12 +136,19 @@
            var res = await this.$API.system.dept.list.get();
            this.depts = res.data;
         },
         getDetail(id) {
            console.log(this.deptCategoryList)
         getDetail(id,fixed) {
            this.$HTTP.get(`/api/blade-system/data-scope-manager/detail?id=${id}`).then(res=> {
               if(res.code == 200) {
                  //可以和上面一样单个注入,也可以像下面一样直接合并进去
                  Object.assign(this.addDictForm, res.data);
                  res.data.parentId == 0?res.data.parentId = "":res.data.parentId;
                  res.data.$parentId = res.data.parentName;
                  res.data.$deptCategory = res.data.deptCategoryName;
                  res.data.deptCategory = String(res.data.deptCategory);
                  if(fixed) { //新增子项
                     this.addDictForm.parentId = id;
                  }else {
                     Object.assign(this.addDictForm, res.data);
                  }
               }
            })
         },
@@ -160,7 +175,7 @@
         },
         //表单注入数据
         setData(data){
            this.getDetail(data.id);
            this.getDetail(data.id,data.fixed);
         }
      }
   }