suerprisePlus
2024-08-14 d4a3ca549f8755c2f87442c27217c3be39cab5cc
src/views/dataManager/semanticFunction/child/agentInsertFile.vue
@@ -1,27 +1,36 @@
<template>
    <div :id="msgId" class="textBox">
        <div v-loading="loading" element-loading-text="数据上传中..." element-loading-spinner="el-icon-loading"
            element-loading-background="rgba(0, 0, 0, 0.6)" class="fileBox" v-for="(item, index) in filieOption"
            :key="index">
            <span>{{ item.name }}</span><span class="upMsg">
                {{ upMsg }}
            </span>
        </div>
    </div>
</template>
<script>
import { rag_chat, rag_search, rag_upload } from "@/api/mapView/rag.js";
export default {
    data() {
        return {
            msgId: null,
            msgText: '',
            filieOption: [],
            loading: false,
            upMsg: "",
        }
    },
    props: {
        childObject: {
            type: Array,
            type: Object,
            required: true
        }
    },
    watch: {
        childObject: {
            handler(newVal, oldVal) {
                if (newVal) {
                    console.log(newVal);
                    this.setTextMsg(newVal)
                }
            },
@@ -31,11 +40,57 @@
    },
    methods: {
        setTextMsg(res) {
            if (!res.msg) return
            this.id = res.id
            console.log("insertFile", msg);
            this.filieOption = res.msg;
            this.$nextTick(() => {
                this.loading = true;
                this.setInsertFile()
            })
        },
        setInsertFile() {
            const fs = document.getElementById("insertFile")
            if (fs.files.length <= 0) return;
            const formData = new FormData();
            for (var i = 0, c = fs.files.length; i < c; i++) {
                formData.append("file", fs.files[i]); // fs.files[i].name,file
            }
            rag_upload(formData).then(response => {
                this.loading = false
                document.getElementById('insertFile').value = ""
                if (response.data == 'success') {
                    this.upMsg = "上传成功"
                } else {
                    this.upMsg = "上传失败"
                }
            })
        }
    }
}
</script>
<style></style>
<style lang="scss" scoped>
.textBox {
    padding-top: 10px;
}
.fileBox {
    background: white;
    padding: 10px;
    margin-bottom: 10px;
    min-width: 300px;
    min-height: 70px;
    display: flex;
    align-items: center;
    border-radius: 5px;
    justify-content: space-between;
    .upMsg {
        font-size: 12px;
        color: #1890ff;
    }
}
</style>