Commit c2e97b11 by liimin

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

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