修改接口:/api/mapPrd/{skinStyle}/list 改为 /api/mapPrd/{mapId}/list

This commit is contained in:
fan 2019-10-30 17:41:29 +08:00
parent 36c33ed416
commit e5c832aa00
8 changed files with 749 additions and 767 deletions

View File

@ -62,9 +62,9 @@ export function deleteTrainingCategory(data) {
/**
* 获取地图下的产品列表
*/
export function getCommodityMapProduct(skinCode) {
export function getCommodityMapProduct(mapId) {
return request({
url: `/api/mapPrd/${skinCode}/list`,
url: `/api/mapPrd/${mapId}/list`,
method: 'get'
});
}

View File

@ -119,7 +119,7 @@ export default {
} else {
this.courseModel.skinCode = this.$route.query.skinCode;
}
getCommodityMapProduct(this.$route.query.skinCode).then(response => {
getCommodityMapProduct(this.$route.query.mapId).then(response => {
this.productList = response.data || [];
this.productList = this.productList.filter(elem => { return elem.prdType != '03'; });
});

View File

@ -197,7 +197,7 @@ export default {
}
},
mounted() {
this.skinCodeChoose(this.$route.params.skinCode);
this.mapIdChoose(this.$route.query.mapId);
},
methods: {
show(data) {
@ -211,11 +211,11 @@ export default {
this.dialogShow = false;
this.loading = false;
},
skinCodeChoose(skinCode) {
mapIdChoose(mapId) {
this.operateModel.prdCode = '';
this.productList = [];
if (skinCode) {
getCommodityMapProduct(skinCode).then((response) => {
if (mapId) {
getCommodityMapProduct(mapId).then((response) => {
this.productList = response.data;
this.productList = this.productList.filter(elem => { return elem.prdType != '03'; });
});

View File

@ -172,7 +172,7 @@ export default {
getSkinCodeList().then(response => {
this.skinCodeList = response.data;
});
getCommodityMapProduct(this.$route.params.skinCode).then((response) => {
getCommodityMapProduct(this.$route.query.mapId).then((response) => {
const productList = response.data;
if (productList && productList.length > 0) {
productList.forEach(elem => {

View File

@ -15,176 +15,168 @@ import { getPublishMapList } from '@/api/jmap/map';
import { getCommodityMapProduct } from '@/api/management/mapprd';
export default {
name: 'UsersTrainingAdd',
props: {
type: {
type: String,
required: true
}
},
data() {
return {
dialogVisible: false,
formModel: {
mapId: '',
mapPrdCode: '',
userId: '',
userName: '',
duration: ''
},
LessonList: [],
mapPrdList: [],
UserList: [],
UserLoading: false
};
},
computed: {
form() {
const form = {
labelWidth: '120px',
items: [
{ prop: 'mapId', label: this.$t('system.mapName'), type: 'select', required: true, options: this.LessonList, change: true, onChange: this.mapChange, placeholder: this.$t('rules.mapInput') },
{ prop: 'mapPrdCode', label: this.$t('system.productName'), type: 'select', required: true, options: this.mapPrdList, placeholder: this.$t('rules.productInput') },
{ prop: 'userName', label: this.$t('system.userName'), type: 'complete', required: false, querySearchAsync: this.querySearchAsync, handleSelect: this.prdSelect, placeholder: this.$t('system.pleaseInputNames') },
{ prop: 'duration', label: this.$t('system.trainingUseTime'), type: 'text', rightWidth: true, required: true, message: 's' }
]
};
return form;
},
rules() {
const crules = {
mapId: [
{ required: true, message: this.$t('rules.mapInput'), trigger: 'change' }
],
userName: [
{ required: true, message: this.$t('rules.chooseUser'), trigger: 'change' }
],
mapPrdCode: [
{ required: true, message: this.$t('rules.productInput'), trigger: 'change' }
],
duration: [
{ required: true, message: this.$t('rules.timeInput'), trigger: 'blur' }
]
};
return crules;
},
title() {
return this.$t('system.createSimulationTitle');
}
},
mounted() {
this.initLoadPage();
},
methods: {
initLoadPage() {
//
this.LessonList.length = 0;
this.UserList.length = 0;
const param = {
pageNum: 1,
pageSize: 10
};
getPublishMapList(param).then(response => {
const data = response.data.list;
if (data && data.length) {
data.forEach(elem => {
this.LessonList.push({ value: elem.id, label: elem.name, skinCode: elem.skinCode });
});
}
});
},
// input
async querySearchAsync(queryString, cb) {
// queryString
const results = [];
if (queryString) {
try {
const params = {
fuzzyParam: queryString
};
const res = await getDimUserList(params);
const list = res.data;
list.forEach(item => {
const value = {
id: item.id,
value: `${item.nickname}(${item.name})${item.mobile}`
};
results.push(value);
});
cb(results);
} catch (error) {
console.error(error);
cb(results);
}
} else {
cb(results);
}
},
prdSelect(item) {
this.formModel.userId = item.id;
},
async mapChange(val) {
let skinCode = '';
this.mapPrdList = [];
this.formModel.mapPrdCode = '';
if (this.LessonList.length) {
this.LessonList.forEach(item => {
if (item.value == val) {
skinCode = item.skinCode;
}
});
try {
const res = await getCommodityMapProduct(skinCode);
const data = res.data;
if (data && data.length) {
data.forEach(elem => {
this.mapPrdList.push({ value: elem.code, label: elem.name });
});
}
} catch (error) {
console.error(error);
}
}
},
show(data) {
this.dialogVisible = true;
},
doSave() {
const self = this;
this.$refs.dataform.validateForm(() => {
self.save();
});
},
save() {
const self = this;
const params = {
mapId: this.formModel.mapId,
mapPrdCode: this.formModel.mapPrdCode,
userId: this.formModel.userId,
duration: parseInt(this.formModel.duration)
};
if (params.userId) {
postSimulationStats(params).then(response => {
self.$message.success(this.$t('system.addSuccess'));
self.handleClose();
self.$emit('reloadTable');
}).catch(error => {
self.$message.error(this.$t('error.addFailed') + error.message);
});
} else {
this.$message.error(this.$t('rules.chooseUser'));
}
},
handleClose(done) {
this.formModel = {
mapId: '',
mapPrdCode: '',
userId: '',
userName: '',
duration: ''
};
this.dialogVisible = false;
}
}
name: 'UsersTrainingAdd',
props: {
type: {
type: String,
required: true
}
},
data() {
return {
dialogVisible: false,
formModel: {
mapId: '',
mapPrdCode: '',
userId: '',
userName: '',
duration: ''
},
LessonList: [],
mapPrdList: [],
UserList: [],
UserLoading: false
};
},
computed: {
form() {
const form = {
labelWidth: '120px',
items: [
{ prop: 'mapId', label: this.$t('system.mapName'), type: 'select', required: true, options: this.LessonList, change: true, onChange: this.mapChange, placeholder: this.$t('rules.mapInput') },
{ prop: 'mapPrdCode', label: this.$t('system.productName'), type: 'select', required: true, options: this.mapPrdList, placeholder: this.$t('rules.productInput') },
{ prop: 'userName', label: this.$t('system.userName'), type: 'complete', required: false, querySearchAsync: this.querySearchAsync, handleSelect: this.prdSelect, placeholder: this.$t('system.pleaseInputNames') },
{ prop: 'duration', label: this.$t('system.trainingUseTime'), type: 'text', rightWidth: true, required: true, message: 's' }
]
};
return form;
},
rules() {
const crules = {
mapId: [
{ required: true, message: this.$t('rules.mapInput'), trigger: 'change' }
],
userName: [
{ required: true, message: this.$t('rules.chooseUser'), trigger: 'change' }
],
mapPrdCode: [
{ required: true, message: this.$t('rules.productInput'), trigger: 'change' }
],
duration: [
{ required: true, message: this.$t('rules.timeInput'), trigger: 'blur' }
]
};
return crules;
},
title() {
return this.$t('system.createSimulationTitle');
}
},
mounted() {
this.initLoadPage();
},
methods: {
initLoadPage() {
//
this.LessonList.length = 0;
this.UserList.length = 0;
const param = {
pageNum: 1,
pageSize: 10
};
getPublishMapList(param).then(response => {
const data = response.data.list;
if (data && data.length) {
data.forEach(elem => {
this.LessonList.push({ value: elem.id, label: elem.name, skinCode: elem.skinCode });
});
}
});
},
// input
async querySearchAsync(queryString, cb) {
// queryString
const results = [];
if (queryString) {
try {
const params = {
fuzzyParam: queryString
};
const res = await getDimUserList(params);
const list = res.data;
list.forEach(item => {
const value = {
id: item.id,
value: `${item.nickname}(${item.name})${item.mobile}`
};
results.push(value);
});
cb(results);
} catch (error) {
console.error(error);
cb(results);
}
} else {
cb(results);
}
},
prdSelect(item) {
this.formModel.userId = item.id;
},
async mapChange(val) {
this.mapPrdList = [];
this.formModel.mapPrdCode = '';
try {
const res = await getCommodityMapProduct(val);
const data = res.data;
if (data && data.length) {
data.forEach(elem => {
this.mapPrdList.push({ value: elem.code, label: elem.name });
});
}
} catch (error) {
console.error(error);
}
},
show(data) {
this.dialogVisible = true;
},
doSave() {
const self = this;
this.$refs.dataform.validateForm(() => {
self.save();
});
},
save() {
const self = this;
const params = {
mapId: this.formModel.mapId,
mapPrdCode: this.formModel.mapPrdCode,
userId: this.formModel.userId,
duration: parseInt(this.formModel.duration)
};
if (params.userId) {
postSimulationStats(params).then(response => {
self.$message.success(this.$t('system.addSuccess'));
self.handleClose();
self.$emit('reloadTable');
}).catch(error => {
self.$message.error(this.$t('error.addFailed') + error.message);
});
} else {
this.$message.error(this.$t('rules.chooseUser'));
}
},
handleClose(done) {
this.formModel = {
mapId: '',
mapPrdCode: '',
userId: '',
userName: '',
duration: ''
};
this.dialogVisible = false;
}
}
};
</script>

View File

@ -10,7 +10,6 @@
</template>
<script>
import { getPublishMapInfo } from '@/api/jmap/map';
import { getCommodityMapProduct } from '@/api/management/mapprd';
import { OperatorModel, PermissionType } from '@/scripts/ConstDic';
import { getTotalRemains } from '@/api/management/author';
@ -18,295 +17,293 @@ import { superAdmin, admin } from '@/router';
import { getDimUserList } from '@/api/management/user';
export default {
name: 'EditRule',
props: {
permissionTypeList: {
type: Array,
required: true
},
publishMapList: {
type: Array,
required: true
},
publisLessonList: {
type: Array,
required: true
}
},
data() {
return {
show: false,
type: '',
mapProductList: [],
filterPublisLessonList: [],
formModel: {
permissionType: '',
mapId: '',
lessonId: '',
prdCode: '',
date: '',
amount: 0,
ownerId: '',
roleName: ''
},
DatePicker: {
shortcuts: [{
text: this.$t('global.today'),
onClick(picker) {
picker.$emit('pick', new Date());
}
}]
},
numberMessage: ''
};
},
name: 'EditRule',
props: {
permissionTypeList: {
type: Array,
required: true
},
publishMapList: {
type: Array,
required: true
},
publisLessonList: {
type: Array,
required: true
}
},
data() {
return {
show: false,
type: '',
mapProductList: [],
filterPublisLessonList: [],
formModel: {
permissionType: '',
mapId: '',
lessonId: '',
prdCode: '',
date: '',
amount: 0,
ownerId: '',
roleName: ''
},
DatePicker: {
shortcuts: [{
text: this.$t('global.today'),
onClick(picker) {
picker.$emit('pick', new Date());
}
}]
},
numberMessage: ''
};
},
computed: {
form() {
const form = {
labelWidth: '120px',
items: [
{ prop: 'permissionType', label: this.$t('permission.permissionType'), type: 'select', required: false, disabled: !this.isAdd, options: this.permissionTypeList, change: true, onChange: this.permissionTypeChange },
{ prop: 'mapId', label: this.$t('permission.mapName'), type: 'select', required: false, disabled: !this.isAdd, show: this.isShowMap, options: this.publishMapList, change: true, onChange: this.mapChange },
{ prop: 'prdCode', label: this.$t('permission.mapProductName'), type: 'select', required: false, disabled: !this.isAdd, show: this.isShowMapProduct, options: this.mapProductList, change: true, onChange: this.mapProductChange },
{ prop: 'lessonId', label: this.$t('permission.lessonName'), type: 'select', required: false, disabled: !this.isAdd, show: this.isShowLesson, options: this.filterPublisLessonList },
{ prop: 'roleName', label: this.$t('permission.belonger'), type: 'complete', required: false, disabled: !this.isAdd && this.isAdministrator, show: this.isShowRole, querySearchAsync: this.querySearchAsync, handleSelect: this.prdSelect, placeholder: '请输入昵称/名字/手机号' },
{ prop: 'date', label: this.$t('permission.selectDate'), type: 'daterange', required: false, viewFormat: 'yyyy-MM-dd HH:mm:ss', valueFormat: 'yyyy-MM-dd HH:mm:ss' },
{ prop: 'amount', label: '权限个数', type: 'number', required: false, min: 0, max: this.maxTotal, message: this.numberMessage }
]
};
return form;
},
rules() {
const that = this;
const crules = {
permissionType: [
{ required: true, message: this.$t('rules.permissionTypeInput'), trigger: 'change' }
],
mapId: [
{ required: true, message: this.$t('rules.selectMapName'), trigger: 'change' }
],
prdCode: [
{ required: true, message: this.$t('rules.selectMapProductName'), trigger: 'change' }
],
lessonId: [
{ required: true, message: this.$t('rules.lessonInput'), trigger: 'change' }
],
date: [
{ required: true, message: this.$t('rules.inputTime'), trigger: 'blur' }
],
amount: [
{ required: true, message: this.$t('rules.inputPermissionNumber'), trigger: 'change' },
{
validator(rule, value, callback) {
if (Number.isInteger(Number(value)) && Number(value) > 0) {
callback();
} else {
callback(new Error(that.$t('rules.permissionNumberGreater0')));
}
},
trigger: 'blur'
}
]
};
return crules;
},
title() {
if (this.isAdd) {
return this.$t('permission.addPermissionPackageRule');
} else {
return this.$t('permission.editPermissionPackageRule');
}
},
disabled() {
return this.formModel.amount > this.maxTotal || this.formModel.amount <= 0;
},
isAdd() {
return this.type == 'add';
},
isAdministrator() {
return this.$store.state.user.roles.indexOf(superAdmin) || this.$store.state.user.roles.indexOf(admin);
},
isShowMap() {
return this.formModel.permissionType !== '04';
computed: {
form() {
const form = {
labelWidth: '120px',
items: [
{ prop: 'permissionType', label: this.$t('permission.permissionType'), type: 'select', required: false, disabled: !this.isAdd, options: this.permissionTypeList, change: true, onChange: this.permissionTypeChange },
{ prop: 'mapId', label: this.$t('permission.mapName'), type: 'select', required: false, disabled: !this.isAdd, show: this.isShowMap, options: this.publishMapList, change: true, onChange: this.mapChange },
{ prop: 'prdCode', label: this.$t('permission.mapProductName'), type: 'select', required: false, disabled: !this.isAdd, show: this.isShowMapProduct, options: this.mapProductList, change: true, onChange: this.mapProductChange },
{ prop: 'lessonId', label: this.$t('permission.lessonName'), type: 'select', required: false, disabled: !this.isAdd, show: this.isShowLesson, options: this.filterPublisLessonList },
{ prop: 'roleName', label: this.$t('permission.belonger'), type: 'complete', required: false, disabled: !this.isAdd && this.isAdministrator, show: this.isShowRole, querySearchAsync: this.querySearchAsync, handleSelect: this.prdSelect, placeholder: '请输入昵称/名字/手机号' },
{ prop: 'date', label: this.$t('permission.selectDate'), type: 'daterange', required: false, viewFormat: 'yyyy-MM-dd HH:mm:ss', valueFormat: 'yyyy-MM-dd HH:mm:ss' },
{ prop: 'amount', label: '权限个数', type: 'number', required: false, min: 0, max: this.maxTotal, message: this.numberMessage }
]
};
return form;
},
rules() {
const that = this;
const crules = {
permissionType: [
{ required: true, message: this.$t('rules.permissionTypeInput'), trigger: 'change' }
],
mapId: [
{ required: true, message: this.$t('rules.selectMapName'), trigger: 'change' }
],
prdCode: [
{ required: true, message: this.$t('rules.selectMapProductName'), trigger: 'change' }
],
lessonId: [
{ required: true, message: this.$t('rules.lessonInput'), trigger: 'change' }
],
date: [
{ required: true, message: this.$t('rules.inputTime'), trigger: 'blur' }
],
amount: [
{ required: true, message: this.$t('rules.inputPermissionNumber'), trigger: 'change' },
{
validator(rule, value, callback) {
if (Number.isInteger(Number(value)) && Number(value) > 0) {
callback();
} else {
callback(new Error(that.$t('rules.permissionNumberGreater0')));
}
},
trigger: 'blur'
}
]
};
return crules;
},
title() {
if (this.isAdd) {
return this.$t('permission.addPermissionPackageRule');
} else {
return this.$t('permission.editPermissionPackageRule');
}
},
disabled() {
return this.formModel.amount > this.maxTotal || this.formModel.amount <= 0;
},
isAdd() {
return this.type == 'add';
},
isAdministrator() {
return this.$store.state.user.roles.indexOf(superAdmin) || this.$store.state.user.roles.indexOf(admin);
},
isShowMap() {
return this.formModel.permissionType !== '04';
},
isShowRole() {
return this.$store.state.user.roles.indexOf(superAdmin) != -1;
},
isShowMapProduct() {
return this.formModel.permissionType !== '04';
},
isShowLesson() {
return this.formModel.permissionType != '04' && this.formModel.permissionType != '03';
}
},
watch: {
formModel: {
handler: function (val, old) {
this.setTotalMax();
},
deep: true
}
},
methods: {
setTotalMax() {
let endTime;
let startTime;
if (this.formModel.date) {
endTime = this.formModel.date[1];
startTime = this.formModel.date[0];
}
},
isShowRole() {
return this.$store.state.user.roles.indexOf(superAdmin) != -1;
},
isShowMapProduct() {
return this.formModel.permissionType !== '04';
},
isShowLesson() {
return this.formModel.permissionType != '04' && this.formModel.permissionType != '03';
}
},
watch: {
formModel: {
handler: function (val, old) {
this.setTotalMax();
},
deep: true
}
},
methods: {
setTotalMax() {
let endTime;
let startTime;
if (this.formModel.date) {
endTime = this.formModel.date[1];
startTime = this.formModel.date[0];
}
var validator = {};
validator[PermissionType.LESSON] = () => { return this.formModel.lessonId && this.formModel.mapId && this.formModel.prdCode; };
validator[PermissionType.EXAM] = () => { return this.formModel.lessonId && this.formModel.mapId && this.formModel.prdCode; };
validator[PermissionType.SIMULATION] = () => { return this.formModel.mapId && this.formModel.prdCode; };
validator[PermissionType.SCREEN] = () => { return true; };
var validator = {};
validator[PermissionType.LESSON] = () => { return this.formModel.lessonId && this.formModel.mapId && this.formModel.prdCode; };
validator[PermissionType.EXAM] = () => { return this.formModel.lessonId && this.formModel.mapId && this.formModel.prdCode; };
validator[PermissionType.SIMULATION] = () => { return this.formModel.mapId && this.formModel.prdCode; };
validator[PermissionType.SCREEN] = () => { return true; };
if (endTime && startTime && this.formModel.permissionType && validator[this.formModel.permissionType]()) {
if (endTime > startTime) {
const model = {
startTime: startTime,
endTime: endTime,
permissionType: this.formModel.permissionType,
ownerId: this.formModel.ownerId
};
if (endTime && startTime && this.formModel.permissionType && validator[this.formModel.permissionType]()) {
if (endTime > startTime) {
const model = {
startTime: startTime,
endTime: endTime,
permissionType: this.formModel.permissionType,
ownerId: this.formModel.ownerId
};
if (this.formModel.permissionType == PermissionType.LESSON || this.formModel.permissionType == PermissionType.EXAM) {
model['lessonId'] = this.formModel.lessonId;
model['mapId'] = this.formModel.mapId;
model['prdCode'] = this.formModel.prdCode;
} else if (this.formModel.permissionType == PermissionType.SIMULATION) {
model['mapId'] = this.formModel.mapId;
model['prdCode'] = this.formModel.prdCode;
}
if (this.formModel.permissionType == PermissionType.LESSON || this.formModel.permissionType == PermissionType.EXAM) {
model['lessonId'] = this.formModel.lessonId;
model['mapId'] = this.formModel.mapId;
model['prdCode'] = this.formModel.prdCode;
} else if (this.formModel.permissionType == PermissionType.SIMULATION) {
model['mapId'] = this.formModel.mapId;
model['prdCode'] = this.formModel.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 = '';
}
},
permissionTypeChange() {
this.formModel.mapId = '';
this.formModel.prdCode = '';
this.formModel.lessonId = '';
},
mapChange(mapId) {
this.formModel.prdCode = '';
this.formModel.lessonId = '';
this.mapProductList = [];
getPublishMapInfo(mapId).then(resp => {
getCommodityMapProduct(resp.data.skinCode).then(rest => {
const list = rest.data || [];
this.mapProductList = list.map(elem => {
return { value: elem.code, label: elem.name };
});
});
});
},
mapProductChange(prdCode) {
this.formModel.lessonId = '';
this.filterPublisLessonList = this.publisLessonList.filter(elem => { return elem.mapId == this.formModel.mapId && elem.prdCode == this.formModel.prdCode; });
},
// input
async querySearchAsync(queryString, cb) {
// queryString
const results = [];
if (queryString) {
try {
const params = {
fuzzyParam: queryString
};
const res = await getDimUserList(params);
const list = res.data;
list.forEach(item => {
const value = {
id: item.id,
value: `${item.nickname}(${item.name})${item.mobile}`
};
results.push(value);
});
cb(results);
} catch (error) {
cb(results);
}
} else {
cb(results);
}
},
prdSelect(item) {
this.formModel.ownerId = item.id;
},
doShow(data) {
this.show = true;
this.type = data.type;
if (!this.isAdd) {
const model = data.item;
this.formModel = {
permissionType: model.permissionType,
mapId: model.mapId,
lessonId: model.lessonId,
prdCode: model.prdCode,
date: [model.startTime, model.endTime],
amount: model.amount,
ownerId: this.formModel.ownerId,
roleName: this.formModel.roleName
};
}
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 = '';
}
},
permissionTypeChange() {
this.formModel.mapId = '';
this.formModel.prdCode = '';
this.formModel.lessonId = '';
},
mapChange(mapId) {
this.formModel.prdCode = '';
this.formModel.lessonId = '';
this.mapProductList = [];
getCommodityMapProduct(mapId).then(rest => {
const list = rest.data || [];
this.mapProductList = list.map(elem => {
return { value: elem.code, label: elem.name };
});
});
},
mapProductChange(prdCode) {
this.formModel.lessonId = '';
this.filterPublisLessonList = this.publisLessonList.filter(elem => { return elem.mapId == this.formModel.mapId && elem.prdCode == this.formModel.prdCode; });
},
// input
async querySearchAsync(queryString, cb) {
// queryString
const results = [];
if (queryString) {
try {
const params = {
fuzzyParam: queryString
};
const res = await getDimUserList(params);
const list = res.data;
list.forEach(item => {
const value = {
id: item.id,
value: `${item.nickname}(${item.name})${item.mobile}`
};
results.push(value);
});
cb(results);
} catch (error) {
cb(results);
}
} else {
cb(results);
}
},
prdSelect(item) {
this.formModel.ownerId = item.id;
},
doShow(data) {
this.show = true;
this.type = data.type;
if (!this.isAdd) {
const model = data.item;
this.formModel = {
permissionType: model.permissionType,
mapId: model.mapId,
lessonId: model.lessonId,
prdCode: model.prdCode,
date: [model.startTime, model.endTime],
amount: model.amount,
ownerId: this.formModel.ownerId,
roleName: this.formModel.roleName
};
}
this.formModel.amount = 0;
},
doClose() {
this.show = false;
},
draftRule() {
this.$refs.dataform.validateForm(() => {
if (this.formModel.amount <= this.maxTotal && this.formModel.amount) {
if (this.isAdd) {
this.$emit('addRuleForm', {
operator: OperatorModel.TRANSFER,
permissionType: this.formModel.permissionType,
mapId: this.isShowMap ? this.formModel.mapId : '',
lessonId: this.isShowLesson ? this.formModel.lessonId : '',
prdCode: this.isShowMapProduct ? this.formModel.prdCode : '',
startTime: this.formModel.date[0],
endTime: this.formModel.date[1],
amount: this.formModel.amount,
ownerId: this.formModel.ownerId,
roleName: this.formModel.roleName
});
} else {
this.$emit('editRuleForm', {
operator: OperatorModel.TRANSFER,
permissionType: this.formModel.permissionType,
mapId: this.isShowMap ? this.formModel.mapId : '',
lessonId: this.isShowLesson ? this.formModel.lessonId : '',
prdCode: this.isShowMapProduct ? this.formModel.prdCode : '',
startTime: this.formModel.date[0],
endTime: this.formModel.date[1],
amount: this.formModel.amount,
ownerId: this.formModel.ownerId,
roleName: this.formModel.roleName
});
}
this.doClose();
}
});
}
}
this.formModel.amount = 0;
},
doClose() {
this.show = false;
},
draftRule() {
this.$refs.dataform.validateForm(() => {
if (this.formModel.amount <= this.maxTotal && this.formModel.amount) {
if (this.isAdd) {
this.$emit('addRuleForm', {
operator: OperatorModel.TRANSFER,
permissionType: this.formModel.permissionType,
mapId: this.isShowMap ? this.formModel.mapId : '',
lessonId: this.isShowLesson ? this.formModel.lessonId : '',
prdCode: this.isShowMapProduct ? this.formModel.prdCode : '',
startTime: this.formModel.date[0],
endTime: this.formModel.date[1],
amount: this.formModel.amount,
ownerId: this.formModel.ownerId,
roleName: this.formModel.roleName
});
} else {
this.$emit('editRuleForm', {
operator: OperatorModel.TRANSFER,
permissionType: this.formModel.permissionType,
mapId: this.isShowMap ? this.formModel.mapId : '',
lessonId: this.isShowLesson ? this.formModel.lessonId : '',
prdCode: this.isShowMapProduct ? this.formModel.prdCode : '',
startTime: this.formModel.date[0],
endTime: this.formModel.date[1],
amount: this.formModel.amount,
ownerId: this.formModel.ownerId,
roleName: this.formModel.roleName
});
}
this.doClose();
}
});
}
}
};
</script>

View File

@ -70,7 +70,7 @@
</template>
<script>
import { listPublishMap, getPublishMapInfo } from '@/api/jmap/map';
import { listPublishMap } from '@/api/jmap/map';
import { getPublishLessonList } from '@/api/jmap/lesson';
import { getCommodityMapProduct } from '@/api/management/mapprd';
import { packagePermissionDistribute } from '@/api/management/distribute';
@ -79,187 +79,184 @@ import EditRule from './editRule';
import CanTransfer from './canDistribute';
export default {
name: 'PackRule',
components: {
EditRule,
QrCode,
CanTransfer
},
data() {
return {
display: 1,
urlInfo: {},
PermissionTypeList: [],
PublisLessonList: [],
PublishMapList: [],
mapProductList: [],
ruleList: []
};
},
computed: {
height() {
return this.$store.state.app.height - 63;
}
},
mounted() {
this.loadInitData();
},
methods: {
getSummaries(param) {
const { columns, data } = param;
const sums = [];
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = this.$t('global.totoal');
return;
}
name: 'PackRule',
components: {
EditRule,
QrCode,
CanTransfer
},
data() {
return {
display: 1,
urlInfo: {},
PermissionTypeList: [],
PublisLessonList: [],
PublishMapList: [],
mapProductList: [],
ruleList: []
};
},
computed: {
height() {
return this.$store.state.app.height - 63;
}
},
mounted() {
this.loadInitData();
},
methods: {
getSummaries(param) {
const { columns, data } = param;
const sums = [];
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = this.$t('global.totoal');
return;
}
if (index === 6) {
const values = data.map(item => Number(item[column.property]));
if (!values.every(value => isNaN(value))) {
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
}
}
});
if (index === 6) {
const values = data.map(item => Number(item[column.property]));
if (!values.every(value => isNaN(value))) {
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
}
}
});
return sums;
},
computedName(list, code) {
let name = '';
list.forEach(elem => {
if (elem.value == code) {
name = elem.label;
}
});
return name;
},
async computedMapProduct(item) {
let name = '';
const resp = await getPublishMapInfo(item.mapId);
const rest = await getCommodityMapProduct(resp.data.skinCode);
const list = rest.data || [];
list.forEach(elem => {
if (elem.id == item.mapProductCode) {
name = elem.name;
return;
}
});
return name;
},
loadInitData() {
this.PermissionTypeList = [];
this.$Dictionary.permissionType().then(list => {
this.PermissionTypeList = list.map(elem => {
return { value: elem.code, label: elem.name };
});
});
return sums;
},
computedName(list, code) {
let name = '';
list.forEach(elem => {
if (elem.value == code) {
name = elem.label;
}
});
return name;
},
async computedMapProduct(item) {
let name = '';
const rest = await getCommodityMapProduct(item.mapId);
const list = rest.data || [];
list.forEach(elem => {
if (elem.id == item.mapProductCode) {
name = elem.name;
return;
}
});
return name;
},
loadInitData() {
this.PermissionTypeList = [];
this.$Dictionary.permissionType().then(list => {
this.PermissionTypeList = list.map(elem => {
return { value: elem.code, label: elem.name };
});
});
this.EffectiveTypeList = [];
this.$Dictionary.effectiveType().then(list => {
this.EffectiveTypeList = list.map(elem => {
return { value: elem.code, label: elem.name };
});
});
this.EffectiveTypeList = [];
this.$Dictionary.effectiveType().then(list => {
this.EffectiveTypeList = list.map(elem => {
return { value: elem.code, label: elem.name };
});
});
this.PublishMapList = [];
listPublishMap().then(response => {
const list = response.data || [];
this.PublishMapList = list.map(elem => {
return { value: elem.id, label: elem.name };
});
});
this.PublishMapList = [];
listPublishMap().then(response => {
const list = response.data || [];
this.PublishMapList = list.map(elem => {
return { value: elem.id, label: elem.name };
});
});
this.PublisLessonList = [];
getPublishLessonList().then(response => {
const list = response.data || [];
this.PublisLessonList = list.map(elem => {
return { value: elem.id, label: elem.name, mapId: elem.mapId, prdCode: elem.prdCode };
});
});
},
turnback() {
this.$router.go(-1);
},
dialogAdd() {
this.$refs.addRule.doShow({ type: 'add' });
},
dialogEdit(item) {
this.$refs.addRule.doShow({ type: 'edit', item: item });
},
deleteForm(item) {
var index = this.ruleList.indexOf(item);
if (index >= 0) {
this.ruleList.splice(index, 1);
}
},
addRuleForm(item) {
const index = this.ruleList.findIndex(elem => {
return item.mapId == elem.mapId &&
this.PublisLessonList = [];
getPublishLessonList().then(response => {
const list = response.data || [];
this.PublisLessonList = list.map(elem => {
return { value: elem.id, label: elem.name, mapId: elem.mapId, prdCode: elem.prdCode };
});
});
},
turnback() {
this.$router.go(-1);
},
dialogAdd() {
this.$refs.addRule.doShow({ type: 'add' });
},
dialogEdit(item) {
this.$refs.addRule.doShow({ type: 'edit', item: item });
},
deleteForm(item) {
var index = this.ruleList.indexOf(item);
if (index >= 0) {
this.ruleList.splice(index, 1);
}
},
addRuleForm(item) {
const index = this.ruleList.findIndex(elem => {
return item.mapId == elem.mapId &&
item.lessonId == elem.lessonId &&
item.prdCode == elem.prdCode &&
item.permissionType == elem.permissionType;
});
getPublishMapInfo(item.mapId).then(resp => {
getCommodityMapProduct(resp.data.skinCode).then(rest => {
const list = rest.data || [];
this.mapProductList = list.map(elem => {
return { value: elem.code, label: elem.name };
});
});
});
if (index < 0) {
this.ruleList.push(item);
} else {
this.$message.warning(this.$t('permission.hasExitRule'));
}
},
editRuleForm(item) {
const index = this.ruleList.findIndex(elem => {
return item.mapId == elem.mapId &&
});
getCommodityMapProduct(item.mapId).then(rest => {
const list = rest.data || [];
this.mapProductList = list.map(elem => {
return { value: elem.code, label: elem.name };
});
});
if (index < 0) {
this.ruleList.push(item);
} else {
this.$message.warning(this.$t('permission.hasExitRule'));
}
},
editRuleForm(item) {
const index = this.ruleList.findIndex(elem => {
return item.mapId == elem.mapId &&
item.lessonId == elem.lessonId &&
item.mapProductCode == elem.mapProductCode &&
item.permissionType == elem.permissionType;
});
});
if (index >= 0) {
Object.assign(this.ruleList[index], item);
}
},
packForm() {
if (this.ruleList.length) {
this.$refs.canDistribute.doShow();
} else {
this.$messageBox(this.$t('permission.pleaseAddRule'));
}
},
distribute(data) {
this.url = '';
this.ruleList.forEach(item => {
item.canDistribute = data.canDistribute;
});
packagePermissionDistribute(this.ruleList).then(resp => {
this.urlInfo = {
url: resp.data,
title: this.$t('global.distributeQrcode')
};
this.qrcodeShow();
}).catch(() => {
this.$messageBox(this.$t('error.packagePermissionFailed'));
});
},
qrcodeShow() {
if (this.$refs) {
this.$refs.qrCode.doShow(this.urlInfo);
}
}
}
if (index >= 0) {
Object.assign(this.ruleList[index], item);
}
},
packForm() {
if (this.ruleList.length) {
this.$refs.canDistribute.doShow();
} else {
this.$messageBox(this.$t('permission.pleaseAddRule'));
}
},
distribute(data) {
this.url = '';
this.ruleList.forEach(item => {
item.canDistribute = data.canDistribute;
});
packagePermissionDistribute(this.ruleList).then(resp => {
this.urlInfo = {
url: resp.data,
title: this.$t('global.distributeQrcode')
};
this.qrcodeShow();
}).catch(() => {
this.$messageBox(this.$t('error.packagePermissionFailed'));
});
},
qrcodeShow() {
if (this.$refs) {
this.$refs.qrCode.doShow(this.urlInfo);
}
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>

View File

@ -1,144 +1,140 @@
<template>
<div>
<el-dialog :title="title" :visible.sync="dialogVisible" width="500px" :before-close="doClose" center>
<data-form ref="dataform" :form="form" :formModel="formModel" :rules="rules"></data-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="doCreate">{{$t('global.confirm')}}</el-button>
<el-button @click="doClose">{{$t('global.cancel')}}</el-button>
</span>
</el-dialog>
</div>
<div>
<el-dialog :title="title" :visible.sync="dialogVisible" width="500px" :before-close="doClose" center>
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="doCreate">{{ $t('global.confirm') }}</el-button>
<el-button @click="doClose">{{ $t('global.cancel') }}</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import ConstConfig from '@/scripts/ConstConfig';
import Cookies from 'js-cookie';
import { listPublishMap } from '@/api/jmap/map';
import { getCommodityMapProduct } from '@/api/management/mapprd';
export default {
name: 'OnceGenerate',
data() {
return {
dialogVisible: false,
mapList: [],
disabled:null,
productList:[],
mapInfoList:[],
projectList:[],
typeList:[],
formModel:{
mapId:'',
name: "",
prdCode: "",
type: "",
id:null,
}
import ConstConfig from '@/scripts/ConstConfig';
import Cookies from 'js-cookie';
import { listPublishMap } from '@/api/jmap/map';
import { getCommodityMapProduct } from '@/api/management/mapprd';
export default {
name: 'OnceGenerate',
props: {
title: String,
operateType:String
},
data() {
return {
dialogVisible: false,
mapList: [],
disabled:null,
productList:[],
mapInfoList:[],
projectList:[],
typeList:[],
formModel:{
mapId:'',
name: '',
prdCode: '',
type: '',
id:null
}
},
mounted() {
this.loadInitData();
},
props: {
title: String,
operateType:String
},
computed: {
form() {
let form={};
if(this.operateType=="add"){
form={
labelWidth: '150px',
items: [
{ prop: 'customized', label: this.$t('systemGenerate.customized'), type: 'select', required: true,options: this.projectList},
{ prop: 'mapId', label: this.$t('systemGenerate.mapName'), type: 'select', required: true,options: this.mapList,change:true,onChange:this.changeMap},
{ prop: 'prdCode', label: this.$t('systemGenerate.prdName'), type: 'select', required: true,options:this.productList},
{ prop: 'name', label: this.$t('systemGenerate.name'), type: 'text', required: true,},
{ prop: 'type', label: this.$t('systemGenerate.type'), type: 'select', required: true,options: this.typeList},
]
}
}
else{
form={
labelWidth: '150px',
items: [
{ prop: 'name', label: this.$t('systemGenerate.name'), type: 'text', required: true,},
]
}
}
return form
},
rules() {
let crules ={};
if(this.operateType=="add"){
crules ={customized:[
{ required: true, message: this.$t('systemGenerate.selectProject'), trigger: 'change'},
],
mapId:[
{ required: true, message: this.$t('systemGenerate.selectMap'), trigger: 'change'},
],
name: [
{ required: true, message: this.$t('systemGenerate.inputName'), trigger: 'blur' },
{ required: true, message: this.$t('systemGenerate.inputName'), trigger: 'change' },
],
type:[
{ required: true, message: this.$t('systemGenerate.selectType'), trigger: 'change'},
],
prdCode:[
{ required: true, message: this.$t('systemGenerate.selectPrdName'), trigger: 'change'},
]
}
}else{
crules ={
name: [
{ required: true, message: this.$t('systemGenerate.inputName'), trigger: 'blur' },
{ required: true, message: this.$t('systemGenerate.inputName'), trigger: 'change' },
],
};
}
return crules
},
},
methods:{
loadInitData(){
this.projectList=[{value:'xty',label:'西铁院'}];
let customeredProductType=ConstConfig.ConstSelect.customeredProductType;
this.typeList=Cookies.get("user_lang")=="en"?
customeredProductType.map(elem => { return { value: elem.value, label: elem.enlabel } }):
customeredProductType.map(elem => { return { value: elem.value, label: elem.label } });
listPublishMap().then(response => {
this.mapInfoList=response.data;
this.mapList = response.data.map(elem => { return { value: elem.id, label: elem.name } });
})
},
changeMap(index){
this.productList=[];
let mapInfo=this.mapInfoList.find(elem=>{
return elem.id==index;
});
getCommodityMapProduct(mapInfo.skinCode).then((response) => {
this.productList = response.data.map(elem => { return { value: elem.code, label: elem.name } });
this.formModel.prdCode="";
});
},
doShow(data) {
if(data){
this.formModel.name=data.name;
this.formModel.id=data.id;
}
this.dialogVisible = true
},
doCreate() {
let self = this
this.$refs.dataform.validateForm(() => {
self.$emit('create', Object.assign({}, this.formModel));
self.doClose()
})
},
doClose() {
this.$refs.dataform.resetForm();
this.dialogVisible = false
};
},
computed: {
form() {
let form = {};
if (this.operateType == 'add') {
form = {
labelWidth: '150px',
items: [
{ prop: 'customized', label: this.$t('systemGenerate.customized'), type: 'select', required: true, options: this.projectList},
{ prop: 'mapId', label: this.$t('systemGenerate.mapName'), type: 'select', required: true, options: this.mapList, change:true, onChange:this.changeMap},
{ prop: 'prdCode', label: this.$t('systemGenerate.prdName'), type: 'select', required: true, options:this.productList},
{ prop: 'name', label: this.$t('systemGenerate.name'), type: 'text', required: true},
{ prop: 'type', label: this.$t('systemGenerate.type'), type: 'select', required: true, options: this.typeList}
]
};
} else {
form = {
labelWidth: '150px',
items: [
{ prop: 'name', label: this.$t('systemGenerate.name'), type: 'text', required: true}
]
};
}
return form;
},
rules() {
let crules = {};
if (this.operateType == 'add') {
crules = {customized:[
{ required: true, message: this.$t('systemGenerate.selectProject'), trigger: 'change'}
],
mapId:[
{ required: true, message: this.$t('systemGenerate.selectMap'), trigger: 'change'}
],
name: [
{ required: true, message: this.$t('systemGenerate.inputName'), trigger: 'blur' },
{ required: true, message: this.$t('systemGenerate.inputName'), trigger: 'change' }
],
type:[
{ required: true, message: this.$t('systemGenerate.selectType'), trigger: 'change'}
],
prdCode:[
{ required: true, message: this.$t('systemGenerate.selectPrdName'), trigger: 'change'}
]
};
} else {
crules = {
name: [
{ required: true, message: this.$t('systemGenerate.inputName'), trigger: 'blur' },
{ required: true, message: this.$t('systemGenerate.inputName'), trigger: 'change' }
]
};
}
return crules;
}
};
},
mounted() {
this.loadInitData();
},
methods:{
loadInitData() {
this.projectList = [{value:'xty', label:'西铁院'}];
const customeredProductType = ConstConfig.ConstSelect.customeredProductType;
this.typeList = Cookies.get('user_lang') == 'en'
? customeredProductType.map(elem => { return { value: elem.value, label: elem.enlabel }; })
: customeredProductType.map(elem => { return { value: elem.value, label: elem.label }; });
listPublishMap().then(response => {
this.mapInfoList = response.data;
this.mapList = response.data.map(elem => { return { value: elem.id, label: elem.name }; });
});
},
changeMap(index) {
this.productList = [];
getCommodityMapProduct(index).then((response) => {
this.productList = response.data.map(elem => { return { value: elem.code, label: elem.name }; });
this.formModel.prdCode = '';
});
},
doShow(data) {
if (data) {
this.formModel.name = data.name;
this.formModel.id = data.id;
}
this.dialogVisible = true;
},
doCreate() {
const self = this;
this.$refs.dataform.validateForm(() => {
self.$emit('create', Object.assign({}, this.formModel));
self.doClose();
});
},
doClose() {
this.$refs.dataform.resetForm();
this.dialogVisible = false;
}
}
};
</script>
<style lang="scss" scoped>
/deep/ .el-dialog--center .el-dialog__body{