feat: 同数据源直连数据集之间支持数据关联

This commit is contained in:
junjie
2021-07-15 11:05:11 +08:00
parent 1d927404d9
commit a68323de2f
10 changed files with 226 additions and 67 deletions

View File

@@ -954,7 +954,8 @@ export default {
left_join: 'LEFT JOIN',
right_join: 'RIGHT JOIN',
inner_join: 'INNER JOIN',
full_join: 'FULL JOIN'
full_join: 'FULL JOIN',
can_not_union_diff_datasource: 'Union dataset must have same data source'
},
datasource: {
datasource: 'Data Source',

View File

@@ -954,7 +954,8 @@ export default {
left_join: '左連接',
right_join: '右連接',
inner_join: '內連接',
full_join: '全連接'
full_join: '全連接',
can_not_union_diff_datasource: '被關聯數據集必須與當前數據集的數據源一致'
},
datasource: {
datasource: '數據源',

View File

@@ -954,7 +954,8 @@ export default {
left_join: '左连接',
right_join: '右连接',
inner_join: '内连接',
full_join: '全连接'
full_join: '全连接',
can_not_union_diff_datasource: '被关联数据集必须与当前数据集的数据源一致'
},
datasource: {
datasource: '数据源',

View File

@@ -23,7 +23,7 @@
</el-row>
<el-col style="display: flex;flex-direction: row">
<el-col class="panel-height" style="width: 220px;border-right:solid 1px #dcdfe6;border-top:solid 1px #dcdfe6;padding-right: 15px;overflow-y: auto;">
<dataset-group-selector :custom-type="customType" :table="table" :mode="1" :checked-list="checkedList" :union-data="unionData" @getTable="getTable" />
<dataset-group-selector :custom-type="customType" :table="table" :checked-list="checkedList" :union-data="unionData" @getTable="getTable" />
</el-col>
<el-col class="panel-height" style="width: 235px;border-top:solid 1px #dcdfe6;padding: 0 15px;overflow-y: auto;">
<dataset-custom-field :table="table" :checked-list="checkedList" @getChecked="getChecked" />
@@ -151,9 +151,9 @@ export default {
id: this.param.tableId,
name: this.name,
sceneId: this.param.id,
dataSourceId: null,
dataSourceId: this.param.tableId ? this.param.table.dataSourceId : this.table.dataSourceId,
type: 'custom',
mode: 1,
mode: this.param.tableId ? this.param.table.mode : this.table.mode,
info: '{"list":' + JSON.stringify(this.checkedList) + '}'
}
post('/dataset/table/customPreview', table).then(response => {
@@ -202,9 +202,9 @@ export default {
id: this.param.tableId,
name: this.name,
sceneId: this.param.id,
dataSourceId: null,
dataSourceId: this.table.dataSourceId,
type: 'custom',
mode: 1,
mode: this.table.mode,
info: '{"list":' + JSON.stringify(this.checkedList) + '}'
}
post('/dataset/table/update', table).then(response => {

View File

@@ -265,7 +265,9 @@ export default {
mode: this.mode < 0 ? null : this.mode,
typeFilter: this.customType ? this.customType : null
}, false).then(response => {
this.tables = response.data
this.tables = response.data.filter(ele => {
return !(ele.mode === 0 && ele.type === 'sql')
})
for (let i = 0; i < this.tables.length; i++) {
if (this.tables[i].mode === 1 && this.kettleRunning === false) {
this.$set(this.tables[i], 'disabled', true)

View File

@@ -81,16 +81,16 @@
</el-table-column>
<el-table-column property="originName" :label="$t('dataset.field_origin_name')" width="100">
<template slot-scope="scope">
<span :title="scope.row.originName" class="field-class" style="display: inline-block;width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
{{ scope.row.originName }}
<span :title="scope.row.originName" class="field-class" style="width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<span style="font-size: 12px;">{{ scope.row.originName }}</span>
</span>
</template>
</el-table-column>
<el-table-column property="groupType" :label="$t('dataset.field_group_type')" width="180">
<template slot-scope="scope">
<el-radio-group v-model="scope.row.groupType">
<el-radio label="d">{{ $t('chart.dimension') }}</el-radio>
<el-radio label="q">{{ $t('chart.quota') }}</el-radio>
<el-radio-group v-model="scope.row.groupType" size="mini">
<el-radio-button label="d">{{ $t('chart.dimension') }}</el-radio-button>
<el-radio-button label="q">{{ $t('chart.quota') }}</el-radio-button>
</el-radio-group>
</template>
</el-table-column>

View File

@@ -94,7 +94,7 @@
<el-radio class="union-relation-css" label="1:N">{{ $t('dataset.left_join') }}</el-radio>
<el-radio class="union-relation-css" label="N:1">{{ $t('dataset.right_join') }}</el-radio>
<el-radio class="union-relation-css" label="1:1">{{ $t('dataset.inner_join') }}</el-radio>
<el-radio class="union-relation-css" label="N:N">{{ $t('dataset.full_join') }}</el-radio>
<!-- <el-radio class="union-relation-css" label="N:N">{{ $t('dataset.full_join') }}</el-radio>-->
</el-radio-group>
</el-col>
@@ -105,7 +105,7 @@
width="500"
trigger="click"
>
<dataset-group-selector-tree :fix-height="true" show-mode="union" :custom-type="customType" :mode="1" @getTable="getTable" />
<dataset-group-selector-tree :fix-height="true" show-mode="union" :custom-type="customType" :mode="table.mode" @getTable="getTable" />
<el-button slot="reference" size="mini" style="width: 100%;">
<p class="table-name-css" :title="targetTable.name || $t('dataset.pls_slc_union_table')">{{ targetTable.name || $t('dataset.pls_slc_union_table') }}</p>
</el-button>
@@ -204,6 +204,9 @@ export default {
},
initUnion() {
if (this.table.id) {
if (this.table.mode === 0) {
this.customType = ['db']
}
post('dataset/union/listByTableId/' + this.table.id, {}).then(response => {
// console.log(response)
this.unionData = response.data
@@ -301,6 +304,16 @@ export default {
})
return
}
if (this.table.mode === 0) {
if (param.dataSourceId !== this.table.dataSourceId) {
this.$message({
type: 'error',
message: this.$t('dataset.can_not_union_diff_datasource'),
showClose: true
})
return
}
}
this.targetTable = param
this.union.targetTableId = param.id
this.union.targetTableFieldId = ''

View File

@@ -48,7 +48,7 @@
<el-tab-pane :label="$t('dataset.data_preview')" name="dataPreview">
<tab-data-preview :param="param" :table="table" :fields="fields" :data="data" :page="page" :form="tableViewRowForm" @reSearch="reSearch" />
</el-tab-pane>
<el-tab-pane v-if="table.type !== 'custom' && table.mode === 1" :label="$t('dataset.join_view')" name="joinView">
<el-tab-pane v-if="table.type !== 'custom'" :label="$t('dataset.join_view')" name="joinView">
<union-view :param="param" :table="table" />
</el-tab-pane>
<el-tab-pane v-if="table.mode === 1 && (table.type === 'db' || table.type === 'sql')" :label="$t('dataset.update_info')" name="updateInfo">
@@ -156,10 +156,10 @@ export default {
},
editSql() {
this.$emit('switchComponent', { name: 'AddSQL', param: { id: this.table.sceneId, tableId: this.table.id }})
this.$emit('switchComponent', { name: 'AddSQL', param: { id: this.table.sceneId, tableId: this.table.id, table: this.table }})
},
editCustom() {
this.$emit('switchComponent', { name: 'AddCustom', param: { id: this.table.sceneId, tableId: this.table.id }})
this.$emit('switchComponent', { name: 'AddCustom', param: { id: this.table.sceneId, tableId: this.table.id, table: this.table }})
},
reSearch(val) {