index.vue 17 KB

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