desc: 调整修改权限逻辑

This commit is contained in:
zyy 2019-09-03 16:13:23 +08:00
parent 10ab09451b
commit 40b67b8cf3
8 changed files with 166 additions and 69 deletions

View File

@ -3,8 +3,8 @@ export function getBaseUrl() {
let BASE_API;
if (process.env.NODE_ENV === 'development') {
// BASE_API = 'https://joylink.club/jlcloud';
BASE_API = 'https://test.joylink.club/jlcloud';
// BASE_API = 'http://192.168.3.5:9000'; // 袁琪
// BASE_API = 'https://test.joylink.club/jlcloud';
BASE_API = 'http://192.168.3.5:9000'; // 袁琪
// BASE_API = 'http://192.168.3.6:9000'; // 旭强
// BASE_API = 'http://192.168.3.4:9000' // 琰培
} else {

View File

@ -80,8 +80,8 @@ StompClient.prototype = {
this.status = false;
this.count++;
this.reconnect(this.count);
}).catch(() => {
this.logOut();
}).catch((err) => {
this.logOut(err);
});
};
}
@ -103,30 +103,27 @@ StompClient.prototype = {
this.reconnect(this.count);
}
}).catch((err) => {
if (err.code == 40003 || err.code == 40004 || err.code == 40005 || err.code == 50012) {
this.logOut();
}
if (err.code == 50008 || err.code == 50014) {
this.url = websocketUrl + handleToken();
this.status = false;
this.count++;
this.reconnect(this.count);
}
this.logOut(err);
});
}
}, 30000);
}
resolve(this);
}, () => {
// console.log('向服务器发起websocket连接', 222222);
if (this.checkTimer) {
clearInterval(this.checkTimer);
this.checkTimer = null;
}
checkLoginLine().then(() => {
this.connect();
}).catch(() => {
this.logOut();
}).catch((err) => {
if (err.code == 40003 || err.code == 40004 || err.code == 40005 || err.code == 50012) {
this.logOut();
}
if (err.code == 50008 || err.code == 50014) {
this.url = websocketUrl + handleToken();
this.connect();
}
});
});
} catch (err) {
@ -135,16 +132,24 @@ StompClient.prototype = {
});
},
logOut() {
MessageBox.confirm('你已被登出,请重新登录', '确定登出', {
confirmButtonText: '重新登录',
showCancelButton: false,
type: 'warning'
}).then(() => {
store.dispatch('FedLogOut', gainClientId()).then(() => {
location.reload();// 为了重新实例化vue-router对象 避免bug
logOut(err) {
if (err.code == 40003 || err.code == 40004 || err.code == 40005 || err.code == 50012) {
MessageBox.confirm('你已被登出,请重新登录', '确定登出', {
confirmButtonText: '重新登录',
showCancelButton: false,
type: 'warning'
}).then(() => {
store.dispatch('FedLogOut', gainClientId()).then(() => {
location.reload();// 为了重新实例化vue-router对象 避免bug
});
});
});
}
if (err.code == 50008 || err.code == 50014) {
this.url = websocketUrl + handleToken();
this.status = false;
this.count++;
this.reconnect(this.count);
}
},
// 恢复链接
reconnect(count) {

View File

@ -1,5 +1,5 @@
<template>
<el-dialog title="打包详情" :visible.sync="dialogShow" width="50%" :before-close="close">
<el-dialog title="打包详情" :visible.sync="dialogShow" width="700px" :before-close="close">
<div>
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
</div>
@ -47,15 +47,15 @@ export default {
type: 'tag',
columnValue: (row) => { return this.$convertField(row.type, this.PermissionTypeList, ['value', 'label']); },
tagType: (row) => { return ''; }
},
{
title: '创建时间',
prop: 'createTime'
},
{
title: '创建者',
prop: 'creatorUserName'
}
// {
// title: '',
// prop: 'createTime'
// },
// {
// title: '',
// prop: 'creatorUserName'
// }
],
actions: [
]

View File

@ -159,8 +159,6 @@ export default {
resp.data.list.forEach(item => {
if (item.id == elem.id) {
item.isPut = true;
} else {
item.isPut = false;
}
});
});

View File

@ -183,11 +183,7 @@ export default {
},
saveAs() {
this.$refs['form'].validate((valid) => {
if (this.ruleList.length) {
const arr = this.ruleList.map(nor => {
return nor.id;
});
this.editModel['relPermissions'] = arr;
if (!this.isPackage) {
this.loading = true;
putPermissonDetail(this.editModel).then(response => {
this.loading = false;
@ -199,7 +195,24 @@ export default {
this.$messageBox(this.$t('map.saveFailed'));
});
} else {
this.$messageBox('请选择多个权限');
if (this.ruleList.length) {
const arr = this.ruleList.map(nor => {
return nor.id;
});
this.editModel['relPermissions'] = arr;
this.loading = true;
putPermissonDetail(this.editModel).then(response => {
this.loading = false;
this.$message.success('修改成功!');
this.$emit('refresh');
this.close();
}).catch(() => {
this.loading = false;
this.$messageBox(this.$t('map.saveFailed'));
});
} else {
this.$messageBox('请选择多个权限');
}
}
});
},

View File

@ -11,7 +11,17 @@
<el-form-item label="权限名称:" prop="name">
<el-input v-model="addModel.name" size="small" />
</el-form-item>
<el-form-item label="地图名称:">
<el-form-item label="描述" prop="remarks">
<el-input
v-model="addModel.remarks"
type="textarea"
:rows="2"
placeholder="请输入内容"
maxlength="60"
show-word-limit
/>
</el-form-item>
<el-form-item v-show="isPackage" label="地图名称:">
<el-select v-model="addModel.mapId" :disabled="ruleList.length ? true : false">
<el-option
v-for="item in mapList"
@ -22,30 +32,33 @@
</el-select>
</el-form-item>
</el-form>
<el-button class="addList" size="small" @click="dialogSelect">添加权限</el-button>
<el-table
:data="ruleList"
border
style="width: 100%"
:height="height-450"
>
<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 v-show="isPackage">
<el-button class="addList" size="small" @click="dialogSelect">添加权限</el-button>
<el-table
:data="ruleList"
border
style="width: 100%"
:height="height-450"
>
<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>
</el-card>
<div class="draft">
<el-button-group>
<el-button type="primary" @click="packForm">{{ $t('orderAuthor.packaging') }}</el-button>
<el-button v-if="!$route.query.id" type="primary" @click="packForm">{{ $t('orderAuthor.packaging') }}</el-button>
<el-button v-if="$route.query.id" type="primary" @click="update">更新</el-button>
<el-button type="primary" @click="turnback">{{ $t('global.back') }}</el-button>
</el-button-group>
</div>
@ -64,7 +77,7 @@
<script>
import { UrlConfig } from '@/router/index';
import { createLessonPermisson } from '@/api/management/author';
import { createLessonPermisson, getPermissionList, putPermissonDetail } from '@/api/management/author';
import { listPublishMap } from '@/api/jmap/map';
import ChoosePermission from './choosePermission';
import { EventBus } from '@/scripts/event-bus';
@ -80,6 +93,7 @@ export default {
display: 1,
addModel: {
name: '',
remarks: '',
mapId: ''
},
rules: {
@ -91,7 +105,8 @@ export default {
ruleList: [],
EffectiveTypeList: [],
PermissionTypeList: [],
mapList: []
mapList: [],
isPackage: true
};
},
computed: {
@ -131,12 +146,21 @@ export default {
this.mapList = [];
const res = await listPublishMap();
res.data.forEach(elem => {
// this.queryForm.queryObject.mapId.config.data.push({ value: elem.id, label: elem.name });
this.mapList.push({ value: elem.id, label: elem.name });
});
} catch (error) {
console.error(error, '获取发布地图');
}
if (this.$route.query.id) {
const res = await getPermissionList(this.$route.query.id);
if (res.code == 200) {
this.ruleList = res.data.relPermissions;
this.addModel.mapId = res.data.relPermissions[0].mapId;
this.isPackage = res.data.isPackage;
this.addModel.name = res.data.name;
this.addModel.remarks = res.data.remarks;
}
}
},
dialogSelect(row) {
if (this.addModel.mapId) {
@ -172,13 +196,38 @@ export default {
this.$message.success('打包成功');
setTimeout(() => {
this.$router.push({ path: `${UrlConfig.orderauthor.authorMange}` });
}, 2000);
}, 500);
}).catch(() => {
this.$messageBox(this.$t('tip.packagingFailed'));
});
} else {
this.$messageBox('请选择多个权限');
}
},
update() {
this.$refs['formData'].validate((valid) => {
if (this.ruleList.length) {
const arr = this.ruleList.map(nor => {
return nor.id;
});
const data = {
id: this.$route.query.id,
name: this.addModel.name,
remarks: this.addModel.remarks,
relPermissions: arr
};
putPermissonDetail(data).then(response => {
this.$message.success('修改成功!');
setTimeout(() => {
this.$router.push({ path: `${UrlConfig.orderauthor.authorMange}` });
}, 500);
}).catch(() => {
this.$messageBox(this.$t('map.saveFailed'));
});
} else {
this.$messageBox('请选择多个权限');
}
});
}
}
};

View File

@ -179,7 +179,11 @@ export default {
this.$router.push({ path: `${UrlConfig.orderauthor.authorMange}/rules` });
},
handleEdit(index, row) {
this.$refs.edit.doShow(row);
if (row.isPackage) {
this.$router.push({ path: `${UrlConfig.orderauthor.authorMange}/rules`, query: { id: row.id } });
} else {
this.$refs.edit.doShow(row);
}
},
create() {
this.$refs.create.doShow();

View File

@ -150,6 +150,14 @@ export default {
return (this.$route.query.lessonId ? row.creatorId == this.userId : true) && row.status == 1;
}
},
{
name: '删除',
type: 'warning',
handleClick: this.handleDelete,
showControl: (row) => {
return this.$route.query.lessonId && row.status == 1;
}
},
{
name: this.$t('global.putaway'),
type: 'primary',
@ -253,6 +261,25 @@ export default {
});
}).catch(() => { });
},
//
handleDelete(index, data) {
this.$confirm(this.$t('publish.wellDelPaper'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
setExamEfficacy(data).then(res => {
this.queryList.reload();
this.$message({
type: 'success',
message: this.$t('publish.setSuccess')
});
}).catch(res => {
this.$message({ type: 'warning', message: `${this.$t('error.setFailed')}${res.message}` });
});
}).catch(() => { });
},
//
handleEfficacy(index, data) {
this.$confirm(this.$t('publish.wellSoldOutPaper'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
@ -270,6 +297,7 @@ export default {
});
}).catch(() => { });
},
//
handleEffective(index, data) {
this.$confirm(this.$t('publish.wellPutawayPaper'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),