index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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, orderBaseDetail } 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: 1
  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 = 1
  124. this.createFormBool = true
  125. }
  126. }),
  127. this.optionsEvensAuth("createGCWorkOrder", {
  128. click: () => {
  129. this.workOrderType = 2
  130. this.createFormBool = true
  131. }
  132. }),
  133. this.optionsEvensAuth("createWbWorkOrder", {
  134. click: () => {
  135. this.workOrderType = 4
  136. this.createFormBool = true
  137. }
  138. })
  139. ],
  140. [
  141. this.optionsEvensAuth(["importTemplate", "downloadImportTemplate"], {
  142. name: '导入工单',
  143. click: () => { }
  144. }),
  145. this.optionsEvensAuth("importTemplate", ({ moduleName }) => {
  146. return {
  147. name: moduleName,
  148. render: () => {
  149. return this.importButton(orderBaseImport, moduleName)
  150. }
  151. }
  152. }),
  153. this.optionsEvensAuth("downloadImportTemplate", {
  154. click: () => {
  155. commonTemplateDownload({ name: '工单导入模板.xlsx' }, `${this.$route.meta.title}`)
  156. .then(res => {
  157. this.$message({
  158. message: '下载成功',
  159. type: 'success'
  160. })
  161. })
  162. .catch(err => {
  163. this.$message.error('下载失败')
  164. })
  165. }
  166. }),
  167. ],
  168. [
  169. this.optionsEvensAuth(["bulkOrder", "lotOrder"], {
  170. name: '批量操作',
  171. click: () => { }
  172. }),
  173. this.optionsEvensAuth("bulkOrder", {
  174. click: () => {
  175. if (this.recordSelected.length === 0) {
  176. this.$message.warning('请勾选工单')
  177. return
  178. }
  179. this.reassignmentBool = true
  180. }
  181. }),
  182. this.optionsEvensAuth("lotOrder", {
  183. click: () => {
  184. if (this.recordSelected.length === 0) {
  185. this.$message.warning('请勾选工单')
  186. return
  187. }
  188. this.rescheduleBool = true
  189. }
  190. }),
  191. ],
  192. ]
  193. ]
  194. }
  195. },
  196. created() {
  197. this.initFun()
  198. EventBus.$on('handleOrderClone', () => {
  199. this.handleClose()
  200. })
  201. // 获取工单类型
  202. listPageV2({ "pageNum": 1, "pageSize": -1, "params": [{ "param": "a.status", "compare": "=", "value": "true" }] }).then(res => {
  203. this.orderTypeList = res.data.records.map(item => ({
  204. value: item.id,
  205. label: item.orderSmallTypeText
  206. }))
  207. })
  208. },
  209. methods: {
  210. initFun() {
  211. if (this.pageType == "detail") {
  212. this.id = this.pageCode
  213. orderBaseDetail({
  214. orderBaseId: this.id
  215. }).then(res => {
  216. this.workOrderType = Number(res?.data?.saleType)
  217. this.$nextTick(() => {
  218. this.detailFormBool = true
  219. })
  220. })
  221. }
  222. if (this.pageType == "saleOrderId") {
  223. this.defaultSearchData = [{ "param": "a.sale_order_id", "compare": "=", "value": this.pageCode, label: "销售订单号" }]
  224. }
  225. if (this.pageType == "pgIncreItemId") {
  226. this.defaultSearchData = [{ "param": "a.pg_incre_order_id", "compare": "=", "value": this.pageCode, label: "增置服务订单ID" }]
  227. }
  228. if (this.pageType == "rpProjectRepairId") {
  229. this.defaultSearchData = [{ "param": "a.rp_project_repair_id", "compare": "=", "value": this.pageCode, label: "维保配置ID" }]
  230. }
  231. if (this.pageType == "projectNo") {
  232. this.defaultSearchData = [{ "param": "a.project_no", "compare": "=", "value": this.pageCode, label: "工程编号" }]
  233. }
  234. },
  235. selectable(row, index) {
  236. return !["YWG", "YJS", "YQX"].includes(Object.entries(row.selectMapData.orderStatus).find(([key, val]) => val == row.orderStatus)?.[0]) && !row.rpProjectRepairId
  237. },
  238. screeningAnalysis(jname, val) {
  239. if (jname == 'orderFlags') {
  240. return (val || []).map(item => item.tagName).join(',')
  241. } else {
  242. return val
  243. }
  244. },
  245. filterMethod(value, row, column) {
  246. if (column['property'] == 'orderFlags') {
  247. return (row[column['property']] || []).map(item => item.tagName).join(',') === value
  248. }
  249. return row[column['property']] === value
  250. },
  251. // 获取统计
  252. getOrderBaseStatusCount(...p) {
  253. orderBaseStatusCount(...p).then(res => {
  254. this.orderStatusList = [{
  255. label: "待预约",
  256. value: "DYY"
  257. }, {
  258. label: "待商户派工",
  259. value: "DSHPG"
  260. }, {
  261. label: "待网点派工",
  262. value: "DWDPG"
  263. }, {
  264. label: "待接单",
  265. value: "DJD"
  266. }, {
  267. label: "服务中",
  268. value: "FWZ"
  269. }, {
  270. label: "异常单",
  271. value: "YCD"
  272. }, {
  273. label: "已完工待结算",
  274. value: "YWG"
  275. }, {
  276. label: "已结算",
  277. value: "YJS"
  278. }, {
  279. label: "已取消",
  280. value: "YQX"
  281. }].map(item => {
  282. var data = res.data.find(val => val.orderStatus == item.value)
  283. if (data) {
  284. item.label = `${item.label}(${data.total})`
  285. }
  286. return item
  287. })
  288. })
  289. },
  290. // 列表请求函数
  291. getList(p, cb) {
  292. var pam = JSON.parse(JSON.stringify(p))
  293. try {
  294. if (pam.orderStatus) {
  295. pam.params.push({ "param": "a.order_status", "compare": "=", "value": pam.orderStatus })
  296. }
  297. if (pam.orderSmallType) {
  298. pam.params.push({ "param": "a.order_small_type", "compare": "=", "value": pam.orderSmallType })
  299. }
  300. // if (this.$route.query.saleOrderId && !pam.params.find(item => item.param == "a.sale_order_id")) {
  301. // pam.params.push({ "param": "a.sale_order_id", "compare": "like", "value": this.$route.query.saleOrderId, label: "销售订单号" })
  302. // }
  303. // if (this.$route.query.pgIncreItemId && !pam.params.find(item => item.param == "a.pg_incre_order_id")) {
  304. // pam.params.push({ "param": "a.pg_incre_order_id", "compare": "like", "value": this.$route.query.pgIncreItemId, label: "增置服务明细ID" })
  305. // }
  306. // if (this.$route.query.rpProjectRepairId && !pam.params.find(item => item.param == "a.rp_project_repair_id")) {
  307. // pam.params.push({ "param": "a.rp_project_repair_id", "compare": "=", "value": this.$route.query.rpProjectRepairId })
  308. // }
  309. cb && cb(pam)
  310. return orderBaseList(pam)
  311. } catch (err) {
  312. } finally {
  313. this.$nextTick(() => {
  314. this.getOrderBaseStatusCount({ orderSmallType: pam.orderSmallType || "" })
  315. })
  316. }
  317. },
  318. // 列表导出函数
  319. exportList: orderBaseListExport,
  320. // 监听勾选变化
  321. selectionChange(data) {
  322. this.recordSelected = data
  323. },
  324. operation() {
  325. return this.operationBtn({
  326. edit: {
  327. click: ({ row, index, column }) => {
  328. this.id = row.id
  329. this.workOrderType = Number(Object.entries(row.selectMapData.saleType).find(([key, val]) => val == row.saleType)?.[0] || 1)
  330. this.$nextTick(() => {
  331. this.detailFormBool = true
  332. })
  333. }
  334. }
  335. })
  336. },
  337. handleClose() {
  338. this.$router.push({
  339. name: "workOrderPool",
  340. params: {},
  341. query: {}
  342. })
  343. this.$nextTick(() => {
  344. this.createFormBool = false
  345. this.detailFormBool = false
  346. this.recordSelected = []
  347. this.$refs?.pageRef?.refreshList()
  348. })
  349. },
  350. rescheduleClose() {
  351. this.rescheduleBool = false
  352. this.recordSelected = []
  353. this.$refs?.pageRef?.refreshList()
  354. },
  355. reassignmentClose() {
  356. this.reassignmentBool = false
  357. this.recordSelected = []
  358. this.$refs?.pageRef?.refreshList()
  359. },
  360. }
  361. }
  362. </script>
  363. <style lang="scss" scoped></style>