2021-05-07 14:51:40 +08:00
|
|
|
<template>
|
|
|
|
<el-row>
|
|
|
|
<el-button size="mini" @click="showUnionEdit">{{ $t('dataset.add_union') }}</el-button>
|
|
|
|
<el-row>
|
|
|
|
<el-table
|
|
|
|
size="mini"
|
|
|
|
:data="unionData"
|
2021-05-12 16:39:53 +08:00
|
|
|
:height="height"
|
|
|
|
border
|
2021-05-07 14:51:40 +08:00
|
|
|
style="width: 100%;margin-top: 10px;"
|
|
|
|
>
|
|
|
|
<el-table-column
|
|
|
|
prop="sourceTableName"
|
|
|
|
:label="$t('dataset.source_table')"
|
|
|
|
/>
|
|
|
|
<el-table-column
|
|
|
|
prop="sourceTableFieldName"
|
|
|
|
:label="$t('dataset.source_field')"
|
|
|
|
/>
|
|
|
|
<el-table-column
|
|
|
|
prop="sourceUnionRelation"
|
|
|
|
:label="$t('dataset.union_relation')"
|
|
|
|
/>
|
|
|
|
<el-table-column
|
|
|
|
prop="targetTableName"
|
|
|
|
:label="$t('dataset.target_table')"
|
|
|
|
/>
|
|
|
|
<el-table-column
|
|
|
|
prop="targetTableFieldName"
|
|
|
|
:label="$t('dataset.target_field')"
|
|
|
|
/>
|
|
|
|
<el-table-column
|
2021-05-12 16:39:53 +08:00
|
|
|
align="left"
|
|
|
|
:label="$t('dataset.operate')"
|
2021-05-07 14:51:40 +08:00
|
|
|
>
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<el-button type="text" size="mini" @click="edit(scope.row)">{{ $t('dataset.edit') }}</el-button>
|
|
|
|
<el-button type="text" size="mini" @click="deleteUnion(scope.row)">{{ $t('dataset.delete') }}</el-button>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table>
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
<el-dialog
|
|
|
|
v-dialogDrag
|
|
|
|
:title="$t('dataset.union_setting')"
|
|
|
|
:visible="editUnion"
|
|
|
|
:show-close="false"
|
|
|
|
width="600px"
|
|
|
|
class="dialog-css"
|
|
|
|
>
|
|
|
|
<el-row style="display: flex;align-items: center;justify-content: center;">
|
|
|
|
<el-col :span="6">
|
2021-06-11 17:11:13 +08:00
|
|
|
<p class="table-name-css" :title="table.name">{{ table.name }}</p>
|
2021-05-07 14:51:40 +08:00
|
|
|
<el-select v-model="union.sourceTableFieldId" :placeholder="$t('dataset.pls_slc_union_field')" filterable clearable size="mini">
|
|
|
|
<el-option
|
|
|
|
v-for="item in sourceFieldOption"
|
|
|
|
:key="item.id"
|
|
|
|
:label="item.name"
|
|
|
|
:value="item.id"
|
|
|
|
>
|
|
|
|
<span>
|
|
|
|
<span v-if="item.deType === 0">
|
|
|
|
<svg-icon v-if="item.deType === 0" icon-class="field_text" class="field-icon-text" />
|
|
|
|
</span>
|
|
|
|
<span v-if="item.deType === 1">
|
|
|
|
<svg-icon v-if="item.deType === 1" icon-class="field_time" class="field-icon-time" />
|
|
|
|
</span>
|
|
|
|
<span v-if="item.deType === 2 || item.deType === 3">
|
|
|
|
<svg-icon v-if="item.deType === 2 || item.deType === 3" icon-class="field_value" class="field-icon-value" />
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
<span>
|
|
|
|
{{ item.name }}
|
|
|
|
</span>
|
|
|
|
</el-option>
|
|
|
|
</el-select>
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
<el-col :span="6">
|
|
|
|
<el-radio-group v-model="union.sourceUnionRelation" size="mini" style="display: block;width: 100%;text-align: center;">
|
|
|
|
<el-radio class="union-relation-css" label="1:1">1 : 1</el-radio>
|
|
|
|
<el-radio class="union-relation-css" label="N:1">N : 1</el-radio>
|
2021-05-07 18:29:15 +08:00
|
|
|
<el-radio class="union-relation-css" label="1:N">1 : N</el-radio>
|
2021-05-07 14:51:40 +08:00
|
|
|
</el-radio-group>
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
<el-col :span="6">
|
|
|
|
<el-popover
|
2021-05-08 10:36:06 +08:00
|
|
|
ref="targetTable"
|
2021-05-07 14:51:40 +08:00
|
|
|
placement="bottom"
|
2021-05-08 10:36:06 +08:00
|
|
|
width="500"
|
|
|
|
trigger="click"
|
2021-05-07 14:51:40 +08:00
|
|
|
>
|
2021-06-24 17:13:46 +08:00
|
|
|
<dataset-group-selector :fix-height="true" show-mode="union" :custom-type="customType" :mode="1" @getTable="getTable" />
|
2021-06-11 17:11:13 +08:00
|
|
|
<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>
|
2021-05-07 14:51:40 +08:00
|
|
|
</el-popover>
|
|
|
|
|
|
|
|
<el-select v-model="union.targetTableFieldId" :placeholder="$t('dataset.pls_slc_union_field')" filterable clearable size="mini">
|
|
|
|
<el-option
|
|
|
|
v-for="item in targetFieldOption"
|
|
|
|
:key="item.id"
|
|
|
|
:label="item.name"
|
|
|
|
:value="item.id"
|
|
|
|
>
|
|
|
|
<span>
|
|
|
|
<span v-if="item.deType === 0">
|
|
|
|
<svg-icon v-if="item.deType === 0" icon-class="field_text" class="field-icon-text" />
|
|
|
|
</span>
|
|
|
|
<span v-if="item.deType === 1">
|
|
|
|
<svg-icon v-if="item.deType === 1" icon-class="field_time" class="field-icon-time" />
|
|
|
|
</span>
|
|
|
|
<span v-if="item.deType === 2 || item.deType === 3">
|
|
|
|
<svg-icon v-if="item.deType === 2 || item.deType === 3" icon-class="field_value" class="field-icon-value" />
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
<span>
|
|
|
|
{{ item.name }}
|
|
|
|
</span>
|
|
|
|
</el-option>
|
|
|
|
</el-select>
|
|
|
|
</el-col>
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
<el-button size="mini" @click="closeUnion">{{ $t('dataset.cancel') }}</el-button>
|
|
|
|
<el-button type="primary" size="mini" @click="saveUnion">{{ $t('dataset.confirm') }}</el-button>
|
|
|
|
</div>
|
|
|
|
</el-dialog>
|
|
|
|
</el-row>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { post, fieldList } from '../../../api/dataset/dataset'
|
|
|
|
import DatasetGroupSelector from '../common/DatasetGroupSelector'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'UnionView',
|
|
|
|
components: { DatasetGroupSelector },
|
|
|
|
props: {
|
|
|
|
table: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2021-05-12 16:39:53 +08:00
|
|
|
height: 500,
|
2021-05-07 14:51:40 +08:00
|
|
|
union: {
|
|
|
|
id: null,
|
|
|
|
sourceTableId: this.table.id,
|
|
|
|
sourceTableFieldId: '',
|
|
|
|
sourceUnionRelation: '',
|
|
|
|
targetTableId: '',
|
|
|
|
targetTableFieldId: '',
|
|
|
|
targetUnionRelation: ''
|
|
|
|
},
|
|
|
|
unionData: [],
|
|
|
|
editUnion: false,
|
|
|
|
sourceFieldOption: [],
|
2021-05-08 10:36:06 +08:00
|
|
|
targetFieldOption: [],
|
2021-06-16 18:29:00 +08:00
|
|
|
targetTable: {},
|
|
|
|
customType: ['db', 'sql', 'excel']
|
2021-05-07 14:51:40 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
'table': function() {
|
|
|
|
this.initUnion()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2021-05-12 16:39:53 +08:00
|
|
|
this.calHeight()
|
2021-05-07 14:51:40 +08:00
|
|
|
this.initUnion()
|
|
|
|
},
|
|
|
|
methods: {
|
2021-05-12 16:39:53 +08:00
|
|
|
calHeight() {
|
|
|
|
const that = this
|
|
|
|
setTimeout(function() {
|
|
|
|
const currentHeight = document.documentElement.clientHeight
|
|
|
|
that.height = currentHeight - 56 - 30 - 26 - 25 - 55 - 38 - 28 - 10
|
|
|
|
}, 10)
|
|
|
|
},
|
2021-05-07 14:51:40 +08:00
|
|
|
initUnion() {
|
2021-05-10 15:22:36 +08:00
|
|
|
if (this.table.id) {
|
|
|
|
post('dataset/union/listByTableId/' + this.table.id, {}).then(response => {
|
|
|
|
// console.log(response)
|
|
|
|
this.unionData = response.data
|
|
|
|
})
|
|
|
|
}
|
2021-05-07 14:51:40 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
showUnionEdit() {
|
2021-06-16 18:29:00 +08:00
|
|
|
// 校验同步状态
|
2021-06-16 19:25:33 +08:00
|
|
|
// post('/dataset/table/checkDorisTableIsExists/' + this.table.id, {}, true).then(response => {
|
|
|
|
// if (response.data) {
|
|
|
|
this.union.sourceTableId = this.table.id
|
|
|
|
fieldList(this.table.id).then(response => {
|
|
|
|
this.sourceFieldOption = response.data
|
2021-05-07 14:51:40 +08:00
|
|
|
})
|
2021-06-16 19:25:33 +08:00
|
|
|
this.editUnion = true
|
|
|
|
// } else {
|
|
|
|
// this.$message({
|
|
|
|
// type: 'error',
|
|
|
|
// message: this.$t('dataset.invalid_table_check'),
|
|
|
|
// showClose: true
|
|
|
|
// })
|
|
|
|
// }
|
|
|
|
// })
|
2021-05-07 14:51:40 +08:00
|
|
|
},
|
|
|
|
saveUnion() {
|
2021-05-10 15:22:36 +08:00
|
|
|
// console.log(this.union)
|
2021-05-07 14:51:40 +08:00
|
|
|
if (!this.union.sourceTableFieldId || !this.union.sourceUnionRelation || !this.union.targetTableId || !this.union.targetTableFieldId) {
|
|
|
|
this.$message({
|
|
|
|
type: 'error',
|
|
|
|
message: this.$t('dataset.pls_setting_union_success'),
|
|
|
|
showClose: true
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.union.targetUnionRelation = this.union.sourceUnionRelation.split('').reverse().join('')
|
|
|
|
post('dataset/union/save', this.union).then(response => {
|
|
|
|
this.$message({
|
|
|
|
type: 'success',
|
|
|
|
message: this.$t('dataset.save_success'),
|
|
|
|
showClose: true
|
|
|
|
})
|
|
|
|
this.closeUnion()
|
|
|
|
this.initUnion()
|
|
|
|
})
|
|
|
|
},
|
|
|
|
closeUnion() {
|
|
|
|
this.editUnion = false
|
|
|
|
this.resetUnion()
|
|
|
|
},
|
|
|
|
resetUnion() {
|
|
|
|
this.union = {
|
|
|
|
id: null,
|
|
|
|
sourceTableId: this.table.id,
|
|
|
|
sourceTableFieldId: '',
|
|
|
|
sourceUnionRelation: '',
|
|
|
|
targetTableId: '',
|
|
|
|
targetTableFieldId: '',
|
|
|
|
targetUnionRelation: ''
|
|
|
|
}
|
2021-05-25 11:53:19 +08:00
|
|
|
this.targetTable = {}
|
2021-05-07 14:51:40 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
edit(item) {
|
|
|
|
this.union = JSON.parse(JSON.stringify(item))
|
2021-05-08 10:36:06 +08:00
|
|
|
this.targetTable.name = this.union.targetTableName
|
2021-05-07 14:51:40 +08:00
|
|
|
fieldList(this.union.targetTableId).then(response => {
|
|
|
|
this.targetFieldOption = response.data
|
|
|
|
this.showUnionEdit()
|
|
|
|
})
|
|
|
|
},
|
|
|
|
deleteUnion(item) {
|
|
|
|
this.$confirm(this.$t('dataset.confirm_delete'), this.$t('dataset.tips'), {
|
|
|
|
confirmButtonText: this.$t('dataset.confirm'),
|
|
|
|
cancelButtonText: this.$t('dataset.cancel'),
|
|
|
|
type: 'warning'
|
|
|
|
}).then(() => {
|
|
|
|
post('dataset/union/delete/' + item.id, {}).then(response => {
|
|
|
|
this.$message({
|
|
|
|
type: 'success',
|
|
|
|
message: this.$t('dataset.delete_success'),
|
|
|
|
showClose: true
|
|
|
|
})
|
|
|
|
this.initUnion()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getTable(param) {
|
|
|
|
// console.log(param)
|
2021-05-10 15:22:36 +08:00
|
|
|
if (param.id === this.table.id) {
|
|
|
|
this.$message({
|
|
|
|
type: 'error',
|
|
|
|
message: this.$t('dataset.can_not_union_self'),
|
|
|
|
showClose: true
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
2021-05-08 10:36:06 +08:00
|
|
|
this.targetTable = param
|
2021-05-07 14:51:40 +08:00
|
|
|
this.union.targetTableId = param.id
|
|
|
|
this.union.targetTableFieldId = ''
|
|
|
|
fieldList(param.id).then(response => {
|
|
|
|
this.targetFieldOption = response.data
|
|
|
|
})
|
2021-05-08 10:36:06 +08:00
|
|
|
this.$refs['targetTable'].doClose()
|
2021-05-07 14:51:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.table-name-css{
|
|
|
|
margin: 4px 2px;
|
2021-06-11 17:11:13 +08:00
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
2021-05-07 14:51:40 +08:00
|
|
|
}
|
|
|
|
.union-relation-css{
|
|
|
|
display: block;
|
|
|
|
width: 100%;
|
|
|
|
padding: 4px 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.dialog-css>>>.el-dialog__title {
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
|
|
|
.dialog-css >>> .el-dialog__header {
|
|
|
|
padding: 20px 20px 0;
|
|
|
|
}
|
|
|
|
.dialog-css >>> .el-dialog__body {
|
|
|
|
padding: 10px 20px 20px;
|
|
|
|
}
|
|
|
|
</style>
|