salarySolutionEdit.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <m-dialog ref="dialog" :title="itemData.entity ? '编辑' : '新增'" @sure="onSure">
  3. <m-form ref="form" v-model="formQuery" :items="items" v-loading="loading"></m-form>
  4. </m-dialog>
  5. </template>
  6. <script>
  7. import {
  8. saveSolution,
  9. getSolutionDetails
  10. } from '@/api/salary'
  11. import { mapGetters } from 'vuex'
  12. export default {
  13. name: 'salary-solution-edit',
  14. data () {
  15. return {
  16. loading: false,
  17. formQuery: {
  18. title: null,
  19. tag: null
  20. },
  21. itemData: {}
  22. }
  23. },
  24. computed: {
  25. ...mapGetters(['organizationTree']),
  26. items () {
  27. return [
  28. {
  29. label: '方案名称',
  30. prop: 'title',
  31. type: 'input',
  32. rules: [
  33. { required: true, message: '请输入方案名称', trigger: 'blur' }
  34. ],
  35. options: {
  36. placeholder: '请输入方案名称'
  37. }
  38. },
  39. {
  40. label: '方案描述',
  41. prop: 'tag',
  42. type: 'input',
  43. options: {
  44. placeholder: '请输入方案描述'
  45. }
  46. },
  47. {
  48. label: '绩效机构',
  49. prop: 'organizationNo',
  50. type: 'cascader',
  51. options: {
  52. clearable: true,
  53. placeholder: '请选择机构',
  54. options: this.organizationTree,
  55. showAllLevels: false,
  56. props: {
  57. checkStrictly: true,
  58. // emitPath: false,
  59. value: 'organizationNo',
  60. label: 'organizationName',
  61. children: 'child'
  62. }
  63. }
  64. }
  65. ]
  66. }
  67. },
  68. methods: {
  69. async open (item) {
  70. this.$refs.dialog.open()
  71. if (item) {
  72. this.formQuery.title = item.title
  73. this.formQuery.tag = item.tag
  74. this.loading = true
  75. try {
  76. const { data } = await getSolutionDetails({
  77. performanceSolutionId: item.performanceSolutionId
  78. })
  79. this.itemData = data
  80. } catch (error) {
  81. this.$message.error(error)
  82. } finally {
  83. this.loading = false
  84. }
  85. } else {
  86. this.formQuery.title = null
  87. this.formQuery.tag = null
  88. this.itemData = {}
  89. }
  90. },
  91. onSure () {
  92. this.$refs.form.validate(async valid => {
  93. if (valid) {
  94. const query = {
  95. entity: {
  96. performanceSolutionId: this.itemData.entity?.performanceSolutionId,
  97. ...this.formQuery
  98. },
  99. calculateConfigurations: this.itemData.calculateConfigurations ?? []
  100. }
  101. try {
  102. await saveSolution(query)
  103. this.$refs.dialog.close()
  104. this.$emit('refresh')
  105. this.$message.success('保存成功')
  106. } catch (error) {
  107. this.$message.error(error)
  108. }
  109. }
  110. })
  111. }
  112. }
  113. }
  114. </script>
  115. <style lang="scss" scoped>
  116. </style>