|
@@ -79,6 +79,7 @@
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
import { ref, onMounted, onUnmounted, computed, nextTick } from 'vue';
|
|
import { ref, onMounted, onUnmounted, computed, nextTick } from 'vue';
|
|
|
|
|
+import { useI18n } from 'vue-i18n';
|
|
|
import { Message } from '@arco-design/web-vue';
|
|
import { Message } from '@arco-design/web-vue';
|
|
|
|
|
|
|
|
import { jsonStringify } from '../../utils/utils';
|
|
import { jsonStringify } from '../../utils/utils';
|
|
@@ -126,6 +127,8 @@ const props = defineProps({
|
|
|
session_id: String
|
|
session_id: String
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+const i18n = useI18n();
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* input的一些操作方法
|
|
* input的一些操作方法
|
|
|
*/
|
|
*/
|
|
@@ -287,6 +290,18 @@ const enable_text_input = computed(() => {
|
|
|
return true;
|
|
return true;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 对话文本是否必须
|
|
|
|
|
+ */
|
|
|
|
|
+const is_chat_text_required = computed(() => {
|
|
|
|
|
+ const is_enable = enable_text_input.value;
|
|
|
|
|
+ if (!is_enable) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 默认的文本值
|
|
* 默认的文本值
|
|
|
*/
|
|
*/
|
|
@@ -324,6 +339,26 @@ const enable_file_upload = computed(() => {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 文档出卷
|
|
|
|
|
+ if (menu_id === 7) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return false;
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 对话文件是否必须
|
|
|
|
|
+ */
|
|
|
|
|
+const is_chat_file_required = computed(() => {
|
|
|
|
|
+ const is_enable = enable_file_upload.value;
|
|
|
|
|
+ if (!is_enable) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const menu_id = current_menu_id.value;
|
|
|
|
|
+
|
|
|
|
|
+ // 文档出卷:文件必须上传
|
|
|
if (menu_id === 7) {
|
|
if (menu_id === 7) {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
@@ -450,16 +485,34 @@ const handleInputSubmit = async (options) => {
|
|
|
let ask_text = options.text; // 文本
|
|
let ask_text = options.text; // 文本
|
|
|
const ask_files = options.files; // 文件列表
|
|
const ask_files = options.files; // 文件列表
|
|
|
|
|
|
|
|
- // TODO: 内容检查,如果文本内容不合法,则不允许发送
|
|
|
|
|
- if (enable_text_input.value) {
|
|
|
|
|
|
|
+ // 用户选定的文件数量
|
|
|
|
|
+ const file_total = ask_files.length;
|
|
|
|
|
+
|
|
|
|
|
+ const is_text_required = is_chat_text_required.value;
|
|
|
|
|
+ const is_file_required = is_chat_file_required.value;
|
|
|
|
|
+
|
|
|
|
|
+ // 检查对话文字是否必须
|
|
|
|
|
+ if (is_text_required) {
|
|
|
if (!ask_text) {
|
|
if (!ask_text) {
|
|
|
- handleErrorMessage('请输入文字');
|
|
|
|
|
|
|
+ const msg = i18n.t('conversation.please_input_text');
|
|
|
|
|
+
|
|
|
|
|
+ handleErrorMessage(msg);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
ask_text = default_text_value.value;
|
|
ask_text = default_text_value.value;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 检查对话文件是否必须
|
|
|
|
|
+ if (is_file_required) {
|
|
|
|
|
+ if (file_total === 0) {
|
|
|
|
|
+ const msg = i18n.t('conversation.please_upload_file');
|
|
|
|
|
+
|
|
|
|
|
+ handleErrorMessage(msg);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// --------------------------------------------
|
|
// --------------------------------------------
|
|
|
// --------------------------------------------
|
|
// --------------------------------------------
|
|
|
// --------------------------------------------
|
|
// --------------------------------------------
|
|
@@ -560,7 +613,7 @@ const handleInputSubmit = async (options) => {
|
|
|
/**
|
|
/**
|
|
|
* 如果存在文件数据,则进行文件上传
|
|
* 如果存在文件数据,则进行文件上传
|
|
|
*/
|
|
*/
|
|
|
- if (ask_files.length !== 0) {
|
|
|
|
|
|
|
+ if (file_total !== 0) {
|
|
|
// 进行文件上传,获取文件信息
|
|
// 进行文件上传,获取文件信息
|
|
|
const chat_id = chat_new_id.value;
|
|
const chat_id = chat_new_id.value;
|
|
|
|
|
|