fix: 数据集创建 返回对应的数据集 数据源bug 路由切换bug

This commit is contained in:
dataeaseShu 2022-09-23 11:17:18 +08:00
parent 0f563f4feb
commit ffc8271611
9 changed files with 88 additions and 102 deletions

View File

@ -3,7 +3,7 @@
<keep-alive> <keep-alive>
<router-view v-if="['/dataset/index', '/system/system-settings/appearance'].includes(key)"></router-view> <router-view v-if="['/dataset/index', '/system/system-settings/appearance'].includes(key)"></router-view>
</keep-alive> </keep-alive>
<router-view v-if="!['/dataset/index', '/system/system-settings/appearance'].includes(key)"></router-view> <router-view :key="key" v-if="!['/dataset/index', '/system/system-settings/appearance'].includes(key)"></router-view>
<plugin-com v-show="false" ref="de-theme" component-name="ThemeSetting" /> <plugin-com v-show="false" ref="de-theme" component-name="ThemeSetting" />
</div> </div>
</template> </template>

View File

@ -1,9 +1,9 @@
<template> <template>
<div class="dataset-api"> <div class="dataset-api">
<p v-if="!showLeft" class="arrow-right" @click="showLeft = true"> <p v-show="!showLeft" class="arrow-right" @click="showLeft = true">
<i class="el-icon-d-arrow-right" /> <i class="el-icon-d-arrow-right" />
</p> </p>
<div v-else class="table-list"> <div v-show="showLeft" class="table-list">
<p class="select-ds"> <p class="select-ds">
{{ $t('deDataset.select_data_source') }} {{ $t('deDataset.select_data_source') }}
<i class="el-icon-d-arrow-left" @click="showLeft = false" /> <i class="el-icon-d-arrow-left" @click="showLeft = false" />
@ -153,9 +153,11 @@
<script> <script>
import { listApiDatasource, post, isKettleRunning } from '@/api/dataset/dataset' 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'
export default { export default {
name: 'AddApi', name: 'AddApi',
mixins: [cancelMix],
props: { props: {
param: { param: {
type: Object, type: Object,
@ -350,17 +352,12 @@ export default {
post('/dataset/table/batchAdd', tables) post('/dataset/table/batchAdd', tables)
.then((response) => { .then((response) => {
this.openMessageSuccess('deDataset.set_saved_successfully') this.openMessageSuccess('deDataset.set_saved_successfully')
this.cancel() this.cancel(response.data)
}) })
.finally(() => { .finally(() => {
this.loading = false this.loading = false
}) })
}, },
cancel() {
this.$router.push('/dataset/index')
},
dataReset() { dataReset() {
this.searchTable = '' this.searchTable = ''
this.options = [] this.options = []

View File

@ -1,9 +1,9 @@
<template> <template>
<div class="dataset-db" v-loading="loading"> <div class="dataset-db" v-loading="loading">
<p v-if="!showLeft" @click="showLeft = true" class="arrow-right"> <p v-show="!showLeft" @click="showLeft = true" class="arrow-right">
<i class="el-icon-d-arrow-right"></i> <i class="el-icon-d-arrow-right"></i>
</p> </p>
<div class="table-list" v-else> <div class="table-list" v-show="showLeft">
<p class="select-ds"> <p class="select-ds">
{{ $t('deDataset.select_data_source') }} {{ $t('deDataset.select_data_source') }}
<i @click="showLeft = false" class="el-icon-d-arrow-left"></i> <i @click="showLeft = false" class="el-icon-d-arrow-left"></i>
@ -158,10 +158,10 @@
import { listDatasource, post, isKettleRunning } from '@/api/dataset/dataset' 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'
export default { export default {
name: 'AddDB', name: 'AddDB',
mixins: [msgCfm], mixins: [ msgCfm, cancelMix],
props: { props: {
param: { param: {
type: Object, type: Object,
@ -368,16 +368,12 @@ export default {
post('/dataset/table/batchAdd', tables) post('/dataset/table/batchAdd', tables)
.then((response) => { .then((response) => {
this.openMessageSuccess('deDataset.set_saved_successfully') this.openMessageSuccess('deDataset.set_saved_successfully')
this.cancel() this.cancel(response.data)
}) })
.finally(() => { .finally(() => {
this.loading = false this.loading = false
}) })
}, },
cancel() {
this.$router.back()
},
dataReset() { dataReset() {
this.searchTable = '' this.searchTable = ''
this.options = [] this.options = []

View File

@ -1,9 +1,9 @@
<template> <template>
<div class="dataset-excel" v-loading="loading"> <div class="dataset-excel" v-loading="loading">
<p v-if="!showLeft" @click="showLeft = true" class="arrow-right"> <p v-show="!showLeft" @click="showLeft = true" class="arrow-right">
<i class="el-icon-d-arrow-right"></i> <i class="el-icon-d-arrow-right"></i>
</p> </p>
<div v-else class="table-list"> <div v-show="showLeft" class="table-list">
<p class="select-ds"> <p class="select-ds">
<span <span
>{{ $t('deDataset.select_data_table ') }} >{{ $t('deDataset.select_data_table ') }}
@ -192,12 +192,13 @@ import i18n from '@/lang'
import { $alert, $confirm } from '@/utils/message' import { $alert, $confirm } from '@/utils/message'
import store from '@/store' import store from '@/store'
import msgCfm from '@/components/msgCfm/index' import msgCfm from '@/components/msgCfm/index'
import cancelMix from './cancelMix'
const token = getToken() const token = getToken()
export default { export default {
name: 'AddExcel', name: 'AddExcel',
mixins: [msgCfm], mixins: [ msgCfm, cancelMix],
props: { props: {
param: { param: {
type: Object, type: Object,
@ -500,7 +501,7 @@ export default {
this.loading = true this.loading = true
post('/dataset/table/update', table).then((response) => { post('/dataset/table/update', table).then((response) => {
this.openMessageSuccess('deDataset.set_saved_successfully') this.openMessageSuccess('deDataset.set_saved_successfully')
this.cancel() this.cancel(response.data)
}) })
}) })
.catch((action) => { .catch((action) => {
@ -512,7 +513,7 @@ export default {
post('/dataset/table/update', table) post('/dataset/table/update', table)
.then((response) => { .then((response) => {
this.openMessageSuccess('deDataset.set_saved_successfully') this.openMessageSuccess('deDataset.set_saved_successfully')
this.cancel() this.cancel(response.data)
}) })
.finally(() => { .finally(() => {
this.loading = false this.loading = false
@ -526,16 +527,13 @@ export default {
post('/dataset/table/update', table) post('/dataset/table/update', table)
.then((response) => { .then((response) => {
this.openMessageSuccess('deDataset.set_saved_successfully') this.openMessageSuccess('deDataset.set_saved_successfully')
this.cancel() this.cancel(response.data)
}) })
.finally(() => { .finally(() => {
this.loading = false this.loading = false
}) })
} }
}, },
cancel() {
this.$router.back()
},
dataReset() { dataReset() {
this.searchTable = '' this.searchTable = ''
this.options = [] this.options = []

View File

@ -371,11 +371,12 @@ import 'codemirror/addon/hint/sql-hint'
import 'codemirror/addon/hint/show-hint' 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 _ from 'lodash' import _ from 'lodash'
export default { export default {
name: 'AddSQL', name: 'AddSQL',
components: { codemirror }, components: { codemirror },
mixins: [msgCfm], mixins: [ msgCfm, cancelMix],
props: { props: {
param: { param: {
type: Object, type: Object,
@ -656,17 +657,12 @@ export default {
post('/dataset/table/update', table) post('/dataset/table/update', table)
.then((response) => { .then((response) => {
this.openMessageSuccess('deDataset.set_saved_successfully') this.openMessageSuccess('deDataset.set_saved_successfully')
this.cancel() this.cancel(response.data)
}) })
.finally(() => { .finally(() => {
this.loading = false this.loading = false
}) })
}, },
cancel() {
this.$router.push('/dataset/index')
},
showSQL(val) { showSQL(val) {
this.sql = val || '' this.sql = val || ''
}, },

View File

@ -107,8 +107,10 @@ import datasetTree from '@/views/dataset/common/datasetTree'
import UnionEdit from '@/views/dataset/add/union/UnionEdit' import UnionEdit from '@/views/dataset/add/union/UnionEdit'
import { post } from '@/api/dataset/dataset' import { post } from '@/api/dataset/dataset'
import UnionPreview from '@/views/dataset/add/union/UnionPreview' import UnionPreview from '@/views/dataset/add/union/UnionPreview'
import cancelMix from './cancelMix'
export default { export default {
name: 'AddUnion', name: 'AddUnion',
mixins: [cancelMix],
components: { components: {
UnionPreview, UnionPreview,
UnionEdit, UnionEdit,
@ -218,14 +220,11 @@ export default {
} }
post('/dataset/table/update', table).then((response) => { post('/dataset/table/update', table).then((response) => {
this.$emit('saveSuccess', table) this.$emit('saveSuccess', table)
this.cancel() this.cancel(response.data)
}).finally(() => { }).finally(() => {
this.loading = false; this.loading = false;
}) })
}, },
cancel() {
this.$router.back()
},
selectDs() { selectDs() {
this.selectDsDialog = true this.selectDsDialog = true
}, },

View File

@ -0,0 +1,19 @@
export default {
methods: {
cancel(arr = []) {
if (arr.length === 1) {
const [dataset] = arr;
const { id, name } = dataset;
this.$router.push({
name: 'dataset',
params: {
id,
name
}
})
} else {
this.$router.back()
}
}
}
}

View File

@ -222,10 +222,7 @@
/> />
</span> </span>
<span <span
v-if=" v-if="['db', 'sql'].includes(data.modelInnerType)"
data.modelInnerType === 'db' ||
data.modelInnerType === 'sql'
"
> >
<span v-if="data.mode === 0" style="margin-left: 6px" <span v-if="data.mode === 0" style="margin-left: 6px"
><i class="el-icon-s-operation" ><i class="el-icon-s-operation"
@ -241,6 +238,7 @@
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
" "
:class="[{ 'de-fill-block': !['db', 'sql'].includes(data.modelInnerType)}]"
:title="data.name" :title="data.name"
>{{ data.name }}</span >{{ data.name }}</span
> >
@ -498,6 +496,7 @@ export default {
}, },
isTreeSearch: false, isTreeSearch: false,
kettleRunning: false, kettleRunning: false,
pageCreated: false,
engineMode: 'local', engineMode: 'local',
searchPids: [], // pid searchPids: [], // pid
filterText: '', filterText: '',
@ -528,13 +527,17 @@ export default {
} }
}, },
activated() { activated() {
if (!this.pageCreated) return;
const dataset = this.$refs.datasetTreeRef?.getCurrentNode() const dataset = this.$refs.datasetTreeRef?.getCurrentNode()
const { id, name } = this.$route.params
queryAuthModel({ modelType: 'dataset' }, true).then((res) => { queryAuthModel({ modelType: 'dataset' }, true).then((res) => {
localStorage.setItem('dataset-tree', JSON.stringify(res.data)) localStorage.setItem('dataset-tree', JSON.stringify(res.data))
this.tData = res.data this.tData = res.data
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.datasetTreeRef?.filter(this.filterText) this.$refs.datasetTreeRef?.filter(this.filterText)
if (dataset) { if (id && name.includes(this.filterText)) {
this.dfsTableData(this.tData, id)
} else if (dataset) {
this.$refs.datasetTreeRef?.setCurrentNode(dataset) this.$refs.datasetTreeRef?.setCurrentNode(dataset)
this.nodeClick(dataset) this.nodeClick(dataset)
} }
@ -542,6 +545,7 @@ export default {
}) })
}, },
created() { created() {
this.pageCreated = true;
this.kettleState() this.kettleState()
engineMode().then((res) => { engineMode().then((res) => {
this.engineMode = res.data this.engineMode = res.data
@ -552,6 +556,19 @@ export default {
this.refresh() this.refresh()
}, },
methods: { methods: {
dfsTableData(arr, id) {
arr.some(ele => {
if(ele.id === id) {
this.$refs.datasetTreeRef?.setCurrentNode(ele)
this.nodeClick(ele)
this.expandedArray.push(id)
return true
} else if (ele.children?.length) {
this.dfsTableData(ele.children, id)
}
return false
});
},
nameRepeat(value) { nameRepeat(value) {
if (!this.fileList || this.fileList.length === 0) { if (!this.fileList || this.fileList.length === 0) {
return false return false
@ -978,8 +995,8 @@ export default {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.search-input { .de-fill-block {
padding: 12px 0; margin-left: 35px !important;
} }
.custom-tree-container { .custom-tree-container {

View File

@ -20,13 +20,10 @@
</el-col> </el-col>
</el-row> </el-row>
<div class="table-container"> <div class="table-container">
<grid-table <el-table
v-loading="loading" v-loading="loading"
:tableData="tableData" :data="filterTable"
:columns="[]" :style="{ width: '100%' }"
:pagination="paginationConfig"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
> >
<el-table-column <el-table-column
key="name" key="name"
@ -34,28 +31,20 @@
:label="$t('datasource.table_name')" :label="$t('datasource.table_name')"
/> />
<el-table-column <el-table-column
slot="__operation"
:label="$t('commons.operating')" :label="$t('commons.operating')"
key="__operation"
fixed="right" fixed="right"
width="168" width="108"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<el-button
@click="createtDataset(scope.row)"
class="text-btn mar3 mar6"
type="text"
>{{ $t("datasource.create_dataset") }}</el-button
>
<el-button <el-button
@click="selectDataset(scope.row)" @click="selectDataset(scope.row)"
class="text-btn" class="de-text-btn mar3"
type="text" type="text"
>{{ $t("dataset.detail") }}</el-button >{{ $t("dataset.detail") }}</el-button
> >
</template> </template>
</el-table-column> </el-table-column>
</grid-table> </el-table>
</div> </div>
<el-drawer <el-drawer
:title="$t('dataset.detail')" :title="$t('dataset.detail')"
@ -106,11 +95,9 @@
<script> <script>
import keyEnter from "@/components/msgCfm/keyEnter.js"; import keyEnter from "@/components/msgCfm/keyEnter.js";
import GridTable from "@/components/gridTable/index.vue";
import {dsTable, post} from "@/api/dataset/dataset"; import {dsTable, post} from "@/api/dataset/dataset";
export default { export default {
mixins: [keyEnter], mixins: [keyEnter],
components: { GridTable },
props: { props: {
params: { params: {
type: Object, type: Object,
@ -123,22 +110,18 @@ export default {
dsTableDetail: {}, dsTableDetail: {},
nikeName: "", nikeName: "",
loading: false, loading: false,
paginationConfig: { dsTableData: [],
currentPage: 1, tableData: [],
pageSize: 10, filterTable: []
total: 0,
},
dsTableData: [{date: 1}],
tableData: [{ name: 1 }],
}; };
}, },
created() { created() {
post('/datasource/getTables/' + this.params.id, {}).then((response) => { this.search()
this.tableData = response.data
})
}, },
methods: { methods: {
createtDataset(row) {}, initSearch() {
this.filterTable = this.tableData.filter(ele => ele.name.includes(this.nikeName))
},
selectDataset(row) { selectDataset(row) {
this.dsTableDetail = row; this.dsTableDetail = row;
this.userDrawer = true; this.userDrawer = true;
@ -148,36 +131,14 @@ export default {
this.dsTableData = response.data this.dsTableData = response.data
}) })
}, },
handleSizeChange(pageSize) {
this.paginationConfig.currentPage = 1;
this.paginationConfig.pageSize = pageSize;
this.search();
},
handleCurrentChange(currentPage) {
this.paginationConfig.currentPage = currentPage;
this.search();
},
initSearch() {
this.handleCurrentChange(1);
},
search() { search() {
this.loading = true; this.loading = true;
const param = { post('/datasource/getTables/' + this.params.id, {}).then((response) => {
conditions: [], this.tableData = response.data
}; this.initSearch()
if (this.nikeName) { }).finally(() => {
param.conditions.push({
field: `dataset_table_task.name`,
operator: "like",
value: this.nikeName,
});
}
const { currentPage, pageSize } = this.paginationConfig;
dsTable(currentPage, pageSize, this.params.id).then((response) => {
this.tableData = response.data.listObject;
this.paginationConfig.total = response.data.itemCount;
this.loading = false; this.loading = false;
}); })
}, },
}, },
}; };
@ -204,6 +165,9 @@ export default {
height: 100%; height: 100%;
padding: 10px 14px; padding: 10px 14px;
box-sizing: border-box; box-sizing: border-box;
.mar3 {
margin-left: -5px;
}
.table-name { .table-name {
font-family: PingFang SC; font-family: PingFang SC;
font-size: 16px; font-size: 16px;