diff --git a/frontend/src/api/virtual/properties.js b/frontend/src/api/virtual/properties.js index 2089b906..4bf21267 100644 --- a/frontend/src/api/virtual/properties.js +++ b/frontend/src/api/virtual/properties.js @@ -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) +} \ No newline at end of file diff --git a/frontend/src/views/virtual/properties/agent_set.vue b/frontend/src/views/virtual/properties/agent_set.vue index d60cf661..a78d75ff 100644 --- a/frontend/src/views/virtual/properties/agent_set.vue +++ b/frontend/src/views/virtual/properties/agent_set.vue @@ -15,16 +15,16 @@ - + - + - - + + diff --git a/frontend/src/views/virtual/properties/cartype_set.vue b/frontend/src/views/virtual/properties/cartype_set.vue index 005ee8a0..2aeb035a 100644 --- a/frontend/src/views/virtual/properties/cartype_set.vue +++ b/frontend/src/views/virtual/properties/cartype_set.vue @@ -15,16 +15,16 @@ - - + - - + + diff --git a/frontend/src/views/virtual/properties/js/agent_set.js b/frontend/src/views/virtual/properties/js/agent_set.js index 7243bdd7..d65853c5 100644 --- a/frontend/src/views/virtual/properties/js/agent_set.js +++ b/frontend/src/views/virtual/properties/js/agent_set.js @@ -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: '',//层级标志 + }; }, } }; diff --git a/frontend/src/views/virtual/properties/js/cartype_set.js b/frontend/src/views/virtual/properties/js/cartype_set.js index 237c6ba8..7483b562 100644 --- a/frontend/src/views/virtual/properties/js/cartype_set.js +++ b/frontend/src/views/virtual/properties/js/cartype_set.js @@ -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: '',//层级标志 + }; }, } }; diff --git a/frontend/src/views/virtual/properties/js/package_set.js b/frontend/src/views/virtual/properties/js/package_set.js index 462f295f..0fcdd4d3 100644 --- a/frontend/src/views/virtual/properties/js/package_set.js +++ b/frontend/src/views/virtual/properties/js/package_set.js @@ -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 = [];//套餐配置列表 }, } }; diff --git a/frontend/src/views/virtual/properties/js/platform_set.js b/frontend/src/views/virtual/properties/js/platform_set.js index 7e65d236..656c786c 100644 --- a/frontend/src/views/virtual/properties/js/platform_set.js +++ b/frontend/src/views/virtual/properties/js/platform_set.js @@ -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 = {}; - }, } }; diff --git a/frontend/src/views/virtual/properties/package_set.vue b/frontend/src/views/virtual/properties/package_set.vue index 22ec22aa..0a45a5bf 100644 --- a/frontend/src/views/virtual/properties/package_set.vue +++ b/frontend/src/views/virtual/properties/package_set.vue @@ -13,17 +13,18 @@ 占比 操作 - - - + - - + + - - + + + diff --git a/frontend/src/views/virtual/properties/platform_set.vue b/frontend/src/views/virtual/properties/platform_set.vue index aa289622..4137b84d 100644 --- a/frontend/src/views/virtual/properties/platform_set.vue +++ b/frontend/src/views/virtual/properties/platform_set.vue @@ -15,17 +15,16 @@ - - -
+ - - + +