RemarkDialog.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <u-popup :show="visible" @close="onClose" mode="center" round="10" :closeOnClickOverlay="false">
  3. <view class="remark-dialog" @click="playGlobalSound">
  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. // 点击全局音效
  38. function playGlobalSound(){
  39. uni.$u.playClickSound()
  40. }
  41. const emit = defineEmits(['update:visible', 'confirm'])
  42. const remarkText = ref('')
  43. const quickTags = ref(['少书', '多书', '子母件', '书单不符'])
  44. // 监听visible变化,初始化remarkText
  45. watch(() => props.visible, (newVal) => {
  46. if (newVal) {
  47. remarkText.value = props.initialValue
  48. }
  49. })
  50. // 追加快速标签
  51. const appendTag = (tag) => {
  52. remarkText.value += remarkText.value ? ' ' + tag : tag
  53. }
  54. // 关闭弹窗
  55. const onClose = () => {
  56. emit('update:visible', false)
  57. }
  58. // 确认提交
  59. const onConfirm = () => {
  60. emit('confirm', remarkText.value)
  61. onClose()
  62. }
  63. </script>
  64. <style scoped>
  65. .remark-dialog {
  66. width: 650rpx;
  67. background-color: #fff;
  68. border-radius: 10px;
  69. padding: 20px;
  70. }
  71. .dialog-title {
  72. text-align: center;
  73. font-size: 16px;
  74. font-weight: 500;
  75. margin-bottom: 20px;
  76. }
  77. .tag-item {
  78. margin-right: 10px;
  79. margin-bottom: 10px;
  80. }
  81. .dialog-footer {
  82. display: flex;
  83. justify-content: space-between;
  84. gap: 15px;
  85. }
  86. .footer-btn {
  87. flex: 1;
  88. }
  89. </style>