suerprisePlus
2024-08-14 d4a3ca549f8755c2f87442c27217c3be39cab5cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<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,
            filieOption: [],
            loading: false,
            upMsg: "",
        }
    },
    props: {
        childObject: {
            type: Object,
            required: true
        }
    },
    watch: {
        childObject: {
            handler(newVal, oldVal) {
                if (newVal) {
                    this.setTextMsg(newVal)
                }
            },
            deep: true,
            immediate: true
        }
    },
    methods: {
        setTextMsg(res) {
            if (!res.msg) return
            this.id = res.id
            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 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>