RepairForm.vue 16 KB

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