RepairForm.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  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="editFlag"
  101. v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.REFUSED_REPAIR === record.status && $auth('repair-application-forms-edit')"
  102. @click="handleEdit(record)" >再次报修</operation-button>
  103. <operation-button
  104. v-show="editFlag"
  105. v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status && $auth('repair-application-forms-edit')"
  106. @click="handleEdit(record)" >修改</operation-button>
  107. <operation-button
  108. v-show="dispatchFlag"
  109. v-if="( DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.REBACK === record.status ||
  110. DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.REPAIR_FAIL === record.status) && $auth('repair-application-forms-dispatch')"
  111. @click="handleAssign(record)" >派工</operation-button>
  112. <operation-button
  113. v-show="allocatedFlag"
  114. v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status && $auth('repair-application-forms-dispatch')"
  115. @click="handleAssign(record)" >接收并派工</operation-button>
  116. <operation-button
  117. v-show="allocatedFlag"
  118. v-if="$auth('repair-application-forms-deal') && (DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status)"
  119. :type="2"
  120. title="是否要驳回?"
  121. @confirm="handleRefused(record)">报修驳回</operation-button>
  122. </template>
  123. </span>
  124. <span slot="status" slot-scope="text">
  125. <badge :text="BaseTool.Object.getField(statusMap,text)" :status="DictCache.COLOR.REPAIR_APPLICATION_FORM_STATUS[text]"/>
  126. </span>
  127. <span slot="level" slot-scope="text">
  128. <badge :text="BaseTool.Object.getField(levelMap,text)" :status="DictCache.COLOR.REPAIR_APPLICATION_FORM_LEVEL[text]"/>
  129. </span>
  130. </s-table>
  131. </a-card>
  132. <base-form ref="baseModal" @ok="handleOk"/>
  133. <base-out-form ref="baseOutModal" @ok="handleOk"/>
  134. <detail ref="detailModal" @ok="handleOk"/>
  135. <detail-out ref="detailOutModal" @ok="handleOk"/>
  136. <assign-form ref="assignForm" @ok="handleOk" />
  137. <dispatch-base-form ref="dispatchBaseForm" @ok="handleOk" />
  138. <refused-form ref='refusedForm' @ok='handleOk'/>
  139. </div>
  140. </template>
  141. <script>
  142. import { STable, Ellipsis } from '@/components'
  143. import BaseForm from './modules/BaseForm'
  144. import BaseOutForm from './modules/BaseOutForm'
  145. import AssignForm from './modules/AssignForm'
  146. import Detail from './modules/DetailRepair'
  147. import DetailOut from './modules/DetailRepairOut'
  148. import RefusedForm from './modules/RefusedForm'
  149. import {
  150. getRepairApplicationFormPage,
  151. deleteRepairApplicationForms,
  152. fetchRepairApplicationForm,
  153. exportRepairApplicationForm,
  154. receive
  155. } from '@/api/repair/application-form'
  156. import DispatchBaseForm from '@/views/repair/application-form/modules/DispatchBaseForm'
  157. export default {
  158. name: 'RepairForm',
  159. components: {
  160. STable,
  161. Ellipsis,
  162. BaseForm,
  163. BaseOutForm,
  164. DetailOut,
  165. AssignForm,
  166. Detail,
  167. DispatchBaseForm,
  168. RefusedForm
  169. },
  170. props: {
  171. filter: {
  172. type: Number,
  173. default: -1
  174. },
  175. searchType: {
  176. type: Number,
  177. default: -1
  178. }
  179. },
  180. data () {
  181. return {
  182. // 查询参数
  183. queryParam: {
  184. filter: this.filter,
  185. searchType: this.searchType,
  186. ...this.$route.query
  187. },
  188. visible: true,
  189. dispatchFlag: false,
  190. allocatedFlag: false,
  191. editFlag: false,
  192. // 表头
  193. columns: [
  194. {
  195. title: '序号',
  196. dataIndex: 'index',
  197. checked: true,
  198. width: '70px',
  199. customRender: (text, record, index) => {
  200. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  201. }
  202. },
  203. {
  204. title: '设备编号',
  205. checked: true,
  206. width: '100px',
  207. dataIndex: 'sbNo'
  208. },
  209. {
  210. title: '设备名称',
  211. checked: true,
  212. width: '150px',
  213. dataIndex: 'sbId',
  214. customRender: (text, record, index) => {
  215. return record.sbName
  216. }
  217. },
  218. {
  219. title: '报修人',
  220. checked: true,
  221. width: '120px',
  222. dataIndex: 'userName'
  223. },
  224. {
  225. title: '维修人',
  226. checked: true,
  227. width: '120px',
  228. dataIndex: 'repairUserName'
  229. },
  230. {
  231. title: '工单类型',
  232. checked: true,
  233. width: '100px',
  234. dataIndex: 'category',
  235. customRender: (text, record, index) => {
  236. return this.BaseTool.Object.getField(this.planFlagMap, text)
  237. }
  238. },
  239. {
  240. title: '报修时间',
  241. checked: true,
  242. width: '200px',
  243. dataIndex: 'applyTime'
  244. },
  245. /* {
  246. title: '紧急等级',
  247. checked: true,
  248. width: '200px',
  249. dataIndex: 'level',
  250. customRender: (text, record, index) => {
  251. return this.BaseTool.Object.getField(this.levelMap, text)
  252. }
  253. },
  254. {
  255. title: '计划性维修',
  256. checked: true,
  257. dataIndex: 'needStop',
  258. customRender: (text, record, index) => {
  259. return this.BaseTool.Object.getField(this.needStopMap, text)
  260. }
  261. }, */
  262. {
  263. title: '创建日期',
  264. width: '200px',
  265. dataIndex: 'createdTime'
  266. },
  267. {
  268. title: '接收超时',
  269. checked: true,
  270. width: '100px',
  271. dataIndex: 'receiveOvertime',
  272. customRender: (text, record, index) => {
  273. if (text) {
  274. return '是'
  275. } else {
  276. return '否'
  277. }
  278. }
  279. },
  280. {
  281. title: '维修超时',
  282. checked: true,
  283. width: '100px',
  284. dataIndex: 'repairOvertime',
  285. customRender: (text, record, index) => {
  286. if (text) {
  287. return '是'
  288. } else {
  289. return '否'
  290. }
  291. }
  292. },
  293. {
  294. title: '报修状态',
  295. checked: true,
  296. width: '100px',
  297. fixed: 'right',
  298. dataIndex: 'status',
  299. scopedSlots: { customRender: 'status' }
  300. },
  301. {
  302. title: '操作',
  303. checked: true,
  304. fixed: 'right',
  305. key: 'action',
  306. width: '150px',
  307. align: 'center',
  308. scopedSlots: { customRender: 'action' }
  309. }
  310. ],
  311. // 下拉框map
  312. sourceMap: {},
  313. levelMap: {},
  314. statusMap: {},
  315. needStopMap: {},
  316. planFlagMap: {},
  317. // 加载数据方法 必须为 Promise 对象
  318. loadData: parameter => {
  319. parameter = {
  320. ...parameter,
  321. ...this.queryParam,
  322. type: null,
  323. dataScope: {
  324. sortBy: 'asc, desc',
  325. sortName: 'status, apply_time'
  326. }
  327. }
  328. return getRepairApplicationFormPage(Object.assign(parameter, this.queryParam))
  329. .then(res => {
  330. console.log(res.data.model)
  331. console.log(res.data)
  332. return res.data
  333. })
  334. },
  335. selectedRowKeys: [],
  336. selectedRows: [],
  337. options: {
  338. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  339. rowSelection: {
  340. selectedRowKeys: this.selectedRowKeys,
  341. onChange: this.onSelectChange
  342. }
  343. },
  344. optionAlertShow: false
  345. }
  346. },
  347. created () {
  348. this.dispatchFlag = false
  349. this.allocatedFlag = false
  350. this.editFlag = false
  351. // const repairModel = this.DictCache.getConfigValueByType(this.DictCache.TYPE.REPAIR_STRATEGY_MODEL)
  352. if (this.searchType === 4) {
  353. this.dispatchFlag = true
  354. }
  355. if (this.searchType === 3) {
  356. this.allocatedFlag = true
  357. }
  358. if (this.searchType === 1 || this.searchType === -1) {
  359. this.editFlag = true
  360. }
  361. /* if (repairModel === this.DictCache.VALUE.REPAIR_MODEL_TYPE.BASE_MODEL) {
  362. this.dispatchFlag = false
  363. } */
  364. // 下拉框map
  365. this.sourceMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
  366. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
  367. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
  368. this.needStopMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  369. this.planFlagMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY)
  370. // 获取浏览器的请求参数:报修单编号:no
  371. const no = this.$route.query.no
  372. if (no != null) {
  373. this.queryParam.no = no
  374. }
  375. this.tableOption()
  376. },
  377. methods: {
  378. tableOption () {
  379. if (!this.optionAlertShow) {
  380. this.options = {
  381. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  382. rowSelection: {
  383. selectedRowKeys: this.selectedRowKeys,
  384. onChange: this.onSelectChange,
  385. getCheckboxProps: record => ({
  386. props: {
  387. disabled: false,
  388. name: record.id
  389. }
  390. })
  391. }
  392. }
  393. this.optionAlertShow = true
  394. } else {
  395. this.options = {
  396. alert: false,
  397. rowSelection: null
  398. }
  399. this.optionAlertShow = false
  400. }
  401. },
  402. batchDelete (id) {
  403. let ids = []
  404. if (this.BaseTool.String.isBlank(id)) {
  405. const length = this.selectedRows.length
  406. if (length === 0) {
  407. this.$message.info('请选择要删除的记录')
  408. return
  409. }
  410. ids = this.selectedRows.map(item => item.id)
  411. } else {
  412. ids = [id]
  413. }
  414. deleteRepairApplicationForms(ids).then(res => {
  415. this.$message.info('删除成功')
  416. this.handleOk()
  417. this.$refs.table.clearSelected()
  418. })
  419. },
  420. handleEdit (record) {
  421. fetchRepairApplicationForm({ id: record.id }).then(res => {
  422. const type = res.data.type
  423. const modal = type === 2 ? this.$refs.baseOutModal : this.$refs.baseModal
  424. modal.base(res.data)
  425. })
  426. },
  427. handleView (record) {
  428. fetchRepairApplicationForm({ id: record.id }).then(res => {
  429. this.visible = false
  430. const type = res.data.type
  431. const modal = type === 2 ? this.$refs.detailOutModal : this.$refs.detailModal
  432. modal.base(res.data)
  433. })
  434. },
  435. handleAssign (record) {
  436. const modal = this.$refs.assignForm
  437. modal.base(record)
  438. },
  439. handleReceive (record) {
  440. const temp = this
  441. fetchRepairApplicationForm({ id: record.id }).then(res => {
  442. receive(res.data).then(() => {
  443. temp.handleOk()
  444. })
  445. })
  446. },
  447. handleRefused (record) {
  448. const modal = this.$refs.refusedForm
  449. modal.base(record)
  450. },
  451. handleOk () {
  452. this.visible = true
  453. this.queryParam.searchStartTime = this.queryParam.searchStartTime ? this.BaseTool.Date.formatter(this.queryParam.searchStartTime, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN) : null
  454. this.queryParam.searchEndTime = this.queryParam.searchEndTime ? this.BaseTool.Date.formatter(this.queryParam.searchEndTime, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN) : null
  455. this.$refs.table.refresh()
  456. },
  457. onSelectChange (selectedRowKeys, selectedRows) {
  458. this.selectedRowKeys = selectedRowKeys
  459. this.selectedRows = selectedRows
  460. },
  461. resetSearchForm () {
  462. this.queryParam = {
  463. }
  464. this.$refs.table.refresh(true)
  465. },
  466. doExport () {
  467. const parameter = {
  468. ...this.queryParam,
  469. searchStartTime: this.queryParam.searchStartTime,
  470. searchEndTime: this.queryParam.searchEndTime
  471. }
  472. exportRepairApplicationForm(parameter).then(file => {
  473. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  474. })
  475. },
  476. handleDispatching (record) {
  477. const modal = this.$refs.dispatchBaseForm
  478. modal.base(record)
  479. }
  480. }
  481. }
  482. </script>