feat: 增加凌源白灰线内容
This commit is contained in:
parent
bac9fcb414
commit
3ed7c5f9b1
|
@ -567,6 +567,16 @@ const routes = [
|
|||
},
|
||||
component: "enm_coal/report",
|
||||
},
|
||||
{
|
||||
name: "coal_report_bh",
|
||||
path: "/enm_coal/report_bh",
|
||||
meta: {
|
||||
title: "生产报告",
|
||||
// icon: "el-icon-document",
|
||||
perms: ["enm_coal"],
|
||||
},
|
||||
component: "enm_coal/report_bh",
|
||||
},
|
||||
{
|
||||
name: "coal_power",
|
||||
path: "/enm_coal/power",
|
||||
|
@ -756,6 +766,16 @@ const routes = [
|
|||
},
|
||||
component: "enm_kilnbase/report",
|
||||
},
|
||||
{
|
||||
name: "kilnbase_report_lybh",
|
||||
path: "/enm_kilnbase/report_lybh",
|
||||
meta: {
|
||||
title: "生产报告",
|
||||
// icon: "el-icon-document",
|
||||
perms: ["enm_kilnbase"],
|
||||
},
|
||||
component: "enm_kilnbase/report_lybh",
|
||||
},
|
||||
{
|
||||
name: "kilnbase_power",
|
||||
path: "/enm_kilnbase/power",
|
||||
|
@ -3271,6 +3291,18 @@ const routes = [
|
|||
},
|
||||
component: "bigScreen/index_enm_ly",
|
||||
},
|
||||
//凌源白灰线大屏
|
||||
{
|
||||
path: "/bigScreenly_bh",
|
||||
name: "bigScreenly_bh",
|
||||
meta: {
|
||||
title: "数智大屏",
|
||||
icon: "el-icon-platform",
|
||||
perms: ["bigScreenly"],
|
||||
fullpage: true,
|
||||
},
|
||||
component: "bigScreen/index_enm_bh",
|
||||
},
|
||||
//光子科技——数据大屏
|
||||
{
|
||||
path: "/bigScreenP",
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -238,6 +238,7 @@ export default {
|
|||
{ label: "班天", value: "day_s" },
|
||||
{ label: "班月", value: "month_s" },
|
||||
{ label: "班时", value: "hour_s"},
|
||||
{ label: "小时", value: "hour"},
|
||||
{ label: "天", value: "day" },
|
||||
{ label: "月", value: "month"},
|
||||
],
|
||||
|
|
|
@ -0,0 +1,150 @@
|
|||
<template>
|
||||
<div class="chat-window">
|
||||
<div class="messages" ref="messageList">
|
||||
<div v-for="(msg, index) in messages" :key="index" :class="msg.role">
|
||||
<strong>{{ msg.role === 'user' ? '你' : '助手' }}:</strong>
|
||||
<span>{{ msg.content }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-box">
|
||||
<textarea
|
||||
v-model="input"
|
||||
@keydown.enter.prevent="handleSend"
|
||||
placeholder="请输入..."
|
||||
/>
|
||||
<button @click="handleSend" :disabled="loading">发送</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
messages: [],
|
||||
input: '',
|
||||
loading: false,
|
||||
eventSource: null,
|
||||
conversationId: '3841325303385792512'
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
conversationId: {
|
||||
immediate: true,
|
||||
handler() {
|
||||
this.messages = []; // 如果你有加载历史消息,可以在此请求
|
||||
this.closeStream();
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async handleSend() {
|
||||
if (!this.input.trim()) return;
|
||||
this.loading = true;
|
||||
|
||||
// 添加用户消息
|
||||
const userMessage = { role: 'user', content: this.input };
|
||||
this.messages.push(userMessage);
|
||||
|
||||
// 添加助手消息框架
|
||||
const assistantMessage = { role: 'assistant', content: '' };
|
||||
this.messages.push(assistantMessage);
|
||||
|
||||
const message = encodeURIComponent(this.input);
|
||||
const url = `/api/ichat/message/completion/`;
|
||||
const payload = {
|
||||
conversation: this.conversationId,
|
||||
message: message
|
||||
}
|
||||
this.input = '';
|
||||
this.scrollToBottom();
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/ichat/message/completion/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
// 更新 assistant 内容
|
||||
assistantMessage.content = result.answer || '';
|
||||
|
||||
// 保存 conversation_id(首次发送消息时获取)
|
||||
if (!this.conversationId && result.conversation_id) {
|
||||
this.conversationId = result.conversation_id;
|
||||
}
|
||||
|
||||
this.scrollToBottom();
|
||||
} else {
|
||||
throw new Error(result.detail || '请求失败');
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('发送失败:', err);
|
||||
assistantMessage.content = '[助手响应失败,请稍后再试]';
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
scrollToBottom() {
|
||||
this.$nextTick(() => {
|
||||
const el = this.$refs.messageList;
|
||||
if (el) el.scrollTop = el.scrollHeight;
|
||||
});
|
||||
},
|
||||
closeStream() {
|
||||
if (this.eventSource) {
|
||||
this.eventSource.close();
|
||||
this.eventSource = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.closeStream();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.chat-window {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
padding: 10px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.messages {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
.user, .assistant {
|
||||
margin-bottom: 10px;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.input-box {
|
||||
display: flex;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
textarea {
|
||||
flex: 1;
|
||||
resize: none;
|
||||
height: 60px;
|
||||
padding: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
button {
|
||||
margin-left: 10px;
|
||||
padding: 0 16px;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue