ai-form-cart.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <uv-popup ref="popup" mode="bottom" round="16">
  3. <view class="fx-col">
  4. <view class="fx-row fx-cen-cen h-[44px] px-50 mx-border-b">
  5. <view class="fx-row fx-bet-cen" @click="modifyCommitName">
  6. <view class="fx-1 text-ellipsis" style="max-width: 240px">
  7. 预览志愿表
  8. <template v-if="commit.name">
  9. {{ ' - ' }}
  10. {{ commit.name }}
  11. </template>
  12. </view>
  13. <uv-icon name="edit-pen-fill" color="primary" class="ml5"/>
  14. </view>
  15. </view>
  16. <scroll-view scroll-y class="bg-bg" style="height: 60vh">
  17. <view class="p-20 fx-col gap-20">
  18. <voluntary-major v-for="item in cart" :data="item" selected-only default-expand/>
  19. </view>
  20. </scroll-view>
  21. <view class="h-[60px] bg-bg px-20 fx-row fx-cen-cen button-combine">
  22. <view class="rounded-full overflow-hidden flex-1 fx-row mx-border mx-shadow-up">
  23. <view class="flex-1">
  24. <uv-button type="error" plain text="清空" icon="trash" icon-color="error" @click="handleClear"/>
  25. </view>
  26. <view class="flex-3">
  27. <uv-button :loading="loading" type="primary" :text="saveWithCountText" @click="handleSave"/>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <mx-popup-template ref="inputDialog" title="志愿表名称" left="" right="确定" @right="dialogInputConfirm">
  33. <uv-input v-model="commit.name" placeholder="请输入志愿表名称(选填)"/>
  34. </mx-popup-template>
  35. </uv-popup>
  36. </template>
  37. <script>
  38. import voluntaryMajor from '../../components/card/voluntary-major.vue';
  39. import InjectAIDataMixin from "@/pages/ie/entry-ai-form/components/InjectAIDataMixin";
  40. import {confirmAsync} from "@/utils/uni-helper";
  41. export default {
  42. name: "ai-form-cart",
  43. components: {voluntaryMajor},
  44. mixins: [InjectAIDataMixin],
  45. data() {
  46. return {
  47. loading: false,
  48. committing: false,
  49. nameConfirmed: false
  50. }
  51. },
  52. computed: {
  53. saveWithCountText() {
  54. const suffix = this.cart.length ? ' (' + this.cart.length + ')' : ''
  55. return '保存' + suffix
  56. }
  57. },
  58. methods: {
  59. async handleClear() {
  60. if (this.committing || this.loading) return
  61. if (this.cart.length) {
  62. await confirmAsync('确认清空全部志愿表?!')
  63. this.handleCartClear()
  64. }
  65. },
  66. modifyCommitName() {
  67. this.$refs.inputDialog.open();
  68. },
  69. handleSave() {
  70. if (!this.commit.name && !this.nameConfirmed) {
  71. this.committing = true
  72. this.modifyCommitName()
  73. return
  74. }
  75. this._saveCore()
  76. },
  77. dialogInputConfirm() {
  78. this.close()
  79. this.nameConfirmed = true
  80. if (this.committing) this._saveCore()
  81. },
  82. async _saveCore() {
  83. this.loading = true
  84. try {
  85. await this.handleCommit()
  86. } finally {
  87. this.committing = false
  88. this.loading = false
  89. }
  90. },
  91. open() {
  92. this.$refs.popup.open()
  93. },
  94. close() {
  95. if (!this.loading) {
  96. this.$refs.popup.close()
  97. }
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. .button-combine {
  104. ::v-deep .uv-button--square {
  105. border: 0;
  106. border-radius: 0;
  107. }
  108. }
  109. </style>