index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  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. !row.isThreeOrder &&
  400. !['YWG', 'GCSZX', 'WDWG', 'YWGO'].includes(orderStatus) &&
  401. !['YJS', 'LRCD'].includes(orderStatus) &&
  402. !['YQX', 'FWZT', 'YCGB', 'FWQX'].includes(orderStatus) &&
  403. !row.rpProjectRepairId
  404. )
  405. },
  406. screeningAnalysis(jname, val) {
  407. if (jname == 'orderFlags') {
  408. return (val || []).map(item => item.tagName).join(',')
  409. } else {
  410. return val
  411. }
  412. },
  413. filterMethod(value, row, column) {
  414. if (column['property'] == 'orderFlags') {
  415. return (row[column['property']] || []).map(item => item.tagName).join(',') === value
  416. }
  417. return row[column['property']] === value
  418. },
  419. // 获取统计
  420. getOrderBaseStatusCount(...p) {
  421. orderBaseStatusCount(...p).then(res => {
  422. this.orderStatusList = [
  423. {
  424. label: '待预约',
  425. value: 'DYY'
  426. },
  427. {
  428. label: '待抢单',
  429. value: 'DQD'
  430. },
  431. {
  432. label: '待商户派工',
  433. value: 'DSHPG'
  434. },
  435. {
  436. label: '待网点派工',
  437. value: 'DWDPG'
  438. },
  439. {
  440. label: '待接单',
  441. value: 'DJD'
  442. },
  443. {
  444. label: '服务中',
  445. value: 'FWZ'
  446. },
  447. {
  448. label: '异常单',
  449. value: 'YCD'
  450. },
  451. {
  452. label: '已完工待结算',
  453. value: 'YWG'
  454. },
  455. {
  456. label: '已结算',
  457. value: 'YJS'
  458. },
  459. {
  460. label: '已取消',
  461. value: 'YQX'
  462. },
  463. {
  464. label: '配件申请中',
  465. value: 'PJSQZ'
  466. },
  467. {
  468. label: '配件已到货',
  469. value: 'PJYDH'
  470. },
  471. {
  472. label: '配件已取消',
  473. value: 'PJYQX'
  474. }
  475. ].map(item => {
  476. var data = res.data.find(val => val.orderStatus == item.value)
  477. if (data) {
  478. item.label = `${item.label}(${data.total})`
  479. }
  480. return item
  481. })
  482. })
  483. },
  484. // 列表请求函数
  485. getList(p, cb) {
  486. var pam = JSON.parse(JSON.stringify(p))
  487. try {
  488. if (pam.orderStatus) {
  489. pam.params.push({ param: 'a.order_status', compare: '=', value: pam.orderStatus })
  490. }
  491. if (pam.orderSmallTypeText) {
  492. pam.params.push({ param: 'a.order_small_type_text', compare: '=', value: pam.orderSmallTypeText })
  493. }
  494. if (this.value1) {
  495. pam.params.push(
  496. { param: 'a.create_time', compare: '>=', value: `${new Date(this.value1).getFullYear()}-1-1 00:00:00` },
  497. { param: 'a.create_time', compare: '<=', value: `${new Date(this.value1).getFullYear()}-12-31 23:59:59` }
  498. )
  499. }
  500. cb && cb(pam)
  501. return orderBaseList(pam)
  502. } catch (err) {
  503. } finally {
  504. this.$nextTick(() => {
  505. this.getOrderBaseStatusCount({
  506. orderSmallTypeText: pam.orderSmallTypeText || '',
  507. ...(() => {
  508. if (this.value1) {
  509. return {
  510. startTime: `${new Date(this.value1).getFullYear()}-1-1 00:00:00`,
  511. endTime: `${new Date(this.value1).getFullYear()}-12-31 23:59:59`
  512. }
  513. }
  514. return {}
  515. })()
  516. })
  517. })
  518. }
  519. },
  520. // 列表导出函数
  521. exportList: orderBaseListExport,
  522. // 监听勾选变化
  523. selectionChange(data) {
  524. this.recordSelected = data
  525. },
  526. operation() {
  527. return this.operationBtn({
  528. edit: {
  529. // conditions: ({ row, index, column }) => {
  530. // return !row.isImport
  531. // },
  532. click: ({ row, index, column }) => {
  533. this.id = row.id
  534. this.workOrderType = Number(
  535. Object.entries(row?.selectMapData?.saleType || {}).find(([key, val]) => val == row.saleType)?.[0] || 1
  536. )
  537. this.$nextTick(() => {
  538. this.detailFormBool = true
  539. })
  540. }
  541. }
  542. // view: {
  543. // conditions: ({ row, index, column }) => {
  544. // return row.isImport
  545. // },
  546. // click: ({ row, index, column }) => {
  547. // this.id = row.id
  548. // this.workOrderType = Number(
  549. // Object.entries(row?.selectMapData?.saleType || {}).find(([key, val]) => val == row.saleType)?.[0] || 1
  550. // )
  551. // this.$nextTick(() => {
  552. // this.detailFormBool = true
  553. // })
  554. // }
  555. // }
  556. })
  557. },
  558. handleClose(cb) {
  559. this.$router.push({
  560. name: 'workOrderPool',
  561. params: {},
  562. query: {}
  563. })
  564. this.$nextTick(() => {
  565. this.cloneWorkOrder = null
  566. this.createFormBool = false
  567. this.detailFormBool = false
  568. this.recordSelected = []
  569. this.$refs?.pageRef?.refreshList()
  570. if (cb && typeof cb === 'function') {
  571. cb()
  572. }
  573. })
  574. },
  575. rescheduleClose() {
  576. this.rescheduleBool = false
  577. this.recordSelected = []
  578. this.$refs?.pageRef?.refreshList()
  579. },
  580. reassignmentClose() {
  581. this.reassignmentBool = false
  582. this.recordSelected = []
  583. this.$refs?.pageRef?.refreshList()
  584. }
  585. }
  586. }
  587. </script>
  588. <style lang="scss" scoped></style>