RepairApplicationFormTable.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <template>
  2. <a-card :bordered="false">
  3. <div class="table-page-search-wrapper">
  4. <a-form layout="inline">
  5. <a-row :gutter="48">
  6. <a-col :md="8" :sm="24">
  7. <a-form-item label="关键字">
  8. <a-input v-model="queryParam.keyword" placeholder="请输入名称/类型名称"/>
  9. </a-form-item>
  10. </a-col>
  11. <a-col :md="8 || 24" :sm="24">
  12. <span class="table-page-search-submitButtons">
  13. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  14. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  15. </span>
  16. </a-col>
  17. </a-row>
  18. </a-form>
  19. </div>
  20. <div class="table-operator">
  21. <a-button v-if="$auth('repair-application-forms-add')" type="primary" icon="plus" @click="handleAdd()">新增</a-button>
  22. <a-button type="primary" style="margin-left: 8px" @click="doExport()">导出</a-button>
  23. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('repair-application-forms-del')">
  24. <a-menu slot="overlay">
  25. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  26. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  27. </a-popconfirm>
  28. </a-menu>
  29. <a-button style="margin-left: 8px">
  30. 批量操作 <a-icon type="down" />
  31. </a-button>
  32. </a-dropdown>
  33. </div>
  34. <s-table
  35. ref="table"
  36. size="default"
  37. rowKey="id"
  38. :columns="columns"
  39. :data="loadData"
  40. :alert="options.alert"
  41. :scroll="{x: 111, y: BaseTool.Constant.scrollY }"
  42. :rowSelection="options.rowSelection"
  43. showPagination="auto"
  44. >
  45. <span slot="action" slot-scope="record">
  46. <template>
  47. <!-- <a @click="handleView(record)">查看</a>-->
  48. <template v-if="[1,2].includes(type)">
  49. <operation-button
  50. @click="handleViewReason(record)">维修报告</operation-button>
  51. <operation-button
  52. :type="2"
  53. title="是否要删除该条数据?"
  54. @confirm="batchDelete(record.id)">删除</operation-button>
  55. </template>
  56. </template>
  57. </span>
  58. <span slot="status" slot-scope="text">
  59. <badge :text="BaseTool.Object.getField(statusMap,text)" :status="DictCache.COLOR.REPAIR_APPLICATION_FORM_STATUS[text]"/>
  60. </span>
  61. <span slot="level" slot-scope="text">
  62. <badge :text="BaseTool.Object.getField(levelMap,text)" :status="DictCache.COLOR.REPAIR_APPLICATION_FORM_LEVEL[text]"/>
  63. </span>
  64. </s-table>
  65. <imp-base-form ref="baseModal" @ok="handleOk"/>
  66. <detail ref="detailModal" @ok="handleOk"/>
  67. <detail-repair-reason ref="detailRepairReason" @ok="handleOk"/>
  68. </a-card>
  69. </template>
  70. <script>
  71. import { STable, Ellipsis } from '@/components'
  72. import ImpBaseForm from './ImpBaseForm'
  73. import Detail from './Detail'
  74. import { getRepairApplicationFormPage, deleteRepairApplicationForms, fetchRepairApplicationForm, exportRepairApplicationForm2 } from '@/api/repair/application-form'
  75. import DetailRepairReason from '@/views/repair/repair-reason/modules/DetailRepairReason'
  76. export default {
  77. name: 'RepairApplicationFormTable',
  78. components: {
  79. STable,
  80. Ellipsis,
  81. ImpBaseForm,
  82. DetailRepairReason,
  83. Detail
  84. },
  85. props: {
  86. type: {
  87. type: Number,
  88. default: 1
  89. },
  90. tableParams: {
  91. type: Object,
  92. default: () => ({})
  93. },
  94. modelParams: {
  95. type: Object,
  96. default: () => ({})
  97. }
  98. },
  99. watch: {
  100. tableParams: {
  101. // deep: true, // 深度监听
  102. handler (newVal, oldVal) {
  103. if (newVal.sbId !== oldVal.sbId) {
  104. this.handleOk()
  105. }
  106. }
  107. }
  108. },
  109. data () {
  110. return {
  111. // 查询参数
  112. queryParam: {
  113. searchType: 1
  114. },
  115. // 表头
  116. columns: [
  117. {
  118. title: '序号',
  119. dataIndex: 'index',
  120. checked: true,
  121. width: '100px',
  122. customRender: (text, record, index) => {
  123. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  124. }
  125. },
  126. /* {
  127. title: '设备名称',
  128. checked: true,
  129. dataIndex: 'sbId',
  130. customRender: (text, record, index) => {
  131. return record.sbName
  132. }
  133. }, */
  134. // {
  135. // title: '部件名称',
  136. // dataIndex: 'partId',
  137. // checked: true,
  138. // customRender: (text, record, index) => {
  139. // return record.partName
  140. // }
  141. // },
  142. {
  143. title: '报修人',
  144. width: '150px',
  145. checked: true,
  146. dataIndex: 'userName'
  147. },
  148. {
  149. title: '维修人',
  150. checked: true,
  151. width: '150px',
  152. dataIndex: 'repairUserName'
  153. },
  154. {
  155. title: '报修单号',
  156. checked: true,
  157. width: '200px',
  158. dataIndex: 'no'
  159. },
  160. {
  161. title: '报修来源',
  162. checked: true,
  163. width: '150px',
  164. dataIndex: 'source',
  165. customRender: (text, record, index) => {
  166. return this.BaseTool.Object.getField(this.sourceMap, text)
  167. }
  168. },
  169. /* {
  170. title: '紧急等级',
  171. checked: true,
  172. dataIndex: 'level',
  173. scopedSlots: { customRender: 'level' }
  174. }, */
  175. {
  176. title: '问题描述',
  177. checked: true,
  178. width: '150px',
  179. dataIndex: 'content',
  180. customRender: (text, record, index) => {
  181. return this.BaseTool.Table.customRenderWidth(this, text, '150px')
  182. }
  183. },
  184. {
  185. title: '报修状态',
  186. checked: true,
  187. width: '150px',
  188. dataIndex: 'status',
  189. scopedSlots: { customRender: 'status' }
  190. },
  191. {
  192. title: '报修时间',
  193. checked: true,
  194. width: '200px',
  195. dataIndex: 'applyTime'
  196. },
  197. {
  198. title: '维修完成时间',
  199. checked: true,
  200. width: '200px',
  201. dataIndex: 'repairEndTime'
  202. },
  203. // {
  204. // title: '备注',
  205. // checked: true,
  206. // dataIndex: 'remark',
  207. // customRender: (text, record, index) => {
  208. // return this.BaseTool.Table.customRenderWidth(this, text, '150px')
  209. // }
  210. // },
  211. {
  212. title: '操作',
  213. checked: true,
  214. key: 'action',
  215. width: '200px',
  216. fixed: 'right',
  217. align: 'center',
  218. scopedSlots: { customRender: 'action' }
  219. }
  220. ],
  221. // 下拉框map
  222. sourceMap: {},
  223. record: null,
  224. levelMap: {},
  225. statusMap: {},
  226. // 加载数据方法 必须为 Promise 对象
  227. loadData: parameter => {
  228. parameter = {
  229. ...parameter,
  230. ...this.tableParams,
  231. ...this.queryParam,
  232. dataScope: {
  233. sortBy: 'desc',
  234. sortName: 'update_time'
  235. }
  236. }
  237. return getRepairApplicationFormPage(Object.assign(parameter, this.queryParam))
  238. .then(res => {
  239. return res.data
  240. })
  241. },
  242. selectedRowKeys: [],
  243. selectedRows: [],
  244. options: {
  245. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  246. rowSelection: {
  247. selectedRowKeys: this.selectedRowKeys,
  248. onChange: this.onSelectChange
  249. }
  250. },
  251. optionAlertShow: false
  252. }
  253. },
  254. created () {
  255. // 下拉框map
  256. this.sourceMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
  257. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
  258. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
  259. this.tableOption()
  260. },
  261. methods: {
  262. tableOption () {
  263. if (!this.optionAlertShow) {
  264. this.options = {
  265. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  266. rowSelection: {
  267. selectedRowKeys: this.selectedRowKeys,
  268. onChange: this.onSelectChange,
  269. getCheckboxProps: record => ({
  270. props: {
  271. disabled: false,
  272. name: record.id
  273. }
  274. })
  275. }
  276. }
  277. this.optionAlertShow = true
  278. } else {
  279. this.options = {
  280. alert: false,
  281. rowSelection: null
  282. }
  283. this.optionAlertShow = false
  284. }
  285. },
  286. batchDelete (id) {
  287. let ids = []
  288. if (this.BaseTool.String.isBlank(id)) {
  289. const length = this.selectedRows.length
  290. if (length === 0) {
  291. this.$message.info('请选择要删除的记录')
  292. return
  293. }
  294. ids = this.selectedRows.map(item => item.id)
  295. } else {
  296. ids = [id]
  297. }
  298. deleteRepairApplicationForms(ids).then(res => {
  299. this.$message.info('删除成功')
  300. this.handleOk()
  301. this.$refs.table.clearSelected()
  302. })
  303. },
  304. handleAdd () {
  305. console.log('this.tableParams.name: ' + this.tableParams.sbName)
  306. const modal = this.$refs.baseModal
  307. modal.base({ sbId: this.tableParams.sbId, sbName: this.tableParams.sbName })
  308. },
  309. handleEdit () {
  310. fetchRepairApplicationForm({ sbId: this.sbId, sbName: this.sbName }).then(res => {
  311. const modal = this.$refs.baseModal
  312. modal.base(res.data)
  313. })
  314. },
  315. handleView (record) {
  316. fetchRepairApplicationForm({ id: record.id }).then(res => {
  317. const modal = this.$refs.detailModal
  318. modal.base(res.data)
  319. })
  320. },
  321. handleOk () {
  322. this.$refs.table.refresh()
  323. },
  324. base (record, queryParam = {}) {
  325. this.visible = true
  326. this.record = record
  327. if (this.isCreated) {
  328. this.$refs.table.clearSelected()
  329. this.handleOk()
  330. } else {
  331. this.tableOption()
  332. this.isCreated = true
  333. }
  334. },
  335. onSelectChange (selectedRowKeys, selectedRows) {
  336. this.selectedRowKeys = selectedRowKeys
  337. this.selectedRows = selectedRows
  338. },
  339. resetSearchForm () {
  340. this.queryParam = {
  341. searchType: 1
  342. }
  343. this.$refs.table.refresh(true)
  344. },
  345. doExport () {
  346. const parameter = {
  347. ...this.queryParam,
  348. ...this.tableParams
  349. }
  350. exportRepairApplicationForm2(parameter).then(file => {
  351. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  352. })
  353. },
  354. handleDispatching (record) {
  355. const modal = this.$refs.dispatchBaseForm
  356. modal.base(record)
  357. },
  358. handleViewReason (record) {
  359. this.visible = false
  360. const modal = this.$refs.detailRepairReason
  361. modal.base(record)
  362. }
  363. }
  364. }
  365. </script>