RepairReason.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <a-card :bordered="false">
  3. <div class="table-page-search-wrapper" @keyup.enter="handleEnter">
  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-repair-reasons-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>-->
  22. <!-- <a-button style="margin-left: 8px" v-if="$auth('repair-repair-reasons-export')" type="primary" icon="download" @click="doExport">导出</a-button>-->
  23. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('repair-repair-reasons-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. tableLayout="fixed"
  40. :data="loadData"
  41. :alert="options.alert"
  42. :rowSelection="options.rowSelection"
  43. showPagination="auto"
  44. >
  45. <span slot="action" slot-scope="record">
  46. <template>
  47. <a @click="handleView(record)">查看</a>
  48. <operation-button
  49. v-if="$auth('repair-repair-reasons-edit')"
  50. @click="handleEdit(record)"
  51. >修改</operation-button>
  52. <operation-button
  53. v-if="$auth('repair-repair-reasons-del')"
  54. :type="2"
  55. title="是否要删除该条数据?"
  56. @confirm="batchDelete(record.id)">删除</operation-button>
  57. </template>
  58. </span>
  59. </s-table>
  60. <base-form ref="baseModal" @ok="handleOk"/>
  61. <detail ref="detailModal"/>
  62. </a-card>
  63. </template>
  64. <script>
  65. import { STable, Ellipsis } from '@/components'
  66. import BaseForm from './modules/BaseForm'
  67. import Detail from './modules/Detail'
  68. import { getRepairReasonPage, deleteRepairReasons, fetchRepairReason, exportRepairReason } from '@/api/repair/repair-reason'
  69. export default {
  70. name: 'RepairReasonList',
  71. components: {
  72. STable,
  73. Ellipsis,
  74. BaseForm,
  75. Detail
  76. },
  77. data () {
  78. return {
  79. // 查询参数
  80. queryParam: {
  81. },
  82. // 表头
  83. columns: [
  84. {
  85. title: '序号',
  86. dataIndex: 'index',
  87. customRender: (text, record, index) => {
  88. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  89. }
  90. },
  91. {
  92. title: '编号',
  93. dataIndex: 'no'
  94. },
  95. {
  96. title: '分析时间',
  97. dataIndex: 'analyzeTime',
  98. width: '200px'
  99. },
  100. {
  101. title: '故障部位',
  102. dataIndex: 'sbPartName',
  103. ellipsis: true,
  104. width: '150px'
  105. },
  106. {
  107. title: '故障现象',
  108. dataIndex: 'problemDesc',
  109. ellipsis: true,
  110. width: '200px'
  111. },
  112. {
  113. title: '处理过程',
  114. dataIndex: 'checkProcess',
  115. ellipsis: true,
  116. width: '200px'
  117. },
  118. /* {
  119. title: '改进措施类别',
  120. dataIndex: 'type',
  121. ellipsis: true,
  122. width: '200px',
  123. customRender: (text, record, index) => {
  124. return this.BaseTool.Object.getField(this.typeMap, text)
  125. }
  126. },*/
  127. {
  128. title: '改进内容',
  129. dataIndex: 'changeRepairPlanContent',
  130. ellipsis: true,
  131. width: '200px'
  132. },
  133. {
  134. title: '操作',
  135. key: 'action',
  136. width: '200px',
  137. align: 'center',
  138. scopedSlots: { customRender: 'action' }
  139. }
  140. ],
  141. // 下拉框map
  142. // 加载数据方法 必须为 Promise 对象
  143. loadData: parameter => {
  144. parameter = {
  145. ...parameter,
  146. ...this.queryParam,
  147. dataScope: {
  148. sortBy: 'desc',
  149. sortName: 'update_time'
  150. }
  151. }
  152. return getRepairReasonPage(Object.assign(parameter, this.queryParam))
  153. .then(res => {
  154. return res.data
  155. })
  156. },
  157. selectedRowKeys: [],
  158. selectedRows: [],
  159. typeMap: {},
  160. statusMap: {},
  161. options: {
  162. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  163. rowSelection: {
  164. selectedRowKeys: this.selectedRowKeys,
  165. onChange: this.onSelectChange
  166. }
  167. },
  168. optionAlertShow: false
  169. }
  170. },
  171. created () {
  172. // 下拉框map
  173. this.tableOption()
  174. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_REASON_STATUS)
  175. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_REASON_TYPE)
  176. },
  177. methods: {
  178. tableOption () {
  179. if (!this.optionAlertShow) {
  180. this.options = {
  181. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  182. rowSelection: {
  183. selectedRowKeys: this.selectedRowKeys,
  184. onChange: this.onSelectChange,
  185. getCheckboxProps: record => ({
  186. props: {
  187. disabled: false,
  188. name: record.id
  189. }
  190. })
  191. }
  192. }
  193. this.optionAlertShow = true
  194. } else {
  195. this.options = {
  196. alert: false,
  197. rowSelection: null
  198. }
  199. this.optionAlertShow = false
  200. }
  201. },
  202. batchDelete (id) {
  203. let ids = []
  204. if (this.BaseTool.String.isBlank(id)) {
  205. const length = this.selectedRows.length
  206. if (length === 0) {
  207. this.$message.info('请选择要删除的记录')
  208. return
  209. }
  210. ids = this.selectedRows.map(item => item.id)
  211. } else {
  212. ids = [id]
  213. }
  214. deleteRepairReasons(ids).then(res => {
  215. this.$message.info('删除成功')
  216. this.handleOk()
  217. this.$refs.table.clearSelected()
  218. })
  219. },
  220. handleEdit (record) {
  221. fetchRepairReason({ id: record.id }).then(res => {
  222. const modal = this.$refs.baseModal
  223. modal.base(res.data)
  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. }
  248. exportRepairReason(parameter).then(file => {
  249. this.BaseTool.Util.downLoadExportExcel(file)
  250. })
  251. },
  252. handleEnter () {
  253. this.$refs.table.refresh(true)
  254. }
  255. }
  256. }
  257. </script>