MyRepairForm.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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: 'sbId',
  114. customRender: (text, record, index) => {
  115. return record.sbName
  116. }
  117. },
  118. {
  119. title: '报修人',
  120. checked: true,
  121. dataIndex: 'userName'
  122. },
  123. {
  124. title: '报修来源',
  125. checked: true,
  126. dataIndex: 'source',
  127. customRender: (text, record, index) => {
  128. return this.BaseTool.Object.getField(this.sourceMap, text)
  129. }
  130. },
  131. {
  132. title: '报修时间',
  133. checked: true,
  134. dataIndex: 'applyTime'
  135. },
  136. {
  137. title: '紧急等级',
  138. checked: true,
  139. dataIndex: 'level',
  140. customRender: (text, record, index) => {
  141. return this.BaseTool.Object.getField(this.levelMap, text)
  142. }
  143. },
  144. {
  145. title: '是否停机',
  146. checked: true,
  147. dataIndex: 'needStop',
  148. customRender: (text, record, index) => {
  149. return this.BaseTool.Object.getField(this.needStopMap, text)
  150. }
  151. },
  152. {
  153. title: '报修状态',
  154. checked: true,
  155. dataIndex: 'status',
  156. scopedSlots: { customRender: 'status' }
  157. },
  158. {
  159. title: '创建日期',
  160. dataIndex: 'createdTime'
  161. },
  162. {
  163. title: '操作',
  164. checked: true,
  165. key: 'action',
  166. width: '200px',
  167. align: 'center',
  168. scopedSlots: { customRender: 'action' }
  169. }
  170. ],
  171. // 下拉框map
  172. sourceMap: {},
  173. levelMap: {},
  174. statusMap: {},
  175. needStopMap: {},
  176. // 加载数据方法 必须为 Promise 对象
  177. loadData: parameter => {
  178. parameter = {
  179. ...parameter,
  180. ...this.queryParam,
  181. type: 1,
  182. dataScope: {
  183. sortBy: 'desc',
  184. sortName: 'update_time'
  185. }
  186. }
  187. return getRepairApplicationFormPage(Object.assign(parameter, this.queryParam))
  188. .then(res => {
  189. return res.data
  190. })
  191. },
  192. selectedRowKeys: [],
  193. selectedRows: [],
  194. options: {
  195. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  196. rowSelection: {
  197. selectedRowKeys: this.selectedRowKeys,
  198. onChange: this.onSelectChange
  199. }
  200. },
  201. optionAlertShow: false
  202. }
  203. },
  204. created () {
  205. // 下拉框map
  206. this.sourceMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
  207. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
  208. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
  209. this.needStopMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  210. this.tableOption()
  211. },
  212. methods: {
  213. tableOption () {
  214. if (!this.optionAlertShow) {
  215. this.options = {
  216. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  217. rowSelection: {
  218. selectedRowKeys: this.selectedRowKeys,
  219. onChange: this.onSelectChange,
  220. getCheckboxProps: record => ({
  221. props: {
  222. disabled: false,
  223. name: record.id
  224. }
  225. })
  226. }
  227. }
  228. this.optionAlertShow = true
  229. } else {
  230. this.options = {
  231. alert: false,
  232. rowSelection: null
  233. }
  234. this.optionAlertShow = false
  235. }
  236. },
  237. batchDelete (id) {
  238. let ids = []
  239. if (this.BaseTool.String.isBlank(id)) {
  240. const length = this.selectedRows.length
  241. if (length === 0) {
  242. this.$message.info('请选择要删除的记录')
  243. return
  244. }
  245. ids = this.selectedRows.map(item => item.id)
  246. } else {
  247. ids = [id]
  248. }
  249. deleteRepairApplicationForms(ids).then(res => {
  250. this.$message.info('删除成功')
  251. this.handleOk()
  252. this.$refs.table.clearSelected()
  253. })
  254. },
  255. handleEdit (record) {
  256. fetchRepairApplicationForm({ id: record.id }).then(res => {
  257. const modal = this.$refs.baseModal
  258. modal.base(res.data)
  259. })
  260. },
  261. handleView (record) {
  262. fetchRepairApplicationForm({ id: record.id }).then(res => {
  263. this.visible = false
  264. const modal = this.$refs.detailModal
  265. modal.base(res.data)
  266. })
  267. },
  268. handleOk () {
  269. this.visible = true
  270. this.$refs.table.refresh()
  271. },
  272. onSelectChange (selectedRowKeys, selectedRows) {
  273. this.selectedRowKeys = selectedRowKeys
  274. this.selectedRows = selectedRows
  275. },
  276. resetSearchForm () {
  277. this.queryParam = {
  278. }
  279. this.$refs.table.refresh(true)
  280. },
  281. doExport () {
  282. const parameter = {
  283. ...this.queryParam
  284. }
  285. exportRepairApplicationForm(parameter).then(file => {
  286. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  287. })
  288. },
  289. handleDispatching (record) {
  290. const modal = this.$refs.dispatchBaseForm
  291. modal.base(record)
  292. }
  293. }
  294. }
  295. </script>