RepairApplicationForm.vue 14 KB

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