定价管理-属性管理-平台配置功能开发

This commit is contained in:
pengyh 2020-04-03 16:36:28 +08:00
parent f528103219
commit 5dfc994526
9 changed files with 661 additions and 162 deletions

View File

@ -151,3 +151,12 @@ export function getPlatformSetList(data) {
export function savePlatformSet(data) { export function savePlatformSet(data) {
return fetch.post('setting/save', data) return fetch.post('setting/save', data)
} }
/**
* [delPlatformSet 删除平台配置]
* @param {[type]} data [description]
* @return {[type]} [description]
*/
export function delPlatformSet(data) {
return fetch.post('setting/delete', data)
}

View File

@ -15,16 +15,16 @@
</Row> </Row>
<Row v-for="(item,index) in agentSetList" style="margin-bottom:10px"> <Row v-for="(item,index) in agentSetList" style="margin-bottom:10px">
<Col span="8"> <Col span="8">
<Select v-model="item.agentId" style="width:80%" placeholder="请选择机构" label-in-value @on-change="handleSelect($event,index)"> <Select v-model="item.info.agentId" style="width:80%" placeholder="请选择机构" label-in-value @on-change="handleSelect($event,index)" :disabled="item.id!=undefined">
<Option v-for="agent in agentList" :value="agent.id" :key="agent.id">{{ agent.name}}</Option> <Option v-for="agent in agentList" :value="agent.id" :key="agent.id">{{agent.name}}</Option>
</Select> </Select>
</Col> </Col>
<Col span="8"> <Col span="8">
<Input v-model="item.value" type="number" placeholder="请输入占比" clearable style="width:80%" /> <Input v-model="item.info.percent" type="number" placeholder="请输入占比" clearable style="width:80%"/>
</Col> </Col>
<Col span="8"> <Col span="8">
<Button type="primary" style="margin-right:20px" @click="cartypeSet(item)">配置车型</Button> <Button type="error" @click="delSet(item,index)" style="margin-right:20px">删除</Button>
<Button type="error" @click="delSet(index)">删除</Button> <Button v-if="item.info.agentId" type="primary" @click="cartypeSet(item,index)">配置车型</Button>
</Col> </Col>
</Row> </Row>
</div> </div>

View File

@ -15,16 +15,16 @@
</Row> </Row>
<Row v-for="(item,index) in carTypeSetList" style="margin-bottom:10px"> <Row v-for="(item,index) in carTypeSetList" style="margin-bottom:10px">
<Col span="8"> <Col span="8">
<Select v-model="item.carType" style="width:80%" placeholder="请选择车型" @on-change="handleSelect($event,index)"> <Select v-model="item.info.vehicleTypeName" style="width:80%" placeholder="请选择车型" label-in-value @on-change="handleSelect($event,index)" :disabled="item.id!=undefined">
<Option v-for="(cartype,key) in carTypeList" :value="key" :key="key">{{ key}}</Option> <Option v-for="(cartype,key) in carTypeList" :value="key" :key="key">{{ key}}</Option>
</Select> </Select>
</Col> </Col>
<Col span="8"> <Col span="8">
<Input v-model="item.value" type="number" placeholder="请输入占比" clearable style="width:80%" /> <Input v-model="item.info.percent" type="number" placeholder="请输入占比" clearable style="width:80%"/>
</Col> </Col>
<Col span="8"> <Col span="8">
<Button type="primary" style="margin-right:20px" @click="packageSet(item)">配置产品</Button> <Button type="error" @click="delSet(item,index)" style="margin-right:20px">删除</Button>
<Button type="error" @click="delSet(index)">删除</Button> <Button v-if="item.info.vehicleTypeName" type="primary" @click="packageSet(item,index)">配置产品</Button>
</Col> </Col>
</Row> </Row>
</div> </div>

View File

@ -13,23 +13,23 @@ export default {
type: [String, Number], type: [String, Number],
default: '' default: ''
}, },
name:{//企业名称 name: {//企业名称
type:String, type: String,
default:'' default: ''
}, },
packagetype: {//企业所属套餐类型 packagetype: {//企业所属套餐类型
type: String, type: String,
default: '', default: '',
}, },
applyid:{//平台应用ID用来获取车型 applyid: {//平台应用ID用来获取车型
type:[String,Number], type: [String, Number],
default:'' default: ''
}, },
propertyId: {//配置ID propertyId: {//配置ID
type: [String, Number], type: [String, Number],
default: '' default: ''
}, },
parentId:{//父级ID parentId: {//父级ID
type: [String, Number], type: [String, Number],
default: '' default: ''
} }
@ -39,42 +39,45 @@ export default {
my_show: false, my_show: false,
loading: false, loading: false,
agentList: [],//机构列表 agentList: [],//机构列表
agentSetList: [ agentSetList: [],//机构配置列表
{ cartype: {
agentId: '', show: false,
agentName: '',
value: '',
}
],
cartype:{
show:false,
title: '', title: '',
applyid:'',//平台应用id applyid: '',//平台应用id
id: '',//企业id id: '',//企业id
name:'',//企业名称 name: '',//企业名称
packagetype: '',//企业所属套餐类型 packagetype: '',//企业所属套餐类型
} propertyId: '',//配置ID
parentId: '',//父级ID
level: '',//层级标志
},
}; };
}, },
components: { components: {
cartypeSet: resolve => require(['views/virtual/properties/cartype_set'], resolve), cartypeSet: resolve => require(['views/virtual/properties/cartype_set'], resolve),
}, },
mounted() { mounted() {
this.$root.$on("close", data => {
this.visibleChange();
});
},
beforeDestroy() {
this.$root.$off("close");
}, },
watch: { watch: {
show(bool) { show(bool) {
this.my_show = bool; this.my_show = bool;
if (bool) { if (bool) {
this.getAgentsList() this.getAgentsList();
this.getPlatformSetList();
} }
}, },
}, },
methods: { methods: {
getAgentsList() { getAgentsList() {
let data = new Object; let data = new Object;
// data.id=this.id; data.id = this.id;
data.id = 21; // data.id = 21;
API.getAgentsList(data) API.getAgentsList(data)
.then(res => { .then(res => {
if (res.code == 0) { if (res.code == 0) {
@ -82,34 +85,171 @@ export default {
} }
}) })
}, },
getPlatformSetList() {
let data = new Object;
data.propertyId = this.propertyId;
data.parentId = this.parentId;
API.getPlatformSetList(data)
.then(res => {
if (res.code == 0) {
this.agentSetList = res.data;
}
})
},
addSet() { addSet() {
const index = this.agentSetList.length; const index = this.agentSetList.length;
const level = `#0#${this.parentId}`
const data = { const data = {
agentId: '', parentId: this.parentId,
agentName: '', propertyId: this.propertyId,
value: '', type: 1,
level: level,
info: {
agentId: '',//机构id
agentName: '',//机构名称
percent: '',//占比
} }
this.$set(this.agentSetList, index, data) }
this.$set(this.agentSetList, index, data);
}, },
handleSelect(data, index) { handleSelect(data, index) {
this.agentSetList[index].agentName = data.label; this.agentSetList.forEach((item, num) => {
if (index != num) {
if (item.info.agentId == data.value) {
this.$Message.error('机构不能重复');
this.$nextTick(() => {
this.$set(this.agentSetList[index].info, 'agentId', '')
})
}
}
})
this.agentSetList[index].info.agentName = data.label;
}, },
cartypeSet(data) { cartypeSet(data, index) {
this.cartype.show=true; const agentSetList = JSON.parse(JSON.stringify(this.agentSetList))
const title=this.title.split("-")[0]; let percentTotal = 0;
this.cartype.title=`${title}-${data.agentName}-车型配置`; let isSave = true;
let params = agentSetList.filter((item) => {
if (item.info.agentId) {
if (item.info.percent <= 0) {
this.$Message.error('每个机构占比必须大于零');
isSave = false;
} else {
percentTotal += Number(item.info.percent);
}
item.info = JSON.stringify(item.info);
return true;
} else {
return false;
}
})
if (percentTotal != 100) {
this.$Message.error('占比总和必须等于100');
return false;
}
if (!isSave) {
return false;
}
let obj = new Object;
obj.list = params;
API.savePlatformSet(obj)
.then(res => {
if (res.code == 0) {
this.agentSetList = res.data;
const title = this.title.split("-")[0];
this.cartype.title = `${title}-${data.info.agentName}-车型配置`;
this.cartype.id = this.id; this.cartype.id = this.id;
this.cartype.name=this.name; this.cartype.name = this.name;
this.cartype.packagetype = this.packagetype; this.cartype.packagetype = this.packagetype;
this.cartype.applyid=this.applyid; this.cartype.applyid = this.applyid;
this.cartype.propertyId = this.propertyId;
this.cartype.parentId = res.data[index].id;
this.cartype.level = res.data[index].level;
this.cartype.show = true;
}
})
}, },
delSet(data) { delSet(data, index) {
const _this = this;
if (data.id) {
this.$Modal.confirm({
title: '警告',
content: '删除后,会将后续配置全部删除!',
onOk: function () {
const agentSetList = JSON.parse(JSON.stringify(_this.agentSetList));
if (agentSetList.length != 1) {
let percentTotal = 0;
let isSave = true;
agentSetList.forEach((item, num) => {
if (item.info.agentId && index != num) {
if (item.info.percent <= 0) {
_this.$Message.error('删除项除外的每个机构占比必须大于零');
isSave = false;
} else {
percentTotal += Number(item.info.percent);
}
}
})
if (percentTotal != 100) {
_this.$Message.error('删除项除外占比总和必须等于100');
return false;
}
if (!isSave) {
return false;
}
}
let obj = new Object;
obj.id = data.id;
obj.level = data.level;
API.delPlatformSet(obj)
.then(res => {
if (res.code == 0) {
_this.agentSetList.splice(index, 1);
_this.delSave();
}
})
}
})
} else {
this.agentSetList.splice(data, 1) this.agentSetList.splice(data, 1)
}
},
delSave() {
const agentSetList = JSON.parse(JSON.stringify(this.agentSetList));
let params = agentSetList.filter((item) => {
if (item.info.agentId) {
item.info = JSON.stringify(item.info);
return true;
} else {
return false;
}
})
let obj = new Object;
obj.list = params;
API.savePlatformSet(obj)
.then(res => {
if (res.code == 0) {
this.agentSetList = res.data;
}
})
}, },
visibleChange(bool) { visibleChange(bool) {
if (!bool) { if (!bool) {
this.$emit('update:show', false); this.$emit('update:show', false);
} }
this.agentList = [];//机构列表
this.agentSetList = [];
this.cartype = {
show: false,
title: '',
applyid: '',//平台应用id
id: '',//企业id
name: '',//企业名称
packagetype: '',//企业所属套餐类型
propertyId: '',//配置ID
parentId: '',//父级ID
level: '',//层级标志
};
}, },
} }
}; };

View File

@ -24,6 +24,18 @@ export default {
applyid: {//平台应用ID用来获取车型 applyid: {//平台应用ID用来获取车型
type: [String, Number], type: [String, Number],
default: '' default: ''
},
propertyId: {//配置ID
type: [String, Number],
default: ''
},
parentId: {//父级ID
type: [String, Number],
default: ''
},
level: {//层级标志
type: String,
default: '',
} }
}, },
data() { data() {
@ -31,21 +43,25 @@ export default {
my_show: false, my_show: false,
loading: false, loading: false,
carTypeList: {},//车辆类型列表 carTypeList: {},//车辆类型列表
carTypeSetList: [ carTypeSetList: [],//车辆类型配置列表
{ package: {
carType: '', show: false,
value: '',
}
],
package:{
show:false,
title: '', title: '',
id: '',//企业id id: '',//企业id
packagetype: '',//校正过的套餐类型 packagetype: '',//校正过的套餐类型
} propertyId: '',//配置ID
parentId: '',//父级ID
level: '',//层级标志
},
}; };
}, },
mounted() { mounted() {
this.$root.$on("close", data => {
this.visibleChange();
});
},
beforeDestroy() {
this.$root.$off("close");
}, },
components: { components: {
packageSet: resolve => require(['views/virtual/properties/package_set'], resolve), packageSet: resolve => require(['views/virtual/properties/package_set'], resolve),
@ -55,14 +71,14 @@ export default {
this.my_show = bool; this.my_show = bool;
if (bool) { if (bool) {
this.getCarTypeList(); this.getCarTypeList();
this.getPlatformSetList();
} }
}, },
}, },
methods: { methods: {
getCarTypeList() { getCarTypeList() {
let data = new Object; let data = new Object;
// data.name=this.name; data.name = this.name;
data.name = '佛山市兴诺科技有限公司'
API.getApplyList(data) API.getApplyList(data)
.then(res => { .then(res => {
if (res.code == 0) { if (res.code == 0) {
@ -74,42 +90,167 @@ export default {
} }
}) })
}, },
getPlatformSetList() {
let data = new Object;
data.propertyId = this.propertyId;
data.parentId = this.parentId;
API.getPlatformSetList(data)
.then(res => {
if (res.code == 0) {
this.carTypeSetList = res.data;
}
})
},
addSet() { addSet() {
const index = this.carTypeSetList.length; const index = this.carTypeSetList.length;
const level = `${this.level}#${this.parentId}`
const data = { const data = {
carType: '', parentId: this.parentId,
value: '', propertyId: this.propertyId,
type: 2,
level: level,
info: {
vehicleTypeName: '',//车辆类型名称
parentName: '',//车辆类型所属分类名称
percent: '',//占比
} }
this.$set(this.carTypeSetList, index, data) }
this.$set(this.carTypeSetList, index, data);
},
delSet(data, index) {
const _this = this;
if (data.id) {
this.$Modal.confirm({
title: '警告',
content: '删除后,会将后续配置全部删除!',
onOk: function () {
const carTypeSetList = JSON.parse(JSON.stringify(_this.carTypeSetList));
if (carTypeSetList.length != 1) {
let percentTotal = 0;
let isSave = true;
carTypeSetList.forEach((item, num) => {
if (item.info.vehicleTypeName && index != num) {
if (item.info.percent <= 0) {
_this.$Message.error('删除项除外的每个车型占比必须大于零');
isSave = false;
} else {
percentTotal += Number(item.info.percent);
}
}
})
if (percentTotal != 100) {
_this.$Message.error('删除项除外占比总和必须等于100');
return false;
}
if (!isSave) {
return false;
}
}
let obj = new Object;
obj.id = data.id;
obj.level = data.level;
API.delPlatformSet(obj)
.then(res => {
if (res.code == 0) {
_this.carTypeSetList.splice(index, 1);
_this.delSave();
}
})
}
})
} else {
this.carTypeSetList.splice(index, 1);
}
},
delSave() {
const carTypeSetList = JSON.parse(JSON.stringify(this.carTypeSetList));
let params = carTypeSetList.filter((item) => {
if (item.info.vehicleTypeName) {
item.info = JSON.stringify(item.info);
return true;
} else {
return false;
}
})
let obj = new Object;
obj.list = params;
API.savePlatformSet(obj)
.then(res => {
if (res.code == 0) {
this.carTypeSetList = res.data;
}
})
}, },
handleSelect(data, index) { handleSelect(data, index) {
// console.log(this.packagetype) this.carTypeSetList.forEach((item, num) => {
if (index != num) {
if (item.info.vehicleTypeName == data.value) {
this.$Message.error('车型不能重复');
this.$nextTick(() => {
this.$set(this.carTypeSetList[index].info, 'vehicleTypeName', '')
})
}
}
})
this.carTypeSetList[index].info.parentName = data.label;
}, },
packageSet(data) { packageSet(data, index) {
this.hanlePackageType(data.carType) const carTypeSetList = JSON.parse(JSON.stringify(this.carTypeSetList))
const titleList=this.title.split('-'); let percentTotal = 0;
this.package.title=`${titleList[0]}-${titleList[1]}-${data.carType}-产品配置` let isSave = true;
// this.package.id=this.id; let params = carTypeSetList.filter((item) => {
this.package.id=21; if (item.info.vehicleTypeName) {
this.package.packagetype=this.hanlePackageType(data.carType); if (item.info.percent <= 0) {
this.package.show=true; this.$Message.error('每个平台占比必须大于零');
console.log(this.package) isSave = false;
} else {
percentTotal += Number(item.info.percent);
}
item.info = JSON.stringify(item.info);
return true;
} else {
return false;
}
})
if (percentTotal != 100) {
this.$Message.error('占比总和必须等于100');
return false;
}
if (!isSave) {
return false;
}
let obj = new Object;
obj.list = params;
API.savePlatformSet(obj)
.then(res => {
if (res.code == 0) {
this.carTypeSetList = res.data;
const titleList = this.title.split('-');
this.package.title = `${titleList[0]}-${titleList[1]}-${data.info.vehicleTypeName}-产品配置`
this.package.id = this.id;
this.package.packagetype = this.hanlePackageType(data.info.vehicleTypeName);
this.package.propertyId = this.propertyId;
this.package.parentId = res.data[index].id;
this.package.level = res.data[index].level;
this.package.show = true;
}
})
}, },
hanlePackageType(data){ hanlePackageType(data) {
const type=this.carTypeList[data]; const type = this.carTypeList[data];
let packagetype=''; let packagetype = '';
if((this.packagetype=='A' || this.packagetype=='C' || this.packagetype=='E')&& type=='商用车'){ if ((this.packagetype == 'A' || this.packagetype == 'C' || this.packagetype == 'E') && type == '商用车') {
packagetype='C类套餐' packagetype = 'C类套餐'
}else if((this.packagetype=='A' || this.packagetype=='C' || this.packagetype=='E')&& type=='乘用车'){ } else if ((this.packagetype == 'A' || this.packagetype == 'C' || this.packagetype == 'E') && type == '乘用车') {
packagetype='A类套餐' packagetype = 'A类套餐'
}else if((this.packagetype=='A' || this.packagetype=='C' || this.packagetype=='E')&& type=='其他'){ } else if ((this.packagetype == 'A' || this.packagetype == 'C' || this.packagetype == 'E') && type == '其他') {
packagetype='E类套餐' packagetype = 'E类套餐'
}else if((this.packagetype=='B' || this.packagetype=='D' || this.packagetype=='F')&& type=='商用车'){ } else if ((this.packagetype == 'B' || this.packagetype == 'D' || this.packagetype == 'F') && type == '商用车') {
packagetype='D类套餐' packagetype = 'D类套餐'
}else if((this.packagetype=='B' || this.packagetype=='D' || this.packagetype=='F')&& type=='乘用车'){ } else if ((this.packagetype == 'B' || this.packagetype == 'D' || this.packagetype == 'F') && type == '乘用车') {
packagetype='B类套餐' packagetype = 'B类套餐'
}else if((this.packagetype=='B' || this.packagetype=='D' || this.packagetype=='F')&& type=='乘用车'){ } else if ((this.packagetype == 'B' || this.packagetype == 'D' || this.packagetype == 'F') && type == '乘用车') {
packagetype='F类套餐' packagetype = 'F类套餐'
} }
return packagetype return packagetype
}, },
@ -117,6 +258,17 @@ export default {
if (!bool) { if (!bool) {
this.$emit('update:show', false); this.$emit('update:show', false);
} }
this.carTypeList = {};//车辆类型列表
this.carTypeSetList = [];
this.package = {
show: false,
title: '',
id: '',//企业id
packagetype: '',//校正过的套餐类型
propertyId: '',//配置ID
parentId: '',//父级ID
level: '',//层级标志
};
}, },
} }
}; };

View File

@ -16,19 +16,26 @@ export default {
packagetype: {//校正过的套餐类型 packagetype: {//校正过的套餐类型
type: String, type: String,
default: '', default: '',
},
propertyId: {//配置ID
type: [String, Number],
default: ''
},
parentId: {//父级ID
type: [String, Number],
default: ''
},
level: {//层级标志
type: String,
default: '',
} }
}, },
data() { data() {
return { return {
my_show: false, my_show: false,
loading: false, loading: false,
packageList:[], packageList: [],//套餐列表
packageSetList:[ packageSetList: [],//套餐配置列表
{
productName:'',//产品名称
percent:'',//占比
}
]
}; };
}, },
mounted() { mounted() {
@ -38,31 +45,163 @@ export default {
this.my_show = bool; this.my_show = bool;
if (bool) { if (bool) {
this.getPackageList(); this.getPackageList();
this.getPlatformSetList();
} }
}, },
}, },
methods: { methods: {
getPackageList() { getPackageList() {
let data = new Object; let data = new Object;
// data.id= this.id; data.id = this.id;
data.id = 21;
API.getPackageList(data) API.getPackageList(data)
.then(res => { .then(res => {
console.log(res) if (res.code == 0) {
if(res.code == 0){ this.packageList = res.data[this.packagetype]
console.log(this.packagetype) }
this.packageList=res.data[this.packagetype] })
console.log(this.packageList) },
getPlatformSetList() {
let data = new Object;
data.propertyId = this.propertyId;
data.parentId = this.parentId;
API.getPlatformSetList(data)
.then(res => {
if (res.code == 0) {
this.packageSetList = res.data;
} }
}) })
}, },
addSet() { addSet() {
const index = this.packageSetList.length;
const level = `${this.level}#${this.parentId}`
const data = {
parentId: this.parentId,
propertyId: this.propertyId,
type: 3,
level: level,
info: {
productName: '',//产品名称
percent: '',//占比
}
}
this.$set(this.packageSetList, index, data);
},
delSet(data, index) {
const _this = this;
if (data.id) {
this.$Modal.confirm({
title: '警告',
content: '确认要删除!',
onOk: function () {
const packageSetList = JSON.parse(JSON.stringify(_this.packageSetList));
if (packageSetList.length != 1) {
let percentTotal = 0;
let isSave = true;
packageSetList.forEach((item, num) => {
if (item.info.productName && index != num) {
if (item.info.percent <= 0) {
_this.$Message.error('删除项除外的每个产品占比必须大于零');
isSave = false;
} else {
percentTotal += Number(item.info.percent);
}
}
})
if (percentTotal != 100) {
_this.$Message.error('删除项除外占比总和必须等于100');
return false;
}
if (!isSave) {
return false;
}
}
let obj = new Object;
obj.id = data.id;
obj.level = data.level;
API.delPlatformSet(obj)
.then(res => {
if (res.code == 0) {
_this.packageSetList.splice(index, 1);
_this.delSave();
}
})
}
})
} else {
this.packageSetList.splice(index, 1);
}
},
delSave() {
const packageSetList = JSON.parse(JSON.stringify(this.packageSetList));
let params = packageSetList.filter((item) => {
if (item.info.productName) {
item.info = JSON.stringify(item.info);
return true;
} else {
return false;
}
})
let obj = new Object;
obj.list = params;
API.savePlatformSet(obj)
.then(res => {
if (res.code == 0) {
this.packageSetList = res.data;
}
})
},
handleSelect(data, index) {
this.packageSetList.forEach((item, num) => {
if (index != num) {
if (item.info.productName == data) {
this.$Message.error('产品不能重复');
this.$nextTick(() => {
this.$set(this.packageSetList[index].info, 'productName', '')
})
}
}
})
},
saveSet(data, index) {
const packageSetList = JSON.parse(JSON.stringify(this.packageSetList))
let percentTotal = 0;
let isSave = true;
let params = packageSetList.filter((item) => {
if (item.info.productName) {
if (item.info.percent <= 0) {
this.$Message.error('每个平台占比必须大于零');
isSave = false;
} else {
percentTotal += Number(item.info.percent);
}
item.info = JSON.stringify(item.info);
return true;
} else {
return false;
}
})
if (percentTotal != 100) {
this.$Message.error('占比总和必须等于100');
return false;
}
if (!isSave) {
return false;
}
let obj = new Object;
obj.list = params;
API.savePlatformSet(obj)
.then(res => {
if (res.code == 0) {
this.$root.$emit('close')
}
})
}, },
visibleChange(bool) { visibleChange(bool) {
if (!bool) { if (!bool) {
this.$emit('update:show', false); this.$emit('update:show', false);
} }
this.packageList = [];//套餐列表
this.packageSetList = [];//套餐配置列表
}, },
} }
}; };

View File

@ -27,7 +27,7 @@ export default {
my_show: false, my_show: false,
loading: false, loading: false,
applyList: [],//应用平台列表 applyList: [],//应用平台列表
applySetList: [], applySetList: [],//应用平台配置列表
agent: { agent: {
show: false, show: false,
title: '', title: '',
@ -38,15 +38,18 @@ export default {
propertyId: '',//配置ID propertyId: '',//配置ID
parentId: '',//父级ID parentId: '',//父级ID
}, },
percentList: {},//储存每个占比的数据
applyidList: {},//储存每个平台ID的数据
}; };
}, },
components: { components: {
agentSet: resolve => require(['views/virtual/properties/agent_set'], resolve), agentSet: resolve => require(['views/virtual/properties/agent_set'], resolve),
}, },
mounted() { mounted() {
this.getApplyList(); this.$root.$on("close", data => {
this.visibleChange();
});
},
beforeDestroy() {
this.$root.$off("close");
}, },
watch: { watch: {
show(bool) { show(bool) {
@ -61,6 +64,7 @@ export default {
getApplyList() { getApplyList() {
let data = new Object; let data = new Object;
data.name = this.name; data.name = this.name;
// data.name = '佛山市兴诺科技有限公司';
API.getApplyList(data) API.getApplyList(data)
.then(res => { .then(res => {
if (res.code == 0) { if (res.code == 0) {
@ -79,22 +83,21 @@ export default {
API.getPlatformSetList(data) API.getPlatformSetList(data)
.then(res => { .then(res => {
if (res.code == 0) { if (res.code == 0) {
res.data.forEach(item=>{
this.percentList[item.info.appId]=Number(item.info.percent);
this.applyidList[item.info.appId]=1;
})
this.applySetList = res.data; this.applySetList = res.data;
} }
}) })
}, },
handleSelect(data, index) { handleSelect(data, index) {
if (this.applyidList[data.value]) { this.applySetList.forEach((item, num) => {
if (index != num) {
if (item.info.appId == data.value) {
this.$Message.error('平台不能重复'); this.$Message.error('平台不能重复');
this.$refs.sel[index].clearSingleSelect(); this.$nextTick(() => {
} else { this.$set(this.applySetList[index].info, 'appId', '')
this.applyidList[data.value] = 1; })
this.percentList[data.value] = 0;
} }
}
})
this.applyList.forEach(item => { this.applyList.forEach(item => {
if (item.id == data.value) { if (item.id == data.value) {
this.applySetList[index].info.appName = item.name; this.applySetList[index].info.appName = item.name;
@ -102,12 +105,6 @@ export default {
} }
}) })
}, },
handleInput(data, appId) {
if (data <= 0) {
this.$Message.error('占比必须大于零');
}
this.percentList[appId] = Number(data);
},
addSet() { addSet() {
const index = this.applySetList.length; const index = this.applySetList.length;
const data = { const data = {
@ -124,26 +121,101 @@ export default {
} }
this.$set(this.applySetList, index, data) this.$set(this.applySetList, index, data)
}, },
agentSet(data,index) { agentSet(data, index) {
let percentTotal = 0 const applySetList = JSON.parse(JSON.stringify(this.applySetList))
for (let k in this.percentList) { let percentTotal = 0;
if (this.percentList[k] <= 0) { let isSave = true;
let params = applySetList.filter((item) => {
if (item.info.appId) {
if (item.info.percent <= 0) {
this.$Message.error('每个平台占比必须大于零'); this.$Message.error('每个平台占比必须大于零');
return false isSave = false;
} else {
percentTotal += Number(item.info.percent);
} }
percentTotal += this.percentList[k]; item.info = JSON.stringify(item.info);
return true;
} else {
return false;
} }
})
if (percentTotal != 100) { if (percentTotal != 100) {
this.$Message.error('占比总和必须等于100'); this.$Message.error('占比总和必须等于100');
return return false;
} }
const applySetList = JSON.parse(JSON.stringify(this.applySetList)) if (!isSave) {
let params = applySetList.filter(item => { return false;
}
let obj = new Object;
obj.list = params;
API.savePlatformSet(obj)
.then(res => {
if (res.code == 0) {
this.applySetList = res.data;
this.agent.id = this.id;
this.agent.name = this.name;
this.agent.packagetype = this.packagetype;
this.agent.applyid = data.info.appId;
this.agent.title = `${data.info.appType}-下级机构配置`;
this.agent.propertyId = this.propertyId;
this.agent.parentId = res.data[index].id;
this.agent.show = true;
}
})
},
delSet(data, index) {
const _this = this;
if (data.id) {
this.$Modal.confirm({
title: '警告',
content: '删除后,会将后续配置全部删除!',
onOk: function () {
const applySetList = JSON.parse(JSON.stringify(_this.applySetList));
if (applySetList.length != 1) {
let percentTotal = 0;
let isSave = true;
applySetList.forEach((item, num) => {
if (item.info.appId && index != num) {
if (item.info.percent <= 0) {
_this.$Message.error('删除项除外的每个平台占比必须大于零');
isSave = false;
} else {
percentTotal += Number(item.info.percent);
}
}
})
if (percentTotal != 100) {
_this.$Message.error('删除项除外占比总和必须等于100');
return false;
}
if (!isSave) {
return false;
}
}
let obj = new Object;
obj.id = data.id;
obj.level = data.level;
API.delPlatformSet(obj)
.then(res => {
if (res.code == 0) {
_this.applySetList.splice(index, 1);
_this.delSave();
}
})
}
})
} else {
this.applySetList.splice(index, 1);
}
},
delSave() {
const applySetList = JSON.parse(JSON.stringify(this.applySetList));
let params = applySetList.filter((item) => {
if (item.info.appId) { if (item.info.appId) {
item.info = JSON.stringify(item.info); item.info = JSON.stringify(item.info);
return true return true;
} else { } else {
return false return false;
} }
}) })
let obj = new Object; let obj = new Object;
@ -151,20 +223,10 @@ export default {
API.savePlatformSet(obj) API.savePlatformSet(obj)
.then(res => { .then(res => {
if (res.code == 0) { if (res.code == 0) {
this.agent.id = this.id; this.applySetList = res.data;
this.agent.name = this.name;
this.agent.packagetype = this.packagetype;
this.agent.applyid = data.info.appId;
this.agent.title = `${data.info.appName}-下级机构配置`;
this.agent.propertyId = this.propertyId;
this.agent.parentId = res.data[index].id;
this.agent.show = true;
} }
}) })
}, },
delSet(data) {
this.applySetList.splice(data, 1)
},
visibleChange(bool) { visibleChange(bool) {
if (!bool) { if (!bool) {
this.$emit('update:show', false); this.$emit('update:show', false);
@ -181,9 +243,6 @@ export default {
propertyId: '',//配置ID propertyId: '',//配置ID
parentId: '',//父级ID parentId: '',//父级ID
}; };
this.percentList = {};
this.applyidList = {};
}, },
} }
}; };

View File

@ -13,17 +13,18 @@
<Col span="10">占比</Col> <Col span="10">占比</Col>
<Col span="2">操作</Col> <Col span="2">操作</Col>
</Row> </Row>
<Row v-for="item in packageSetList" style="margin-bottom:10px"> <Row v-for="(item,index) in packageSetList" style="margin-bottom:10px">
<Col span="12"> <Col span="8">
<Select v-model="item.productName" style="width:80%" placeholder="请选择平台"> <Select v-model="item.info.productName" style="width:80%" placeholder="请选择产品" @on-change="handleSelect($event,index)" :disabled="item.id!=undefined">
<Option v-for="a in packageList" :value="a">{{a}}</Option> <Option v-for="otem in packageList" :value="otem" :key="otem">{{otem}}</Option>
</Select> </Select>
</Col> </Col>
<Col span="10"> <Col span="8">
<Input v-model="item.percent" type="number" placeholder="请输入占比" clearable style="width:80%" /> <Input v-model="item.info.percent" type="number" placeholder="请输入占比" clearable style="width:80%" />
</Col> </Col>
<Col span="2"> <Col span="8">
<Button type="error">删除</Button> <Button type="error" @click="delSet(item,index)" style="margin-right:20px">删除</Button>
<Button v-if="item.info.productName" type="primary" @click="saveSet(item,index)">保存配置</Button>
</Col> </Col>
</Row> </Row>
</div> </div>

View File

@ -15,17 +15,16 @@
</Row> </Row>
<Row v-for="(item,index) in applySetList" style="margin-bottom:10px"> <Row v-for="(item,index) in applySetList" style="margin-bottom:10px">
<Col span="8"> <Col span="8">
<Select ref="sel" v-model="item.info.appId" clearable style="width:80%" placeholder="请选择平台" label-in-value @on-change="handleSelect($event,index)"> <Select v-model="item.info.appId" style="width:80%" placeholder="请选择平台" label-in-value @on-change="handleSelect($event,index)" :disabled="item.id!=undefined">
<Option v-for="apply in applyList" :value="apply.id" :key="apply.id">{{ apply.appType}}</Option> <Option v-for="apply in applyList" :value="apply.id" :key="apply.id">{{ apply.appType}}</Option>
</Select> </Select>
</Col> </Col>
<Col span="8"> <Col span="8">
<Input v-if="item.info.appId" v-model="item.info.percent" type="number" placeholder="请输入占比" clearable style="width:80%" @on-change="handleInput(item.info.percent,item.info.appId)"/> <Input v-model="item.info.percent" type="number" placeholder="请输入占比" clearable style="width:80%"/>
<div v-else style="width:80%;height:10px"></div>
</Col> </Col>
<Col span="8"> <Col span="8">
<Button v-if="item.info.appId" type="primary" style="margin-right:20px" @click="agentSet(item,index)">配置下级机构</Button> <Button type="error" @click="delSet(item,index)" style="margin-right:20px">删除</Button>
<Button type="error" @click="delSet(index)">删除</Button> <Button v-if="item.info.appId" type="primary" @click="agentSet(item,index)">配置下级机构</Button>
</Col> </Col>
</Row> </Row>
</div> </div>