From 746e355df3ce7b588f40e96e4f20ba35266e7190 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期二, 22 八月 2023 11:28:42 +0800
Subject: [PATCH] 1.人员管理开发完成
---
src/views/basicSettings/roleList.vue | 75 +++++++++++++++++++++++--------------
1 files changed, 46 insertions(+), 29 deletions(-)
diff --git a/src/views/basicSettings/roleList.vue b/src/views/basicSettings/roleList.vue
index 1af65de..3fe1ff7 100644
--- a/src/views/basicSettings/roleList.vue
+++ b/src/views/basicSettings/roleList.vue
@@ -42,7 +42,7 @@
<input
v-if="data.isEdit"
:ref="data.code"
- v-model="node.label"
+ v-model="data.name"
type="text"
@click.stop
@blur="roleSave(data)"
@@ -68,7 +68,7 @@
</div>
<div
- style="margin-left: 15px;width:100%;position: relative"
+ style="margin-left: 10px;width:100%;position: relative"
>
<el-button
@@ -222,7 +222,7 @@
<script>
import waves from '@/directive/waves'
import {
- DataPermissions,
+ RoleAddUpdateSava, RoleDeleteSava,
RolePermissionSava,
RolePermissionSearchRole,
RolePermissionSearchRoleMenu,
@@ -230,6 +230,7 @@
} from '@/api/basicSettings'
import arrayToTree from 'array-to-tree'
import { throttle } from '@/utils/debounceAndThrottle'
+import { DataPermissions } from '@/api/GeneralBasicData'
export default {
name: 'RoleList',
@@ -319,7 +320,7 @@
// 鑾峰彇鑿滃崟鏉冮檺瀵瑰簲鐨勬寜閽�
async getRolePermissionSearchRoleMenuButton(rolecode) {
const { data: res } = await RolePermissionSearchRoleMenuButton({ rolecode, type: this.activeName })
- this.allButtonData = JSON.parse(res[0].jsondate)
+ this.allButtonData = res.length > 0 ? JSON.parse(res[0].jsondate) : []
},
// 鑾峰彇鑿滃崟鏉冮檺
async getRolePermissionSearchRoleMenu(rolecode) {
@@ -345,16 +346,6 @@
it.buttoncodelist.includes(j.buttoncode)
)
- // let temp = this.allButtonData.filter(j => j.menucode === it.menucode).length > 0 ? this.allButtonData.filter(j => j.menucode === it.menucode)[0].buttoncode : []
- // temp = temp.length > 0 ? temp.split(',') : []
-
- // it.buttonChecked = [] // 鏁版嵁鍥炴樉
- // it.buttoncodelist.forEach(j => {
- // if (temp.includes(j.buttoncode)) {
- // it.buttonChecked.push(j.buttonname)
- // }
- // })
-
it.buttoncodelist = it.buttoncodelist.map(j => j.buttonname)
}
@@ -364,8 +355,6 @@
it.datacodelist.includes(j.datacode)
).map(j => j.dataname)
}
- // const datacode = this.allButtonData.filter(j => j.menucode === it.menucode).length > 0 ? this.allButtonData.filter(j => j.menucode === it.menucode)[0].datacode : ''
- // it.dataChecked = datacode ? this.dataKeyValue.find(j => j.datacode === datacode).dataname : '' // 鏁版嵁鍥炴樉
})
item.expanded = true
@@ -588,7 +577,7 @@
},
// 瑙掕壊鍚嶇О鏂板
rolePlusClick() {
- this.treeLeft[0].roles.push({ code: 1234, name: '', isEdit: true })
+ this.treeLeft[0].roles.push({ code: '', name: '', isEdit: true })
},
// 瑙掕壊鍚嶇О淇敼
roleEditClick(self, node, data) {
@@ -601,16 +590,47 @@
// 瑙掕壊鍚嶇О鍒犻櫎
roleDeleteClick(self, node, data) {
// console.log(self, node, data)
- // this.treeLeft[0].roles.forEach((item, index) => {
- // if (item.code === data.code) {
- // this.treeLeft[0].roles.splice(index, 1) // 鏆傛椂鍏堝啓鎴愬墠绔垹闄わ紝鍚庢湡璋冪敤鎺ュ彛鍒犻櫎
- // }
- // })
+ this.$confirm('鏄惁纭鍒犻櫎?', '鎻愮ず', {
+ confirmButtonText: '纭畾',
+ cancelButtonText: '鍙栨秷',
+ type: 'warning'
+ }).then(() => {
+ const D = {
+ rolecode: data.code,
+ rolename: data.name,
+ type: this.activeName
+ }
+ RoleDeleteSava(D).then(res => {
+ if (res.code === '200') {
+ this.$notify.success('瑙掕壊鍒犻櫎鎴愬姛锛�')
+ }
+ this.getRolePermissionSearchRole()
+ })
+ }).catch(() => {
+ this.$notify.info('宸插彇娑堝垹闄�')
+ })
},
// 瑙掕壊鍚嶇О淇濆瓨 閲囩敤闃叉姈褰㈠紡
- roleSave: throttle(function(data) {
- data.isEdit = false
- console.log('鎵ц浜嗭紒')
+ roleSave: throttle(function(val) {
+ val.isEdit = false
+
+ if (val.name.trim().length === 0) {
+ this.getRolePermissionSearchRole()
+ return this.$notify.info('鏃犳晥淇濆瓨锛�')
+ }
+
+ const data = {
+ rolecode: val.code,
+ rolename: val.name,
+ type: val.code === '' ? 'Add' : 'Update'
+ }
+ console.log(data, '鎵ц浜嗭紒')
+ RoleAddUpdateSava(data).then(res => {
+ if (res.code === '200') {
+ this.$notify.success(val.code === '' ? '瑙掕壊鏂板鎴愬姛锛�' : '瑙掕壊淇敼鎴愬姛锛�')
+ }
+ })
+ this.getRolePermissionSearchRole()
}, 1000, true),
// 椤甸潰鍕鹃�夊ソ淇濆瓨浜嬩欢
@@ -640,16 +660,13 @@
}
})
- // console.log(arr, 'arr')
const rolecode = this.$refs.treeLeftRef.getCurrentKey()
const res = await RolePermissionSava(JSON.stringify(arr), rolecode, this.activeName)
if (res.code === '200') {
const rolename = this.treeLeft[0].roles.find(i => i.code === rolecode).name
this.$notify.success(rolename + '鐨勮鑹叉潈闄愭彁浜ゆ垚鍔燂紒')
await this.getRolePermissionSearchRoleMenuButton(rolecode)
- // await this.getRolePermissionSearchRoleMenu(rolecode)
}
- // this.$forceUpdate()
},
// 鑾峰彇椤甸潰楂樺害
getHeight() {
@@ -687,7 +704,7 @@
width: 55px;
}
-.el-icon-plus:hover,.el-icon-edit:hover,.el-icon-delete:hover{
+.el-icon-plus:hover, .el-icon-edit:hover, .el-icon-delete:hover {
color: #000 !important;
}
</style>
--
Gitblit v1.9.3