elective-preference-reject.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <div class="mb5 mt10 text-right">
  3. <el-popover v-if="!this.isSelected" ref="pop" placement="right" width="300" trigger="click">
  4. <div>
  5. <el-input type="textarea" :rows="4" placeholder="请输入原因" v-model="recommendGroup.rejectedReason"></el-input>
  6. <p class="fx-row jc-between mt10">
  7. <el-button type="primary" size="mini" @click="handlePopClose">取消</el-button>
  8. <el-button type="danger" size="mini" @click="handleRejected">提交</el-button>
  9. </p>
  10. </div>
  11. <el-button slot="reference" type="danger">不同意</el-button>
  12. </el-popover>
  13. <el-button v-if="isRejected" type="primary" @click="handleCancelRejected">撤销拒绝</el-button>
  14. </div>
  15. </template>
  16. <script>
  17. import ElectiveToolsMixin from './elective-tools-mixins'
  18. import { rejectRecommend, submitElectiveModels } from '@/api/webApi/elective/selected-subject'
  19. export default {
  20. mixins: [ElectiveToolsMixin],
  21. name: 'elective-preference-reject',
  22. props: ['generation'],
  23. inject: {
  24. refreshData: {
  25. default: function() {
  26. }
  27. }
  28. },
  29. computed: {
  30. selectedList() {
  31. return this.generation.activeModel.selectedList
  32. },
  33. recommendGroup() {
  34. return this.generation.activeModel.models.find(g => g.isRecommend) || {}
  35. },
  36. isSelected() {
  37. return this.selectedList.some(this.isGroupSelected)
  38. },
  39. isRejected() {
  40. return this.selectedList.some(this.isGroupRejected)
  41. }
  42. },
  43. methods: {
  44. handlePopClose() {
  45. this.$refs.pop.doClose()
  46. },
  47. async handleCancelRejected() {
  48. try {
  49. this.selectedList.clear()
  50. await submitElectiveModels({ models: [] })
  51. this.$message.success('撤销成功,您可以重新报名')
  52. } finally {
  53. this.refreshData()
  54. }
  55. },
  56. async handleRejected() {
  57. if (!this.recommendGroup.rejectedReason) {
  58. this.$message.error('拒绝原因不能为空')
  59. return
  60. }
  61. try {
  62. const rejects = this.generation.activeModel.models
  63. .filter(g => g.allowSelect)
  64. .map(g => g.groupName).join(' ')
  65. await this.$confirm(`确认拒绝填报 ${rejects}`)
  66. this.recommendGroup.rejected = true
  67. this.selectedList.clear()
  68. this.selectedList.push(this.recommendGroup)
  69. await rejectRecommend({
  70. models: this.selectedList.map(g => ({
  71. groupId: g.groupId,
  72. rejected: g.rejected,
  73. rejectedReason: g.rejectedReason
  74. }))
  75. })
  76. this.handlePopClose()
  77. this.$message.warning('拒绝成功,您未填报任何组合。您可以撤销后重新填报。')
  78. } finally {
  79. this.refreshData()
  80. }
  81. }
  82. }
  83. }
  84. </script>
  85. <style scoped>
  86. </style>