Merge pull request #4319 from dataease/pr@dev_memory_component

feat: 数据集新建页面数据源排序   数据集详情展示UI调整 数据集展示的表与字段支持筛选框搜索
This commit is contained in:
dataeaseShu 2023-01-09 15:57:53 +08:00 committed by GitHub
commit af26cc0c26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 66 additions and 11 deletions

View File

@ -51,6 +51,7 @@
"jquery": "^3.1.1", "jquery": "^3.1.1",
"js-base64": "^3.7.2", "js-base64": "^3.7.2",
"js-cookie": "2.2.0", "js-cookie": "2.2.0",
"js-pinyin": "^0.1.9",
"jsencrypt": "^3.0.0-rc.1", "jsencrypt": "^3.0.0-rc.1",
"jspdf": "^2.3.1", "jspdf": "^2.3.1",
"jszip": "^3.10.1", "jszip": "^3.10.1",

View File

@ -182,8 +182,10 @@ export default {
textAlign: horizontal textAlign: horizontal
} }
this.outsideStyle = { this.outsideStyle = {
flexWrap: 'wrap' flexDirection: 'column'
} }
if (vertical !== 'top' && this.element.component !== 'de-select-grid') { if (vertical !== 'top' && this.element.component !== 'de-select-grid') {
this.titleStyle = null this.titleStyle = null
this.outsideStyle = { this.outsideStyle = {
@ -192,6 +194,10 @@ export default {
} }
} }
if (this.element.component === 'de-select-grid') {
this.$set(this.outsideStyle, 'flexDirection', 'column')
}
if (vertical !== 'top' && this.element.component === 'de-number-range') { if (vertical !== 'top' && this.element.component === 'de-number-range') {
if (!this.titleStyle) { if (!this.titleStyle) {
this.titleStyle = {} this.titleStyle = {}

View File

@ -218,6 +218,7 @@ import { listApiDatasource, post, isKettleRunning } from '@/api/dataset/dataset'
import { dbPreview, engineMode } from '@/api/system/engine' import { dbPreview, engineMode } from '@/api/system/engine'
import cancelMix from './cancelMix' import cancelMix from './cancelMix'
import msgCfm from '@/components/msgCfm/index' import msgCfm from '@/components/msgCfm/index'
import { pySort } from './util'
export default { export default {
name: 'AddApi', name: 'AddApi',
@ -398,7 +399,7 @@ export default {
}, },
initDataSource() { initDataSource() {
listApiDatasource().then((response) => { listApiDatasource().then((response) => {
this.options = response.data this.options = pySort(response.data)
}) })
}, },
kettleState() { kettleState() {

View File

@ -225,6 +225,8 @@ import { listDatasource, post, isKettleRunning } from '@/api/dataset/dataset'
import { engineMode, dbPreview } from '@/api/system/engine' import { engineMode, dbPreview } from '@/api/system/engine'
import msgCfm from '@/components/msgCfm/index' import msgCfm from '@/components/msgCfm/index'
import cancelMix from './cancelMix' import cancelMix from './cancelMix'
import { pySort } from './util'
export default { export default {
name: 'AddDB', name: 'AddDB',
mixins: [msgCfm, cancelMix], mixins: [msgCfm, cancelMix],
@ -415,7 +417,7 @@ export default {
}, },
initDataSource() { initDataSource() {
listDatasource().then((response) => { listDatasource().then((response) => {
this.options = response.data.filter((item) => item.type !== 'api') this.options = pySort(response.data.filter((item) => item.type !== 'api'))
}) })
}, },
kettleState() { kettleState() {

View File

@ -109,6 +109,7 @@
@click=" @click="
showTable = false showTable = false
dataTable = '' dataTable = ''
;keywords = ''
" "
><i class="el-icon-arrow-left" /> {{ $t('chart.back') }}</span> ><i class="el-icon-arrow-left" /> {{ $t('chart.back') }}</span>
<span v-else>{{ $t('deDataset.data_reference') }}</span> <span v-else>{{ $t('deDataset.data_reference') }}</span>
@ -147,13 +148,15 @@
>{{ >{{
$t('deDataset.to_start_using') $t('deDataset.to_start_using')
}}</span> }}</span>
<template v-else>
<el-input :placeholder="$t('fu.search_bar.please_input')" style="padding: 5px" size="small" v-model="keywords"></el-input>
<div <div
v-else-if="dataSource && !dataTable" v-if="dataSource && !dataTable"
v-loading="tableLoading" v-loading="tableLoading"
class="item-list" class="item-list"
> >
<div <div
v-for="ele in tableData" v-for="ele in tableDataCopy"
:key="ele.name" :key="ele.name"
class="table-or-field" class="table-or-field"
@click="typeSwitch(ele)" @click="typeSwitch(ele)"
@ -173,10 +176,11 @@
</div> </div>
<div <div
v-else-if="dataSource && dataTable" v-else-if="dataSource && dataTable"
v-loading="tableLoading"
class="item-list" class="item-list"
> >
<div <div
v-for="ele in fieldData" v-for="ele in fieldDataCopy"
:key="ele.fieldName" :key="ele.fieldName"
class="table-or-field field" class="table-or-field field"
> >
@ -193,6 +197,8 @@
/> />
</div> </div>
</div> </div>
</template>
</div> </div>
<div class="sql-table"> <div class="sql-table">
<div <div
@ -559,6 +565,7 @@ import 'codemirror/addon/hint/show-hint'
import { engineMode } from '@/api/system/engine' import { engineMode } from '@/api/system/engine'
import msgCfm from '@/components/msgCfm/index' import msgCfm from '@/components/msgCfm/index'
import cancelMix from './cancelMix' import cancelMix from './cancelMix'
import { pySort } from './util'
import _ from 'lodash' import _ from 'lodash'
import GridTable from '@/components/gridTable/index.vue' import GridTable from '@/components/gridTable/index.vue'
export default { export default {
@ -579,6 +586,7 @@ export default {
pageSize: 10, pageSize: 10,
total: 0 total: 0
}, },
keywords: '',
sqlData: [], sqlData: [],
dataSource: '', dataSource: '',
loading: false, loading: false,
@ -605,6 +613,8 @@ export default {
completeSingle: false // completeSingle: false //
} }
}, },
tableDataCopy: [],
fieldDataCopy: [],
errImg: require('@/assets/error.png'), errImg: require('@/assets/error.png'),
initImg: require('@/assets/None.png'), initImg: require('@/assets/None.png'),
sqlHeight: 248, sqlHeight: 248,
@ -685,6 +695,21 @@ export default {
handler: function() { handler: function() {
this.calHeight() this.calHeight()
} }
},
keywords(val) {
if (!val) {
this.tableDataCopy = [...this.tableData]
this.fieldDataCopy = [...this.fieldData]
return
}
if (this.dataSource && !this.dataTable) {
this.tableDataCopy = this.tableData.filter(ele => ele.name.includes(val))
}
if (this.dataSource && this.dataTable) {
this.fieldDataCopy = this.fieldData.filter(ele => ele.fieldName.includes(val))
}
} }
}, },
beforeDestroy() { beforeDestroy() {
@ -729,16 +754,22 @@ export default {
this.listSqlLog() this.listSqlLog()
}, },
getField(name) { getField(name) {
this.tableLoading = true
post('/dataset/table/getFields', { post('/dataset/table/getFields', {
dataSourceId: this.dataSource, dataSourceId: this.dataSource,
info: JSON.stringify({ table: name }) info: JSON.stringify({ table: name })
}).then((res) => { }).then((res) => {
this.fieldData = res.data this.fieldData = res.data
this.fieldDataCopy = [...this.fieldData]
})
.finally(() => {
this.tableLoading = false
}) })
}, },
typeSwitch({ name }) { typeSwitch({ name }) {
this.showTable = true this.showTable = true
this.dataTable = name this.dataTable = name
this.keywords = ''
this.getField(name) this.getField(name)
}, },
mousedownDrag() { mousedownDrag() {
@ -787,6 +818,7 @@ export default {
post('/datasource/getTables/' + this.dataSource, {}) post('/datasource/getTables/' + this.dataSource, {})
.then((response) => { .then((response) => {
this.tableData = response.data this.tableData = response.data
this.tableDataCopy = [...this.tableData]
}) })
.finally(() => { .finally(() => {
this.tableLoading = false this.tableLoading = false
@ -799,7 +831,7 @@ export default {
}, 200), }, 200),
initDataSource() { initDataSource() {
return listDatasource().then((response) => { return listDatasource().then((response) => {
this.options = response.data.filter((item) => item.type !== 'api') this.options = pySort(response.data.filter((item) => item.type !== 'api'))
}) })
}, },
@ -1119,7 +1151,7 @@ export default {
.item-list { .item-list {
padding: 16px 8px; padding: 16px 8px;
height: calc(100vh - 200px); height: calc(100vh - 242px);
overflow: auto; overflow: auto;
.table-or-field { .table-or-field {
height: 40px; height: 40px;

View File

@ -0,0 +1,12 @@
import pyjs from 'js-pinyin'
export function zh2py(str) {
return pyjs.getFullChars(str).toLowerCase().charCodeAt()
}
export function pySort(arr = []) {
arr.sort((a, b) => {
return zh2py(a.name[0]) - zh2py(b.name[0])
})
return arr
}

View File

@ -263,7 +263,7 @@ export default {
.info-item { .info-item {
font-family: PingFang SC; font-family: PingFang SC;
font-weight: 400; font-weight: 400;
margin: 6px 0; margin: 6px 0 12px 0;
} }
.info-title { .info-title {
margin: 0!important; margin: 0!important;

View File

@ -662,7 +662,7 @@ export default {
this.$emit('setParams', { ...this.params }) this.$emit('setParams', { ...this.params })
this.$nextTick(() => { this.$nextTick(() => {
this.disabled = appMarketCheck ? !this.appMarketEdit : (Boolean(id) && showModel === 'show' && !this.canEdit) this.disabled = appMarketCheck ? !this.appMarketEdit : (Boolean(id) && showModel === 'show' && !this.canEdit)
if (this.configFromTabs.editor === 'editor') { if (this.configFromTabs?.editor === 'editor') {
this.$emit('editeTodisable', true) this.$emit('editeTodisable', true)
} }
}) })
@ -1113,6 +1113,7 @@ export default {
} }
}) })
} }
this.$refs.dsForm.validate()
if (!status) { if (!status) {
return return
} }