From 17d846ce03261094ae537682a02ac721c0a86db3 Mon Sep 17 00:00:00 2001 From: "zhouhq@fxft.net" Date: Fri, 3 Apr 2020 16:51:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6pengyh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/virtual/properties/agent_set.vue | 35 +++ .../views/virtual/properties/cartype_set.vue | 35 +++ .../views/virtual/properties/configure.vue | 28 ++ .../views/virtual/properties/js/agent_set.js | 255 ++++++++++++++++ .../virtual/properties/js/cartype_set.js | 274 ++++++++++++++++++ .../views/virtual/properties/js/configure.js | 92 ++++++ .../virtual/properties/js/package_set.js | 207 +++++++++++++ .../virtual/properties/js/platform_set.js | 248 ++++++++++++++++ .../views/virtual/properties/package_set.vue | 34 +++ .../views/virtual/properties/platform_set.vue | 35 +++ 10 files changed, 1243 insertions(+) create mode 100644 frontend/src/views/virtual/properties/agent_set.vue create mode 100644 frontend/src/views/virtual/properties/cartype_set.vue create mode 100644 frontend/src/views/virtual/properties/configure.vue create mode 100644 frontend/src/views/virtual/properties/js/agent_set.js create mode 100644 frontend/src/views/virtual/properties/js/cartype_set.js create mode 100644 frontend/src/views/virtual/properties/js/configure.js create mode 100644 frontend/src/views/virtual/properties/js/package_set.js create mode 100644 frontend/src/views/virtual/properties/js/platform_set.js create mode 100644 frontend/src/views/virtual/properties/package_set.vue create mode 100644 frontend/src/views/virtual/properties/platform_set.vue diff --git a/frontend/src/views/virtual/properties/agent_set.vue b/frontend/src/views/virtual/properties/agent_set.vue new file mode 100644 index 00000000..a78d75ff --- /dev/null +++ b/frontend/src/views/virtual/properties/agent_set.vue @@ -0,0 +1,35 @@ + + diff --git a/frontend/src/views/virtual/properties/cartype_set.vue b/frontend/src/views/virtual/properties/cartype_set.vue new file mode 100644 index 00000000..2aeb035a --- /dev/null +++ b/frontend/src/views/virtual/properties/cartype_set.vue @@ -0,0 +1,35 @@ + + diff --git a/frontend/src/views/virtual/properties/configure.vue b/frontend/src/views/virtual/properties/configure.vue new file mode 100644 index 00000000..b8a1ba34 --- /dev/null +++ b/frontend/src/views/virtual/properties/configure.vue @@ -0,0 +1,28 @@ + + + diff --git a/frontend/src/views/virtual/properties/js/agent_set.js b/frontend/src/views/virtual/properties/js/agent_set.js new file mode 100644 index 00000000..d65853c5 --- /dev/null +++ b/frontend/src/views/virtual/properties/js/agent_set.js @@ -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: '',//层级标志 + }; + }, + } +}; diff --git a/frontend/src/views/virtual/properties/js/cartype_set.js b/frontend/src/views/virtual/properties/js/cartype_set.js new file mode 100644 index 00000000..7483b562 --- /dev/null +++ b/frontend/src/views/virtual/properties/js/cartype_set.js @@ -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: '',//层级标志 + }; + }, + } +}; diff --git a/frontend/src/views/virtual/properties/js/configure.js b/frontend/src/views/virtual/properties/js/configure.js new file mode 100644 index 00000000..a1951f6d --- /dev/null +++ b/frontend/src/views/virtual/properties/js/configure.js @@ -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: {} + }; + }, + } +}; diff --git a/frontend/src/views/virtual/properties/js/package_set.js b/frontend/src/views/virtual/properties/js/package_set.js new file mode 100644 index 00000000..0fcdd4d3 --- /dev/null +++ b/frontend/src/views/virtual/properties/js/package_set.js @@ -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 = [];//套餐配置列表 + }, + } +}; diff --git a/frontend/src/views/virtual/properties/js/platform_set.js b/frontend/src/views/virtual/properties/js/platform_set.js new file mode 100644 index 00000000..656c786c --- /dev/null +++ b/frontend/src/views/virtual/properties/js/platform_set.js @@ -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 + }; + }, + } +}; diff --git a/frontend/src/views/virtual/properties/package_set.vue b/frontend/src/views/virtual/properties/package_set.vue new file mode 100644 index 00000000..0a45a5bf --- /dev/null +++ b/frontend/src/views/virtual/properties/package_set.vue @@ -0,0 +1,34 @@ + + diff --git a/frontend/src/views/virtual/properties/platform_set.vue b/frontend/src/views/virtual/properties/platform_set.vue new file mode 100644 index 00000000..4137b84d --- /dev/null +++ b/frontend/src/views/virtual/properties/platform_set.vue @@ -0,0 +1,35 @@ + +