refactor(page): support multiple chat

This commit is contained in:
qianmoQ 2024-11-17 16:13:15 +08:00
parent f7f385b777
commit a47b315737
2 changed files with 25 additions and 21 deletions

View File

@ -9,7 +9,7 @@
<ShadcnSpin v-model="loading" fixed/> <ShadcnSpin v-model="loading" fixed/>
<div v-if="!loading" class="p-2"> <div v-if="!loading" class="p-2">
<ShadcnToggleGroup v-model="report"> <ShadcnToggleGroup v-model="report" multiple>
<ShadcnRow gutter="8"> <ShadcnRow gutter="8">
<ShadcnCol v-for="item of data" span="4"> <ShadcnCol v-for="item of data" span="4">
<ShadcnToggle :key="item.id" class="px-1 py-1" :value="item.id"> <ShadcnToggle :key="item.id" class="px-1 py-1" :value="item.id">
@ -111,7 +111,7 @@ export default defineComponent({
return { return {
loading: false, loading: false,
data: [] as ReportModel[], data: [] as ReportModel[],
report: '', report: [] as any[],
pageIndex: 1, pageIndex: 1,
pageSize: 10, pageSize: 10,
dataCount: 0 dataCount: 0
@ -157,8 +157,10 @@ export default defineComponent({
}, },
onSubmit() onSubmit()
{ {
const node = this.data.find(item => item.id === toNumber(this.report[0])) const nodes = this.data.filter(item =>
this.$emit('change', node) this.report.some((reportId: number) => toNumber(item.id) === toNumber(reportId))
)
this.$emit('change', nodes)
this.onCancel() this.onCancel()
}, },

View File

@ -208,24 +208,26 @@ export default defineComponent({
} }
}) })
}, },
onChange(node: ReportModel) onChange(nodes: ReportModel[])
{ {
const newItem = { nodes.forEach((node: ReportModel) => {
x: 0, const newItem = {
y: 0, x: 0,
w: 3, y: 0,
h: 4, w: 3,
i: 'new-' + Date.now(), h: 4,
title: node.name, i: 'new-' + Date.now(),
node: { title: node.name,
id: node.id, node: {
configure: node.configure, id: node.id,
code: node.dataset?.code, configure: node.configure,
query: node?.query code: node.dataset?.code,
}, query: node?.query
original: node },
} original: node
this.layouts.push(newItem) }
this.layouts.push(newItem)
})
}, },
onSubmit() onSubmit()
{ {