Преглед изворни кода

Merge branch 'cheng' into dev

Cheng пре 3 година
родитељ
комит
ec1db74da9
2 измењених фајлова са 143 додато и 128 уклоњено
  1. 83 98
      src/views/dataPermission/index.vue
  2. 60 30
      src/views/role/index.vue

+ 83 - 98
src/views/dataPermission/index.vue

@@ -14,8 +14,10 @@
         ref="dataTable"
         v-loading="loading"
         :data="tableData"
+        max-height="370"
         border
-       @select="changeData"
+        @expand-change="getNode"
+        @select="changeData"
         header-row-class-name="custom-table-header"
     >
       <el-table-column type="selection" width="60" align="center"></el-table-column>
@@ -33,8 +35,8 @@
         </template>
       </el-table-column>
     </el-table>
-    <el-dialog :title="title" :visible.sync="visible" width="800px" :before-close="close" :append-to-body="true">
-      <el-form v-if="visible" :model="ruleForm" :rules="rules" ref="ruleForm" label-width="80px" label-position="left">
+    <el-dialog :title="title" :visible.sync="visible" width="900px" :before-close="close" :append-to-body="true">
+      <el-form v-if="visible" :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" label-position="left">
            <el-form-item label="所属功能" prop="function">
             <el-input v-model="ruleForm.function" size="small" :readonly="true" placeholder="请输入所属功能"></el-input>
         </el-form-item>
@@ -43,43 +45,45 @@
         </el-form-item>
         <el-form-item label="数据权限">
              <template>
-              <div class="add"><el-button type="primary" @click="addList()">添加</el-button> </div>
-                  <div style="border:1px solid #C0C0C0;border-radius:4px;overflow:auto;min-height:200px;padding: 10px 20px">
-                    <el-row :gutter="24" v-for="(item,i) in list" :key="i" class="listItem">
-                      <el-col :span="4" style="padding:0">
-                        <span>
-                          <span v-if="i==0" style="opacity: 0;"> 内容 </span>
-                          <el-select v-else v-model="item.logicOpr">
-                              <el-option
-                          v-for="item in dictionaries.LOGIC_OPERATOR"
-                          :key="item.dictChildValue"
-                          :label="item.dictChildLabel"
-                          :value="item.dictChildValue">
-                        </el-option>
-                          </el-select>
-                        </span>
-                      </el-col>
-
-                      <el-col :span="7">
-                        <el-select v-model="item.field">
-                            <el-option
-                          v-for="item in dictionaries.dataDict"
-                          :key="item.dataSourceField"
-                          :label="item.dataSourceName"
-                          :value="item.dataSourceField">
-                        </el-option>
+              <div class="add">
+                <el-button type="primary" @click="addList()">添加</el-button>
+              </div>
+                <div style="border:1px solid #C0C0C0;border-radius:4px;overflow:auto;min-height:200px;padding: 10px 20px">
+                  <el-row :gutter="24" v-for="(item,i) in list" :key="i" class="listItem">
+                    <el-col :span="4" style="padding:0">
+                      <span>
+                        <span v-if="i==0" style="opacity: 0;"> 内容 </span>
+                        <el-select v-else v-model="item.logicOpr">
+                          <el-option
+                            v-for="item in dictionaries.LOGIC_OPERATOR"
+                            :key="item.dictChildValue"
+                            :label="item.dictChildLabel"
+                            :value="item.dictChildValue">
+                          </el-option>
                         </el-select>
-                      </el-col>
-                      <el-col :span="3" style="padding:0">
-                        <el-select v-model="item.opr">
-                            <el-option
-                          v-for="item in dictionaries.OPERATOR"
-                          :key="item.dictChildValue"
-                          :label="item.dictChildLabel"
-                          :value="item.dictChildValue">
+                      </span>
+                    </el-col>
+
+                    <el-col :span="7">
+                      <el-select v-model="item.field">
+                        <el-option
+                        v-for="item in dictionaries.dataDict"
+                        :key="item.dataSourceField"
+                        :label="item.dataSourceName"
+                        :value="item.dataSourceField">
+                      </el-option>
+                      </el-select>
+                    </el-col>
+                    <el-col :span="3" style="padding:0">
+                      <el-select v-model="item.opr">
+                        <el-option
+                        v-for="item in dictionaries.OPERATOR"
+                        :key="item.dictChildValue"
+                        :label="item.dictChildLabel"
+                        :value="item.dictChildValue">
                         </el-option>
-                        </el-select>
-                      </el-col>
+                      </el-select>
+                    </el-col>
                       <el-col :span="7">
                         <el-select v-model="item.value"
                           filterable
@@ -124,11 +128,13 @@ export default {
     Treeselect,
     TreeItem
   },
+  props: [
+    'functionId',
+    'functionName',
+    'functionInfo'
+  ],
   data() {
     name: 'DataPermission'
-    props: {
-
-    }
     return {
       options:[{label:'你好',value:1},{label:'你好1',value:2},{label:'你好2',value:3}],   
       visible: false,
@@ -139,7 +145,10 @@ export default {
       title: '',
       show:false,
       disabled:false,
-      lastName:'',
+      lastName: '',
+      funId: this.functionId,
+      funName: this.functionName,
+      funInfo: this.functionInfo,
       functionLis: [],
       multipleSelection: [],
       queryParams: {
@@ -155,45 +164,17 @@ export default {
         parentId: [{ required: true, message: '请选择所属部门', trigger: 'change' },],
       },
       list:[],
-      
-      dataList:
-        {
-          "nodeType": "logic",
-          "logicOpr": "or",
-          "left":{
-              "nodeType": "logic",
-              "logicOpr": "and",
-              "left": {
-              "nodeType": "exp",
-                "field": "POSITION_DESCRIPTION",
-                "opr": "=",
-                "value": "'总经理1'"
-              },
-              "right": {
-                "nodeType": "exp",
-                "field": "POSITION_DESCRIPTION",
-                "opr": "=",
-                "value": "'总经理2'"
-              }
-            },
-          "right": {
-            "nodeType": "exp",
-            "field": "POSITION_DESCRIPTION",
-            "opr": "=",
-            "value": "'总经理3'"
-          }
-
-      }
     }
   },
   created(){
-   
+    
   },
  
   mounted() {
     this.getList()
     this.getFunctionList()
-    // this.ListToTree()
+    this.funId = 6
+    // this.$emit('getPremissData', this.funId)
   },
   computed: {
     dictionaries() {
@@ -205,7 +186,14 @@ export default {
     }
   },
   methods: {
-    changeData(selection,row){
+        handleSelectionChange(val) {
+      this.multipleSelection = val;
+      if (val.length > 0) {
+        this.$emit('getPremissData', this.funId, this.funName, val[0])
+      }
+      // console.log(val[0])
+    },
+       changeData(selection,row){
       if (selection.length > 1) {
           const del_row = selection.shift()
           this.$refs.dataTable.toggleRowSelection(del_row, false)
@@ -220,7 +208,6 @@ export default {
       this.list.splice(i, 1)
     },
     ListToTree(){
-      console.log(this.dataList)
       var a =[]
       if(this.list.length==1){
         a = this.list[0]
@@ -235,14 +222,10 @@ export default {
           a[i].nodeType='logic'
           a[i].right=this.list[i]
           a[i].logicOpr = this.list[i].logicOpr
-          // delete  a[i].right.logicOpr
-          // delete  a[i].left.logicOpr
-          
         }
       }
       console.log(a)
       this.ruleForm.rule = JSON.stringify(a[a.length-1])
-      // this.TreeToList(a[a.length-1])
     },
     TreeToList(data){
        var root = data
@@ -273,25 +256,23 @@ export default {
     }
     l(root)
           // console.log(result)
-          var i=0
-          var c=0
-          function s(i){
-          if(i<result.length){
-            
-            if(i==0){
-              a.push(result[i])
-              i+=1
-              c+=1
-            }
-            if(i%2==1){
-              a.push(result[i])
-              // console.log(a[c])
-              a[c]['logicOpr'] = result[i+1].logicOpr
-              i+=2
-               c+=1
-            }
-            
-            s(i)
+        var i=0
+        var c=0
+        function s(i){
+        if(i<result.length){
+          if(i==0){
+            a.push(result[i])
+            i+=1
+            c+=1
+          }
+          if(i%2==1){
+            a.push(result[i])
+            // console.log(a[c])
+            a[c]['logicOpr'] = result[i+1].logicOpr
+            i+=2
+             c+=1
+          }
+          s(i)
         }
       }
       s(i)
@@ -331,6 +312,7 @@ export default {
       this.$api.getDataList(this.queryParams).then(response => {
         
         this.tableData = response.data
+        console.log(response.data)
         this.total=response.pageColumn.total
         this.loading = false
       }).catch(error => {
@@ -341,6 +323,9 @@ export default {
       this.$api.getFunctionList().then(response => {
         this.functionList = response.data
       })
+      console.log(this.funId)
+      console.log(this.functionName)
+      console.log(this.functionInfo)
     },
     submit() {
       this.$refs.ruleForm.validate((valid) => {

+ 60 - 30
src/views/role/index.vue

@@ -16,12 +16,14 @@
         header-row-class-name="custom-table-header"
         :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
     >
-      <el-table-column prop="name" label="角色名称" align="" show-overflow-tooltip></el-table-column>
+      <el-table-column prop="name" label="角色名称" align="" show-overflow-tooltip>
+
+      </el-table-column>
       <el-table-column label="功能权限" align="center" show-overflow-tooltip>
-        <!-- <template slot-scope="scope">
-          <span v-for="item in scope.row.functionList">{{item.name}}
+        <template slot-scope="scope">
+          <span v-for="item in scope.row.functionList" :key="item.id">{{item.name}}
           </span>
-        </template> -->
+        </template>
       </el-table-column>
       <el-table-column label="数据权限" align="center" show-overflow-tooltip>
          <template slot-scope="scope">
@@ -64,18 +66,23 @@
             >
               <el-table-column type="expand">
                 <template style="width:80%;" slot-scope="scope">
-                  <div >
+                  <div>
                     <el-table
                         border
                         :data="scope.row.children"
                         row-key="id"
                         ref="multiTable"
+                        
                         @selection-change="handleSelectionChange"
                       >
                       <el-table-column label="功能名称" align="left" prop="name">
                         <template slot-scope="scope">
                           <el-checkbox-group v-model="checkList" style="display:inline-block" @change="handleCheckedCitiesChange">
-                            <el-checkbox :label="scope.row.id">{{scope.row.name}}</el-checkbox></el-checkbox-group>
+                            <el-checkbox :label="scope.row.id" @change="getFunInfo(scope.row)"
+                            >
+                              {{scope.row.name}}
+                            </el-checkbox>
+                          </el-checkbox-group>
                         </template>
                       </el-table-column>
                       <el-table-column label="操作" align="center">
@@ -95,17 +102,6 @@
               </el-table-column>
             </el-table>
           </el-form-item>
-          <el-form-item label="数据权限" prop="data" v-if="showDataList">
-            <el-cascader
-              v-model="ruleForm.data"
-              :options="dataList"
-              :props="{multiple:true, checkStrictly: false,value:'id',label:'dataName' }"
-              collapse-tags
-              placeholder="请输入数据权限"
-              clearable
-              style="width:100%">
-            </el-cascader>
-          </el-form-item>
           <el-form-item label="备注" prop="remark">
             <el-input v-model="ruleForm.remark" placeholder="请输入备注" type="textarea" maxlength="100" show-word-limit></el-input>
           </el-form-item>
@@ -114,12 +110,22 @@
         <div slot="footer" class="dialog-footer">
           <el-button @click="close">取 消</el-button>
           <el-button type="primary" @click="submit" :loading="btnLoading">确 定</el-button>
-      </div>
+        </div>
     </el-dialog>
     <!-- 新增中选中功能后的添加弹窗 -->
     <el-dialog :title="permissTitle" :visible.sync="permissVisible" width="1100px" :before-close="premissClose" custom-class="permiss">
-    <div style="height: 600px;">
-      <DataPermission></DataPermission>
+    <div style="height: 500px;">
+      <DataPermission 
+      :functionId="functionId"
+      :functionName="functionName"
+      :functionInfo="functionInfo"
+      @getPremissData="getPremissData"
+      >
+      </DataPermission>
+    </div>
+    <div slot="footer" class="dialog-footer">
+      <el-button @click="premissClose">取 消</el-button>
+      <el-button type="primary" @click="premissSubmit" :loading="btnLoading">确 定</el-button>
     </div>
     </el-dialog>
   </div>
@@ -136,6 +142,9 @@ export default {
   },
   data() {
     return {
+      functionId: '',
+      functionName: '',
+      functionInfo: [],
       checkList:[],
       checked: true,
       visible: false,
@@ -178,14 +187,31 @@ export default {
     }
   },
   methods: {
-   
-   handleCheckedCitiesChange(value) {
-        console.log(value)
-      },
-      handleSelectionChange(val) {
-        console.log( val,this.$refs.multipleTable.selection)
-        this.multipleSelection = val;
-      },
+    getPremissData(id, name, data) {
+      if (this.functionInfo.length === 0) {
+        this.functionInfo.push({
+          'functionId': id,
+          'functionName': name,
+          'dataPremiss': data
+        })
+      } 
+      else if (this.functionInfo.length > 0) {
+        console.log(this.functionInfo.some(item => item.dataPremiss === data))
+      }
+      console.log(this.functionInfo)
+    },
+    getFunInfo(val) {
+      this.functionId = val.id
+      this.functionName = val.name
+    },
+    handleCheckedCitiesChange(value) {
+        // console.log(value)
+    },
+    handleSelectionChange(val) {
+      // console.log(val,this.$refs.multipleTable.selection)
+      this.multipleSelection = val;
+      // console.log(val)
+    },
     normalizer(node) {
       return {
         id: node.id,
@@ -211,8 +237,12 @@ export default {
     close() {
       this.visible = false
     },
+    premissSubmit() {
+      console.log('')
+    },
     premissClose() {
       this.permissVisible = false
+      console.log(this.functionId)
     },
      handleCurrentChange(val) {
       this.queryParams.current = val;
@@ -224,7 +254,6 @@ export default {
       //   functions:this.ruleForm.function 
       // }
       if(val==false){
-  
         this.$api.getDataList({functionList:this.ruleForm.function}).then(response => {
         this.dataList = response.data
       })
@@ -240,6 +269,7 @@ export default {
       this.loading = true
       this.$api.getRoleList(this.queryParams).then(response => {
         this.tableData = response.data
+        // console.log(response.data)
         this.total=response.pageColumn.total
         this.loading = false
       }).catch(error => {
@@ -249,7 +279,7 @@ export default {
     submit() {
       this.$refs.ruleForm.validate((valid) => {
         if (valid) {
-             this.ruleForm.functions=[]
+          this.ruleForm.functions=[]
         for(var i =0;i<this.ruleForm.function.length;i++){
           var a =this.ruleForm.function[i].join(',')
           this.ruleForm.functions.push(a)