index.vue 12 KB

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