wujingjing
2025-04-07 457cc6cf166d3b6c22be4f78c1db8802a7fbb4c7
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<template>
    <div class="pc-detail w100 h100 box-border">
        <div class="w100 h100 grid box-border set-body">
            <div class="left">
                <div class="p-[32px]">
                    <div class="flex justify-between items-center">
                        <div class="flex items-center">
                            <i class="ywifont ywicon-gongzuozongjie text-[#1c86ff]" style="font-size: 20px !important"></i>
                            <span class="text-[14px] text-[#000] leading-5 ml-1">{{ state.select_name ? state.select_name : '' }}</span>
                        </div>
                        <!-- <el-select v-model="state.seriesModel" placeholder="请选择" size="large" @change="handleModelChange">
                            <el-option v-for="item in state.modelOptionList" :key="item.id" :label="item.title" :value="item.id" />
                        </el-select> -->
                    </div>
                    <div class="pt-[30px]">
                        <el-form
                            ref="modelFormRef"
                            :model="state.modelForm"
                            :rules="modelRules"
                            label-width="auto"
                            class="custom-form"
                            label-position="top"
                            status-icon
                            size="large"
                        >
                            <el-form-item label="主题" prop="theme">
                                <el-input v-model="state.modelForm.theme" clearable />
                            </el-form-item>
                            <el-form-item label="类型" prop="modelType">
                                <el-select
                                    v-model="state.modelForm.modelType"
                                    placeholder="请选择类型"
                                    popper-class="custom-select-style"
                                    :teleported="false"
                                >
                                    <el-option v-for="item in state.modelTypeList" :key="item.ID" :label="item.Name" :value="item.Name"> </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="补充内容" prop="supplementContenT">
                                <el-input v-model="state.modelForm.supplementContenT" type="textarea" :rows="6" />
                            </el-form-item>
                            <div class="pt-[60px] text-right">
                                <el-button type="primary" @click="handleSubmit" size="large">立即生成</el-button>
                            </div>
                        </el-form>
                    </div>
                </div>
            </div>
            <div class="right" v-loading="state.contentLoading">
                <div class="top">
                    <div class="left">
                        <i></i>
                        <span>{{ state.select_name ? state.select_name : '' }}总结</span>
                    </div>
                </div>
                <div class="output">
                    <p class="placeholder">{{ state.workContent }}</p>
                </div>
            </div>
        </div>
    </div>
</template>
 
<script setup lang="ts">
import type { FormRules } from 'element-plus';
import { onMounted, reactive, ref } from 'vue';
import { useRoute } from 'vue-router';
import { QuestionWorkAi, getBigModelList } from '/@/api/ai/chat';
import { activeRoomId, activeSectionAId } from '/@/stores/chatRoom';
let state = reactive({
    seriesModel: '',
    modelOptionList: [],
    modelForm: {
        theme: '',
        modelType: '',
        supplementContenT: '',
    },
    modelTypeList: [
        {
            ID: 1,
            Name: '日总结',
        },
        {
            ID: 2,
            Name: '周总结',
        },
        {
            ID: 3,
            Name: '月度总结',
        },
        {
            ID: 4,
            Name: '部门总结',
        },
    ],
    workContent: '在左侧输入内容并提交,将自动为您生成工作总结',
    llm_id: '',
    select_question: null,
    select_name: null,
    contentLoading: false,
});
const modelRules = reactive<FormRules>({
    theme: [{ required: true, message: '必填项', trigger: 'blur' }],
    supplementContenT: [{ required: true, message: '必填项', trigger: 'blur' }],
    modelType: [{ required: true, message: '必填项', trigger: 'change' }],
});
const modelFormRef = ref(null);
//获取大模型列表
const getModelList = async () => {
    const res = await getBigModelList();
    state.modelOptionList = res.llm_list || [];
};
//切换模型
const handleModelChange = async (val: string) => {
    state.llm_id = val;
};
//立即生成
const handleSubmit = async () => {
    const valid = await modelFormRef.value.validate().catch(() => {});
    if (!valid) return;
    state.contentLoading = true;
    const res = await QuestionWorkAi({
        section_a_id: activeSectionAId.value, //当前问题对应的主场景
        sample_id: '', //当前问题对应的sample_id(可不填或为空)
        llm_id: state.llm_id ? state.llm_id : '', //当前问题对应的llm_id(不填则用缺省llm)
        history_group_id: activeRoomId.value, //当前问题对应的history group id
        raw_mode: true, //是否直接调用大模型回答问题(不填为false)
        question: state.select_question, //提出的问题
    }).finally(() => {
        state.contentLoading = false;
    });
    state.workContent = res.answer;
};
onMounted(() => {
    const route = useRoute();
    const pathInfo = route.query;
    activeSectionAId.value = pathInfo.ID;
    state.select_question = pathInfo.Title;
    state.select_name = pathInfo.Name;
    getModelList();
});
</script>
<style scoped lang="scss">
.pc-detail {
    padding: 74px 32px 42px;
    font-size: 14px;
    font-family: var(--fontFamily);
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    position: relative;
    .set-body {
        grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
        grid-template-rows: minmax(0, 1fr);
        column-gap: 20px;
        .left {
            text-align: center;
            height: 100%;
            background-color: #fff;
            border-radius: 8px;
            overflow-y: auto;
            box-shadow: 0 0 1px rgba(0, 0, 0, 0.16);
            .model_right {
                min-width: 230px;
                height: 36px;
                border-radius: 8px;
                border: 1px solid #d8dae5;
                display: flex;
                align-items: center;
                justify-content: center;
                cursor: pointer;
            }
        }
        .right {
            height: 100%;
            background-color: #fff;
            box-shadow: 0 0 1px rgba(0, 0, 0, 0.16);
            border-radius: 8px;
            .top {
                margin: 0 32px;
                display: flex;
                justify-content: space-between;
                padding: 32px 0;
                .left {
                    display: flex;
                    align-items: center;
                    i {
                        width: 4px;
                        height: 14px;
                        background: #1c86ff;
                        border-radius: 0 100px 100px 0;
                        margin-right: 10px;
                    }
                }
            }
            .output {
                box-sizing: border-box;
                height: calc(100% - 132px);
                max-height: calc(100% - 132px);
                overflow-y: auto;
                padding: 10px;
                line-height: 25px;
                border-radius: 10px;
                background: #fff;
                border: 1px solid #eee;
                position: relative;
                margin: 0 32px;
                .placeholder {
                    position: absolute;
                    top: 12px;
                    left: 12px;
                    z-index: 10;
                    font-size: 14px;
                    color: #838383;
                }
            }
        }
    }
}
:deep(.el-select-dropdown__list) {
    max-width: 700px !important;
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.custom-select-style .el-select-dropdown__item {
    height: 32px;
    background: #eaf4ff;
    border-radius: 8px;
    margin: 5px;
    font-size: 14px;
    padding: 0 20px;
}
.custom-select-style .el-select-dropdown__item.selected {
    color: #409eff !important;
    font-weight: 700;
}
</style>