flow-bonus.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <div v-loading="loading">
  3. <div class="white-box">
  4. <div class="filter-box">
  5. <filter-user :filter-types="filterTypes" :filter-btn-name="$t('common.screen')" @select-value="handleFilterUser" />
  6. </div>
  7. <el-table ref="multipleTable" class="table-box" :data="tableData" stripe style="width: 100%;" :height="tool.getTableHeight()">
  8. <el-table-column v-for="(tableHeader, key) in tableHeaders" :key="key" :label="tableHeader.header" :width="tableHeader.other.width ? tableHeader.other.width : ''" :prop="tableHeader.other.prop ? tableHeader.other.prop : null">
  9. <template slot-scope="scope">
  10. <template v-if="scope.row[tableHeader.index].other.tag">
  11. <el-tag :type="scope.row[tableHeader.index].other.tag.type ? scope.row[tableHeader.index].other.tag.type : null" :size="scope.row[tableHeader.index].other.tag.size ? scope.row[tableHeader.index].other.tag.size : null" :class="scope.row[tableHeader.index].other.tag.class ? scope.row[tableHeader.index].other.tag.class : null">{{ scope.row[tableHeader.index].value }}</el-tag>
  12. </template>
  13. <template v-else>
  14. <div v-html="scope.row[tableHeader.index].value" />
  15. </template>
  16. </template>
  17. </el-table-column>
  18. </el-table>
  19. <div class="white-box-footer">
  20. <el-button v-show="permission.hasPermission(`bonus/flow-bonus-export`)" type="success" size="small" @click="handleExport">{{$t('common.exportExcel')}}<!-- 导出Excel --></el-button>
  21. <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
  22. </div>
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. import { fetchFlowBonus, fetchFlowBonusExport } from '@/api/bonus'
  28. import tool from '@/utils/tool'
  29. import baseInfo from '@/utils/baseInfo'
  30. import FilterUser from '../../components/FilterUser'
  31. import permission from '@/utils/permission'
  32. import Pagination from '@/components/Pagination'
  33. import filterHelper from '@/utils/filterHelper'
  34. import ElementUI from 'element-ui'
  35. export default {
  36. name: 'BonusFlowBonus',
  37. components: { FilterUser, Pagination },
  38. data() {
  39. return {
  40. tableHeaders: null,
  41. tableData: null,
  42. loading: true,
  43. multipleSelection: [],
  44. currentPage: 1,
  45. totalPages: 1,
  46. totalCount: 1,
  47. pageSize: 20,
  48. tool: tool,
  49. permission: permission,
  50. baseDecLevels: baseInfo.decLevels(),
  51. baseEmpLevels: baseInfo.empLevels(),
  52. filterTypes: null,
  53. filterModel: {}
  54. }
  55. },
  56. mounted() {
  57. this.getData()
  58. },
  59. methods: {
  60. handleCurrentChange(page) {
  61. this.getData(page, this.pageSize)
  62. },
  63. handleSizeChange(pageSize) {
  64. this.getData(this.currentPage, pageSize)
  65. },
  66. handleFilterUser(filterData) {
  67. filterHelper.handleFilterUser(this, filterData)
  68. },
  69. getData(page, pageSize) {
  70. const filterData = this.filterModel
  71. this.loading = true
  72. const paramsData = Object.assign({
  73. page: (page === null || page === undefined) ? 1 : page,
  74. pageSize: (pageSize === null || pageSize === undefined) ? this.pageSize : pageSize
  75. }, filterData)
  76. fetchFlowBonus(paramsData).then(response => {
  77. this.filterTypes = response.data.filterTypes
  78. this.tableData = response.data.list
  79. this.tableHeaders = response.data.columnsShow ? response.data.columnsShow : []
  80. this.loading = false
  81. this.currentPage = page
  82. this.totalPages = parseInt(response.data.totalPages)
  83. this.totalCount = parseInt(response.data.totalCount)
  84. this.pageSize = pageSize
  85. // vueObj.sumData = response.sumData
  86. })
  87. },
  88. handleExport() {
  89. this.$confirm(this.$t('common.exportCurrentData'), this.$t('common.notice'), { // `确定要导出当前数据吗?`, '提示',
  90. confirmButtonText: this.$t('common.confirm'), // 确定
  91. cancelButtonText: this.$t('common.cancel'), // 取消
  92. }).then(() => {
  93. return fetchFlowBonusExport(this.filterModel)
  94. }).then(response => {
  95. this.$message({
  96. message: response.data,
  97. type: 'success'
  98. })
  99. }).catch((error) => {
  100. if(error !== 'cancel'){
  101. ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
  102. }
  103. })
  104. }
  105. }
  106. }
  107. </script>
  108. <style scoped>
  109. .table-box .el-form-item__label {
  110. width: 100px;
  111. color: #99a9bf;
  112. }
  113. .table-box .el-form-item {
  114. width: 30%;
  115. margin-right: 0;
  116. margin-bottom: 0;
  117. }
  118. </style>