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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<template>
    <div class="enterBox">
 
        <input type="file" @change="setInputFileChange" multiple accept=".docx,.txt" id="insertFile" style="display:none">
        <div class="enterContent">
            <el-input type="textarea" :rows="rows" maxRows="4" placeholder="请输入您的问题..." v-model="msgContent"
                maxlength="4000" @keyup="onKeyup">
            </el-input>
            <el-link @click="setInutFile" :underline="false" title="文件上传" style="font-size: 20px; margin:0px 16px">
                <i class="el-icon-folder"></i>
            </el-link>
            <el-link @click="sendMessage" :underline="false" title="发送">
                <i class="el-icon-position" style="font-size: 20px;"></i>
            </el-link>
        </div>
 
    </div>
</template>
 
<script>
export default {
    data() {
        return {
            msgContent: null,
            rows: 1,
        }
    },
    mounted() {
        this.initEnterStart();
    },
    methods: {
        initEnterStart() {
            this.msgContent = null;
        },
        sendMessage() {
            if (!this.msgContent) return
 
            this.$emit('sendmsg', {
                type: 'text',
                val: this.msgContent
            });
            this.$nextTick(() => {
                this.msgContent = null;
                this.rows = 1
            })
        },
        onKeyup(e) {
 
            if (e.keyCode === 13) {
                this.sendMessage()
            }
        },
        setInutFile() {
            document.getElementById('insertFile').click();
        },
        setInputFileChange() {
            const fs = document.getElementById('insertFile');
            if (fs.files.length <= 0) return;
            const std = [];
            for (var i = 0, c = fs.files.length; i < c; i++) {
                std.push({
                    name: fs.files[i].name
                });
            }
            this.$emit('sendmsg', {
                type: 'insertFile',
                val: std
            });
          
        },
    }
}
</script>
 
<style lang="scss" scoped>
.enterBox {
    width: 100%;
    height: calc(100% - 10px);
 
    border-radius: 5px;
    // border: 3px solid #e7e7e7;
    margin-top: 10px;
    padding: 10px 10px;
    display: flex;
    justify-content: center;
 
    .enterContent {
        width: 70%;
        padding: 6px 10px;
        border: 1px solid #ccc;
        border-radius: 5px;
        display: flex;
 
 
    }
 
 
 
    .emoji {
        width: 20px;
        height: 20px;
        margin-left: 10px;
        margin-bottom: 5px;
    }
 
    .enterButton {
        width: 100%;
        display: flex;
        justify-content: flex-end;
    }
 
    ::v-deep .el-textarea__inner {
        border: 1px solid rgba(255, 255, 255, 0) !important;
        resize: none !important;
        overflow: auto;
        -ms-overflow-style: none;
        /* IE 和 Edge */
        scrollbar-width: none;
    }
 
}
</style>