定价管理-属性管理-平台配置功能开发
This commit is contained in:
parent
f528103219
commit
5dfc994526
@ -151,3 +151,12 @@ export function getPlatformSetList(data) {
|
||||
export function savePlatformSet(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)
|
||||
}
|
@ -15,16 +15,16 @@
|
||||
</Row>
|
||||
<Row v-for="(item,index) in agentSetList" style="margin-bottom:10px">
|
||||
<Col span="8">
|
||||
<Select v-model="item.agentId" style="width:80%" placeholder="请选择机构" label-in-value @on-change="handleSelect($event,index)">
|
||||
<Option v-for="agent in agentList" :value="agent.id" :key="agent.id">{{ agent.name}}</Option>
|
||||
<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>
|
||||
</Select>
|
||||
</Col>
|
||||
<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 span="8">
|
||||
<Button type="primary" style="margin-right:20px" @click="cartypeSet(item)">配置车型</Button>
|
||||
<Button type="error" @click="delSet(index)">删除</Button>
|
||||
<Button type="error" @click="delSet(item,index)" style="margin-right:20px">删除</Button>
|
||||
<Button v-if="item.info.agentId" type="primary" @click="cartypeSet(item,index)">配置车型</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
|
@ -15,16 +15,16 @@
|
||||
</Row>
|
||||
<Row v-for="(item,index) in carTypeSetList" style="margin-bottom:10px">
|
||||
<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>
|
||||
</Select>
|
||||
</Col>
|
||||
<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 span="8">
|
||||
<Button type="primary" style="margin-right:20px" @click="packageSet(item)">配置产品</Button>
|
||||
<Button type="error" @click="delSet(index)">删除</Button>
|
||||
<Button type="error" @click="delSet(item,index)" style="margin-right:20px">删除</Button>
|
||||
<Button v-if="item.info.vehicleTypeName" type="primary" @click="packageSet(item,index)">配置产品</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
|
@ -13,23 +13,23 @@ export default {
|
||||
type: [String, Number],
|
||||
default: ''
|
||||
},
|
||||
name:{//企业名称
|
||||
type:String,
|
||||
default:''
|
||||
name: {//企业名称
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
packagetype: {//企业所属套餐类型
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
applyid:{//平台应用ID用来获取车型
|
||||
type:[String,Number],
|
||||
default:''
|
||||
applyid: {//平台应用ID用来获取车型
|
||||
type: [String, Number],
|
||||
default: ''
|
||||
},
|
||||
propertyId: {//配置ID
|
||||
type: [String, Number],
|
||||
default: ''
|
||||
},
|
||||
parentId:{//父级ID
|
||||
parentId: {//父级ID
|
||||
type: [String, Number],
|
||||
default: ''
|
||||
}
|
||||
@ -39,42 +39,45 @@ export default {
|
||||
my_show: false,
|
||||
loading: false,
|
||||
agentList: [],//机构列表
|
||||
agentSetList: [
|
||||
{
|
||||
agentId: '',
|
||||
agentName: '',
|
||||
value: '',
|
||||
}
|
||||
],
|
||||
cartype:{
|
||||
show:false,
|
||||
agentSetList: [],//机构配置列表
|
||||
cartype: {
|
||||
show: false,
|
||||
title: '',
|
||||
applyid:'',//平台应用id
|
||||
applyid: '',//平台应用id
|
||||
id: '',//企业id
|
||||
name:'',//企业名称
|
||||
name: '',//企业名称
|
||||
packagetype: '',//企业所属套餐类型
|
||||
}
|
||||
|
||||
propertyId: '',//配置ID
|
||||
parentId: '',//父级ID
|
||||
level: '',//层级标志
|
||||
},
|
||||
};
|
||||
},
|
||||
components: {
|
||||
cartypeSet: resolve => require(['views/virtual/properties/cartype_set'], resolve),
|
||||
},
|
||||
mounted() {
|
||||
this.$root.$on("close", data => {
|
||||
this.visibleChange();
|
||||
});
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$root.$off("close");
|
||||
},
|
||||
watch: {
|
||||
show(bool) {
|
||||
this.my_show = bool;
|
||||
if (bool) {
|
||||
this.getAgentsList()
|
||||
this.getAgentsList();
|
||||
this.getPlatformSetList();
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getAgentsList() {
|
||||
let data = new Object;
|
||||
// data.id=this.id;
|
||||
data.id = 21;
|
||||
data.id = this.id;
|
||||
// data.id = 21;
|
||||
API.getAgentsList(data)
|
||||
.then(res => {
|
||||
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() {
|
||||
const index = this.agentSetList.length;
|
||||
const level = `#0#${this.parentId}`
|
||||
const data = {
|
||||
agentId: '',
|
||||
agentName: '',
|
||||
value: '',
|
||||
parentId: this.parentId,
|
||||
propertyId: this.propertyId,
|
||||
type: 1,
|
||||
level: level,
|
||||
info: {
|
||||
agentId: '',//机构id
|
||||
agentName: '',//机构名称
|
||||
percent: '',//占比
|
||||
}
|
||||
}
|
||||
this.$set(this.agentSetList, index, data)
|
||||
this.$set(this.agentSetList, index, data);
|
||||
},
|
||||
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) {
|
||||
this.cartype.show=true;
|
||||
const title=this.title.split("-")[0];
|
||||
this.cartype.title=`${title}-${data.agentName}-车型配置`;
|
||||
this.cartype.id = this.id;
|
||||
this.cartype.name=this.name;
|
||||
this.cartype.packagetype = this.packagetype;
|
||||
this.cartype.applyid=this.applyid;
|
||||
cartypeSet(data, index) {
|
||||
const agentSetList = JSON.parse(JSON.stringify(this.agentSetList))
|
||||
let percentTotal = 0;
|
||||
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.name = this.name;
|
||||
this.cartype.packagetype = this.packagetype;
|
||||
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) {
|
||||
this.agentSetList.splice(data, 1)
|
||||
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)
|
||||
}
|
||||
},
|
||||
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) {
|
||||
if (!bool) {
|
||||
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: '',//层级标志
|
||||
};
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -24,6 +24,18 @@ export default {
|
||||
applyid: {//平台应用ID用来获取车型
|
||||
type: [String, Number],
|
||||
default: ''
|
||||
},
|
||||
propertyId: {//配置ID
|
||||
type: [String, Number],
|
||||
default: ''
|
||||
},
|
||||
parentId: {//父级ID
|
||||
type: [String, Number],
|
||||
default: ''
|
||||
},
|
||||
level: {//层级标志
|
||||
type: String,
|
||||
default: '',
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@ -31,21 +43,25 @@ export default {
|
||||
my_show: false,
|
||||
loading: false,
|
||||
carTypeList: {},//车辆类型列表
|
||||
carTypeSetList: [
|
||||
{
|
||||
carType: '',
|
||||
value: '',
|
||||
}
|
||||
],
|
||||
package:{
|
||||
show:false,
|
||||
carTypeSetList: [],//车辆类型配置列表
|
||||
package: {
|
||||
show: false,
|
||||
title: '',
|
||||
id: '',//企业id
|
||||
packagetype: '',//校正过的套餐类型
|
||||
}
|
||||
propertyId: '',//配置ID
|
||||
parentId: '',//父级ID
|
||||
level: '',//层级标志
|
||||
},
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.$root.$on("close", data => {
|
||||
this.visibleChange();
|
||||
});
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$root.$off("close");
|
||||
},
|
||||
components: {
|
||||
packageSet: resolve => require(['views/virtual/properties/package_set'], resolve),
|
||||
@ -55,14 +71,14 @@ export default {
|
||||
this.my_show = bool;
|
||||
if (bool) {
|
||||
this.getCarTypeList();
|
||||
this.getPlatformSetList();
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getCarTypeList() {
|
||||
let data = new Object;
|
||||
// data.name=this.name;
|
||||
data.name = '佛山市兴诺科技有限公司'
|
||||
data.name = this.name;
|
||||
API.getApplyList(data)
|
||||
.then(res => {
|
||||
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() {
|
||||
const index = this.carTypeSetList.length;
|
||||
const level = `${this.level}#${this.parentId}`
|
||||
const data = {
|
||||
carType: '',
|
||||
value: '',
|
||||
parentId: this.parentId,
|
||||
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) {
|
||||
// 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) {
|
||||
this.hanlePackageType(data.carType)
|
||||
const titleList=this.title.split('-');
|
||||
this.package.title=`${titleList[0]}-${titleList[1]}-${data.carType}-产品配置`
|
||||
// this.package.id=this.id;
|
||||
this.package.id=21;
|
||||
this.package.packagetype=this.hanlePackageType(data.carType);
|
||||
this.package.show=true;
|
||||
console.log(this.package)
|
||||
packageSet(data, index) {
|
||||
const carTypeSetList = JSON.parse(JSON.stringify(this.carTypeSetList))
|
||||
let percentTotal = 0;
|
||||
let isSave = true;
|
||||
let params = carTypeSetList.filter((item) => {
|
||||
if (item.info.vehicleTypeName) {
|
||||
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.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){
|
||||
const type=this.carTypeList[data];
|
||||
let packagetype='';
|
||||
if((this.packagetype=='A' || this.packagetype=='C' || this.packagetype=='E')&& type=='商用车'){
|
||||
packagetype='C类套餐'
|
||||
}else if((this.packagetype=='A' || this.packagetype=='C' || this.packagetype=='E')&& type=='乘用车'){
|
||||
packagetype='A类套餐'
|
||||
}else if((this.packagetype=='A' || this.packagetype=='C' || this.packagetype=='E')&& type=='其他'){
|
||||
packagetype='E类套餐'
|
||||
}else if((this.packagetype=='B' || this.packagetype=='D' || this.packagetype=='F')&& type=='商用车'){
|
||||
packagetype='D类套餐'
|
||||
}else if((this.packagetype=='B' || this.packagetype=='D' || this.packagetype=='F')&& type=='乘用车'){
|
||||
packagetype='B类套餐'
|
||||
}else if((this.packagetype=='B' || this.packagetype=='D' || this.packagetype=='F')&& type=='乘用车'){
|
||||
packagetype='F类套餐'
|
||||
hanlePackageType(data) {
|
||||
const type = this.carTypeList[data];
|
||||
let packagetype = '';
|
||||
if ((this.packagetype == 'A' || this.packagetype == 'C' || this.packagetype == 'E') && type == '商用车') {
|
||||
packagetype = 'C类套餐'
|
||||
} else if ((this.packagetype == 'A' || this.packagetype == 'C' || this.packagetype == 'E') && type == '乘用车') {
|
||||
packagetype = 'A类套餐'
|
||||
} else if ((this.packagetype == 'A' || this.packagetype == 'C' || this.packagetype == 'E') && type == '其他') {
|
||||
packagetype = 'E类套餐'
|
||||
} else if ((this.packagetype == 'B' || this.packagetype == 'D' || this.packagetype == 'F') && type == '商用车') {
|
||||
packagetype = 'D类套餐'
|
||||
} else if ((this.packagetype == 'B' || this.packagetype == 'D' || this.packagetype == 'F') && type == '乘用车') {
|
||||
packagetype = 'B类套餐'
|
||||
} else if ((this.packagetype == 'B' || this.packagetype == 'D' || this.packagetype == 'F') && type == '乘用车') {
|
||||
packagetype = 'F类套餐'
|
||||
}
|
||||
return packagetype
|
||||
},
|
||||
@ -117,6 +258,17 @@ export default {
|
||||
if (!bool) {
|
||||
this.$emit('update:show', false);
|
||||
}
|
||||
this.carTypeList = {};//车辆类型列表
|
||||
this.carTypeSetList = [];
|
||||
this.package = {
|
||||
show: false,
|
||||
title: '',
|
||||
id: '',//企业id
|
||||
packagetype: '',//校正过的套餐类型
|
||||
propertyId: '',//配置ID
|
||||
parentId: '',//父级ID
|
||||
level: '',//层级标志
|
||||
};
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -16,19 +16,26 @@ export default {
|
||||
packagetype: {//校正过的套餐类型
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
propertyId: {//配置ID
|
||||
type: [String, Number],
|
||||
default: ''
|
||||
},
|
||||
parentId: {//父级ID
|
||||
type: [String, Number],
|
||||
default: ''
|
||||
},
|
||||
level: {//层级标志
|
||||
type: String,
|
||||
default: '',
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
my_show: false,
|
||||
loading: false,
|
||||
packageList:[],
|
||||
packageSetList:[
|
||||
{
|
||||
productName:'',//产品名称
|
||||
percent:'',//占比
|
||||
}
|
||||
]
|
||||
packageList: [],//套餐列表
|
||||
packageSetList: [],//套餐配置列表
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
@ -38,31 +45,163 @@ export default {
|
||||
this.my_show = bool;
|
||||
if (bool) {
|
||||
this.getPackageList();
|
||||
this.getPlatformSetList();
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getPackageList() {
|
||||
let data = new Object;
|
||||
// data.id= this.id;
|
||||
data.id = 21;
|
||||
data.id = this.id;
|
||||
API.getPackageList(data)
|
||||
.then(res => {
|
||||
console.log(res)
|
||||
if(res.code == 0){
|
||||
console.log(this.packagetype)
|
||||
this.packageList=res.data[this.packagetype]
|
||||
console.log(this.packageList)
|
||||
if (res.code == 0) {
|
||||
this.packageList = res.data[this.packagetype]
|
||||
}
|
||||
})
|
||||
},
|
||||
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() {
|
||||
|
||||
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) {
|
||||
if (!bool) {
|
||||
this.$emit('update:show', false);
|
||||
}
|
||||
this.packageList = [];//套餐列表
|
||||
this.packageSetList = [];//套餐配置列表
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -27,7 +27,7 @@ export default {
|
||||
my_show: false,
|
||||
loading: false,
|
||||
applyList: [],//应用平台列表
|
||||
applySetList: [],
|
||||
applySetList: [],//应用平台配置列表
|
||||
agent: {
|
||||
show: false,
|
||||
title: '',
|
||||
@ -38,15 +38,18 @@ export default {
|
||||
propertyId: '',//配置ID
|
||||
parentId: '',//父级ID
|
||||
},
|
||||
percentList: {},//储存每个占比的数据
|
||||
applyidList: {},//储存每个平台ID的数据
|
||||
};
|
||||
},
|
||||
components: {
|
||||
agentSet: resolve => require(['views/virtual/properties/agent_set'], resolve),
|
||||
},
|
||||
mounted() {
|
||||
this.getApplyList();
|
||||
this.$root.$on("close", data => {
|
||||
this.visibleChange();
|
||||
});
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$root.$off("close");
|
||||
},
|
||||
watch: {
|
||||
show(bool) {
|
||||
@ -61,6 +64,7 @@ export default {
|
||||
getApplyList() {
|
||||
let data = new Object;
|
||||
data.name = this.name;
|
||||
// data.name = '佛山市兴诺科技有限公司';
|
||||
API.getApplyList(data)
|
||||
.then(res => {
|
||||
if (res.code == 0) {
|
||||
@ -79,22 +83,21 @@ export default {
|
||||
API.getPlatformSetList(data)
|
||||
.then(res => {
|
||||
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;
|
||||
}
|
||||
})
|
||||
},
|
||||
handleSelect(data, index) {
|
||||
if (this.applyidList[data.value]) {
|
||||
this.$Message.error('平台不能重复');
|
||||
this.$refs.sel[index].clearSingleSelect();
|
||||
} else {
|
||||
this.applyidList[data.value] = 1;
|
||||
this.percentList[data.value] = 0;
|
||||
}
|
||||
this.applySetList.forEach((item, num) => {
|
||||
if (index != num) {
|
||||
if (item.info.appId == data.value) {
|
||||
this.$Message.error('平台不能重复');
|
||||
this.$nextTick(() => {
|
||||
this.$set(this.applySetList[index].info, 'appId', '')
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
this.applyList.forEach(item => {
|
||||
if (item.id == data.value) {
|
||||
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() {
|
||||
const index = this.applySetList.length;
|
||||
const data = {
|
||||
@ -124,26 +121,101 @@ export default {
|
||||
}
|
||||
this.$set(this.applySetList, index, data)
|
||||
},
|
||||
agentSet(data,index) {
|
||||
let percentTotal = 0
|
||||
for (let k in this.percentList) {
|
||||
if (this.percentList[k] <= 0) {
|
||||
this.$Message.error('每个平台占比必须大于零');
|
||||
return false
|
||||
agentSet(data, index) {
|
||||
const applySetList = JSON.parse(JSON.stringify(this.applySetList))
|
||||
let percentTotal = 0;
|
||||
let isSave = true;
|
||||
let params = applySetList.filter((item) => {
|
||||
if (item.info.appId) {
|
||||
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;
|
||||
}
|
||||
percentTotal += this.percentList[k];
|
||||
}
|
||||
})
|
||||
if (percentTotal != 100) {
|
||||
this.$Message.error('占比总和必须等于100');
|
||||
return
|
||||
return false;
|
||||
}
|
||||
const applySetList = JSON.parse(JSON.stringify(this.applySetList))
|
||||
let params = applySetList.filter(item => {
|
||||
if (!isSave) {
|
||||
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) {
|
||||
item.info = JSON.stringify(item.info);
|
||||
return true
|
||||
return true;
|
||||
} else {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
})
|
||||
let obj = new Object;
|
||||
@ -151,20 +223,10 @@ export default {
|
||||
API.savePlatformSet(obj)
|
||||
.then(res => {
|
||||
if (res.code == 0) {
|
||||
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.appName}-下级机构配置`;
|
||||
this.agent.propertyId = this.propertyId;
|
||||
this.agent.parentId = res.data[index].id;
|
||||
this.agent.show = true;
|
||||
this.applySetList = res.data;
|
||||
}
|
||||
})
|
||||
},
|
||||
delSet(data) {
|
||||
this.applySetList.splice(data, 1)
|
||||
},
|
||||
visibleChange(bool) {
|
||||
if (!bool) {
|
||||
this.$emit('update:show', false);
|
||||
@ -181,9 +243,6 @@ export default {
|
||||
propertyId: '',//配置ID
|
||||
parentId: '',//父级ID
|
||||
};
|
||||
this.percentList = {};
|
||||
this.applyidList = {};
|
||||
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -13,17 +13,18 @@
|
||||
<Col span="10">占比</Col>
|
||||
<Col span="2">操作</Col>
|
||||
</Row>
|
||||
<Row v-for="item in packageSetList" style="margin-bottom:10px">
|
||||
<Col span="12">
|
||||
<Select v-model="item.productName" style="width:80%" placeholder="请选择平台">
|
||||
<Option v-for="a in packageList" :value="a">{{a}}</Option>
|
||||
<Row v-for="(item,index) in packageSetList" style="margin-bottom:10px">
|
||||
<Col span="8">
|
||||
<Select v-model="item.info.productName" style="width:80%" placeholder="请选择产品" @on-change="handleSelect($event,index)" :disabled="item.id!=undefined">
|
||||
<Option v-for="otem in packageList" :value="otem" :key="otem">{{otem}}</Option>
|
||||
</Select>
|
||||
</Col>
|
||||
<Col span="10">
|
||||
<Input v-model="item.percent" type="number" placeholder="请输入占比" clearable style="width:80%" />
|
||||
<Col span="8">
|
||||
<Input v-model="item.info.percent" type="number" placeholder="请输入占比" clearable style="width:80%" />
|
||||
</Col>
|
||||
<Col span="2">
|
||||
<Button type="error">删除</Button>
|
||||
<Col span="8">
|
||||
<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>
|
||||
</Row>
|
||||
</div>
|
||||
|
@ -15,17 +15,16 @@
|
||||
</Row>
|
||||
<Row v-for="(item,index) in applySetList" style="margin-bottom:10px">
|
||||
<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>
|
||||
</Select>
|
||||
</Col>
|
||||
<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)"/>
|
||||
<div v-else style="width:80%;height:10px"></div>
|
||||
<Input v-model="item.info.percent" type="number" placeholder="请输入占比" clearable style="width:80%"/>
|
||||
</Col>
|
||||
<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(index)">删除</Button>
|
||||
<Button type="error" @click="delSet(item,index)" style="margin-right:20px">删除</Button>
|
||||
<Button v-if="item.info.appId" type="primary" @click="agentSet(item,index)">配置下级机构</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user