权限分发接口调整
This commit is contained in:
parent
7921c9fde4
commit
1a13c9ad2c
@ -2,140 +2,159 @@ import request from '@/utils/request';
|
||||
|
||||
/** 权限转增*/
|
||||
export function getLessons(data) {
|
||||
return request({
|
||||
url: '/api/distribute/getLessons',
|
||||
method: 'get',
|
||||
data: data
|
||||
});
|
||||
return request({
|
||||
url: '/api/distribute/getLessons',
|
||||
method: 'get',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
/** 权限分发*/
|
||||
export function giveLessons(data) {
|
||||
return request({
|
||||
url: '/api/distribute/distribute',
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
return request({
|
||||
url: '/api/distribute/distribute',
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
/** 权限转增*/
|
||||
export function permissionTurnAdd(data) {
|
||||
return request({
|
||||
url: '/api/distribute/transfer',
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
return request({
|
||||
url: '/api/distribute/transfer',
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
/** 从订单分发权限(获取二维码)*/
|
||||
export function postDistribute(data) {
|
||||
return request({
|
||||
url: `/api/distribute/${data.code}/distribute`,
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
return request({
|
||||
url: `/api/distribute/${data.code}/distribute`,
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
/** 权限获取*/
|
||||
export function getPermission(state) {
|
||||
return request({
|
||||
url: `/api/distribute/getPermission?state=${state}`,
|
||||
method: 'get'
|
||||
});
|
||||
return request({
|
||||
url: `/api/distribute/getPermission?state=${state}`,
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
/** 接收课程权限*/
|
||||
export function receiveLessons(data) {
|
||||
return request({
|
||||
url: '/api/distribute/receiveLessons',
|
||||
method: 'get',
|
||||
data: data
|
||||
});
|
||||
return request({
|
||||
url: '/api/distribute/receiveLessons',
|
||||
method: 'get',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
/** 考试权限分发*/
|
||||
export function giveExams(data) {
|
||||
return request({
|
||||
url: `/api/distribute/giveExams`,
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
return request({
|
||||
url: `/api/distribute/giveExams`,
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
/** 权限打包分页查询*/
|
||||
export function listPackagePermission(params) {
|
||||
return request({
|
||||
url: '/api/distribute',
|
||||
method: 'get',
|
||||
params: params
|
||||
});
|
||||
return request({
|
||||
url: '/api/distribute',
|
||||
method: 'get',
|
||||
params: params
|
||||
});
|
||||
}
|
||||
|
||||
/** 打包权限*/
|
||||
export function packagePermissionDistribute(data) {
|
||||
return request({
|
||||
url: `/api/distribute/givePermission/package`,
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
return request({
|
||||
url: `/api/distribute/givePermission/package`,
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
/** 权限回收*/
|
||||
export function restorePackagePermission(id) {
|
||||
return request({
|
||||
url: `/api/distribute/${id}/restore`,
|
||||
method: 'put'
|
||||
});
|
||||
return request({
|
||||
url: `/api/distribute/${id}/restore`,
|
||||
method: 'put'
|
||||
});
|
||||
}
|
||||
|
||||
/** 生成打包权限二维码*/
|
||||
export function getPackageQrCode(params) {
|
||||
return request({
|
||||
url: `/api/distribute/package/qrCode`,
|
||||
method: 'get',
|
||||
params: params
|
||||
});
|
||||
return request({
|
||||
url: `/api/distribute/package/qrCode`,
|
||||
method: 'get',
|
||||
params: params
|
||||
});
|
||||
}
|
||||
|
||||
/** 权限分发打包详情*/
|
||||
export function getPermissionPackageDetail(id, params) {
|
||||
return request({
|
||||
url: `/api/distribute/package/${id}/detail`,
|
||||
method: 'get',
|
||||
params: params
|
||||
});
|
||||
return request({
|
||||
url: `/api/distribute/package/${id}/detail`,
|
||||
method: 'get',
|
||||
params: params
|
||||
});
|
||||
}
|
||||
|
||||
/** 权限分发打包*/
|
||||
export function permissionDistributePackage(data) {
|
||||
return request({
|
||||
url: `/api/distribute/package`,
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
return request({
|
||||
url: `/api/distribute/package`,
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
/** 权限分发解包*/
|
||||
export function permissionDistributeUnPackage(permissionId) {
|
||||
return request({
|
||||
url: `/api/distribute/${permissionId}/unPackage`,
|
||||
method: 'delete'
|
||||
});
|
||||
return request({
|
||||
url: `/api/distribute/${permissionId}/unPackage`,
|
||||
method: 'delete'
|
||||
});
|
||||
}
|
||||
|
||||
/** 查询可打包的权限分发*/
|
||||
export function listCanPackagePermission(params) {
|
||||
return request({
|
||||
url: `/api/distribute/package`,
|
||||
method: 'get',
|
||||
params: params
|
||||
});
|
||||
return request({
|
||||
url: `/api/distribute/package`,
|
||||
method: 'get',
|
||||
params: params
|
||||
});
|
||||
}
|
||||
|
||||
// 设置权限分发列表 权限失效
|
||||
export function setCommodityStatus(id) {
|
||||
return request({
|
||||
url: `/api/distribute/${id}/invalid`,
|
||||
method: 'get'
|
||||
});
|
||||
return request({
|
||||
url: `/api/distribute/${id}/invalid`,
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取用户可以分发/转增的权限*/
|
||||
export function getAvailableUserPermission(params) {
|
||||
return request({
|
||||
url: `/api/userPermission/getAvailableUserPermission`,
|
||||
method: 'get',
|
||||
params: params
|
||||
});
|
||||
}
|
||||
|
||||
/** 用户权限转增分发打包生成权限*/
|
||||
export function givePermission(data) {
|
||||
return request({
|
||||
url: `/api/distribute/packageUserPermission`,
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -196,5 +196,6 @@ export default {
|
||||
america: 'America',
|
||||
companyInfo:'Beijing Jiulian Technology Co., Ltd',
|
||||
companyTel:'Tel: +86 13289398171',
|
||||
companyICP:'Copyright ©2018 Beijing Jiulian Technology Co., Ltd ICP: 18028522'
|
||||
companyICP:'Copyright ©2018 Beijing Jiulian Technology Co., Ltd ICP: 18028522',
|
||||
enterPermissionNum:'please input permission number'
|
||||
};
|
||||
|
@ -196,5 +196,6 @@ export default {
|
||||
america: '美国',
|
||||
companyInfo:'北京玖琏科技有限公司',
|
||||
companyTel:'联系电话: 13289398171',
|
||||
companyICP:'Copyright ©2018 北京玖琏科技有限公司 京ICP备18028522号'
|
||||
companyICP:'Copyright ©2018 北京玖琏科技有限公司 京ICP备18028522号',
|
||||
enterPermissionNum:'请输入权限数量'
|
||||
};
|
||||
|
@ -1,6 +1,61 @@
|
||||
<template>
|
||||
<el-dialog v-dialogDrag :title="title" :visible.sync="dialogVisible" width="35%" :before-close="handleClose" center>
|
||||
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
|
||||
<el-dialog v-dialogDrag :title="title" :visible.sync="dialogVisible" width="600px" :before-close="handleClose" center>
|
||||
<div>
|
||||
<el-form ref="distributeForm" :rules="rules" :model="formModel">
|
||||
<el-form-item key="date" prop="date" :label="this.$t('global.selectionTime')" :required="false" label-width="100px">
|
||||
<el-date-picker
|
||||
v-model="formModel.date"
|
||||
align="right"
|
||||
type="datetimerange"
|
||||
format="yyyy-MM-dd HH:mm:ss"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
@change="changeSelectDate"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-table
|
||||
v-if="isShowPermission()"
|
||||
:data="formModel.permissionList"
|
||||
border
|
||||
stripe
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table-column
|
||||
prop="permissionName"
|
||||
label="权限名称"
|
||||
align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="amount"
|
||||
label="权限总数"
|
||||
align="center"
|
||||
width="80"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="remains"
|
||||
label="剩余权限"
|
||||
align="center"
|
||||
width="80"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="isPackage"
|
||||
label="是否万能"
|
||||
align="center"
|
||||
width="80"
|
||||
/>
|
||||
<el-table-column
|
||||
label="分发权限数量"
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<!-- :label="$t('global.permissionList')" -->
|
||||
<el-form-item key="permissionList" :prop="'permissionList.' + scope.$index + '.chooseNumber'" :required="false" :rules="rules.chooseNumber">
|
||||
<el-input-number v-model="scope.row.chooseNumber" size="mini" :max="scope.row.remains" :min="0" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form>
|
||||
</div>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="handleSure">{{ $t('global.confirm') }}</el-button>
|
||||
<el-button @click="close">{{ $t('global.cancel') }}</el-button>
|
||||
@ -9,194 +64,195 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getTotalRemains } from '@/api/management/author';
|
||||
// import { getTotalRemains } from '@/api/management/author';
|
||||
import { PermissionType } from '@/scripts/ConstDic';
|
||||
import { giveLessons } from '@/api/management/distribute';
|
||||
import { getAvailableUserPermission, givePermission } from '@/api/management/distribute';
|
||||
|
||||
export default {
|
||||
name: 'GiveLesson',
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
maxTotal: 0,
|
||||
formModel: {
|
||||
lessonId: '',
|
||||
lessonName: '',
|
||||
total: 0,
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
date: ''
|
||||
},
|
||||
prdCode: '',
|
||||
mapId: '',
|
||||
TimePicker: { start: '08:30', step: '00:15', end: '18:30' },
|
||||
numberMessage: '',
|
||||
PermissionType: ''
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
form() {
|
||||
const form = {
|
||||
labelWidth: '100px',
|
||||
items: [
|
||||
{ prop: 'lessonName', label: this.$t('global.name'), type: 'text', required: false, readonly: true },
|
||||
{ prop: 'date', label: this.$t('global.selectionTime'), type: 'datetimerange', required: false, viewFormat: 'yyyy-MM-dd HH:mm:ss', valueFormat: 'yyyy-MM-dd HH:mm:ss' },
|
||||
{ prop: 'total', label: this.$t('global.permissionNumber'), type: 'number', required: false, min: 0, max: this.maxTotal, message: this.numberMessage }
|
||||
]
|
||||
};
|
||||
return form;
|
||||
},
|
||||
rules() {
|
||||
const that = this;
|
||||
const crules = {
|
||||
total: [
|
||||
{ required: true, message: this.$t('global.pleaseInputPermissionNumber'), trigger: 'change' },
|
||||
{
|
||||
validator(rule, value, callback) {
|
||||
if (Number.isInteger(Number(value)) && Number(value) > 0) {
|
||||
callback();
|
||||
} else {
|
||||
callback(new Error(that.$t('global.permissionGreaterThen0')));
|
||||
}
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
startTime: [
|
||||
{ required: true, message: this.$t('global.enterStartTime'), trigger: 'change' }
|
||||
],
|
||||
endTime: [
|
||||
{ required: true, message: this.$t('global.enterEndTime'), trigger: 'change' }
|
||||
],
|
||||
date: [
|
||||
{ required: true, message: this.$t('global.enterDate'), trigger: 'blur' }
|
||||
]
|
||||
};
|
||||
return crules;
|
||||
},
|
||||
title() {
|
||||
if (this.PermissionType == PermissionType.LESSON) {
|
||||
return this.$t('global.distributeLessonPermission');
|
||||
} else if (this.PermissionType == PermissionType.EXAM) {
|
||||
return this.$t('global.distributeExamPermission');
|
||||
} else if (this.PermissionType == PermissionType.SIMULATION) {
|
||||
return this.$t('global.distributeSimulationPermission');
|
||||
} else if (this.PermissionType == PermissionType.SCREEN) {
|
||||
return this.$t('global.distributeScreenPermission');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'formModel.date': function (val, old) {
|
||||
this.setTotalMax();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setTotalMax() {
|
||||
let endTime;
|
||||
let startTime;
|
||||
if (this.formModel.date) {
|
||||
endTime = this.formModel.date[1];
|
||||
startTime = this.formModel.date[0];
|
||||
}
|
||||
this.maxTotal = 0;
|
||||
if (endTime && startTime) {
|
||||
if (endTime > startTime) {
|
||||
const model = {
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
permissionType: this.PermissionType
|
||||
};
|
||||
if (this.PermissionType == PermissionType.LESSON || this.PermissionType == PermissionType.EXAM) {
|
||||
model['lessonId'] = this.formModel.lessonId;
|
||||
model['mapId'] = this.mapId;
|
||||
model['prdCode'] = this.prdCode;
|
||||
} else if (this.PermissionType == PermissionType.SIMULATION) {
|
||||
model['mapId'] = this.mapId;
|
||||
model['prdCode'] = this.prdCode;
|
||||
}
|
||||
// 获取用户某课程某段时间内可用的权限数量
|
||||
getTotalRemains(model).then(response => {
|
||||
this.maxTotal = response.data;
|
||||
if (this.maxTotal == 0) {
|
||||
this.numberMessage = '可用权限数量为0';
|
||||
} else {
|
||||
this.numberMessage = `(${this.$t('global.remainPermissionNumber')}:${this.maxTotal})`;
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$messageBox(this.$t('error.obtainMaxNumberFailed'));
|
||||
});
|
||||
} else {
|
||||
this.numberMessage = '结束时间必须大于开始时间';
|
||||
}
|
||||
} else {
|
||||
this.numberMessage = '';
|
||||
}
|
||||
},
|
||||
doShow(data) {
|
||||
this.dialogVisible = true;
|
||||
if (data) {
|
||||
this.formModel.lessonId = data.id;
|
||||
this.formModel.lessonName = data.name;
|
||||
this.prdCode = data.prdCode;
|
||||
this.mapId = data.mapId;
|
||||
this.PermissionType = data.PermissionType;
|
||||
this.setTotalMax();
|
||||
}
|
||||
},
|
||||
handleSure() {
|
||||
this.$refs.dataform.validateForm(() => {
|
||||
const model = {
|
||||
startTime: this.formModel.date[0],
|
||||
endTime: this.formModel.date[1],
|
||||
permissionType: this.PermissionType,
|
||||
amount: this.formModel.total
|
||||
};
|
||||
if (this.PermissionType == PermissionType.LESSON || this.PermissionType == PermissionType.EXAM) {
|
||||
model['lessonId'] = this.formModel.lessonId;
|
||||
model['mapId'] = this.mapId;
|
||||
model['prdCode'] = this.prdCode;
|
||||
} else if (this.PermissionType == PermissionType.SIMULATION) {
|
||||
model['mapId'] = this.mapId;
|
||||
model['prdCode'] = this.prdCode;
|
||||
}
|
||||
// 权限分发请求
|
||||
giveLessons(model).then(response => {
|
||||
const url = response.data;
|
||||
this.$emit('QrCodeShow', {
|
||||
url: url,
|
||||
title: this.$t('global.distributeQrcode')
|
||||
});
|
||||
this.dialogVisible = false;
|
||||
this.$emit('initLoadPage');
|
||||
this.handleClose();
|
||||
}).catch(() => {
|
||||
this.$messageBox(this.$t('error.getDistributeQrcodeFailed'));
|
||||
});
|
||||
});
|
||||
},
|
||||
close() {
|
||||
this.dialogVisible = false;
|
||||
this.handleClose();
|
||||
},
|
||||
handleClose(done) {
|
||||
this.maxTotal = 0;
|
||||
this.formModel = {
|
||||
lessonId: '',
|
||||
lessonName: '',
|
||||
total: 0,
|
||||
startTime: '',
|
||||
endTime: ''
|
||||
};
|
||||
this.$refs.dataform.resetForm();
|
||||
if (done) {
|
||||
done();
|
||||
} else {
|
||||
this.dialogVisible = false;
|
||||
}
|
||||
name: 'GiveLesson',
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
maxTotal: 0,
|
||||
formModel: {
|
||||
lessonId: '',
|
||||
lessonName: '',
|
||||
permissionList:[],
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
date: ''
|
||||
},
|
||||
prdCode: '',
|
||||
mapId: '',
|
||||
numberMessage: '',
|
||||
PermissionType: ''
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
rules() {
|
||||
const crules = {
|
||||
startTime: [
|
||||
{ required: true, message: this.$t('global.enterStartTime'), trigger: 'change' }
|
||||
],
|
||||
endTime: [
|
||||
{ required: true, message: this.$t('global.enterEndTime'), trigger: 'change' }
|
||||
],
|
||||
date: [
|
||||
{ required: true, message: this.$t('global.enterDate'), trigger: 'blur' }
|
||||
],
|
||||
chooseNumber:[
|
||||
{ required: true, message: this.$t('global.enterPermissionNum'), trigger: 'blur'}
|
||||
]
|
||||
};
|
||||
return crules;
|
||||
},
|
||||
title() {
|
||||
if (this.PermissionType == PermissionType.LESSON) {
|
||||
return this.$t('global.distributeLessonPermission');
|
||||
} else if (this.PermissionType == PermissionType.EXAM) {
|
||||
return this.$t('global.distributeExamPermission');
|
||||
} else if (this.PermissionType == PermissionType.SIMULATION) {
|
||||
return this.$t('global.distributeSimulationPermission');
|
||||
} else if (this.PermissionType == PermissionType.SCREEN) {
|
||||
return this.$t('global.distributeScreenPermission');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'formModel.date': function (val, old) {
|
||||
this.setTotalMax();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setTotalMax() {
|
||||
let endTime;
|
||||
let startTime;
|
||||
if (this.formModel.date) {
|
||||
endTime = this.formModel.date[1];
|
||||
startTime = this.formModel.date[0];
|
||||
}
|
||||
// this.maxTotal = 0;
|
||||
if (endTime && startTime) {
|
||||
if (endTime > startTime) {
|
||||
// const model = {
|
||||
// startTime: startTime,
|
||||
// endTime: endTime,
|
||||
// permissionType: this.PermissionType
|
||||
// };
|
||||
// if (this.PermissionType == PermissionType.LESSON || this.PermissionType == PermissionType.EXAM) {
|
||||
// model['lessonId'] = this.formModel.lessonId;
|
||||
// model['mapId'] = this.mapId;
|
||||
// model['prdCode'] = this.prdCode;
|
||||
// } else if (this.PermissionType == PermissionType.SIMULATION) {
|
||||
// model['mapId'] = this.mapId;
|
||||
// model['prdCode'] = this.prdCode;
|
||||
// }
|
||||
// // 获取用户某课程某段时间内可用的权限数量
|
||||
// getTotalRemains(model).then(response => {
|
||||
// this.maxTotal = response.data;
|
||||
// if (this.maxTotal == 0) {
|
||||
// this.numberMessage = '可用权限数量为0';
|
||||
// } else {
|
||||
// this.numberMessage = `(${this.$t('global.remainPermissionNumber')}:${this.maxTotal})`;
|
||||
// }
|
||||
// }).catch(() => {
|
||||
// this.$messageBox(this.$t('error.obtainMaxNumberFailed'));
|
||||
// });
|
||||
} else {
|
||||
this.numberMessage = '结束时间必须大于开始时间';
|
||||
}
|
||||
} else {
|
||||
this.numberMessage = '';
|
||||
}
|
||||
},
|
||||
changeSelectDate() {
|
||||
const data = {mapId:this.mapId, prdCode:this.prdCode, startTime:this.formModel.date[0], endTime:this.formModel.date[1]};
|
||||
if (this.PermissionType == PermissionType.LESSON || this.PermissionType == PermissionType.EXAM) {
|
||||
data.lessonId = this.formModel.lessonId;
|
||||
data.type = this.PermissionType;
|
||||
}
|
||||
getAvailableUserPermission(data).then(res=>{
|
||||
if (res.data.length > 0) {
|
||||
this.formModel.permissionList = res.data;
|
||||
}
|
||||
}).catch(error=>{
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
isShowPermission() {
|
||||
return this.formModel.permissionList && this.formModel.permissionList.length > 0;
|
||||
},
|
||||
doShow(data) {
|
||||
this.dialogVisible = true;
|
||||
if (data) {
|
||||
this.formModel.lessonId = data.id;
|
||||
this.formModel.lessonName = data.name;
|
||||
this.prdCode = data.prdCode;
|
||||
this.mapId = data.mapId;
|
||||
this.PermissionType = data.PermissionType;
|
||||
this.setTotalMax();
|
||||
}
|
||||
},
|
||||
handleSure() {
|
||||
this.$refs['distributeForm'].validate((info) => {
|
||||
if (info) {
|
||||
const model = {
|
||||
startTime: this.formModel.date[0],
|
||||
endTime: this.formModel.date[1],
|
||||
userPermissionAndAmountVOList:[],
|
||||
packageOrGift: 1
|
||||
};
|
||||
this.formModel.permissionList.forEach(data=>{
|
||||
model.userPermissionAndAmountVOList.push({'userPermissionId':data.id, 'amount':data.chooseNumber});
|
||||
});
|
||||
// 权限分发请求
|
||||
givePermission(model).then(response => {
|
||||
debugger;
|
||||
const url = response.data;
|
||||
this.$emit('QrCodeShow', {
|
||||
url: url,
|
||||
title: this.$t('global.distributeQrcode')
|
||||
});
|
||||
this.dialogVisible = false;
|
||||
this.$emit('initLoadPage');
|
||||
this.handleClose();
|
||||
}).catch(() => {
|
||||
this.$messageBox(this.$t('error.getDistributeQrcodeFailed'));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// if (this.PermissionType == PermissionType.LESSON || this.PermissionType == PermissionType.EXAM) {
|
||||
// model['lessonId'] = this.formModel.lessonId;
|
||||
// model['mapId'] = this.mapId;
|
||||
// model['prdCode'] = this.prdCode;
|
||||
// } else if (this.PermissionType == PermissionType.SIMULATION) {
|
||||
// model['mapId'] = this.mapId;
|
||||
// model['prdCode'] = this.prdCode;
|
||||
// }
|
||||
});
|
||||
},
|
||||
close() {
|
||||
this.dialogVisible = false;
|
||||
this.handleClose();
|
||||
},
|
||||
handleClose(done) {
|
||||
this.formModel = {
|
||||
lessonId: '',
|
||||
lessonName: '',
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
date:'',
|
||||
permissionList:[]
|
||||
};
|
||||
this.$refs['distributeForm'].resetFields();
|
||||
if (done) {
|
||||
done();
|
||||
} else {
|
||||
this.dialogVisible = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -14,194 +14,194 @@ import { permissionTurnAdd } from '@/api/management/distribute';
|
||||
import { PermissionType } from '@/scripts/ConstDic';
|
||||
|
||||
export default {
|
||||
name: 'GoLsesson',
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
maxTotal: 0,
|
||||
formModel: {
|
||||
lessonId: '',
|
||||
lessonName: '',
|
||||
total: 0,
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
date: ''
|
||||
},
|
||||
prdCode: '',
|
||||
mapId: '',
|
||||
DatePicker: {
|
||||
shortcuts: [{
|
||||
text: this.$t('global.today'),
|
||||
onClick(picker) {
|
||||
picker.$emit('pick', new Date());
|
||||
}
|
||||
}]
|
||||
},
|
||||
numberMessage: '',
|
||||
PermissionType: ''
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
form() {
|
||||
const form = {
|
||||
labelWidth: '80px',
|
||||
items: [
|
||||
{ prop: 'lessonName', label: this.$t('global.name'), type: 'text', required: false, readonly: true },
|
||||
{ prop: 'date', label: this.$t('global.selectionTime'), type: 'daterange', required: false, viewFormat: 'yyyy-MM-dd', valueFormat: 'yyyy-MM-dd' },
|
||||
{ prop: 'total', label: this.$t('global.permissionNumber'), type: 'number', required: false, min: 0, max: this.maxTotal, message: this.numberMessage }
|
||||
]
|
||||
};
|
||||
return form;
|
||||
},
|
||||
rules() {
|
||||
const that = this;
|
||||
const crules = {
|
||||
total: [
|
||||
{ required: true, message: this.$t('global.pleaseInputPermissionNumber'), trigger: 'change' },
|
||||
{
|
||||
validator(rule, value, callback) {
|
||||
if (Number.isInteger(Number(value)) && Number(value) > 0) {
|
||||
callback();
|
||||
} else {
|
||||
callback(new Error(that.$t('global.permissionGreaterThen0')));
|
||||
}
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
startTime: [
|
||||
{ required: true, message: this.$t('global.enterStartTime'), trigger: 'change' }
|
||||
],
|
||||
endTime: [
|
||||
{ required: true, message: this.$t('global.enterEndTime'), trigger: 'change' }
|
||||
],
|
||||
date: [
|
||||
{ required: true, message: this.$t('global.enterDate'), trigger: 'blur' }
|
||||
]
|
||||
};
|
||||
return crules;
|
||||
},
|
||||
title() {
|
||||
if (this.PermissionType == PermissionType.LESSON) {
|
||||
return this.$t('global.transferLessonPermission');
|
||||
} else if (this.PermissionType == PermissionType.EXAM) {
|
||||
return this.$t('global.transferExamPermission');
|
||||
} else if (this.PermissionType == PermissionType.SIMULATION) {
|
||||
return this.$t('global.transferSimulationPermission');
|
||||
} else if (this.PermissionType == PermissionType.SCREEN) {
|
||||
return this.$t('global.transferScreenPermission');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'formModel.date': function (val, old) {
|
||||
this.setTotalMax();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setTotalMax() {
|
||||
let endTime;
|
||||
let startTime;
|
||||
if (this.formModel.date) {
|
||||
endTime = this.formModel.date[1];
|
||||
startTime = this.formModel.date[0];
|
||||
}
|
||||
this.maxTotal = 0;
|
||||
if (endTime && startTime) {
|
||||
if (endTime > startTime) {
|
||||
const model = {
|
||||
startTime: `${startTime} 00:00:00`,
|
||||
endTime: `${endTime} 23:59:59`,
|
||||
permissionType: this.PermissionType
|
||||
};
|
||||
if (this.PermissionType == PermissionType.LESSON || this.PermissionType == PermissionType.EXAM) {
|
||||
model['lessonId'] = this.formModel.lessonId;
|
||||
model['mapId'] = this.mapId;
|
||||
model['prdCode'] = this.prdCode;
|
||||
} else if (this.PermissionType == PermissionType.SIMULATION) {
|
||||
model['mapId'] = this.mapId;
|
||||
model['prdCode'] = this.prdCode;
|
||||
}
|
||||
getTotalRemains(model).then(response => {
|
||||
this.maxTotal = response.data;
|
||||
if (this.maxTotal == 0) {
|
||||
this.numberMessage = this.$t('tip.theNumberOfPermissionsAvailableIsZero');
|
||||
} else {
|
||||
this.numberMessage = `(${this.$t('global.remainPermissionNumber')}:${this.maxTotal})`;
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$messageBox(this.$t('error.obtainMaxNumberFailed'));
|
||||
});
|
||||
} else {
|
||||
this.numberMessage = this.$t('tip.endTimeRules');
|
||||
}
|
||||
} else {
|
||||
this.numberMessage = '';
|
||||
}
|
||||
},
|
||||
doShow(data) {
|
||||
this.dialogVisible = true;
|
||||
if (data) {
|
||||
this.formModel.lessonId = data.id;
|
||||
this.formModel.lessonName = data.name;
|
||||
this.prdCode = data.prdCode;
|
||||
this.mapId = data.mapId;
|
||||
this.PermissionType = data.PermissionType;
|
||||
this.setTotalMax();
|
||||
}
|
||||
},
|
||||
handleSure() {
|
||||
this.$refs.dataform.validateForm(() => {
|
||||
const model = {
|
||||
startTime: `${this.formModel.date[0]} 00:00:00`,
|
||||
endTime: `${this.formModel.date[1]} 23:59:59`,
|
||||
amount: this.formModel.total,
|
||||
permissionType: this.PermissionType
|
||||
};
|
||||
if (this.PermissionType == PermissionType.LESSON || this.PermissionType == PermissionType.EXAM) {
|
||||
model['lessonId'] = this.formModel.lessonId;
|
||||
model['mapId'] = this.mapId;
|
||||
model['prdCode'] = this.prdCode;
|
||||
} else if (this.PermissionType == PermissionType.SIMULATION) {
|
||||
model['mapId'] = this.mapId;
|
||||
model['prdCode'] = this.prdCode;
|
||||
}
|
||||
// 转增
|
||||
permissionTurnAdd(model).then(response => {
|
||||
const url = response.data;
|
||||
this.$emit('QrCodeShow', {
|
||||
url: url,
|
||||
title: this.$t('global.transferQrcode')
|
||||
});
|
||||
this.dialogVisible = false;
|
||||
this.$emit('initLoadPage');
|
||||
this.handleClose();
|
||||
}).catch(() => {
|
||||
this.$messageBox(this.$t('error.getTransferQrcodeFailed'));
|
||||
});
|
||||
});
|
||||
},
|
||||
close() {
|
||||
this.dialogVisible = false;
|
||||
this.handleClose();
|
||||
},
|
||||
handleClose(done) {
|
||||
this.maxTotal = 0;
|
||||
this.formModel = {
|
||||
lessonId: '',
|
||||
lessonName: '',
|
||||
total: 0,
|
||||
startTime: '',
|
||||
endTime: ''
|
||||
};
|
||||
this.$refs.dataform.resetForm();
|
||||
if (done) {
|
||||
done();
|
||||
} else {
|
||||
this.dialogVisible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
name: 'GoLsesson',
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
maxTotal: 0,
|
||||
formModel: {
|
||||
lessonId: '',
|
||||
lessonName: '',
|
||||
total: 0,
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
date: ''
|
||||
},
|
||||
prdCode: '',
|
||||
mapId: '',
|
||||
DatePicker: {
|
||||
shortcuts: [{
|
||||
text: this.$t('global.today'),
|
||||
onClick(picker) {
|
||||
picker.$emit('pick', new Date());
|
||||
}
|
||||
}]
|
||||
},
|
||||
numberMessage: '',
|
||||
PermissionType: ''
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
form() {
|
||||
const form = {
|
||||
labelWidth: '80px',
|
||||
items: [
|
||||
{ prop: 'lessonName', label: this.$t('global.name'), type: 'text', required: false, readonly: true },
|
||||
{ prop: 'date', label: this.$t('global.selectionTime'), type: 'daterange', required: false, viewFormat: 'yyyy-MM-dd', valueFormat: 'yyyy-MM-dd' },
|
||||
{ prop: 'total', label: this.$t('global.permissionNumber'), type: 'number', required: false, min: 0, max: this.maxTotal, message: this.numberMessage }
|
||||
]
|
||||
};
|
||||
return form;
|
||||
},
|
||||
rules() {
|
||||
const that = this;
|
||||
const crules = {
|
||||
total: [
|
||||
{ required: true, message: this.$t('global.pleaseInputPermissionNumber'), trigger: 'change' },
|
||||
{
|
||||
validator(rule, value, callback) {
|
||||
if (Number.isInteger(Number(value)) && Number(value) > 0) {
|
||||
callback();
|
||||
} else {
|
||||
callback(new Error(that.$t('global.permissionGreaterThen0')));
|
||||
}
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
startTime: [
|
||||
{ required: true, message: this.$t('global.enterStartTime'), trigger: 'change' }
|
||||
],
|
||||
endTime: [
|
||||
{ required: true, message: this.$t('global.enterEndTime'), trigger: 'change' }
|
||||
],
|
||||
date: [
|
||||
{ required: true, message: this.$t('global.enterDate'), trigger: 'blur' }
|
||||
]
|
||||
};
|
||||
return crules;
|
||||
},
|
||||
title() {
|
||||
if (this.PermissionType == PermissionType.LESSON) {
|
||||
return this.$t('global.transferLessonPermission');
|
||||
} else if (this.PermissionType == PermissionType.EXAM) {
|
||||
return this.$t('global.transferExamPermission');
|
||||
} else if (this.PermissionType == PermissionType.SIMULATION) {
|
||||
return this.$t('global.transferSimulationPermission');
|
||||
} else if (this.PermissionType == PermissionType.SCREEN) {
|
||||
return this.$t('global.transferScreenPermission');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'formModel.date': function (val, old) {
|
||||
this.setTotalMax();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setTotalMax() {
|
||||
let endTime;
|
||||
let startTime;
|
||||
if (this.formModel.date) {
|
||||
endTime = this.formModel.date[1];
|
||||
startTime = this.formModel.date[0];
|
||||
}
|
||||
this.maxTotal = 0;
|
||||
if (endTime && startTime) {
|
||||
if (endTime > startTime) {
|
||||
const model = {
|
||||
startTime: `${startTime} 00:00:00`,
|
||||
endTime: `${endTime} 23:59:59`,
|
||||
permissionType: this.PermissionType
|
||||
};
|
||||
if (this.PermissionType == PermissionType.LESSON || this.PermissionType == PermissionType.EXAM) {
|
||||
model['lessonId'] = this.formModel.lessonId;
|
||||
model['mapId'] = this.mapId;
|
||||
model['prdCode'] = this.prdCode;
|
||||
} else if (this.PermissionType == PermissionType.SIMULATION) {
|
||||
model['mapId'] = this.mapId;
|
||||
model['prdCode'] = this.prdCode;
|
||||
}
|
||||
getTotalRemains(model).then(response => {
|
||||
this.maxTotal = response.data;
|
||||
if (this.maxTotal == 0) {
|
||||
this.numberMessage = this.$t('tip.theNumberOfPermissionsAvailableIsZero');
|
||||
} else {
|
||||
this.numberMessage = `(${this.$t('global.remainPermissionNumber')}:${this.maxTotal})`;
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$messageBox(this.$t('error.obtainMaxNumberFailed'));
|
||||
});
|
||||
} else {
|
||||
this.numberMessage = this.$t('tip.endTimeRules');
|
||||
}
|
||||
} else {
|
||||
this.numberMessage = '';
|
||||
}
|
||||
},
|
||||
doShow(data) {
|
||||
this.dialogVisible = true;
|
||||
if (data) {
|
||||
this.formModel.lessonId = data.id;
|
||||
this.formModel.lessonName = data.name;
|
||||
this.prdCode = data.prdCode;
|
||||
this.mapId = data.mapId;
|
||||
this.PermissionType = data.PermissionType;
|
||||
this.setTotalMax();
|
||||
}
|
||||
},
|
||||
handleSure() {
|
||||
this.$refs.dataform.validateForm(() => {
|
||||
const model = {
|
||||
startTime: `${this.formModel.date[0]} 00:00:00`,
|
||||
endTime: `${this.formModel.date[1]} 23:59:59`,
|
||||
amount: this.formModel.total,
|
||||
permissionType: this.PermissionType
|
||||
};
|
||||
if (this.PermissionType == PermissionType.LESSON || this.PermissionType == PermissionType.EXAM) {
|
||||
model['lessonId'] = this.formModel.lessonId;
|
||||
model['mapId'] = this.mapId;
|
||||
model['prdCode'] = this.prdCode;
|
||||
} else if (this.PermissionType == PermissionType.SIMULATION) {
|
||||
model['mapId'] = this.mapId;
|
||||
model['prdCode'] = this.prdCode;
|
||||
}
|
||||
// 转增
|
||||
permissionTurnAdd(model).then(response => {
|
||||
const url = response.data;
|
||||
this.$emit('QrCodeShow', {
|
||||
url: url,
|
||||
title: this.$t('global.transferQrcode')
|
||||
});
|
||||
this.dialogVisible = false;
|
||||
this.$emit('initLoadPage');
|
||||
this.handleClose();
|
||||
}).catch(() => {
|
||||
this.$messageBox(this.$t('error.getTransferQrcodeFailed'));
|
||||
});
|
||||
});
|
||||
},
|
||||
close() {
|
||||
this.dialogVisible = false;
|
||||
this.handleClose();
|
||||
},
|
||||
handleClose(done) {
|
||||
this.maxTotal = 0;
|
||||
this.formModel = {
|
||||
lessonId: '',
|
||||
lessonName: '',
|
||||
total: 0,
|
||||
startTime: '',
|
||||
endTime: ''
|
||||
};
|
||||
this.$refs.dataform.resetForm();
|
||||
if (done) {
|
||||
done();
|
||||
} else {
|
||||
this.dialogVisible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -50,6 +50,7 @@ import CreateEmptyPlan from './editTool/menus/createEmptyPlan';
|
||||
import { getRpListByUserMapId, publishRunPlan, releaseOrCancelRunPlan, previewRunPlan} from '@/api/designPlatform';
|
||||
import { getRpListByMapId, deleteRunPlan } from '@/api/runplan';
|
||||
import { launchFullscreen } from '@/utils/screen';
|
||||
import { UrlConfig } from '@/router/index';
|
||||
export default {
|
||||
name: 'UserRunPlanList',
|
||||
components: {
|
||||
|
Loading…
Reference in New Issue
Block a user