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; let BASE_API;
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
// BASE_API = 'https://joylink.club/jlcloud'; // BASE_API = 'https://joylink.club/jlcloud';
BASE_API = 'https://test.joylink.club/jlcloud'; // BASE_API = 'https://test.joylink.club/jlcloud';
// BASE_API = 'http://192.168.3.5:9000'; // 袁琪 BASE_API = 'http://192.168.3.5:9000'; // 袁琪
// BASE_API = 'http://192.168.3.6:9000'; // 旭强 // BASE_API = 'http://192.168.3.6:9000'; // 旭强
// BASE_API = 'http://192.168.3.4:9000' // 琰培 // BASE_API = 'http://192.168.3.4:9000' // 琰培
} else { } else {

View File

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

View File

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

View File

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

View File

@ -183,6 +183,18 @@ export default {
}, },
saveAs() { saveAs() {
this.$refs['form'].validate((valid) => { this.$refs['form'].validate((valid) => {
if (!this.isPackage) {
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 {
if (this.ruleList.length) { if (this.ruleList.length) {
const arr = this.ruleList.map(nor => { const arr = this.ruleList.map(nor => {
return nor.id; return nor.id;
@ -201,6 +213,7 @@ export default {
} else { } else {
this.$messageBox('请选择多个权限'); this.$messageBox('请选择多个权限');
} }
}
}); });
}, },
deleteForm(index, row) { deleteForm(index, row) {

View File

@ -11,7 +11,17 @@
<el-form-item label="权限名称:" prop="name"> <el-form-item label="权限名称:" prop="name">
<el-input v-model="addModel.name" size="small" /> <el-input v-model="addModel.name" size="small" />
</el-form-item> </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-select v-model="addModel.mapId" :disabled="ruleList.length ? true : false">
<el-option <el-option
v-for="item in mapList" v-for="item in mapList"
@ -22,6 +32,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div v-show="isPackage">
<el-button class="addList" size="small" @click="dialogSelect">添加权限</el-button> <el-button class="addList" size="small" @click="dialogSelect">添加权限</el-button>
<el-table <el-table
:data="ruleList" :data="ruleList"
@ -42,10 +53,12 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</div>
</el-card> </el-card>
<div class="draft"> <div class="draft">
<el-button-group> <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 type="primary" @click="turnback">{{ $t('global.back') }}</el-button>
</el-button-group> </el-button-group>
</div> </div>
@ -64,7 +77,7 @@
<script> <script>
import { UrlConfig } from '@/router/index'; 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 { listPublishMap } from '@/api/jmap/map';
import ChoosePermission from './choosePermission'; import ChoosePermission from './choosePermission';
import { EventBus } from '@/scripts/event-bus'; import { EventBus } from '@/scripts/event-bus';
@ -80,6 +93,7 @@ export default {
display: 1, display: 1,
addModel: { addModel: {
name: '', name: '',
remarks: '',
mapId: '' mapId: ''
}, },
rules: { rules: {
@ -91,7 +105,8 @@ export default {
ruleList: [], ruleList: [],
EffectiveTypeList: [], EffectiveTypeList: [],
PermissionTypeList: [], PermissionTypeList: [],
mapList: [] mapList: [],
isPackage: true
}; };
}, },
computed: { computed: {
@ -131,12 +146,21 @@ export default {
this.mapList = []; this.mapList = [];
const res = await listPublishMap(); const res = await listPublishMap();
res.data.forEach(elem => { 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 }); this.mapList.push({ value: elem.id, label: elem.name });
}); });
} catch (error) { } catch (error) {
console.error(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) { dialogSelect(row) {
if (this.addModel.mapId) { if (this.addModel.mapId) {
@ -172,13 +196,38 @@ export default {
this.$message.success('打包成功'); this.$message.success('打包成功');
setTimeout(() => { setTimeout(() => {
this.$router.push({ path: `${UrlConfig.orderauthor.authorMange}` }); this.$router.push({ path: `${UrlConfig.orderauthor.authorMange}` });
}, 2000); }, 500);
}).catch(() => { }).catch(() => {
this.$messageBox(this.$t('tip.packagingFailed')); this.$messageBox(this.$t('tip.packagingFailed'));
}); });
} else { } else {
this.$messageBox('请选择多个权限'); 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` }); this.$router.push({ path: `${UrlConfig.orderauthor.authorMange}/rules` });
}, },
handleEdit(index, row) { handleEdit(index, row) {
if (row.isPackage) {
this.$router.push({ path: `${UrlConfig.orderauthor.authorMange}/rules`, query: { id: row.id } });
} else {
this.$refs.edit.doShow(row); this.$refs.edit.doShow(row);
}
}, },
create() { create() {
this.$refs.create.doShow(); 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; 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'), name: this.$t('global.putaway'),
type: 'primary', type: 'primary',
@ -253,6 +261,25 @@ export default {
}); });
}).catch(() => { }); }).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) { handleEfficacy(index, data) {
this.$confirm(this.$t('publish.wellSoldOutPaper'), this.$t('global.tips'), { this.$confirm(this.$t('publish.wellSoldOutPaper'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'), confirmButtonText: this.$t('global.confirm'),
@ -270,6 +297,7 @@ export default {
}); });
}).catch(() => { }); }).catch(() => { });
}, },
//
handleEffective(index, data) { handleEffective(index, data) {
this.$confirm(this.$t('publish.wellPutawayPaper'), this.$t('global.tips'), { this.$confirm(this.$t('publish.wellPutawayPaper'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'), confirmButtonText: this.$t('global.confirm'),