RepairOut.vue 9.8 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-add')" type="primary" icon="plus" @click="$refs.baseOutModal.base()">新增</a-button>
  24. <a-button style="margin-left: 8px" v-if="$auth('repair-application-forms-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  25. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('repair-application-forms-del')">
  26. <a-menu slot="overlay">
  27. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  28. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  29. </a-popconfirm>
  30. </a-menu>
  31. <a-button style="margin-left: 8px">
  32. 批量操作 <a-icon type="down" />
  33. </a-button>
  34. </a-dropdown>
  35. </div>
  36. <s-table
  37. ref="table"
  38. size="default"
  39. rowKey="id"
  40. :columns="columns"
  41. :data="loadData"
  42. :alert="options.alert"
  43. :rowSelection="options.rowSelection"
  44. showPagination="auto"
  45. >
  46. <span slot="action" slot-scope="record">
  47. <template>
  48. <a @click="handleView(record)">查看</a>
  49. <operation-button
  50. v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status && $auth('repair-application-forms-edit')"
  51. @click="handleEdit(record)" >修改</operation-button>
  52. <operation-button
  53. v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status && $auth('repair-application-forms-del')"
  54. :type="2"
  55. title="是否要删除该条数据?"
  56. @confirm="batchDelete(record.id)">删除</operation-button>
  57. <!--<operation-button
  58. v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status && $auth('repair-application-forms-dispatch')"
  59. @click="handleDispatching(record)" >派工</operation-button>-->
  60. </template>
  61. </span>
  62. <span slot="status" slot-scope="text">
  63. <badge :text="BaseTool.Object.getField(statusMap,text)" :status="DictCache.COLOR.REPAIR_APPLICATION_FORM_STATUS[text]"/>
  64. </span>
  65. <span slot="level" slot-scope="text">
  66. <badge :text="BaseTool.Object.getField(levelMap,text)" :status="DictCache.COLOR.REPAIR_APPLICATION_FORM_LEVEL[text]"/>
  67. </span>
  68. </s-table>
  69. </div>
  70. <base-form ref="baseModal" @ok="handleOk"/>
  71. <detail-out ref="detailOutModal" @ok="handleOk"/>
  72. </a-card>
  73. </template>
  74. <script>
  75. import { STable, Ellipsis } from '@/components'
  76. import BaseForm from './modules/BaseOutForm'
  77. import DetailOut from './modules/DetailRepairOut'
  78. import { getRepairApplicationFormPage, deleteRepairApplicationForms, fetchRepairApplicationForm, exportRepairApplicationForm } from '@/api/repair/application-form'
  79. export default {
  80. name: 'RepairOut',
  81. components: {
  82. STable,
  83. Ellipsis,
  84. BaseForm,
  85. DetailOut
  86. },
  87. data () {
  88. return {
  89. // 查询参数
  90. queryParam: {
  91. filter: 0,
  92. searchType: 2
  93. },
  94. visible: true,
  95. // 表头
  96. columns: [
  97. {
  98. title: '序号',
  99. dataIndex: 'index',
  100. checked: true,
  101. customRender: (text, record, index) => {
  102. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  103. }
  104. },
  105. {
  106. title: '委外单号',
  107. checked: true,
  108. dataIndex: 'outNo'
  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: 'actualUser'
  122. // },
  123. {
  124. title: '维修人',
  125. checked: true,
  126. dataIndex: 'repairUserName'
  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: 2,
  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.detailOutModal
  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>