RepairForm.vue 16 KB

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