diff --git a/src/views/permissionManage/create.vue b/src/views/permissionManage/create.vue index b82aea3fd..5ad251967 100644 --- a/src/views/permissionManage/create.vue +++ b/src/views/permissionManage/create.vue @@ -8,10 +8,40 @@ - + + + + + + + + + + + + + + + + { + 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'); diff --git a/src/views/permissionManage/index.vue b/src/views/permissionManage/index.vue index 137f88bef..b498d6e7d 100644 --- a/src/views/permissionManage/index.vue +++ b/src/views/permissionManage/index.vue @@ -1,7 +1,7 @@ @@ -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 });