MyRepairForm.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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="8" :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="8 || 24" :sm="24">
  13. <span class="table-page-search-submitButtons">
  14. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  15. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  16. </span>
  17. </a-col>
  18. </a-row>
  19. </a-form>
  20. </div>
  21. <div class="table-operator">
  22. <!-- <a-button v-if="$auth('repair-application-forms-add')" type="primary" icon="plus" @click="$refs.baseModal.base({},{filter: -1})">新增</a-button>-->
  23. <a-button style="margin-left: 8px" v-if="$auth('repair-application-forms-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  24. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('repair-application-forms-del')">
  25. <a-menu slot="overlay">
  26. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  27. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  28. </a-popconfirm>
  29. </a-menu>
  30. <a-button style="margin-left: 8px">
  31. 批量操作 <a-icon type="down" />
  32. </a-button>
  33. </a-dropdown>
  34. </div>
  35. <s-table
  36. ref="table"
  37. size="default"
  38. rowKey="id"
  39. :columns="columns"
  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="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status && $auth('repair-application-forms-edit')"
  50. @click="handleEdit(record)" >修改</operation-button>
  51. <operation-button
  52. v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status && $auth('repair-application-forms-del')"
  53. :type="2"
  54. title="是否要删除该条数据?"
  55. @confirm="batchDelete(record.id)">删除</operation-button>
  56. <!--<operation-button
  57. v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status && $auth('repair-application-forms-dispatch')"
  58. @click="handleDispatching(record)" >派工</operation-button>-->
  59. </template>
  60. </span>
  61. <span slot="status" slot-scope="text">
  62. <badge :text="BaseTool.Object.getField(statusMap,text)" :status="DictCache.COLOR.REPAIR_APPLICATION_FORM_STATUS[text]"/>
  63. </span>
  64. <span slot="level" slot-scope="text">
  65. <badge :text="BaseTool.Object.getField(levelMap,text)" :status="DictCache.COLOR.REPAIR_APPLICATION_FORM_LEVEL[text]"/>
  66. </span>
  67. </s-table>
  68. </div>
  69. <base-form ref="baseModal" @ok="handleOk"/>
  70. <detail ref="detailModal" @ok="handleOk"/>
  71. <detail-out ref="detailOutModal" @ok="handleOk"/>
  72. <dispatch-base-form ref="dispatchBaseForm" @ok="handleOk" />
  73. </a-card>
  74. </template>
  75. <script>
  76. import { STable, Ellipsis } from '@/components'
  77. import BaseForm from './modules/BaseForm'
  78. import Detail from './modules/DetailRepair'
  79. import DetailOut from './modules/DetailRepairOut'
  80. import { getRepairApplicationFormPage, deleteRepairApplicationForms, fetchRepairApplicationForm, exportRepairApplicationForm } from '@/api/repair/application-form'
  81. import DispatchBaseForm from '@/views/repair/application-form/modules/DispatchBaseForm'
  82. export default {
  83. name: 'MyRepairApplicationFormList',
  84. components: {
  85. STable,
  86. Ellipsis,
  87. BaseForm,
  88. Detail,
  89. DetailOut,
  90. DispatchBaseForm
  91. },
  92. data () {
  93. return {
  94. // 查询参数
  95. queryParam: {
  96. filter: 0,
  97. searchType: 2
  98. },
  99. visible: true,
  100. // 表头
  101. columns: [
  102. {
  103. title: '序号',
  104. dataIndex: 'index',
  105. checked: true,
  106. customRender: (text, record, index) => {
  107. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  108. }
  109. },
  110. {
  111. title: '设备编号',
  112. checked: true,
  113. dataIndex: 'sbNo'
  114. },
  115. {
  116. title: '设备名称',
  117. checked: true,
  118. dataIndex: 'sbId',
  119. customRender: (text, record, index) => {
  120. return record.sbName
  121. }
  122. },
  123. {
  124. title: '报修人',
  125. checked: true,
  126. dataIndex: 'userName'
  127. },
  128. {
  129. title: '报修来源',
  130. checked: true,
  131. dataIndex: 'source',
  132. customRender: (text, record, index) => {
  133. return this.BaseTool.Object.getField(this.sourceMap, text)
  134. }
  135. },
  136. {
  137. title: '报修时间',
  138. checked: true,
  139. dataIndex: 'applyTime'
  140. },
  141. {
  142. title: '紧急等级',
  143. checked: true,
  144. dataIndex: 'level',
  145. customRender: (text, record, index) => {
  146. return this.BaseTool.Object.getField(this.levelMap, text)
  147. }
  148. },
  149. {
  150. title: '是否停机',
  151. checked: true,
  152. dataIndex: 'needStop',
  153. customRender: (text, record, index) => {
  154. return this.BaseTool.Object.getField(this.needStopMap, text)
  155. }
  156. },
  157. {
  158. title: '报修状态',
  159. checked: true,
  160. dataIndex: 'status',
  161. scopedSlots: { customRender: 'status' }
  162. },
  163. {
  164. title: '创建日期',
  165. dataIndex: 'createdTime'
  166. },
  167. {
  168. title: '操作',
  169. checked: true,
  170. key: 'action',
  171. width: '200px',
  172. align: 'center',
  173. scopedSlots: { customRender: 'action' }
  174. }
  175. ],
  176. // 下拉框map
  177. sourceMap: {},
  178. levelMap: {},
  179. statusMap: {},
  180. needStopMap: {},
  181. // 加载数据方法 必须为 Promise 对象
  182. loadData: parameter => {
  183. parameter = {
  184. ...parameter,
  185. ...this.queryParam,
  186. type: 1,
  187. dataScope: {
  188. sortBy: 'desc',
  189. sortName: 'update_time'
  190. }
  191. }
  192. return getRepairApplicationFormPage(Object.assign(parameter, this.queryParam))
  193. .then(res => {
  194. return res.data
  195. })
  196. },
  197. selectedRowKeys: [],
  198. selectedRows: [],
  199. options: {
  200. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  201. rowSelection: {
  202. selectedRowKeys: this.selectedRowKeys,
  203. onChange: this.onSelectChange
  204. }
  205. },
  206. optionAlertShow: false
  207. }
  208. },
  209. created () {
  210. // 下拉框map
  211. this.sourceMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
  212. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
  213. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
  214. this.needStopMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  215. this.tableOption()
  216. },
  217. methods: {
  218. tableOption () {
  219. if (!this.optionAlertShow) {
  220. this.options = {
  221. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  222. rowSelection: {
  223. selectedRowKeys: this.selectedRowKeys,
  224. onChange: this.onSelectChange,
  225. getCheckboxProps: record => ({
  226. props: {
  227. disabled: false,
  228. name: record.id
  229. }
  230. })
  231. }
  232. }
  233. this.optionAlertShow = true
  234. } else {
  235. this.options = {
  236. alert: false,
  237. rowSelection: null
  238. }
  239. this.optionAlertShow = false
  240. }
  241. },
  242. batchDelete (id) {
  243. let ids = []
  244. if (this.BaseTool.String.isBlank(id)) {
  245. const length = this.selectedRows.length
  246. if (length === 0) {
  247. this.$message.info('请选择要删除的记录')
  248. return
  249. }
  250. ids = this.selectedRows.map(item => item.id)
  251. } else {
  252. ids = [id]
  253. }
  254. deleteRepairApplicationForms(ids).then(res => {
  255. this.$message.info('删除成功')
  256. this.handleOk()
  257. this.$refs.table.clearSelected()
  258. })
  259. },
  260. handleEdit (record) {
  261. fetchRepairApplicationForm({ id: record.id }).then(res => {
  262. const modal = this.$refs.baseModal
  263. modal.base(res.data)
  264. })
  265. },
  266. handleView (record) {
  267. fetchRepairApplicationForm({ id: record.id }).then(res => {
  268. this.visible = false
  269. const modal = this.$refs.detailModal
  270. modal.base(res.data)
  271. })
  272. },
  273. handleOk () {
  274. this.visible = true
  275. this.$refs.table.refresh()
  276. },
  277. onSelectChange (selectedRowKeys, selectedRows) {
  278. this.selectedRowKeys = selectedRowKeys
  279. this.selectedRows = selectedRows
  280. },
  281. resetSearchForm () {
  282. this.queryParam = {
  283. }
  284. this.$refs.table.refresh(true)
  285. },
  286. doExport () {
  287. const parameter = {
  288. ...this.queryParam
  289. }
  290. exportRepairApplicationForm(parameter).then(file => {
  291. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  292. })
  293. },
  294. handleDispatching (record) {
  295. const modal = this.$refs.dispatchBaseForm
  296. modal.base(record)
  297. }
  298. }
  299. }
  300. </script>