Commit fe04a447 by liimin

修改基础数据获取

1 parent eab908e0
...@@ -53,3 +53,12 @@ export function PostList (data = {}) { ...@@ -53,3 +53,12 @@ export function PostList (data = {}) {
data.method = `${path}post` data.method = `${path}post`
return request(data, RequestMethods.GET) return request(data, RequestMethods.GET)
} }
/**
* 获取基础数据
* @param {*} data 参数
*/
export function BaseDataApi (data = {}) {
data.method = `fims.configuration.from.conftype`
return request(data, RequestMethods.GET)
}
...@@ -2,13 +2,30 @@ ...@@ -2,13 +2,30 @@
* @Author: limin * @Author: limin
* @Date: 2019-09-01 19:06:01 * @Date: 2019-09-01 19:06:01
* @Last Modified by: limin * @Last Modified by: limin
* @Last Modified time: 2019-09-02 10:52:44 * @Last Modified time: 2019-09-04 12:11:33
*/ */
/**
* 前端基础数据管理对应的接口名称的key
*/
export const TYPE_NAME='confType'
/**
* 后台提供一个接 通过类型获取对应数据
* 此处定义类型
*/
export const ConfigType ={
STATION: 'STATION_TYPE',
POST:'POST_TYPE',
SUBSYS:'SUBSYSTEM_TYPE'
}
export const BaseData = { export const BaseData = {
ROLE: 'role', ROLE: {KEY:'role',TYPE:''},
COMPANY: 'company', // COMPANY: 'company',
DEPART: 'depart', // DEPART: 'depart',
STATION: 'station', STATION: {KEY:'station',TYPE:ConfigType.STATION},
POST:'post' POST:{KEY:'post',TYPE:ConfigType.POST},
SUBSYS:{KEY:'subsys',TYPE:ConfigType.SUBSYS}
} }
...@@ -58,8 +58,9 @@ export default { ...@@ -58,8 +58,9 @@ export default {
*/ */
const filter = btn => mapping ? mapping[data[mapping['field']]].includes(btn.label):true const filter = btn => mapping ? mapping[data[mapping['field']]].includes(btn.label):true
const $store = _this.$store.getters['d2admin/auth/curBtns'] const $store = _this.$store.getters['d2admin/auth/curBtns']
if(!$store) return h('div')
if(label){ //指定label if(label){ //指定label
const __item = $store && $store.find(btn => (btn.label === label) && filter(btn)) const __item = $store.find(btn => (btn.label === label) && filter(btn))
__item && curBtns.push(__item) __item && curBtns.push(__item)
}else { }else {
/** /**
......
...@@ -2,31 +2,30 @@ ...@@ -2,31 +2,30 @@
* @Author: limin * @Author: limin
* @Date: 2019-09-01 17:56:57 * @Date: 2019-09-01 17:56:57
* @Last Modified by: limin * @Last Modified by: limin
* @Last Modified time: 2019-09-02 11:20:15 * @Last Modified time: 2019-09-04 14:06:32
*/ */
import { FetchRoleList, CompanyList, DepartList, StationList,PostList } from '@/api/sys.base' import { FetchRoleList, CompanyList, DepartList, StationList,PostList , BaseDataApi } from '@/api/sys.base'
import { BaseData } from '@/common/constants' import { BaseData,TYPE_NAME,ConfigType } from '@/common/constants'
const map = { const map = {
[BaseData.ROLE]: FetchRoleList, [BaseData.ROLE.KEY]: FetchRoleList,
[BaseData.COMPANY]: CompanyList, // [BaseData.COMPANY]: CompanyList,
[BaseData.DEPART]: DepartList, // [BaseData.DEPART.KEY]: DepartList,
[BaseData.STATION]: StationList, [BaseData.STATION.KEY]: BaseDataApi,
[BaseData.POST]: PostList [BaseData.POST.KEY]: BaseDataApi,
[BaseData.SUBSYS.KEY]: BaseDataApi
} }
export default { export default {
namespaced: true, namespaced: true,
state: { state: {
// 所属公司
company: [],
// 角色 // 角色
role: [], role: [],
// 部门
depart: [],
// 站点 // 站点
station: [], station: [],
//职务 //职务
post:[] post:[],
//子系统
subsys:[]
}, },
actions: { actions: {
/** /**
...@@ -38,18 +37,19 @@ export default { ...@@ -38,18 +37,19 @@ export default {
return new Promise(async resolve => { return new Promise(async resolve => {
Promise.all([ Promise.all([
FetchRoleList(), FetchRoleList(),
CompanyList(), // CompanyList(),
DepartList(), // DepartList(),
StationList(), BaseDataApi({[TYPE_NAME]:ConfigType.STATION}),
PostList() BaseDataApi({[TYPE_NAME]:ConfigType.POST}),
]).then( async ([role, company, depart, station, post] = res) => { BaseDataApi({[TYPE_NAME]:ConfigType.SUBSYS})
]).then( async ([role,station, post,subsys] = res) => {
state.role = role state.role = role
state.station = station state.station = station
state.depart = depart state.subsys = subsys
state.company = company
state.post = post state.post = post
await dispatch('save2db', {path: `base`,value: {role, company, depart, station,post}}) await dispatch('save2db', {path: `base`,value: {role, station,post,subsys}})
resolve({ role, company, depart, station,post }) resolve({role, station,post,subsys})
}) })
}) })
}, },
...@@ -82,8 +82,8 @@ export default { ...@@ -82,8 +82,8 @@ export default {
if (state.role.length === 0) { if (state.role.length === 0) {
state = await dispatch('getFromdb','base') || await dispatch('init') state = await dispatch('getFromdb','base') || await dispatch('init')
} }
const {role, company, depart, station, post} = state const {role, station,post,subsys} = state
resolve({role, company, depart, station, post}) resolve({role, station,post,subsys})
}) })
}, },
/** /**
...@@ -125,7 +125,7 @@ export default { ...@@ -125,7 +125,7 @@ export default {
*/ */
getFromAjax ({ state, dispatch, commit }, name) { getFromAjax ({ state, dispatch, commit }, name) {
return new Promise(async resolve => { return new Promise(async resolve => {
const value = await map[name]() const value = await map[name]({[TYPE_NAME]:BaseData.find(data=>data.KEY===name).TYPE})
resolve(value) resolve(value)
}) })
} }
......
...@@ -35,35 +35,21 @@ ...@@ -35,35 +35,21 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-form-item label="所属公司:" prop="companyCode"> <el-form-item label="所属公司:" prop="companyName">
<el-select v-model="regForm.companyCode" placeholder="请选择" class="sigle-select"> <el-input v-model="regForm.companyName" placeholder="请输入公司名称"></el-input>
<el-option
:label="company.companyName"
:value="company.companyCode"
v-for="(company,index) in baseData.companys"
:key="index"
></el-option>
</el-select>
</el-form-item> </el-form-item>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="部门:" prop="departCode"> <el-form-item label="部门:" prop="departName">
<el-select v-model="regForm.departCode" placeholder="请选择"> <el-input v-model="regForm.departName" placeholder="请输入部门名称"></el-input>
<el-option
:label="depart.departName"
:value="depart.departCode"
v-for="(depart,index) in baseData.departs"
:key="index"
></el-option>
</el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="职务:" prop="postCode"> <el-form-item label="职务:" prop="postCode">
<el-select v-model="regForm.postCode" placeholder="请选择"> <el-select v-model="regForm.postCode" placeholder="请选择">
<el-option <el-option
:label="post.postName" :label="post.confValue"
:value="post.postCode" :value="post.confCode"
v-for="(post,index) in baseData.posts" v-for="(post,index) in baseData.posts"
:key="index" :key="index"
></el-option> ></el-option>
...@@ -74,8 +60,8 @@ ...@@ -74,8 +60,8 @@
<el-form-item label="所属站点:" prop="stationCode"> <el-form-item label="所属站点:" prop="stationCode">
<el-select v-model="regForm.stationCode" placeholder="请选择" class="sigle-select"> <el-select v-model="regForm.stationCode" placeholder="请选择" class="sigle-select">
<el-option <el-option
:label="station.stationName" :label="station.confValue"
:value="station.stationCode" :value="station.confCode"
v-for="(station,index) in baseData.stations" v-for="(station,index) in baseData.stations"
:key="index" :key="index"
></el-option> ></el-option>
...@@ -114,7 +100,7 @@ export default { ...@@ -114,7 +100,7 @@ export default {
confirm: '', confirm: '',
userName: '', userName: '',
mobile: '', mobile: '',
companyCode: [], companyName: [],
departName: '', departName: '',
postCode: '', postCode: '',
stationCode: '' stationCode: ''
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!