index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <div class="white pa-3">
  3. <el-tabs v-model="activeName" @tab-click="handleClick">
  4. <el-tab-pane
  5. v-for="item in items"
  6. :key="item.name"
  7. :label="item.label"
  8. :name="item.name"
  9. >
  10. <component :is="item.component" :ref="item.name" :label="item.label" @hook:mounted="onComponentMounted" @history="onHistory"></component>
  11. </el-tab-pane>
  12. </el-tabs>
  13. <DrawerHistory ref="drawerHistoryRefs" :get-page="getPage">
  14. <template #panel="{ item }">
  15. <el-form label-position="right" class="m-form" label-width="100px">
  16. <el-form-item label="方案名称">
  17. <el-tag>{{ itemData.title }}</el-tag>
  18. </el-form-item>
  19. <el-form-item label="方案描述">
  20. <div>{{ itemData.tag }}</div>
  21. </el-form-item>
  22. <el-form-item label="规则配置">
  23. <m-card class="mb-3" v-if="item.length">
  24. <el-form label-position="right" class="m-form" label-width="200px">
  25. <el-form-item v-for="_item in item" :key="_item.performanceSolutionId + _item.calculateConfigurationId" :label="_item.name">
  26. <el-tag>{{ _item.value }}</el-tag>
  27. </el-form-item>
  28. </el-form>
  29. </m-card>
  30. </el-form-item>
  31. </el-form>
  32. </template>
  33. </DrawerHistory>
  34. </div>
  35. </template>
  36. <script>
  37. import DrawerHistory from '@/components/DrawerHistory'
  38. import {
  39. getSolutionDetails
  40. } from '@/api/salary'
  41. export default {
  42. name: 'salary-solution',
  43. components: {
  44. DrawerHistory
  45. },
  46. data () {
  47. return {
  48. activeName: '',
  49. items: [],
  50. itemData: {}
  51. }
  52. },
  53. created () {
  54. this.items = this.$route.meta.roles.filter(e => e.hidden === 1).sort((a, b) => a.sort - b.sort).map(e => {
  55. return {
  56. name: e.name,
  57. label: e.label,
  58. component: () => import(`./${e.component}/index.vue`)
  59. }
  60. })
  61. if (this.$route.query.name) {
  62. this.activeName = this.$route.query.name
  63. } else {
  64. this.activeName = this.items[0].name
  65. }
  66. },
  67. methods: {
  68. handleClick () {
  69. this.$router.push(`${this.$route.path}?name=${this.activeName}`)
  70. this.$nextTick(() => {
  71. this.$refs[this.activeName][0].onInit()
  72. })
  73. },
  74. onComponentMounted () {
  75. this.$nextTick(() => {
  76. this.$refs[this.activeName] && this.$refs[this.activeName][0].onInit()
  77. })
  78. },
  79. onHistory (row) {
  80. this.itemData = row
  81. this.$refs.drawerHistoryRefs.open(`${row.title} 历史记录`)
  82. },
  83. async getPage () {
  84. return new Promise((resolve, reject) => {
  85. getSolutionDetails({ performanceSolutionId: this.itemData.performanceSolutionId }).then(({ data }) => {
  86. resolve({
  87. data: data.calculateConfigurations,
  88. total: data.calculateConfigurations.length
  89. })
  90. }).catch(reject)
  91. })
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss" scoped>
  97. ::v-deep .el-tabs__content {
  98. overflow: visible !important;
  99. }
  100. </style>