RepairApplicationFormTable.vue 11 KB

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