index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. <template>
  2. <!-- 工单池 -->
  3. <template-page
  4. ref="pageRef"
  5. :getList="getList"
  6. :operation="operation()"
  7. :exportList="exportList"
  8. :optionsEvensGroup="optionsEvensGroup"
  9. :columnParsing="columnParsing"
  10. :tableAttributes="tableAttributes"
  11. :tableEvents="tableEvents"
  12. :moreParameters="moreParameters"
  13. :screeningAnalysis="screeningAnalysis"
  14. :filterMethod="filterMethod"
  15. :replaceOrNotMap="true"
  16. :defaultSearchData="defaultSearchData"
  17. >
  18. <!-- 创建工单 -->
  19. <div class="cartographer_big">
  20. <el-dialog
  21. title="创建工单"
  22. width="100%"
  23. :modal="false"
  24. :visible.sync="createFormBool"
  25. :before-close="handleClose"
  26. >
  27. <workOrderInfo :workOrderType="workOrderType" v-if="createFormBool" :cloneWorkOrder="cloneWorkOrder" />
  28. </el-dialog>
  29. </div>
  30. <!-- 工单详情 -->
  31. <div class="cartographer_big">
  32. <el-dialog
  33. :title="'工单详情-' + id"
  34. width="100%"
  35. :modal="false"
  36. :visible.sync="detailFormBool"
  37. :before-close="handleClose"
  38. >
  39. <Detail v-if="detailFormBool" :id="id" :workOrderType="workOrderType" />
  40. </el-dialog>
  41. </div>
  42. <!-- 批量预约/改约 -->
  43. <div class="cartographer_big">
  44. <el-dialog
  45. title="批量约单"
  46. width="100%"
  47. :modal="false"
  48. :visible.sync="rescheduleBool"
  49. :before-close="rescheduleClose"
  50. >
  51. <Reschedule v-if="rescheduleBool" :recordSelected="recordSelected" @close="rescheduleClose" />
  52. </el-dialog>
  53. </div>
  54. <!-- 批量派工/改派 -->
  55. <div class="cartographer_big">
  56. <el-dialog
  57. title="批量派单"
  58. width="100%"
  59. :modal="false"
  60. :visible.sync="reassignmentBool"
  61. :before-close="reassignmentClose"
  62. >
  63. <Reassignment v-if="reassignmentBool" :recordSelected="recordSelected" @close="reassignmentClose" />
  64. </el-dialog>
  65. </div>
  66. </template-page>
  67. </template>
  68. <script>
  69. import { EventBus } from '@/utils/eventBus'
  70. import TemplatePage from '@/components/template/template-page-1.vue'
  71. import import_mixin from '@/components/template/import_mixin.js'
  72. import operation_mixin from '@/components/template/operation_mixin.js'
  73. import { listPageV2 } from '@/api/workOrder/orderType'
  74. import {
  75. orderBaseList,
  76. orderBaseListExport,
  77. orderBaseStatusCount,
  78. orderBaseImport,
  79. orderBaseImport2,
  80. orderBaseDetail
  81. } from '@/api/workOrderPool.js'
  82. import workOrderInfo from './detailModule/workOrderInfo/index.vue'
  83. import Detail from './detail'
  84. import Reassignment from './components/reassignment/index.vue'
  85. import Reschedule from './components/reschedule/index.vue'
  86. import { commonTemplateDownload } from '@/api/common.js'
  87. import orderListColumn from '@/mixin/orderListColumn'
  88. import selectOptionWebsit from '@/utils/selectOptionWebsit.js'
  89. export default {
  90. components: {
  91. TemplatePage,
  92. workOrderInfo,
  93. Detail,
  94. Reassignment,
  95. Reschedule
  96. },
  97. mixins: [import_mixin, operation_mixin, orderListColumn],
  98. data() {
  99. return {
  100. id: this.$route.query.id || '',
  101. // 创建表单
  102. createFormBool: false,
  103. // 详情
  104. detailFormBool: false,
  105. // 批量改约
  106. rescheduleBool: false,
  107. // 批量派工/改派
  108. reassignmentBool: false,
  109. // 表格属性
  110. tableAttributes: {
  111. // 启用勾选列
  112. selectColumn: true,
  113. selectable: this.selectable
  114. },
  115. // 表格事件
  116. tableEvents: {
  117. 'selection-change': this.selectionChange
  118. },
  119. recordSelected: [],
  120. orderTypeList: [],
  121. orderStatusList: [],
  122. defaultSearchData: [],
  123. workOrderType: 1,
  124. cloneWorkOrder: null
  125. }
  126. },
  127. computed: {
  128. moreParameters() {
  129. return [
  130. {
  131. name: '工单类型',
  132. key: 'orderSmallTypeText',
  133. value: '',
  134. conditions: [
  135. {
  136. label: '全部',
  137. value: ''
  138. },
  139. ...this.orderTypeList
  140. ]
  141. },
  142. {
  143. name: '工单状态',
  144. key: 'orderStatus',
  145. value: this.pageType == 'orderStatus' && this.pageCode ? this.pageCode : '',
  146. conditions: [
  147. {
  148. label: '全部',
  149. value: ''
  150. },
  151. ...this.orderStatusList
  152. ]
  153. }
  154. ]
  155. },
  156. // 用户信息
  157. userInfo() {
  158. return JSON.parse(localStorage.getItem('greemall_user'))
  159. },
  160. // 事件组合
  161. optionsEvensGroup() {
  162. return [
  163. [
  164. [
  165. this.optionsEvensAuth(['createWorkOrder', 'createWbWorkOrder'], {
  166. name: '创建工单',
  167. click: () => {}
  168. }),
  169. this.optionsEvensAuth('createWorkOrder', {
  170. click: () => {
  171. this.workOrderType = 1
  172. this.createFormBool = true
  173. }
  174. }),
  175. this.optionsEvensAuth('createGCWorkOrder', {
  176. click: () => {
  177. this.workOrderType = 2
  178. this.createFormBool = true
  179. }
  180. }),
  181. this.optionsEvensAuth('createWbWorkOrder', {
  182. click: () => {
  183. this.workOrderType = 4
  184. this.createFormBool = true
  185. }
  186. })
  187. ],
  188. [
  189. this.optionsEvensAuth(
  190. ['importTemplate', 'downloadImportTemplate', 'importTemplate2', 'downloadImportTemplate2'],
  191. {
  192. name: '导入工单',
  193. click: () => {}
  194. }
  195. ),
  196. this.optionsEvensAuth('importTemplate', ({ moduleName }) => {
  197. return {
  198. name: moduleName,
  199. render: () => {
  200. return this.importButton(orderBaseImport, moduleName, () => {
  201. return new Promise((r, j) => {
  202. selectOptionWebsit
  203. .bind(this)()
  204. .then(websit => {
  205. r({ createWebsitId: websit?.websitId, createWebsitName: websit?.name })
  206. })
  207. .catch(j)
  208. })
  209. })
  210. }
  211. }
  212. }),
  213. this.optionsEvensAuth('downloadImportTemplate', {
  214. click: () => {
  215. commonTemplateDownload({ name: '工单导入模板.xlsx' }, `${this.$route.meta.title}`)
  216. .then(res => {
  217. this.$message({
  218. message: '下载成功',
  219. type: 'success'
  220. })
  221. })
  222. .catch(err => {
  223. this.$message.error('下载失败')
  224. })
  225. }
  226. }),
  227. this.optionsEvensAuth('importTemplate2', ({ moduleName }) => {
  228. return {
  229. name: moduleName,
  230. render: () => {
  231. return this.importButton(orderBaseImport2, moduleName, () => {
  232. return new Promise((r, j) => {
  233. selectOptionWebsit
  234. .bind(this)()
  235. .then(websit => {
  236. r({ createWebsitId: websit?.websitId, createWebsitName: websit?.name })
  237. })
  238. .catch(j)
  239. })
  240. })
  241. }
  242. }
  243. }),
  244. this.optionsEvensAuth('downloadImportTemplate2', {
  245. click: () => {
  246. commonTemplateDownload({ name: '工单导入模板2.xlsx' }, `${this.$route.meta.title}`)
  247. .then(res => {
  248. this.$message({
  249. message: '下载成功',
  250. type: 'success'
  251. })
  252. })
  253. .catch(err => {
  254. this.$message.error('下载失败')
  255. })
  256. }
  257. })
  258. ],
  259. [
  260. this.optionsEvensAuth(['bulkOrder', 'lotOrder'], {
  261. name: '批量操作',
  262. click: () => {}
  263. }),
  264. this.optionsEvensAuth('bulkOrder', {
  265. click: () => {
  266. if (this.recordSelected.length === 0) {
  267. this.$message.warning('请勾选工单')
  268. return
  269. }
  270. this.reassignmentBool = true
  271. }
  272. }),
  273. this.optionsEvensAuth('lotOrder', {
  274. click: () => {
  275. if (this.recordSelected.length === 0) {
  276. this.$message.warning('请勾选工单')
  277. return
  278. }
  279. this.rescheduleBool = true
  280. }
  281. })
  282. ]
  283. ]
  284. ]
  285. }
  286. },
  287. created() {
  288. this.initFun()
  289. EventBus.$on('handleOrderClone', () => {
  290. this.handleClose()
  291. })
  292. EventBus.$on('cloneWorkOrder', data => {
  293. this.handleClose(() => {
  294. this.cloneWorkOrder = data
  295. this.workOrderType = data.saleType
  296. this.createFormBool = false
  297. this.$nextTick(() => {
  298. this.createFormBool = true
  299. })
  300. })
  301. })
  302. // 获取工单类型
  303. listPageV2({ pageNum: 1, pageSize: -1, params: [{ param: 'a.status', compare: '=', value: 'true' }] }).then(res => {
  304. var obj = {}
  305. res.data.records.map(item => {
  306. if (!obj[item.orderSmallTypeText]) {
  307. obj[item.orderSmallTypeText] = {
  308. value: item.orderSmallTypeText,
  309. label: item.orderSmallTypeText
  310. }
  311. }
  312. })
  313. this.orderTypeList = Object.values(obj)
  314. })
  315. },
  316. methods: {
  317. initFun() {
  318. if (this.pageType == 'detail') {
  319. this.id = this.pageCode
  320. orderBaseDetail({
  321. orderBaseId: this.id
  322. }).then(res => {
  323. this.workOrderType = Number(res?.data?.saleType)
  324. this.$nextTick(() => {
  325. this.detailFormBool = true
  326. })
  327. })
  328. }
  329. if (this.pageType == 'saleOrderId') {
  330. this.defaultSearchData = [{ param: 'a.sale_order_id', compare: '=', value: this.pageCode, label: '销售订单号' }]
  331. }
  332. if (this.pageType == 'pgIncreItemId') {
  333. this.defaultSearchData = [
  334. { param: 'a.pg_incre_order_id', compare: '=', value: this.pageCode, label: '增置服务订单ID' }
  335. ]
  336. }
  337. if (this.pageType == 'rpProjectRepairId') {
  338. this.defaultSearchData = [
  339. { param: 'a.rp_project_repair_id', compare: '=', value: this.pageCode, label: '维保配置ID' }
  340. ]
  341. }
  342. if (this.pageType == 'projectNo') {
  343. this.defaultSearchData = [{ param: 'a.project_no', compare: '=', value: this.pageCode, label: '工程编号' }]
  344. }
  345. },
  346. selectable(row, index) {
  347. return (
  348. !['YWG', 'YJS', 'YQX'].includes(
  349. Object.entries(row.selectMapData.orderStatus).find(([key, val]) => val == row.orderStatus)?.[0]
  350. ) && !row.rpProjectRepairId
  351. )
  352. },
  353. screeningAnalysis(jname, val) {
  354. if (jname == 'orderFlags') {
  355. return (val || []).map(item => item.tagName).join(',')
  356. } else {
  357. return val
  358. }
  359. },
  360. filterMethod(value, row, column) {
  361. if (column['property'] == 'orderFlags') {
  362. return (row[column['property']] || []).map(item => item.tagName).join(',') === value
  363. }
  364. return row[column['property']] === value
  365. },
  366. // 获取统计
  367. getOrderBaseStatusCount(...p) {
  368. orderBaseStatusCount(...p).then(res => {
  369. this.orderStatusList = [
  370. {
  371. label: '待预约',
  372. value: 'DYY'
  373. },
  374. {
  375. label: '待抢单',
  376. value: 'DQD'
  377. },
  378. {
  379. label: '待商户派工',
  380. value: 'DSHPG'
  381. },
  382. {
  383. label: '待网点派工',
  384. value: 'DWDPG'
  385. },
  386. {
  387. label: '待接单',
  388. value: 'DJD'
  389. },
  390. {
  391. label: '服务中',
  392. value: 'FWZ'
  393. },
  394. {
  395. label: '异常单',
  396. value: 'YCD'
  397. },
  398. {
  399. label: '已完工待结算',
  400. value: 'YWG'
  401. },
  402. {
  403. label: '已结算',
  404. value: 'YJS'
  405. },
  406. {
  407. label: '已取消',
  408. value: 'YQX'
  409. },
  410. {
  411. label: '配件申请中',
  412. value: 'PJSQZ'
  413. },
  414. {
  415. label: '配件已到货',
  416. value: 'PJYDH'
  417. },
  418. {
  419. label: '配件已取消',
  420. value: 'PJYQX'
  421. }
  422. ].map(item => {
  423. var data = res.data.find(val => val.orderStatus == item.value)
  424. if (data) {
  425. item.label = `${item.label}(${data.total})`
  426. }
  427. return item
  428. })
  429. })
  430. },
  431. // 列表请求函数
  432. getList(p, cb) {
  433. var pam = JSON.parse(JSON.stringify(p))
  434. try {
  435. if (pam.orderStatus) {
  436. pam.params.push({ param: 'a.order_status', compare: '=', value: pam.orderStatus })
  437. }
  438. if (pam.orderSmallTypeText) {
  439. pam.params.push({ param: 'a.order_small_type_text', compare: '=', value: pam.orderSmallTypeText })
  440. }
  441. cb && cb(pam)
  442. return orderBaseList(pam)
  443. } catch (err) {
  444. } finally {
  445. this.$nextTick(() => {
  446. this.getOrderBaseStatusCount({ orderSmallTypeText: pam.orderSmallTypeText || '' })
  447. })
  448. }
  449. },
  450. // 列表导出函数
  451. exportList: orderBaseListExport,
  452. // 监听勾选变化
  453. selectionChange(data) {
  454. this.recordSelected = data
  455. },
  456. operation() {
  457. return this.operationBtn({
  458. edit: {
  459. click: ({ row, index, column }) => {
  460. this.id = row.id
  461. this.workOrderType = Number(
  462. Object.entries(row?.selectMapData?.saleType || {}).find(([key, val]) => val == row.saleType)?.[0] || 1
  463. )
  464. this.$nextTick(() => {
  465. this.detailFormBool = true
  466. })
  467. }
  468. }
  469. })
  470. },
  471. handleClose(cb) {
  472. this.$router.push({
  473. name: 'workOrderPool',
  474. params: {},
  475. query: {}
  476. })
  477. this.$nextTick(() => {
  478. this.cloneWorkOrder = null
  479. this.createFormBool = false
  480. this.detailFormBool = false
  481. this.recordSelected = []
  482. this.$refs?.pageRef?.refreshList()
  483. if (cb && typeof cb === 'function') {
  484. cb()
  485. }
  486. })
  487. },
  488. rescheduleClose() {
  489. this.rescheduleBool = false
  490. this.recordSelected = []
  491. this.$refs?.pageRef?.refreshList()
  492. },
  493. reassignmentClose() {
  494. this.reassignmentBool = false
  495. this.recordSelected = []
  496. this.$refs?.pageRef?.refreshList()
  497. }
  498. }
  499. }
  500. </script>
  501. <style lang="scss" scoped></style>