index.vue 16 KB

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