SbOil.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <template>
  2. <a-card :bordered="false">
  3. <div class="table-page-search-wrapper" @keyup.enter="handleEnter">
  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="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">
  21. <a-button v-if="$auth('sb-oils-add')" type="primary" icon="plus" @click="$refs.baseModalList.base()">新增</a-button>
  22. <a-button style="margin-left: 8px" v-if="$auth('sb-oils-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  23. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('sb-oils-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. :bordered="this.MyGlobalConstant.BORDERED"
  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="$auth('sb-oils-oil')
  50. && (record.status === DictCache.VALUE.SB_OIL_STATUS.AGREE
  51. || record.status === DictCache.VALUE.SB_OIL_STATUS.OIL
  52. )&& record.isOiL"
  53. @click="handleHandle(record)"
  54. >加油</operation-button>
  55. <operation-button
  56. v-if="$auth('sb-oils-audit')
  57. && record.status === DictCache.VALUE.SB_OIL_STATUS.AGREE && record.isAudit
  58. && record.auditType === DictCache.VALUE.SB_OIL_AUDIT_TYPE.SYSTEM
  59. "
  60. @click="auditHandle(record)"
  61. >审批</operation-button>
  62. <template
  63. v-if="record.createdUserId === userInfo.userId">
  64. <template v-if="record.status === DictCache.VALUE.SB_OIL_STATUS.OIL">
  65. <operation-button
  66. v-if="$auth('sb-oils-confirm')"
  67. @click="handleConfirm(record)"
  68. >确认</operation-button>
  69. </template>
  70. <template v-if="record.status === DictCache.VALUE.SB_OIL_STATUS.APPLY">
  71. <operation-button
  72. v-if="$auth('sb-oils-edit')"
  73. @click="handleEdit(record)"
  74. >修改</operation-button>
  75. <operation-button
  76. v-if="$auth('sb-oils-del')"
  77. :type="2"
  78. title="是否要删除该条数据?"
  79. @confirm="batchDelete(record.id)">删除</operation-button>
  80. </template>
  81. </template>
  82. </template>
  83. </span>
  84. </s-table>
  85. <base-form ref="baseModal" @ok="handleOk"/>
  86. <base-form-list ref="baseModalList" @ok="handleOk" />
  87. <execute-base-form ref="executeBaseForm" @ok="handleOk" />
  88. <audit-base-form ref="auditBaseForm" @ok="handleOk" />
  89. <detail ref="detailModal"/>
  90. </a-card>
  91. </template>
  92. <script>
  93. import { STable, Ellipsis } from '@/components'
  94. import BaseForm from './modules/BaseForm'
  95. import BaseFormList from './modules/BaseFormList'
  96. import Detail from './modules/Detail'
  97. import ExecuteBaseForm from '@/views/sb/oil/modules/ExecuteBaseForm'
  98. import AuditBaseForm from '@/views/sb/oil/modules/AuditBaseForm'
  99. import { getSbOilPage, deleteSbOils, fetchSbOil, exportSbOil } from '@/api/sb/oil'
  100. export default {
  101. name: 'SbOilList',
  102. components: {
  103. STable,
  104. Ellipsis,
  105. BaseForm,
  106. BaseFormList,
  107. ExecuteBaseForm,
  108. AuditBaseForm,
  109. Detail
  110. },
  111. data () {
  112. return {
  113. // 查询参数
  114. queryParam: {
  115. },
  116. userInfo: this.$store.getters.userInfo,
  117. // 表头
  118. columns: [
  119. {
  120. title: '序号',
  121. dataIndex: 'index',
  122. customRender: (text, record, index) => {
  123. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  124. }
  125. },
  126. {
  127. title: '设备名称',
  128. dataIndex: 'sbName'
  129. },
  130. {
  131. title: '设备编号',
  132. dataIndex: 'sbNo'
  133. },
  134. {
  135. title: '仓库名称',
  136. dataIndex: 'storeName'
  137. },
  138. {
  139. title: '申请人',
  140. dataIndex: 'userName'
  141. },
  142. {
  143. title: '申请油量',
  144. dataIndex: 'applyOil',
  145. customRender: (text, record, index) => {
  146. const result = this.BaseTool.Amount.formatter(text)
  147. if (this.BaseTool.String.isNotBlank(result)) {
  148. return result + '升'
  149. } else {
  150. return ''
  151. }
  152. }
  153. },
  154. {
  155. title: '实际加油量',
  156. dataIndex: 'realOil',
  157. customRender: (text, record, index) => {
  158. const result = this.BaseTool.Amount.formatter(text)
  159. if (this.BaseTool.String.isNotBlank(result)) {
  160. return result + '升'
  161. } else {
  162. return ''
  163. }
  164. }
  165. },
  166. {
  167. title: '状态',
  168. dataIndex: 'status',
  169. customRender: (text, record, index) => {
  170. return this.BaseTool.Table.statusCustomRenderDict(this, text, record,
  171. this.DictCache.COLOR.SB_OIL_STATUS, this.statusMap)
  172. }
  173. },
  174. {
  175. title: '审批类型',
  176. dataIndex: 'auditType',
  177. customRender: (text, record, index) => {
  178. return this.BaseTool.Table.getMapText(this.auditTypeMap, text)
  179. }
  180. },
  181. {
  182. title: '仓库管理员',
  183. dataIndex: 'storeUserName'
  184. },
  185. {
  186. title: '申请说明',
  187. dataIndex: 'applyRemark',
  188. customRender: (text, record, index) => {
  189. return this.BaseTool.Table.customRenderWidth(this, text, '150px')
  190. }
  191. },
  192. {
  193. title: '审批说明',
  194. dataIndex: 'remark',
  195. customRender: (text, record, index) => {
  196. return this.BaseTool.Table.customRenderWidth(this, text, '150px')
  197. }
  198. },
  199. {
  200. title: '加油说明',
  201. dataIndex: 'handleRemark',
  202. customRender: (text, record, index) => {
  203. return this.BaseTool.Table.customRenderWidth(this, text, '150px')
  204. }
  205. },
  206. {
  207. title: '操作',
  208. key: 'action',
  209. width: '200px',
  210. align: 'center',
  211. scopedSlots: { customRender: 'action' }
  212. }
  213. ],
  214. // 下拉框map
  215. statusMap: {},
  216. auditTypeMap: {},
  217. // 加载数据方法 必须为 Promise 对象
  218. loadData: parameter => {
  219. parameter = {
  220. ...parameter,
  221. ...this.queryParam
  222. }
  223. return getSbOilPage(parameter)
  224. .then(res => {
  225. return res.data
  226. })
  227. },
  228. selectedRowKeys: [],
  229. selectedRows: [],
  230. options: {
  231. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  232. rowSelection: {
  233. selectedRowKeys: this.selectedRowKeys,
  234. onChange: this.onSelectChange
  235. }
  236. },
  237. optionAlertShow: false
  238. }
  239. },
  240. created () {
  241. // 下拉框map
  242. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_OIL_STATUS)
  243. this.auditTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_OIL_AUDIT_TYPE)
  244. this.tableOption()
  245. },
  246. methods: {
  247. tableOption () {
  248. if (!this.optionAlertShow) {
  249. this.options = {
  250. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  251. rowSelection: {
  252. selectedRowKeys: this.selectedRowKeys,
  253. onChange: this.onSelectChange,
  254. getCheckboxProps: record => ({
  255. props: {
  256. disabled: false,
  257. name: record.id
  258. }
  259. })
  260. }
  261. }
  262. this.optionAlertShow = true
  263. } else {
  264. this.options = {
  265. alert: false,
  266. rowSelection: null
  267. }
  268. this.optionAlertShow = false
  269. }
  270. },
  271. batchDelete (id) {
  272. let ids = []
  273. if (this.BaseTool.String.isBlank(id)) {
  274. const length = this.selectedRows.length
  275. if (length === 0) {
  276. this.$message.info('请选择要删除的记录')
  277. return
  278. }
  279. ids = this.selectedRows.map(item => item.id)
  280. } else {
  281. ids = [id]
  282. }
  283. deleteSbOils(ids).then(res => {
  284. this.$message.info('删除成功')
  285. this.handleOk()
  286. this.$refs.table.clearSelected()
  287. })
  288. },
  289. handleEdit (record) {
  290. fetchSbOil({ id: record.id }).then(res => {
  291. const modal = this.$refs.baseModal
  292. modal.base(res.data)
  293. })
  294. },
  295. handleConfirm (record) {
  296. fetchSbOil({ id: record.id }).then(res => {
  297. const modal = this.$refs.baseModal
  298. modal.base(res.data)
  299. })
  300. },
  301. handleHandle (record) {
  302. fetchSbOil({ id: record.id }).then(res => {
  303. const modal = this.$refs.executeBaseForm
  304. modal.base(res.data)
  305. })
  306. },
  307. auditHandle (record) {
  308. fetchSbOil({ id: record.id }).then(res => {
  309. const modal = this.$refs.auditBaseForm
  310. modal.base(res.data)
  311. })
  312. },
  313. handleView (record) {
  314. fetchSbOil({ id: record.id }).then(res => {
  315. const modal = this.$refs.detailModal
  316. modal.base(res.data)
  317. })
  318. },
  319. handleOk () {
  320. this.$refs.table.refresh()
  321. },
  322. onSelectChange (selectedRowKeys, selectedRows) {
  323. this.selectedRowKeys = selectedRowKeys
  324. this.selectedRows = selectedRows
  325. },
  326. resetSearchForm () {
  327. this.queryParam = {
  328. }
  329. this.$refs.table.refresh(true)
  330. },
  331. doExport () {
  332. const parameter = {
  333. ...this.queryParam
  334. }
  335. exportSbOil(parameter).then(file => {
  336. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  337. })
  338. },
  339. handleEnter () {
  340. this.$refs.table.refresh(true)
  341. }
  342. }
  343. }
  344. </script>