enum.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /**
  2. * @description store enum (枚举页面)各种配置枚举
  3. */
  4. import {
  5. getTypeList,
  6. } from "@/api/common" /* eslint-disable-line */
  7. const state = {
  8. evectionTypeList: null, // 出差列表
  9. moduleList: null, // 模块列表
  10. degreeList: null, // 缓急程度
  11. applyTypeList: null, // 采购类型
  12. applyPayTypeList: null, // 采购支付类型
  13. offerTypeList: null, // 呈批类型
  14. leaveTypeList: null, // 请假类型
  15. maintainTypeList: null, // 维修类型
  16. contractTypeList: null, // 合同类型
  17. // 1=待审批,2=审批中,3=审批通过,4=审批拒绝
  18. // NOTE: 审批信息中的审核流程枚举
  19. approveFlowPathEnum: [undefined, '待审核', '审核中', '已通过', '已驳回'],
  20. // :2=审批中,3=审批通过,4=审批驳回,5=审批撤销
  21. // NOTE: 申请`status`枚举
  22. approveInfoEnum: [],
  23. enumIsYesOrNo: [
  24. {
  25. id: 0,
  26. name: '否'
  27. },
  28. {
  29. id: 1,
  30. name: '是'
  31. }
  32. ]
  33. }
  34. const getters = {
  35. // NOTE: 审核流程枚举
  36. getApproveFlowPathEnum: state => (status) => {
  37. if (![1, 2, 3, 4].includes(status)) return 'unknow'
  38. return state.approveFlowPathEnum[status]
  39. }
  40. }
  41. const mutations = {
  42. // NOTE: 出差类型
  43. SET_EVECTION_TYPE_LIST(state, paylod) {
  44. state.evectionTypeList = [...paylod.list]
  45. },
  46. // NOTE: 模块列表
  47. SET_MODULE_LIST(state, paylod) {
  48. state.moduleList = [...paylod.list]
  49. },
  50. // NOTE: 缓急程度
  51. SET_DEGREE_LIST(state, paylod) {
  52. state.degreeList = [...paylod.list]
  53. },
  54. // NOTE: 采购类型
  55. SET_APPLY_TYPE_LIST(state, paylod) {
  56. state.applyTypeList = [...paylod.list]
  57. },
  58. // NOTE: 采购支付类型
  59. SET_APPLY_PAY_TYPE_LIST(state, paylod) {
  60. state.applyPayTypeList = [...paylod.list]
  61. },
  62. // NOTE: 呈批类型
  63. SET_OFFER_TYPE_LIST(state, paylod) {
  64. state.offerTypeList = [...paylod.list]
  65. },
  66. // NOTE: 请假类型
  67. SET_LEAVE_TYPE_LIST(state, paylod) {
  68. state.leaveTypeList = [...paylod.list]
  69. },
  70. // NOTE: 维修类型
  71. SET_MAINTAIN_TYPE_LIST(state, paylod) {
  72. state.maintainTypeList = [...paylod.list]
  73. },
  74. // NOTE: 合同类型
  75. SET_CONTRACT_TYPE_LIST(state, paylod) {
  76. state.contractTypeList = [...paylod.list]
  77. }
  78. }
  79. const actions = {
  80. getTypeList({ commit }) {
  81. return new Promise((resolve, reject) => {
  82. getTypeList().then(result => {
  83. if (result.code === 1) {
  84. const {
  85. module_list,
  86. degree_list,
  87. pay_type_list,
  88. data1,
  89. data2,
  90. data5,
  91. data6,
  92. data8,
  93. data9
  94. } = result.data
  95. commit({
  96. type: 'SET_EVECTION_TYPE_LIST',
  97. list: data5
  98. })
  99. commit({
  100. type: 'SET_MODULE_LIST',
  101. list: module_list
  102. })
  103. commit({
  104. type: 'SET_DEGREE_LIST',
  105. list: degree_list
  106. })
  107. commit({
  108. type: 'SET_APPLY_PAY_TYPE_LIST',
  109. list: pay_type_list
  110. })
  111. commit({
  112. type: 'SET_APPLY_TYPE_LIST',
  113. list: data1
  114. })
  115. commit({
  116. type: 'SET_OFFER_TYPE_LIST',
  117. list: data2
  118. })
  119. commit({
  120. type: 'SET_LEAVE_TYPE_LIST',
  121. list: data6
  122. })
  123. commit({
  124. type: 'SET_MAINTAIN_TYPE_LIST',
  125. list: data8
  126. })
  127. commit({
  128. type: 'SET_CONTRACT_TYPE_LIST',
  129. list: data9
  130. })
  131. resolve()
  132. }
  133. }).catch(error => reject(error))
  134. })
  135. },
  136. // 获取出差类型
  137. // getEvectionTypeList({ commit }) {
  138. // return new Promise((resolve, reject) => {
  139. // getAwayType().then(result => {
  140. // if (result.code === 1) {
  141. // commit({
  142. // type: 'SET_EVECTION_TYPE_LIST',
  143. // list: result.data
  144. // })
  145. // resolve(result.data)
  146. // }
  147. // }).catch(error => {
  148. // console.log('getEvectionTypeList error>', error);
  149. // reject([])
  150. // })
  151. // })
  152. // }
  153. }
  154. export default {
  155. namespaced: true,
  156. state,
  157. getters,
  158. mutations,
  159. actions
  160. }