DialogInput.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <div class="dialog-input">
  3. <div>
  4. <a-textarea placeholder="输入文本内容" allow-clear />
  5. </div>
  6. <div>
  7. <div>
  8. <div>联网查询</div>
  9. </div>
  10. <div>
  11. <div v-if="enable_frequent_question">常用问题定义</div>
  12. <div v-if="enable_file_upload">文件上传</div>
  13. <div v-if="enable_voice_recognition">语音识别</div>
  14. <div @click="handleSubmit">发送</div>
  15. </div>
  16. </div>
  17. <div>文件上传预览区: 当点击文件上传,选择某个文件后,此处需要展示进行预览。</div>
  18. </div>
  19. </template>
  20. <script setup>
  21. const props = defineProps({
  22. /**
  23. * 是否禁用操作
  24. * 默认 false
  25. * 当此值为 true 时,此组件的任何功能都不可用
  26. * 当对话正在进行时,此值应为 true,意味着不允许继续对话
  27. * 直到一轮对话结束,或者一轮对话终止,此值才应该变为 false
  28. */
  29. disabled: {
  30. type: Boolean,
  31. default: false,
  32. required: false
  33. },
  34. /**
  35. * 是否开启文件上传功能
  36. * 默认 true,即默认开启
  37. * 当此值为 false 时,该组件将没有文件上传按钮
  38. */
  39. enable_file_upload: {
  40. type: Boolean,
  41. default: true,
  42. required: false
  43. },
  44. /**
  45. * 是否开启 常用问题 功能
  46. * 如果此值为false,则 常用问题 定义功能不可用
  47. */
  48. enable_frequent_question: {
  49. type: Boolean,
  50. default: true,
  51. required: false
  52. },
  53. /**
  54. * 是否开启音频识别功能
  55. * 如果此值为 false,则语音识别功能不可用
  56. */
  57. enable_voice_recognition: {
  58. type: Boolean,
  59. default: false,
  60. required: false
  61. },
  62. /**
  63. * 在 enable_file_upload === true 的前提下
  64. * 文件上传的类型,默认是 *,不限类型
  65. * 对应html属性 accept
  66. * 对应 arco.design Upload accept 属性
  67. * @see https://arco.design/vue/component/upload#API
  68. * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#htmlattrdefaccept
  69. */
  70. file_upload_type: {
  71. type: String,
  72. default: '*',
  73. required: false
  74. },
  75. /**
  76. * 在 enable_file_upload === true 的前提下
  77. * 文件上传的数量限制
  78. * 默认值为0,表示不限制
  79. * 对应 arco.design Upload limit 属性
  80. */
  81. file_upload_limit: {
  82. type: Number,
  83. default: 0,
  84. required: false
  85. },
  86. /**
  87. * 输入框文本占位提示
  88. */
  89. text_placeholder: {
  90. type: String
  91. },
  92. /**
  93. * 输入的文本长度限制
  94. * 默认值为0,表示不限制长度
  95. * 对应 arco.design textarea max-length 属性
  96. * @see https://arco.design/vue/component/textarea#API
  97. */
  98. text_limit: {
  99. type: Number,
  100. default: 0,
  101. required: false
  102. },
  103. /**
  104. * 是否显示字数统计
  105. * 对应 arco.design textarea show-word-limit
  106. * @see https://arco.design/vue/component/textarea#API
  107. */
  108. show_text_count: {
  109. type: Boolean,
  110. default: false,
  111. required: false
  112. }
  113. });
  114. const emit = defineEmits(['inputTextChange', 'inputFileChange', 'submit']);
  115. const handleSubmit = () => {
  116. // 检查是否是禁用状态
  117. if (props.disabled) {
  118. return;
  119. }
  120. emit('submit');
  121. };
  122. </script>
  123. <style lang="css" scoped>
  124. .dialog-input {
  125. color: var(--color-text-1);
  126. }
  127. </style>