rt-sim-training-client/src/views/orderauthor/permission/index.vue

264 lines
11 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
<div>
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList">
</QueryListPage>
<qr-code ref="qrCode"></qr-code>
</div>
</template>
<script>
import { superAdmin } from '@/router';
import { listPackagePermission, restorePackagePermission, getPackageQrCode, permissionDistributeUnPackage } from '@/api/management/distribute';
import { UrlConfig } from '@/router/index';
import QrCode from "@/components/QrCode";
export default {
name: 'author',
components: {
QrCode
},
data() {
return {
EffectiveTypeList: [],
PermissionTypeList: [],
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
queryForm: {
labelWidth: '120px',
reset: true,
queryObject: {
'userMobile': {
type: 'text',
label: '创建人手机号'
},
'userName': {
type: 'text',
label: '创建人员'
},
'permissionType': {
type: 'select',
label: '权限类型',
config: {
data: []
}
},
'status': {
type: 'select',
label: '权限状态',
value: '1',
config: {
data: []
}
}
}
},
queryList: {
query: this.queryFunction,
selectCheckShow: false,
indexShow: true,
columns: [
{
title: '组织机构/企业',
prop: 'organizationName'
},
{
title: '创建人员',
prop: 'userName'
},
{
title: '创建人手机号',
prop: 'userMobile'
},
{
title: '地图名称',
prop: 'mapName',
},
{
title: '地图产品名称',
prop: 'mapProductName',
},
{
title: '课程名称',
prop: 'lessonName',
},
{
title: '权限类型',
prop: 'permissionType',
type: 'tag',
2019-08-08 15:57:36 +08:00
columnValue: (row) => { return this.$convertField(row.permissionType, this.PermissionTypeList, ['value', 'label']) },
2019-07-26 13:32:43 +08:00
tagType: (row) => { return '' }
},
{
title: '公用/专用',
prop: 'canDistribute',
type: 'tag',
columnValue: (row) => { return this.$ConstSelect.translate(row.canDistribute, 'PermissionUseList') },
tagType: (row) => {
switch (row.canDistribute) {
case true: return 'success';
case false: return 'danger';
}
}
},
{
title: '是否永久',
prop: 'forever',
type: 'tag',
columnValue: (row) => { return this.$ConstSelect.translate(row.forever, 'Whether') },
tagType: (row) => {
switch (row.forever) {
case true: return 'success';
case false: return 'danger';
}
}
},
{
title: '开始时间',
prop: 'startTime',
type: 'formatter',
formatter: this.formatterDate
},
{
title: '结束时间',
prop: 'endTime',
type: 'formatter',
formatter: this.formatterDate
},
{
title: '权限状态',
prop: 'status',
type: 'tag',
2019-08-08 15:57:36 +08:00
columnValue: (row) => { return this.$convertField(row.status, this.EffectiveTypeList, ['value', 'label']) },
2019-07-26 13:32:43 +08:00
tagType: (row) => {
switch (row.status) {
case '1': return 'success';
default: return 'danger';
}
}
},
{
type: 'button',
title: '操作',
width: '300',
hide: (row) => { return this.$store.state.user.roles.indexOf(superAdmin) < 0; },
buttons: [
{
name: '获取二维码',
handleClick: this.handleRtCodeShow,
type: '',
showControl: (row) => { return true }
},
{
name: '权限详情',
handleClick: this.handlePermissionDetail,
type: '',
showControl: (row) => { return row.status == '1' && (row.source == '02' || row.source == '04') }
},
{
name: '回收',
handleClick: this.handleRestore,
type: 'danger',
showControl: (row) => { return row.status == '1' && row.source == '04' }
},
{
name: '解包',
handleClick: this.handleUnPackage,
type: 'danger',
showControl: (row) => { return row.status == '1' && row.source == '02' }
}
]
}
],
actions: [
{ text: '权限打包', btnCode: 'employee_insert', handler: this.handlePackage },
]
}
}
},
mounted() {
this.loadInitData();
},
methods: {
loadInitData() {
this.$Dictionary.effectiveType().then(list => {
list.forEach(elem => {
this.queryForm.queryObject.status.config.data.push({ value: elem.code, label: elem.name });
})
2019-08-08 15:57:36 +08:00
this.$convertList(list, this.EffectiveTypeList, elem => {
2019-07-26 13:32:43 +08:00
return true;
});
});
this.$Dictionary.permissionType().then(list => {
list.forEach(elem => {
this.queryForm.queryObject.permissionType.config.data.push({ value: elem.code, label: elem.name });
});
2019-08-08 15:57:36 +08:00
this.$convertList(list, this.PermissionTypeList, elem => {
2019-07-26 13:32:43 +08:00
return true;
});
this.PermissionTypeList.push({ value: undefined, label: '权限包' });
});
},
formatterDate(row, porpInfo) {
if (row.hasOwnProperty(porpInfo.property)) {
}
return row[porpInfo.property];
},
queryFunction(params) {
return listPackagePermission(params);
},
reloadTable() {
if (this.queryList && this.queryList.reload) {
this.queryList.reload()
}
},
handlePermissionDetail(index, row) {
this.$router.push({ path: `${UrlConfig.orderauthor.transferDetail}/${row.id}` })
},
handleRtCodeShow(index, row) {
getPackageQrCode({ id: row.id }).then(resp => {
this.$refs.qrCode.doShow({
url: resp.data,
title: '权限转赠二维码'
});
}).catch(error => {
this.$messageBox('获取打包权限二维码失败');
})
},
handleRestore(index, row) {
this.$confirm('此操作将回收权限, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
restorePackagePermission(row.id).then(resp => {
this.reloadTable();
this.$message.success('回收权限成功!');
}).catch(error => {
this.$messageBox('回收权限失败');
})
}).catch(() => { });
},
handleUnPackage(index, row) {
this.$confirm('此操作将解包, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
permissionDistributeUnPackage(row.id).then(resp => {
this.reloadTable();
this.$message.success('解包成功!');
}).catch(error => {
this.$messageBox('解包失败');
})
}).catch(() => { });
},
handlePackage() {
this.$router.push({ path: `${UrlConfig.orderauthor.trainferPackage}` })
}
}
}
</script>