123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- /**
- * @description store enum (枚举页面)各种配置枚举
- */
- import {
- getTypeList,
- } from "@/api/common" /* eslint-disable-line */
- const state = {
- evectionTypeList: [], // 出差列表
- moduleList: [], // 模块列表
- degreeList: [], // 缓急程度
- applyTypeList: [], // 采购类型
- applyPayTypeList: [], // 采购支付类型
- offerTypeList: [], // 呈批类型
- leaveTypeList: [], // 请假类型
- maintainTypeList: [], // 维修类型
- contractTypeList: [], // 合同类型
- timeList: [], // 请假周期列表
- // 1=待审批,2=审批中,3=审批通过,4=审批拒绝
- // NOTE: 审批信息中的审核流程枚举
- approveFlowPathEnum: [undefined, '待审核', '审核中', '已通过', '已驳回'],
- // :2=审批中,3=审批通过,4=审批驳回,5=审批撤销
- // NOTE: 申请`status`枚举
- approveInfoEnum: [],
- enumIsYesOrNo: [
- {
- id: 0,
- name: '否'
- },
- {
- id: 1,
- name: '是'
- }
- ]
- }
- /**
- * 根据id在数据中返回相应的枚举值
- * @param {array} arrs 数据列表{name,id}[]
- * @param {number} id 需要获取枚举的id
- * @returns {string}
- */
- function getKeyToTxt(arrs, id) {
- let target = arrs.filter(row => row.id === id)
- if (!target.length) return 'UNKNOW'
- return target[0].name
- }
- const getters = {
- // NOTE: 审核流程枚举
- getApproveFlowPathEnum: state => (status) => {
- if (![1, 2, 3, 4].includes(status)) return 'unknow'
- return state.approveFlowPathEnum[status]
- },
- // NOTE: 获取模块列表的名称; 根据ID去获取
- getModuleText: state => id => getKeyToTxt(state.moduleList, id),
- // NOTE: 获取缓急程度枚举
- getDegreeText: state => id => getKeyToTxt(state.degreeList, id),
- // NOTE: 获取维修分类
- getMaintainText: state => id => getKeyToTxt(state.maintainTypeList, id),
- getPayTypeText: state => id => getKeyToTxt(state.applyPayTypeList, id),
- getapplyTypeText: state => id => getKeyToTxt(state.applyTypeList, id),
- }
- const mutations = {
- // NOTE: 出差类型
- SET_EVECTION_TYPE_LIST(state, payload) {
- state.evectionTypeList = [...payload.list]
- },
- // NOTE: 模块列表
- SET_MODULE_LIST(state, payload) {
- state.moduleList = [...payload.list]
- },
- // NOTE: 缓急程度
- SET_DEGREE_LIST(state, payload) {
- state.degreeList = [...payload.list]
- },
- // NOTE: 采购类型
- SET_APPLY_TYPE_LIST(state, payload) {
- state.applyTypeList = [...payload.list]
- },
- // NOTE: 采购支付类型
- SET_APPLY_PAY_TYPE_LIST(state, payload) {
- state.applyPayTypeList = [...payload.list]
- },
- // NOTE: 呈批类型
- SET_OFFER_TYPE_LIST(state, payload) {
- state.offerTypeList = [...payload.list]
- },
- // NOTE: 请假类型
- SET_LEAVE_TYPE_LIST(state, payload) {
- state.leaveTypeList = [...payload.list]
- },
- // NOTE: 维修类型
- SET_MAINTAIN_TYPE_LIST(state, payload) {
- state.maintainTypeList = [...payload.list]
- },
- // NOTE: 合同类型
- SET_CONTRACT_TYPE_LIST(state, payload) {
- state.contractTypeList = [...payload.list]
- },
- // NOTE: 请假周期列表
- SET_TIME_LIST (state, payload) {
- state.timeList = [...payload.list]
- }
- }
- const actions = {
- getTypeList({ commit }) {
- return new Promise((resolve, reject) => {
- getTypeList().then(result => {
- if (result.code === 1) {
- const {
- module_list,
- degree_list,
- pay_type_list,
- data1,
- data2,
- data5,
- data6,
- data8,
- data9,
- time_list
- } = result.data
- commit({
- type: 'SET_EVECTION_TYPE_LIST',
- list: data5
- })
- commit({
- type: 'SET_MODULE_LIST',
- list: module_list
- })
- commit({
- type: 'SET_DEGREE_LIST',
- list: degree_list
- })
- commit({
- type: 'SET_APPLY_PAY_TYPE_LIST',
- list: pay_type_list
- })
- commit({
- type: 'SET_APPLY_TYPE_LIST',
- list: data1
- })
- commit({
- type: 'SET_OFFER_TYPE_LIST',
- list: data2
- })
- commit({
- type: 'SET_LEAVE_TYPE_LIST',
- list: data6
- })
- commit({
- type: 'SET_MAINTAIN_TYPE_LIST',
- list: data8
- })
- commit({
- type: 'SET_CONTRACT_TYPE_LIST',
- list: data9
- })
- commit({
- type: 'SET_TIME_LIST',
- list: time_list
- })
- resolve()
- }
- }).catch(error => reject(error))
- })
- },
- // 获取出差类型
- // getEvectionTypeList({ commit }) {
- // return new Promise((resolve, reject) => {
- // getAwayType().then(result => {
- // if (result.code === 1) {
- // commit({
- // type: 'SET_EVECTION_TYPE_LIST',
- // list: result.data
- // })
- // resolve(result.data)
- // }
- // }).catch(error => {
- // console.log('getEvectionTypeList error>', error);
- // reject([])
- // })
- // })
- // }
- }
- export default {
- namespaced: true,
- state,
- getters,
- mutations,
- actions
- }
|