修改接口:/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

@ -124,17 +124,10 @@ export default {
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 res = await getCommodityMapProduct(val);
const data = res.data;
if (data && data.length) {
data.forEach(elem => {
@ -144,7 +137,6 @@ export default {
} catch (error) {
console.error(error);
}
}
},
show(data) {
this.dialogVisible = true;

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';
@ -208,14 +207,12 @@ export default {
this.formModel.prdCode = '';
this.formModel.lessonId = '';
this.mapProductList = [];
getPublishMapInfo(mapId).then(resp => {
getCommodityMapProduct(resp.data.skinCode).then(rest => {
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 = '';

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';
@ -142,8 +142,7 @@ export default {
},
async computedMapProduct(item) {
let name = '';
const resp = await getPublishMapInfo(item.mapId);
const rest = await getCommodityMapProduct(resp.data.skinCode);
const rest = await getCommodityMapProduct(item.mapId);
const list = rest.data || [];
list.forEach(elem => {
if (elem.id == item.mapProductCode) {
@ -206,14 +205,12 @@ export default {
item.prdCode == elem.prdCode &&
item.permissionType == elem.permissionType;
});
getPublishMapInfo(item.mapId).then(resp => {
getCommodityMapProduct(resp.data.skinCode).then(rest => {
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 {

View File

@ -1,21 +1,25 @@
<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>
<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>
<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 {
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,
@ -27,118 +31,110 @@
typeList:[],
formModel:{
mapId:'',
name: "",
prdCode: "",
type: "",
id:null,
name: '',
prdCode: '',
type: '',
id:null
}
};
},
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();
},
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 } });
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=[];
let mapInfo=this.mapInfoList.find(elem=>{
return elem.id==index;
this.mapInfoList = response.data;
this.mapList = response.data.map(elem => { return { value: elem.id, label: elem.name }; });
});
getCommodityMapProduct(mapInfo.skinCode).then((response) => {
this.productList = response.data.map(elem => { return { value: elem.code, label: elem.name } });
this.formModel.prdCode="";
},
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;
if (data) {
this.formModel.name = data.name;
this.formModel.id = data.id;
}
this.dialogVisible = true
this.dialogVisible = true;
},
doCreate() {
let self = this
const self = this;
this.$refs.dataform.validateForm(() => {
self.$emit('create', Object.assign({}, this.formModel));
self.doClose()
})
self.doClose();
});
},
doClose() {
this.$refs.dataform.resetForm();
this.dialogVisible = false
this.dialogVisible = false;
}
}
};
};
</script>
<style lang="scss" scoped>
/deep/ .el-dialog--center .el-dialog__body{