RepairOut.vue 10 KB

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