vue2-client 1.9.73 → 1.9.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/base-client/components/common/XConversation/XConversation.vue +140 -0
- package/src/base-client/components/common/XConversation/XConversationDemo.vue +28 -0
- package/src/base-client/components/common/XForm/XFormItem.vue +1 -1
- package/src/router/async/router.map.js +3 -1
package/package.json
CHANGED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div class="chat-container" v-if="loading">
|
|
4
|
+
<!-- 对话展示区域 -->
|
|
5
|
+
<div class="chat-content">
|
|
6
|
+
<div
|
|
7
|
+
v-for="(message, index) in messages"
|
|
8
|
+
:key="index"
|
|
9
|
+
:class="['chat-message', message.type]"
|
|
10
|
+
>
|
|
11
|
+
<span class="chat-avatar">{{ message.type === 'user' ? '👤' : '🤖' }}</span>
|
|
12
|
+
<div class="chat-text">{{ message.text }}</div>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<!-- 输入框和发送按钮 -->
|
|
17
|
+
<div class="chat-input">
|
|
18
|
+
<a-input
|
|
19
|
+
v-model="inputMessage"
|
|
20
|
+
placeholder="Type your message..."
|
|
21
|
+
@pressEnter="sendMessage"
|
|
22
|
+
/>
|
|
23
|
+
<a-button type="primary" @click="sendMessage">Send</a-button>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
<a-spin :spinning="!loading" />
|
|
27
|
+
</div>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script>
|
|
31
|
+
import { runLogic } from '@vue2-client/services/api/common'
|
|
32
|
+
export default {
|
|
33
|
+
data () {
|
|
34
|
+
return {
|
|
35
|
+
serviceName: undefined,
|
|
36
|
+
// 组件加载状态
|
|
37
|
+
loading: false,
|
|
38
|
+
// 配置内容
|
|
39
|
+
renderConfig: undefined,
|
|
40
|
+
inputMessage: '', // 用户输入的内容
|
|
41
|
+
additionalInfo: {},
|
|
42
|
+
messages: [ // 消息列表
|
|
43
|
+
{ type: 'bot', text: 'Hello! How can I assist you today?' },
|
|
44
|
+
],
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
methods: {
|
|
48
|
+
setAddtionalInfo (params) {
|
|
49
|
+
this.additionalInfo = params
|
|
50
|
+
},
|
|
51
|
+
init (params) {
|
|
52
|
+
const {
|
|
53
|
+
serviceName,
|
|
54
|
+
// 配置内容
|
|
55
|
+
value
|
|
56
|
+
} = params
|
|
57
|
+
this.renderConfig = value
|
|
58
|
+
this.loading = true
|
|
59
|
+
this.serviceName = serviceName
|
|
60
|
+
},
|
|
61
|
+
async sendMessage () {
|
|
62
|
+
if (!this.inputMessage.trim()) return
|
|
63
|
+
|
|
64
|
+
// 添加用户消息
|
|
65
|
+
this.messages.push({ type: 'user', text: this.inputMessage })
|
|
66
|
+
|
|
67
|
+
// 清空输入框
|
|
68
|
+
const userMessage = this.inputMessage
|
|
69
|
+
this.inputMessage = ''
|
|
70
|
+
|
|
71
|
+
// 模拟机器人的回复
|
|
72
|
+
const response = await runLogic(this.renderConfig.logicName, {
|
|
73
|
+
question: userMessage,
|
|
74
|
+
additionalInfo: this.additionalInfo
|
|
75
|
+
}, this.serviceName)
|
|
76
|
+
this.messages.push({ type: 'bot', text: response })
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<style scoped>
|
|
83
|
+
.chat-container {
|
|
84
|
+
display: flex;
|
|
85
|
+
flex-direction: column;
|
|
86
|
+
height: 500px;
|
|
87
|
+
border: 1px solid #d9d9d9;
|
|
88
|
+
border-radius: 4px;
|
|
89
|
+
overflow: hidden;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.chat-content {
|
|
93
|
+
flex: 1;
|
|
94
|
+
padding: 16px;
|
|
95
|
+
overflow-y: auto;
|
|
96
|
+
background: #f5f5f5;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.chat-message {
|
|
100
|
+
display: flex;
|
|
101
|
+
align-items: flex-start;
|
|
102
|
+
margin-bottom: 10px;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.chat-message.user {
|
|
106
|
+
justify-content: flex-end;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.chat-message.bot {
|
|
110
|
+
justify-content: flex-start;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.chat-avatar {
|
|
114
|
+
margin: 0 8px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.chat-text {
|
|
118
|
+
max-width: 70%;
|
|
119
|
+
padding: 8px 12px;
|
|
120
|
+
border-radius: 4px;
|
|
121
|
+
background-color: #fff;
|
|
122
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.chat-message.user .chat-text {
|
|
126
|
+
background-color: #e6f7ff;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.chat-input {
|
|
130
|
+
display: flex;
|
|
131
|
+
padding: 8px;
|
|
132
|
+
background: #fff;
|
|
133
|
+
border-top: 1px solid #d9d9d9;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.chat-input a-input {
|
|
137
|
+
flex: 1;
|
|
138
|
+
margin-right: 8px;
|
|
139
|
+
}
|
|
140
|
+
</style>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<h1>对话示例</h1>
|
|
4
|
+
<XConversation ref="XConversation"/>
|
|
5
|
+
</div>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
import XConversation from './XConversation.vue' // 请根据实际路径调整
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
name: 'ConversationDemo',
|
|
13
|
+
components: {
|
|
14
|
+
XConversation
|
|
15
|
+
},
|
|
16
|
+
mounted () {
|
|
17
|
+
this.$refs.XConversation.init({
|
|
18
|
+
value: { logicName: 'submitMessage' },
|
|
19
|
+
serviceName: 'af-his'
|
|
20
|
+
})
|
|
21
|
+
this.$refs.XConversation.setAddtionalInfo({ patient_id: 37 })
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<style scoped>
|
|
27
|
+
/* 这里可以添加你的样式 */
|
|
28
|
+
</style>
|
|
@@ -642,7 +642,7 @@ export default {
|
|
|
642
642
|
name: 'XFormItem',
|
|
643
643
|
components: {
|
|
644
644
|
XFormTable: () => import('@vue2-client/base-client/components/common/XFormTable/XFormTable.vue'),
|
|
645
|
-
Recoding: () => import('@vue2-client/base-client/components/common/Recoding'),
|
|
645
|
+
Recoding: () => import('@vue2-client/base-client/components/common/Recording/Recoding.vue'),
|
|
646
646
|
XLicensePlate,
|
|
647
647
|
XTreeSelect,
|
|
648
648
|
XFormCol,
|
|
@@ -85,11 +85,13 @@ routerResource.example = {
|
|
|
85
85
|
name: '示例页面',
|
|
86
86
|
// component: () => import('@vue2-client/base-client/components/common/XAddNativeForm/demo.vue'),
|
|
87
87
|
// component: () => import('@vue2-client/base-client/components/common/XFormGroup/demo.vue'),
|
|
88
|
+
// component: () => import('@vue2-client/base-client/components/common/XFormGroup/demo.vue'),
|
|
88
89
|
// component: () => import('@vue2-client/base-client/components/common/XReport/XReportDemo.vue'),
|
|
89
|
-
component: () => import('@vue2-client/base-client/components/common/XFormTable/demo.vue'),
|
|
90
|
+
// component: () => import('@vue2-client/base-client/components/common/XFormTable/demo.vue'),
|
|
90
91
|
// component: () => import('@vue2-client/base-client/components/common/XTab/XTabDemo.vue'),
|
|
91
92
|
// component: () => import('@vue2-client/base-client/components/common/XReportGrid/XReportDemo.vue'),
|
|
92
93
|
// component: () => import('@vue2-client/pages/WorkflowDetail/WorkFlowDemo.vue'),
|
|
94
|
+
component: () => import('@vue2-client/base-client/components/common/XConversation/XConversationDemo.vue'),
|
|
93
95
|
// component: () => import('@vue2-client/base-client/components/common/XButtons/XButtonDemo.vue'),
|
|
94
96
|
meta: {
|
|
95
97
|
// 菜单中不显示
|