调整权限管理

This commit is contained in:
dong 2022-10-31 18:24:47 +08:00
parent 56b2885fba
commit 64dd376229
2 changed files with 181 additions and 11 deletions

View File

@ -8,10 +8,40 @@
<el-form-item :label="$t('orderAuthor.describtion')">
<el-input v-model="editModel.des" />
</el-form-item>
<el-form-item :label="$t('orderAuthor.ability')">
<el-form-item :label="$t('orderAuthor.permissionType')" prop="permissionType">
<el-select v-model="editModel.permissionType" :placeholder="$t('map.pleaseSelect')">
<el-option
v-for="item in permissionTypeList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item v-if="editModel.permissionType === 0" label="项目" prop="projectCode">
<el-select v-model="editModel.projectCode" :placeholder="$t('map.pleaseSelect')">
<el-option
v-for="item in projectList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item v-if="editModel.permissionType === 1 || editModel.permissionType === 2" label="线路" prop="mapId">
<el-select v-model="editModel.mapId" :placeholder="$t('map.pleaseSelect')" @change="mapIdChange">
<el-option
v-for="item in mapList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item v-if="editModel.permissionType === 2" :label="$t('orderAuthor.ability')" prop="abilityIds">
<el-select v-model="editModel.abilityIds" multiple :placeholder="$t('map.pleaseSelect')">
<el-option
v-for="item in abilityList"
v-for="item in filterAbilityList"
:key="item.value"
:label="item.label"
:value="item.value"
@ -33,7 +63,19 @@ import { createPermission, updatePermission } from '@/api/permissionManage';
export default {
name: 'MapSaveAs',
props: {
abilityList:{
abilityList: {
required:true,
type:Array
},
permissionTypeList: {
required:true,
type:Array
},
mapList: {
required:true,
type:Array
},
projectList: {
required:true,
type:Array
}
@ -46,16 +88,60 @@ export default {
editModel: {
name: '',
des: '',
permissionType: '',
projectCode: '',
mapId: '',
abilityIds: []
},
editRules: {
name: [
{ required: true, message: this.$t('rules.enterPermissionName'), trigger: 'blur' }
],
permissionType: [
{ required: true, message: '请选择权限类型!', trigger: 'blur' }
],
projectCode: [
{ required: true, message: '请选择项目!', trigger: 'blur' }
],
mapId: [
{ required: true, message: '请选择线路!', trigger: 'blur' }
],
abilityIds: [
{ required: true, message: '请选择功能!', trigger: 'blur' },
{ validator: this.validateLimit, trigger: 'blur' }
]
}
};
},
computed: {
mapName() {
let name = '';
const findObj = this.mapList.find(item => {
return item.value == this.editModel.mapId;
});
if (findObj && this.editModel.mapId) {
name = findObj.label;
}
return name;
},
filterAbilityList() {
return this.abilityList.filter(item => {
return item.mapName == this.mapName;
});
}
},
methods: {
mapIdChange() {
this.editModel.abilityIds = [];
},
validateLimit(rule, value, callback) {
const num = value.length;
if (num >= 1) {
callback();
} else {
callback(new Error('请选择功能!'));
}
},
doShow(data) {
if (data) {
this.isEdit = true;
@ -64,9 +150,8 @@ export default {
abilityIds.push(item.id);
});
this.editModel = {
id: data.id,
name: data.name,
des: data.des || '',
...data,
mapId: data.mapId ? String(data.mapId) : '',
abilityIds: abilityIds
};
} else {
@ -79,6 +164,9 @@ export default {
this.editModel = {
name: '',
des: '',
permissionType: '',
projectCode: '',
mapId: '',
abilityIds: []
};
},
@ -97,7 +185,17 @@ export default {
if (this.isEdit) {
apiFn = updatePermission;
}
apiFn(this.editModel).then((res) => {
const cpData = Object.assign({}, this.editModel);
if (this.editModel.permissionType === 0) {
delete cpData.mapId;
cpData.abilityIds = [];
} else if (this.editModel.permissionType === 1) {
delete cpData.projectCode;
cpData.abilityIds = [];
} else if (this.editModel.permissionType === 2) {
delete cpData.projectCode;
}
apiFn(cpData).then((res) => {
this.loading = false;
this.$message.success(`${this.isEdit ? '编辑' : '新建'}成功!`);
this.$emit('refresh');

View File

@ -1,7 +1,7 @@
<template>
<div>
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
<create ref="create" :ability-list="abilityList" @refresh="reloadTable" />
<create ref="create" :ability-list="abilityList" :permission-type-list="permissionTypeList" :map-list="mapList" :project-list="projectList" @refresh="reloadTable" />
</div>
</template>
@ -9,6 +9,8 @@
import { getPermissionPage } from '@/api/permissionManage';
import Create from './create';
import { getAllAbility } from '@/api/functionManage';
import { queryMapListByUser } from '@/api/jmap/map';
import { ProjectList } from '@/scripts/ProjectConfig';
export default {
name: 'PermissionManage',
@ -33,24 +35,52 @@ export default {
},
data() {
return {
// PermissionTypeList: [],
// mapList: [],
permissionTypeList: [
{label: '项目', value: 0},
{label: '线路', value: 1},
{label: '线路功能', value: 2}
],
mapList: [],
abilityList: [],
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
queryForm: {
columnNum: 6,
labelWidth: '100px',
leftSpan: 19,
reset: true,
queryObject: {
name: {
type: 'text',
columnNeed: 1,
label: this.$t('orderAuthor.permissionName')
},
des: {
type: 'text',
label: this.$t('orderAuthor.describtion')
},
permissionType: {
type: 'select',
label: this.$t('orderAuthor.permissionType'),
config: {
data: []
}
},
projectCode: {
type: 'select',
label: '项目',
config: {
data: []
}
},
mapId: {
type: 'select',
label: '线路',
config: {
data: []
}
}
}
},
@ -58,6 +88,7 @@ export default {
query: this.queryFunction,
selectCheckShow: false,
indexShow: true,
height: '700',
columns: [
{
title: this.$t('orderAuthor.permissionName'),
@ -68,6 +99,27 @@ export default {
title: this.$t('orderAuthor.describtion'),
prop: 'des'
},
{
title: this.$t('orderAuthor.permissionType'),
prop: 'permissionType',
type: 'tag',
columnValue: (row) => { return this.$convertField(row.permissionType, this.permissionTypeList, ['value', 'label']); },
tagType: (row) => { return ''; }
},
{
title: '项目',
prop: 'projectCode',
type: 'tag',
columnValue: (row) => { return this.$convertField(row.projectCode, this.projectList, ['value', 'label']); },
tagType: (row) => { return ''; }
},
{
title: '线路',
prop: 'mapId',
type: 'tag',
columnValue: (row) => { return this.$convertField(row.mapId, this.mapList, ['value', 'label']); },
tagType: (row) => { return ''; }
},
{
title: this.$t('orderAuthor.ability'),
prop: 'abilityVOList',
@ -117,14 +169,33 @@ export default {
}
};
},
computed: {
projectList() {
return ProjectList;
}
},
created() {
this.getAllAbility();
if (this.tableHeight) {
this.queryList.height = this.tableHeight;
}
this.loadInitData();
},
methods: {
loadInitData() {
this.queryForm.queryObject.permissionType.config.data = this.permissionTypeList;
this.queryForm.queryObject.projectCode.config.data = ProjectList;
//
queryMapListByUser().then(res => {
res.data.forEach(elem => {
const obj = { value: elem.id, label: elem.name };
this.queryForm.queryObject.mapId.config.data.push(obj);
this.mapList.push(obj);
});
}).catch(error=>{
console.error(error, '获取发布地图');
});
},
selectDisabled(index, row) {
let s = false;
const findObj = this.selectIds.find(item => {
@ -139,6 +210,7 @@ export default {
getAllAbility().then(res => {
res.data && res.data.forEach(item => {
this.abilityList.push({
mapName: item.mapName,
label: item.name,
value: item.id
});