MyRepairForm.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template>
  2. <a-card :bordered="false">
  3. <div class="table-page-search-wrapper">
  4. <a-form layout="inline">
  5. <a-row :gutter="48">
  6. <a-col :md="8" :sm="24">
  7. <a-form-item label="关键字">
  8. <a-input v-model.trim="queryParam.keyword" placeholder="请输入名称/类型名称"/>
  9. </a-form-item>
  10. </a-col>
  11. <a-col :md="8 || 24" :sm="24">
  12. <span class="table-page-search-submitButtons">
  13. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  14. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  15. </span>
  16. </a-col>
  17. </a-row>
  18. </a-form>
  19. </div>
  20. <div class="table-operator" style="margin-bottom: 8px;">
  21. <a-button v-if="$auth('repair-forms-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>
  22. <a-button style="margin-left: 8px" v-if="$auth('repair-forms-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  23. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('repair-forms-del')">
  24. <a-menu slot="overlay">
  25. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  26. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  27. </a-popconfirm>
  28. </a-menu>
  29. <a-button style="margin-left: 8px">
  30. 批量操作 <a-icon type="down" />
  31. </a-button>
  32. </a-dropdown>
  33. </div>
  34. <s-table
  35. ref="table"
  36. size="default"
  37. rowKey="id"
  38. :widthSpace="true"
  39. :columns="columns"
  40. :data="loadData"
  41. :alert="options.alert"
  42. :rowSelection="options.rowSelection"
  43. :scroll="{y: BaseTool.Constant.scrollY }"
  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_FORM_STATUS.NOT_DEAL === record.status && $auth('repair-forms-deal')"
  51. :type="2"
  52. title="确认接收该维修任务?"
  53. @confirm="handleDealEdit(record)" >接收</operation-button>
  54. <operation-button
  55. v-if="[DictCache.VALUE.REPAIR_FORM_STATUS.YES_DEAL,DictCache.VALUE.REPAIR_FORM_STATUS.RETURN].includes(record.status)
  56. && $auth('repair-forms-edit')"
  57. @click="handleEdit(record)" >维修</operation-button>
  58. <operation-button v-if="record.status< DictCache.VALUE.REPAIR_FORM_STATUS.YES_DEAL" @click="handleDispatching(record)" >转派</operation-button>
  59. <!-- <operation-button
  60. v-if="$auth('repair-forms-add-fee')"
  61. @click="handleAddFee(record)" >维修费用</operation-button>
  62. <operation-button
  63. v-if="$auth('repair-fees-part-used')"
  64. @click="handleAddPartUsed(record)" >更换备件</operation-button>
  65. -->
  66. <!--<operation-button
  67. v-if="[DictCache.VALUE.REPAIR_FORM_STATUS.NOT_DEAL, DictCache.VALUE.REPAIR_FORM_STATUS.RETURN].includes(record.status)"
  68. :type="2"
  69. title="确定完成吗?"
  70. @confirm="handleFinished(record.id)">完成</operation-button>-->
  71. </template>
  72. </span>
  73. </s-table>
  74. <base-form ref="baseModal" @ok="handleOk"/>
  75. <detail ref="detailModal"/>
  76. <repair-fee-base-form ref="repairFeeModal" @ok="handleOk"/>
  77. <repair-fee-list ref="repairFeeList" />
  78. <spare-part-used-select-modal ref="sparePartUsedSelectModal" />
  79. <repair-part-used-modal ref="repairPartUsedModal" />
  80. <dispatch-base-form ref="dispatchBaseForm" @ok="handleOk" />
  81. </a-card>
  82. </template>
  83. <script>
  84. import { STable, Ellipsis } from '@/components'
  85. import BaseForm from './modules/BaseForm'
  86. import Detail from '../application-form/modules/Detail'
  87. import RepairFeeList from '@/views/repair/fee/modules/RepairFeeList'
  88. import RepairPartUsedModal from '@/views/repair/part-used/modules/RepairPartUsedModal'
  89. import { getRepairFormPage, deleteRepairForms, fetchRepairForm, exportRepairForm, repairFormDeal, finish } from '@/api/repair/form'
  90. import RepairFeeBaseForm from '@/views/repair/fee/modules/BaseForm'
  91. import SparePartUsedSelectModal from '@/views/sqarepartmanage/sparepartused/modules/SparePartUsedSelectModal'
  92. import DispatchBaseForm from '@/views/repair/form/modules/DispatchBaseForm'
  93. import { getRepairApplicationFormPage, deleteRepairApplicationForms, fetchRepairApplicationForm, exportRepairApplicationForm } from '@/api/repair/application-form'
  94. export default {
  95. name: 'RepairFormList',
  96. components: {
  97. STable,
  98. Ellipsis,
  99. BaseForm,
  100. Detail,
  101. RepairFeeList,
  102. RepairPartUsedModal,
  103. RepairFeeBaseForm,
  104. SparePartUsedSelectModal,
  105. DispatchBaseForm
  106. },
  107. data () {
  108. return {
  109. // 查询参数
  110. queryParam: {
  111. filter: 0
  112. },
  113. // 表头
  114. columns: [
  115. {
  116. title: '序号',
  117. dataIndex: 'index',
  118. width: 80,
  119. checked: true,
  120. customRender: (text, record, index) => {
  121. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  122. }
  123. },
  124. // {
  125. // title: '报修单号',
  126. // width: 150,
  127. // checked: true,
  128. // dataIndex: 'applicationNo'
  129. // },
  130. // {
  131. // title: '维修单号',
  132. // checked: true,
  133. // dataIndex: 'no',
  134. // width: 150
  135. // },
  136. {
  137. title: '设备名称',
  138. checked: true,
  139. width: 150,
  140. dataIndex: 'sbName'
  141. },
  142. // {
  143. // title: '部位名称',
  144. // dataIndex: 'partName',
  145. // checked: true
  146. // },
  147. // {
  148. // title: '报修人',
  149. // width: 100,
  150. // checked: true,
  151. // dataIndex: 'repairUserName'
  152. // },
  153. {
  154. title: '报修来源',
  155. checked: true,
  156. dataIndex: 'applicationSource',
  157. width: 100,
  158. customRender: (text, record, index) => {
  159. return this.BaseTool.Object.getField(this.sourceMap, text)
  160. }
  161. },
  162. {
  163. title: '报修时间',
  164. width: 150,
  165. checked: true,
  166. dataIndex: 'applicationApplyTime'
  167. },
  168. {
  169. title: '紧急等级',
  170. checked: true,
  171. width: 100,
  172. dataIndex: 'applicationLevel',
  173. customRender: (text, record, index) => {
  174. return this.BaseTool.Table.statusCustomRenderDict(this, text, record,
  175. this.DictCache.COLOR.REPAIR_APPLICATION_FORM_LEVEL, this.levelMap)
  176. }
  177. },
  178. {
  179. title: '维修状态',
  180. checked: true,
  181. width: 100,
  182. dataIndex: 'status',
  183. customRender: (text, record, index) => {
  184. return this.BaseTool.Table.statusCustomRenderDict(this, text, record,
  185. this.DictCache.COLOR.REPAIR_FORM_STATUS, this.statusMap)
  186. }
  187. },
  188. {
  189. title: '操作',
  190. key: 'action',
  191. checked: true,
  192. width: '250px',
  193. align: 'center',
  194. scopedSlots: { customRender: 'action' }
  195. }
  196. ],
  197. // 下拉框map
  198. needStopMap: {},
  199. statusMap: {},
  200. sourceMap: {},
  201. levelMap: {},
  202. // 加载数据方法 必须为 Promise 对象
  203. loadData: parameter => {
  204. parameter = {
  205. ...parameter,
  206. ...this.queryParam,
  207. dataScope: {
  208. sortBy: 'desc',
  209. sortName: 'update_time'
  210. }
  211. }
  212. return getRepairFormPage(Object.assign(parameter, this.queryParam))
  213. .then(res => {
  214. return res.data
  215. })
  216. },
  217. selectedRowKeys: [],
  218. selectedRows: [],
  219. options: {
  220. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  221. rowSelection: {
  222. selectedRowKeys: this.selectedRowKeys,
  223. onChange: this.onSelectChange
  224. }
  225. },
  226. optionAlertShow: false
  227. }
  228. },
  229. created () {
  230. // 下拉框map
  231. this.needStopMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  232. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_FORM_STATUS)
  233. this.sourceMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
  234. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
  235. this.tableOption()
  236. },
  237. methods: {
  238. tableOption () {
  239. if (!this.optionAlertShow) {
  240. this.options = {
  241. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  242. rowSelection: {
  243. selectedRowKeys: this.selectedRowKeys,
  244. onChange: this.onSelectChange,
  245. getCheckboxProps: record => ({
  246. props: {
  247. disabled: false,
  248. name: record.id
  249. }
  250. })
  251. }
  252. }
  253. this.optionAlertShow = true
  254. } else {
  255. this.options = {
  256. alert: false,
  257. rowSelection: null
  258. }
  259. this.optionAlertShow = false
  260. }
  261. },
  262. batchDelete (id) {
  263. let ids = []
  264. if (this.BaseTool.String.isBlank(id)) {
  265. const length = this.selectedRows.length
  266. if (length === 0) {
  267. this.$message.info('请选择要删除的记录')
  268. return
  269. }
  270. ids = this.selectedRows.map(item => item.id)
  271. } else {
  272. ids = [id]
  273. }
  274. deleteRepairForms(ids).then(res => {
  275. this.$message.info('删除成功')
  276. this.handleOk()
  277. this.$refs.table.clearSelected()
  278. })
  279. },
  280. handleEdit (record) {
  281. fetchRepairForm({ id: record.id }).then(res => {
  282. const modal = this.$refs.baseModal
  283. modal.base(res.data)
  284. })
  285. },
  286. handleView (record) {
  287. fetchRepairApplicationForm({ id: record.applicationId }).then(res => {
  288. const modal = this.$refs.detailModal
  289. modal.base(res.data)
  290. })
  291. },
  292. handleDispatching (record) {
  293. const modal = this.$refs.dispatchBaseForm
  294. modal.base(record)
  295. },
  296. handleOk () {
  297. this.$refs.table.refresh()
  298. },
  299. onSelectChange (selectedRowKeys, selectedRows) {
  300. this.selectedRowKeys = selectedRowKeys
  301. this.selectedRows = selectedRows
  302. },
  303. resetSearchForm () {
  304. this.queryParam = {
  305. }
  306. this.$refs.table.refresh(true)
  307. },
  308. doExport () {
  309. const parameter = {
  310. ...this.queryParam
  311. }
  312. exportRepairForm(parameter).then(file => {
  313. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  314. })
  315. },
  316. handleAddFee (record) {
  317. /* const modal = this.$refs.repairFeeModal
  318. modal.base(null, record) */
  319. this.$refs.repairFeeList.base(record, { repairId: record.id })
  320. },
  321. handleAddPartUsed (record) {
  322. /* const modal = this.$refs.repairFeeModal
  323. modal.base(null, record) */
  324. this.$refs.sparePartUsedSelectModal.base(record, { sbId: record.sbId, modelId: record.modelId })
  325. },
  326. handleFinished (record) {
  327. finish(record).then(() => {
  328. this.$message.info('操作成功')
  329. this.handleOk()
  330. })
  331. },
  332. handleDealEdit (record) {
  333. repairFormDeal(record).then(() => {
  334. this.$message.info('操作成功')
  335. this.handleOk()
  336. })
  337. }
  338. }
  339. }
  340. </script>