From 54fce285f0819932489b5a97a9cafac53599d52d Mon Sep 17 00:00:00 2001 From: pengyh Date: Tue, 31 Mar 2020 19:04:13 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=BA=94=E7=94=A8=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E8=BD=A6=E8=BE=86=E9=85=8D=E7=BD=AE=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/public/config.js | 3 +- frontend/src/api/virtual/properties.js | 65 ++++-- frontend/src/main.js | 3 +- frontend/src/service/service.js | 142 +++++++----- .../views/virtual/properties/configure.vue | 33 +++ .../src/views/virtual/properties/index.vue | 209 ++++++++---------- .../views/virtual/properties/js/configure.js | 92 ++++++++ .../src/views/virtual/properties/js/index.js | 136 +++++++----- 8 files changed, 426 insertions(+), 257 deletions(-) create mode 100644 frontend/src/views/virtual/properties/configure.vue create mode 100644 frontend/src/views/virtual/properties/js/configure.js diff --git a/frontend/public/config.js b/frontend/public/config.js index 030346b9..543f8d78 100644 --- a/frontend/public/config.js +++ b/frontend/public/config.js @@ -3,7 +3,8 @@ var CONFIG = { login_background: '/assets/login_background.jpg', logo_big: '/assets/logo_big.png', logo_small: '/assets/logo_small.png', - url: (window.location.hostname === 'localhost') ? 'http://vd.dipp.ink/' : '/' + url: (window.location.hostname === 'localhost') ? 'http://vd.dipp.ink/' : '/', + ascsUrl: (window.location.hostname === 'localhost') ? 'http://172.16.14.91:8080/' : '/' }; window.CONFIG = CONFIG; diff --git a/frontend/src/api/virtual/properties.js b/frontend/src/api/virtual/properties.js index 0fc9fe77..25e0ac2b 100644 --- a/frontend/src/api/virtual/properties.js +++ b/frontend/src/api/virtual/properties.js @@ -8,9 +8,9 @@ * @return {[type]} [description] */ export function settings(data) { - return service.get('api/virtual/properties/settings', { - params: data - }); + return service.get('api/virtual/properties/settings', { + params: data + }); } /** @@ -19,9 +19,9 @@ export function settings(data) { * @return {[type]} [description] */ export function agents(data) { - return service.get('api/virtual/properties/agents', { - params: data - }); + return service.get('api/virtual/properties/agents', { + params: data + }); } /** @@ -30,7 +30,7 @@ export function agents(data) { * @return {[type]} [description] */ export function settingsStore(data) { - return service.post('api/virtual/properties/settings', data); + return service.post('api/virtual/properties/settings', data); } /** @@ -39,9 +39,9 @@ export function settingsStore(data) { * @return {[type]} [description] */ export function index(data) { - return service.get('api/virtual/properties/index', { - params: data - }); + return service.get('api/virtual/properties/index', { + params: data + }); } /** @@ -50,7 +50,7 @@ export function index(data) { * @return {[type]} [description] */ export function store(data) { - return serviceForm.post('api/virtual/properties/store', data); + return serviceForm.post('api/virtual/properties/store', data); } /** @@ -59,9 +59,9 @@ export function store(data) { * @return {[type]} [description] */ export function exportExcel(data) { - return service.get('api/virtual/properties/export', { - params: data - }); + return service.get('api/virtual/properties/export', { + params: data + }); } /** @@ -70,15 +70,36 @@ export function exportExcel(data) { * @return {[type]} [description] */ export function importExcel(file) { - let config = { - headers: { - 'Content-Type': 'multipart/form-data' - } - }; + let config = { + headers: { + 'Content-Type': 'multipart/form-data' + } + }; - let params = new FormData(); + let params = new FormData(); - params.append('file', file); + params.append('file', file); - return service.post('api/virtual/properties/import', params, config); + return service.post('api/virtual/properties/import', params, config); } + +/** + * [getCarAndplatformList 展示所有的平台车辆] + * @param {[type]} data [description] + * @return {[type]} [description] + */ + +export function getCarTypeToPlatformList(data) { + return fetch.get('setting/list', { params: data }) +} + +/** + * [import 展示所有的平台车辆] + * @param {[type]} data [description] + * @return {[type]} [description] + */ + +export function saveCarTypeToPlatform(data) { + return fetch.post('setting/update', data) +} + diff --git a/frontend/src/main.js b/frontend/src/main.js index 754a852f..34592e27 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -7,7 +7,7 @@ import iView from "iview"; import iviewArea from "iview-area"; import Cookies from "js-cookie"; import Treeselect from "@riophae/vue-treeselect"; -import { service, serviceForm } from "service/service"; +import { service, serviceForm,fetch} from "service/service"; import App from "./App"; import router from "./router"; import store from "./store"; @@ -52,3 +52,4 @@ window.md5 = md5; window.jquery = window.$ = jquery; window.service = service; window.serviceForm = serviceForm; +window.fetch = fetch; diff --git a/frontend/src/service/service.js b/frontend/src/service/service.js index 6436b617..f513b62e 100644 --- a/frontend/src/service/service.js +++ b/frontend/src/service/service.js @@ -6,85 +6,102 @@ let domain = window.CONFIG.url; // 创建axios实例 export const service = axios.create({ - timeout: 1800000, - headers: { - post: { - 'Content-Type': 'application/x-www-form-urlencoded' - } - }, - baseURL: domain + timeout: 1800000, + headers: { + post: { + 'Content-Type': 'application/x-www-form-urlencoded' + } + }, + baseURL: domain }); export const serviceForm = axios.create({ - timeout: 1800000, - headers: { - post: { - 'Content-Type': 'multipart/form-data' - } - }, - baseURL: domain + timeout: 1800000, + headers: { + post: { + 'Content-Type': 'multipart/form-data' + } + }, + baseURL: domain }); -// http request 拦截器 -let request = function(config) { - const token = getToken(); - // 判断是否存在token,如果存在的话,则每个http header都加上token - if (token) { - config.headers.Authorization = `Bearer ${token}`; - } +export const fetch = axios.create({ + timeout: 1800000, + headers: { + 'Content-Type': 'application/json; charset=utf-8' + }, + baseURL: window.CONFIG.ascsUrl +}) - // 配置取消请求 - if (window._source) { - config.cancelToken = window._source.token; - } - return config; +// http request 拦截器 +let request = function (config) { + const token = getToken(); + // 判断是否存在token,如果存在的话,则每个http header都加上token + if (token) { + config.headers.Authorization = `Bearer ${token}`; + } + + // 配置取消请求 + if (window._source) { + config.cancelToken = window._source.token; + } + return config; }; -let request_err = function(err) { - Message.error('请求超时'); - return Promise.reject(err); +//fetch 的 http request 拦截器 +let fetchRequest = function (config) { + // 配置取消请求 + if (window._source) { + config.cancelToken = window._source.token; + } + return config; +}; + +let request_err = function (err) { + Message.error('请求超时'); + return Promise.reject(err); }; // http response 拦截器 -let response = function(res) { - const data = res.data; - const message = data.message || '未知错误'; +let response = function (res) { + const data = res.data; + const message = data.message || '未知错误'; - if (res.status) { - switch (res.status) { - case 200: - if (data.code !== 0) { - Message.error(message); + if (res.status) { + switch (res.status) { + case 200: + if (data.code !== 0) { + Message.error(message); + } + break; } - break; } - } - return data; + return data; }; -let response_err = function(err) { - if (err.response) { - const data = err.response.data; - const message = data.message ? data.message : '未知错误'; - switch (err.response.status) { - case 401: - if ([40001, 40002, 40003, 40008].includes(data.code)) { - // 40001未登录、40002未激活、40003已禁用、40008token未传递 - localStorage.clear(); - removeToken(); - vm.$router.replace({ path: '/login', query: { redirect: encodeURIComponent(vm.$route.fullPath) } }); - Message.error(message); +let response_err = function (err) { + if (err.response) { + const data = err.response.data; + const message = data.message ? data.message : '未知错误'; + switch (err.response.status) { + case 401: + if ([40001, 40002, 40003, 40008].includes(data.code)) { + // 40001未登录、40002未激活、40003已禁用、40008token未传递 + localStorage.clear(); + removeToken(); + vm.$router.replace({ path: '/login', query: { redirect: encodeURIComponent(vm.$route.fullPath) } }); + Message.error(message); + } + break; + case 500: + Message.error('服务器忙,请稍后再试'); + break; + default: + Message.error(message); + break; } - break; - case 500: - Message.error('服务器忙,请稍后再试'); - break; - default: - Message.error(message); - break; } - } - return Promise.resolve(err); + return Promise.resolve(err); }; service.interceptors.request.use(request, request_err); @@ -93,6 +110,9 @@ service.interceptors.response.use(response, response_err); serviceForm.interceptors.request.use(request, request_err); serviceForm.interceptors.response.use(response, response_err); +fetch.interceptors.request.use(fetchRequest, request_err); +fetch.interceptors.response.use(response, response_err); + axios.interceptors.response.use(response, response_err); window.axios = axios; diff --git a/frontend/src/views/virtual/properties/configure.vue b/frontend/src/views/virtual/properties/configure.vue new file mode 100644 index 00000000..0fa326cc --- /dev/null +++ b/frontend/src/views/virtual/properties/configure.vue @@ -0,0 +1,33 @@ + + + diff --git a/frontend/src/views/virtual/properties/index.vue b/frontend/src/views/virtual/properties/index.vue index c9e6370f..3d187781 100644 --- a/frontend/src/views/virtual/properties/index.vue +++ b/frontend/src/views/virtual/properties/index.vue @@ -1,139 +1,104 @@ 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/index.js b/frontend/src/views/virtual/properties/js/index.js index d9e720ef..f4d98574 100644 --- a/frontend/src/views/virtual/properties/js/index.js +++ b/frontend/src/views/virtual/properties/js/index.js @@ -5,7 +5,8 @@ export default { 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) + UiSettings: resolve => require(['views/virtual/properties/settings'], resolve), + UiConfigure: resolve => require(['views/virtual/properties/configure'],resolve) }, data() { return { @@ -17,6 +18,7 @@ export default { }, only: ['company_id', 'package_id', 'product', 'vehicle_type', 'company', 'platform', 'customer', 'province', 'agent'], updates: new Map(), + configureShow: false, settingsShow: false, settingsData: {}, agentsData: {}, @@ -88,54 +90,54 @@ export default { 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: '平台/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', @@ -210,7 +212,41 @@ export default { 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); + } + } + } ] }; }, From f528103219575c38ae1bfdef5c9cd42ba1d79450 Mon Sep 17 00:00:00 2001 From: pengyh Date: Thu, 2 Apr 2020 21:16:04 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/virtual/properties.js | 52 +- frontend/src/service/service.js | 4 +- .../views/virtual/properties/agent_set.vue | 35 + .../views/virtual/properties/cartype_set.vue | 35 + .../views/virtual/properties/configure.vue | 9 +- .../src/views/virtual/properties/index.vue | 2 + .../views/virtual/properties/js/agent_set.js | 115 ++ .../virtual/properties/js/cartype_set.js | 122 ++ .../src/views/virtual/properties/js/index.js | 1071 +++++++++-------- .../virtual/properties/js/package_set.js | 68 ++ .../virtual/properties/js/platform_set.js | 189 +++ .../views/virtual/properties/package_set.vue | 33 + .../views/virtual/properties/platform_set.vue | 36 + 13 files changed, 1230 insertions(+), 541 deletions(-) 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/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/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/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 @@ + + From 5dfc994526a5ec96e3a460dab5eb8bd139fe8d81 Mon Sep 17 00:00:00 2001 From: pengyh Date: Fri, 3 Apr 2020 16:36:28 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=AE=9A=E4=BB=B7=E7=AE=A1=E7=90=86-?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E7=AE=A1=E7=90=86-=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/virtual/properties.js | 9 + .../views/virtual/properties/agent_set.vue | 10 +- .../views/virtual/properties/cartype_set.vue | 8 +- .../views/virtual/properties/js/agent_set.js | 216 +++++++++++++--- .../virtual/properties/js/cartype_set.js | 230 +++++++++++++++--- .../virtual/properties/js/package_set.js | 169 +++++++++++-- .../virtual/properties/js/platform_set.js | 155 ++++++++---- .../views/virtual/properties/package_set.vue | 17 +- .../views/virtual/properties/platform_set.vue | 9 +- 9 files changed, 661 insertions(+), 162 deletions(-) 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 @@ - - -
+ - - + +