RepairForm.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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.content" placeholder="问题描述模糊查询"/>
  25. </a-form-item>
  26. </a-col>
  27. <a-col :md="6" :sm="24">
  28. <a-form-item label="起始日期">
  29. <a-date-picker
  30. v-model="queryParam.searchStartTime"
  31. style="width: 100%"
  32. :format="BaseTool.Date.PICKER_NORM_DATETIME_PATTERN"
  33. />
  34. </a-form-item>
  35. </a-col>
  36. <a-col :md="6" :sm="24">
  37. <a-form-item label="结束日期">
  38. <a-date-picker
  39. v-model="queryParam.searchEndTime"
  40. style="width: 100%"
  41. :format="BaseTool.Date.PICKER_NORM_DATETIME_PATTERN"
  42. />
  43. </a-form-item>
  44. </a-col>
  45. <a-col :md="8 || 24" :sm="24">
  46. <span class="table-page-search-submitButtons">
  47. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  48. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  49. </span>
  50. </a-col>
  51. </a-row>
  52. </a-form>
  53. </div>
  54. <div class="table-operator">
  55. <a-button v-if="$auth('repair-application-forms-add')" type="primary" icon="plus" @click="$refs.baseModal.base({},{filter: -1})">新增</a-button>
  56. <a-button style="margin-left: 8px" v-if="$auth('repair-application-forms-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  57. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('repair-application-forms-del')">
  58. <a-menu slot="overlay">
  59. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  60. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  61. </a-popconfirm>
  62. </a-menu>
  63. <a-button style="margin-left: 8px">
  64. 批量操作 <a-icon type="down" />
  65. </a-button>
  66. </a-dropdown>
  67. </div>
  68. <s-table
  69. ref="table"
  70. size="default"
  71. rowKey="id"
  72. :columns="columns"
  73. :data="loadData"
  74. :alert="options.alert"
  75. :rowSelection="options.rowSelection"
  76. :scroll="{x: 1000, y: BaseTool.Constant.scrollY }"
  77. showPagination="auto"
  78. >
  79. <span slot="action" slot-scope="record">
  80. <template>
  81. <a @click="handleView(record)">查看</a>
  82. <operation-button
  83. v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status && $auth('repair-application-forms-edit')"
  84. @click="handleEdit(record)" >修改</operation-button>
  85. <!-- <operation-button-->
  86. <!-- v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status && $auth('repair-application-forms-del')"-->
  87. <!-- :type="2"-->
  88. <!-- title="是否要删除该条数据?"-->
  89. <!-- @confirm="batchDelete(record.id)">删除</operation-button>-->
  90. <!--<operation-button
  91. v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status && $auth('repair-application-forms-dispatch')"
  92. @click="handleDispatching(record)" >派工</operation-button>-->
  93. <operation-button
  94. v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status && $auth('repair-application-forms-edit')"
  95. @click="handleAssign(record)" >派工</operation-button>
  96. </template>
  97. </span>
  98. <span slot="status" slot-scope="text">
  99. <badge :text="BaseTool.Object.getField(statusMap,text)" :status="DictCache.COLOR.REPAIR_APPLICATION_FORM_STATUS[text]"/>
  100. </span>
  101. <span slot="level" slot-scope="text">
  102. <badge :text="BaseTool.Object.getField(levelMap,text)" :status="DictCache.COLOR.REPAIR_APPLICATION_FORM_LEVEL[text]"/>
  103. </span>
  104. </s-table>
  105. </div>
  106. <base-form ref="baseModal" @ok="handleOk"/>
  107. <base-out-form ref="baseOutModal" @ok="handleOk"/>
  108. <detail ref="detailModal" @ok="handleOk"/>
  109. <detail-out ref="detailOutModal" @ok="handleOk"/>
  110. <assign-form ref="assignForm" @ok="handleOk" />
  111. <dispatch-base-form ref="dispatchBaseForm" @ok="handleOk" />
  112. </a-card>
  113. </template>
  114. <script>
  115. import { STable, Ellipsis } from '@/components'
  116. import BaseForm from './modules/BaseForm'
  117. import BaseOutForm from './modules/BaseOutForm'
  118. import AssignForm from './modules/AssignForm'
  119. import Detail from './modules/DetailRepair'
  120. import DetailOut from './modules/DetailRepairOut'
  121. import { getRepairApplicationFormPage, deleteRepairApplicationForms, fetchRepairApplicationForm, exportRepairApplicationForm } from '@/api/repair/application-form'
  122. import DispatchBaseForm from '@/views/repair/application-form/modules/DispatchBaseForm'
  123. export default {
  124. name: 'RepairForm',
  125. components: {
  126. STable,
  127. Ellipsis,
  128. BaseForm,
  129. BaseOutForm,
  130. DetailOut,
  131. AssignForm,
  132. Detail,
  133. DispatchBaseForm
  134. },
  135. props: {
  136. filter: {
  137. type: Number,
  138. default: -1
  139. },
  140. searchType: {
  141. type: Number,
  142. default: null
  143. }
  144. },
  145. data () {
  146. return {
  147. // 查询参数
  148. queryParam: {
  149. filter: this.filter,
  150. searchType: this.searchType
  151. },
  152. visible: true,
  153. // 表头
  154. columns: [
  155. {
  156. title: '序号',
  157. dataIndex: 'index',
  158. checked: true,
  159. width: '70px',
  160. customRender: (text, record, index) => {
  161. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  162. }
  163. },
  164. {
  165. title: '设备编号',
  166. checked: true,
  167. width: '100px',
  168. dataIndex: 'sbNo'
  169. },
  170. {
  171. title: '设备名称',
  172. checked: true,
  173. width: '150px',
  174. dataIndex: 'sbId',
  175. customRender: (text, record, index) => {
  176. return record.sbName
  177. }
  178. },
  179. {
  180. title: '报修人',
  181. checked: true,
  182. width: '120px',
  183. dataIndex: 'actualUser'
  184. },
  185. {
  186. title: '报修来源',
  187. checked: true,
  188. width: '100px',
  189. dataIndex: 'source',
  190. customRender: (text, record, index) => {
  191. return this.BaseTool.Object.getField(this.sourceMap, text)
  192. }
  193. },
  194. {
  195. title: '报修时间',
  196. checked: true,
  197. width: '150px',
  198. dataIndex: 'applyTime'
  199. },
  200. /* {
  201. title: '紧急等级',
  202. checked: true,
  203. width: '200px',
  204. dataIndex: 'level',
  205. customRender: (text, record, index) => {
  206. return this.BaseTool.Object.getField(this.levelMap, text)
  207. }
  208. },
  209. {
  210. title: '是否停机',
  211. checked: true,
  212. dataIndex: 'needStop',
  213. customRender: (text, record, index) => {
  214. return this.BaseTool.Object.getField(this.needStopMap, text)
  215. }
  216. }, */
  217. {
  218. title: '创建日期',
  219. width: '200px',
  220. dataIndex: 'createdTime'
  221. },
  222. {
  223. title: '接收超时',
  224. checked: true,
  225. width: '100px',
  226. dataIndex: 'receiveOvertime',
  227. customRender: (text, record, index) => {
  228. if (text === '1') {
  229. return '是'
  230. } else {
  231. return '否'
  232. }
  233. }
  234. },
  235. {
  236. title: '维修超时',
  237. checked: true,
  238. width: '100px',
  239. dataIndex: 'repairOvertime',
  240. customRender: (text, record, index) => {
  241. if (text === '1') {
  242. return '是'
  243. } else {
  244. return '否'
  245. }
  246. }
  247. },
  248. {
  249. title: '报修状态',
  250. checked: true,
  251. width: '100px',
  252. fixed: 'right',
  253. dataIndex: 'status',
  254. scopedSlots: { customRender: 'status' }
  255. },
  256. {
  257. title: '操作',
  258. checked: true,
  259. fixed: 'right',
  260. key: 'action',
  261. width: '150px',
  262. align: 'center',
  263. scopedSlots: { customRender: 'action' }
  264. }
  265. ],
  266. // 下拉框map
  267. sourceMap: {},
  268. levelMap: {},
  269. statusMap: {},
  270. needStopMap: {},
  271. // 加载数据方法 必须为 Promise 对象
  272. loadData: parameter => {
  273. parameter = {
  274. ...parameter,
  275. ...this.queryParam,
  276. type: 1,
  277. dataScope: {
  278. sortBy: 'desc',
  279. sortName: 'update_time'
  280. }
  281. }
  282. return getRepairApplicationFormPage(Object.assign(parameter, this.queryParam))
  283. .then(res => {
  284. return res.data
  285. })
  286. },
  287. selectedRowKeys: [],
  288. selectedRows: [],
  289. options: {
  290. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  291. rowSelection: {
  292. selectedRowKeys: this.selectedRowKeys,
  293. onChange: this.onSelectChange
  294. }
  295. },
  296. optionAlertShow: false
  297. }
  298. },
  299. created () {
  300. // 下拉框map
  301. this.sourceMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
  302. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
  303. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
  304. this.needStopMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  305. // 获取浏览器的请求参数:报修单编号:no
  306. const no = this.$route.query.no
  307. if (no != null) {
  308. this.queryParam.no = no
  309. }
  310. this.tableOption()
  311. },
  312. methods: {
  313. tableOption () {
  314. if (!this.optionAlertShow) {
  315. this.options = {
  316. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  317. rowSelection: {
  318. selectedRowKeys: this.selectedRowKeys,
  319. onChange: this.onSelectChange,
  320. getCheckboxProps: record => ({
  321. props: {
  322. disabled: false,
  323. name: record.id
  324. }
  325. })
  326. }
  327. }
  328. this.optionAlertShow = true
  329. } else {
  330. this.options = {
  331. alert: false,
  332. rowSelection: null
  333. }
  334. this.optionAlertShow = false
  335. }
  336. },
  337. batchDelete (id) {
  338. let ids = []
  339. if (this.BaseTool.String.isBlank(id)) {
  340. const length = this.selectedRows.length
  341. if (length === 0) {
  342. this.$message.info('请选择要删除的记录')
  343. return
  344. }
  345. ids = this.selectedRows.map(item => item.id)
  346. } else {
  347. ids = [id]
  348. }
  349. deleteRepairApplicationForms(ids).then(res => {
  350. this.$message.info('删除成功')
  351. this.handleOk()
  352. this.$refs.table.clearSelected()
  353. })
  354. },
  355. handleEdit (record) {
  356. fetchRepairApplicationForm({ id: record.id }).then(res => {
  357. const type = res.data.type
  358. const modal = type === 2 ? this.$refs.baseOutModal : this.$refs.baseModal
  359. modal.base(res.data)
  360. })
  361. },
  362. handleView (record) {
  363. fetchRepairApplicationForm({ id: record.id }).then(res => {
  364. this.visible = false
  365. const type = res.data.type
  366. const modal = type === 2 ? this.$refs.detailOutModal : this.$refs.detailModal
  367. modal.base(res.data)
  368. })
  369. },
  370. handleAssign (record) {
  371. const modal = this.$refs.assignForm
  372. modal.base(record)
  373. },
  374. handleOk () {
  375. this.visible = true
  376. this.queryParam.searchStartTime = this.queryParam.searchStartTime ? this.BaseTool.Date.formatter(this.queryParam.searchStartTime, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN) : null
  377. this.queryParam.searchEndTime = this.queryParam.searchEndTime ? this.BaseTool.Date.formatter(this.queryParam.searchEndTime, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN) : null
  378. this.$refs.table.refresh()
  379. },
  380. onSelectChange (selectedRowKeys, selectedRows) {
  381. this.selectedRowKeys = selectedRowKeys
  382. this.selectedRows = selectedRows
  383. },
  384. resetSearchForm () {
  385. this.queryParam = {
  386. }
  387. this.$refs.table.refresh(true)
  388. },
  389. doExport () {
  390. const parameter = {
  391. ...this.queryParam,
  392. searchStartTime: this.queryParam.searchStartTime,
  393. searchEndTime: this.queryParam.searchEndTime
  394. }
  395. exportRepairApplicationForm(parameter).then(file => {
  396. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  397. })
  398. },
  399. handleDispatching (record) {
  400. const modal = this.$refs.dispatchBaseForm
  401. modal.base(record)
  402. }
  403. }
  404. }
  405. </script>