orderBtnsShow.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. import { getStorage } from '@/common/utils/storage.js'
  2. import moment from 'moment-timezone'
  3. // 设置时区为中国
  4. moment.tz.setDefault('Asia/Shanghai')
  5. export default {
  6. methods: {
  7. isTodayOrYesterday(timeString) {
  8. const date = moment(timeString)
  9. const now = moment()
  10. // 获取今天和昨天的日期
  11. const today = now.startOf('day')
  12. const yesterday = today.clone().subtract(1, 'days')
  13. // 判断给定日期是否在今天或昨天
  14. return date.isSame(today, 'day') || date.isSame(yesterday, 'day')
  15. },
  16. orderStatus_v_zh(orderStatus, item) {
  17. if (item?.isImportExcel && item?.isMeet === false) {
  18. return 'DJD'
  19. }
  20. if (['DYY'].includes(orderStatus)) {
  21. // 待预约
  22. return 'DYY'
  23. } else if (['DQD'].includes(orderStatus)) {
  24. // 待抢单
  25. return 'DQD'
  26. } else if (
  27. [
  28. 'DSHPG',
  29. 'CJ',
  30. 'YPD',
  31. 'DXSPD',
  32. 'DZBPG',
  33. 'DWDSPGP',
  34. 'DXSSPGP',
  35. 'DTJXSSPGP',
  36. 'DZBSPGP',
  37. 'DFZXPD',
  38. 'DFZXSPGP',
  39. 'XSBH',
  40. 'TJXSBH',
  41. 'ZBBH',
  42. 'FZXBH',
  43. 'FL'
  44. ].includes(orderStatus)
  45. ) {
  46. // 待商户派工
  47. return 'DSHPG'
  48. } else if (['DWDPG', 'DWDPD', 'WDBH'].includes(orderStatus)) {
  49. // 待网点派工
  50. return 'DWDPG'
  51. } else if (['DJD'].includes(orderStatus)) {
  52. // 待接单
  53. return 'DJD'
  54. } else if (['FWZ', 'GCSZT', 'BFWG', 'DSM', 'YZP'].includes(orderStatus)) {
  55. // 服务中
  56. return 'FWZ'
  57. } else if (['YCD'].includes(orderStatus)) {
  58. // 异常单
  59. return 'YCD'
  60. } else if (['YWG', 'GCSZX', 'WDWG', 'YWGO'].includes(orderStatus)) {
  61. // 已完工待结算
  62. return 'YWG'
  63. } else if (['YJS', 'LRCD'].includes(orderStatus)) {
  64. // 已结算
  65. return 'YJS'
  66. } else if (['YQX', 'FWZT', 'YCGB', 'FWQX'].includes(orderStatus)) {
  67. // 已取消
  68. return 'YQX'
  69. }
  70. return ''
  71. },
  72. // 接单按钮
  73. JIEDAN(item, userInfo) {
  74. // ---------------
  75. return (
  76. (item.isImportExcel &&
  77. !item.isMeet &&
  78. item.attr == 'SELF' &&
  79. (item.orderType == 'INSTALL' ? !!userInfo.workerNumber : true)) ||
  80. // ---------------
  81. (item.isImportExcel && !item.isMeet && item.attr != 'SELF') ||
  82. // ---------------
  83. (!item.isImportExcel &&
  84. item.attr == 'SELF' &&
  85. ['DYY', 'DJD'].includes(this.orderStatus_v_zh(item.orderStatus, item)) &&
  86. (item.orderType == 'INSTALL' ? !!userInfo.workerNumber : true)) ||
  87. // ---------------
  88. (!item.isImportExcel &&
  89. item.attr != 'SELF' &&
  90. (['DYY'].includes(this.orderStatus_v_zh(item.orderStatus, item)) ||
  91. (['DJD'].includes(this.orderStatus_v_zh(item.orderStatus, item))
  92. ? item.orderType == 'INSTALL'
  93. ? !!userInfo.workerNumber
  94. : true
  95. : false)))
  96. )
  97. },
  98. // 抢单按钮
  99. QIANGDAN(item, userInfo) {
  100. // ---------------
  101. return (
  102. (!item.isImportExcel &&
  103. item.attr == 'SELF' &&
  104. ['DQD'].includes(this.orderStatus_v_zh(item.orderStatus, item)) &&
  105. (item.orderType == 'INSTALL' ? !!userInfo.workerNumber : true)) ||
  106. // ---------------
  107. (!item.isImportExcel && item.attr != 'SELF' && ['DQD'].includes(this.orderStatus_v_zh(item.orderStatus, item)))
  108. )
  109. },
  110. // 配件申请
  111. PEIJIANSHENQING(item, userInfo) {
  112. // ---------------
  113. return (
  114. ((item.isImportExcel &&
  115. item.orderType != 'INSTALL' &&
  116. (['DYY', 'FWZ'].includes(this.orderStatus_v_zh(item.orderStatus, item)) ||
  117. (['DQD', 'DJD', 'DSHPG', 'DWDPG'].includes(this.orderStatus_v_zh(item.orderStatus, item)) &&
  118. !userInfo.workerNumber))) ||
  119. // ---------------
  120. (item.isImportExcel &&
  121. item.orderType != 'INSTALL' &&
  122. ['YWG'].includes(this.orderStatus_v_zh(item.orderStatus, item)) &&
  123. this.isTodayOrYesterday(item.overTime)) ||
  124. // ---------------
  125. (!item.isImportExcel && ['DYY', 'FWZ'].includes(this.orderStatus_v_zh(item.orderStatus, item)))) &&
  126. (item.isImportExcel ? item.isMeet : true)
  127. )
  128. },
  129. // 变更小工
  130. BIANGENGXIAOGONG(item, userInfo) {
  131. // ---------------
  132. return (
  133. ((item.isImportExcel &&
  134. ['DYY', 'FWZ', 'YWG'].includes(this.orderStatus_v_zh(item.orderStatus, item)) &&
  135. (item.orderType == 'INSTALL' ? !!userInfo.workerNumber : true)) ||
  136. // ---------------
  137. (item.isImportExcel &&
  138. ['DQD', 'DJD', 'DSHPG', 'DWDPG'].includes(this.orderStatus_v_zh(item.orderStatus, item)) &&
  139. item.orderType != 'INSTALL' &&
  140. !userInfo.workerNumber) ||
  141. // ---------------
  142. (!item.isImportExcel &&
  143. ['DYY', 'FWZ', 'YWG'].includes(this.orderStatus_v_zh(item.orderStatus, item)) &&
  144. (item.orderType == 'INSTALL' ? !!userInfo.workerNumber : true))) &&
  145. (item.isImportExcel ? item.isMeet : true)
  146. )
  147. },
  148. // 辅材收费
  149. FUCAISHOUFEI(item, userInfo) {
  150. return (
  151. ((item.isImportExcel &&
  152. ['DYY', 'FWZ'].includes(this.orderStatus_v_zh(item.orderStatus, item)) &&
  153. (item.orderType == 'INSTALL' ? !!userInfo.workerNumber : true)) ||
  154. //----------
  155. (item.isImportExcel &&
  156. ['DQD', 'DJD', 'DSHPG', 'DWDPG'].includes(this.orderStatus_v_zh(item.orderStatus, item)) &&
  157. item.orderType != 'INSTALL' &&
  158. !userInfo.workerNumber) ||
  159. //----------
  160. (!item.isImportExcel &&
  161. ['DYY', 'FWZ'].includes(this.orderStatus_v_zh(item.orderStatus, item)) &&
  162. !!userInfo.workerNumber) ||
  163. //----------
  164. (((item.isImportExcel &&
  165. ['YWG'].includes(this.orderStatus_v_zh(item.orderStatus, item)) &&
  166. (item.orderType == 'INSTALL' ? !!userInfo.workerNumber : true)) ||
  167. (!item.isImportExcel &&
  168. ['YWG'].includes(this.orderStatus_v_zh(item.orderStatus, item)) &&
  169. !!userInfo.workerNumber)) &&
  170. this.isTodayOrYesterday(item.overTime))) &&
  171. (item.isImportExcel ? item.isMeet : true)
  172. )
  173. },
  174. PEIJIANSHOUFEI(item, userInfo) {
  175. return (
  176. ((item.isImportExcel &&
  177. item.orderType != 'INSTALL' &&
  178. (['DYY', 'FWZ'].includes(this.orderStatus_v_zh(item.orderStatus, item)) ||
  179. (['DQD', 'DJD', 'DSHPG', 'DWDPG'].includes(this.orderStatus_v_zh(item.orderStatus, item)) &&
  180. !userInfo.workerNumber))) ||
  181. //----------
  182. (!item.isImportExcel &&
  183. item.orderType != 'INSTALL' &&
  184. ['DYY', 'FWZ'].includes(this.orderStatus_v_zh(item.orderStatus, item)) &&
  185. !!userInfo.workerNumber) ||
  186. //----------
  187. (((item.isImportExcel &&
  188. item.orderType != 'INSTALL' &&
  189. ['YWG'].includes(this.orderStatus_v_zh(item.orderStatus, item))) ||
  190. (!item.isImportExcel &&
  191. item.orderType != 'INSTALL' &&
  192. ['YWG'].includes(this.orderStatus_v_zh(item.orderStatus, item)) &&
  193. !!userInfo.workerNumber)) &&
  194. this.isTodayOrYesterday(item.overTime))) &&
  195. (item.isImportExcel ? item.isMeet : true)
  196. )
  197. },
  198. GUOCHENFANKUI(item, userInfo) {
  199. return (
  200. (['DYY', 'FWZ'].includes(this.orderStatus_v_zh(item.orderStatus, item)) ||
  201. (item.isImportExcel &&
  202. item.orderType != 'INSTALL' &&
  203. !userInfo.workerNumber &&
  204. ['DQD', 'DJD', 'DSHPG', 'DWDPG'].includes(this.orderStatus_v_zh(item.orderStatus, item)))) &&
  205. (item.isImportExcel ? item.isMeet : true)
  206. )
  207. }
  208. }
  209. }