Skip to content

Commit 8033f9d

Browse files
committed
feat: chat select datasource
1 parent 26455cd commit 8033f9d

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

frontend/src/views/chat/WelcomeBlock.vue

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import {ChatInfo} from "@/api/chat.ts";
44
import {computed, onMounted, ref} from "vue";
55
import {datasourceApi} from "@/api/datasource.ts";
66
import DatasourceItemCard from '../ds/DatasourceItemCard.vue'
7-
import { useI18n } from 'vue-i18n'
8-
const { t } = useI18n()
7+
import {useI18n} from 'vue-i18n'
8+
9+
const {t} = useI18n()
910
const props = withDefaults(defineProps<{
1011
modelValue?: number
1112
currentChat: ChatInfo
@@ -50,9 +51,27 @@ function listDs() {
5051
})
5152
}
5253
54+
const dialogVisible = ref(false)
55+
56+
const DatasourceListRef = ref()
57+
58+
const innerDs = ref()
59+
5360
function showDs() {
61+
innerDs.value = props.modelValue
5462
listDs()
63+
dialogVisible.value = true
64+
}
65+
66+
function selectDsInDialog(ds: any) {
67+
innerDs.value = ds.id
68+
}
5569
70+
function comfirmSelectDs() {
71+
if (innerDs.value) {
72+
emits("update:modelValue", innerDs.value)
73+
dialogVisible.value = false
74+
}
5675
}
5776
5877
@@ -75,7 +94,7 @@ onMounted(() => {
7594
</div>
7695
<div class="ds-row-container">
7796
<template v-for="(item, _index) in dsList" :key="_index">
78-
<DatasourceItemCard :ds="item" @click="selectDs(item)"
97+
<DatasourceItemCard :ds="item" @click="selectDs(item)" v-if="_index<3 || item?.id===modelValue"
7998
class="ds-card" :class="[item?.id===modelValue? 'ds-card-selected': '']"/>
8099
</template>
81100
</div>
@@ -93,6 +112,28 @@ onMounted(() => {
93112
</div>
94113
</template>
95114
</div>
115+
116+
117+
<el-drawer v-model="dialogVisible" title="Choose Datasource" width="800" ref="DatasourceListRef" direction="btt"
118+
size="100%">
119+
<el-scrollbar>
120+
<div class="ds-row-container">
121+
<template v-for="(item, _index) in dsList" :key="_index">
122+
<DatasourceItemCard :ds="item" @click="selectDsInDialog(item)"
123+
class="ds-card" :class="[item?.id===innerDs? 'ds-card-selected': '']"/>
124+
</template>
125+
</div>
126+
</el-scrollbar>
127+
<template #footer>
128+
<div class="dialog-footer">
129+
<el-button @click="dialogVisible = false">Cancel</el-button>
130+
<el-button type="primary" @click="comfirmSelectDs">
131+
Confirm
132+
</el-button>
133+
</div>
134+
</template>
135+
</el-drawer>
136+
96137
</ChatBlock>
97138
</template>
98139

@@ -126,6 +167,7 @@ onMounted(() => {
126167
127168
.ds-card-selected {
128169
box-shadow: 0 1px 3px var(--ed-color-primary-light-5);
170+
border: 1px solid var(--ed-color-primary-light-5);
129171
}
130172
131173

0 commit comments

Comments
 (0)