desc: 修改权限编辑

This commit is contained in:
zyy 2019-09-03 14:38:05 +08:00
parent 8d06b98ba1
commit 7fbadc2bd3
5 changed files with 199 additions and 105 deletions

View File

@ -61,6 +61,14 @@ export function setLessonPermisson(data) {
}); });
} }
/** 设置权限失效或有效*/
export function getPermissionList(id) {
return request({
url: `/api/permission/${id}`,
method: 'get'
});
}
/** /**
* 查询仿真权限列表 * 查询仿真权限列表
*/ */

View File

@ -93,44 +93,11 @@ export default {
activeName: 'first', activeName: 'first',
SignalLeftOrRightList: [], SignalLeftOrRightList: [],
SignalPotLampTypeList: [], SignalPotLampTypeList: [],
/*
{ code: '01', name: '物理点灯' },
{ code: '02', name: '逻辑电灯' }
*/
SignalLampPostTypeList: [], SignalLampPostTypeList: [],
/*
{ code: '01', name: '矮柱' },
{ code: '02', name: '高柱' }
*/
SignalLampPositionTypeList: [], SignalLampPositionTypeList: [],
/*
{ code: '01', name: '单灯' },
{ code: '02', name: '双灯' },
{ code: '03', name: '三灯' },
{ code: '04', name: '四灯' },
{ code: '05', name: '五灯' }
*/
SignalDirectionTypeList: [], SignalDirectionTypeList: [],
/*
{ code: '01', name: '向左行使' },
{ code: '02', name: '向右行驶' }
*/
SignalPositionTypeList: [], SignalPositionTypeList: [],
/*
{ code: '01', name: '区段上边' },
{ code: '02', name: '区段下边' }
*/
SignalUseTypeList: [], SignalUseTypeList: [],
/*
{ code: '01', name: '进站信号机' },
{ code: '02', name: '出站信号机' },
{ code: '03', name: '通过信号机' },
{ code: '04', name: '防护信号机' },
{ code: '05', name: '调车信号机' },
{ code: '06', name: '阻挡信号机' },
{ code: '07', name: '预告信号机' },
{ code: '08', name: '复位信号机' }
*/
failTypes: [ failTypes: [
{ code: '00', name: this.$t('map.normal') }, { code: '00', name: this.$t('map.normal') },
{ code: '01', name: this.$t('map.signalFilamentAlarm') } { code: '01', name: this.$t('map.signalFilamentAlarm') }
@ -145,10 +112,7 @@ export default {
potLampType: '01', potLampType: '01',
directionType: '', directionType: '',
positionType: '', positionType: '',
namePosition: { namePosition: { x: 0, y: 0 },
x: 0,
y: 0
},
useType: '', useType: '',
stationCode: '', stationCode: '',
linkCode: '', linkCode: '',
@ -156,18 +120,9 @@ export default {
rotate: 0, rotate: 0,
guideShow: false, guideShow: false,
buttonShow: false, buttonShow: false,
position: { position: { x: 0, y: 0 },
x: 0, buttonPosition: { x: 0, y: 0 },
y: 0 guidePosition: { x: 0, y: 0 }
},
buttonPosition: {
x: 0,
y: 0
},
guidePosition: {
x: 0,
y: 0
}
}, },
addModel: { addModel: {
sectionCode: '', sectionCode: '',
@ -207,7 +162,7 @@ export default {
return list; return list;
}, },
form() { form() {
const form = { return {
labelWidth: '150px', labelWidth: '150px',
items: { items: {
code: { code: {
@ -258,10 +213,9 @@ export default {
} }
} }
}; };
return form;
}, },
rules() { rules() {
const rules = { return {
code: [ code: [
{ required: true, message: this.$t('rules.selectEquipment'), trigger: 'change' } { required: true, message: this.$t('rules.selectEquipment'), trigger: 'change' }
], ],
@ -293,7 +247,6 @@ export default {
{ required: true, message: this.$t('rules.signalGuidePositionY'), trigger: 'blur' } { required: true, message: this.$t('rules.signalGuidePositionY'), trigger: 'blur' }
] ]
}; };
return rules;
} }
}, },
watch: { watch: {

View File

@ -6,6 +6,7 @@
width="90%" width="90%"
:before-close="doClose" :before-close="doClose"
:close-on-click-modal="false" :close-on-click-modal="false"
:z-index="3000"
> >
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" /> <QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
</el-dialog> </el-dialog>

View File

@ -1,5 +1,6 @@
<template> <template>
<el-dialog title="修改权限内容" :visible.sync="dialogShow" width="30%" :before-close="handleClose"> <div>
<el-dialog title="修改权限内容" :visible.sync="dialogShow" width="30%" :before-close="handleClose" :z-index="2000">
<div> <div>
<el-form <el-form
ref="form" ref="form"
@ -24,30 +25,79 @@
/> />
</el-form-item> </el-form-item>
</el-form> </el-form>
<div v-show="isPackage">
<div class="form_title">地图名称:</div>
<el-select v-model="editModel.mapId" size="mini" :disabled="ruleList.length ? true : false">
<el-option
v-for="item in mapList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
<el-button class="addList" size="small" @click="dialogSelect">添加权限</el-button>
<el-table
:data="ruleList"
border
style="width: 100%"
:height="200"
>
<el-table-column prop="name" label="权限名称" />
<el-table-column prop="type" :label="this.$t('orderAuthor.permissionType')">
<template slot-scope="scope">
{{ computedName(PermissionTypeList, scope.row.type) }}
</template>
</el-table-column>
<el-table-column :label="this.$t('global.operate')" width="80">
<template slot-scope="scope">
<el-button type="text" size="small" @click="deleteForm(scope.$index, scope.row)">{{ $t('global.delete') }}
</el-button>
</template>
</el-table-column>
</el-table>
</div>
</div> </div>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="dialogShow = false">{{ $t('map.cancel') }}</el-button> <el-button @click="dialogShow = false">{{ $t('map.cancel') }}</el-button>
<el-button type="primary" :loading="loading" @click="saveAs">{{ $t('map.confirm') }}</el-button> <el-button type="primary" :loading="loading" @click="saveAs">{{ $t('map.confirm') }}</el-button>
</span> </span>
</el-dialog> </el-dialog>
<choose-permission
ref="choosePermission"
:rule-list="ruleList"
:effective-type-list="EffectiveTypeList"
:permission-type-list="PermissionTypeList"
@addRuleForm="addRuleForm"
@deleteForm="deleteForm"
/>
</div>
</template> </template>
<script> <script>
import { putPermissonDetail } from '@/api/management/author'; import { putPermissonDetail, getPermissionList } from '@/api/management/author';
import { listPublishMap } from '@/api/jmap/map';
import { EventBus } from '@/scripts/event-bus';
import ChoosePermission from './choosePermission';
export default { export default {
name: 'MapSaveAs', name: 'MapSaveAs',
props: { components: {
ChoosePermission
}, },
data() { data() {
return { return {
dialogShow: false, dialogShow: false,
loading: false, loading: false,
isPackage: false,
mapList: [],
ruleList: [],
PermissionTypeList: [],
EffectiveTypeList: [],
editModel: { editModel: {
id: '', id: '',
name: '', name: '',
remarks: '' remarks: '',
mapId: ''
}, },
editRules: { editRules: {
name: [ name: [
@ -56,23 +106,75 @@ export default {
} }
}; };
}, },
watch: { computed: {
// height() {
// return this.$store.state.app.height - 65;
// }
},
mounted() {
this.loadInitData();
}, },
methods: { methods: {
doShow(data) { async loadInitData() {
this.EffectiveTypeList = [];
this.$Dictionary.effectiveType().then(list => {
this.EffectiveTypeList = list.map(elem => { return { value: elem.code, label: elem.name }; });
});
this.PermissionTypeList = [];
this.$Dictionary.permissionType().then(list => {
this.PermissionTypeList = list.map(elem => { return { value: elem.code, label: elem.name }; });
});
this.mapList = [];
const res = await listPublishMap();
if (res.code == 200 && res.data.length) {
res.data.forEach(elem => {
this.mapList.push({ value: elem.id, label: elem.name });
});
} else {
console.error(res);
}
},
computedName(list, code) {
let name = '';
list.forEach(elem => {
if (elem.value == code) {
name = elem.label;
}
});
return name;
},
dialogSelect(row) {
if (this.editModel.mapId) {
this.$refs.choosePermission.doShow(this.editModel.mapId);
} else {
this.$messageBox('请选择地图');
}
},
async doShow(data) {
this.dialogShow = true; this.dialogShow = true;
this.editModel = { this.editModel = {
id: data.id, id: data.id,
name: data.name, name: data.name,
remarks: data.remarks remarks: data.remarks,
mapId: ''
}; };
this.isPackage = data.isPackage;
if (this.isPackage) {
const res = await getPermissionList(data.id);
if (res.code == 200) {
this.ruleList = res.data.relPermissions;
this.editModel.mapId = res.data.relPermissions[0].mapId;
}
}
}, },
close() { close() {
this.editModel = { this.editModel = {
id: '', id: '',
name: '', name: '',
remarks: '' remarks: '',
mapId: ''
}; };
this.dialogShow = false; this.dialogShow = false;
}, },
@ -81,6 +183,11 @@ export default {
}, },
saveAs() { saveAs() {
this.$refs['form'].validate((valid) => { this.$refs['form'].validate((valid) => {
if (this.ruleList.length) {
const arr = this.ruleList.map(nor => {
return nor.id;
});
this.editModel['relPermissions'] = arr;
this.loading = true; this.loading = true;
putPermissonDetail(this.editModel).then(response => { putPermissonDetail(this.editModel).then(response => {
this.loading = false; this.loading = false;
@ -91,8 +198,35 @@ export default {
this.loading = false; this.loading = false;
this.$messageBox(this.$t('map.saveFailed')); this.$messageBox(this.$t('map.saveFailed'));
}); });
} else {
this.$messageBox('请选择多个权限');
}
}); });
},
deleteForm(index, row) {
const idx = this.ruleList.findIndex(elem => { return elem.id == row.id; });
if (idx >= 0) {
row['isPut'] = false;
this.ruleList.splice(idx, 1);
}
EventBus.$emit('reloadTable', { index: index, list: row });
},
addRuleForm(index, row) {
row['isPut'] = true;
this.ruleList.push(row);
EventBus.$emit('reloadTable', { index: index, list: row });
} }
} }
}; };
</script> </script>
<style rel="stylesheet/scss" lang="scss" scoped>
.form_title{
float: left;
width: 90px;
margin-right: 10px;
line-height: 31px;
text-align: right;
font-weight: bold;
margin-bottom: 8px;
}
</style>

View File

@ -29,8 +29,6 @@
style="width: 100%" style="width: 100%"
:height="height-450" :height="height-450"
> >
<!-- <el-table-column prop="createTime" label="创建时间" />
<el-table-column prop="creatorUserName" label="创建者" /> -->
<el-table-column prop="name" label="权限名称" /> <el-table-column prop="name" label="权限名称" />
<el-table-column prop="type" :label="this.$t('orderAuthor.permissionType')"> <el-table-column prop="type" :label="this.$t('orderAuthor.permissionType')">
<template slot-scope="scope"> <template slot-scope="scope">