salarySolutionParam.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <m-dialog ref="dialog" title="系数管理" @sure="onSure">
  3. <el-form v-loading="loading" label-width="100px">
  4. <el-form-item label="名称">
  5. <el-tag color="primary">{{ itemData.title }}</el-tag>
  6. </el-form-item>
  7. <el-form-item label="系数管理">
  8. <m-card shadow="never">
  9. <template v-if="items.length" v-slot:default>
  10. <el-tabs v-model="activeNames" >
  11. <el-tab-pane
  12. v-for="item in items"
  13. :key="item.category"
  14. :title="item.category"
  15. :name="item.category"
  16. :label="item.category"
  17. >
  18. <el-form-item
  19. label-width="150px"
  20. v-for="(calculateConfiguration, index) in item.calculateConfigurations"
  21. :key="index"
  22. :label="calculateConfiguration.name"
  23. class="mt-3"
  24. >
  25. <template v-if="calculateConfiguration.valueCategory === 0">
  26. <el-slider
  27. input-size="small"
  28. v-model="calculateConfiguration.value"
  29. :min="calculateConfiguration.miniValue"
  30. :max="calculateConfiguration.maxValue"
  31. :step="0.01"
  32. show-input
  33. >
  34. </el-slider>
  35. </template>
  36. <template v-else>
  37. <m-table
  38. clearHeader
  39. shadow="never"
  40. :headers="[
  41. { label: '名称', prop: 'name' },
  42. { label: '值', prop: 'value' }
  43. ]"
  44. :items="calculateConfiguration.value"
  45. >
  46. <template #value="{ row }">
  47. <el-input v-model="row.value" size="small" placeholder="请输入对应的值"></el-input>
  48. </template>
  49. </m-table>
  50. </template>
  51. </el-form-item>
  52. </el-tab-pane>
  53. </el-tabs>
  54. </template>
  55. <template v-if="!items.length">
  56. <m-empty description="尚未配置系数"></m-empty>
  57. </template>
  58. </m-card>
  59. </el-form-item>
  60. </el-form>
  61. </m-dialog>
  62. </template>
  63. <script>
  64. import {
  65. getSolutionDetails,
  66. saveSolution
  67. } from '@/api/salary'
  68. export default {
  69. name: 'salarySolutionParam',
  70. inject: ['env'],
  71. data () {
  72. return {
  73. activeNames: null,
  74. loading: false,
  75. itemData: {},
  76. items: []
  77. }
  78. },
  79. methods: {
  80. async open (item) {
  81. this.itemData = item
  82. this.$refs.dialog.open()
  83. this.loading = true
  84. try {
  85. const { data } = await getSolutionDetails({
  86. performanceSolutionId: item.performanceSolutionId
  87. })
  88. this.items = data.performanceSolutionDetailRespCategoryVos.map(e => {
  89. e.calculateConfigurations = e.calculateConfigurations.map(item => {
  90. if (item.valueCategory !== 0) {
  91. item.value = JSON.parse(item.value)
  92. return item
  93. }
  94. item.maxValue = !item.maxValue ? Infinity : Number(item.maxValue)
  95. item.miniValue = !item.miniValue ? -Infinity : Number(item.miniValue)
  96. if (item.value) {
  97. item.value = Number(item.value)
  98. }
  99. return item
  100. })
  101. return e
  102. })
  103. this.activeNames = this.items[0]?.category
  104. } catch (error) {
  105. this.$message.error(error)
  106. } finally {
  107. this.loading = false
  108. }
  109. },
  110. async onSure () {
  111. const query = {
  112. entity: {
  113. performanceSolutionId: this.itemData.performanceSolutionId,
  114. env: this.env
  115. },
  116. performanceSolutionDetailRespCategoryVos: this.items
  117. }
  118. try {
  119. await saveSolution(query)
  120. this.$refs.dialog.close()
  121. this.$emit('refresh')
  122. this.$message.success('保存成功')
  123. } catch (error) {
  124. this.$message.error(error)
  125. }
  126. }
  127. }
  128. }
  129. </script>
  130. <style lang="scss" scoped>
  131. </style>