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); + } + } + } ] }; },