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

281 lines
7.8 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
2019-08-19 18:42:53 +08:00
<div>
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
<qr-code ref="qrCode" />
<qcode ref="qcode" />
2019-08-19 18:42:53 +08:00
</div>
2019-07-26 13:32:43 +08:00
</template>
<script>
import { admin } from '@/router';
2019-08-19 18:42:53 +08:00
import { listPackagePermission, restorePackagePermission, getPackageQrCode, permissionDistributeUnPackage } from '@/api/management/distribute';
import { UrlConfig } from '@/router/index';
import QrCode from '@/components/QrCode';
import Qcode from './Qcode';
2019-07-26 13:32:43 +08:00
2019-08-19 18:42:53 +08:00
export default {
name: 'Author',
components: {
QrCode,
Qcode
2019-08-19 18:42:53 +08:00
},
data() {
return {
EffectiveTypeList: [],
PermissionTypeList: [],
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
queryForm: {
labelWidth: '140px',
2019-08-19 18:42:53 +08:00
reset: true,
queryObject: {
// 'userMobile': {
// type: 'text',
// label: this.$t('orderAuthor.founderPhone')
// },
2019-08-19 18:42:53 +08:00
'userName': {
type: 'text',
label: this.$t('orderAuthor.founder')
},
// 'permissionType': {
// type: 'select',
// label: this.$t('orderAuthor.permissionType'),
// config: {
// data: []
// }
// },
2019-08-19 18:42:53 +08:00
'status': {
type: 'select',
label: '状态',
2019-08-19 18:42:53 +08:00
value: '1',
config: {
data: []
}
}
}
},
queryList: {
query: this.queryFunction,
selectCheckShow: false,
indexShow: true,
columns: [
{
title: this.$t('orderAuthor.organizationOrEnterprise'),
prop: 'organizationName'
},
{
2019-09-11 09:34:12 +08:00
title: this.$t('orderAuthor.permissionName'),
prop: 'permissionName'
},
2019-08-19 18:42:53 +08:00
{
title: this.$t('orderAuthor.founder'),
prop: 'userName'
},
// {
// title: this.$t('orderAuthor.founderPhone'),
// prop: 'userMobile'
// },
// {
// title: this.$t('orderAuthor.mapName'),
// prop: 'mapName'
// },
// {
// title: this.$t('orderAuthor.mapProductName'),
// prop: 'mapProductName'
// },
// {
// title: this.$t('orderAuthor.courseName'),
// prop: 'lessonName'
// },
// {
// title: this.$t('orderAuthor.permissionType'),
// prop: 'permissionType',
// type: 'tag',
// columnValue: (row) => { return this.$convertField(row.permissionType, this.PermissionTypeList, ['value', 'label']); },
// tagType: (row) => { return ''; }
// },
2019-08-19 18:42:53 +08:00
{
title: this.$t('orderAuthor.publicOrPrivate'),
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 'warning';
2019-08-19 18:42:53 +08:00
}
}
},
{
title: this.$t('orderAuthor.permanenceOrNot'),
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 'warning';
2019-08-19 18:42:53 +08:00
}
}
},
{
title: '总数量',
prop: 'amount'
},
{
title: '剩余数量',
prop: 'remains'
},
2019-08-19 18:42:53 +08:00
{
title: this.$t('orderAuthor.startTime'),
prop: 'startTime',
type: 'formatter',
formatter: this.formatterDate
2019-07-26 13:32:43 +08:00
2019-08-19 18:42:53 +08:00
},
{
title: this.$t('orderAuthor.endTime'),
prop: 'endTime',
type: 'formatter',
formatter: this.formatterDate
},
{
title: '状态',
2019-08-19 18:42:53 +08:00
prop: 'status',
type: 'tag',
columnValue: (row) => { return this.$convertField(row.status, this.EffectiveTypeList, ['value', 'label']); },
tagType: (row) => {
switch (row.status) {
case '1': return 'success';
default: return 'danger';
}
}
},
{
type: 'button',
title: this.$t('global.operate'),
width: this.$i18n.locale == 'en' ? '400': '300',
hide: (row) => { return this.$store.state.user.roles.indexOf(admin) < 0; },
2019-08-19 18:42:53 +08:00
buttons: [
{
name: this.$t('orderAuthor.obtainQrCode'),
handleClick: this.handleRtCodeShow,
type: '',
showControl: (row) => { return row.status == '1'; }
2019-08-19 18:42:53 +08:00
},
{
name: this.$t('orderAuthor.authorityDetails'),
handleClick: this.handlePermissionDetail,
type: '',
showControl: (row) => { return row.status == '1' && (row.source == '02' || row.source == '04'); }
},
{
name: this.$t('orderAuthor.recovery'),
handleClick: this.handleRestore,
type: 'danger',
showControl: (row) => { return row.status == '1' && row.source == '04'; }
},
{
name: this.$t('orderAuthor.unpacking'),
handleClick: this.handleUnPackage,
type: 'danger',
showControl: (row) => { return row.status == '1' && row.source == '02'; }
}
]
}
],
actions: [
{ text: this.$t('orderAuthor.privilegePackaging'), btnCode: 'employee_insert', handler: this.handlePackage },
{ text: '领取权限', handler: this.handlerPermission, show: process.env.NODE_ENV == 'development' }
2019-08-19 18:42:53 +08:00
]
}
};
},
2019-07-26 13:32:43 +08:00
2019-08-19 18:42:53 +08:00
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 });
});
this.$convertList(list, this.EffectiveTypeList, elem => {
return true;
});
});
// this.$Dictionary.permissionType().then(list => {
// list.forEach(elem => {
// this.queryForm.queryObject.permissionType.config.data.push({ value: elem.code, label: elem.name });
// });
// this.$convertList(list, this.PermissionTypeList, elem => {
// return true;
// });
// this.PermissionTypeList.push({ value: undefined, label: this.$t('orderAuthor.permissionPack') });
// });
2019-08-19 18:42:53 +08:00
},
formatterDate(row, porpInfo) {
return row[porpInfo.property] ? row[porpInfo.property] : '---';
2019-08-19 18:42:53 +08:00
},
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: this.$t('orderAuthor.privilegeTransferQRCode')
});
}).catch(() => {
this.$messageBox(this.$t('tip.getQRCodeFailure'));
});
},
handleRestore(index, row) {
this.$confirm(this.$t('tip.recoveryPrivilegeTip'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
restorePackagePermission(row.id).then(resp => {
this.reloadTable();
this.$message.success(this.$t('tip.recoveryPrivilegesSuccessful'));
}).catch(() => {
this.$messageBox(this.$t('tip.recoveryPrivilegesFailed'));
});
}).catch(() => { });
},
handleUnPackage(index, row) {
this.$confirm(this.$t('tip.unpackingTip'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
permissionDistributeUnPackage(row.id).then(resp => {
this.reloadTable();
this.$message.success(this.$t('tip.unpackingSuccessful'));
}).catch(() => {
this.$messageBox(this.$t('tip.unpackingFailed'));
});
}).catch(() => { });
},
handlePackage() {
this.$router.push({ path: `${UrlConfig.orderauthor.trainferPackage}` });
},
handlerPermission() {
this.$refs.qcode.doShow();
2019-08-19 18:42:53 +08:00
}
}
};
2019-08-12 18:54:32 +08:00
</script>