RemarkDialog.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <u-popup :show="visible" @close="onClose" mode="center" round="10" :closeOnClickOverlay="false">
  3. <view class="remark-dialog">
  4. <view class="dialog-title">编辑备注</view>
  5. <!-- 备注输入框 -->
  6. <view class="dialog-content mb-30">
  7. <u-textarea v-model="remarkText" placeholder="请输入" :maxlength="200" height="100" count></u-textarea>
  8. <!-- 快速输入标签 -->
  9. <view class="quick-tags mt-10">
  10. <text class="common-title">快速填入</text>
  11. <view class="tags-container flex-w mt-20">
  12. <u-tag v-for="(tag, index) in quickTags" :key="index" :text="tag" plain size="mini"
  13. type="primary" @click="appendTag(tag)" class="tag-item"></u-tag>
  14. </view>
  15. </view>
  16. </view>
  17. <!-- 底部按钮 -->
  18. <view class="dialog-footer">
  19. <u-button plain @click="onClose" class="footer-btn">取消</u-button>
  20. <u-button type="primary" @click="onConfirm" class="footer-btn">确定</u-button>
  21. </view>
  22. </view>
  23. </u-popup>
  24. </template>
  25. <script setup>
  26. import { ref, watch } from 'vue'
  27. const props = defineProps({
  28. visible: {
  29. type: Boolean,
  30. default: false
  31. },
  32. initialValue: {
  33. type: String,
  34. default: ''
  35. }
  36. })
  37. const emit = defineEmits(['update:visible', 'confirm'])
  38. const remarkText = ref('')
  39. const quickTags = ref(['少书', '多书', '子母件', '书单不符'])
  40. // 监听visible变化,初始化remarkText
  41. watch(() => props.visible, (newVal) => {
  42. if (newVal) {
  43. remarkText.value = props.initialValue
  44. }
  45. })
  46. // 追加快速标签
  47. const appendTag = (tag) => {
  48. remarkText.value += remarkText.value ? ' ' + tag : tag
  49. }
  50. // 关闭弹窗
  51. const onClose = () => {
  52. emit('update:visible', false)
  53. }
  54. // 确认提交
  55. const onConfirm = () => {
  56. emit('confirm', remarkText.value)
  57. onClose()
  58. }
  59. </script>
  60. <style scoped>
  61. .remark-dialog {
  62. width: 650rpx;
  63. background-color: #fff;
  64. border-radius: 10px;
  65. padding: 20px;
  66. }
  67. .dialog-title {
  68. text-align: center;
  69. font-size: 16px;
  70. font-weight: 500;
  71. margin-bottom: 20px;
  72. }
  73. .tag-item {
  74. margin-right: 10px;
  75. margin-bottom: 10px;
  76. }
  77. .dialog-footer {
  78. display: flex;
  79. justify-content: space-between;
  80. gap: 15px;
  81. }
  82. .footer-btn {
  83. flex: 1;
  84. }
  85. </style>