perf-month.vue 5.1 KB

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