RepairForm.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  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-select v-model="queryParam.deptId" placeholder="请选择部门" allowClear showSearch
  30. optionFilterProp="label">
  31. <a-select-option v-for="item in deptList" :key="item.deptId" :label="item.name"
  32. :value="item.deptId">{{ item.name }}
  33. </a-select-option>
  34. </a-select>
  35. </a-form-item>
  36. </a-col>
  37. <a-col :md="6" :sm="24">
  38. <a-form-item label="问题描述">
  39. <a-input v-model="queryParam.content" placeholder="问题描述模糊查询" />
  40. </a-form-item>
  41. </a-col>
  42. <a-col :md="6" :sm="24">
  43. <a-form-item label="状态">
  44. <a-select v-model="queryParam.status" placeholder="请选择">
  45. <a-select-option v-for="(label, value) in statusMap" :key="value" :label="label"
  46. :value="parseInt(value)">{{ label }}
  47. </a-select-option>
  48. </a-select>
  49. </a-form-item>
  50. </a-col>
  51. <a-col :md="6" :sm="24">
  52. <a-form-item label="报修起始日期">
  53. <a-date-picker v-model="queryParam.searchStartTime" style="width: 100%"
  54. :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN" />
  55. </a-form-item>
  56. </a-col>
  57. <a-col :md="6" :sm="24">
  58. <a-form-item label="报修结束日期">
  59. <a-date-picker v-model="queryParam.searchEndTime" style="width: 100%"
  60. :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN" />
  61. </a-form-item>
  62. </a-col>
  63. <a-col :md="8 || 24" :sm="24">
  64. <span class="table-page-search-submitButtons">
  65. <a-button type="primary" @click="handleOk()">查询</a-button>
  66. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  67. </span>
  68. </a-col>
  69. </a-row>
  70. </a-form>
  71. </div>
  72. <div class="table-operator">
  73. <a-button v-if="$auth('repair-application-forms-add') && filter != 0 && searchType != 2" type="primary"
  74. icon="plus" @click="$refs.baseModal.base({}, { filter: -1 })">新增</a-button>
  75. <a-button style="margin-left: 8px" v-if="$auth('repair-application-forms-export')" type="primary"
  76. icon="download" @click="doExport">导出</a-button>
  77. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('repair-application-forms-del')">
  78. <a-menu slot="overlay">
  79. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  80. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  81. </a-popconfirm>
  82. </a-menu>
  83. <a-button style="margin-left: 8px">
  84. 批量操作 <a-icon type="down" />
  85. </a-button>
  86. </a-dropdown>
  87. </div>
  88. <s-table ref="table" size="default" rowKey="id" :columns="columns" :data="loadData" :alert="options.alert"
  89. :rowSelection="options.rowSelection" :scroll="{ x: 1000, y: BaseTool.Constant.scrollY }" showPagination="auto">
  90. <span slot="action" slot-scope="record">
  91. <template>
  92. <a @click="handleView(record)">查看</a>
  93. <operation-button
  94. v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status && $auth('repair-application-forms-edit')"
  95. @click="handleEdit(record)">修改</operation-button>
  96. <!-- <operation-button-->
  97. <!-- v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status && $auth('repair-application-forms-del')"-->
  98. <!-- :type="2"-->
  99. <!-- title="是否要删除该条数据?"-->
  100. <!-- @confirm="batchDelete(record.id)">删除</operation-button>-->
  101. <!--<operation-button
  102. v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status && $auth('repair-application-forms-dispatch')"
  103. @click="handleDispatching(record)" >派工</operation-button>-->
  104. <operation-button
  105. v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status && $auth('repair-application-forms-dispatch')"
  106. @click="handleAssign(record)">派工</operation-button>
  107. </template>
  108. </span>
  109. <span slot="status" slot-scope="text">
  110. <badge :text="BaseTool.Object.getField(statusMap, text)"
  111. :status="DictCache.COLOR.REPAIR_APPLICATION_FORM_STATUS[text]" />
  112. </span>
  113. <span slot="level" slot-scope="text">
  114. <badge :text="BaseTool.Object.getField(levelMap, text)"
  115. :status="DictCache.COLOR.REPAIR_APPLICATION_FORM_LEVEL[text]" />
  116. </span>
  117. </s-table>
  118. </div>
  119. <base-form ref="baseModal" @ok="handleOk" />
  120. <base-out-form ref="baseOutModal" @ok="handleOk" />
  121. <detail ref="detailModal" @ok="handleOk" />
  122. <detail-out ref="detailOutModal" @ok="handleOk" />
  123. <assign-form ref="assignForm" @ok="handleOk" />
  124. <dispatch-base-form ref="dispatchBaseForm" @ok="handleOk" />
  125. </a-card>
  126. </template>
  127. <script>
  128. import { STable, Ellipsis } from '@/components'
  129. import BaseForm from './modules/BaseForm'
  130. import BaseOutForm from './modules/BaseOutForm'
  131. import AssignForm from './modules/AssignForm'
  132. import Detail from './modules/DetailRepair'
  133. import DetailOut from './modules/DetailRepairOut'
  134. import { getRepairApplicationFormPage, deleteRepairApplicationForms, fetchRepairApplicationForm, exportRepairApplicationForm } from '@/api/repair/application-form'
  135. import DispatchBaseForm from '@/views/repair/application-form/modules/DispatchBaseForm'
  136. import { queryDept } from '@/api/upms/dept'
  137. // import { selectUserDept } from '@/api/upms/user-dept'
  138. export default {
  139. name: 'RepairForm',
  140. components: {
  141. STable,
  142. Ellipsis,
  143. BaseForm,
  144. BaseOutForm,
  145. DetailOut,
  146. AssignForm,
  147. Detail,
  148. DispatchBaseForm
  149. },
  150. props: {
  151. filter: {
  152. type: Number,
  153. default: -1
  154. },
  155. searchType: {
  156. type: Number,
  157. default: null
  158. }
  159. },
  160. data() {
  161. // 从通知链接跳转时(带no参数),不默认按本部门筛选,避免跨部门工单看不到
  162. const hasNoParam = this.$route.query.no != null
  163. return {
  164. // 查询参数
  165. queryParam: {
  166. deptId: hasNoParam ? null : this.$store.getters.userInfo.deptId,
  167. searchStartTime: null,
  168. searchEndTime: null
  169. },
  170. visible: true,
  171. // 表头
  172. columns: [
  173. {
  174. title: '序号',
  175. dataIndex: 'index',
  176. checked: true,
  177. width: '70px',
  178. customRender: (text, record, index) => {
  179. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  180. }
  181. },
  182. {
  183. title: '设备编号',
  184. checked: true,
  185. width: '100px',
  186. dataIndex: 'sbNo'
  187. },
  188. {
  189. title: '设备名称',
  190. checked: true,
  191. width: '150px',
  192. dataIndex: 'sbId',
  193. customRender: (text, record, index) => {
  194. return record.sbName
  195. }
  196. },
  197. {
  198. title: '紧急程度',
  199. checked: true,
  200. width: '120px',
  201. dataIndex: 'level',
  202. customRender: (text, record, index) => {
  203. return this.BaseTool.Object.getField(this.levelMap, text)
  204. }
  205. },
  206. {
  207. title: '故障类型',
  208. checked: true,
  209. width: '120px',
  210. dataIndex: 'repairErrorTypeId',
  211. customRender: (text, record, index) => {
  212. return this.BaseTool.Object.getField(this.faultTypeMap, text)
  213. }
  214. },
  215. {
  216. title: '工单类型',
  217. checked: true,
  218. width: '100px',
  219. dataIndex: 'category',
  220. customRender: (text, record, index) => {
  221. return this.BaseTool.Object.getField(this.planFlagMap, text)
  222. }
  223. },
  224. {
  225. title: '报修时间',
  226. checked: true,
  227. width: '200px',
  228. dataIndex: 'applyTime'
  229. },
  230. /* {
  231. title: '紧急等级',
  232. checked: true,
  233. width: '200px',
  234. dataIndex: 'level',
  235. customRender: (text, record, index) => {
  236. return this.BaseTool.Object.getField(this.levelMap, text)
  237. }
  238. },
  239. {
  240. title: '计划性维修',
  241. checked: true,
  242. dataIndex: 'needStop',
  243. customRender: (text, record, index) => {
  244. return this.BaseTool.Object.getField(this.needStopMap, text)
  245. }
  246. }, */
  247. {
  248. title: '创建日期',
  249. width: '200px',
  250. dataIndex: 'createdTime'
  251. },
  252. {
  253. title: '报修人',
  254. checked: true,
  255. width: '120px',
  256. dataIndex: 'actualUser'
  257. },
  258. {
  259. title: '维修人',
  260. checked: true,
  261. width: '120px',
  262. dataIndex: 'repairUserName'
  263. },
  264. {
  265. title: '报修状态',
  266. checked: true,
  267. width: '100px',
  268. fixed: 'right',
  269. dataIndex: 'status',
  270. scopedSlots: { customRender: 'status' }
  271. },
  272. {
  273. title: '操作',
  274. checked: true,
  275. fixed: 'right',
  276. key: 'action',
  277. width: '150px',
  278. align: 'center',
  279. scopedSlots: { customRender: 'action' }
  280. }
  281. ],
  282. // 下拉框map
  283. sourceMap: {},
  284. levelMap: {},
  285. statusMap: {},
  286. needStopMap: {},
  287. planFlagMap: {},
  288. faultTypeMap: {},
  289. // 部门下拉数据
  290. deptList: [],
  291. // 加载数据方法 必须为 Promise 对象
  292. loadData: parameter => {
  293. parameter = {
  294. ...parameter,
  295. ...this.queryParam,
  296. filter: this.filter,
  297. searchType: this.searchType,
  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. this.faultTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_ERROR_TYPE)
  329. // 获取浏览器的请求参数:报修单编号:no
  330. const no = this.$route.query.no
  331. if (no != null) {
  332. this.queryParam.no = no
  333. // 从通知跳转过来时,清除部门筛选,确保能看到该工单
  334. this.queryParam.deptId = null
  335. }
  336. // 部门下拉数据
  337. queryDept({}).then(res => {
  338. this.deptList = res.data || []
  339. })
  340. // 我的工单:默认查询当前登录人部门的所有相关工单
  341. // if (this.searchType === 2) {
  342. // selectUserDept().then(res => {
  343. // if (res.data && res.data.deptId) {
  344. // this.queryParam.deptId = res.data.deptId
  345. // if (this.$refs.table) {
  346. // this.$refs.table.refresh()
  347. // }
  348. // }
  349. // })
  350. // }
  351. this.tableOption()
  352. },
  353. methods: {
  354. tableOption() {
  355. if (!this.optionAlertShow) {
  356. this.options = {
  357. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  358. rowSelection: {
  359. selectedRowKeys: this.selectedRowKeys,
  360. onChange: this.onSelectChange,
  361. getCheckboxProps: record => ({
  362. props: {
  363. disabled: false,
  364. name: record.id
  365. }
  366. })
  367. }
  368. }
  369. this.optionAlertShow = true
  370. } else {
  371. this.options = {
  372. alert: false,
  373. rowSelection: null
  374. }
  375. this.optionAlertShow = false
  376. }
  377. },
  378. batchDelete(id) {
  379. let ids = []
  380. if (this.BaseTool.String.isBlank(id)) {
  381. const length = this.selectedRows.length
  382. if (length === 0) {
  383. this.$message.info('请选择要删除的记录')
  384. return
  385. }
  386. ids = this.selectedRows.map(item => item.id)
  387. } else {
  388. ids = [id]
  389. }
  390. deleteRepairApplicationForms(ids).then(res => {
  391. this.$message.info('删除成功')
  392. this.handleOk()
  393. this.$refs.table.clearSelected()
  394. })
  395. },
  396. handleEdit(record) {
  397. fetchRepairApplicationForm({ id: record.id }).then(res => {
  398. const type = res.data.type
  399. const modal = type === 2 ? this.$refs.baseOutModal : this.$refs.baseModal
  400. modal.base(res.data)
  401. })
  402. },
  403. handleView(record) {
  404. fetchRepairApplicationForm({ id: record.id }).then(res => {
  405. this.visible = false
  406. // 收起可能残留的详情卡片,避免新旧详情(委外详情)同时显示
  407. if (this.$refs.detailModal) {
  408. this.$refs.detailModal.visible = false
  409. }
  410. if (this.$refs.detailOutModal) {
  411. this.$refs.detailOutModal.visible = false
  412. }
  413. const type = res.data.type
  414. const modal = type === 2 ? this.$refs.detailOutModal : this.$refs.detailModal
  415. modal.base(res.data)
  416. })
  417. },
  418. handleAssign(record) {
  419. const modal = this.$refs.assignForm
  420. modal.base(record)
  421. },
  422. handleOk() {
  423. this.visible = true
  424. this.queryParam.searchStartTime = this.queryParam.searchStartTime ? this.BaseTool.Date.formatter(this.queryParam.searchStartTime, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) + ' 00:00:01' : null
  425. this.queryParam.searchEndTime = this.queryParam.searchEndTime ? this.BaseTool.Date.formatter(this.queryParam.searchEndTime, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) + ' 23:59:59' : null
  426. this.$refs.table.refresh()
  427. },
  428. onSelectChange(selectedRowKeys, selectedRows) {
  429. this.selectedRowKeys = selectedRowKeys
  430. this.selectedRows = selectedRows
  431. },
  432. resetSearchForm() {
  433. // 重置时:如果是从通知跳转(带no参数),则不恢复部门筛选
  434. const no = this.$route.query.no
  435. this.queryParam = {
  436. deptId: no != null ? null : this.$store.getters.userInfo.deptId,
  437. searchStartTime: null,
  438. searchEndTime: null
  439. }
  440. if (no != null) {
  441. this.queryParam.no = no
  442. }
  443. this.$refs.table.refresh(true)
  444. },
  445. doExport() {
  446. const parameter = {
  447. ...this.queryParam,
  448. searchStartTime: this.queryParam.searchStartTime,
  449. searchEndTime: this.queryParam.searchEndTime
  450. }
  451. exportRepairApplicationForm(parameter).then(file => {
  452. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  453. })
  454. },
  455. handleDispatching(record) {
  456. const modal = this.$refs.dispatchBaseForm
  457. modal.base(record)
  458. }
  459. }
  460. }
  461. </script>