1
lzhe
2024-05-02 5237d75a9c44b033c72120d41382a3906fd5cd1c
src/views/console/system/data-scope-manager.vue
@@ -2,7 +2,7 @@
 * @Author: lzhe lzhe@example.com
 * @Date: 2024-03-26 10:28:33
 * @LastEditors: lzhe lzhe@example.com
 * @LastEditTime: 2024-04-17 18:02:12
 * @LastEditTime: 2024-05-02 22:20:47
 * @FilePath: /smart-web/src/views/master/person/main/index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
@@ -10,10 +10,10 @@
   <div class="dict-main">
      <el-form :inline="true" :model="searchData" abel-width="120px">
         <el-form-item label="权限名称">
            <el-input v-model="searchData.name" placeholder="权限名称" clearable />
            <el-input v-model="searchData.deptName" placeholder="权限名称" clearable />
         </el-form-item>
         <el-form-item label="权限描述">
            <el-input v-model="searchData.code" placeholder="权限描述" clearable></el-input>
            <el-input v-model="searchData.deptName" placeholder="权限描述" clearable></el-input>
         </el-form-item>
         <el-form-item>
            <el-button type="primary" @click="searchclick">搜索</el-button>
@@ -22,26 +22,29 @@
      </el-form>
      <div>
         <div style="margin-bottom: 12px;">
            <el-button type="primary">添加</el-button>
            <el-button type="primary" @click="addData">添加</el-button>
            <el-button type="danger" @click="delData">删除</el-button>
            <el-button type="primary" @click="addAuthority">权限设置</el-button>
         </div>
         <div class="dict-table">
            <el-table ref="multipleTableRef" :data="tableData" border row-key="id" style="width: 100%" class="multipleTableRef" @selection-change="handleSelectionChange" :tree-props="{ children: 'children', hasChildren: 'has' }">
               <el-table-column type="selection" width="55" />
               <el-table-column prop="test" label="权限名称"></el-table-column>
               <el-table-column prop="test" label="权限描述"></el-table-column>
               <el-table-column prop="test" label="权限类型"></el-table-column>
               <el-table-column prop="test" label="排序"></el-table-column>
               <el-table-column fixed="right" label="操作">
               <el-table-column prop="deptName" label="权限名称"></el-table-column>
               <el-table-column prop="fullName" label="权限描述"></el-table-column>
               <el-table-column prop="deptCategoryName" label="权限类型"></el-table-column>
               <el-table-column prop="sort" label="排序"></el-table-column>
               <el-table-column fixed="right" label="操作" width="280">
                  <template #default="scope">
                     <el-button text type="primary" size="small" @click="showDrawer(scope.row, scope.$index)">权限配置</el-button>
                     <el-button text type="primary" size="small" @click="table_show(scope.row, scope.$index)">查看</el-button>
                     <el-button text type="primary" size="small" @click="showDrawer(scope.row, scope.$index)">编辑</el-button>
                     <el-button text type="primary" size="small" @click="showDrawer(scope.row, scope.$index)">删除</el-button>
                     <el-button text type="primary" size="small" @click="showDrawer(scope.row, scope.$index)">新增子项</el-button>
                  </template>
               </el-table-column>
            </el-table>
         </div>
      </div>
      <save-dialog v-if="dialog.save" ref="saveDialog" :scopeTypeNameList="scopeTypeNameList" :tableRow="tableRow" @success="addDatascopeSuccess" @closed="dialog.save=false"></save-dialog>
      <save-dialog v-if="dialog.save" ref="saveDialog" :deptCategoryList="deptCategoryList" :parentIdList ="parentIdList" @success="addDatascopeSuccess" @closed="dialog.save=false"></save-dialog>
   </div>
</template>
<script>
@@ -77,46 +80,55 @@
               size: 10
            },
            searchData: {
               name: "",
               code: "",
               belongApplication: "",
               parentId: ""
               deptName: "",
               fullName: "",
               parentId: "0"
            },
            dialog: {
               save: false,
               allocation: false
            },
            tableData: [],
            drawerTableData: [],
            rowId: "",
            tableRow: {}
            tableRow: {},
            parentIdList: [],
            deptCategoryList: []
         }
      },
      created(){
         
      },
      mounted(){
         this.getscopeTypeNameList();//规则分类枚举
         this.searchBtn();
         this.getDictionary();
         this.getParentIdList();
      },
      components: {
          ...ElementPlusIconsVue,saveDialog
       },
      methods: {
         getscopeTypeNameList() {  //规则分类枚举
            this.$HTTP.get("/api/blade-system/dict/dictionary?code=data_scope_type").then(res=> {
         getParentIdList() {
            this.$HTTP.get("/api/blade-system/data-scope-manager/tree").then(res=> {
               if(res.code == 200) {
                  this.scopeTypeNameList = res.data;
                  this.parentIdList = res.data;
               }
            })
         },
         getDictionary() {
            this.$HTTP.get("/api/blade-system/dict/dictionary?code=data_scope_category").then(res=> {
               if(res.code == 200) {
                  this.deptCategoryList = res.data;
               }
            })
         },
         addDatascopeSuccess() {
            this.drawerSearchclick();
            this.searchclick();
         },
         //添加
         addData(){
            this.dialog.save = true
            this.dialog.save = true;
            this.$nextTick(() => {
               this.$refs.saveDialog.open()
               this.$refs.saveDialog.open();
            })
         },
         addAuthority() {
@@ -143,7 +155,6 @@
            this.$HTTP.post("/api/blade-system/data-scope/remove?ids="+selStr).then(res=> {
               if(res.code == 200) {
                  that.$message.success("操作成功");
                  that.drawerSearchclick();
               }
            })
         },
@@ -173,17 +184,12 @@
               this.$HTTP.post("/api/blade-system/data-scope/remove?ids="+row.id).then(res=> {
                  if(res.code == 200) {
                     that.$message.success("操作成功");
                     that.drawerSearchclick();
                  }
               })
            }).catch(() => {
            })
         },
         handleClose(done) {
            this.drawerTableData = [];
              done();
          },
         exportFile(row,index){
            window.open(row.link);
         },
@@ -192,9 +198,8 @@
         },
         searchClearBtn() {
            this.searchData = {
               name: "",
               code: "",
               belongApplication: "",
               deptName: "",
               fullName: "",
               parentId: ""
            }
            this.searchBtn();
@@ -202,33 +207,7 @@
         showDrawer(row){
            this.rowId = row.id;
            this.tableRow = row;  //后面组件会用到
            this.drawerSearchclick();
            this.drawer = true;
         },
         drawerSearchclick() {
            var obj = {};
            for(var key in this.drawerSearchData) {
               if(this.drawerSearchData[key]) {
                  obj[key] = this.drawerSearchData[key];
               }
            }
            obj.menuId = this.rowId;
            this.$HTTP.get("/api/blade-system/data-scope/list?"+this.$TOOL.qsStringify(obj)).then(res=> {
               if(res.code == 200) {
                  this.drawerTableData = res.data.records;
                  this.drawerTotal = res.data.total;
               }
            })
         },
         drawerSearchClearBtn() {
            this.drawerSearchData = {
               scopeName: "",
               resourceCode: "",
               menuId: this.rowId,
               current: 1,
               size: 10
            }
            this.drawerSearchclick();
         },
         searchclick() {
            this.searchBtn();
@@ -240,11 +219,11 @@
                  obj[key] = this.searchData[key];
               }
            }
            // this.$HTTP.get("/api/blade-system/menu/lazy-menu-list",obj).then(res=> {
            //    if(res.code == 200) {
            //       this.tableData = res.data;
            //    }
            // })
            this.$HTTP.get("/api/blade-system/data-scope-manager/lazy-list?" + this.$TOOL.qsStringify(obj)).then(res=> {
               if(res.code == 200) {
                  this.tableData = res.data;
               }
            })
         },
         handleSelectionChange(selection) {
            this.selection = selection;
@@ -259,12 +238,10 @@
            console.log(`每页 ${val} 条`);
            this.drawerSearchData.current = "1";
            this.drawerSearchData.size = val;
            this.drawerSearchclick();
         },
         handleCurrentChange(val) {
            console.log(`当前页: ${val}`);
            this.drawerSearchData.current = val;
            this.drawerSearchclick();
         }
      }
   }