index.vue 13 KB

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