RepairForm.vue 15 KB

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