diff --git a/frontend/src/api/virtual/properties.js b/frontend/src/api/virtual/properties.js index 25e0ac2b..2089b906 100644 --- a/frontend/src/api/virtual/properties.js +++ b/frontend/src/api/virtual/properties.js @@ -90,7 +90,7 @@ export function importExcel(file) { */ export function getCarTypeToPlatformList(data) { - return fetch.get('setting/list', { params: data }) + return fetch.get('property/list', { params: data }) } /** @@ -100,6 +100,54 @@ export function getCarTypeToPlatformList(data) { */ export function saveCarTypeToPlatform(data) { - return fetch.post('setting/update', data) + return fetch.post('property/update', data) } +/** + * [getPlatformList 展示公司应用] + * @param {[type]} data [description] + * @return {[type]} [description] + */ + +export function getApplyList(data) { + return fetch.get('properties/platform', { params: data }) +} + +/** + * [getPlatformList 展示公司下级机构] + * @param {[type]} data [description] + * @return {[type]} [description] + */ + +export function getAgentsList(data) { + return fetch.get('properties/agents', { params: data }) +} + +/** + * [getPlatformList 展示公司所属套餐] + * @param {[type]} data [description] + * @return {[type]} [description] + */ + +export function getPackageList(data) { + return fetch.get('properties/package', { params: data }) +} + +/** + * [getPlatformSetList 展示平台配置列表] + * @param {[type]} data [description] + * @return {[type]} [description] + */ +export function getPlatformSetList(data) { + return fetch.get('setting/list', { params: data }) +} + + +/** + * [savePlatformSet 保存平台配置] + * @param {[type]} data [description] + * @return {[type]} [description] + */ +export function savePlatformSet(data) { + return fetch.post('setting/save', data) +} diff --git a/frontend/src/service/service.js b/frontend/src/service/service.js index f513b62e..e0af02bb 100644 --- a/frontend/src/service/service.js +++ b/frontend/src/service/service.js @@ -28,7 +28,9 @@ export const serviceForm = axios.create({ export const fetch = axios.create({ timeout: 1800000, headers: { - 'Content-Type': 'application/json; charset=utf-8' + post: { + 'Content-Type': 'application/json; charset=utf-8' + } }, baseURL: window.CONFIG.ascsUrl }) 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..d60cf661 --- /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..005ee8a0 --- /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 index 0fa326cc..b8a1ba34 100644 --- a/frontend/src/views/virtual/properties/configure.vue +++ b/frontend/src/views/virtual/properties/configure.vue @@ -1,5 +1,5 @@ diff --git a/frontend/src/views/virtual/properties/index.vue b/frontend/src/views/virtual/properties/index.vue index 3d187781..bccaba14 100644 --- a/frontend/src/views/virtual/properties/index.vue +++ b/frontend/src/views/virtual/properties/index.vue @@ -98,6 +98,8 @@ + + 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..7243bdd7 --- /dev/null +++ b/frontend/src/views/virtual/properties/js/agent_set.js @@ -0,0 +1,115 @@ +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: [ + { + agentId: '', + agentName: '', + value: '', + } + ], + cartype:{ + show:false, + title: '', + applyid:'',//平台应用id + id: '',//企业id + name:'',//企业名称 + packagetype: '',//企业所属套餐类型 + } + + }; + }, + components: { + cartypeSet: resolve => require(['views/virtual/properties/cartype_set'], resolve), + }, + mounted() { + }, + watch: { + show(bool) { + this.my_show = bool; + if (bool) { + this.getAgentsList() + } + }, + }, + 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; + } + }) + }, + addSet() { + const index = this.agentSetList.length; + const data = { + agentId: '', + agentName: '', + value: '', + } + this.$set(this.agentSetList, index, data) + }, + handleSelect(data, index) { + this.agentSetList[index].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; + }, + delSet(data) { + this.agentSetList.splice(data, 1) + }, + visibleChange(bool) { + if (!bool) { + this.$emit('update:show', false); + } + }, + } +}; 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..237c6ba8 --- /dev/null +++ b/frontend/src/views/virtual/properties/js/cartype_set.js @@ -0,0 +1,122 @@ +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: '' + } + }, + data() { + return { + my_show: false, + loading: false, + carTypeList: {},//车辆类型列表 + carTypeSetList: [ + { + carType: '', + value: '', + } + ], + package:{ + show:false, + title: '', + id: '',//企业id + packagetype: '',//校正过的套餐类型 + } + }; + }, + mounted() { + }, + components: { + packageSet: resolve => require(['views/virtual/properties/package_set'], resolve), + }, + watch: { + show(bool) { + this.my_show = bool; + if (bool) { + this.getCarTypeList(); + } + }, + }, + methods: { + getCarTypeList() { + let data = new Object; + // data.name=this.name; + data.name = '佛山市兴诺科技有限公司' + API.getApplyList(data) + .then(res => { + if (res.code == 0) { + res.data.forEach(item => { + if (item.application.id == this.applyid) { + this.carTypeList = item.carType; + } + }) + } + }) + }, + addSet() { + const index = this.carTypeSetList.length; + const data = { + carType: '', + value: '', + } + this.$set(this.carTypeSetList, index, data) + }, + handleSelect(data, index) { + // console.log(this.packagetype) + }, + 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) + }, + 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); + } + }, + } +}; diff --git a/frontend/src/views/virtual/properties/js/index.js b/frontend/src/views/virtual/properties/js/index.js index f4d98574..3dc8d5b2 100644 --- a/frontend/src/views/virtual/properties/js/index.js +++ b/frontend/src/views/virtual/properties/js/index.js @@ -1,552 +1,561 @@ import * as API from 'api/virtual/properties'; export default { - name: 'Products', - components: { - UiEdit: resolve => require(['views/virtual/properties/edit'], resolve), - UiAgent: resolve => require(['views/virtual/properties/agent'], resolve), - UiSettings: resolve => require(['views/virtual/properties/settings'], resolve), - UiConfigure: resolve => require(['views/virtual/properties/configure'],resolve) - }, - data() { - return { - properties: new Map(), - showData: [], - params: { - company_id: '', - package_id: '' - }, - only: ['company_id', 'package_id', 'product', 'vehicle_type', 'company', 'platform', 'customer', 'province', 'agent'], - updates: new Map(), - configureShow: false, - settingsShow: false, - settingsData: {}, - agentsData: {}, - agentsProp: [], - editModel: false, - editObj: { - show: false, - isUpdate: false, - data: null - }, - agentObj: { - show: false, - isUpdate: false, - data: null - }, - search: { - show: true - }, - page: { - total: 0, - limit: 10, - page: 1 - }, - companies: [], - companyFilters: [], - packages: [], - packageFilters: [], - data: [], - columns: [ - { - title: '序号', - key: '', - width: 80, - render: (h, context) => { - return h('span', context.row._index + 1); - } - }, - { - title: '企业名称', - key: 'company_name', - width: 210, - tooltip: true - }, - { - title: '套餐名称', - key: 'package_name', - width: 120 - }, - { - title: '月流量', - key: 'flows', - width: 100 - }, - { - title: '销售数', - key: 'counts', - width: 100 - }, - { - title: '活跃数', - key: 'actives', - width: 100 - }, - { - title: '公司类型', - key: 'company', - minWidth: 170, - render: (h, context) => { - return this.editRender('company', h, context); - } - }, - // { - // title: '平台/API', - // key: 'platform', - // minWidth: 120, - // render: (h, context) => { - // return this.editRender('platform', h, context); - // } - // }, - // { - // title: '客户类型', - // key: 'customer', - // minWidth: 120, - // render: (h, context) => { - // return this.editRender('customer', h, context); - // } - // }, - // { - // title: '产品类型', - // key: 'product', - // minWidth: 130, - // render: (h, context) => { - // return this.editRender('product', h, context); - // } - // }, - // { - // title: '套餐类型', - // key: 'package_type', - // width: 100, - // render: (h, context) => { - // return h('span', this.productPackageTypes[context.row.product]); - // } - // }, - // { - // title: '车辆类型', - // key: 'vehicle_type', - // minWidth: 120, - // render: (h, context) => { - // return this.editRender('vehicle_type', h, context); - // } - // }, - // { - // title: '车型分类', - // key: 'vehicle_group', - // minWidth: 120, - // render: (h, context) => { - // return h('span', this.vehicleTypeVehicleGroups[context.row.vehicle_type]); - // } - // }, - { - title: '销售省份', - key: 'action', - width: 150, - render: (h, { - row, - column, - index - }) => { - let html = []; - - if (this.haveJurisdiction('update')) { - let button = h('Button', { - props: { - type: row.province ? 'success' : 'error', - size: 'small' - }, - class: ['btn'], - on: { - click: (event) => { - this.editObj = { show: true, data: row, isUpdate: this.editModel }; - } - } - }, this.editModel ? '设置' : '查看'); - - html.push(h('Tooltip', { - props: { - content: row.province ? '已设置' : '省份未设置' - } - }, [button])); - } - - if (html.length) { - return h('div', html); - } - } - }, - { - title: '代理商', - key: 'action', - width: 150, - render: (h, { - row, - column, - index - }) => { - let html = []; - - if (this.haveJurisdiction('update')) { - let button = h('Button', { - props: { - type: row.agent ? 'success' : 'error', - size: 'small' - }, - class: ['btn'], - on: { - click: (event) => { - this.agentObj = { show: true, data: row, isUpdate: this.editModel }; - this.agentsProp = this.agentsData[row.company_id] ? this.agentsData[row.company_id] : []; - } - } - }, this.editModel ? '设置' : '查看'); - - html.push(h('Tooltip', { - props: { - content: row.agent ? '已设置' : '代理商未设置' - } - }, [button])); - } - - if (html.length) { - return h('div', html); - } - } - }, - { - title: '平台配置', - key: 'action', - width: 150, - render: (h, { - row, - column, - index - }) => { - let html = []; - - if (this.haveJurisdiction('update')) { - let button = h('Button', { - props: { - type: 'success', - size: 'small' - }, - class: ['btn'], - on: { - click: (event) => { - this.agentObj = { show: true, data: row, isUpdate: this.editModel }; - this.agentsProp = this.agentsData[row.company_id] ? this.agentsData[row.company_id] : []; - } - } - }, '配置'); - - html.push(button); - } - - if (html.length) { - return h('div', html); - } - } - } - ] - }; - }, - watch: { - editModel(value) { - this.columns = this.columns; - this.$refs.table.handleResize(); - } - }, - computed: { - productPackageTypes() { - let obj = {}; - - let packages = this.settingsData.package ? this.settingsData.package : {}; - - for (const key in packages) { - const element = packages[key]; - - for (let index = 0; index < element.length; index++) { - const value = element[index]; - obj[value] = key; - } - } - - return obj; + name: 'Products', + components: { + UiEdit: resolve => require(['views/virtual/properties/edit'], resolve), + UiAgent: resolve => require(['views/virtual/properties/agent'], resolve), + UiSettings: resolve => require(['views/virtual/properties/settings'], resolve), + UiConfigure: resolve => require(['views/virtual/properties/configure'], resolve), + platformSet: resolve => require(['views/virtual/properties/platform_set'], resolve), }, - vehicleTypeVehicleGroups() { - let obj = {}; + data() { + return { + properties: new Map(), + showData: [], + params: { + company_id: '', + package_id: '' + }, + only: ['company_id', 'package_id', 'product', 'vehicle_type', 'company', 'platform', 'customer', 'province', 'agent'], + updates: new Map(), + configureShow: false, + platform: { + show: false, + id: '', + name: '', + }, + settingsShow: false, + settingsData: {}, + agentsData: {}, + agentsProp: [], + editModel: false, + editObj: { + show: false, + isUpdate: false, + data: null + }, + agentObj: { + show: false, + isUpdate: false, + data: null + }, + search: { + show: true + }, + page: { + total: 0, + limit: 10, + page: 1 + }, + companies: [], + companyFilters: [], + packages: [], + packageFilters: [], + data: [], + columns: [ + { + title: '序号', + key: '', + width: 80, + render: (h, context) => { + return h('span', context.row._index + 1); + } + }, + { + title: '企业名称', + key: 'company_name', + width: 210, + tooltip: true + }, + { + title: '套餐名称', + key: 'package_name', + width: 120 + }, + { + title: '月流量', + key: 'flows', + width: 100 + }, + { + title: '销售数', + key: 'counts', + width: 100 + }, + { + title: '活跃数', + key: 'actives', + width: 100 + }, + { + title: '公司类型', + key: 'company', + minWidth: 170, + render: (h, context) => { + return this.editRender('company', h, context); + } + }, + // { + // title: '平台/API', + // key: 'platform', + // minWidth: 120, + // render: (h, context) => { + // return this.editRender('platform', h, context); + // } + // }, + // { + // title: '客户类型', + // key: 'customer', + // minWidth: 120, + // render: (h, context) => { + // return this.editRender('customer', h, context); + // } + // }, + // { + // title: '产品类型', + // key: 'product', + // minWidth: 130, + // render: (h, context) => { + // return this.editRender('product', h, context); + // } + // }, + // { + // title: '套餐类型', + // key: 'package_type', + // width: 100, + // render: (h, context) => { + // return h('span', this.productPackageTypes[context.row.product]); + // } + // }, + // { + // title: '车辆类型', + // key: 'vehicle_type', + // minWidth: 120, + // render: (h, context) => { + // return this.editRender('vehicle_type', h, context); + // } + // }, + // { + // title: '车型分类', + // key: 'vehicle_group', + // minWidth: 120, + // render: (h, context) => { + // return h('span', this.vehicleTypeVehicleGroups[context.row.vehicle_type]); + // } + // }, + { + title: '销售省份', + key: 'action', + width: 150, + render: (h, { + row, + column, + index + }) => { + let html = []; - let vehicles = this.settingsData.vehicle ? this.settingsData.vehicle : {}; + if (this.haveJurisdiction('update')) { + let button = h('Button', { + props: { + type: row.province ? 'success' : 'error', + size: 'small' + }, + class: ['btn'], + on: { + click: (event) => { + this.editObj = { show: true, data: row, isUpdate: this.editModel }; + } + } + }, this.editModel ? '设置' : '查看'); - for (const key in vehicles) { - const element = vehicles[key]; + html.push(h('Tooltip', { + props: { + content: row.province ? '已设置' : '省份未设置' + } + }, [button])); + } - for (let index = 0; index < element.length; index++) { - const value = element[index]; - obj[value] = key; + if (html.length) { + return h('div', html); + } + } + }, + { + title: '代理商', + key: 'action', + width: 150, + render: (h, { + row, + column, + index + }) => { + let html = []; + + if (this.haveJurisdiction('update')) { + let button = h('Button', { + props: { + type: row.agent ? 'success' : 'error', + size: 'small' + }, + class: ['btn'], + on: { + click: (event) => { + this.agentObj = { show: true, data: row, isUpdate: this.editModel }; + this.agentsProp = this.agentsData[row.company_id] ? this.agentsData[row.company_id] : []; + } + } + }, this.editModel ? '设置' : '查看'); + + html.push(h('Tooltip', { + props: { + content: row.agent ? '已设置' : '代理商未设置' + } + }, [button])); + } + + if (html.length) { + return h('div', html); + } + } + }, + { + title: '平台配置', + key: 'action', + width: 150, + render: (h, { + row, + column, + index + }) => { + let html = []; + + if (this.haveJurisdiction('update')) { + let button = h('Button', { + props: { + type: 'success', + size: 'small' + }, + class: ['btn'], + on: { + click: (event) => { + this.platform.show=true; + this.platform.id=row.company_id; + this.platform.name=row.company_name; + this.platform.packagetype=row.package[0]; + this.platform.propertyId=row.id; + } + } + }, '配置'); + + html.push(button); + } + + if (html.length) { + return h('div', html); + } + } + } + ] + }; + }, + watch: { + editModel(value) { + this.columns = this.columns; + this.$refs.table.handleResize(); } - } + }, + computed: { + productPackageTypes() { + let obj = {}; - return obj; - } - }, - created() { - this.index(); - this.settings(); - this.agents(); - }, - methods: { - editRender(key, h, context) { - if (!this.editModel) { - return h('span', context.row[key]); - } + let packages = this.settingsData.package ? this.settingsData.package : {}; - let options = []; + for (const key in packages) { + const element = packages[key]; - let arr; - if (key === 'product') { - arr = Object.values(this.settingsData['package']).join(",").split(","); - } else if (key === 'vehicle_type') { - arr = Object.values(this.settingsData['vehicle']).join(",").split(","); - } else { - arr = this.settingsData[key]; - } + for (let index = 0; index < element.length; index++) { + const value = element[index]; + obj[value] = key; + } + } - for (let index = 0; index < arr.length; index++) { - const element = arr[index]; - options.push(h('Option', { - props: { - value: element - } - }, element)); - } - - return h('Select', { - props: { - value: context.row[key], - size: 'small', - transfer: true + return obj; }, - on: { - input: (value) => { - let index = this.getIndex(context.row); - let property = this.properties.get(index); - property[key] = value; - this.properties.set(index, property); + vehicleTypeVehicleGroups() { + let obj = {}; + + let vehicles = this.settingsData.vehicle ? this.settingsData.vehicle : {}; + + for (const key in vehicles) { + const element = vehicles[key]; + + for (let index = 0; index < element.length; index++) { + const value = element[index]; + obj[value] = key; + } + } + + return obj; + } + }, + created() { + this.index(); + this.settings(); + this.agents(); + }, + methods: { + editRender(key, h, context) { + if (!this.editModel) { + return h('span', context.row[key]); + } + + let options = []; + + let arr; + if (key === 'product') { + arr = Object.values(this.settingsData['package']).join(",").split(","); + } else if (key === 'vehicle_type') { + arr = Object.values(this.settingsData['vehicle']).join(",").split(","); + } else { + arr = this.settingsData[key]; + } + + for (let index = 0; index < arr.length; index++) { + const element = arr[index]; + options.push(h('Option', { + props: { + value: element + } + }, element)); + } + + return h('Select', { + props: { + value: context.row[key], + size: 'small', + transfer: true + }, + on: { + input: (value) => { + let index = this.getIndex(context.row); + let property = this.properties.get(index); + property[key] = value; + this.properties.set(index, property); + this.changePage(this.page.page); + this.updates.set(index, this.properties.get(index)); + } + } + }, options); + }, + /** + * [index 列表] + * @param {Number} company_id [description] + * @return {[type]} [description] + */ + index(page = 1) { + if (!this.properties.size) { + this.isShowLoading(true); + API.index().then(res => { + if (res.code === 0) { + let properties = new Map(); + + res.data.forEach(element => { + properties.set(this.getIndex(element), element); + }); + + this.properties = properties; + this.changePage(page); + this.complete(); + } + this.isShowLoading(false); + }); + } else { + this.changePage(page); + } + }, + complete() { + let companies = {}; + + let properties = Array.from(this.properties.values()); + + properties.forEach((item) => { + companies[item.company_id] = item.company_name; + }); + + let companyArray = []; + + for (const key in companies) { + companyArray.push({ id: key, name: companies[key] }); + } + + this.companies = companyArray; + + let packages = {}; + + properties.forEach((item) => { + packages[item.package_id] = item.package_name; + }); + + let packageArray = []; + + for (const key in packages) { + packageArray.push({ id: key, name: packages[key] }); + } + + this.packages = packageArray; + }, + /** + * [request 刷新] + * @return {[type]} [description] + */ + request() { + this.properties = []; + this.index(); + }, + resetSearch() { + for (let k in this.params) { + this.params[k] = ''; + } + this.index(1); + }, + changeLimit(limit) { + this.page.limit = limit; + this.changePage(1); + }, + changePage(page) { + this.page.page = page; + + let properties = Array.from(this.properties.values()); + + if (this.params.company_id !== '' && this.params.company_id !== undefined) { + properties = properties.filter(el => { return el.company_id == this.params.company_id; }); + } + + if (this.params.package_id !== '' && this.params.package_id !== undefined) { + properties = properties.filter(el => { return el.package_id == this.params.package_id; }); + } + + if (this.params.status !== '' && this.params.status !== undefined) { + if (this.params.status === 0) { + properties = properties.filter(el => { return el.product !== '' && el.province !== null; }); + } else if (this.params.status === 1) { + properties = properties.filter(el => { return el.product === '' || el.province === null; }); + } + } + + this.page.total = properties.length; + + this.showData = properties.slice((page - 1) * this.page.limit, page * this.page.limit); + }, + agents() { + if (!this.agentsData.length) { + API.agents().then(res => { + if (res.code === 0) { + this.agentsData = res.data; + } + }); + } + }, + settings() { + if (!this.settingsData.length) { + API.settings().then(res => { + if (res.code === 0) { + this.settingsData = res.data; + } + }); + } + }, + updateSettings(values) { + this.settingsData = values; + }, + ok() { + if (!this.updates.size) { + this.$Message.warning('数据未修改'); + this.editModel = false; + return; + } + + this.isShowLoading(true); + + let updates = []; + + this.updates.forEach((element) => { + let obj = {}; + for (const key in element) { + if (this.only.indexOf(key) !== -1) { + obj[key] = element[key]; + } + } + updates.push(obj); + }); + + console.log("updates", updates); + + API.store({ data: updates }).then(res => { + if (res.code === 0) { + this.updates = new Map(); + this.editModel = false; + } + this.isShowLoading(false); + }); + }, + handleProvinceSuccess(data) { + let index = this.getIndex(data); + this.properties.set(index, data); this.changePage(this.page.page); this.updates.set(index, this.properties.get(index)); - } - } - }, options); - }, - /** - * [index 列表] - * @param {Number} company_id [description] - * @return {[type]} [description] - */ - index(page = 1) { - if (!this.properties.size) { - this.isShowLoading(true); - API.index().then(res => { - if (res.code === 0) { - let properties = new Map(); + }, + handleAgentSuccess(data) { + let index = this.getIndex(data); + this.properties.set(index, data); + this.changePage(this.page.page); + this.updates.set(index, this.properties.get(index)); + }, + exportExcel() { + let params = {}; - res.data.forEach(element => { - properties.set(this.getIndex(element), element); + for (const key in this.params) { + const element = this.params[key]; + + if (element !== '' && element !== undefined) { + params[key] = element; + } + } + + this.isShowLoading(true); + + API.exportExcel(params).then(res => { + if (res.code === 0) { + if (res.data) { + this.downloadFile(res.data); + } else { + this.$Modal.success({ + title: '提示', + content: '当前导出数据量大,已进入后台队列导出模式,请稍后至导出列表查看下载。' + }); + } + } + this.isShowLoading(false); + }).catch(() => { + this.isShowLoading(false); + }); + }, + importExcel(file) { + this.isShowLoading(true); + API.importExcel(file).then(res => { + if (res.code === 0) { + this.request(); + this.$Message.success(res.message); + } + + this.isShowLoading(false); }); - this.properties = properties; - this.changePage(page); - this.complete(); - } - this.isShowLoading(false); - }); - } else { - this.changePage(page); - } - }, - complete() { - let companies = {}; - - let properties = Array.from(this.properties.values()); - - properties.forEach((item) => { - companies[item.company_id] = item.company_name; - }); - - let companyArray = []; - - for (const key in companies) { - companyArray.push({ id: key, name: companies[key] }); - } - - this.companies = companyArray; - - let packages = {}; - - properties.forEach((item) => { - packages[item.package_id] = item.package_name; - }); - - let packageArray = []; - - for (const key in packages) { - packageArray.push({ id: key, name: packages[key] }); - } - - this.packages = packageArray; - }, - /** - * [request 刷新] - * @return {[type]} [description] - */ - request() { - this.properties = []; - this.index(); - }, - resetSearch() { - for (let k in this.params) { - this.params[k] = ''; - } - this.index(1); - }, - changeLimit(limit) { - this.page.limit = limit; - this.changePage(1); - }, - changePage(page) { - this.page.page = page; - - let properties = Array.from(this.properties.values()); - - if (this.params.company_id !== '' && this.params.company_id !== undefined) { - properties = properties.filter(el => { return el.company_id == this.params.company_id; }); - } - - if (this.params.package_id !== '' && this.params.package_id !== undefined) { - properties = properties.filter(el => { return el.package_id == this.params.package_id; }); - } - - if (this.params.status !== '' && this.params.status !== undefined) { - if (this.params.status === 0) { - properties = properties.filter(el => { return el.product !== '' && el.province !== null; }); - } else if (this.params.status === 1) { - properties = properties.filter(el => { return el.product === '' || el.province === null; }); + return false; + }, + getIndex(row) { + return row.company_id + '_' + row.package_id; } - } - - this.page.total = properties.length; - - this.showData = properties.slice((page - 1) * this.page.limit, page * this.page.limit); - }, - agents() { - if (!this.agentsData.length) { - API.agents().then(res => { - if (res.code === 0) { - this.agentsData = res.data; - } - }); - } - }, - settings() { - if (!this.settingsData.length) { - API.settings().then(res => { - if (res.code === 0) { - this.settingsData = res.data; - } - }); - } - }, - updateSettings(values) { - this.settingsData = values; - }, - ok() { - if (!this.updates.size) { - this.$Message.warning('数据未修改'); - this.editModel = false; - return; - } - - this.isShowLoading(true); - - let updates = []; - - this.updates.forEach((element) => { - let obj = {}; - for (const key in element) { - if (this.only.indexOf(key) !== -1) { - obj[key] = element[key]; - } - } - updates.push(obj); - }); - - console.log("updates", updates); - - API.store({ data: updates }).then(res => { - if (res.code === 0) { - this.updates = new Map(); - this.editModel = false; - } - this.isShowLoading(false); - }); - }, - handleProvinceSuccess(data) { - let index = this.getIndex(data); - this.properties.set(index, data); - this.changePage(this.page.page); - this.updates.set(index, this.properties.get(index)); - }, - handleAgentSuccess(data) { - let index = this.getIndex(data); - this.properties.set(index, data); - this.changePage(this.page.page); - this.updates.set(index, this.properties.get(index)); - }, - exportExcel() { - let params = {}; - - for (const key in this.params) { - const element = this.params[key]; - - if (element !== '' && element !== undefined) { - params[key] = element; - } - } - - this.isShowLoading(true); - - API.exportExcel(params).then(res => { - if (res.code === 0) { - if (res.data) { - this.downloadFile(res.data); - } else { - this.$Modal.success({ - title: '提示', - content: '当前导出数据量大,已进入后台队列导出模式,请稍后至导出列表查看下载。' - }); - } - } - this.isShowLoading(false); - }).catch(() => { - this.isShowLoading(false); - }); - }, - importExcel(file) { - this.isShowLoading(true); - API.importExcel(file).then(res => { - if (res.code === 0) { - this.request(); - this.$Message.success(res.message); - } - - this.isShowLoading(false); - }); - - return false; - }, - getIndex(row) { - return row.company_id + '_' + row.package_id; } - } }; 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..462f295f --- /dev/null +++ b/frontend/src/views/virtual/properties/js/package_set.js @@ -0,0 +1,68 @@ +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: '', + } + }, + data() { + return { + my_show: false, + loading: false, + packageList:[], + packageSetList:[ + { + productName:'',//产品名称 + percent:'',//占比 + } + ] + }; + }, + mounted() { + }, + watch: { + show(bool) { + this.my_show = bool; + if (bool) { + this.getPackageList(); + } + }, + }, + methods: { + getPackageList() { + let data = new Object; + // data.id= this.id; + data.id = 21; + 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) + } + }) + }, + addSet() { + + }, + visibleChange(bool) { + if (!bool) { + this.$emit('update:show', false); + } + }, + } +}; 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..7e65d236 --- /dev/null +++ b/frontend/src/views/virtual/properties/js/platform_set.js @@ -0,0 +1,189 @@ +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 + }, + percentList: {},//储存每个占比的数据 + applyidList: {},//储存每个平台ID的数据 + }; + }, + components: { + agentSet: resolve => require(['views/virtual/properties/agent_set'], resolve), + }, + mounted() { + this.getApplyList(); + }, + watch: { + show(bool) { + this.my_show = bool; + if (bool) { + this.getApplyList(); + this.getPlatformSetList(); + } + }, + }, + methods: { + getApplyList() { + let data = new Object; + data.name = this.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) { + 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.applyList.forEach(item => { + if (item.id == data.value) { + this.applySetList[index].info.appName = item.name; + this.applySetList[index].info.appType = item.appType; + } + }) + }, + handleInput(data, appId) { + if (data <= 0) { + this.$Message.error('占比必须大于零'); + } + this.percentList[appId] = Number(data); + }, + 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) { + let percentTotal = 0 + for (let k in this.percentList) { + if (this.percentList[k] <= 0) { + this.$Message.error('每个平台占比必须大于零'); + return false + } + percentTotal += this.percentList[k]; + } + if (percentTotal != 100) { + this.$Message.error('占比总和必须等于100'); + return + } + 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.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; + } + }) + }, + delSet(data) { + this.applySetList.splice(data, 1) + }, + 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 + }; + this.percentList = {}; + this.applyidList = {}; + + }, + } +}; 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..22ec22aa --- /dev/null +++ b/frontend/src/views/virtual/properties/package_set.vue @@ -0,0 +1,33 @@ + + 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..aa289622 --- /dev/null +++ b/frontend/src/views/virtual/properties/platform_set.vue @@ -0,0 +1,36 @@ + +