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

223 lines
8.6 KiB
Vue
Raw Normal View History

2019-08-29 09:31:58 +08:00
<template>
<div>
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
<detail ref="detail" :permission-type-list="PermissionTypeList" />
2019-08-29 09:31:58 +08:00
</div>
</template>
<script>
import { listPermision, setLessonPermisson } from '@/api/management/author';
import Detail from './detail';
2019-08-29 09:31:58 +08:00
export default {
name: 'Author',
components: {
Detail
},
data() {
return {
PermissionTypeList: [],
EffectiveTypeList: [],
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
queryForm: {
labelWidth: '120px',
reset: true,
queryObject: {
permissionType: {
type: 'select',
label: this.$t('permission.permissionType'),
config: {
data: []
}
},
status: {
type: 'select',
label: this.$t('permission.statusType'),
config: {
data: []
}
},
canDistribute: {
type: 'select',
label: this.$t('permission.permissionUseType'),
config: {
data: [
{ value: false, label: this.$t('permission.private')},
{ value: true, label: this.$t('permission.public')}
]
}
}
}
},
queryList: {
query: this.queryFunction,
selectCheckShow: false,
indexShow: true,
columns: [
{
title: this.$t('permission.userName'),
prop: 'userName'
},
{
title: this.$t('permission.permissionName'),
width: '260',
prop: 'permissionName'
},
{
title: this.$t('permission.permissionType'),
prop: 'permissionType',
type: 'tag',
columnValue: (row) => { return this.$convertField(row.permissionType, this.PermissionTypeList, ['value', 'label']); },
tagType: (row) => { return ''; }
},
{
title: this.$t('permission.permissionUseType'),
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';
}
}
},
{
title: this.$t('permission.isForever'),
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';
}
}
},
{
title: this.$t('permission.permissionTotal'),
prop: 'amount'
},
{
title: this.$t('permission.permissionRemains'),
prop: 'remains'
},
{
title: this.$t('permission.startTime'),
prop: 'startTime',
type: 'formatter',
formatter: this.formatterDate
2019-08-29 09:31:58 +08:00
},
{
title: this.$t('permission.endTime'),
prop: 'endTime',
type: 'formatter',
formatter: this.formatterDate
},
{
title: this.$t('permission.permissionStatus'),
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: '200',
buttons: [
{
name: this.$t('orderAuthor.setupFailure'),
handleClick: this.handleEfficacy,
type: 'warning',
showControl: (row) => {
return row.status == '1';
}
},
// {
// name: this.$t('orderAuthor.setupEffective'),
// type: 'primary',
// handleClick: this.handleEfficacy,
// showControl: (row) => {
// return row.status == '0';
// }
// },
{
name: this.$t('global.details'),
handleClick: this.handleRoleVest,
type: '',
showControl: (row) => { return !row.permissionType; }
}
]
}
],
actions: [
]
}
};
},
mounted() {
this.loadInitData();
},
methods: {
handleRoleVest(index, row) {
this.$refs.detail.doShow(row.permissionId);
},
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;
});
});
2019-08-29 09:31:58 +08:00
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;
});
});
},
formatterDate(row, porpInfo) {
return row[porpInfo.property] ? row[porpInfo.property] : '---';
},
queryFunction(params) {
return listPermision(params);
},
reloadTable() {
if (this.queryList && this.queryList.reload) {
this.queryList.reload();
}
},
handleEfficacy(index, row) {
this.$confirm(this.$t('tip.modifyTheUserPermissionStatus'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
setLessonPermisson({id: row.id }).then(res => {
this.$message.success(this.$t('tip.operationSuccessfully'));
this.reloadTable();
}).catch(() => {
this.$messageBox(this.$t('tip.operationFailed'));
this.reloadTable();
});
}).catch(() => { });
}
}
2019-08-29 09:31:58 +08:00
};
</script>