sandboxCalculate.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <m-dialog title="绩效测算" ref="dialog" v-loading="loading" width="1200px">
  3. <div v-if="!isCalculate && !isSuccess" class="d-flex align-center justify-center">
  4. 正在测算中,请稍后...
  5. </div>
  6. <el-result v-if="isCalculate" icon="success" title="测算完成"></el-result>
  7. <template v-if="isSuccess">
  8. <el-radio-group v-model="choose" @input="getList">
  9. <el-radio
  10. v-for="item in radioItems"
  11. :key="item.id"
  12. :label="item.id"
  13. >
  14. {{ item.name }}
  15. </el-radio>
  16. </el-radio-group>
  17. <m-table
  18. class="mt-3"
  19. shadow="never"
  20. clearHeader
  21. :items="tableItems"
  22. :headers="tableHeaders"
  23. :page-size="tablePageInfo.size"
  24. :page-current="tablePageInfo.current"
  25. :total="tableTotal"
  26. @page-change="onPageChange"
  27. @sort-change="onSortChange"
  28. ></m-table>
  29. </template>
  30. </m-dialog>
  31. </template>
  32. <script>
  33. import {
  34. getSandboxResultList,
  35. getSandboxResultPage
  36. } from '@/api/salary'
  37. export default {
  38. name: 'sandboxCalculate',
  39. data () {
  40. return {
  41. choose: null,
  42. loading: false,
  43. isCalculate: false,
  44. isSuccess: false,
  45. radioItems: [],
  46. tableTotal: 0,
  47. tableOrders: [],
  48. tablePageInfo: {
  49. size: 10,
  50. current: 1
  51. },
  52. tableItems: [],
  53. tableHeaders: []
  54. }
  55. },
  56. methods: {
  57. async open (item) {
  58. this.isCalculate = false
  59. this.isSuccess = false
  60. this.$refs.dialog.open()
  61. this.loading = true
  62. try {
  63. const { data } = await getSandboxResultList({
  64. modelName: item.modelName
  65. })
  66. this.radioItems = data || []
  67. if (this.radioItems.length) {
  68. this.choose = this.radioItems[0].id
  69. }
  70. this.isCalculate = true
  71. await this.getList()
  72. this.isCalculate = false
  73. this.isSuccess = true
  74. } catch (error) {
  75. this.$message.error(error)
  76. } finally {
  77. this.loading = false
  78. }
  79. },
  80. async getList () {
  81. this.loading = true
  82. try {
  83. const { data } = await getSandboxResultPage({
  84. page: {
  85. ...this.tablePageInfo,
  86. orders: this.tableOrders
  87. },
  88. id: this.choose
  89. })
  90. this.tableHeaders = data.dataColumn.map(e => {
  91. return {
  92. label: e.name,
  93. prop: e.enName
  94. }
  95. })
  96. this.tableItems = data.page.records
  97. this.tableTotal = data.page.total
  98. } catch (error) {
  99. this.$message.error(error)
  100. } finally {
  101. this.loading = false
  102. }
  103. },
  104. onPageChange (index) {
  105. this.tablePageInfo.current = index
  106. this.getList()
  107. },
  108. onSortChange (v) {
  109. this.tableOrders = v
  110. this.getList()
  111. }
  112. }
  113. }
  114. </script>
  115. <style lang="scss" scoped>
  116. </style>