修改接口:/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({ return request({
url: `/api/mapPrd/${skinCode}/list`, url: `/api/mapPrd/${mapId}/list`,
method: 'get' method: 'get'
}); });
} }

View File

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

View File

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

View File

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

View File

@ -124,17 +124,10 @@ export default {
this.formModel.userId = item.id; this.formModel.userId = item.id;
}, },
async mapChange(val) { async mapChange(val) {
let skinCode = '';
this.mapPrdList = []; this.mapPrdList = [];
this.formModel.mapPrdCode = ''; this.formModel.mapPrdCode = '';
if (this.LessonList.length) {
this.LessonList.forEach(item => {
if (item.value == val) {
skinCode = item.skinCode;
}
});
try { try {
const res = await getCommodityMapProduct(skinCode); const res = await getCommodityMapProduct(val);
const data = res.data; const data = res.data;
if (data && data.length) { if (data && data.length) {
data.forEach(elem => { data.forEach(elem => {
@ -144,7 +137,6 @@ export default {
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }
}
}, },
show(data) { show(data) {
this.dialogVisible = true; this.dialogVisible = true;

View File

@ -10,7 +10,6 @@
</template> </template>
<script> <script>
import { getPublishMapInfo } from '@/api/jmap/map';
import { getCommodityMapProduct } from '@/api/management/mapprd'; import { getCommodityMapProduct } from '@/api/management/mapprd';
import { OperatorModel, PermissionType } from '@/scripts/ConstDic'; import { OperatorModel, PermissionType } from '@/scripts/ConstDic';
import { getTotalRemains } from '@/api/management/author'; import { getTotalRemains } from '@/api/management/author';
@ -208,14 +207,12 @@ export default {
this.formModel.prdCode = ''; this.formModel.prdCode = '';
this.formModel.lessonId = ''; this.formModel.lessonId = '';
this.mapProductList = []; this.mapProductList = [];
getPublishMapInfo(mapId).then(resp => { getCommodityMapProduct(mapId).then(rest => {
getCommodityMapProduct(resp.data.skinCode).then(rest => {
const list = rest.data || []; const list = rest.data || [];
this.mapProductList = list.map(elem => { this.mapProductList = list.map(elem => {
return { value: elem.code, label: elem.name }; return { value: elem.code, label: elem.name };
}); });
}); });
});
}, },
mapProductChange(prdCode) { mapProductChange(prdCode) {
this.formModel.lessonId = ''; this.formModel.lessonId = '';

View File

@ -70,7 +70,7 @@
</template> </template>
<script> <script>
import { listPublishMap, getPublishMapInfo } from '@/api/jmap/map'; import { listPublishMap } from '@/api/jmap/map';
import { getPublishLessonList } from '@/api/jmap/lesson'; import { getPublishLessonList } from '@/api/jmap/lesson';
import { getCommodityMapProduct } from '@/api/management/mapprd'; import { getCommodityMapProduct } from '@/api/management/mapprd';
import { packagePermissionDistribute } from '@/api/management/distribute'; import { packagePermissionDistribute } from '@/api/management/distribute';
@ -142,8 +142,7 @@ export default {
}, },
async computedMapProduct(item) { async computedMapProduct(item) {
let name = ''; let name = '';
const resp = await getPublishMapInfo(item.mapId); const rest = await getCommodityMapProduct(item.mapId);
const rest = await getCommodityMapProduct(resp.data.skinCode);
const list = rest.data || []; const list = rest.data || [];
list.forEach(elem => { list.forEach(elem => {
if (elem.id == item.mapProductCode) { if (elem.id == item.mapProductCode) {
@ -206,14 +205,12 @@ export default {
item.prdCode == elem.prdCode && item.prdCode == elem.prdCode &&
item.permissionType == elem.permissionType; item.permissionType == elem.permissionType;
}); });
getPublishMapInfo(item.mapId).then(resp => { getCommodityMapProduct(item.mapId).then(rest => {
getCommodityMapProduct(resp.data.skinCode).then(rest => {
const list = rest.data || []; const list = rest.data || [];
this.mapProductList = list.map(elem => { this.mapProductList = list.map(elem => {
return { value: elem.code, label: elem.name }; return { value: elem.code, label: elem.name };
}); });
}); });
});
if (index < 0) { if (index < 0) {
this.ruleList.push(item); this.ruleList.push(item);
} else { } else {

View File

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