Browse Source

组织增加人员检索功能;

dev
luyan 1 year ago
parent
commit
dba0556a3b
  1. 5366
      src/views/modules/base/organization/organization.vue
  2. 615
      src/views/modules/customer/customize/roleList.vue
  3. 669
      src/views/modules/customer/role.vue
  4. 1478
      src/views/modules/home/index.vue
  5. 869
      src/views/modules/productConfig/workRoleAuth.vue
  6. 501
      src/views/modules/workSys/role/role.vue

5366
src/views/modules/base/organization/organization.vue

File diff suppressed because it is too large

615
src/views/modules/customer/customize/roleList.vue

@ -1,98 +1,64 @@
<template> <template>
<div class="role-container"> <div class="role-container">
<el-card class="flex1"> <el-card class="flex1">
<div class="now-name"> <div class="now-name">
当前客户: {{customerName}} 当前客户: {{ customerName }}
<el-button type="primary" <el-button type="primary" size="small" @click="handleSaveSort">保存顺序</el-button>
size="small" </div>
@click="handleSaveSort">保存顺序</el-button> <el-table ref="roleTable" v-loading="loading1" :data="roleList" row-key="roleId" border style="width: 100%">
</div> <el-table-column type="index" width="50"></el-table-column>
<el-table ref="roleTable" <!-- <el-table-column prop="roleId" label="角色ID"></el-table-column> -->
v-loading="loading1" <el-table-column prop="roleName" label="角色名称" width="160">
:data="roleList" <template slot-scope="scope">
row-key="roleId" <el-input v-if="scope.row.isEdit" v-model.trim="scope.row.roleName" clearable>
border </el-input>
style="width: 100%"> <span v-else>{{ scope.row.constName }}</span>
<el-table-column type="index" </template>
width="50"></el-table-column> </el-table-column>
<!-- <el-table-column prop="roleId" label="角色ID"></el-table-column> --> <el-table-column v-if="!funcShow" prop="roleKey" label="角色Key"></el-table-column>
<el-table-column prop="roleName" <el-table-column label="操作">
label="角色名称" <template slot-scope="scope">
width="160"> <el-button type="primary" size="mini"
<template slot-scope="scope"> @click="toOperationConfig(scope.row.roleId, scope.row.roleName)">功能权限</el-button>
<el-input v-if="scope.row.isEdit" <span v-if="scope.row.isEdit" style="display: inline-block; margin-left: 10px;">
v-model.trim="scope.row.roleName" <el-button type="primary" size="small" @click="handleSaveChange(scope.row)">保存</el-button>
clearable> <el-button size="small" @click="scope.row.isEdit = false">取消</el-button>
</el-input> </span>
<span v-else>{{scope.row.constName}}</span> <el-button v-else type="primary" size="mini"
</template> @click="handleChangeName(scope.row)">修改名称</el-button>
</el-table-column> </template>
<el-table-column v-if="!funcShow" </el-table-column>
prop="roleKey" </el-table>
label="角色Key"></el-table-column> </el-card>
<el-table-column label="操作"> <el-card v-show="funcShow" style="flex: 1; margin: 0 10px;">
<template slot-scope="scope"> <div class="now-name">当前角色: {{ roleName }}</div>
<el-button type="primary" <el-table v-loading="loading2" max-height="580" ref="opeTable" :data="opeList" border style="width: 100%"
size="mini"
@click="toOperationConfig(scope.row.roleId, 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-card v-show="funcShow"
style="flex: 1; margin: 0 10px;">
<div class="now-name">当前角色: {{roleName}}</div>
<el-table v-loading="loading2"
max-height="580"
ref="opeTable"
:data="opeList"
border
style="width: 100%"
@select="handleSelectionChange"> @select="handleSelectionChange">
<el-table-column type="selection" <el-table-column type="selection" width="55"></el-table-column>
width="55"></el-table-column> <!-- <el-table-column prop="operationKey" label="操作Key"></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="operationName" <!-- <el-table-column prop="brief" label="简介"></el-table-column> -->
label="操作名称"></el-table-column> <el-table-column label="操作">
<!-- <el-table-column prop="brief" label="简介"></el-table-column> --> <template slot-scope="scope">
<el-table-column label="操作"> <el-button type="primary" size="small"
<template slot-scope="scope"> @click="toScopeConfig(scope.row.operationKey, scope.row.operationName)">权限配置</el-button>
<el-button type="primary" </template>
size="small" </el-table-column>
@click="toScopeConfig(scope.row.operationKey, scope.row.operationName)">权限配置</el-button> </el-table>
</template> </el-card>
</el-table-column> <el-card v-show="roleShow" style="width: 250px;">
</el-table> <div class="now-name">当前功能: {{ funcName }}</div>
</el-card> <div>
<el-card v-show="roleShow" <el-row :gutter="12">
style="width: 250px;"> <el-col v-loading="loading3">
<div class="now-name">当前功能: {{funcName}}</div> <el-card shadow="hover">
<div> <el-checkbox-group class="t" v-model.trim="checkedScopes" @change="roleChange">
<el-row :gutter="12"> <el-checkbox v-for="scope in scopeOptions" :label="scope.scopeKey"
<el-col v-loading="loading3"> :key="scope.scopeKey">{{ scope.scopeName }}</el-checkbox>
<el-card shadow="hover"> </el-checkbox-group>
<el-checkbox-group class="t" </el-card>
v-model.trim="checkedScopes" </el-col>
@change="roleChange"> <!-- <el-col :span="8">
<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-col :span="8">
<el-card shadow="hover"> <el-card shadow="hover">
<el-checkbox-group class="t" v-model.trim="checkedSettings"> <el-checkbox-group class="t" v-model.trim="checkedSettings">
<el-checkbox <el-checkbox
@ -104,261 +70,264 @@
</el-checkbox-group> </el-checkbox-group>
</el-card> </el-card>
</el-col> --> </el-col> -->
</el-row> </el-row>
</div> </div>
</el-card> </el-card>
</div> </div>
</template> </template>
<script> <script>
import Sortable from 'sortablejs' import Sortable from 'sortablejs'
export default { export default {
name: 'RoleList', name: 'RoleList',
props: { props: {
customerId: { customerId: {
type: String, type: String,
default: '' default: ''
}, },
customerName: { customerName: {
type: String, type: String,
default: '' default: ''
}
},
data () {
return {
loading1: false,
loading2: false,
loading3: false,
funcShow: false,
roleShow: false,
roleName: '',
funcName: '',
roleList: [],
opeList: [],
roleKey: '',
operationKey: '',
scopeOptions: [],
settingOptions: [],
checkedScopes: [],
checkedSettings: [],
roleId: ''
}
},
created () {
this.listRolesByCustomerId(this.customerId)
},
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: {
listRolesByCustomerId (customerId) {
this.loading1 = true
this.$http
.post('/epmetuser/govstaffrole/rolesbycustomer/' + customerId)
.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 (roleId) {
this.roleId = roleId
this.loading2 = true
this.$http.post('/gov/access/config/roleopes/' + roleId).then((resp) => {
this.opeList = resp.data.data
this.$nextTick(function() {
this.defaultCheck() //
})
setTimeout(() => {
this.loading2 = false
}, 500)
})
},
listSettingOptions (operationKey) {
let params = {
roleId: this.roleId,
operationKey: operationKey
}
console.log('checkedScopes', this.checkedScopes)
this.checkedScopes = []
this.loading3 = true
this.$http
.post('/gov/access/config/configoptions', params)
.then(resp => {
console.log('scopeOptions', resp.data)
this.scopeOptions = resp.data.data.scopeOptions
resp.data.data.scopeOptions.forEach(item => {
if (item.assigned) this.checkedScopes.push(item.scopeKey)
})
console.log('checkedScopes222', this.checkedScopes)
this.settingOptions = resp.data.data.settingOptions
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 (roleId, roleName) {
this.roleName = roleName
this.funcShow = true
this.opeList = []
this.listOperations4AccessConfig(roleId)
},
toScopeConfig (operationKey, operationName) {
this.roleShow = true
this.operationKey = operationKey
this.funcName = operationName
this.checkedScopes = []
this.listSettingOptions(operationKey)
},
saveOperations4Role (val) {
let param = {
roleId: this.roleId,
opes: val,
customerId: this.customerId
}
this.$http.post('/gov/access/config/saveroleopes', param).then(
resp => {
this.$message({
message: '操作成功',
type: 'success'
})
this.listOperations4AccessConfig(this.roleId)
} }
)
}, },
saveSettings (val) { data() {
let param = { return {
roleId: this.roleId, loading1: false,
operationKey: this.operationKey, loading2: false,
scopeKeys: val, loading3: false,
settingKeys: this.checkedSettings, funcShow: false,
customerId: this.customerId roleShow: false,
} roleName: '',
this.$http.post('/gov/access/config/saveconfig', param).then( funcName: '',
resp => { roleList: [],
this.$message({ opeList: [],
type: 'success', roleKey: '',
message: '保存成功' operationKey: '',
}) scopeOptions: [],
this.listSettingOptions(this.operationKey) settingOptions: [],
checkedScopes: [],
checkedSettings: [],
roleId: ''
} }
)
}, },
roleChange (val) { created() {
this.saveSettings(val) this.listRolesByCustomerId(this.customerId)
}, },
handleSelectionChange (val) { mounted() {
this.saveOperations4Role(val) this.dragRoleSort()
}, },
handleChangeName (row) { beforeDestroy() {
row.isEdit = true 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) { methods: {
let data = { listRolesByCustomerId(customerId) {
roleId: row.roleId, this.loading1 = true
roleName: row.roleName this.$http
} .post('/epmetuser/govstaffrole/rolesbycustomer/' + customerId)
this.$http .then(({ data: res }) => {
.post('/epmetuser/govstaffrole/update-role', data) console.log('ressss', res)
.then(({ data: res }) => { if (res.code === 0) {
console.log('ressss', res) this.roleList = res.data.map(item => {
if (res.code === 0 && res.msg === 'success') { return {
this.$message({ ...item,
type: 'success', constName: item.roleName,
message: '保存成功' isEdit: false
}
})
}
setTimeout(() => {
this.loading1 = false
}, 500)
})
},
listOperations4AccessConfig(roleId) {
this.roleId = roleId
this.loading2 = true
this.$http.post('/gov/access/config/roleopes/' + roleId).then((resp) => {
this.opeList = resp.data.data
this.$nextTick(function () {
this.defaultCheck() //
})
setTimeout(() => {
this.loading2 = false
}, 500)
}) })
this.listRolesByCustomerId(this.customerId) },
} else { listSettingOptions(operationKey) {
this.$message({ let params = {
type: 'error', roleId: this.roleId,
message: res.msg operationKey: operationKey
}
console.log('checkedScopes', this.checkedScopes)
this.checkedScopes = []
this.loading3 = true
this.$http
.post('/gov/access/config/configoptions', params)
.then(resp => {
console.log('scopeOptions', resp.data)
this.scopeOptions = resp.data.data.scopeOptions
resp.data.data.scopeOptions.forEach(item => {
if (item.assigned) this.checkedScopes.push(item.scopeKey)
})
console.log('checkedScopes222', this.checkedScopes)
this.settingOptions = resp.data.data.settingOptions
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(roleId, roleName) {
this.roleName = roleName
this.funcShow = true
this.opeList = []
this.listOperations4AccessConfig(roleId)
},
toScopeConfig(operationKey, operationName) {
this.roleShow = true
this.operationKey = operationKey
this.funcName = operationName
this.checkedScopes = []
this.listSettingOptions(operationKey)
},
saveOperations4Role(val) {
let param = {
roleId: this.roleId,
opes: val,
customerId: this.customerId
}
this.$http.post('/gov/access/config/saveroleopes', param).then(
resp => {
this.$message({
message: '操作成功',
type: 'success'
})
this.listOperations4AccessConfig(this.roleId)
}
)
},
saveSettings(val) {
let param = {
roleId: this.roleId,
operationKey: this.operationKey,
scopeKeys: val,
settingKeys: this.checkedSettings,
customerId: this.customerId
}
this.$http.post('/gov/access/config/saveconfig', param).then(
resp => {
this.$message({
type: 'success',
message: '保存成功'
})
this.listSettingOptions(this.operationKey)
}
)
},
roleChange(val) {
this.saveSettings(val)
},
handleSelectionChange(val) {
this.saveOperations4Role(val)
},
handleChangeName(row) {
row.isEdit = true
},
handleSaveChange(row) {
let data = {
roleId: row.roleId,
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 => { handleSaveSort() {
const targetRow = this.roleList.splice(evt.oldIndex, 1)[0] let data = {
this.roleList.splice(evt.newIndex, 0, targetRow) roleIdList: this.roleList.map(item => {
return item.roleId
})
}
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.roleId
})
}
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> </script>
<style> <style>
.role-container { .role-container {
display: flex; display: flex;
} }
.flex1 { .flex1 {
flex: 1; flex: 1;
} }
.now-name { .now-name {
/* display: flex; /* display: flex;
justify-content: space-between; */ 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;
} }
</style> </style>

669
src/views/modules/customer/role.vue

@ -1,391 +1,362 @@
<template> <template>
<div class="role-container"> <div class="role-container">
<el-card class="flex1"> <el-card class="flex1">
<!-- <div class="now-name"> <!-- <div class="now-name">
当前客户: {{customerName}} 当前客户: {{customerName}}
<el-button type="primary" size="small" @click="handleSaveSort">保存顺序</el-button> <el-button type="primary" size="small" @click="handleSaveSort">保存顺序</el-button>
</div> --> </div> -->
<el-table ref="roleTable" <el-table ref="roleTable" v-loading="loading1" :data="roleList" row-key="roleKey" border
v-loading="loading1"
:data="roleList"
row-key="roleKey"
border
style="width: 100%"> style="width: 100%">
<el-table-column type="index" <el-table-column type="index" width="50"></el-table-column>
width="50"></el-table-column> <!-- <el-table-column prop="roleId" label="角色ID"></el-table-column> -->
<!-- <el-table-column prop="roleId" label="角色ID"></el-table-column> --> <el-table-column prop="roleName" label="角色名称" width="160">
<el-table-column prop="roleName" <template slot-scope="scope">
label="角色名称" <el-input v-if="scope.row.isEdit" v-model.trim="scope.row.roleName" clearable>
width="160"> </el-input>
<template slot-scope="scope"> <span v-else>{{ scope.row.constName }}</span>
<el-input v-if="scope.row.isEdit" </template>
v-model.trim="scope.row.roleName" </el-table-column>
clearable> <el-table-column v-if="!funcShow" prop="roleKey" label="角色Key"></el-table-column>
</el-input> <el-table-column label="操作">
<span v-else>{{scope.row.constName}}</span> <template slot-scope="scope">
</template> <el-button type="primary" size="mini"
</el-table-column> @click="toOperationConfig(scope.row.roleKey, scope.row.roleName)">功能权限</el-button>
<el-table-column v-if="!funcShow" <!-- <span v-if="scope.row.isEdit" style="display: inline-block; margin-left: 10px;">
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 type="primary" size="small" @click="handleSaveChange(scope.row)">保存</el-button>
<el-button size="small" @click="scope.row.isEdit=false">取消</el-button> <el-button size="small" @click="scope.row.isEdit=false">取消</el-button>
</span> </span>
<el-button v-else type="primary" size="mini" @click="handleChangeName(scope.row)">修改名称</el-button> --> <el-button v-else type="primary" size="mini" @click="handleChangeName(scope.row)">修改名称</el-button> -->
</template> </template>
</el-table-column> </el-table-column>
</el-table> </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>
</el-card> </el-card>
<el-card v-show="roleShow" <el-dialog :visible.sync="funcShow" :close-on-click-modal="false" :close-on-press-escape="false" width="70%"
style="width: 250px; margin-left: 10px;"> top="30px" title="功能列表" @closed="handleDialogClosed">
<div class="now-name">当前功能: {{funcName}}</div> <div class="role-flex" v-if="funcShow">
<div class="now-name"> <el-card class="flex1">
<el-button type="primary" <div class="now-name">当前角色: {{ roleName }}</div>
size="small" <div class="now-name">
@click="saveSettings">保存范围</el-button> <el-button type="primary" size="small" @click="saveOperations4Role">保存功能</el-button>
</div> </div>
<div> <el-table v-loading="loading2" height="580" ref="opeTable" :data="opeList" border
<el-row :gutter="12"> @select="handleSelectionChange">
<el-col v-loading="loading3"> <el-table-column type="selection" width="55"></el-table-column>
<el-card shadow="hover"> <!-- <el-table-column prop="operationKey" label="操作Key"></el-table-column> -->
<el-checkbox-group class="t" <el-table-column prop="operationName" label="操作名称"></el-table-column>
v-model.trim="checkedScopes" <!-- <el-table-column prop="brief" label="简介"></el-table-column> -->
@change="roleChange"> <el-table-column label="操作">
<el-checkbox v-for="scope in scopeOptions" <template slot-scope="scope">
:label="scope.scopeKey" <el-button type="primary" size="small"
:key="scope.scopeKey">{{scope.scopeName}}</el-checkbox> @click="toScopeConfig(scope.row.operationKey, scope.row.operationName)">范围配置</el-button>
</el-checkbox-group> </template>
</el-table-column>
</el-table>
</el-card> </el-card>
</el-col> <el-card v-show="roleShow" style="width: 250px; margin-left: 10px;">
</el-row> <div class="now-name">当前功能: {{ funcName }}</div>
</div> <div class="now-name">
</el-card> <el-button type="primary" size="small" @click="saveSettings">保存范围</el-button>
</div> </div>
</el-dialog> <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> </template>
<script> <script>
import Sortable from 'sortablejs' import Sortable from 'sortablejs'
export default { export default {
name: 'RoleList', name: 'RoleList',
props: { props: {
customerId: { customerId: {
type: String, type: String,
default: '' default: ''
}, },
customerName: { customerName: {
type: String, type: String,
default: '' 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'
})
}
} }
)
}, },
saveSettings () { data() {
let param = { return {
roleKey: this.roleKey, loading1: false,
operationKey: this.operationKey, loading2: false,
scopeKeys: this.scopeSection loading3: false,
} funcShow: false,
this.$http.post('/gov/access/config/opedefaultscopes/save', param).then( roleShow: false,
resp => { roleName: '',
const { code, msg } = resp.data funcName: '',
if (code === 0 && msg === 'success') { roleList: [],
this.$message({ opeList: [],
type: 'success', roleKey: '',
message: '保存成功' operationKey: '',
}) scopeOptions: [],
this.listSettingOptions(this.operationKey) settingOptions: [],
} else { checkedScopes: [],
this.$message({ checkedSettings: [],
message: msg, operateSection: [], //
type: 'error' scopeSection: [] //
})
}
} }
)
}, },
roleChange (val) { created() {
this.scopeSection = val this.listRolesByCustomerId()
// this.saveSettings(val)
}, },
handleSelectionChange (val) { mounted() {
this.operateSection = val this.dragRoleSort()
// this.saveOperations4Role(val)
}, },
handleChangeName (row) { beforeDestroy() {
row.isEdit = true 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) { methods: {
let data = { handleDialogClosed() {
roleKey: row.roleKey, this.roleName = ''
roleName: row.roleName this.roleKey = ''
} this.funcName = ''
this.$http this.operateSection = []
.post('/epmetuser/govstaffrole/update-role', data) this.scopeSection = []
.then(({ data: res }) => { this.funcShow = false
console.log('ressss', res) this.roleShow = false
if (res.code === 0 && res.msg === 'success') { },
this.$message({ listRolesByCustomerId(customerId) {
type: 'success', this.loading1 = true
message: '保存成功' 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 { listSettingOptions(operationKey) {
this.$message({ let params = {
type: 'error', roleKey: this.roleKey,
message: res.msg 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 => { handleSaveSort() {
const targetRow = this.roleList.splice(evt.oldIndex, 1)[0] let data = {
this.roleList.splice(evt.newIndex, 0, targetRow) 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> </script>
<style> <style>
.role-container, .role-container,
.role-flex { .role-flex {
display: flex; display: flex;
} }
.flex1 { .flex1 {
flex: 1; flex: 1;
} }
.now-name { .now-name {
/* display: flex; /* display: flex;
justify-content: space-between; */ 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 { .role-container .el-dialog__body {
padding: 0 20px 20px; padding: 0 20px 20px;
} }
</style> </style>

1478
src/views/modules/home/index.vue

File diff suppressed because it is too large

869
src/views/modules/productConfig/workRoleAuth.vue

@ -1,506 +1,443 @@
<template> <template>
<div class="role-container"> <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">
<el-card class="flex1"> <el-card class="flex1">
<div class="now-name">当前角色: {{roleName}}</div> <el-tabs v-model.trim="activeName" @tab-click="tabClick" class="el-tabs">
<div class="now-name"> <el-tab-pane label="工作端" name="work">
<el-button type="primary" <div class="now-name">
size="small" 上下拖动可改变角色顺序
@click="saveOperations4Role">保存功能</el-button> <el-button type="primary" size="small" @click="handleSaveSort">保存顺序</el-button>
</div> </div>
<el-table v-loading="loading2" <el-table ref="roleTable" v-loading="loading1" :data="roleList" row-key="roleKey" border
height="580" style="width: 100%">
ref="opeTable" <el-table-column type="index" header-align="left" align="left" width="50"></el-table-column>
:data="opeList" <el-table-column prop="roleName" label="角色名称" header-align="left" align="left" width="180">
border <template slot-scope="scope">
@select="handleSelectionChange"> <el-input v-if="scope.row.isEdit" v-model.trim="scope.row.roleName" clearable>
<el-table-column type="selection" </el-input>
width="55"></el-table-column> <span v-else>{{ scope.row.constName }}</span>
<!-- <el-table-column prop="operationKey" label="操作Key"></el-table-column> --> </template>
<el-table-column prop="operationName" </el-table-column>
label="操作名称"></el-table-column> <el-table-column v-if="!funcShow" prop="roleKey" header-align="left" align="left" label="角色Key"
<!-- <el-table-column prop="brief" label="简介"></el-table-column> --> width="150"></el-table-column>
<el-table-column label="操作"> <el-table-column prop="description" label="角色职责" header-align="left" align="left">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="primary" <p style="text-align:left;margin:3px 0"
size="small" v-for="(item, index) in scope.row.descriptionList" :key="index">{{ item }}</p>
@click="toScopeConfig(scope.row.operationKey, scope.row.operationName)">范围配置</el-button> <!-- <p>{{scope.row.description}}</p> -->
</template> </template>
</el-table-column> </el-table-column>
</el-table> <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>
<el-card v-show="roleShow" <!-- 角色职责弹出框 -->
style="width: 250px; margin-left: 10px;"> <el-dialog :visible.sync="dutyShow" :close-on-click-modal="false" :close-on-press-escape="false" title="角色职责"
<div class="now-name">当前功能: {{funcName}}</div> width="30%" @closed="handleDutyClosed">
<div class="now-name"> <div class="div_duty" v-if="dutyShow">
<el-button type="primary" <el-input type="textarea" :rows="8" v-model.trim="description"></el-input>
size="small" <div class="div_btn">
@click="saveSettings">保存范围</el-button> <el-button type="primary" size="small" @click="updateRole()">保存</el-button>
<el-button type="primary" <el-button size="small" @click="dutyShow = false">取消</el-button>
size="small" </div>
@click="toAllClient">同步到所有客户</el-button> </div>
</div> </el-dialog>
<div> <!-- 功能配置弹出框 -->
<el-row :gutter="12"> <el-dialog :visible.sync="funcShow" :close-on-click-modal="false" :close-on-press-escape="false" width="70%"
<el-col v-loading="loading3"> top="30px" title="功能列表" @closed="handleDialogClosed">
<el-card shadow="hover"> <div class="role-flex" v-if="funcShow">
<el-checkbox-group class="t" <el-card class="flex1">
v-model.trim="checkedScopes" <div class="now-name">当前角色: {{ roleName }}</div>
@change="roleChange"> <div class="now-name">
<el-checkbox v-for="scope in scopeOptions" <el-button type="primary" size="small" @click="saveOperations4Role">保存功能</el-button>
:label="scope.scopeKey" </div>
:key="scope.scopeKey">{{scope.scopeName}}</el-checkbox> <el-table v-loading="loading2" height="580" ref="opeTable" :data="opeList" border
</el-checkbox-group> @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-card>
</el-col> <el-card v-show="roleShow" style="width: 250px; margin-left: 10px;">
</el-row> <div class="now-name">当前功能: {{ funcName }}</div>
</div> <div class="now-name">
</el-card> <el-button type="primary" size="small" @click="saveSettings">保存范围</el-button>
</div> <el-button type="primary" size="small" @click="toAllClient">同步到所有客户</el-button>
</el-dialog> </div>
</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> </template>
<script> <script>
import Sortable from 'sortablejs' import Sortable from 'sortablejs'
import { requestPost } from "@/js/dai/request"; import { requestPost } from "@/js/dai/request";
export default { export default {
name: 'RoleList', name: 'RoleList',
props: { props: {
customerId: { customerId: {
type: String, type: String,
default: '' default: ''
}, },
customerName: { customerName: {
type: String, type: String,
default: '' 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
}, },
saveName (row) { data() {
this.selRoleId = row.id return {
this.description = row.description activeName: "work",
this.roleName = row.roleName loading1: false,
this.updateRole() 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() {
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() 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) { mounted() {
let params = { this.dragRoleSort()
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 () { beforeDestroy() {
for (var index in this.opeList) { let _data = this.$data
let role = this.opeList[index] for (let n in _data) {
if (role.assigned) { if (typeof _data[n] === 'boolean') _data[n] = false
this.$refs.opeTable.toggleRowSelection(role, true) if (typeof _data[n] === 'string') _data[n] = ''
if (typeof _data[n] === 'object') _data[n] = []
} }
}
}, },
toScopeConfig (operationKey, operationName) { methods: {
this.roleShow = true tabClick() {
this.operationKey = operationKey },
this.funcName = operationName //
this.checkedScopes = [] listRoles() {
this.listSettingOptions(operationKey) this.loading1 = true
}, this.$http
saveOperations4Role () { .post('/epmetuser/govstaffrole/roletemplates')
let param = { .then(({ data: res }) => {
roleKey: this.roleKey, if (res.code === 0) {
operationKeys: this.operateSection.map(item => item.operationKey) this.roleList = res.data.map(item => {
} return {
this.$http.post('/gov/access/config/roledefaultopes/save', param).then( ...item,
resp => { constName: item.roleName,
const { code, msg } = resp.data isEdit: false,
if (code === 0 && msg === 'success') { descriptionList: item.description ? item.description.split("\n") : ""
this.$message({ }
message: '操作成功', })
type: 'success' console.log('roleList', this.roleList)
}) }
this.listOperations4AccessConfig(this.roleKey) setTimeout(() => {
} else { this.loading1 = false
this.$message({ }, 500)
message: msg, })
type: 'error' },
}) //
} handleDutyClosed() {
} this.selRoleId = ''
) this.roleName = ''
}, this.description = ''
saveSettings () { this.dutyShow = false
let param = { },
roleKey: this.roleKey, //
operationKey: this.operationKey, handelChangeDuty(row) {
scopeKeys: this.scopeSection this.selRoleId = row.id
} this.description = row.description
this.$http.post('/gov/access/config/opedefaultscopes/save', param).then( this.roleName = row.roleName
resp => { this.dutyShow = true
const { code, msg } = resp.data },
if (code === 0 && msg === 'success') { handleChangeName(row) {
this.$message({ row.isEdit = true
type: 'success', },
message: '保存成功' 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 { listSettingOptions(operationKey) {
this.$message({ let params = {
message: msg, roleKey: this.roleKey,
type: 'error' 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 => { handleSaveSort() {
const targetRow = this.roleList.splice(evt.oldIndex, 1)[0] let data = {
this.roleList.splice(evt.newIndex, 0, targetRow) 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> </script>
<style scoped> <style scoped>
.role-container, .role-container,
.role-flex { .role-flex {
display: flex; display: flex;
} }
.flex1 { .flex1 {
flex: 1; flex: 1;
} }
.now-name { .now-name {
/* display: flex; /* display: flex;
justify-content: space-between; */ 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 { .role-container .el-dialog__body {
padding: 0 20px 20px; padding: 0 20px 20px;
} }
.div_duty { .div_duty {
height: 300px; height: 300px;
position: relative; position: relative;
} }
.div_btn { .div_btn {
position: absolute; position: absolute;
bottom: 30px; bottom: 30px;
right: 15px; right: 15px;
} }
</style> </style>

501
src/views/modules/workSys/role/role.vue

@ -1,20 +1,13 @@
<template> <template>
<div class="g-main"> <div class="g-main">
<div class="m-search"> <div class="m-search">
<el-form :inline="true" <el-form :inline="true" :model="formData" ref="ref_searchform" :label-width="'110px'">
:model="formData" <el-form-item label="角色名称" prop="name">
ref="ref_searchform" <el-input v-model.trim="formData.name" size="small" class="list_item_width_1" clearable
:label-width="'110px'"> placeholder="请输入角色名称">
<el-form-item label="角色名称" </el-input>
prop="name"> </el-form-item>
<el-input v-model.trim="formData.name" <!-- <el-form-item label="创建时间"
size="small"
class="list_item_width_1"
clearable
placeholder="请输入角色名称">
</el-input>
</el-form-item>
<!-- <el-form-item label="创建时间"
label-width="110px" label-width="110px"
prop="createdTime"> prop="createdTime">
<el-date-picker v-model.trim="formData.createdTime" <el-date-picker v-model.trim="formData.createdTime"
@ -26,116 +19,58 @@
placeholder="创建时间"> placeholder="创建时间">
</el-date-picker> </el-date-picker>
</el-form-item> --> </el-form-item> -->
<el-button style="margin-left:10px" <el-button style="margin-left:10px" size="small" class="diy-button--add"
size="small" @click="handleSearch">查询</el-button>
class="diy-button--add" <el-button style="margin-left:30px" size="small" class="diy-button--white"
@click="handleSearch">查询</el-button> @click="resetSearch">重置</el-button>
<el-button style="margin-left:30px" </el-form>
size="small" </div>
class="diy-button--white" <div class="m-table">
@click="resetSearch">重置</el-button> <div class="div_btn">
</el-form> <el-button class="diy-button--add" size="small" @click="handleAdd">新增</el-button>
</div>
<el-table class="table" ref="ref_table" :data="tableData" border :height="tableHeight"
v-loading="tableLoading" style="width: 100%">
<el-table-column label="序号" header-align="center" align="center" type="index"
width="50"></el-table-column>
<el-table-column prop="name" header-align="center" align="center" label="角色名称" min-width="100">
</el-table-column>
<el-table-column prop="defaultRole" header-align="center" align="center" label="默认角色" in-width="30">
<template slot-scope="scope">
{{ scope.row.defaultRole == '0' ? 'X' : '√' }}
</template>
</el-table-column>
<el-table-column prop="levelName" header-align="center" align="center" label="级别" in-width="30">
</el-table-column>
<el-table-column prop="remark" header-align="center" align="center" label="备注" min-width="110">
</el-table-column>
<el-table-column prop="createdTime" header-align="center" align="center" label="创建时间" min-width="170">
</el-table-column>
<el-table-column label="操作" fixed="right" width="140" header-align="center" align="center"
class="operate">
<template slot-scope="scope">
<el-button v-if="true" type="text" class="div-table-button--detail" size="small"
@click="handleDetail(scope.row)">查看</el-button>
<el-button type="text" class="div-table-button--edit" size="small"
@click="handleEdit(scope.row)">修改</el-button>
<el-button v-if="scope.row.defaultRole !== '1'" type="text" class="div-table-button--delete "
size="small" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div>
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
:current-page.sync="pageNo" :page-sizes="[20, 50, 100, 200]" :page-size="pageSize"
layout="sizes, prev, pager, next, total" :total="total">
</el-pagination>
</div>
</div>
<!-- 修改弹出框 -->
<el-dialog :visible.sync="formShow" :close-on-click-modal="false" :close-on-press-escape="false"
:title="formTitle" width="850px" top="5vh" class="dialog-h" @closed="diaClose">
<role-form ref="ref_form" @dialogCancle="diaClose" @dialogOk="addFormOk"></role-form>
</el-dialog>
</div> </div>
<div class="m-table">
<div class="div_btn">
<el-button class="diy-button--add"
size="small"
@click="handleAdd">新增</el-button>
</div>
<el-table class="table"
ref="ref_table"
:data="tableData"
border
:height="tableHeight"
v-loading="tableLoading"
style="width: 100%">
<el-table-column label="序号"
header-align="center"
align="center"
type="index"
width="50"></el-table-column>
<el-table-column prop="name"
header-align="center"
align="center"
label="角色名称"
min-width="100">
</el-table-column>
<el-table-column prop="defaultRole"
header-align="center"
align="center"
label="默认角色"
in-width="30">
<template slot-scope="scope">
{{ scope.row.defaultRole == '0' ? 'X' : '√' }}
</template>
</el-table-column>
<el-table-column prop="levelName"
header-align="center"
align="center"
label="级别"
in-width="30">
</el-table-column>
<el-table-column prop="remark"
header-align="center"
align="center"
label="备注"
min-width="110">
</el-table-column>
<el-table-column prop="createdTime"
header-align="center"
align="center"
label="创建时间"
min-width="170">
</el-table-column>
<el-table-column label="操作"
fixed="right"
width="140"
header-align="center"
align="center"
class="operate">
<template slot-scope="scope">
<el-button v-if="true"
type="text"
class="div-table-button--detail"
size="small"
@click="handleDetail(scope.row)">查看</el-button>
<el-button type="text"
class="div-table-button--edit"
size="small"
@click="handleEdit(scope.row)">修改</el-button>
<el-button v-if="scope.row.defaultRole!=='1'"
type="text"
class="div-table-button--delete "
size="small"
@click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div>
<el-pagination @size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page.sync="pageNo"
:page-sizes="[20, 50, 100, 200]"
:page-size="pageSize"
layout="sizes, prev, pager, next, total"
:total="total">
</el-pagination>
</div>
</div>
<!-- 修改弹出框 -->
<el-dialog :visible.sync="formShow"
:close-on-click-modal="false"
:close-on-press-escape="false"
:title="formTitle"
width="850px"
top="5vh"
class="dialog-h"
@closed="diaClose">
<role-form ref="ref_form"
@dialogCancle="diaClose"
@dialogOk="addFormOk"></role-form>
</el-dialog>
</div>
</template> </template>
<script> <script>
import roleForm from './roleForm' import roleForm from './roleForm'
@ -144,174 +79,174 @@ import { mapGetters } from 'vuex'
import { Loading } from 'element-ui' // Loading import { Loading } from 'element-ui' // Loading
let loading // let loading //
export default { export default {
data () { data() {
return { return {
loading: false, loading: false,
total: 0, total: 0,
pageSize:window.localStorage.getItem('pageSize') || 20, pageSize: window.localStorage.getItem('pageSize') || 20,
pageNo: 0, pageNo: 0,
tableLoading: false, tableLoading: false,
isResiUser: true, isResiUser: true,
agencyId: '', agencyId: '',
timeRange: [], timeRange: [],
formData: { formData: {
name: '',// name: '',//
// createdTime: '',// // createdTime: '',//
}, },
tableData: [], tableData: [],
//form //form
formShow: false, formShow: false,
formTitle: '新增', formTitle: '新增',
} }
},
components: {
roleForm
},
async created () {
},
async mounted () {
const { user } = this.$store.state
this.agencyId = user.agencyId
await this.loadTable()
},
activated () {
this.$refs['ref_table'].doLayout()
},
methods: {
async handleSearch () {
this.isResiUser = this.formData.orgType === 'current'
await this.loadTable()
this.$nextTick(() => {
this.$refs.ref_table.doLayout() //
})
},
async loadTable () {
this.tableLoading = true
const url = "/gov/access/govrole/page"
let params = {
pageSize: this.pageSize,
pageNo: this.pageNo,
...this.formData
}
const { data, code, msg } = await requestGet(url, params)
if (code === 0) {
this.total = data.total
this.tableData = data.list
} else {
this.$message.error(msg)
}
this.tableLoading = false
},
handleTimeChange (time) {
if (time) {
this.formData.startTime = time[0]
this.formData.endTime = time[1]
} else {
this.formData.startTime = ''
this.formData.endTime = ''
}
},
diaClose () {
this.$refs.ref_form.resetData()
this.formShow = false
}, },
handleAdd () { components: {
this.formTitle = '新增' roleForm
this.formShow = true
this.$nextTick(() => {
this.$refs.ref_form.initForm('add', null)
})
}, },
handleEdit (row) { async created() {
this.formTitle = '修改'
this.formShow = true
this.$nextTick(() => {
this.$refs.ref_form.initForm('edit', row.id, row.defaultRole)
})
}, },
handleDetail (row) { async mounted() {
this.formTitle = '详情' const { user } = this.$store.state
this.formShow = true this.agencyId = user.agencyId
this.$nextTick(() => { await this.loadTable()
this.$refs.ref_form.initForm('detail', row.id)
})
}, },
addFormOk () { activated() {
this.formShow = false this.$refs['ref_table'].doLayout()
this.loadTable()
}, },
async handleDelete (row) { methods: {
let message = '确认删除?' async handleSearch() {
this.$confirm(message, "提示", { this.isResiUser = this.formData.orgType === 'current'
confirmButtonText: "确定", await this.loadTable()
cancelButtonText: "取消", this.$nextTick(() => {
type: "warning" this.$refs.ref_table.doLayout() //
}) })
.then(() => { },
this.deleteRole(row) async loadTable() {
}) this.tableLoading = true
.catch(err => { const url = "/gov/access/govrole/page"
}); let params = {
pageSize: this.pageSize,
pageNo: this.pageNo,
...this.formData
}
const { data, code, msg } = await requestGet(url, params)
if (code === 0) {
this.total = data.total
this.tableData = data.list
} else {
this.$message.error(msg)
}
this.tableLoading = false
},
handleTimeChange(time) {
if (time) {
this.formData.startTime = time[0]
this.formData.endTime = time[1]
} else {
this.formData.startTime = ''
this.formData.endTime = ''
}
},
diaClose() {
this.$refs.ref_form.resetData()
this.formShow = false
},
handleAdd() {
this.formTitle = '新增'
this.formShow = true
this.$nextTick(() => {
this.$refs.ref_form.initForm('add', null)
})
},
handleEdit(row) {
this.formTitle = '修改'
this.formShow = true
this.$nextTick(() => {
this.$refs.ref_form.initForm('edit', row.id, row.defaultRole)
})
},
handleDetail(row) {
this.formTitle = '详情'
this.formShow = true
this.$nextTick(() => {
this.$refs.ref_form.initForm('detail', row.id)
})
},
addFormOk() {
this.formShow = false
this.loadTable()
},
async handleDelete(row) {
let message = '确认删除?'
this.$confirm(message, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
this.deleteRole(row)
})
.catch(err => {
});
},
async deleteRole(row) {
const url = "/gov/access/govrole/del"
let params = [row.id]
const { data, code, msg } = await requestPost(url, params)
if (code === 0) {
this.$message({
type: "success",
message: "操作成功"
});
this.loadTable()
} else {
this.$message.error(msg)
}
},
//
resetSearch() {
this.formData = {
name: '',//
}
this.pageNo = 0
this.loadTable()
},
handleSizeChange(val) {
this.pageSize = val
this.pageNo = 1
this.loadTable()
},
handleCurrentChange(val) {
this.pageNo = val
this.loadTable()
},
//
startLoading() {
loading = Loading.service({
lock: true, //
text: '正在加载……', //
background: 'rgba(0,0,0,.7)' //
})
},
//
endLoading() {
// clearTimeout(timer);
if (loading) {
loading.close()
}
}
}, },
async deleteRole (row) { computed: {
const url = "/gov/access/govrole/del" tableHeight() {
let params = [row.id] return this.$store.state.inIframe ? this.clientHeight - 360 + this.iframeHeight : this.clientHeight - 360
const { data, code, msg } = await requestPost(url, params) },
if (code === 0) { ...mapGetters(['clientHeight', 'iframeHeight'])
this.$message({
type: "success",
message: "操作成功"
});
this.loadTable()
} else {
this.$message.error(msg)
}
}, },
// watch: {
resetSearch () {
this.formData = {
name: '',//
}
this.pageNo = 0
this.loadTable()
}, },
handleSizeChange (val) { props: {
this.pageSize = val
this.pageNo = 1
this.loadTable()
},
handleCurrentChange (val) {
this.pageNo = val
this.loadTable()
},
//
startLoading () {
loading = Loading.service({
lock: true, //
text: '正在加载……', //
background: 'rgba(0,0,0,.7)' //
})
},
//
endLoading () {
// clearTimeout(timer);
if (loading) {
loading.close()
}
} }
},
computed: {
tableHeight () {
return this.$store.state.inIframe ? this.clientHeight - 360 + this.iframeHeight : this.clientHeight - 360
},
...mapGetters(['clientHeight', 'iframeHeight'])
},
watch: {
},
props: {
}
} }
</script> </script>
<style lang="scss" scoped > <style lang="scss" scoped>
@import "@/assets/scss/modules/management/epidemic.scss"; @import "@/assets/scss/modules/management/epidemic.scss";
</style> </style>

Loading…
Cancel
Save