init
This commit is contained in:
106
src/vuex/modules/com.js
Normal file
106
src/vuex/modules/com.js
Normal file
@@ -0,0 +1,106 @@
|
||||
import * as types from '../types'
|
||||
import { getStore, setStore } from '@js/mUtils.js'
|
||||
|
||||
const baseUrl = process.env.NODE_ENV === 'development' ? 'http://192.168.81.156:8010' : 'http://192.168.81.156:8010'
|
||||
|
||||
/**
|
||||
* App通用配置
|
||||
*/
|
||||
const state = {
|
||||
loading: false,
|
||||
showToast: false,
|
||||
showAlert: false,
|
||||
showSuccess: true,
|
||||
showFail: false,
|
||||
toastMsg: '退出登录',
|
||||
alertMsg: '操作成功',
|
||||
baseUrl: getStore('baseUrl') || baseUrl,
|
||||
setTime: getStore('setTime') || 10000,
|
||||
setTime1: getStore('setTime1') || 60000,
|
||||
equipId: getStore('equipId') || '0'
|
||||
}
|
||||
|
||||
const actions = {
|
||||
setLoadingState ({ commit }, status) {
|
||||
commit(types.COM_LOADING_STATUS, status)
|
||||
},
|
||||
showToast ({ commit }, status) {
|
||||
commit(types.COM_SHOW_TOAST, status)
|
||||
},
|
||||
showAlert ({ commit }, status) {
|
||||
commit(types.COM_SHOW_ALERT, status)
|
||||
},
|
||||
showSuccess ({ commit }, status) {
|
||||
commit(types.COM_SHOW_SUCCESS, status)
|
||||
},
|
||||
showFail ({ commit }, status) {
|
||||
commit(types.COM_SHOW_FAIL, status)
|
||||
},
|
||||
toastMsg ({ commit }, str) {
|
||||
commit(types.COM_TOAST_MSG, str)
|
||||
},
|
||||
alertMsg ({ commit }, str) {
|
||||
commit(types.COM_ALERT_MSG, str)
|
||||
},
|
||||
setConfig ({commit}, res) {
|
||||
setStore('baseUrl', res.baseUrl)
|
||||
setStore('setTime', res.setTime)
|
||||
setStore('setTime1', res.setTime1)
|
||||
setStore('equipId', res.equipId)
|
||||
commit(types.COM_CONFIG, res)
|
||||
}
|
||||
}
|
||||
|
||||
const getters = {
|
||||
loading: state => state.loading,
|
||||
showToast: state => state.showToast,
|
||||
showAlert: state => state.showAlert,
|
||||
baseUrl: state => state.baseUrl,
|
||||
setTime: state => state.setTime,
|
||||
setTime1: state => state.setTime1,
|
||||
equipId: state => state.equipId
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
[types.COM_LOADING_STATUS] (state, status) {
|
||||
state.loading = status
|
||||
},
|
||||
|
||||
[types.COM_SHOW_TOAST] (state, status) {
|
||||
state.showToast = status
|
||||
},
|
||||
|
||||
[types.COM_SHOW_ALERT] (state, status) {
|
||||
state.showAlert = status
|
||||
},
|
||||
|
||||
[types.COM_SHOW_SUCCESS] (state, status) {
|
||||
state.showSuccess = status
|
||||
},
|
||||
|
||||
[types.COM_SHOW_FAIL] (state, status) {
|
||||
state.showFail = status
|
||||
},
|
||||
|
||||
[types.COM_TOAST_MSG] (state, str) {
|
||||
state.toastMsg = str
|
||||
},
|
||||
|
||||
[types.COM_ALERT_MSG] (state, str) {
|
||||
state.alertMsg = str
|
||||
},
|
||||
|
||||
[types.COM_CONFIG] (state, res) {
|
||||
state.baseUrl = res.baseUrl
|
||||
state.setTime = res.setTime
|
||||
state.setTime1 = res.setTime1
|
||||
state.equipId = res.equipId
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
state,
|
||||
actions,
|
||||
getters,
|
||||
mutations
|
||||
}
|
||||
52
src/vuex/modules/user.js
Normal file
52
src/vuex/modules/user.js
Normal file
@@ -0,0 +1,52 @@
|
||||
import * as types from '../types'
|
||||
import { getStore, setStore } from '@js/mUtils.js'
|
||||
|
||||
const state = {
|
||||
accountId: getStore('accountId') || '',
|
||||
accountName: getStore('accountName') || '',
|
||||
userName: getStore('userName') || '',
|
||||
deptUuid: getStore('deptUuid') || ''
|
||||
}
|
||||
|
||||
const getters = {
|
||||
accountId: state => state.accountId,
|
||||
accountName: state => state.accountName,
|
||||
userName: state => state.userName,
|
||||
deptUuid: state => state.deptUuid
|
||||
}
|
||||
|
||||
const actions = {
|
||||
setUserInfo ({ commit }, res) {
|
||||
setStore('accountId', res.account_id)
|
||||
setStore('accountName', res.account_name)
|
||||
setStore('userName', res.user_name)
|
||||
setStore('deptUuid', res.dept_uuid)
|
||||
commit(types.SET_USER_INFO, res)
|
||||
},
|
||||
setSignOut ({ commit }) {
|
||||
localStorage.removeItem('accountId')
|
||||
localStorage.removeItem('userName')
|
||||
localStorage.removeItem('accountName')
|
||||
localStorage.removeItem('deptUuid')
|
||||
commit(types.SET_SIGN_OUT)
|
||||
}
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
[types.SET_USER_INFO] (state, res) {
|
||||
state.accountId = res.account_id
|
||||
state.accountName = res.account_name
|
||||
state.userName = res.user_name
|
||||
state.memberName = res.member_name
|
||||
},
|
||||
[types.SET_SIGN_OUT] (state) {
|
||||
state.accountId = ''
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations
|
||||
}
|
||||
14
src/vuex/store.js
Normal file
14
src/vuex/store.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
import user from './modules/user'
|
||||
import com from './modules/com'
|
||||
|
||||
Vue.use(Vuex)
|
||||
|
||||
export default new Vuex.Store({
|
||||
modules: {
|
||||
user,
|
||||
com
|
||||
}
|
||||
})
|
||||
33
src/vuex/types.js
Normal file
33
src/vuex/types.js
Normal file
@@ -0,0 +1,33 @@
|
||||
// 公共配置
|
||||
export const COM_CONFIG = 'COM_CONFIG'
|
||||
|
||||
// 提示
|
||||
export const COM_LOADING_STATUS = 'COM_LOADING_STATUS'
|
||||
export const COM_SHOW_TOAST = 'COM_SHOW_TOAST' // 显示toast
|
||||
export const COM_SHOW_SUCCESS = 'COM_SHOW_SUCCESS' // 显示成功toast
|
||||
export const COM_SHOW_FAIL = 'COM_SHOW_FAIL' // 显示失败toast
|
||||
export const COM_TOAST_MSG = 'COM_TOAST_MSG' // 显示toast文字
|
||||
export const COM_SHOW_ALERT = 'COM_SHOW_ALERT'
|
||||
export const COM_ALERT_MSG = 'COM_ALERT_MSG'
|
||||
|
||||
// 用户
|
||||
export const SET_USER_INFO = 'SET_USER_INFO'
|
||||
export const SET_SIGN_OUT = 'SET_SIGN_OUT'
|
||||
|
||||
// 收货组盘
|
||||
|
||||
export const LACK_MATER_ARR = 'LACK_MATER_ARR' // 欠料提示列表
|
||||
export const TROUBLE_MATER_ARR = 'TROUBLE_MATER_ARR' // 物料维护列表
|
||||
export const MATER_TO_STORE_OBJ = 'MATER_TO_STORE_OBJ' // 送料入库选中信息
|
||||
|
||||
// 在库管理
|
||||
export const FLAT_MATER_TRIM_OBJ = 'FLAT_MATER_TRIM_OBJ' // 拣选出库数组信息
|
||||
|
||||
// 基础管理
|
||||
export const GET_SHELF_OBJ = 'GET_SHELF_OBJ' // 货位设置
|
||||
|
||||
// 物料列表
|
||||
export const GET_MATER_LIST = 'GET_MATER_LIST'
|
||||
|
||||
// 数据字典
|
||||
export const RECEIVE_TYPE = 'RECEIVE_TYPE'
|
||||
Reference in New Issue
Block a user