RepairReasonTable.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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 || 24" :sm="24">
  7. <span class="table-page-search-submitButtons">
  8. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  9. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  10. </span>
  11. </a-col>
  12. </a-row>
  13. </a-form>
  14. </div>
  15. <div class="table-operator">
  16. <!-- <a-button v-if="$auth('check-jobs-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>-->
  17. <a-button style="margin-left: 8px" v-if="($auth('check-spot-jobs-export') || $auth('check-polling-jobs-export'))" type="primary" icon="download" @click="doExport">导出</a-button>
  18. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && ($auth('check-spot-jobs-finish') || $auth('check-polling-jobs-finish'))">
  19. <a-menu slot="overlay">
  20. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  21. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  22. </a-popconfirm>
  23. </a-menu>
  24. <a-button style="margin-left: 8px">
  25. 批量操作 <a-icon type="down" />
  26. </a-button>
  27. </a-dropdown>
  28. </div>
  29. <s-table
  30. ref="table"
  31. size="default"
  32. rowKey="id"
  33. :columns="columns"
  34. :data="loadData"
  35. :alert="options.alert"
  36. :rowSelection="options.rowSelection"
  37. showPagination="auto"
  38. >
  39. <span slot="action" slot-scope="record">
  40. <template>
  41. <a @click="handleView(record)">查看</a>
  42. </template>
  43. </span>
  44. </s-table>
  45. <base-form ref="baseModal" @ok="handleOk"/>
  46. <detail ref="detailModal" @ok="handleOk"/>
  47. </a-card>
  48. </template>
  49. <script>
  50. import { STable, Ellipsis } from '@/components'
  51. import BaseForm from './BaseForm'
  52. import Detail from './Detail'
  53. import { deleteRepairReasons, getRepairReasonPage, fetchRepairReason, exportRepairReason } from '@/api/repair/repair-reason'
  54. export default {
  55. name: 'RepairReasonTable',
  56. components: {
  57. STable,
  58. Ellipsis,
  59. BaseForm,
  60. Detail
  61. },
  62. props: {
  63. /**
  64. * 检查类型: 1-负责 2-巡检
  65. */
  66. checkType: {
  67. type: Number,
  68. default: 1
  69. },
  70. type: {
  71. type: Number,
  72. default: 1
  73. },
  74. status: {
  75. type: Number,
  76. default: null
  77. },
  78. tableParams: {
  79. type: Object,
  80. default: () => ({})
  81. },
  82. modelParams: {
  83. type: Object,
  84. default: () => ({})
  85. }
  86. },
  87. watch: {
  88. tableParams: {
  89. // deep: true, // 深度监听
  90. handler (newVal, oldVal) {
  91. if (newVal.sbId !== oldVal.sbId) {
  92. this.handleOk()
  93. }
  94. }
  95. }
  96. },
  97. data () {
  98. return {
  99. // 查询参数
  100. queryParam: {
  101. },
  102. // 表头
  103. columns: [
  104. {
  105. title: '序号',
  106. dataIndex: 'index',
  107. width: '70px',
  108. customRender: (text, record, index) => {
  109. return `${index + 1}`
  110. }
  111. },
  112. {
  113. title: '分析时间',
  114. dataIndex: 'analyzeTime',
  115. width: '200px'
  116. },
  117. {
  118. title: '故障部位',
  119. dataIndex: 'sbPartName',
  120. ellipsis: true,
  121. width: '150px'
  122. },
  123. {
  124. title: '故障现象',
  125. dataIndex: 'problemDesc',
  126. ellipsis: true,
  127. width: '200px'
  128. },
  129. {
  130. title: '检查处理过程',
  131. dataIndex: 'checkProcess',
  132. ellipsis: true,
  133. width: '200px'
  134. },
  135. {
  136. title: '原因分析',
  137. dataIndex: 'reasonAnalysis',
  138. ellipsis: true,
  139. width: '200px'
  140. },
  141. {
  142. title: '操作',
  143. key: 'action',
  144. width: '200px',
  145. align: 'center',
  146. scopedSlots: { customRender: 'action' }
  147. }
  148. ],
  149. // 加载数据方法 必须为 Promise 对象
  150. loadData: parameter => {
  151. parameter = {
  152. ...parameter,
  153. ...this.queryParam,
  154. ...this.tableParams,
  155. dataScope: {
  156. sortBy: 'desc',
  157. sortName: 'update_time'
  158. }
  159. }
  160. return getRepairReasonPage(Object.assign(parameter, this.queryParam))
  161. .then(res => {
  162. return res.data
  163. })
  164. },
  165. selectedRowKeys: [],
  166. selectedRows: [],
  167. options: {
  168. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  169. rowSelection: {
  170. selectedRowKeys: this.selectedRowKeys,
  171. onChange: this.onSelectChange
  172. }
  173. },
  174. optionAlertShow: false
  175. }
  176. },
  177. created () {
  178. // 下拉框map
  179. this.tableOption()
  180. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_REASON_STATUS)
  181. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_REASON_TYPE)
  182. },
  183. methods: {
  184. tableOption () {
  185. if (!this.optionAlertShow) {
  186. this.options = {
  187. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  188. rowSelection: {
  189. selectedRowKeys: this.selectedRowKeys,
  190. onChange: this.onSelectChange,
  191. getCheckboxProps: record => ({
  192. props: {
  193. disabled: false,
  194. name: record.id
  195. }
  196. })
  197. }
  198. }
  199. this.optionAlertShow = true
  200. } else {
  201. this.options = {
  202. alert: false,
  203. rowSelection: null
  204. }
  205. this.optionAlertShow = false
  206. }
  207. },
  208. batchDelete (id) {
  209. let ids = []
  210. if (this.BaseTool.String.isBlank(id)) {
  211. const length = this.selectedRows.length
  212. if (length === 0) {
  213. this.$message.info('请选择要删除的记录')
  214. return
  215. }
  216. ids = this.selectedRows.map(item => item.id)
  217. } else {
  218. ids = [id]
  219. }
  220. deleteRepairReasons(ids).then(res => {
  221. this.$message.info('删除成功')
  222. this.handleOk()
  223. this.$refs.table.clearSelected()
  224. })
  225. },
  226. handleView (record) {
  227. fetchRepairReason({ id: record.id }).then(res => {
  228. const modal = this.$refs.detailModal
  229. modal.base(res.data)
  230. })
  231. },
  232. handleOk () {
  233. this.$refs.table.refresh()
  234. },
  235. onSelectChange (selectedRowKeys, selectedRows) {
  236. this.selectedRowKeys = selectedRowKeys
  237. this.selectedRows = selectedRows
  238. },
  239. resetSearchForm () {
  240. this.queryParam = {
  241. }
  242. this.$refs.table.refresh(true)
  243. },
  244. doExport () {
  245. const parameter = {
  246. ...this.queryParam,
  247. ...this.tableParams
  248. }
  249. exportRepairReason(parameter).then(file => {
  250. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  251. })
  252. }
  253. }
  254. }
  255. </script>