Skip to content

Commit 30fc652

Browse files
committed
feat(Data Source): Supports batch uploading of data tables (Note)
1 parent 417c594 commit 30fc652

File tree

7 files changed

+415
-8
lines changed

7 files changed

+415
-8
lines changed

frontend/src/api/datasource.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@ export const datasourceApi = {
2727
cancelRequests: () => request.cancelRequests(),
2828
getSchema: (data: any) => request.post('/datasource/getSchemaByConf', data),
2929
syncFields: (id: number) => request.post(`/datasource/syncFields/${id}`),
30+
exportDsSchema: (id: any) =>
31+
request.get(`/datasource/exportDsSchema/${id}`, {
32+
responseType: 'blob',
33+
requestOptions: { customError: true },
34+
}),
3035
}
Lines changed: 3 additions & 0 deletions
Loading

frontend/src/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"Details": "Details"
99
},
1010
"parameter": {
11+
"memo": "Memo update rules: Match table name and field name. If a match is found, update the table memo and field memo; otherwise, leave the memo unchanged.",
1112
"parameter_configuration": "Parameter Config",
1213
"question_count_settings": "Question Count Settings",
1314
"model_thinking_process": "Expand Model Thinking Process",

frontend/src/i18n/ko-KR.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"Details": "세부"
99
},
1010
"parameter": {
11+
"memo": "메모 업데이트 규칙: 테이블 이름과 필드 이름이 일치하는지 확인합니다. 일치하는 항목이 있으면 테이블 메모와 필드 메모를 업데이트하고, 그렇지 않으면 메모를 변경하지 않고 그대로 둡니다.",
1112
"parameter_configuration": "매개변수 구성",
1213
"question_count_settings": "질문 수 설정",
1314
"model_thinking_process": "모델 사고 프로세스 확장",
@@ -819,4 +820,4 @@
819820
"modelType": {
820821
"llm": "대형 언어 모델"
821822
}
822-
}
823+
}

frontend/src/i18n/zh-CN.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"Details": "详情"
99
},
1010
"parameter": {
11+
"memo": "备注更新规则:根据表名和字段名匹配,如果匹配则更新表备注和字段备注;如果匹配不上,备注保持不变。",
1112
"parameter_configuration": "参数配置",
1213
"question_count_settings": "问数设置",
1314
"model_thinking_process": "展开模型思考过程",
@@ -140,7 +141,7 @@
140141
"click_to_select_file": "点击选择文件",
141142
"upload_hint_first": "",
142143
"upload_hint_download_template": "下载模板",
143-
"upload_hint_end": ",按要求填写后上传",
144+
"upload_hint_end": ",按要求填写后上传",
144145
"continue_to_upload": "继续导入",
145146
"reset_password": "重置密码",
146147
"password_reset_successful": "重置密码成功",

frontend/src/views/ds/DataTable.vue

Lines changed: 79 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@ import { ref, computed, onMounted, reactive } from 'vue'
33
import { datasourceApi } from '@/api/datasource'
44
import icon_right_outlined from '@/assets/svg/icon_right_outlined.svg'
55
import icon_form_outlined from '@/assets/svg/icon_form_outlined.svg'
6+
import icon_import_outlined from '@/assets/svg/icon_import_outlined.svg'
67
import icon_searchOutline_outlined from '@/assets/svg/icon_search-outline_outlined.svg'
78
import EmptyBackground from '@/views/dashboard/common/EmptyBackground.vue'
89
import edit from '@/assets/svg/icon_edit_outlined.svg'
910
import { useI18n } from 'vue-i18n'
1011
import ParamsForm from './ParamsForm.vue'
12+
import UploaderRemark from '@/views/system/excel-upload/UploaderRemark.vue'
1113
import TableRelationship from '@/views/ds/TableRelationship.vue'
1214
import icon_mindnote_outlined from '@/assets/svg/icon_mindnote_outlined.svg'
1315
import { Refresh } from '@element-plus/icons-vue'
16+
1417
interface Table {
1518
name: string
1619
host: string
@@ -106,17 +109,29 @@ const fieldListComputed = computed(() => {
106109
return fieldList.value.slice((currentPage - 1) * pageSize, currentPage * pageSize)
107110
})
108111
109-
const init = () => {
112+
const init = (reset = false) => {
110113
initLoading.value = true
111114
datasourceApi.getDs(props.info.id).then((res) => {
112115
ds.value = res
113116
fieldList.value = []
114117
pageInfo.total = 0
115118
pageInfo.currentPage = 1
116-
datasourceApi.tableList(props.info.id).then((res) => {
117-
tableList.value = res
118-
initLoading.value = false
119-
})
119+
datasourceApi
120+
.tableList(props.info.id)
121+
.then((res) => {
122+
tableList.value = res
123+
124+
if (currentTable.value?.id && reset) {
125+
tableList.value.forEach((ele) => {
126+
if (ele.id === currentTable.value?.id) {
127+
clickTable(ele)
128+
}
129+
})
130+
}
131+
})
132+
.finally(() => {
133+
initLoading.value = false
134+
})
120135
})
121136
}
122137
onMounted(() => {
@@ -237,6 +252,47 @@ const syncFields = () => {
237252
})
238253
}
239254
255+
function downloadTemplate() {
256+
datasourceApi
257+
.exportDsSchema(props.info.id)
258+
.then((res) => {
259+
const blob = new Blob([res], {
260+
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
261+
})
262+
const link = document.createElement('a')
263+
link.href = URL.createObjectURL(blob)
264+
link.download = props.info.name + '.xlsx'
265+
document.body.appendChild(link)
266+
link.click()
267+
document.body.removeChild(link)
268+
})
269+
.catch(async (error) => {
270+
if (error.response) {
271+
try {
272+
let text = await error.response.data.text()
273+
try {
274+
text = JSON.parse(text)
275+
} finally {
276+
ElMessage({
277+
message: text,
278+
type: 'error',
279+
showClose: true,
280+
})
281+
}
282+
} catch (e) {
283+
console.error('Error processing error response:', e)
284+
}
285+
} else {
286+
console.error('Other error:', error)
287+
ElMessage({
288+
message: error,
289+
type: 'error',
290+
showClose: true,
291+
})
292+
}
293+
})
294+
}
295+
240296
const emits = defineEmits(['back', 'refresh'])
241297
const back = () => {
242298
emits('back')
@@ -298,6 +354,16 @@ const btnSelectClick = (val: any) => {
298354
<icon_right_outlined></icon_right_outlined>
299355
</el-icon>
300356
<div class="name">{{ info.name }}</div>
357+
<el-button @click="downloadTemplate" class="export-remark" secondary>
358+
<template #icon>
359+
<icon_import_outlined></icon_import_outlined>
360+
</template>
361+
{{ $t('professional.export') }}
362+
</el-button>
363+
<UploaderRemark
364+
:upload-path="`/datasource/uploadDsSchema/${info.id}`"
365+
@upload-finished="init"
366+
></UploaderRemark>
301367
</div>
302368
<div class="content">
303369
<div class="side-list">
@@ -590,8 +656,9 @@ const btnSelectClick = (val: any) => {
590656
line-height: 22px;
591657
color: #646a73;
592658
border-bottom: 1px solid #1f232926;
659+
position: relative;
593660
594-
.ed-button {
661+
.ed-button.is-text {
595662
height: 22px;
596663
line-height: 22px;
597664
color: #646a73;
@@ -606,6 +673,12 @@ const btnSelectClick = (val: any) => {
606673
}
607674
}
608675
676+
.export-remark {
677+
position: absolute;
678+
right: 116px;
679+
top: 12px;
680+
}
681+
609682
.name {
610683
color: #1f2329;
611684
margin-left: 4px;

0 commit comments

Comments
 (0)