index.vue 13 KB

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