|
|
@@ -1,60 +1,29 @@
|
|
|
<script setup lang="ts">
|
|
|
import { ref } from 'vue';
|
|
|
-import FileUpload from './FileUpload.vue';
|
|
|
|
|
|
-const { value } = defineProps(['value']);
|
|
|
+const { value: inputValue } = defineProps(['value']);
|
|
|
const emit = defineEmits(['submit', 'update:value']);
|
|
|
|
|
|
-const uploadRef = ref();
|
|
|
-const inputFootIcons = [
|
|
|
- { icon: 'icon-at', text: '智能体' },
|
|
|
- { icon: 'icon-standard', text: '词库' },
|
|
|
- { icon: 'icon-add', text: '附件' },
|
|
|
-];
|
|
|
-
|
|
|
-const handleUpload = () => {
|
|
|
- const input = document.createElement('input');
|
|
|
- input.type = 'file';
|
|
|
- input.multiple = true;
|
|
|
- input.onchange = (e: Event) => {
|
|
|
- const files = (e.target as HTMLInputElement).files;
|
|
|
- if (files) {
|
|
|
- uploadRef.value.handleFiles(files);
|
|
|
- }
|
|
|
- };
|
|
|
- input.click();
|
|
|
-};
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
- <FileUpload ref="uploadRef">
|
|
|
<McInput
|
|
|
- :value="value"
|
|
|
+ :value="inputValue"
|
|
|
:maxLength="2000"
|
|
|
- @change="(value: string) => emit('update:value', value)"
|
|
|
- @submit="emit('submit', value)"
|
|
|
+ @change="(newValue: string) => emit('update:value', newValue)"
|
|
|
+ @submit="emit('submit', inputValue)"
|
|
|
>
|
|
|
<template #extra>
|
|
|
<div class="input-foot-wrapper">
|
|
|
<div class="input-foot-left">
|
|
|
- <span v-for="(item, index) in inputFootIcons" :key="index">
|
|
|
- <i
|
|
|
- v-if="item.icon === 'icon-add'"
|
|
|
- :class="item.icon"
|
|
|
- @click="handleUpload"
|
|
|
- style="cursor: pointer"
|
|
|
- ></i>
|
|
|
- <i v-else :class="item.icon"></i>
|
|
|
- {{ item.text }}
|
|
|
- </span>
|
|
|
<span class="input-foot-dividing-line"></span>
|
|
|
- <span class="input-foot-maxlength">{{ value.length }}/2000</span>
|
|
|
+ <span class="input-foot-maxlength">{{ inputValue.length }}/2000</span>
|
|
|
</div>
|
|
|
<div class="input-foot-right">
|
|
|
<d-button
|
|
|
icon="op-clearup"
|
|
|
shape="round"
|
|
|
- :disabled="!value"
|
|
|
+ :disabled="!inputValue"
|
|
|
@click="emit('update:value', '')"
|
|
|
>
|
|
|
清空输入
|
|
|
@@ -63,5 +32,4 @@ const handleUpload = () => {
|
|
|
</div>
|
|
|
</template>
|
|
|
</McInput>
|
|
|
- </FileUpload>
|
|
|
-</template>
|
|
|
+</template>
|