RepairFormPool.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. <template>
  2. <div>
  3. <a-card v-show="visible">
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline">
  6. <a-row :gutter="48">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="关键字">
  9. <a-input v-model.trim="queryParam.keyword" placeholder="请输入设备名称/设备编号"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="设备自编号">
  14. <a-input v-model="queryParam.zbh" placeholder="请输入设备自编号"/>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="报修人">
  19. <a-input v-model="queryParam.actualUser" placeholder="请输入报修人"/>
  20. </a-form-item>
  21. </a-col>
  22. <a-col :md="6" :sm="24">
  23. <a-form-item label="维修人">
  24. <a-input v-model="queryParam.repairUserName" placeholder="请输入维修人"/>
  25. </a-form-item>
  26. </a-col>
  27. <a-col :md="6" :sm="24">
  28. <a-form-item label="问题描述">
  29. <a-input v-model="queryParam.content" placeholder="问题描述模糊查询"/>
  30. </a-form-item>
  31. </a-col>
  32. <a-col :md="6" :sm="24">
  33. <a-form-item label="状态">
  34. <a-select v-model="queryParam.status" placeholder="请选择">
  35. <a-select-option
  36. v-for="(label,value) in statusMap"
  37. :key="value"
  38. :label="label"
  39. :value="parseInt(value)">{{ label }}
  40. </a-select-option>
  41. </a-select>
  42. </a-form-item>
  43. </a-col>
  44. <a-col :md="6" :sm="24">
  45. <a-form-item label="报修起始日期">
  46. <a-date-picker
  47. v-model="queryParam.searchStartTime"
  48. style="width: 100%"
  49. :format="BaseTool.Date.PICKER_NORM_DATETIME_PATTERN"
  50. />
  51. </a-form-item>
  52. </a-col>
  53. <a-col :md="6" :sm="24">
  54. <a-form-item label="报修结束日期">
  55. <a-date-picker
  56. v-model="queryParam.searchEndTime"
  57. style="width: 100%"
  58. :format="BaseTool.Date.PICKER_NORM_DATETIME_PATTERN"
  59. />
  60. </a-form-item>
  61. </a-col>
  62. <a-col :md="8 || 24" :sm="24">
  63. <span class="table-page-search-submitButtons">
  64. <a-button type="primary" @click="handleOk()">查询</a-button>
  65. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  66. </span>
  67. </a-col>
  68. </a-row>
  69. </a-form>
  70. </div>
  71. <div class="table-operator" style="margin-bottom: 8px;">
  72. <a-button v-if="$auth('repair-application-forms-add')" type="primary" icon="plus" @click="$refs.baseModal.base({},{filter: -1})">新增</a-button>
  73. <a-button style="margin-left: 8px" v-if="$auth('repair-application-forms-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  74. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('repair-application-forms-del')">
  75. <a-menu slot="overlay">
  76. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  77. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  78. </a-popconfirm>
  79. </a-menu>
  80. <a-button style="margin-left: 8px">
  81. 批量操作 <a-icon type="down" />
  82. </a-button>
  83. </a-dropdown>
  84. </div>
  85. <s-table
  86. ref="table"
  87. size="default"
  88. rowKey="id"
  89. :columns="columns"
  90. :data="loadData"
  91. :alert="options.alert"
  92. :rowSelection="options.rowSelection"
  93. :scroll="{x: 1000, y: BaseTool.Constant.scrollY }"
  94. showPagination="auto"
  95. >
  96. <span slot="action" slot-scope="record">
  97. <template>
  98. <a @click="handleView(record)">工单主页</a>
  99. <!-- <operation-button
  100. v-show="allocatedFlag"
  101. v-if="(DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status)"
  102. :type="2"
  103. title="是否要接单?"
  104. @confirm="receiveRepair(record)">接单</operation-button>
  105. <operation-button
  106. v-show="editFlag"
  107. v-if="(DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ACCEPTANCE === record.status)"
  108. :type="2"
  109. title="是否要接受?"
  110. @confirm="handleApprove">接受</operation-button>
  111. <operation-button
  112. v-show="editFlag"
  113. v-if="(DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ACCEPTANCE === record.status)"
  114. :type="2"
  115. title="是否要拒绝?"
  116. @confirm="handleReturn">拒绝</operation-button> -->
  117. <!-- <operation-button
  118. v-show="editFlag"
  119. v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status && $auth('repair-application-forms-edit')"
  120. @click="handleEdit(record)" >修改</operation-button>
  121. <operation-button
  122. v-show="dispatchFlag"
  123. v-if="( DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.REBACK === record.status ||
  124. DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.REPAIR_FAIL === record.status) && $auth('repair-application-forms-dispatch')"
  125. @click="handleAssign(record)" >派工</operation-button>
  126. <operation-button
  127. v-show="allocatedFlag"
  128. v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status && $auth('repair-application-forms-dispatch')"
  129. @click="handleAssign(record)" >接收并派工</operation-button>
  130. <operation-button
  131. v-show="allocatedFlag"
  132. v-if="$auth('repair-application-forms-deal') && (DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status)"
  133. :type="2"
  134. title="是否要驳回?"
  135. @confirm="handleRefused(record)">报修驳回</operation-button>-->
  136. </template>
  137. </span>
  138. <span slot="content" slot-scope="content">
  139. <span v-html="content"></span>
  140. </span>
  141. <span slot="status" slot-scope="text">
  142. <badge :text="BaseTool.Object.getField(statusMap,text)" :status="DictCache.COLOR.REPAIR_APPLICATION_FORM_STATUS[text]"/>
  143. </span>
  144. <span slot="level" slot-scope="text">
  145. <badge :text="BaseTool.Object.getField(levelMap,text)" :status="DictCache.COLOR.REPAIR_APPLICATION_FORM_LEVEL[text]"/>
  146. </span>
  147. </s-table>
  148. </a-card>
  149. <base-form ref="baseModal" @ok="handleOk"/>
  150. <base-out-form ref="baseOutModal" @ok="handleOk"/>
  151. <detail ref="detailModal" @ok="handleOk"/>
  152. <detail-out ref="detailOutModal" @ok="handleOk"/>
  153. <assign-form ref="assignForm" @ok="handleOk" />
  154. <dispatch-base-form ref="dispatchBaseForm" @ok="handleOk" />
  155. <refused-form ref="refusedForm" @ok="handleOk"/>
  156. <check-form ref="checkForm" @ok="handleOk" />
  157. </div>
  158. </template>
  159. <script>
  160. import { STable, Ellipsis } from '@/components'
  161. import BaseForm from './modules/BaseForm'
  162. import BaseOutForm from './modules/BaseOutForm'
  163. import AssignForm from './modules/AssignForm'
  164. import Detail from './modules/DetailRepair'
  165. import DetailOut from './modules/DetailRepairOut'
  166. import RefusedForm from './modules/RefusedForm'
  167. import {
  168. getRepairApplicationFormPoolPage,
  169. deleteRepairApplicationForms,
  170. fetchRepairApplicationForm,
  171. exportRepairApplicationForm,
  172. receive, receiveRepair, approve
  173. } from '@/api/repair/application-form'
  174. import DispatchBaseForm from '@/views/repair/application-form/modules/DispatchBaseForm'
  175. import CheckForm from './modules/CheckForm'
  176. import Vue from 'vue'
  177. export default {
  178. name: 'RepairForm',
  179. components: {
  180. CheckForm,
  181. STable,
  182. Ellipsis,
  183. BaseForm,
  184. BaseOutForm,
  185. DetailOut,
  186. AssignForm,
  187. Detail,
  188. DispatchBaseForm,
  189. RefusedForm
  190. },
  191. data () {
  192. return {
  193. // 查询参数
  194. queryParam: {
  195. },
  196. visible: true,
  197. dispatchFlag: false,
  198. allocatedFlag: false,
  199. editFlag: false,
  200. // 表头
  201. columns: [
  202. {
  203. title: '序号',
  204. dataIndex: 'index',
  205. checked: true,
  206. width: '70px',
  207. customRender: (text, record, index) => {
  208. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  209. }
  210. },
  211. {
  212. title: '工单编号',
  213. checked: true,
  214. width: '100px',
  215. dataIndex: 'no'
  216. },
  217. {
  218. title: '设备名称',
  219. checked: true,
  220. width: '150px',
  221. dataIndex: 'sbId',
  222. customRender: (text, record, index) => {
  223. return record.sbName
  224. }
  225. },
  226. {
  227. title: '设备位号',
  228. checked: true,
  229. width: '100px',
  230. dataIndex: 'positionNo'
  231. },
  232. {
  233. title: '工作内容',
  234. checked: true,
  235. width: '150px',
  236. dataIndex: 'content',
  237. scopedSlots: { customRender: 'content' }
  238. },
  239. {
  240. title: '录入时间',
  241. checked: true,
  242. width: '200px',
  243. dataIndex: 'applyTime'
  244. },
  245. {
  246. title: '来源分类',
  247. checked: true,
  248. width: '100px',
  249. dataIndex: 'source',
  250. customRender: (text, record, index) => {
  251. if (text === 1) {
  252. return '内部报修'
  253. } else if (text === 2) {
  254. return '生产报修'
  255. } else if (text === 3) {
  256. return '隐患排查'
  257. } else if (text === 4) {
  258. return '巡检'
  259. }
  260. }
  261. },
  262. {
  263. title: '检修等级',
  264. checked: true,
  265. width: '100px',
  266. dataIndex: 'repairPlanLevel'
  267. },
  268. {
  269. title: '工单类型',
  270. checked: true,
  271. width: '100px',
  272. dataIndex: 'category',
  273. customRender: (text, record, index) => {
  274. return this.BaseTool.Object.getField(this.planFlagMap, text)
  275. }
  276. },
  277. /* {
  278. title: '紧急等级',
  279. checked: true,
  280. width: '200px',
  281. dataIndex: 'level',
  282. customRender: (text, record, index) => {
  283. return this.BaseTool.Object.getField(this.levelMap, text)
  284. }
  285. },
  286. {
  287. title: '计划性维修',
  288. checked: true,
  289. dataIndex: 'needStop',
  290. customRender: (text, record, index) => {
  291. return this.BaseTool.Object.getField(this.needStopMap, text)
  292. }
  293. }, */
  294. {
  295. title: '工单状态',
  296. checked: true,
  297. width: '100px',
  298. fixed: 'right',
  299. dataIndex: 'status',
  300. scopedSlots: { customRender: 'status' }
  301. },
  302. {
  303. title: '操作',
  304. checked: true,
  305. fixed: 'right',
  306. key: 'action',
  307. width: '150px',
  308. align: 'center',
  309. scopedSlots: { customRender: 'action' }
  310. }
  311. ],
  312. // 下拉框map
  313. sourceMap: {},
  314. levelMap: {},
  315. statusMap: {},
  316. categoryMap: {},
  317. needStopMap: {},
  318. planFlagMap: {},
  319. // 加载数据方法 必须为 Promise 对象
  320. loadData: parameter => {
  321. parameter = {
  322. ...parameter,
  323. ...this.queryParam,
  324. type: null,
  325. dataScope: {
  326. sortBy: 'asc, desc',
  327. sortName: 'status, apply_time'
  328. }
  329. }
  330. return getRepairApplicationFormPoolPage(Object.assign(parameter, this.queryParam))
  331. .then(res => {
  332. console.log(res.data.model)
  333. console.log(res.data)
  334. return res.data
  335. })
  336. },
  337. selectedRowKeys: [],
  338. selectedRows: [],
  339. options: {
  340. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  341. rowSelection: {
  342. selectedRowKeys: this.selectedRowKeys,
  343. onChange: this.onSelectChange
  344. }
  345. },
  346. optionAlertShow: false
  347. }
  348. },
  349. created () {
  350. this.dispatchFlag = false
  351. this.allocatedFlag = false
  352. this.editFlag = false
  353. // const repairModel = this.DictCache.getConfigValueByType(this.DictCache.TYPE.REPAIR_STRATEGY_MODEL)
  354. if (this.searchType === 3) {
  355. this.allocatedFlag = true
  356. }
  357. // 获取当前用户角色
  358. const bxrFlag = Vue.ls.get('bxrFlag')
  359. if (this.searchType === 5 && bxrFlag === 1) {
  360. this.editFlag = true
  361. }
  362. /* if (repairModel === this.DictCache.VALUE.REPAIR_MODEL_TYPE.BASE_MODEL) {
  363. this.dispatchFlag = false
  364. } */
  365. // 下拉框map
  366. this.categoryMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY)
  367. this.sourceMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
  368. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
  369. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
  370. this.needStopMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  371. this.planFlagMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY)
  372. // 获取浏览器的请求参数:报修单编号:no
  373. const no = this.$route.query.no
  374. if (no != null) {
  375. this.queryParam.no = no
  376. }
  377. this.tableOption()
  378. },
  379. methods: {
  380. tableOption () {
  381. if (!this.optionAlertShow) {
  382. this.options = {
  383. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  384. rowSelection: {
  385. selectedRowKeys: this.selectedRowKeys,
  386. onChange: this.onSelectChange,
  387. getCheckboxProps: record => ({
  388. props: {
  389. disabled: false,
  390. name: record.id
  391. }
  392. })
  393. }
  394. }
  395. this.optionAlertShow = true
  396. } else {
  397. this.options = {
  398. alert: false,
  399. rowSelection: null
  400. }
  401. this.optionAlertShow = false
  402. }
  403. },
  404. batchDelete (id) {
  405. let ids = []
  406. if (this.BaseTool.String.isBlank(id)) {
  407. const length = this.selectedRows.length
  408. if (length === 0) {
  409. this.$message.info('请选择要删除的记录')
  410. return
  411. }
  412. ids = this.selectedRows.map(item => item.id)
  413. } else {
  414. ids = [id]
  415. }
  416. deleteRepairApplicationForms(ids).then(res => {
  417. this.$message.info('删除成功')
  418. this.handleOk()
  419. this.$refs.table.clearSelected()
  420. })
  421. },
  422. receiveRepair (record) {
  423. const params = {}
  424. params.id = record.id
  425. params.repairDeptId = record.repairDeptId
  426. params.applyTime = record.applyTime
  427. params.userId = record.userId
  428. params.no = record.no
  429. params.category = record.category
  430. receiveRepair(params).then(() => {
  431. this.$message.info('接单成功')
  432. this.handleOk()
  433. })
  434. },
  435. handleEdit (record) {
  436. fetchRepairApplicationForm({ id: record.id }).then(res => {
  437. const type = res.data.type
  438. const modal = type === 2 ? this.$refs.baseOutModal : this.$refs.baseModal
  439. modal.base(res.data)
  440. })
  441. },
  442. handleView (record) {
  443. fetchRepairApplicationForm({ id: record.id }).then(res => {
  444. this.visible = false
  445. const type = res.data.type
  446. const modal = type === 2 ? this.$refs.detailOutModal : this.$refs.detailModal
  447. modal.base(res.data)
  448. })
  449. },
  450. handleAssign (record) {
  451. const modal = this.$refs.assignForm
  452. modal.base(record)
  453. },
  454. handleApprove (record) {
  455. approve(record).then(() => {
  456. this.$message.info('操作成功')
  457. this.handleOk()
  458. })
  459. },
  460. handleReturn (record) {
  461. const modal = this.$refs.checkForm
  462. modal.base(record, 1)
  463. },
  464. handleReceive (record) {
  465. const temp = this
  466. fetchRepairApplicationForm({ id: record.id }).then(res => {
  467. receive(res.data).then(() => {
  468. temp.handleOk()
  469. })
  470. })
  471. },
  472. handleRefused (record) {
  473. const modal = this.$refs.refusedForm
  474. modal.base(record)
  475. },
  476. handleOk () {
  477. this.visible = true
  478. this.queryParam.searchStartTime = this.queryParam.searchStartTime ? this.BaseTool.Date.formatter(this.queryParam.searchStartTime, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN) : null
  479. this.queryParam.searchEndTime = this.queryParam.searchEndTime ? this.BaseTool.Date.formatter(this.queryParam.searchEndTime, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN) : null
  480. this.$refs.table.refresh()
  481. },
  482. onSelectChange (selectedRowKeys, selectedRows) {
  483. this.selectedRowKeys = selectedRowKeys
  484. this.selectedRows = selectedRows
  485. },
  486. resetSearchForm () {
  487. this.queryParam = {
  488. }
  489. this.$refs.table.refresh(true)
  490. },
  491. doExport () {
  492. const parameter = {
  493. ...this.queryParam,
  494. searchStartTime: this.queryParam.searchStartTime,
  495. searchEndTime: this.queryParam.searchEndTime
  496. }
  497. exportRepairApplicationForm(parameter).then(file => {
  498. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  499. })
  500. },
  501. handleDispatching (record) {
  502. const modal = this.$refs.dispatchBaseForm
  503. modal.base(record)
  504. }
  505. }
  506. }
  507. </script>