应用类型车辆配置开发

This commit is contained in:
pengyh 2020-03-31 19:04:13 +08:00
parent b5e8560472
commit 54fce285f0
8 changed files with 426 additions and 257 deletions

View File

@ -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;

View File

@ -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)
}

View File

@ -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;

View File

@ -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;

View File

@ -0,0 +1,33 @@
<template>
<Drawer :mask-closable="false" @on-visible-change="visibleChange" title="应用类型车辆配置" v-model="my_show" width="900">
<div class="page-edit-wrap uinn-lr20">
<Row>
<Col span="3" style="line-height:32px">平台类型</Col>
<Col span="21">
<Select v-model="param.name" style="width:400px" @on-change="getCarTypes">
<Option v-for="(item,key) in configure" :value="key" :key="key">{{key}}</Option>
</Select>
</Col>
</Row>
<Row style="margin-top:20px" v-if="param.name">
<Col span="3" style="line-height:32px">车辆类型</Col>
<Col span="21">
<Tabs v-model="carTypeName">
<TabPane v-for="(item,key) in carTypeList" :key="key" :name="key" :label="key">
<CheckboxGroup v-model="param.value[key]">
<Checkbox :label="name" v-for="(name,index) in item" :key="index"></Checkbox>
</CheckboxGroup>
</TabPane>
</Tabs>
</Col>
</Row>
</div>
<div class="ta-c">
<Button @click="clear" class="w-80 umar-r5" ghost type="primary">取消</Button>
<Button :loading="loading" @click="ok" class="w-80" type="primary">确认</Button>
</div>
</Drawer>
</template>
<script src="./js/configure.js"></script>

View File

@ -1,139 +1,104 @@
<template>
<div class="page-wrap">
<ui-loading :show="page_loading.show"></ui-loading>
<div class="page-wrap">
<ui-loading :show="page_loading.show"></ui-loading>
<div class="page-handle-wrap">
<ul class="handle-wraper bd-b">
<li class="f-l">
<div class="text-exp">
<b>全部信息</b>
</div>
</li>
<li class="f-r">
<div class="handle-item lh-32" v-if="hasPermission('update')">
<b class="umar-r10">编辑模式</b>
<Switch v-model="editModel" size="large">
<span slot="open"></span>
<span slot="close"></span>
</Switch>
</div>
<div class="page-handle-wrap">
<ul class="handle-wraper bd-b">
<li class="f-l">
<div class="text-exp">
<b>全部信息</b>
</div>
</li>
<li class="f-r">
<div class="handle-item lh-32" v-if="hasPermission('update')">
<b class="umar-r10">编辑模式</b>
<Switch v-model="editModel" size="large">
<span slot="open"></span>
<span slot="close"></span>
</Switch>
</div>
<div class="handle-item">
<Button
@click="ok"
icon="md-checkmark"
type="primary"
v-if="hasPermission('update') && editModel"
>保存修改</Button>
</div>
<div class="handle-item">
<Button @click="ok" icon="md-checkmark" type="primary" v-if="hasPermission('update') && editModel">保存修改</Button>
</div>
<div class="handle-item">
<Button
@click="settingsShow = true"
icon="md-add"
type="primary"
v-if="hasPermission('create')"
>配置管理</Button>
</div>
<div class="handle-item">
<Button @click="settingsShow = true" icon="md-add" type="primary" v-if="hasPermission('create')">配置管理</Button>
</div>
<div class="handle-item">
<Button @click="search.show=!search.show" ghost icon="ios-search" type="primary">搜索</Button>
</div>
<div class="handle-item">
<Button @click="configureShow = true" type="primary">应用类型车辆配置</Button>
</div>
<div class="handle-item">
<Button @click="request()" icon="md-refresh">刷新</Button>
</div>
</li>
</ul>
<div class="handle-item">
<Button @click="search.show=!search.show" ghost icon="ios-search" type="primary">搜索</Button>
</div>
<div class="search-wrap" v-show="search.show">
<ul class="handle-wraper">
<li class="handle-item w-250">
<Select placeholder="企业名称" v-model.trim="params.company_id" clearable filterable>
<Option
:key="index"
:value="item.id"
v-for="(item, index) in companies"
>{{ item.name }}</Option>
</Select>
</li>
<div class="handle-item">
<Button @click="request()" icon="md-refresh">刷新</Button>
</div>
</li>
</ul>
<li class="handle-item w-250">
<Select placeholder="套餐名称" v-model.trim="params.package_id" clearable filterable>
<Option
:key="index"
:value="item.id"
v-for="(item, index) in packages"
>{{ item.name }}</Option>
</Select>
</li>
<div class="search-wrap" v-show="search.show">
<ul class="handle-wraper">
<li class="handle-item w-250">
<Select placeholder="企业名称" v-model.trim="params.company_id" clearable filterable>
<Option :key="index" :value="item.id" v-for="(item, index) in companies">{{ item.name }}</Option>
</Select>
</li>
<li class="handle-item w-250">
<Select placeholder="设置状态" v-model.trim="params.status" clearable>
<Option :value="0">已设置</Option>
<Option :value="1">未设置</Option>
</Select>
</li>
<li class="handle-item w-250">
<Select placeholder="套餐名称" v-model.trim="params.package_id" clearable filterable>
<Option :key="index" :value="item.id" v-for="(item, index) in packages">{{ item.name }}</Option>
</Select>
</li>
<li class="f-r">
<div class="handle-item">
<Upload :before-upload="importExcel" action="/" :format="['xls','xlsx','csv']">
<Button type="primary" ghost>导入</Button>
</Upload>
<li class="handle-item w-250">
<Select placeholder="设置状态" v-model.trim="params.status" clearable>
<Option :value="0">已设置</Option>
<Option :value="1">未设置</Option>
</Select>
</li>
<li class="f-r">
<div class="handle-item">
<Upload :before-upload="importExcel" action="/" :format="['xls','xlsx','csv']">
<Button type="primary" ghost>导入</Button>
</Upload>
</div>
<div class="handle-item" v-if="hasPermission('output')">
<Button @click="exportExcel" type="warning" ghost>导出</Button>
</div>
<div class="handle-item">
<Button @click="index(1)" ghost type="primary">立即搜索</Button>
</div>
<div class="handle-item">
<Button @click="resetSearch" ghost type="warning">重置搜索</Button>
</div>
</li>
</ul>
</div>
</div>
<div class="handle-item" v-if="hasPermission('output')">
<Button @click="exportExcel" type="warning" ghost>导出</Button>
</div>
<div class="page-list-wrap">
<Table ref="table" :columns="columns" :data="showData ? showData : []"></Table>
</div>
<div class="handle-item">
<Button @click="index(1)" ghost type="primary">立即搜索</Button>
</div>
<div class="handle-item">
<Button @click="resetSearch" ghost type="warning">重置搜索</Button>
</div>
</li>
</ul>
</div>
<div class="page-turn-wrap" v-if="showData">
<Page :current="Number(page.page)" :page-size="Number(page.limit)" :page-size-opts="[10, 20, 50, 100]" :total="Number(page.total)" @on-change="changePage" @on-page-size-change="changeLimit" show-elevator show-total show-sizer></Page>
</div>
<ui-edit :data="editObj.data" :isUpdate="editObj.isUpdate" :show.sync="editObj.show" :provinces="settingsData.province ? settingsData.province : []" @province-success="handleProvinceSuccess"></ui-edit>
<ui-agent :data="agentObj.data" :isUpdate="agentObj.isUpdate" :show.sync="agentObj.show" :agents="agentsProp ? agentsProp : []" :platforms="settingsData.platform ? settingsData.platform : []" @agent-success="handleAgentSuccess"></ui-agent>
<ui-settings :data="settingsData" :show.sync="settingsShow" @store-success="updateSettings"></ui-settings>
<ui-configure :show.sync="configureShow"></ui-configure>
</div>
<div class="page-list-wrap">
<Table ref="table" :columns="columns" :data="showData ? showData : []"></Table>
</div>
<div class="page-turn-wrap" v-if="showData">
<Page
:current="Number(page.page)"
:page-size="Number(page.limit)"
:page-size-opts="[10, 20, 50, 100]"
:total="Number(page.total)"
@on-change="changePage"
@on-page-size-change="changeLimit"
show-elevator
show-total
show-sizer
></Page>
</div>
<ui-edit
:data="editObj.data"
:isUpdate="editObj.isUpdate"
:show.sync="editObj.show"
:provinces="settingsData.province ? settingsData.province : []"
@province-success="handleProvinceSuccess"
></ui-edit>
<ui-agent
:data="agentObj.data"
:isUpdate="agentObj.isUpdate"
:show.sync="agentObj.show"
:agents="agentsProp ? agentsProp : []"
:platforms="settingsData.platform ? settingsData.platform : []"
@agent-success="handleAgentSuccess"
></ui-agent>
<ui-settings :data="settingsData" :show.sync="settingsShow" @store-success="updateSettings"></ui-settings>
</div>
</template>
<script src="./js/index.js"></script>

View File

@ -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: {}
};
},
}
};

View File

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