合并pengyh

This commit is contained in:
zhouhq@fxft.net 2020-04-03 16:51:02 +08:00
parent f522eee5b9
commit 17d846ce03
10 changed files with 1243 additions and 0 deletions

View File

@ -0,0 +1,35 @@
<template>
<div>
<Modal :mask-closable="false" @on-visible-change="visibleChange" v-model="my_show" width="800" footer-hide>
<div slot="header">
<span style="margin-right:20px">{{title}}</span>
<Button type="primary" @click="addSet">添加</Button>
</div>
<div style="height:500px">
<Row style="margin-bottom:10px;font-size:14px;font-weight: bold;">
<Col span="8">
机构名称
</Col>
<Col span="8">占比</Col>
<Col span="8">操作</Col>
</Row>
<Row v-for="(item,index) in agentSetList" style="margin-bottom:10px">
<Col span="8">
<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.info.percent" type="number" placeholder="请输入占比" clearable style="width:80%"/>
</Col>
<Col span="8">
<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>
</Modal>
<cartype-set :show.sync="cartype.show" v-bind="cartype"></cartype-set>
</div>
</template>
<script src="./js/agent_set.js"></script>

View File

@ -0,0 +1,35 @@
<template>
<div>
<Modal :mask-closable="false" @on-visible-change="visibleChange" v-model="my_show" width="800" footer-hide>
<div slot="header">
<span style="margin-right:20px">{{title}}</span>
<Button type="primary" @click="addSet">添加</Button>
</div>
<div style="height:500px">
<Row style="margin-bottom:10px;font-size:14px;font-weight: bold;">
<Col span="8">
车型名称
</Col>
<Col span="8">占比</Col>
<Col span="8">操作</Col>
</Row>
<Row v-for="(item,index) in carTypeSetList" style="margin-bottom:10px">
<Col span="8">
<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.info.percent" type="number" placeholder="请输入占比" clearable style="width:80%"/>
</Col>
<Col span="8">
<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>
</Modal>
<package-set :show.sync="package.show" v-bind="package"></package-set>
</div>
</template>
<script src="./js/cartype_set.js"></script>

View File

@ -0,0 +1,28 @@
<template>
<Modal :mask-closable="false" @on-visible-change="visibleChange" title="应用类型车辆配置" v-model="my_show" width="600" @on-ok="ok" @on-cancel="clear">
<div class="page-edit-wrap uinn-lr20">
<Row>
<Col span="3" style="line-height:32px">平台类型</Col>
<Col span="21">
<Select v-model="param.name" style="width:400px" @on-change="getCarTypes">
<Option v-for="(item,key) in configure" :value="key" :key="key">{{key}}</Option>
</Select>
</Col>
</Row>
<Row style="margin-top:20px" v-if="param.name">
<Col span="3" style="line-height:32px">车辆类型</Col>
<Col span="21">
<Tabs v-model="carTypeName">
<TabPane v-for="(item,key) in carTypeList" :key="key" :name="key" :label="key">
<CheckboxGroup v-model="param.value[key]">
<Checkbox :label="name" v-for="(name,index) in item" :key="index"></Checkbox>
</CheckboxGroup>
</TabPane>
</Tabs>
</Col>
</Row>
</div>
</Modal >
</template>
<script src="./js/configure.js"></script>

View File

@ -0,0 +1,255 @@
import * as API from "api/virtual/properties";
export default {
props: {
show: {
type: Boolean,
default: false
},
title: {//弹窗标题
type: String,
default: ''
},
id: {//企业id
type: [String, Number],
default: ''
},
name: {//企业名称
type: String,
default: ''
},
packagetype: {//企业所属套餐类型
type: String,
default: '',
},
applyid: {//平台应用ID用来获取车型
type: [String, Number],
default: ''
},
propertyId: {//配置ID
type: [String, Number],
default: ''
},
parentId: {//父级ID
type: [String, Number],
default: ''
}
},
data() {
return {
my_show: false,
loading: false,
agentList: [],//机构列表
agentSetList: [],//机构配置列表
cartype: {
show: false,
title: '',
applyid: '',//平台应用id
id: '',//企业id
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.getPlatformSetList();
}
},
},
methods: {
getAgentsList() {
let data = new Object;
data.id = this.id;
// data.id = 21;
API.getAgentsList(data)
.then(res => {
if (res.code == 0) {
this.agentList = res.data;
}
})
},
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 = {
parentId: this.parentId,
propertyId: this.propertyId,
type: 1,
level: level,
info: {
agentId: '',//机构id
agentName: '',//机构名称
percent: '',//占比
}
}
this.$set(this.agentSetList, index, data);
},
handleSelect(data, index) {
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, 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, 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: '',//层级标志
};
},
}
};

View File

@ -0,0 +1,274 @@
import * as API from "api/virtual/properties";
export default {
props: {
show: {
type: Boolean,
default: false
},
title: {//弹窗标题
type: String,
default: ''
},
id: {//企业id
type: [String, Number],
default: ''
},
name: {//企业名称
type: String,
default: ''
},
packagetype: {//企业所属套餐类型
type: String,
default: '',
},
applyid: {//平台应用ID用来获取车型
type: [String, Number],
default: ''
},
propertyId: {//配置ID
type: [String, Number],
default: ''
},
parentId: {//父级ID
type: [String, Number],
default: ''
},
level: {//层级标志
type: String,
default: '',
}
},
data() {
return {
my_show: false,
loading: false,
carTypeList: {},//车辆类型列表
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),
},
watch: {
show(bool) {
this.my_show = bool;
if (bool) {
this.getCarTypeList();
this.getPlatformSetList();
}
},
},
methods: {
getCarTypeList() {
let data = new Object;
data.name = this.name;
API.getApplyList(data)
.then(res => {
if (res.code == 0) {
res.data.forEach(item => {
if (item.application.id == this.applyid) {
this.carTypeList = item.carType;
}
})
}
})
},
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 = {
parentId: this.parentId,
propertyId: this.propertyId,
type: 2,
level: level,
info: {
vehicleTypeName: '',//车辆类型名称
parentName: '',//车辆类型所属分类名称
percent: '',//占比
}
}
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) {
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, 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类套餐'
}
return packagetype
},
visibleChange(bool) {
if (!bool) {
this.$emit('update:show', false);
}
this.carTypeList = {};//车辆类型列表
this.carTypeSetList = [];
this.package = {
show: false,
title: '',
id: '',//企业id
packagetype: '',//校正过的套餐类型
propertyId: '',//配置ID
parentId: '',//父级ID
level: '',//层级标志
};
},
}
};

View File

@ -0,0 +1,92 @@
import * as API from "api/virtual/properties";
export default {
props: {
show: {
type: Boolean,
default: false
},
},
data() {
return {
my_show: false,
loading: false,
configure: [],//配置总数据
carTypeList: {},//车辆类型
carTypeName: '',
param: {
name: '',//选中平台
value: {},//选中的车辆类型
},
};
},
watch: {
show(bool) {
this.my_show = bool;
if (bool) {
this.getCarTypeToPlatformList()
}
},
},
methods: {
getCarTypeToPlatformList() {
API.getCarTypeToPlatformList()
.then(res => {
if (res.code == 0) {
this.configure = res.data;
}
})
},
getCarTypes(val) {
if (!val) return;
const configure = this.configure[val] || {};
this.carTypeList = configure.carList;
this.param.value = {};
if (configure['已选']) {
this.param.value = configure['已选']
} else {
for (let k in configure.carList) {
this.$set(this.param.value, k, [])
}
}
this.carTypeName = Object.keys(configure.carList)[0];
},
ok() {
let data = new Object;
data.name = this.param.name;
data.value = JSON.stringify(this.param.value);
this.loading = true;
API.saveCarTypeToPlatform(data)
.then(res => {
this.loading = false;
if (res.code == 0) {
this.$Message.success('修改成功');
}
})
.catch(err => {
this.loading = false;
})
},
clear() {
this.my_show = false;
this.configure = [];
this.carTypeList = {};
this.carTypeName = '';
this.param = {
name: '',
value: {}
};
},
visibleChange(bool) {
if (!bool) {
this.$emit('update:show', false);
}
this.configure = [];
this.carTypeList = {};
this.carTypeName = '';
this.param = {
name: '',
value: {}
};
},
}
};

View File

@ -0,0 +1,207 @@
import * as API from "api/virtual/properties";
export default {
props: {
show: {
type: Boolean,
default: false
},
title: {//弹窗标题
type: String,
default: ''
},
id: {//企业id
type: [String, Number],
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: [],//套餐配置列表
};
},
mounted() {
},
watch: {
show(bool) {
this.my_show = bool;
if (bool) {
this.getPackageList();
this.getPlatformSetList();
}
},
},
methods: {
getPackageList() {
let data = new Object;
data.id = this.id;
API.getPackageList(data)
.then(res => {
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 = [];//套餐配置列表
},
}
};

View File

@ -0,0 +1,248 @@
import * as API from "api/virtual/properties";
export default {
props: {
show: {
type: Boolean,
default: false
},
id: {//企业id
type: [String, Number],
default: ''
},
name: {//企业名称
type: String,
default: '',
},
packagetype: {//企业所属套餐类型
type: String,
default: '',
},
propertyId: {//配置ID
type: [String, Number],
default: ''
}
},
data() {
return {
my_show: false,
loading: false,
applyList: [],//应用平台列表
applySetList: [],//应用平台配置列表
agent: {
show: false,
title: '',
applyid: '',//平台应用id
id: '',//企业id
name: '',//企业名称
packagetype: '',//企业所属套餐类型
propertyId: '',//配置ID
parentId: '',//父级ID
},
};
},
components: {
agentSet: resolve => require(['views/virtual/properties/agent_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.getApplyList();
this.getPlatformSetList();
}
},
},
methods: {
getApplyList() {
let data = new Object;
data.name = this.name;
// data.name = '佛山市兴诺科技有限公司';
API.getApplyList(data)
.then(res => {
if (res.code == 0) {
let applyList = [];
res.data.forEach(item => {
applyList.push(item.application);
})
this.applyList = applyList;
}
})
},
getPlatformSetList() {
let data = new Object;
data.propertyId = this.propertyId;
data.parentId = 0;
API.getPlatformSetList(data)
.then(res => {
if (res.code == 0) {
this.applySetList = res.data;
}
})
},
handleSelect(data, index) {
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;
this.applySetList[index].info.appType = item.appType;
}
})
},
addSet() {
const index = this.applySetList.length;
const data = {
parentId: 0,
propertyId: this.propertyId,
type: 0,
level: "#0",
info: {
appName: '',
appType: '',
appId: '',
percent: '',
}
}
this.$set(this.applySetList, index, data)
},
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;
}
})
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.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;
} else {
return false;
}
})
let obj = new Object;
obj.list = params;
API.savePlatformSet(obj)
.then(res => {
if (res.code == 0) {
this.applySetList = res.data;
}
})
},
visibleChange(bool) {
if (!bool) {
this.$emit('update:show', false);
}
this.applyList = [];//应用平台列表
this.applySetList = [];
this.agent = {
show: false,
title: '',
applyid: '',//平台应用id
id: '',//企业id
name: '',//企业名称
packagetype: '',//企业所属套餐类型
propertyId: '',//配置ID
parentId: '',//父级ID
};
},
}
};

View File

@ -0,0 +1,34 @@
<template>
<div>
<Modal :mask-closable="false" @on-visible-change="visibleChange" v-model="my_show" width="800" footer-hide>
<div slot="header">
<span style="margin-right:20px">{{title}}</span>
<Button type="primary" @click="addSet">添加</Button>
</div>
<div style="height:500px">
<Row style="margin-bottom:10px;font-size:14px;font-weight: bold;">
<Col span="12">
产品名称
</Col>
<Col span="10">占比</Col>
<Col span="2">操作</Col>
</Row>
<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="8">
<Input v-model="item.info.percent" type="number" placeholder="请输入占比" clearable style="width:80%" />
</Col>
<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>
</Modal>
</div>
</template>
<script src="./js/package_set.js"></script>

View File

@ -0,0 +1,35 @@
<template>
<div>
<Modal :mask-closable="false" @on-visible-change="visibleChange" v-model="my_show" width="800" footer-hide>
<div slot="header">
<span style="margin-right:20px">平台配置</span>
<Button type="primary" @click="addSet">添加</Button>
</div>
<div style="height:500px">
<Row style="margin-bottom:10px;font-size:14px;font-weight: bold;">
<Col span="8">
平台名称
</Col>
<Col span="8">占比</Col>
<Col span="8">操作</Col>
</Row>
<Row v-for="(item,index) in applySetList" style="margin-bottom:10px">
<Col span="8">
<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-model="item.info.percent" type="number" placeholder="请输入占比" clearable style="width:80%"/>
</Col>
<Col span="8">
<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>
</Modal>
<agent-set :show.sync="agent.show" v-bind="agent"></agent-set>
</div>
</template>
<script src="./js/platform_set.js"></script>