Przeglądaj źródła

修改数据权限

zhuliu 3 lat temu
rodzic
commit
0de58f6505
2 zmienionych plików z 108 dodań i 17 usunięć
  1. 96 10
      src/views/dataPermission/index.vue
  2. 12 7
      src/views/role/index.vue

+ 96 - 10
src/views/dataPermission/index.vue

@@ -116,6 +116,37 @@
         <el-button type="primary" @click="submit" :loading="btnLoading">确 定</el-button>
       </div>
     </el-dialog>
+     <!-- <el-table
+    ref="multipleTable"
+    :data="option"
+    tooltip-effect="dark"
+    style="width: 100%"
+    @selection-change="handleSelectionChange">
+    <el-table-column
+      type="selection"
+      width="55">
+    </el-table-column>
+    <el-table-column
+      label="日期"
+      width="120">
+      <template slot-scope="scope">{{ scope.row.date }}</template>
+    </el-table-column>
+    <el-table-column
+      prop="name"
+      label="姓名"
+      width="120">
+    </el-table-column>
+    <el-table-column
+      prop="address"
+      label="地址"
+      show-overflow-tooltip>
+    </el-table-column>
+  </el-table>
+  <div style="margin-top: 20px">
+    <el-button @click="toggleSelection([option[1], option[2]])">切换第二、第三行的选中状态</el-button>
+    <el-button @click="toggleSelection()">取消选择</el-button>
+  </div> -->
+  <el-button @click="toggleSelection([tableData[1], tableData[0]])">切换第二、第三行的选中状态</el-button>
   </div>
 </template>
 
@@ -136,6 +167,35 @@ export default {
   data() {
     name: 'DataPermission'
     return {
+       option: [{
+          date: '2016-05-03',
+          name: '王小虎',
+          address: '上海市普陀区金沙江路 1518 弄'
+        }, {
+          date: '2016-05-02',
+          name: '王小虎',
+          address: '上海市普陀区金沙江路 1518 弄'
+        }, {
+          date: '2016-05-04',
+          name: '王小虎',
+          address: '上海市普陀区金沙江路 1518 弄'
+        }, {
+          date: '2016-05-01',
+          name: '王小虎',
+          address: '上海市普陀区金沙江路 1518 弄'
+        }, {
+          date: '2016-05-08',
+          name: '王小虎',
+          address: '上海市普陀区金沙江路 1518 弄'
+        }, {
+          date: '2016-05-06',
+          name: '王小虎',
+          address: '上海市普陀区金沙江路 1518 弄'
+        }, {
+          date: '2016-05-07',
+          name: '王小虎',
+          address: '上海市普陀区金沙江路 1518 弄'
+        }],
       options:[{label:'你好',value:1},{label:'你好1',value:2},{label:'你好2',value:3}],   
       visible: false,
       loading: false,
@@ -168,10 +228,11 @@ export default {
     
   },
  
-  mounted() {
-    this.getList()
+ async mounted() {
+   await this.getList()
     this.getFunctionList()
     console.log(this.fun)
+    // this.func=this.fun
     // this.funId = 6
     // this.$emit('getPremissData', this.funId)
   },
@@ -186,14 +247,34 @@ export default {
   },
   watch:{
     fun(val,oldval){
-      if(val!=oldval){
-        this.$refs.dataTable.clearSelection()
+      console.log(val,oldval)
+        // this.$refs.dataTable.clearSelection()
         this.func = val
-        this.getList()
-      }
-    }
+      this.getList()
+    
+    },
+    // func(val,oldval){
+    //   if(val!=oldval){
+    //     this.getList()
+    //   }
+      
+    // }
   },
   methods: {
+      toggleSelection(rows) {
+        console.log(rows)
+        if (rows) {
+          rows.forEach(row => {
+            console.log(row)
+            this.$refs.dataTable.toggleRowSelection(row);
+          });
+        } else {
+          this.$refs.multipleTable.clearSelection();
+        }
+      },
+      handleSelectionChange(val) {
+        this.multipleSelection = val;
+      },
     changeData(selection,row){
       if (selection.length > 1) {
         const del_row = selection.shift()
@@ -201,7 +282,7 @@ export default {
         // console.log(del_row)
       }
       this.multipleSelection = selection[0]
-      this.$emit('getPremissData', this.fun.id, this.fun.name,this.multipleSelection)
+      this.$emit('getPremissData', this.fun.fun.id, this.fun.fun.name,this.multipleSelection)
       console.log(this.multipleSelection)
 
     },
@@ -321,12 +402,17 @@ export default {
       this.queryParams.current = val;
       this.getList();
     },
-    getList() {
+   async getList() {
       this.loading = true
-      this.queryParams.functionId = this.func.id
+      this.queryParams.functionId = this.func.fun.id
       console.log(this.queryParams)
       this.$api.getDataList(this.queryParams).then(response => {
         this.tableData = response.data
+        console.log(this.func)
+        //  rows.forEach(row => {
+        //     this.$refs.multipleTable.toggleRowSelection(row);
+        //   });
+        this.toggleSelection([this.tableData[1]])
         console.log(response.data)
         this.loading = false
       }).catch(error => {

+ 12 - 7
src/views/role/index.vue

@@ -78,7 +78,7 @@
                       <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" :checked="checked" @change="getFunInfo(scope.row)"
+                            <el-checkbox :label="scope.row.id" @change="getFunInfo(scope.row)"
                             >
                               {{scope.row.name}}
                             </el-checkbox>
@@ -89,8 +89,8 @@
                         <template slot-scope="scope">
                           <span v-if="checkList.filter(item=>item==scope.row.id)[0]">
                             <span v-if="(permissionData.filter(item=>item.functionId == scope.row.id))[0]">{{(permissionData.filter(item=>item.functionId == scope.row.id))[0].permissionData.name}}</span>
-                            <el-link style="margin-left: 10px" :underline="false" v-if="(permissionData.filter(item=>item.functionId == scope.row.id))[0]" @click="premissVisibale(scope.row)">修改</el-link>
-                            <el-link style="margin-left:10px" :underline="false" v-else-if="checkList.filter(item=>item==scope.row.id)[0]" @click="premissVisibale(scope.row)">添加</el-link>
+                            <el-link style="margin-left: 10px" :underline="false" v-if="(permissionData.filter(item=>item.functionId == scope.row.id))[0]" @click="editpremissVisibale(scope.row,(permissionData.filter(item=>item.functionId == scope.row.id))[0].permissionData)">修改</el-link>
+                            <el-link style="margin-left:10px" :underline="false" v-else-if="checkList.filter(item=>item==scope.row.id)[0]" @click="addpremissVisibale(scope.row)">添加</el-link>
                           </span>
                           
                           
@@ -210,7 +210,7 @@ export default {
       this.permissVisible=false
     },
     getFunInfo(val) {
-      this.fun = val
+      // this.fun = val
       this.functionName = val.name
     },
     handleCheckedCitiesChange(value) {
@@ -240,10 +240,15 @@ export default {
       this.visible = true
       this.ruleForm = { ...row }
     },
-    premissVisibale(val) {
-      this.permissTitle = '数据权限管理'
+    addpremissVisibale(val) {
+      this.permissTitle = '添加数据权限管理'
       this.permissVisible = true
-      this.fun = val
+      this.fun = {fun:val}
+    },
+     editpremissVisibale(val,permission) {
+      this.permissTitle = '修改数据权限管理'
+      this.permissVisible = true
+      this.fun = {fun:val,permission:permission}
     },
     close() {
       this.visible = false