6 changed files with 4462 additions and 5036 deletions
File diff suppressed because it is too large
@ -1,391 +1,362 @@ |
|||
<template> |
|||
<div class="role-container"> |
|||
<el-card class="flex1"> |
|||
<!-- <div class="now-name"> |
|||
<div class="role-container"> |
|||
<el-card class="flex1"> |
|||
<!-- <div class="now-name"> |
|||
当前客户: {{customerName}} |
|||
<el-button type="primary" size="small" @click="handleSaveSort">保存顺序</el-button> |
|||
</div> --> |
|||
<el-table ref="roleTable" |
|||
v-loading="loading1" |
|||
:data="roleList" |
|||
row-key="roleKey" |
|||
border |
|||
<el-table ref="roleTable" v-loading="loading1" :data="roleList" row-key="roleKey" border |
|||
style="width: 100%"> |
|||
<el-table-column type="index" |
|||
width="50"></el-table-column> |
|||
<!-- <el-table-column prop="roleId" label="角色ID"></el-table-column> --> |
|||
<el-table-column prop="roleName" |
|||
label="角色名称" |
|||
width="160"> |
|||
<template slot-scope="scope"> |
|||
<el-input v-if="scope.row.isEdit" |
|||
v-model.trim="scope.row.roleName" |
|||
clearable> |
|||
</el-input> |
|||
<span v-else>{{scope.row.constName}}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column v-if="!funcShow" |
|||
prop="roleKey" |
|||
label="角色Key"></el-table-column> |
|||
<el-table-column label="操作"> |
|||
<template slot-scope="scope"> |
|||
<el-button type="primary" |
|||
size="mini" |
|||
@click="toOperationConfig(scope.row.roleKey, scope.row.roleName)">功能权限</el-button> |
|||
<!-- <span v-if="scope.row.isEdit" style="display: inline-block; margin-left: 10px;"> |
|||
<el-table-column type="index" width="50"></el-table-column> |
|||
<!-- <el-table-column prop="roleId" label="角色ID"></el-table-column> --> |
|||
<el-table-column prop="roleName" label="角色名称" width="160"> |
|||
<template slot-scope="scope"> |
|||
<el-input v-if="scope.row.isEdit" v-model.trim="scope.row.roleName" clearable> |
|||
</el-input> |
|||
<span v-else>{{ scope.row.constName }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column v-if="!funcShow" prop="roleKey" label="角色Key"></el-table-column> |
|||
<el-table-column label="操作"> |
|||
<template slot-scope="scope"> |
|||
<el-button type="primary" size="mini" |
|||
@click="toOperationConfig(scope.row.roleKey, scope.row.roleName)">功能权限</el-button> |
|||
<!-- <span v-if="scope.row.isEdit" style="display: inline-block; margin-left: 10px;"> |
|||
<el-button type="primary" size="small" @click="handleSaveChange(scope.row)">保存</el-button> |
|||
<el-button size="small" @click="scope.row.isEdit=false">取消</el-button> |
|||
</span> |
|||
<el-button v-else type="primary" size="mini" @click="handleChangeName(scope.row)">修改名称</el-button> --> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
</el-card> |
|||
<el-dialog :visible.sync="funcShow" |
|||
:close-on-click-modal="false" |
|||
:close-on-press-escape="false" |
|||
width="70%" |
|||
top="30px" |
|||
title="功能列表" |
|||
@closed="handleDialogClosed"> |
|||
<div class="role-flex" |
|||
v-if="funcShow"> |
|||
<el-card class="flex1"> |
|||
<div class="now-name">当前角色: {{roleName}}</div> |
|||
<div class="now-name"> |
|||
<el-button type="primary" |
|||
size="small" |
|||
@click="saveOperations4Role">保存功能</el-button> |
|||
</div> |
|||
<el-table v-loading="loading2" |
|||
height="580" |
|||
ref="opeTable" |
|||
:data="opeList" |
|||
border |
|||
@select="handleSelectionChange"> |
|||
<el-table-column type="selection" |
|||
width="55"></el-table-column> |
|||
<!-- <el-table-column prop="operationKey" label="操作Key"></el-table-column> --> |
|||
<el-table-column prop="operationName" |
|||
label="操作名称"></el-table-column> |
|||
<!-- <el-table-column prop="brief" label="简介"></el-table-column> --> |
|||
<el-table-column label="操作"> |
|||
<template slot-scope="scope"> |
|||
<el-button type="primary" |
|||
size="small" |
|||
@click="toScopeConfig(scope.row.operationKey, scope.row.operationName)">范围配置</el-button> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
</el-card> |
|||
<el-card v-show="roleShow" |
|||
style="width: 250px; margin-left: 10px;"> |
|||
<div class="now-name">当前功能: {{funcName}}</div> |
|||
<div class="now-name"> |
|||
<el-button type="primary" |
|||
size="small" |
|||
@click="saveSettings">保存范围</el-button> |
|||
</div> |
|||
<div> |
|||
<el-row :gutter="12"> |
|||
<el-col v-loading="loading3"> |
|||
<el-card shadow="hover"> |
|||
<el-checkbox-group class="t" |
|||
v-model.trim="checkedScopes" |
|||
@change="roleChange"> |
|||
<el-checkbox v-for="scope in scopeOptions" |
|||
:label="scope.scopeKey" |
|||
:key="scope.scopeKey">{{scope.scopeName}}</el-checkbox> |
|||
</el-checkbox-group> |
|||
<el-dialog :visible.sync="funcShow" :close-on-click-modal="false" :close-on-press-escape="false" width="70%" |
|||
top="30px" title="功能列表" @closed="handleDialogClosed"> |
|||
<div class="role-flex" v-if="funcShow"> |
|||
<el-card class="flex1"> |
|||
<div class="now-name">当前角色: {{ roleName }}</div> |
|||
<div class="now-name"> |
|||
<el-button type="primary" size="small" @click="saveOperations4Role">保存功能</el-button> |
|||
</div> |
|||
<el-table v-loading="loading2" height="580" ref="opeTable" :data="opeList" border |
|||
@select="handleSelectionChange"> |
|||
<el-table-column type="selection" width="55"></el-table-column> |
|||
<!-- <el-table-column prop="operationKey" label="操作Key"></el-table-column> --> |
|||
<el-table-column prop="operationName" label="操作名称"></el-table-column> |
|||
<!-- <el-table-column prop="brief" label="简介"></el-table-column> --> |
|||
<el-table-column label="操作"> |
|||
<template slot-scope="scope"> |
|||
<el-button type="primary" size="small" |
|||
@click="toScopeConfig(scope.row.operationKey, scope.row.operationName)">范围配置</el-button> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
</el-card> |
|||
</el-col> |
|||
</el-row> |
|||
</div> |
|||
</el-card> |
|||
</div> |
|||
</el-dialog> |
|||
</div> |
|||
<el-card v-show="roleShow" style="width: 250px; margin-left: 10px;"> |
|||
<div class="now-name">当前功能: {{ funcName }}</div> |
|||
<div class="now-name"> |
|||
<el-button type="primary" size="small" @click="saveSettings">保存范围</el-button> |
|||
</div> |
|||
<div> |
|||
<el-row :gutter="12"> |
|||
<el-col v-loading="loading3"> |
|||
<el-card shadow="hover"> |
|||
<el-checkbox-group class="t" v-model.trim="checkedScopes" @change="roleChange"> |
|||
<el-checkbox v-for="scope in scopeOptions" :label="scope.scopeKey" |
|||
:key="scope.scopeKey">{{ scope.scopeName }}</el-checkbox> |
|||
</el-checkbox-group> |
|||
</el-card> |
|||
</el-col> |
|||
</el-row> |
|||
</div> |
|||
</el-card> |
|||
</div> |
|||
</el-dialog> |
|||
</div> |
|||
</template> |
|||
<script> |
|||
import Sortable from 'sortablejs' |
|||
export default { |
|||
name: 'RoleList', |
|||
props: { |
|||
customerId: { |
|||
type: String, |
|||
default: '' |
|||
}, |
|||
customerName: { |
|||
type: String, |
|||
default: '' |
|||
} |
|||
}, |
|||
data () { |
|||
return { |
|||
loading1: false, |
|||
loading2: false, |
|||
loading3: false, |
|||
funcShow: false, |
|||
roleShow: false, |
|||
roleName: '', |
|||
funcName: '', |
|||
roleList: [], |
|||
opeList: [], |
|||
roleKey: '', |
|||
operationKey: '', |
|||
scopeOptions: [], |
|||
settingOptions: [], |
|||
checkedScopes: [], |
|||
checkedSettings: [], |
|||
operateSection: [], // 功能选择列表 |
|||
scopeSection: [] // 范围选择列表 |
|||
} |
|||
}, |
|||
created () { |
|||
this.listRolesByCustomerId() |
|||
}, |
|||
mounted () { |
|||
this.dragRoleSort() |
|||
}, |
|||
beforeDestroy () { |
|||
let _data = this.$data |
|||
for (let n in _data) { |
|||
if (typeof _data[n] === 'boolean') _data[n] = false |
|||
if (typeof _data[n] === 'string') _data[n] = '' |
|||
if (typeof _data[n] === 'object') _data[n] = [] |
|||
} |
|||
}, |
|||
methods: { |
|||
handleDialogClosed () { |
|||
this.roleName = '' |
|||
this.roleKey = '' |
|||
this.funcName = '' |
|||
this.operateSection = [] |
|||
this.scopeSection = [] |
|||
this.funcShow = false |
|||
this.roleShow = false |
|||
}, |
|||
listRolesByCustomerId (customerId) { |
|||
this.loading1 = true |
|||
this.$http |
|||
.post('/epmetuser/govstaffrole/roletemplates') |
|||
.then(({ data: res }) => { |
|||
console.log('ressss', res) |
|||
if (res.code === 0) { |
|||
this.roleList = res.data.map(item => { |
|||
return { |
|||
...item, |
|||
constName: item.roleName, |
|||
isEdit: false |
|||
} |
|||
}) |
|||
} |
|||
setTimeout(() => { |
|||
this.loading1 = false |
|||
}, 500) |
|||
}) |
|||
}, |
|||
listOperations4AccessConfig (roleKey) { |
|||
this.roleKey = roleKey |
|||
this.loading2 = true |
|||
this.$http.post('/gov/access/config/roledefaultops/' + roleKey).then((resp) => { |
|||
this.opeList = resp.data.data |
|||
this.$nextTick(function() { |
|||
this.defaultCheck() // 每次更新了数据,触发这个函数即可。 |
|||
}) |
|||
setTimeout(() => { |
|||
this.loading2 = false |
|||
}, 500) |
|||
}) |
|||
}, |
|||
listSettingOptions (operationKey) { |
|||
let params = { |
|||
roleKey: this.roleKey, |
|||
operationKey: operationKey |
|||
} |
|||
console.log('checkedScopes', this.checkedScopes) |
|||
this.loading3 = true |
|||
this.checkedScopes = [] |
|||
this.$http |
|||
.post('/gov/access/config/opedefaultscopes/list', params) |
|||
.then(resp => { |
|||
console.log('scopeOptions', resp.data) |
|||
this.scopeOptions = resp.data.data |
|||
resp.data.data.forEach(item => { |
|||
if (item.assigned) this.checkedScopes.push(item.scopeKey) |
|||
}) |
|||
console.log('checkedScopes222', this.checkedScopes) |
|||
this.settingOptions = resp.data.data |
|||
setTimeout(() => { |
|||
this.loading3 = false |
|||
}, 500) |
|||
}) |
|||
}, |
|||
defaultCheck () { |
|||
for (var index in this.opeList) { |
|||
let role = this.opeList[index] |
|||
if (role.assigned) { |
|||
this.$refs.opeTable.toggleRowSelection(role, true) |
|||
} |
|||
} |
|||
}, |
|||
toOperationConfig (roleKey, roleName) { |
|||
this.roleName = roleName |
|||
this.funcShow = true |
|||
this.opeList = [] |
|||
this.listOperations4AccessConfig(roleKey) |
|||
}, |
|||
toScopeConfig (operationKey, operationName) { |
|||
this.roleShow = true |
|||
this.operationKey = operationKey |
|||
this.funcName = operationName |
|||
this.checkedScopes = [] |
|||
this.listSettingOptions(operationKey) |
|||
}, |
|||
saveOperations4Role () { |
|||
let param = { |
|||
roleKey: this.roleKey, |
|||
operationKeys: this.operateSection.map(item => item.operationKey) |
|||
} |
|||
this.$http.post('/gov/access/config/roledefaultopes/save', param).then( |
|||
resp => { |
|||
const { code, msg } = resp.data |
|||
if (code === 0 && msg === 'success') { |
|||
this.$message({ |
|||
message: '操作成功', |
|||
type: 'success' |
|||
}) |
|||
this.listOperations4AccessConfig(this.roleKey) |
|||
} else { |
|||
this.$message({ |
|||
message: msg, |
|||
type: 'error' |
|||
}) |
|||
} |
|||
name: 'RoleList', |
|||
props: { |
|||
customerId: { |
|||
type: String, |
|||
default: '' |
|||
}, |
|||
customerName: { |
|||
type: String, |
|||
default: '' |
|||
} |
|||
) |
|||
}, |
|||
saveSettings () { |
|||
let param = { |
|||
roleKey: this.roleKey, |
|||
operationKey: this.operationKey, |
|||
scopeKeys: this.scopeSection |
|||
} |
|||
this.$http.post('/gov/access/config/opedefaultscopes/save', param).then( |
|||
resp => { |
|||
const { code, msg } = resp.data |
|||
if (code === 0 && msg === 'success') { |
|||
this.$message({ |
|||
type: 'success', |
|||
message: '保存成功' |
|||
}) |
|||
this.listSettingOptions(this.operationKey) |
|||
} else { |
|||
this.$message({ |
|||
message: msg, |
|||
type: 'error' |
|||
}) |
|||
} |
|||
data() { |
|||
return { |
|||
loading1: false, |
|||
loading2: false, |
|||
loading3: false, |
|||
funcShow: false, |
|||
roleShow: false, |
|||
roleName: '', |
|||
funcName: '', |
|||
roleList: [], |
|||
opeList: [], |
|||
roleKey: '', |
|||
operationKey: '', |
|||
scopeOptions: [], |
|||
settingOptions: [], |
|||
checkedScopes: [], |
|||
checkedSettings: [], |
|||
operateSection: [], // 功能选择列表 |
|||
scopeSection: [] // 范围选择列表 |
|||
} |
|||
) |
|||
}, |
|||
roleChange (val) { |
|||
this.scopeSection = val |
|||
// this.saveSettings(val) |
|||
created() { |
|||
this.listRolesByCustomerId() |
|||
}, |
|||
handleSelectionChange (val) { |
|||
this.operateSection = val |
|||
// this.saveOperations4Role(val) |
|||
mounted() { |
|||
this.dragRoleSort() |
|||
}, |
|||
handleChangeName (row) { |
|||
row.isEdit = true |
|||
beforeDestroy() { |
|||
let _data = this.$data |
|||
for (let n in _data) { |
|||
if (typeof _data[n] === 'boolean') _data[n] = false |
|||
if (typeof _data[n] === 'string') _data[n] = '' |
|||
if (typeof _data[n] === 'object') _data[n] = [] |
|||
} |
|||
}, |
|||
handleSaveChange (row) { |
|||
let data = { |
|||
roleKey: row.roleKey, |
|||
roleName: row.roleName |
|||
} |
|||
this.$http |
|||
.post('/epmetuser/govstaffrole/update-role', data) |
|||
.then(({ data: res }) => { |
|||
console.log('ressss', res) |
|||
if (res.code === 0 && res.msg === 'success') { |
|||
this.$message({ |
|||
type: 'success', |
|||
message: '保存成功' |
|||
methods: { |
|||
handleDialogClosed() { |
|||
this.roleName = '' |
|||
this.roleKey = '' |
|||
this.funcName = '' |
|||
this.operateSection = [] |
|||
this.scopeSection = [] |
|||
this.funcShow = false |
|||
this.roleShow = false |
|||
}, |
|||
listRolesByCustomerId(customerId) { |
|||
this.loading1 = true |
|||
this.$http |
|||
.post('/epmetuser/govstaffrole/roletemplates') |
|||
.then(({ data: res }) => { |
|||
console.log('ressss', res) |
|||
if (res.code === 0) { |
|||
this.roleList = res.data.map(item => { |
|||
return { |
|||
...item, |
|||
constName: item.roleName, |
|||
isEdit: false |
|||
} |
|||
}) |
|||
} |
|||
setTimeout(() => { |
|||
this.loading1 = false |
|||
}, 500) |
|||
}) |
|||
}, |
|||
listOperations4AccessConfig(roleKey) { |
|||
this.roleKey = roleKey |
|||
this.loading2 = true |
|||
this.$http.post('/gov/access/config/roledefaultops/' + roleKey).then((resp) => { |
|||
this.opeList = resp.data.data |
|||
this.$nextTick(function () { |
|||
this.defaultCheck() // 每次更新了数据,触发这个函数即可。 |
|||
}) |
|||
setTimeout(() => { |
|||
this.loading2 = false |
|||
}, 500) |
|||
}) |
|||
this.listRolesByCustomerId(this.customerId) |
|||
} else { |
|||
this.$message({ |
|||
type: 'error', |
|||
message: res.msg |
|||
}, |
|||
listSettingOptions(operationKey) { |
|||
let params = { |
|||
roleKey: this.roleKey, |
|||
operationKey: operationKey |
|||
} |
|||
console.log('checkedScopes', this.checkedScopes) |
|||
this.loading3 = true |
|||
this.checkedScopes = [] |
|||
this.$http |
|||
.post('/gov/access/config/opedefaultscopes/list', params) |
|||
.then(resp => { |
|||
console.log('scopeOptions', resp.data) |
|||
this.scopeOptions = resp.data.data |
|||
resp.data.data.forEach(item => { |
|||
if (item.assigned) this.checkedScopes.push(item.scopeKey) |
|||
}) |
|||
console.log('checkedScopes222', this.checkedScopes) |
|||
this.settingOptions = resp.data.data |
|||
setTimeout(() => { |
|||
this.loading3 = false |
|||
}, 500) |
|||
}) |
|||
}, |
|||
defaultCheck() { |
|||
for (var index in this.opeList) { |
|||
let role = this.opeList[index] |
|||
if (role.assigned) { |
|||
this.$refs.opeTable.toggleRowSelection(role, true) |
|||
} |
|||
} |
|||
}, |
|||
toOperationConfig(roleKey, roleName) { |
|||
this.roleName = roleName |
|||
this.funcShow = true |
|||
this.opeList = [] |
|||
this.listOperations4AccessConfig(roleKey) |
|||
}, |
|||
toScopeConfig(operationKey, operationName) { |
|||
this.roleShow = true |
|||
this.operationKey = operationKey |
|||
this.funcName = operationName |
|||
this.checkedScopes = [] |
|||
this.listSettingOptions(operationKey) |
|||
}, |
|||
saveOperations4Role() { |
|||
let param = { |
|||
roleKey: this.roleKey, |
|||
operationKeys: this.operateSection.map(item => item.operationKey) |
|||
} |
|||
this.$http.post('/gov/access/config/roledefaultopes/save', param).then( |
|||
resp => { |
|||
const { code, msg } = resp.data |
|||
if (code === 0 && msg === 'success') { |
|||
this.$message({ |
|||
message: '操作成功', |
|||
type: 'success' |
|||
}) |
|||
this.listOperations4AccessConfig(this.roleKey) |
|||
} else { |
|||
this.$message({ |
|||
message: msg, |
|||
type: 'error' |
|||
}) |
|||
} |
|||
} |
|||
) |
|||
}, |
|||
saveSettings() { |
|||
let param = { |
|||
roleKey: this.roleKey, |
|||
operationKey: this.operationKey, |
|||
scopeKeys: this.scopeSection |
|||
} |
|||
this.$http.post('/gov/access/config/opedefaultscopes/save', param).then( |
|||
resp => { |
|||
const { code, msg } = resp.data |
|||
if (code === 0 && msg === 'success') { |
|||
this.$message({ |
|||
type: 'success', |
|||
message: '保存成功' |
|||
}) |
|||
this.listSettingOptions(this.operationKey) |
|||
} else { |
|||
this.$message({ |
|||
message: msg, |
|||
type: 'error' |
|||
}) |
|||
} |
|||
} |
|||
) |
|||
}, |
|||
roleChange(val) { |
|||
this.scopeSection = val |
|||
// this.saveSettings(val) |
|||
}, |
|||
handleSelectionChange(val) { |
|||
this.operateSection = val |
|||
// this.saveOperations4Role(val) |
|||
}, |
|||
handleChangeName(row) { |
|||
row.isEdit = true |
|||
}, |
|||
handleSaveChange(row) { |
|||
let data = { |
|||
roleKey: row.roleKey, |
|||
roleName: row.roleName |
|||
} |
|||
this.$http |
|||
.post('/epmetuser/govstaffrole/update-role', data) |
|||
.then(({ data: res }) => { |
|||
console.log('ressss', res) |
|||
if (res.code === 0 && res.msg === 'success') { |
|||
this.$message({ |
|||
type: 'success', |
|||
message: '保存成功' |
|||
}) |
|||
this.listRolesByCustomerId(this.customerId) |
|||
} else { |
|||
this.$message({ |
|||
type: 'error', |
|||
message: res.msg |
|||
}) |
|||
} |
|||
}) |
|||
}, |
|||
dragRoleSort() { |
|||
const el = this.$refs.roleTable.$el.querySelectorAll('.el-table__body-wrapper > table > tbody')[0] |
|||
this.sortTable = Sortable.create(el, { |
|||
group: 'dragTable', |
|||
ghostClass: 'sortable-ghost', // Class name for the drop placeholder, |
|||
// setData: function(dataTransfer, dragEl) { |
|||
// dataTransfer.setData("Text", dragEl.textContent); |
|||
// }, |
|||
delay: 0, |
|||
onChange: evt => { |
|||
// console.log(evt) |
|||
}, |
|||
onEnd: evt => { |
|||
const targetRow = this.roleList.splice(evt.oldIndex, 1)[0] |
|||
this.roleList.splice(evt.newIndex, 0, targetRow) |
|||
} |
|||
}) |
|||
} |
|||
}) |
|||
}, |
|||
dragRoleSort () { |
|||
const el = this.$refs.roleTable.$el.querySelectorAll('.el-table__body-wrapper > table > tbody')[0] |
|||
this.sortTable = Sortable.create(el, { |
|||
group: 'dragTable', |
|||
ghostClass: 'sortable-ghost', // Class name for the drop placeholder, |
|||
// setData: function(dataTransfer, dragEl) { |
|||
// dataTransfer.setData("Text", dragEl.textContent); |
|||
// }, |
|||
delay: 0, |
|||
onChange: evt => { |
|||
// console.log(evt) |
|||
}, |
|||
onEnd: evt => { |
|||
const targetRow = this.roleList.splice(evt.oldIndex, 1)[0] |
|||
this.roleList.splice(evt.newIndex, 0, targetRow) |
|||
handleSaveSort() { |
|||
let data = { |
|||
roleIdList: this.roleList.map(item => { |
|||
return item.roleKey |
|||
}) |
|||
} |
|||
this.$http |
|||
.post('/epmetuser/govstaffrole/save-sortorder', data) |
|||
.then(({ data: res }) => { |
|||
console.log('ressss', res) |
|||
if (res.code === 0 && res.msg === 'success') { |
|||
this.$message({ |
|||
type: 'success', |
|||
message: '保存成功' |
|||
}) |
|||
this.listRolesByCustomerId(this.customerId) |
|||
} else { |
|||
this.$message({ |
|||
type: 'error', |
|||
message: res.msg |
|||
}) |
|||
} |
|||
}) |
|||
} |
|||
}) |
|||
}, |
|||
handleSaveSort () { |
|||
let data = { |
|||
roleIdList: this.roleList.map(item => { |
|||
return item.roleKey |
|||
}) |
|||
} |
|||
this.$http |
|||
.post('/epmetuser/govstaffrole/save-sortorder', data) |
|||
.then(({ data: res }) => { |
|||
console.log('ressss', res) |
|||
if (res.code === 0 && res.msg === 'success') { |
|||
this.$message({ |
|||
type: 'success', |
|||
message: '保存成功' |
|||
}) |
|||
this.listRolesByCustomerId(this.customerId) |
|||
} else { |
|||
this.$message({ |
|||
type: 'error', |
|||
message: res.msg |
|||
}) |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
<style> |
|||
.role-container, |
|||
.role-flex { |
|||
display: flex; |
|||
display: flex; |
|||
} |
|||
|
|||
.flex1 { |
|||
flex: 1; |
|||
flex: 1; |
|||
} |
|||
|
|||
.now-name { |
|||
/* display: flex; |
|||
/* display: flex; |
|||
justify-content: space-between; */ |
|||
margin-bottom: 10px; |
|||
margin-bottom: 10px; |
|||
} |
|||
.aui-wrapper .el-card + .el-card { |
|||
margin-top: 0; |
|||
|
|||
.aui-wrapper .el-card+.el-card { |
|||
margin-top: 0; |
|||
} |
|||
|
|||
.role-container .el-dialog__body { |
|||
padding: 0 20px 20px; |
|||
padding: 0 20px 20px; |
|||
} |
|||
</style> |
|||
|
|||
File diff suppressed because it is too large
@ -1,506 +1,443 @@ |
|||
<template> |
|||
<div class="role-container"> |
|||
<el-card class="flex1"> |
|||
<el-tabs v-model.trim="activeName" |
|||
@tab-click="tabClick" |
|||
class="el-tabs"> |
|||
<el-tab-pane label="工作端" |
|||
name="work"> |
|||
<div class="now-name"> |
|||
上下拖动可改变角色顺序 |
|||
<el-button type="primary" |
|||
size="small" |
|||
@click="handleSaveSort">保存顺序</el-button> |
|||
</div> |
|||
<el-table ref="roleTable" |
|||
v-loading="loading1" |
|||
:data="roleList" |
|||
row-key="roleKey" |
|||
border |
|||
style="width: 100%"> |
|||
<el-table-column type="index" |
|||
header-align="left" |
|||
align="left" |
|||
width="50"></el-table-column> |
|||
<el-table-column prop="roleName" |
|||
label="角色名称" |
|||
header-align="left" |
|||
align="left" |
|||
width="180"> |
|||
<template slot-scope="scope"> |
|||
<el-input v-if="scope.row.isEdit" |
|||
v-model.trim="scope.row.roleName" |
|||
clearable> |
|||
</el-input> |
|||
<span v-else>{{scope.row.constName}}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column v-if="!funcShow" |
|||
prop="roleKey" |
|||
header-align="left" |
|||
align="left" |
|||
label="角色Key" |
|||
width="150"></el-table-column> |
|||
<el-table-column prop="description" |
|||
label="角色职责" |
|||
header-align="left" |
|||
align="left"> |
|||
<template slot-scope="scope"> |
|||
<p style="text-align:left;margin:3px 0" |
|||
v-for="(item,index) in scope.row.descriptionList" |
|||
:key="index">{{item}}</p> |
|||
<!-- <p>{{scope.row.description}}</p> --> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column width="450" |
|||
label="操作"> |
|||
<template slot-scope="scope"> |
|||
<el-button type="primary" |
|||
size="mini" |
|||
@click="handelChangeDuty(scope.row)">修改职责</el-button> |
|||
<el-button type="primary" |
|||
size="mini" |
|||
@click="toOperationConfig(scope.row.roleKey, scope.row.roleName)">功能权限</el-button> |
|||
<span v-if="scope.row.isEdit" |
|||
style="display: inline-block; margin-left: 10px;"> |
|||
<el-button type="primary" |
|||
size="small" |
|||
@click="saveName(scope.row)">保存</el-button> |
|||
<el-button size="small" |
|||
@click="scope.row.isEdit=false">取消</el-button> |
|||
</span> |
|||
<el-button v-else |
|||
type="primary" |
|||
size="mini" |
|||
@click="handleChangeName(scope.row)">修改名称</el-button> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
</el-tab-pane> |
|||
<el-tab-pane label="居民端" |
|||
name="resi"> |
|||
</el-tab-pane> |
|||
</el-tabs> |
|||
</el-card> |
|||
<!-- 角色职责弹出框 --> |
|||
<el-dialog :visible.sync="dutyShow" |
|||
:close-on-click-modal="false" |
|||
:close-on-press-escape="false" |
|||
title="角色职责" |
|||
width="30%" |
|||
@closed="handleDutyClosed"> |
|||
<div class="div_duty" |
|||
v-if="dutyShow"> |
|||
<el-input type="textarea" |
|||
:rows="8" |
|||
v-model.trim="description"></el-input> |
|||
<div class="div_btn"> |
|||
<el-button type="primary" |
|||
size="small" |
|||
@click="updateRole()">保存</el-button> |
|||
<el-button size="small" |
|||
@click="dutyShow=false">取消</el-button> |
|||
</div> |
|||
</div> |
|||
</el-dialog> |
|||
<!-- 功能配置弹出框 --> |
|||
<el-dialog :visible.sync="funcShow" |
|||
:close-on-click-modal="false" |
|||
:close-on-press-escape="false" |
|||
width="70%" |
|||
top="30px" |
|||
title="功能列表" |
|||
@closed="handleDialogClosed"> |
|||
<div class="role-flex" |
|||
v-if="funcShow"> |
|||
<div class="role-container"> |
|||
<el-card class="flex1"> |
|||
<div class="now-name">当前角色: {{roleName}}</div> |
|||
<div class="now-name"> |
|||
<el-button type="primary" |
|||
size="small" |
|||
@click="saveOperations4Role">保存功能</el-button> |
|||
</div> |
|||
<el-table v-loading="loading2" |
|||
height="580" |
|||
ref="opeTable" |
|||
:data="opeList" |
|||
border |
|||
@select="handleSelectionChange"> |
|||
<el-table-column type="selection" |
|||
width="55"></el-table-column> |
|||
<!-- <el-table-column prop="operationKey" label="操作Key"></el-table-column> --> |
|||
<el-table-column prop="operationName" |
|||
label="操作名称"></el-table-column> |
|||
<!-- <el-table-column prop="brief" label="简介"></el-table-column> --> |
|||
<el-table-column label="操作"> |
|||
<template slot-scope="scope"> |
|||
<el-button type="primary" |
|||
size="small" |
|||
@click="toScopeConfig(scope.row.operationKey, scope.row.operationName)">范围配置</el-button> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
<el-tabs v-model.trim="activeName" @tab-click="tabClick" class="el-tabs"> |
|||
<el-tab-pane label="工作端" name="work"> |
|||
<div class="now-name"> |
|||
上下拖动可改变角色顺序 |
|||
<el-button type="primary" size="small" @click="handleSaveSort">保存顺序</el-button> |
|||
</div> |
|||
<el-table ref="roleTable" v-loading="loading1" :data="roleList" row-key="roleKey" border |
|||
style="width: 100%"> |
|||
<el-table-column type="index" header-align="left" align="left" width="50"></el-table-column> |
|||
<el-table-column prop="roleName" label="角色名称" header-align="left" align="left" width="180"> |
|||
<template slot-scope="scope"> |
|||
<el-input v-if="scope.row.isEdit" v-model.trim="scope.row.roleName" clearable> |
|||
</el-input> |
|||
<span v-else>{{ scope.row.constName }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column v-if="!funcShow" prop="roleKey" header-align="left" align="left" label="角色Key" |
|||
width="150"></el-table-column> |
|||
<el-table-column prop="description" label="角色职责" header-align="left" align="left"> |
|||
<template slot-scope="scope"> |
|||
<p style="text-align:left;margin:3px 0" |
|||
v-for="(item, index) in scope.row.descriptionList" :key="index">{{ item }}</p> |
|||
<!-- <p>{{scope.row.description}}</p> --> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column width="450" label="操作"> |
|||
<template slot-scope="scope"> |
|||
<el-button type="primary" size="mini" |
|||
@click="handelChangeDuty(scope.row)">修改职责</el-button> |
|||
<el-button type="primary" size="mini" |
|||
@click="toOperationConfig(scope.row.roleKey, scope.row.roleName)">功能权限</el-button> |
|||
<span v-if="scope.row.isEdit" style="display: inline-block; margin-left: 10px;"> |
|||
<el-button type="primary" size="small" @click="saveName(scope.row)">保存</el-button> |
|||
<el-button size="small" @click="scope.row.isEdit = false">取消</el-button> |
|||
</span> |
|||
<el-button v-else type="primary" size="mini" |
|||
@click="handleChangeName(scope.row)">修改名称</el-button> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
</el-tab-pane> |
|||
<el-tab-pane label="居民端" name="resi"> |
|||
</el-tab-pane> |
|||
</el-tabs> |
|||
</el-card> |
|||
<el-card v-show="roleShow" |
|||
style="width: 250px; margin-left: 10px;"> |
|||
<div class="now-name">当前功能: {{funcName}}</div> |
|||
<div class="now-name"> |
|||
<el-button type="primary" |
|||
size="small" |
|||
@click="saveSettings">保存范围</el-button> |
|||
<el-button type="primary" |
|||
size="small" |
|||
@click="toAllClient">同步到所有客户</el-button> |
|||
</div> |
|||
<div> |
|||
<el-row :gutter="12"> |
|||
<el-col v-loading="loading3"> |
|||
<el-card shadow="hover"> |
|||
<el-checkbox-group class="t" |
|||
v-model.trim="checkedScopes" |
|||
@change="roleChange"> |
|||
<el-checkbox v-for="scope in scopeOptions" |
|||
:label="scope.scopeKey" |
|||
:key="scope.scopeKey">{{scope.scopeName}}</el-checkbox> |
|||
</el-checkbox-group> |
|||
<!-- 角色职责弹出框 --> |
|||
<el-dialog :visible.sync="dutyShow" :close-on-click-modal="false" :close-on-press-escape="false" title="角色职责" |
|||
width="30%" @closed="handleDutyClosed"> |
|||
<div class="div_duty" v-if="dutyShow"> |
|||
<el-input type="textarea" :rows="8" v-model.trim="description"></el-input> |
|||
<div class="div_btn"> |
|||
<el-button type="primary" size="small" @click="updateRole()">保存</el-button> |
|||
<el-button size="small" @click="dutyShow = false">取消</el-button> |
|||
</div> |
|||
</div> |
|||
</el-dialog> |
|||
<!-- 功能配置弹出框 --> |
|||
<el-dialog :visible.sync="funcShow" :close-on-click-modal="false" :close-on-press-escape="false" width="70%" |
|||
top="30px" title="功能列表" @closed="handleDialogClosed"> |
|||
<div class="role-flex" v-if="funcShow"> |
|||
<el-card class="flex1"> |
|||
<div class="now-name">当前角色: {{ roleName }}</div> |
|||
<div class="now-name"> |
|||
<el-button type="primary" size="small" @click="saveOperations4Role">保存功能</el-button> |
|||
</div> |
|||
<el-table v-loading="loading2" height="580" ref="opeTable" :data="opeList" border |
|||
@select="handleSelectionChange"> |
|||
<el-table-column type="selection" width="55"></el-table-column> |
|||
<!-- <el-table-column prop="operationKey" label="操作Key"></el-table-column> --> |
|||
<el-table-column prop="operationName" label="操作名称"></el-table-column> |
|||
<!-- <el-table-column prop="brief" label="简介"></el-table-column> --> |
|||
<el-table-column label="操作"> |
|||
<template slot-scope="scope"> |
|||
<el-button type="primary" size="small" |
|||
@click="toScopeConfig(scope.row.operationKey, scope.row.operationName)">范围配置</el-button> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
</el-card> |
|||
</el-col> |
|||
</el-row> |
|||
</div> |
|||
</el-card> |
|||
</div> |
|||
</el-dialog> |
|||
</div> |
|||
<el-card v-show="roleShow" style="width: 250px; margin-left: 10px;"> |
|||
<div class="now-name">当前功能: {{ funcName }}</div> |
|||
<div class="now-name"> |
|||
<el-button type="primary" size="small" @click="saveSettings">保存范围</el-button> |
|||
<el-button type="primary" size="small" @click="toAllClient">同步到所有客户</el-button> |
|||
</div> |
|||
<div> |
|||
<el-row :gutter="12"> |
|||
<el-col v-loading="loading3"> |
|||
<el-card shadow="hover"> |
|||
<el-checkbox-group class="t" v-model.trim="checkedScopes" @change="roleChange"> |
|||
<el-checkbox v-for="scope in scopeOptions" :label="scope.scopeKey" |
|||
:key="scope.scopeKey">{{ scope.scopeName }}</el-checkbox> |
|||
</el-checkbox-group> |
|||
</el-card> |
|||
</el-col> |
|||
</el-row> |
|||
</div> |
|||
</el-card> |
|||
</div> |
|||
</el-dialog> |
|||
</div> |
|||
</template> |
|||
<script> |
|||
import Sortable from 'sortablejs' |
|||
import { requestPost } from "@/js/dai/request"; |
|||
export default { |
|||
name: 'RoleList', |
|||
props: { |
|||
customerId: { |
|||
type: String, |
|||
default: '' |
|||
}, |
|||
customerName: { |
|||
type: String, |
|||
default: '' |
|||
} |
|||
}, |
|||
data () { |
|||
return { |
|||
activeName: "work", |
|||
loading1: false, |
|||
loading2: false, |
|||
loading3: false, |
|||
selRoleId: '', |
|||
//职责弹出框相关 |
|||
dutyShow: false, |
|||
description: '', |
|||
roleName: '', |
|||
//功能权限弹出框相关 |
|||
funcShow: false, |
|||
roleShow: false, |
|||
roleName: '', |
|||
funcName: '', |
|||
roleList: [], |
|||
opeList: [], |
|||
roleKey: '', |
|||
operationKey: '', |
|||
scopeOptions: [], |
|||
settingOptions: [], |
|||
checkedScopes: [], |
|||
checkedSettings: [], |
|||
operateSection: [], // 功能选择列表 |
|||
scopeSection: [] // 范围选择列表 |
|||
} |
|||
}, |
|||
created () { |
|||
this.listRoles() |
|||
}, |
|||
mounted () { |
|||
this.dragRoleSort() |
|||
}, |
|||
beforeDestroy () { |
|||
let _data = this.$data |
|||
for (let n in _data) { |
|||
if (typeof _data[n] === 'boolean') _data[n] = false |
|||
if (typeof _data[n] === 'string') _data[n] = '' |
|||
if (typeof _data[n] === 'object') _data[n] = [] |
|||
} |
|||
}, |
|||
methods: { |
|||
tabClick () { |
|||
}, |
|||
//获取角色列表 |
|||
listRoles () { |
|||
this.loading1 = true |
|||
this.$http |
|||
.post('/epmetuser/govstaffrole/roletemplates') |
|||
.then(({ data: res }) => { |
|||
if (res.code === 0) { |
|||
this.roleList = res.data.map(item => { |
|||
return { |
|||
...item, |
|||
constName: item.roleName, |
|||
isEdit: false, |
|||
descriptionList: item.description ? item.description.split("\n") : "" |
|||
} |
|||
}) |
|||
console.log('roleList', this.roleList) |
|||
} |
|||
setTimeout(() => { |
|||
this.loading1 = false |
|||
}, 500) |
|||
}) |
|||
}, |
|||
//关闭角色职责弹出框 |
|||
handleDutyClosed () { |
|||
this.selRoleId = '' |
|||
this.roleName = '' |
|||
this.description = '' |
|||
this.dutyShow = false |
|||
}, |
|||
//显示角色职责弹出框 |
|||
handelChangeDuty (row) { |
|||
this.selRoleId = row.id |
|||
this.description = row.description |
|||
this.roleName = row.roleName |
|||
this.dutyShow = true |
|||
}, |
|||
handleChangeName (row) { |
|||
row.isEdit = true |
|||
name: 'RoleList', |
|||
props: { |
|||
customerId: { |
|||
type: String, |
|||
default: '' |
|||
}, |
|||
customerName: { |
|||
type: String, |
|||
default: '' |
|||
} |
|||
}, |
|||
saveName (row) { |
|||
this.selRoleId = row.id |
|||
this.description = row.description |
|||
this.roleName = row.roleName |
|||
this.updateRole() |
|||
data() { |
|||
return { |
|||
activeName: "work", |
|||
loading1: false, |
|||
loading2: false, |
|||
loading3: false, |
|||
selRoleId: '', |
|||
//职责弹出框相关 |
|||
dutyShow: false, |
|||
description: '', |
|||
roleName: '', |
|||
//功能权限弹出框相关 |
|||
funcShow: false, |
|||
roleShow: false, |
|||
roleName: '', |
|||
funcName: '', |
|||
roleList: [], |
|||
opeList: [], |
|||
roleKey: '', |
|||
operationKey: '', |
|||
scopeOptions: [], |
|||
settingOptions: [], |
|||
checkedScopes: [], |
|||
checkedSettings: [], |
|||
operateSection: [], // 功能选择列表 |
|||
scopeSection: [] // 范围选择列表 |
|||
} |
|||
}, |
|||
//保存角色名称、职责 |
|||
async updateRole () { |
|||
console.log(this.description) |
|||
const url = "/epmetuser/govstaffrole/updatedefaultrole" |
|||
const params = { |
|||
roleId: this.selRoleId, |
|||
roleName: this.roleName, |
|||
description: this.description |
|||
} |
|||
const { data, code, msg } = await requestPost(url, params) |
|||
if (code === 0) { |
|||
this.dutyShow = false |
|||
created() { |
|||
this.listRoles() |
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
}, |
|||
//同步权限到所有客户 |
|||
async toAllClient () { |
|||
const url = "/gov/access/config/add-ope-and-scopes-4role/by-default-conf" |
|||
const params = { |
|||
roleKey: this.roleKey, |
|||
operationKey: this.operationKey, |
|||
} |
|||
const { data, code, msg } = await requestPost(url, params) |
|||
if (code === 0) { |
|||
this.$message.success('同步成功') |
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
}, |
|||
//关闭功能配置弹出框 |
|||
handleDialogClosed () { |
|||
this.roleName = '' |
|||
this.roleKey = '' |
|||
this.funcName = '' |
|||
this.operateSection = [] |
|||
this.scopeSection = [] |
|||
this.funcShow = false |
|||
this.roleShow = false |
|||
}, |
|||
//点击功能权限按钮 |
|||
toOperationConfig (roleKey, roleName) { |
|||
this.roleName = roleName |
|||
this.funcShow = true |
|||
this.opeList = [] |
|||
this.listOperations4AccessConfig(roleKey) |
|||
}, |
|||
listOperations4AccessConfig (roleKey) { |
|||
this.roleKey = roleKey |
|||
this.loading2 = true |
|||
this.$http.post('/gov/access/config/roledefaultops/' + roleKey).then((resp) => { |
|||
this.opeList = resp.data.data |
|||
this.$nextTick(function() { |
|||
this.defaultCheck() // 每次更新了数据,触发这个函数即可。 |
|||
}) |
|||
setTimeout(() => { |
|||
this.loading2 = false |
|||
}, 500) |
|||
}) |
|||
}, |
|||
listSettingOptions (operationKey) { |
|||
let params = { |
|||
roleKey: this.roleKey, |
|||
operationKey: operationKey |
|||
} |
|||
console.log('checkedScopes', this.checkedScopes) |
|||
this.loading3 = true |
|||
this.$http |
|||
.post('/gov/access/config/opedefaultscopes/list', params) |
|||
.then(resp => { |
|||
console.log('scopeOptions', resp.data) |
|||
this.scopeOptions = resp.data.data |
|||
resp.data.data.forEach(item => { |
|||
if (item.assigned) this.checkedScopes.push(item.scopeKey) |
|||
}) |
|||
console.log('checkedScopes222', this.checkedScopes) |
|||
this.settingOptions = resp.data.data |
|||
setTimeout(() => { |
|||
this.loading3 = false |
|||
}, 500) |
|||
}) |
|||
mounted() { |
|||
this.dragRoleSort() |
|||
}, |
|||
defaultCheck () { |
|||
for (var index in this.opeList) { |
|||
let role = this.opeList[index] |
|||
if (role.assigned) { |
|||
this.$refs.opeTable.toggleRowSelection(role, true) |
|||
beforeDestroy() { |
|||
let _data = this.$data |
|||
for (let n in _data) { |
|||
if (typeof _data[n] === 'boolean') _data[n] = false |
|||
if (typeof _data[n] === 'string') _data[n] = '' |
|||
if (typeof _data[n] === 'object') _data[n] = [] |
|||
} |
|||
} |
|||
}, |
|||
toScopeConfig (operationKey, operationName) { |
|||
this.roleShow = true |
|||
this.operationKey = operationKey |
|||
this.funcName = operationName |
|||
this.checkedScopes = [] |
|||
this.listSettingOptions(operationKey) |
|||
}, |
|||
saveOperations4Role () { |
|||
let param = { |
|||
roleKey: this.roleKey, |
|||
operationKeys: this.operateSection.map(item => item.operationKey) |
|||
} |
|||
this.$http.post('/gov/access/config/roledefaultopes/save', param).then( |
|||
resp => { |
|||
const { code, msg } = resp.data |
|||
if (code === 0 && msg === 'success') { |
|||
this.$message({ |
|||
message: '操作成功', |
|||
type: 'success' |
|||
}) |
|||
this.listOperations4AccessConfig(this.roleKey) |
|||
} else { |
|||
this.$message({ |
|||
message: msg, |
|||
type: 'error' |
|||
}) |
|||
} |
|||
} |
|||
) |
|||
}, |
|||
saveSettings () { |
|||
let param = { |
|||
roleKey: this.roleKey, |
|||
operationKey: this.operationKey, |
|||
scopeKeys: this.scopeSection |
|||
} |
|||
this.$http.post('/gov/access/config/opedefaultscopes/save', param).then( |
|||
resp => { |
|||
const { code, msg } = resp.data |
|||
if (code === 0 && msg === 'success') { |
|||
this.$message({ |
|||
type: 'success', |
|||
message: '保存成功' |
|||
methods: { |
|||
tabClick() { |
|||
}, |
|||
//获取角色列表 |
|||
listRoles() { |
|||
this.loading1 = true |
|||
this.$http |
|||
.post('/epmetuser/govstaffrole/roletemplates') |
|||
.then(({ data: res }) => { |
|||
if (res.code === 0) { |
|||
this.roleList = res.data.map(item => { |
|||
return { |
|||
...item, |
|||
constName: item.roleName, |
|||
isEdit: false, |
|||
descriptionList: item.description ? item.description.split("\n") : "" |
|||
} |
|||
}) |
|||
console.log('roleList', this.roleList) |
|||
} |
|||
setTimeout(() => { |
|||
this.loading1 = false |
|||
}, 500) |
|||
}) |
|||
}, |
|||
//关闭角色职责弹出框 |
|||
handleDutyClosed() { |
|||
this.selRoleId = '' |
|||
this.roleName = '' |
|||
this.description = '' |
|||
this.dutyShow = false |
|||
}, |
|||
//显示角色职责弹出框 |
|||
handelChangeDuty(row) { |
|||
this.selRoleId = row.id |
|||
this.description = row.description |
|||
this.roleName = row.roleName |
|||
this.dutyShow = true |
|||
}, |
|||
handleChangeName(row) { |
|||
row.isEdit = true |
|||
}, |
|||
saveName(row) { |
|||
this.selRoleId = row.id |
|||
this.description = row.description |
|||
this.roleName = row.roleName |
|||
this.updateRole() |
|||
}, |
|||
//保存角色名称、职责 |
|||
async updateRole() { |
|||
console.log(this.description) |
|||
const url = "/epmetuser/govstaffrole/updatedefaultrole" |
|||
const params = { |
|||
roleId: this.selRoleId, |
|||
roleName: this.roleName, |
|||
description: this.description |
|||
} |
|||
const { data, code, msg } = await requestPost(url, params) |
|||
if (code === 0) { |
|||
this.dutyShow = false |
|||
this.listRoles() |
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
}, |
|||
//同步权限到所有客户 |
|||
async toAllClient() { |
|||
const url = "/gov/access/config/add-ope-and-scopes-4role/by-default-conf" |
|||
const params = { |
|||
roleKey: this.roleKey, |
|||
operationKey: this.operationKey, |
|||
} |
|||
const { data, code, msg } = await requestPost(url, params) |
|||
if (code === 0) { |
|||
this.$message.success('同步成功') |
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
}, |
|||
//关闭功能配置弹出框 |
|||
handleDialogClosed() { |
|||
this.roleName = '' |
|||
this.roleKey = '' |
|||
this.funcName = '' |
|||
this.operateSection = [] |
|||
this.scopeSection = [] |
|||
this.funcShow = false |
|||
this.roleShow = false |
|||
}, |
|||
//点击功能权限按钮 |
|||
toOperationConfig(roleKey, roleName) { |
|||
this.roleName = roleName |
|||
this.funcShow = true |
|||
this.opeList = [] |
|||
this.listOperations4AccessConfig(roleKey) |
|||
}, |
|||
listOperations4AccessConfig(roleKey) { |
|||
this.roleKey = roleKey |
|||
this.loading2 = true |
|||
this.$http.post('/gov/access/config/roledefaultops/' + roleKey).then((resp) => { |
|||
this.opeList = resp.data.data |
|||
this.$nextTick(function () { |
|||
this.defaultCheck() // 每次更新了数据,触发这个函数即可。 |
|||
}) |
|||
setTimeout(() => { |
|||
this.loading2 = false |
|||
}, 500) |
|||
}) |
|||
this.listSettingOptions(this.operationKey) |
|||
} else { |
|||
this.$message({ |
|||
message: msg, |
|||
type: 'error' |
|||
}, |
|||
listSettingOptions(operationKey) { |
|||
let params = { |
|||
roleKey: this.roleKey, |
|||
operationKey: operationKey |
|||
} |
|||
console.log('checkedScopes', this.checkedScopes) |
|||
this.loading3 = true |
|||
this.$http |
|||
.post('/gov/access/config/opedefaultscopes/list', params) |
|||
.then(resp => { |
|||
console.log('scopeOptions', resp.data) |
|||
this.scopeOptions = resp.data.data |
|||
resp.data.data.forEach(item => { |
|||
if (item.assigned) this.checkedScopes.push(item.scopeKey) |
|||
}) |
|||
console.log('checkedScopes222', this.checkedScopes) |
|||
this.settingOptions = resp.data.data |
|||
setTimeout(() => { |
|||
this.loading3 = false |
|||
}, 500) |
|||
}) |
|||
}, |
|||
defaultCheck() { |
|||
for (var index in this.opeList) { |
|||
let role = this.opeList[index] |
|||
if (role.assigned) { |
|||
this.$refs.opeTable.toggleRowSelection(role, true) |
|||
} |
|||
} |
|||
}, |
|||
toScopeConfig(operationKey, operationName) { |
|||
this.roleShow = true |
|||
this.operationKey = operationKey |
|||
this.funcName = operationName |
|||
this.checkedScopes = [] |
|||
this.listSettingOptions(operationKey) |
|||
}, |
|||
saveOperations4Role() { |
|||
let param = { |
|||
roleKey: this.roleKey, |
|||
operationKeys: this.operateSection.map(item => item.operationKey) |
|||
} |
|||
this.$http.post('/gov/access/config/roledefaultopes/save', param).then( |
|||
resp => { |
|||
const { code, msg } = resp.data |
|||
if (code === 0 && msg === 'success') { |
|||
this.$message({ |
|||
message: '操作成功', |
|||
type: 'success' |
|||
}) |
|||
this.listOperations4AccessConfig(this.roleKey) |
|||
} else { |
|||
this.$message({ |
|||
message: msg, |
|||
type: 'error' |
|||
}) |
|||
} |
|||
} |
|||
) |
|||
}, |
|||
saveSettings() { |
|||
let param = { |
|||
roleKey: this.roleKey, |
|||
operationKey: this.operationKey, |
|||
scopeKeys: this.scopeSection |
|||
} |
|||
this.$http.post('/gov/access/config/opedefaultscopes/save', param).then( |
|||
resp => { |
|||
const { code, msg } = resp.data |
|||
if (code === 0 && msg === 'success') { |
|||
this.$message({ |
|||
type: 'success', |
|||
message: '保存成功' |
|||
}) |
|||
this.listSettingOptions(this.operationKey) |
|||
} else { |
|||
this.$message({ |
|||
message: msg, |
|||
type: 'error' |
|||
}) |
|||
} |
|||
} |
|||
) |
|||
}, |
|||
roleChange(val) { |
|||
this.scopeSection = val |
|||
// this.saveSettings(val) |
|||
}, |
|||
handleSelectionChange(val) { |
|||
this.operateSection = val |
|||
// this.saveOperations4Role(val) |
|||
}, |
|||
dragRoleSort() { |
|||
const el = this.$refs.roleTable.$el.querySelectorAll('.el-table__body-wrapper > table > tbody')[0] |
|||
this.sortTable = Sortable.create(el, { |
|||
group: 'dragTable', |
|||
ghostClass: 'sortable-ghost', // Class name for the drop placeholder, |
|||
// setData: function(dataTransfer, dragEl) { |
|||
// dataTransfer.setData("Text", dragEl.textContent); |
|||
// }, |
|||
delay: 0, |
|||
onChange: evt => { |
|||
// console.log(evt) |
|||
}, |
|||
onEnd: evt => { |
|||
const targetRow = this.roleList.splice(evt.oldIndex, 1)[0] |
|||
this.roleList.splice(evt.newIndex, 0, targetRow) |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
) |
|||
}, |
|||
roleChange (val) { |
|||
this.scopeSection = val |
|||
// this.saveSettings(val) |
|||
}, |
|||
handleSelectionChange (val) { |
|||
this.operateSection = val |
|||
// this.saveOperations4Role(val) |
|||
}, |
|||
dragRoleSort () { |
|||
const el = this.$refs.roleTable.$el.querySelectorAll('.el-table__body-wrapper > table > tbody')[0] |
|||
this.sortTable = Sortable.create(el, { |
|||
group: 'dragTable', |
|||
ghostClass: 'sortable-ghost', // Class name for the drop placeholder, |
|||
// setData: function(dataTransfer, dragEl) { |
|||
// dataTransfer.setData("Text", dragEl.textContent); |
|||
// }, |
|||
delay: 0, |
|||
onChange: evt => { |
|||
// console.log(evt) |
|||
}, |
|||
onEnd: evt => { |
|||
const targetRow = this.roleList.splice(evt.oldIndex, 1)[0] |
|||
this.roleList.splice(evt.newIndex, 0, targetRow) |
|||
handleSaveSort() { |
|||
let data = { |
|||
roleIdList: this.roleList.map(item => { |
|||
return item.id |
|||
}) |
|||
} |
|||
this.$http |
|||
.post('/epmetuser/govstaffrole/savedefaultsort', data) |
|||
.then(({ data: res }) => { |
|||
console.log('ressss', res) |
|||
if (res.code === 0 && res.msg === 'success') { |
|||
this.$message({ |
|||
type: 'success', |
|||
message: '保存成功' |
|||
}) |
|||
this.listRoles() |
|||
} else { |
|||
this.$message({ |
|||
type: 'error', |
|||
message: res.msg |
|||
}) |
|||
} |
|||
}) |
|||
} |
|||
}) |
|||
}, |
|||
handleSaveSort () { |
|||
let data = { |
|||
roleIdList: this.roleList.map(item => { |
|||
return item.id |
|||
}) |
|||
} |
|||
this.$http |
|||
.post('/epmetuser/govstaffrole/savedefaultsort', data) |
|||
.then(({ data: res }) => { |
|||
console.log('ressss', res) |
|||
if (res.code === 0 && res.msg === 'success') { |
|||
this.$message({ |
|||
type: 'success', |
|||
message: '保存成功' |
|||
}) |
|||
this.listRoles() |
|||
} else { |
|||
this.$message({ |
|||
type: 'error', |
|||
message: res.msg |
|||
}) |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
<style scoped> |
|||
.role-container, |
|||
.role-flex { |
|||
display: flex; |
|||
display: flex; |
|||
} |
|||
|
|||
.flex1 { |
|||
flex: 1; |
|||
flex: 1; |
|||
} |
|||
|
|||
.now-name { |
|||
/* display: flex; |
|||
/* display: flex; |
|||
justify-content: space-between; */ |
|||
margin-bottom: 10px; |
|||
margin-bottom: 10px; |
|||
} |
|||
.aui-wrapper .el-card + .el-card { |
|||
margin-top: 0; |
|||
|
|||
.aui-wrapper .el-card+.el-card { |
|||
margin-top: 0; |
|||
} |
|||
|
|||
.role-container .el-dialog__body { |
|||
padding: 0 20px 20px; |
|||
padding: 0 20px 20px; |
|||
} |
|||
|
|||
.div_duty { |
|||
height: 300px; |
|||
position: relative; |
|||
height: 300px; |
|||
position: relative; |
|||
} |
|||
|
|||
.div_btn { |
|||
position: absolute; |
|||
bottom: 30px; |
|||
right: 15px; |
|||
position: absolute; |
|||
bottom: 30px; |
|||
right: 15px; |
|||
} |
|||
</style> |
|||
|
|||
Loading…
Reference in new issue