Skip to content

Commit 2e4789b

Browse files
committed
fix(Data Source): Data source table structure supports field retrieval #447
1 parent 06e79f5 commit 2e4789b

File tree

6 files changed

+18
-13
lines changed

6 files changed

+18
-13
lines changed

frontend/src/assets/svg/logo_cas.svg

Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 1 addition & 1 deletion
Loading

frontend/src/i18n/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"all_data_sources": "All data sources",
5454
"partial_data_sources": "Partial data sources",
5555
"add_it_here": "Drag the table name on the left to add it here",
56-
"table_relationship_management": "Table relationship management",
56+
"table_relationship_management": "Table relationship manage",
5757
"system_management": "System Management",
5858
"data_training": "SQL Sample Lib",
5959
"problem_description": "Problem Description",

frontend/src/views/ds/DataTable.vue

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import UploaderRemark from '@/views/system/excel-upload/UploaderRemark.vue'
1313
import TableRelationship from '@/views/ds/TableRelationship.vue'
1414
import icon_mindnote_outlined from '@/assets/svg/icon_mindnote_outlined.svg'
1515
import { Refresh } from '@element-plus/icons-vue'
16+
import { debounce } from 'lodash-es'
1617
1718
interface Table {
1819
name: string
@@ -106,7 +107,9 @@ const handleCurrentChange = (val: number) => {
106107
107108
const fieldListComputed = computed(() => {
108109
const { currentPage, pageSize } = pageInfo
109-
return fieldList.value.slice((currentPage - 1) * pageSize, currentPage * pageSize)
110+
return fieldList.value
111+
.filter((ele: any) => ele.field_name.toLowerCase().includes(fieldName.value.toLowerCase()))
112+
.slice((currentPage - 1) * pageSize, currentPage * pageSize)
110113
})
111114
112115
const init = (reset = false) => {
@@ -166,6 +169,7 @@ const clickTable = (table: any) => {
166169
fieldList.value = res
167170
pageInfo.total = res.length
168171
pageInfo.currentPage = 1
172+
fieldName.value = ''
169173
datasourceApi.previewData(props.info.id, buildData()).then((res) => {
170174
previewData.value = res
171175
})
@@ -313,22 +317,23 @@ const renderHeader = ({ column }: any) => {
313317
document.body.removeChild(span)
314318
return column.label
315319
}
316-
317-
const fieldNameSearch = () => {
318-
btnSelectClick(btnSelect.value)
319-
}
320+
const fieldNameSearch = debounce(() => {
321+
pageInfo.currentPage = 1
322+
pageInfo.total = fieldListComputed.value.length
323+
}, 100)
320324
const fieldName = ref('')
321325
const btnSelectClick = (val: any) => {
322326
btnSelect.value = val
323327
loading.value = true
324328
325329
if (val === 'd') {
326330
datasourceApi
327-
.fieldList(currentTable.value.id, { fieldName: fieldName.value })
331+
.fieldList(currentTable.value.id, { fieldName: '' })
328332
.then((res) => {
329333
fieldList.value = res
330334
pageInfo.total = res.length
331335
pageInfo.currentPage = 1
336+
fieldName.value = ''
332337
})
333338
.finally(() => {
334339
loading.value = false
@@ -496,7 +501,7 @@ const btnSelectClick = (val: any) => {
496501
:placeholder="t('dashboard.search')"
497502
autocomplete="off"
498503
clearable
499-
@blur="fieldNameSearch"
504+
@input="fieldNameSearch"
500505
/>
501506
<el-button
502507
v-if="ds.type !== 'excel'"
@@ -565,7 +570,7 @@ const btnSelectClick = (val: any) => {
565570
</el-table-column>
566571
</el-table>
567572
</div>
568-
<div v-if="fieldList.length && btnSelect === 'd'" class="pagination-container">
573+
<div v-if="pageInfo.total && btnSelect === 'd'" class="pagination-container">
569574
<el-pagination
570575
v-model:current-page="pageInfo.currentPage"
571576
v-model:page-size="pageInfo.pageSize"

0 commit comments

Comments
 (0)