Commit c2e97b11 by liimin

1.完善注册 2.增加 基础数据vuex 管理

1 parent d5893268
import request from './request' import request from './request'
const path = 'fims.device.' const path = 'fims.device.'
function getListApi(data) { function getListApi (data) {
data.method = `${path}list` data.method = `${path}list`
return request(data) return request(data)
} }
......
...@@ -2,29 +2,29 @@ import request from './request' ...@@ -2,29 +2,29 @@ import request from './request'
const path = 'fims.order.' const path = 'fims.order.'
function getListApi(data) { function getListApi (data) {
data.method = `${path}search` data.method = `${path}search`
return request(data) return request(data)
} }
function detailApi (data) { function detailApi (data) {
data.method = `${path}detail` data.method = `${path}detail`
return request(data) return request(data)
} }
function removeApi (data) { function removeApi (data) {
data.method = `${path}delete` data.method = `${path}delete`
return request(data) return request(data)
} }
function downloadApi (data) { function downloadApi (data) {
data.method = `${path}download` data.method = `${path}download`
return request(data) return request(data)
} }
export { export {
getListApi, getListApi,
detailApi, detailApi,
removeApi, removeApi,
downloadApi downloadApi
}
\ No newline at end of file \ No newline at end of file
}
...@@ -2,12 +2,15 @@ ...@@ -2,12 +2,15 @@
* @Author: limin * @Author: limin
* @Date: 2019-08-26 18:02:41 * @Date: 2019-08-26 18:02:41
* @Last Modified by: limin * @Last Modified by: limin
* @Last Modified time: 2019-08-29 03:55:24 * @Last Modified time: 2019-09-01 15:33:02
*/ */
import axios from '@/plugin/axios' import axios from '@/plugin/axios'
import sign from './sign' import sign from './sign'
const request = (params, method) => { import RequestMethods from './request.methods'
// import util from '@/libs/util'
const request = (params = {}, method = RequestMethods.GET) => {
// params = util.deepClone(params)
params.source = '' params.source = ''
params.app_key = '48e5e13229b82c1b4e6e8c96151f0637' params.app_key = '48e5e13229b82c1b4e6e8c96151f0637'
params.timestamp = new Date().getTime() params.timestamp = new Date().getTime()
...@@ -18,7 +21,7 @@ const request = (params, method) => { ...@@ -18,7 +21,7 @@ const request = (params, method) => {
const url = params.method const url = params.method
return axios({ return axios({
url, url,
method: method || 'get', method,
data: sign(params) data: sign(params)
}) })
} }
......
/*
* @Author: limin
* @Date: 2019-08-26 18:02:55
* @Last Modified by: limin
* @Last Modified time: 2019-09-01 17:18:41
*/
import request from './request'
import RequestMethods from './request.methods'
// 用户相关
const user_path = 'fims.user.'
/**
* 用户登录
* @param {*} data 参数
*/
export function AccountLogin (data) {
data.method = `${user_path}login`
return request(data, RequestMethods.POST)
}
/**
* 注册
* @param {*} data 参数
*/
export function Reg (data = {}) {
data.method = `${user_path}register`
return request(data, RequestMethods.GET)
}
/*
* @Author: limin
* @Date: 2019-08-26 18:02:55
* @Last Modified by: limin
* @Last Modified time: 2019-09-01 17:19:07
*/
import request from './request'
import RequestMethods from './request.methods'
// 基础数据
const path = 'fims.base.'
/**
* 获取站点列表
* @param {*} data 参数
*/
export function StationList (data = {}) {
data.method = `${path}station`
return request(data, RequestMethods.GET)
}
/**
* 获取公司列表
* @param {*} data 参数
*/
export function CompanyList (data = {}) {
data.method = `${path}company`
return request(data, RequestMethods.GET)
}
/**
* 获取部门列表
* @param {*} data 参数
*/
export function DepartList (data = {}) {
data.method = `${path}depart`
return request(data, RequestMethods.GET)
}
/**
* 获取角色列表
* @param {*} data 参数
*/
export function FetchRoleList (data = {}) {
data.method = `fims.role.list`
return request(data, RequestMethods.GET)
}
/*
* @Author: limin
* @Date: 2019-09-01 19:06:01
* @Last Modified by: limin
* @Last Modified time: 2019-09-01 19:06:01
*/
export const BaseData = {
ROLE: 'role',
COMPANY: 'company',
DEPART: 'depart',
STATION: 'station'
}
...@@ -8,4 +8,4 @@ ...@@ -8,4 +8,4 @@
import Vue from 'vue' import Vue from 'vue'
import focus from './src/focus' import focus from './src/focus'
Vue.directive(focus.name,focus)
\ No newline at end of file \ No newline at end of file
Vue.directive(focus.name, focus)
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
*/ */
export default { export default {
name:'focus', name: 'focus',
inserted: function (el) { inserted: function (el) {
el.querySelector('input').focus(); el.querySelector('input').focus()
} }
} }
...@@ -15,14 +15,14 @@ export default { ...@@ -15,14 +15,14 @@ export default {
data () { data () {
return { return {
predefine: [ predefine: [
'#FF0000','#008000','#0000FF' '#FF0000', '#008000', '#0000FF'
] ]
} }
}, },
computed: { computed: {
...mapState('d2admin', { ...mapState('d2admin', {
value:state=>state.color.value, value: state => state.color.value,
listTheme:state=>state.theme.list listTheme: state => state.theme.list
}) })
}, },
watch: { watch: {
...@@ -31,7 +31,7 @@ export default { ...@@ -31,7 +31,7 @@ export default {
} }
}, },
mounted () { mounted () {
this.predefine= [...this.predefine,...this.listTheme.map(theme=>theme.color)] this.predefine = [...this.predefine, ...this.listTheme.map(theme => theme.color)]
}, },
methods: { methods: {
...mapActions('d2admin/color', [ ...mapActions('d2admin/color', [
......
...@@ -46,100 +46,95 @@ ...@@ -46,100 +46,95 @@
</template> </template>
<script> <script>
import { mapState, mapActions } from "vuex"; import { mapState, mapActions } from 'vuex'
import { Message, MessageBox } from "element-ui"; import { Message, MessageBox } from 'element-ui'
export default { export default {
name: "PersonalPanel", name: 'PersonalPanel',
props: { props: {
user: { user: {
type: Object, type: Object,
default: { default: {
name: "admin", name: 'admin',
avatar: "@/assets/user.png", avatar: '@/assets/user.png',
role: "超级管理员", role: '超级管理员',
registeInfo: "注册时间:2018-12-25 " registeInfo: '注册时间:2018-12-25 '
} }
} }
}, },
computed: { computed: {
...mapState("d2admin/user", ["info"]) ...mapState('d2admin/user', ['info'])
}, },
data() { data () {
return {}; return {}
}, },
methods: { methods: {
...mapActions("d2admin/account", ["logout"]), ...mapActions('d2admin/account', ['logout']),
/** /**
* @description 登出 * @description 登出
*/ */
logOut() { logOut () {
this.$store.commit("d2admin/gray/set", true); this.$store.commit('d2admin/gray/set', true)
MessageBox.confirm("确定要注销当前用户吗", "注销用户", { MessageBox.confirm('确定要注销当前用户吗', '注销用户', {
confirmButtonText: "确定", confirmButtonText: '确定',
cancelButtonText: "取消", cancelButtonText: '取消',
type: "warning" type: 'warning'
}).then(async () => { }).then(async () => {
await this.$store.commit("d2admin/gray/set", false); await this.$store.commit('d2admin/gray/set', false)
// await this.$store.dispatch('d2admin/user/set', {}) // await this.$store.dispatch('d2admin/user/set', {})
await this.logout(); await this.logout()
this.$router.push('/login') this.$router.push('/login')
}) })
.catch(() => { .catch(() => {
this.$store.commit("d2admin/gray/set", false); this.$store.commit('d2admin/gray/set', false)
Message({ Message({
message: "取消注销操作" message: '取消注销操作'
}); })
}); })
}, },
clear(){ clear () {
this.$store.commit("d2admin/gray/set", true); this.$store.commit('d2admin/gray/set', true)
MessageBox.confirm("清空缓存将重置所有个性化设置并退出到登录界面", "清空缓存", { MessageBox.confirm('清空缓存将重置所有个性化设置并退出到登录界面', '清空缓存', {
confirmButtonText: "确定", confirmButtonText: '确定',
cancelButtonText: "取消", cancelButtonText: '取消',
type: "warning" type: 'warning'
}).then(async () => { }).then(async () => {
await this.$store.commit("d2admin/gray/set", false); await this.$store.commit('d2admin/gray/set', false)
await this.$store.dispatch('d2admin/db/set', { localStorage.clear();
dbName: 'sys',
path: '',
value: '',
user: true
})
window.location.reload() window.location.reload()
}) })
.catch(() => { .catch(() => {
this.$store.commit("d2admin/gray/set", false); this.$store.commit('d2admin/gray/set', false)
Message({ Message({
message: "取消清除缓存操作" message: '取消清除缓存操作'
}); })
}); })
}, },
comfirm(text,title,cancleText){ comfirm (text, title, cancleText) {
return new Promise((reject,resolve)=>{ return new Promise((reject, resolve) => {
this.$store.commit("d2admin/gray/set", true); this.$store.commit('d2admin/gray/set', true)
MessageBox.confirm(text, title, { MessageBox.confirm(text, title, {
confirmButtonText: "确定", confirmButtonText: '确定',
cancelButtonText: "取消", cancelButtonText: '取消',
type: "warning" type: 'warning'
}).then(async () => { }).then(async () => {
await this.$store.commit("d2admin/gray/set", false); await this.$store.commit('d2admin/gray/set', false)
resolve(true) resolve(true)
}) })
.catch(() => { .catch(() => {
this.$store.commit("d2admin/gray/set", false); this.$store.commit('d2admin/gray/set', false)
Message({ Message({
message: cancleText message: cancleText
}); })
reject() reject()
}); })
}) })
}, },
// 打开个人信息弹出框 // 打开个人信息弹出框
openUserMsgDialog: function() { openUserMsgDialog: function () {
console.log("aaaa"); console.log('aaaa')
} }
} }
}; }
</script> </script>
<style scoped> <style scoped>
...@@ -165,7 +160,7 @@ export default { ...@@ -165,7 +160,7 @@ export default {
} }
.avatar-container { .avatar-container {
display: inline-block; display: inline-block;
align: center; text-align: center;
} }
.name-role { .name-role {
font-size: 14px; font-size: 14px;
......
...@@ -7,7 +7,7 @@ import 'flex.css' ...@@ -7,7 +7,7 @@ import 'flex.css'
import '@/components' import '@/components'
// svg 图标 // svg 图标
import '@/assets/svg-icons' import '@/assets/svg-icons'
//指令 // 指令
import '@/directives' import '@/directives'
// 功能插件 // 功能插件
...@@ -31,7 +31,7 @@ export default { ...@@ -31,7 +31,7 @@ export default {
// 事件传递 // 事件传递
Vue.prototype.$event = new Vue() Vue.prototype.$event = new Vue()
// Element // Element
Vue.use(ElementUI,{ size: 'medium', zIndex: 3000 }) Vue.use(ElementUI, { size: 'medium', zIndex: 3000 })
// 插件 // 插件
Vue.use(pluginError) Vue.use(pluginError)
Vue.use(pluginLog) Vue.use(pluginLog)
......
import util from '@/libs/util.js' import util from '@/libs/util.js'
import router from '@/router' import router from '@/router'
import { AccountLogin } from '@api/sys.login' import { AccountLogin } from '@api/sys.account'
export default { export default {
namespaced: true, namespaced: true,
actions: { actions: {
...@@ -36,6 +36,8 @@ export default { ...@@ -36,6 +36,8 @@ export default {
await dispatch('d2admin/user/set', { await dispatch('d2admin/user/set', {
name: user.name name: user.name
}, { root: true }) }, { root: true })
// 强制初始化基础数据
await dispatch('d2admin/base/init', null, { root: true })
// 用户登录后从持久化数据加载一系列的设置 // 用户登录后从持久化数据加载一系列的设置
await dispatch('load') await dispatch('load')
// 结束 // 结束
...@@ -85,6 +87,8 @@ export default { ...@@ -85,6 +87,8 @@ export default {
// await dispatch('d2admin/size/set', 'medium', { root: true }) // await dispatch('d2admin/size/set', 'medium', { root: true })
// DB -> store 持久化数据加载全局尺寸 // DB -> store 持久化数据加载全局尺寸
await dispatch('d2admin/size/load', null, { root: true }) await dispatch('d2admin/size/load', null, { root: true })
// DB - > 初始化 基础数据
// await dispatch('d2admin/base/init', null, { root: true })
// // store 设置系统主色 // // store 设置系统主色
// await dispatch('d2admin/color/set', process.env.VUE_APP_MAIN_COLOR) // await dispatch('d2admin/color/set', process.env.VUE_APP_MAIN_COLOR)
// 后台接口 -> store // 后台接口 -> store
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: limin * @Author: limin
* @Date: 2019-08-27 17:25:12 * @Date: 2019-08-27 17:25:12
* @Last Modified by: limin * @Last Modified by: limin
* @Last Modified time: 2019-08-29 00:53:59 * @Last Modified time: 2019-09-01 19:00:46
*/ */
import util from '@/libs/util.js' import util from '@/libs/util.js'
import router from '@/router' import router from '@/router'
...@@ -57,7 +57,7 @@ export default { ...@@ -57,7 +57,7 @@ export default {
return new Promise(async resolve => { return new Promise(async resolve => {
// 设置数据 // 设置数据
dispatch('d2admin/db/set', { dispatch('d2admin/db/set', {
dbName: 'sys', dbName: 'database',
path: 'source', path: 'source',
value: state.source, value: state.source,
user: true user: true
...@@ -99,7 +99,7 @@ export default { ...@@ -99,7 +99,7 @@ export default {
return new Promise(async resolve => { return new Promise(async resolve => {
if (!state.source) { if (!state.source) {
state.source = await dispatch('d2admin/db/get', { state.source = await dispatch('d2admin/db/get', {
dbName: 'sys', dbName: 'database',
path: 'source', path: 'source',
user: true user: true
}, { root: true }) }, { root: true })
......
/*
* @Author: limin
* @Date: 2019-09-01 17:56:57
* @Last Modified by: limin
* @Last Modified time: 2019-09-01 18:57:45
*/
import { FetchRoleList, CompanyList, DepartList, StationList } from '@/api/sys.base'
import { BaseData } from '@/common/constants'
const map = {
[BaseData.ROLE]: FetchRoleList,
[BaseData.COMPANY]: CompanyList,
[BaseData.DEPART]: DepartList,
[BaseData.STATION]: StationList
}
export default {
namespaced: true,
state: {
// 所属公司
company: [],
// 角色
role: [],
// 部门
depart: [],
// 站点
station: []
},
actions: {
/**
* 初始化获取 基础数据 并 前端持久化
* 每次登录会强制 初始化
* @param {*} param0
*/
init ({ state, dispatch, commit }) {
return new Promise(async resolve => {
Promise.all([
FetchRoleList(),
CompanyList(),
DepartList(),
StationList()
]).then( async ([role, company, depart, station] = res) => {
state.role = role
state.station = station
state.depart = depart
state.company = company
await dispatch('save2db', {path: `base`,value: {role, company, depart, station}})
resolve({ role, company, depart, station })
})
})
},
/**
* 根据名字获取基础数据
* 获取步骤:
* 内存 -> 前端持久化数据库 -> 后台接口
* @param {*} param0
* @param {*} name 名称 state 中的任意一个 强烈建议 使用 @/common/constants/BaseData 中的常量 便于灵活修改
*/
get ({ state, dispatch }, name) {
return new Promise(async resolve => {
let __data = state[name]
if (!__data.length) {
__data = await dispatch('getFromdb', `base.${name}`) || await dispatch('getFromAjax', name)
state[name] = __data
await dispatch('save2db', {path: `base.${name}`,value: __data})
}
resolve(__data)
})
},
/**
* 获取所有基础数据
* 获取步骤:
* 内存 -> 前端持久化数据库 -> 后台接口
* @param {*} param0
*/
load ({ state,dispatch }) {
return new Promise(async resolve => {
if (state.role.length === 0) {
state = await dispatch('getFromdb','base') || await dispatch('init')
}
const {role, company, depart, station} = state
resolve({role, company, depart, station})
})
},
/**
* 内部方法 从前端持久化数据库 获取指定数据
* @param {*} param0
* @param {*} path 数据 路径
*/
getFromdb ({ dispatch }, path) {
return new Promise(async resolve => {
const value = await dispatch('d2admin/db/get', {
dbName: 'database',
path,
user: true
}, { root: true })
resolve(value)
})
},
/**
* 内部方法 前端持久化 一个 数据
* @param {*} param0
* @param {*} param1 value 需要持久化的数据 path 需要持久化的数据路径
*/
save2db ({ dispatch }, {value,path}) {
return new Promise(async resolve => {
await dispatch('d2admin/db/set', {
dbName: 'database',
path,
value,
user: true
}, { root: true })
resolve(value)
})
},
/**
* 从后端获取一个数据
* @param {*} param0
* @param {*} name @/common/constants/BaseData 中的常量
*/
getFromAjax ({ state, dispatch, commit }, name) {
return new Promise(async resolve => {
const value = await map[name]()
resolve(value)
})
}
},
mutations: {
}
}
...@@ -43,9 +43,9 @@ export default { ...@@ -43,9 +43,9 @@ export default {
}) })
}, },
clear ({ state, dispatch },) { clear ({ state, dispatch }) {
return new Promise(async resolve => { return new Promise(async resolve => {
await dispatch('set',{}) await dispatch('set', {})
resolve() resolve()
}) })
} }
......
<template>
<div>
</div>
</template>
<script>
export default {
}
</script>
<style lang="scss" scoped>
</style>
...@@ -140,7 +140,7 @@ export default { ...@@ -140,7 +140,7 @@ export default {
} }
}, },
mounted() {}, mounted () {},
methods: { methods: {
......
...@@ -112,7 +112,7 @@ export default { ...@@ -112,7 +112,7 @@ export default {
components: { components: {
EditDialog EditDialog
}, },
data() { data () {
return { return {
// 编辑弹窗 // 编辑弹窗
editVisible: false, editVisible: false,
...@@ -173,7 +173,7 @@ export default { ...@@ -173,7 +173,7 @@ export default {
} }
}, },
mounted() { mounted () {
this.loadingGetList() this.loadingGetList()
}, },
...@@ -202,7 +202,7 @@ export default { ...@@ -202,7 +202,7 @@ export default {
}) })
}, },
editDevice(params) { editDevice (params) {
editApi(params).then(res => { editApi(params).then(res => {
// console.log(res) // console.log(res)
this.handleEditClose() this.handleEditClose()
...@@ -214,7 +214,7 @@ export default { ...@@ -214,7 +214,7 @@ export default {
}, },
// 导入 // 导入
importFile(e) { importFile (e) {
const params = { const params = {
file: e.target.files[0] file: e.target.files[0]
} }
......
...@@ -107,7 +107,7 @@ import { getListApi, removeApi, exportApi } from '@api/maintainManagement' ...@@ -107,7 +107,7 @@ import { getListApi, removeApi, exportApi } from '@api/maintainManagement'
import notice from '@/common/notice' import notice from '@/common/notice'
export default { export default {
name: 'maintainManagement', name: 'maintainManagement',
data() { data () {
return { return {
// 搜索 // 搜索
searchForm: { searchForm: {
...@@ -199,12 +199,13 @@ export default { ...@@ -199,12 +199,13 @@ export default {
label: '子系统类型', label: '子系统类型',
prop: 'subsystemType', prop: 'subsystemType',
formatter: (cellValue) => { formatter: (cellValue) => {
if(cellValue.subsystemType) if (cellValue.subsystemType) {
return { return {
1: '座椅', 1: '座椅',
2: '电池' 2: '电池'
}[cellValue.subsystemType] }[cellValue.subsystemType]
} }
}
}, { }, {
label: '故障描述', label: '故障描述',
prop: 'downDescription' prop: 'downDescription'
...@@ -212,7 +213,7 @@ export default { ...@@ -212,7 +213,7 @@ export default {
label: '处理方式', label: '处理方式',
prop: 'treatment', prop: 'treatment',
formatter: (cellValue) => { formatter: (cellValue) => {
if(cellValue.treatment) { if (cellValue.treatment) {
return { return {
1: '现场维修', 1: '现场维修',
2: '更换' 2: '更换'
...@@ -248,7 +249,7 @@ export default { ...@@ -248,7 +249,7 @@ export default {
} }
}, },
mounted() { mounted () {
this.loadingGetList() this.loadingGetList()
}, },
...@@ -275,7 +276,7 @@ export default { ...@@ -275,7 +276,7 @@ export default {
this.tableLoading = false this.tableLoading = false
}) })
}, },
exportOrder() { exportOrder () {
const params = this.getParams() const params = this.getParams()
exportApi(params).then(res => { exportApi(params).then(res => {
notice.okTips() notice.okTips()
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<script> <script>
export default { export default {
name: 'DetailDialog', name: 'DetailDialog',
data() { data () {
return { return {
} }
}, },
...@@ -27,10 +27,10 @@ export default { ...@@ -27,10 +27,10 @@ export default {
} }
}, },
mounted() {}, mounted () {},
methods: { methods: {
handleClose() { handleClose () {
this.$emit('closeDialog') this.$emit('closeDialog')
} }
} }
......
...@@ -109,7 +109,7 @@ export default { ...@@ -109,7 +109,7 @@ export default {
components: { components: {
DetailDialog DetailDialog
}, },
data() { data () {
return { return {
detailVisible: false, detailVisible: false,
// 搜索 // 搜索
...@@ -157,7 +157,7 @@ export default { ...@@ -157,7 +157,7 @@ export default {
} }
}, },
mounted() { mounted () {
this.loadingGetList() this.loadingGetList()
}, },
...@@ -184,7 +184,7 @@ export default { ...@@ -184,7 +184,7 @@ export default {
this.tableLoading = false this.tableLoading = false
}) })
}, },
editSubSystem(value) { editSubSystem (value) {
const params = value const params = value
params.method = value.id ? methods.Edit : methods.Add params.method = value.id ? methods.Edit : methods.Add
editApi(params).then(res => { editApi(params).then(res => {
......
...@@ -71,11 +71,11 @@ import { getListApi } from '@api/materialList' ...@@ -71,11 +71,11 @@ import { getListApi } from '@api/materialList'
import notice from '@/common/notice' import notice from '@/common/notice'
export default { export default {
name: 'materialList', name: 'materialList',
data() { data () {
return { return {
searchForm: { searchForm: {
keyWord: '', keyWord: '',
responsible: '', responsible: ''
}, },
// 表格 // 表格
tableLoading: false, tableLoading: false,
...@@ -109,7 +109,7 @@ export default { ...@@ -109,7 +109,7 @@ export default {
} }
}, },
mounted() { mounted () {
this.loadingGetList() this.loadingGetList()
}, },
......
...@@ -80,13 +80,13 @@ export default { ...@@ -80,13 +80,13 @@ export default {
watch: { watch: {
isVisible (val) { isVisible (val) {
this.disabled = this.editForm.trafficCode ? true : false this.disabled = !!this.editForm.trafficCode
this.editForm.openType = this.editForm.trafficCode ? this.editForm.openType : '1' this.editForm.openType = this.editForm.trafficCode ? this.editForm.openType : '1'
this.$refs.editRuleForm && this.$refs.editRuleForm.resetFields() this.$refs.editRuleForm && this.$refs.editRuleForm.resetFields()
} }
}, },
mounted() {}, mounted () {},
methods: { methods: {
......
...@@ -164,7 +164,7 @@ export default { ...@@ -164,7 +164,7 @@ export default {
} }
}, },
mounted() { mounted () {
this.loadingGetList() this.loadingGetList()
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!