RepairForm.vue 11 KB

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