2021-03-03 15:06:52 +08:00
|
|
|
<template xmlns:el-col="http://www.w3.org/1999/html">
|
|
|
|
<el-col>
|
|
|
|
<!-- group -->
|
|
|
|
<el-col v-if="!sceneMode">
|
|
|
|
<el-row class="title-css">
|
|
|
|
<span class="title-text">
|
|
|
|
{{ $t('dataset.datalist') }}
|
|
|
|
</span>
|
|
|
|
</el-row>
|
2021-03-11 14:36:02 +08:00
|
|
|
<el-divider />
|
2021-03-03 15:06:52 +08:00
|
|
|
|
|
|
|
<el-row>
|
|
|
|
<el-button icon="el-icon-circle-plus" type="primary" size="mini" @click="add('group')">
|
|
|
|
{{ $t('dataset.add_group') }}
|
|
|
|
</el-button>
|
|
|
|
<el-button icon="el-icon-folder-add" type="primary" size="mini" @click="add('scene')">
|
|
|
|
{{ $t('dataset.add_scene') }}
|
|
|
|
</el-button>
|
|
|
|
</el-row>
|
|
|
|
|
2021-03-30 12:24:27 +08:00
|
|
|
<!-- <el-row>-->
|
|
|
|
<!-- <el-form>-->
|
|
|
|
<!-- <el-form-item class="form-item">-->
|
|
|
|
<!-- <el-input-->
|
|
|
|
<!-- v-model="search"-->
|
|
|
|
<!-- size="mini"-->
|
|
|
|
<!-- :placeholder="$t('dataset.search')"-->
|
|
|
|
<!-- prefix-icon="el-icon-search"-->
|
|
|
|
<!-- clearable-->
|
|
|
|
<!-- />-->
|
|
|
|
<!-- </el-form-item>-->
|
|
|
|
<!-- </el-form>-->
|
|
|
|
<!-- </el-row>-->
|
2021-03-03 15:06:52 +08:00
|
|
|
|
|
|
|
<el-col class="custom-tree-container">
|
|
|
|
<div class="block">
|
|
|
|
<el-tree
|
|
|
|
:default-expanded-keys="expandedArray"
|
2021-03-03 17:38:41 +08:00
|
|
|
:data="tData"
|
2021-03-03 15:06:52 +08:00
|
|
|
node-key="id"
|
|
|
|
:expand-on-click-node="true"
|
|
|
|
@node-click="nodeClick"
|
|
|
|
>
|
|
|
|
<span slot-scope="{ node, data }" class="custom-tree-node">
|
2021-05-07 18:29:15 +08:00
|
|
|
<span style="display: flex;flex: 1;width: 0;">
|
2021-03-03 15:06:52 +08:00
|
|
|
<span v-if="data.type === 'scene'">
|
2021-04-12 18:43:13 +08:00
|
|
|
<!-- <el-button-->
|
|
|
|
<!-- icon="el-icon-folder-opened"-->
|
|
|
|
<!-- type="text"-->
|
|
|
|
<!-- size="mini"-->
|
|
|
|
<!-- />-->
|
|
|
|
<svg-icon icon-class="scene" class="ds-icon-scene" />
|
2021-03-03 15:06:52 +08:00
|
|
|
</span>
|
2021-05-07 18:29:15 +08:00
|
|
|
<span style="margin-left: 6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">{{ data.name }}</span>
|
2021-03-03 15:06:52 +08:00
|
|
|
</span>
|
|
|
|
<span>
|
|
|
|
<span v-if="data.type ==='group'" @click.stop>
|
|
|
|
<el-dropdown trigger="click" size="small" @command="clickAdd">
|
|
|
|
<span class="el-dropdown-link">
|
|
|
|
<el-button
|
|
|
|
icon="el-icon-plus"
|
|
|
|
type="text"
|
|
|
|
size="small"
|
|
|
|
/>
|
|
|
|
</span>
|
|
|
|
<el-dropdown-menu slot="dropdown">
|
|
|
|
<el-dropdown-item icon="el-icon-circle-plus" :command="beforeClickAdd('group',data,node)">
|
|
|
|
{{ $t('dataset.group') }}
|
|
|
|
</el-dropdown-item>
|
|
|
|
<el-dropdown-item icon="el-icon-folder-add" :command="beforeClickAdd('scene',data,node)">
|
|
|
|
{{ $t('dataset.scene') }}
|
|
|
|
</el-dropdown-item>
|
|
|
|
</el-dropdown-menu>
|
|
|
|
</el-dropdown>
|
|
|
|
</span>
|
|
|
|
<span style="margin-left: 12px;" @click.stop>
|
|
|
|
<el-dropdown trigger="click" size="small" @command="clickMore">
|
|
|
|
<span class="el-dropdown-link">
|
|
|
|
<el-button
|
|
|
|
icon="el-icon-more"
|
|
|
|
type="text"
|
|
|
|
size="small"
|
|
|
|
/>
|
|
|
|
</span>
|
|
|
|
<el-dropdown-menu slot="dropdown">
|
|
|
|
<el-dropdown-item icon="el-icon-edit-outline" :command="beforeClickMore('rename',data,node)">
|
|
|
|
{{ $t('dataset.rename') }}
|
|
|
|
</el-dropdown-item>
|
|
|
|
<!-- <el-dropdown-item icon="el-icon-right" :command="beforeClickMore('move',data,node)">-->
|
|
|
|
<!-- {{$t('dataset.move_to')}}-->
|
|
|
|
<!-- </el-dropdown-item>-->
|
|
|
|
<el-dropdown-item icon="el-icon-delete" :command="beforeClickMore('delete',data,node)">
|
|
|
|
{{ $t('dataset.delete') }}
|
|
|
|
</el-dropdown-item>
|
|
|
|
</el-dropdown-menu>
|
|
|
|
</el-dropdown>
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</el-tree>
|
|
|
|
</div>
|
|
|
|
</el-col>
|
|
|
|
|
2021-05-07 11:04:50 +08:00
|
|
|
<el-dialog v-dialogDrag :title="dialogTitle" :visible="editGroup" :show-close="false" width="30%">
|
2021-03-03 15:06:52 +08:00
|
|
|
<el-form ref="groupForm" :model="groupForm" :rules="groupFormRules">
|
|
|
|
<el-form-item :label="$t('commons.name')" prop="name">
|
2021-03-11 14:36:02 +08:00
|
|
|
<el-input v-model="groupForm.name" />
|
2021-03-03 15:06:52 +08:00
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
<el-button size="mini" @click="close()">{{ $t('dataset.cancel') }}</el-button>
|
2021-03-03 18:35:51 +08:00
|
|
|
<el-button type="primary" size="mini" @click="saveGroup(groupForm)">{{ $t('dataset.confirm') }}
|
|
|
|
</el-button>
|
2021-03-03 15:06:52 +08:00
|
|
|
</div>
|
|
|
|
</el-dialog>
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
<!--scene-->
|
|
|
|
<el-col v-if="sceneMode">
|
|
|
|
<el-row class="title-css">
|
|
|
|
<span class="title-text">
|
|
|
|
{{ currGroup.name }}
|
|
|
|
</span>
|
2021-04-12 18:24:02 +08:00
|
|
|
<el-button icon="el-icon-back" size="mini" style="float: right" circle @click="back">
|
|
|
|
<!-- {{ $t('dataset.back') }}-->
|
2021-03-03 15:06:52 +08:00
|
|
|
</el-button>
|
|
|
|
</el-row>
|
2021-03-11 14:36:02 +08:00
|
|
|
<el-divider />
|
2021-03-03 15:06:52 +08:00
|
|
|
<el-row>
|
|
|
|
<el-dropdown style="margin-right: 10px;" size="small" trigger="click" @command="clickAddData">
|
|
|
|
<el-button type="primary" size="mini" plain>
|
|
|
|
{{ $t('dataset.add_table') }}
|
|
|
|
</el-button>
|
|
|
|
<el-dropdown-menu slot="dropdown">
|
|
|
|
<el-dropdown-item :command="beforeClickAddData('db')">
|
2021-04-12 17:43:51 +08:00
|
|
|
<svg-icon icon-class="ds-db" class="ds-icon-db" />
|
2021-03-03 15:06:52 +08:00
|
|
|
{{ $t('dataset.db_data') }}
|
|
|
|
</el-dropdown-item>
|
|
|
|
<el-dropdown-item :command="beforeClickAddData('sql')">
|
2021-04-12 17:43:51 +08:00
|
|
|
<svg-icon icon-class="ds-sql" class="ds-icon-sql" />
|
2021-03-03 15:06:52 +08:00
|
|
|
{{ $t('dataset.sql_data') }}
|
|
|
|
</el-dropdown-item>
|
|
|
|
<el-dropdown-item :command="beforeClickAddData('excel')">
|
2021-04-12 17:43:51 +08:00
|
|
|
<svg-icon icon-class="ds-excel" class="ds-icon-excel" />
|
2021-03-03 15:06:52 +08:00
|
|
|
{{ $t('dataset.excel_data') }}
|
|
|
|
</el-dropdown-item>
|
|
|
|
<el-dropdown-item :command="beforeClickAddData('custom')">
|
2021-04-12 17:43:51 +08:00
|
|
|
<svg-icon icon-class="ds-custom" class="ds-icon-custom" />
|
2021-03-03 15:06:52 +08:00
|
|
|
{{ $t('dataset.custom_data') }}
|
|
|
|
</el-dropdown-item>
|
|
|
|
</el-dropdown-menu>
|
|
|
|
</el-dropdown>
|
|
|
|
<!-- <el-button type="primary" size="mini" plain>
|
|
|
|
{{ $t('dataset.update') }}
|
|
|
|
</el-button>
|
|
|
|
<el-button type="primary" size="mini" plain>
|
|
|
|
{{ $t('dataset.process') }}
|
|
|
|
</el-button> -->
|
|
|
|
</el-row>
|
|
|
|
<el-row>
|
|
|
|
<el-form>
|
|
|
|
<el-form-item class="form-item">
|
|
|
|
<el-input
|
|
|
|
v-model="search"
|
|
|
|
size="mini"
|
|
|
|
:placeholder="$t('dataset.search')"
|
|
|
|
prefix-icon="el-icon-search"
|
|
|
|
clearable
|
|
|
|
/>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
</el-row>
|
|
|
|
<span v-show="false">{{ sceneData }}</span>
|
|
|
|
<el-tree
|
|
|
|
:data="tableData"
|
|
|
|
node-key="id"
|
|
|
|
:expand-on-click-node="true"
|
2021-03-30 12:24:27 +08:00
|
|
|
class="tree-list"
|
2021-04-29 16:16:56 +08:00
|
|
|
highlight-current
|
2021-03-03 15:06:52 +08:00
|
|
|
@node-click="sceneClick"
|
|
|
|
>
|
2021-03-30 18:11:32 +08:00
|
|
|
<span slot-scope="{ node, data }" class="custom-tree-node-list">
|
2021-05-07 18:29:15 +08:00
|
|
|
<span style="display: flex;flex: 1;width: 0;">
|
2021-03-03 15:06:52 +08:00
|
|
|
<span>
|
2021-04-12 17:43:51 +08:00
|
|
|
<svg-icon v-if="data.type === 'db'" icon-class="ds-db" class="ds-icon-db" />
|
|
|
|
<svg-icon v-if="data.type === 'sql'" icon-class="ds-sql" class="ds-icon-sql" />
|
|
|
|
<svg-icon v-if="data.type === 'excel'" icon-class="ds-excel" class="ds-icon-excel" />
|
|
|
|
<svg-icon v-if="data.type === 'custom'" icon-class="ds-custom" class="ds-icon-custom" />
|
2021-03-03 15:06:52 +08:00
|
|
|
</span>
|
2021-04-20 11:48:38 +08:00
|
|
|
<span v-if="data.type === 'db' || data.type === 'sql'">
|
2021-03-11 14:36:02 +08:00
|
|
|
<span v-if="data.mode === 0" style="margin-left: 6px"><i class="el-icon-s-operation" /></span>
|
2021-04-12 17:18:07 +08:00
|
|
|
<span v-if="data.mode === 1" style="margin-left: 6px"><i class="el-icon-alarm-clock" /></span>
|
2021-03-03 15:06:52 +08:00
|
|
|
</span>
|
2021-05-07 18:29:15 +08:00
|
|
|
<span style="margin-left: 6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">{{ data.name }}</span>
|
2021-03-03 15:06:52 +08:00
|
|
|
</span>
|
|
|
|
<span>
|
|
|
|
<span style="margin-left: 12px;" @click.stop>
|
|
|
|
<el-dropdown trigger="click" size="small" @command="clickMore">
|
|
|
|
<span class="el-dropdown-link">
|
|
|
|
<el-button
|
|
|
|
icon="el-icon-more"
|
|
|
|
type="text"
|
|
|
|
size="small"
|
|
|
|
/>
|
|
|
|
</span>
|
|
|
|
<el-dropdown-menu slot="dropdown">
|
|
|
|
<el-dropdown-item icon="el-icon-edit-outline" :command="beforeClickMore('editTable',data,node)">
|
2021-04-27 18:43:15 +08:00
|
|
|
{{ $t('dataset.rename') }}
|
2021-03-03 15:06:52 +08:00
|
|
|
</el-dropdown-item>
|
|
|
|
<!-- <el-dropdown-item icon="el-icon-right" :command="beforeClickMore('move',data,node)">-->
|
|
|
|
<!-- {{$t('dataset.move_to')}}-->
|
|
|
|
<!-- </el-dropdown-item>-->
|
|
|
|
<el-dropdown-item icon="el-icon-delete" :command="beforeClickMore('deleteTable',data,node)">
|
|
|
|
{{ $t('dataset.delete') }}
|
|
|
|
</el-dropdown-item>
|
|
|
|
</el-dropdown-menu>
|
|
|
|
</el-dropdown>
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</el-tree>
|
|
|
|
|
2021-05-07 11:04:50 +08:00
|
|
|
<el-dialog v-dialogDrag :title="$t('dataset.table')" :visible="editTable" :show-close="false" width="30%">
|
2021-03-03 15:06:52 +08:00
|
|
|
<el-form ref="tableForm" :model="tableForm" :rules="tableFormRules">
|
|
|
|
<el-form-item :label="$t('commons.name')" prop="name">
|
2021-03-11 14:36:02 +08:00
|
|
|
<el-input v-model="tableForm.name" />
|
2021-03-03 15:06:52 +08:00
|
|
|
</el-form-item>
|
2021-03-11 14:36:02 +08:00
|
|
|
<!-- <el-form-item :label="$t('dataset.mode')" prop="mode">-->
|
|
|
|
<!-- <el-radio v-model="tableForm.mode" label="0">{{ $t('dataset.direct_connect') }}</el-radio>-->
|
|
|
|
<!-- <el-radio v-model="tableForm.mode" label="1">{{ $t('dataset.sync_data') }}</el-radio>-->
|
|
|
|
<!-- </el-form-item>-->
|
2021-03-03 15:06:52 +08:00
|
|
|
</el-form>
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
<el-button size="mini" @click="closeTable()">{{ $t('dataset.cancel') }}</el-button>
|
2021-03-03 18:35:51 +08:00
|
|
|
<el-button type="primary" size="mini" @click="saveTable(tableForm)">{{ $t('dataset.confirm') }}
|
|
|
|
</el-button>
|
2021-03-03 15:06:52 +08:00
|
|
|
</div>
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
</el-col>
|
|
|
|
</el-col>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree } from '@/api/dataset/dataset'
|
2021-03-03 18:35:51 +08:00
|
|
|
|
2021-03-03 15:06:52 +08:00
|
|
|
export default {
|
|
|
|
name: 'Group',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
sceneMode: false,
|
|
|
|
dialogTitle: '',
|
|
|
|
search: '',
|
|
|
|
editGroup: false,
|
|
|
|
editTable: false,
|
2021-03-03 17:38:41 +08:00
|
|
|
tData: [],
|
2021-03-03 15:06:52 +08:00
|
|
|
tableData: [],
|
2021-03-30 12:24:27 +08:00
|
|
|
tables: [],
|
2021-03-03 15:06:52 +08:00
|
|
|
currGroup: {},
|
|
|
|
expandedArray: [],
|
|
|
|
groupForm: {
|
|
|
|
name: '',
|
|
|
|
pid: null,
|
|
|
|
level: 0,
|
|
|
|
type: '',
|
|
|
|
children: [],
|
|
|
|
sort: 'type desc,name asc'
|
|
|
|
},
|
|
|
|
tableForm: {
|
|
|
|
name: '',
|
|
|
|
mode: '',
|
|
|
|
sort: 'type asc,create_time desc,name asc'
|
|
|
|
},
|
|
|
|
groupFormRules: {
|
|
|
|
name: [
|
2021-03-04 15:38:37 +08:00
|
|
|
{ required: true, message: this.$t('commons.input_content'), trigger: 'change' }
|
2021-03-03 15:06:52 +08:00
|
|
|
]
|
|
|
|
},
|
|
|
|
tableFormRules: {
|
|
|
|
name: [
|
2021-03-04 15:38:37 +08:00
|
|
|
{ required: true, message: this.$t('commons.input_content'), trigger: 'change' }
|
2021-03-03 15:06:52 +08:00
|
|
|
],
|
|
|
|
mode: [
|
2021-03-04 15:38:37 +08:00
|
|
|
{ required: true, message: this.$t('commons.input_content'), trigger: 'change' }
|
2021-03-03 15:06:52 +08:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
sceneData: function() {
|
|
|
|
console.log(this.$store.state.dataset.sceneData + ' do post')
|
|
|
|
this.tableTree()
|
|
|
|
return this.$store.state.dataset.sceneData
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
// search(val){
|
|
|
|
// this.groupForm.name = val;
|
|
|
|
// this.tree(this.groupForm);
|
|
|
|
// }
|
2021-03-30 12:24:27 +08:00
|
|
|
search(val) {
|
|
|
|
if (val && val !== '') {
|
|
|
|
this.tableData = JSON.parse(JSON.stringify(this.tables.filter(ele => { return ele.name.includes(val) })))
|
|
|
|
} else {
|
|
|
|
this.tableData = JSON.parse(JSON.stringify(this.tables))
|
|
|
|
}
|
|
|
|
}
|
2021-03-03 15:06:52 +08:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.tree(this.groupForm)
|
|
|
|
this.refresh()
|
|
|
|
this.tableTree()
|
|
|
|
// this.$router.push('/dataset');
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
clickAdd(param) {
|
|
|
|
// console.log(param);
|
|
|
|
this.add(param.type)
|
|
|
|
this.groupForm.pid = param.data.id
|
|
|
|
this.groupForm.level = param.data.level + 1
|
|
|
|
},
|
|
|
|
|
|
|
|
beforeClickAdd(type, data, node) {
|
|
|
|
return {
|
|
|
|
'type': type,
|
|
|
|
'data': data,
|
|
|
|
'node': node
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
clickMore(param) {
|
2021-03-08 11:35:28 +08:00
|
|
|
// console.log(param)
|
2021-03-03 15:06:52 +08:00
|
|
|
switch (param.type) {
|
|
|
|
case 'rename':
|
|
|
|
this.add(param.data.type)
|
|
|
|
this.groupForm = JSON.parse(JSON.stringify(param.data))
|
|
|
|
break
|
|
|
|
case 'move':
|
|
|
|
|
|
|
|
break
|
|
|
|
case 'delete':
|
|
|
|
this.delete(param.data)
|
|
|
|
break
|
|
|
|
case 'editTable':
|
|
|
|
this.editTable = true
|
|
|
|
this.tableForm = JSON.parse(JSON.stringify(param.data))
|
|
|
|
this.tableForm.mode = this.tableForm.mode + ''
|
|
|
|
break
|
|
|
|
case 'deleteTable':
|
|
|
|
this.deleteTable(param.data)
|
|
|
|
break
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
beforeClickMore(type, data, node) {
|
|
|
|
return {
|
|
|
|
'type': type,
|
|
|
|
'data': data,
|
|
|
|
'node': node
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
add(type) {
|
|
|
|
switch (type) {
|
|
|
|
case 'group':
|
|
|
|
this.dialogTitle = this.$t('dataset.group')
|
|
|
|
break
|
|
|
|
case 'scene':
|
|
|
|
this.dialogTitle = this.$t('dataset.scene')
|
|
|
|
break
|
|
|
|
}
|
|
|
|
this.groupForm.type = type
|
|
|
|
this.editGroup = true
|
|
|
|
},
|
|
|
|
|
|
|
|
saveGroup(group) {
|
|
|
|
// console.log(group);
|
|
|
|
this.$refs['groupForm'].validate((valid) => {
|
|
|
|
if (valid) {
|
|
|
|
addGroup(group).then(res => {
|
|
|
|
this.close()
|
|
|
|
this.$message({
|
2021-03-04 15:38:37 +08:00
|
|
|
message: this.$t('dataset.save_success'),
|
2021-03-03 15:06:52 +08:00
|
|
|
type: 'success',
|
|
|
|
showClose: true
|
|
|
|
})
|
|
|
|
this.tree(this.groupForm)
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.$message({
|
|
|
|
message: this.$t('commons.input_content'),
|
|
|
|
type: 'error',
|
|
|
|
showClose: true
|
|
|
|
})
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
saveTable(table) {
|
2021-03-03 18:35:51 +08:00
|
|
|
// console.log(table)
|
2021-03-03 15:06:52 +08:00
|
|
|
table.mode = parseInt(table.mode)
|
|
|
|
this.$refs['tableForm'].validate((valid) => {
|
|
|
|
if (valid) {
|
|
|
|
addTable(table).then(response => {
|
|
|
|
this.closeTable()
|
|
|
|
this.$message({
|
2021-03-04 15:38:37 +08:00
|
|
|
message: this.$t('dataset.save_success'),
|
2021-03-03 15:06:52 +08:00
|
|
|
type: 'success',
|
|
|
|
showClose: true
|
|
|
|
})
|
|
|
|
this.tableTree()
|
2021-03-03 18:35:51 +08:00
|
|
|
// this.$router.push('/dataset/home')
|
|
|
|
this.$emit('switchComponent', { name: '' })
|
2021-03-03 15:06:52 +08:00
|
|
|
this.$store.dispatch('dataset/setTable', null)
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.$message({
|
|
|
|
message: this.$t('commons.input_content'),
|
|
|
|
type: 'error',
|
|
|
|
showClose: true
|
|
|
|
})
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
delete(data) {
|
|
|
|
this.$confirm(this.$t('dataset.confirm_delete'), this.$t('dataset.tips'), {
|
|
|
|
confirmButtonText: this.$t('dataset.confirm'),
|
|
|
|
cancelButtonText: this.$t('dataset.cancel'),
|
|
|
|
type: 'warning'
|
|
|
|
}).then(() => {
|
|
|
|
delGroup(data.id).then(response => {
|
|
|
|
this.$message({
|
|
|
|
type: 'success',
|
|
|
|
message: this.$t('dataset.delete_success'),
|
|
|
|
showClose: true
|
|
|
|
})
|
|
|
|
this.tree(this.groupForm)
|
|
|
|
})
|
|
|
|
}).catch(() => {
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
deleteTable(data) {
|
|
|
|
this.$confirm(this.$t('dataset.confirm_delete'), this.$t('dataset.tips'), {
|
|
|
|
confirmButtonText: this.$t('dataset.confirm'),
|
|
|
|
cancelButtonText: this.$t('dataset.cancel'),
|
|
|
|
type: 'warning'
|
|
|
|
}).then(() => {
|
|
|
|
delTable(data.id).then(response => {
|
|
|
|
this.$message({
|
|
|
|
type: 'success',
|
|
|
|
message: this.$t('dataset.delete_success'),
|
|
|
|
showClose: true
|
|
|
|
})
|
|
|
|
this.tableTree()
|
2021-03-03 18:35:51 +08:00
|
|
|
// this.$router.push('/dataset/home')
|
|
|
|
this.$emit('switchComponent', { name: '' })
|
2021-03-03 15:06:52 +08:00
|
|
|
this.$store.dispatch('dataset/setTable', null)
|
|
|
|
})
|
|
|
|
}).catch(() => {
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
close() {
|
|
|
|
this.editGroup = false
|
|
|
|
this.groupForm = {
|
|
|
|
name: '',
|
|
|
|
pid: null,
|
|
|
|
level: 0,
|
|
|
|
type: '',
|
|
|
|
children: [],
|
|
|
|
sort: 'type desc,name asc'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
closeTable() {
|
|
|
|
this.editTable = false
|
|
|
|
this.tableForm = {
|
|
|
|
name: ''
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
tree(group) {
|
|
|
|
groupTree(group).then(res => {
|
2021-03-03 18:20:59 +08:00
|
|
|
this.tData = res.data
|
2021-03-03 15:06:52 +08:00
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
tableTree() {
|
2021-03-30 12:24:27 +08:00
|
|
|
this.tables = []
|
2021-03-03 15:06:52 +08:00
|
|
|
this.tableData = []
|
|
|
|
if (this.currGroup.id) {
|
|
|
|
loadTable({
|
|
|
|
sort: 'type asc,create_time desc,name asc',
|
|
|
|
sceneId: this.currGroup.id
|
|
|
|
}).then(res => {
|
2021-03-30 12:24:27 +08:00
|
|
|
this.tables = res.data
|
|
|
|
this.tableData = JSON.parse(JSON.stringify(this.tables))
|
2021-03-03 15:06:52 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
nodeClick(data, node) {
|
|
|
|
// console.log(data);
|
|
|
|
// console.log(node);
|
|
|
|
if (data.type === 'scene') {
|
|
|
|
this.sceneMode = true
|
|
|
|
this.currGroup = data
|
|
|
|
this.$store.dispatch('dataset/setSceneData', this.currGroup.id)
|
|
|
|
}
|
|
|
|
if (node.expanded) {
|
|
|
|
this.expandedArray.push(data.id)
|
|
|
|
} else {
|
|
|
|
const index = this.expandedArray.indexOf(data.id)
|
|
|
|
if (index > -1) {
|
|
|
|
this.expandedArray.splice(index, 1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// console.log(this.expandedArray);
|
|
|
|
},
|
|
|
|
|
|
|
|
back() {
|
|
|
|
this.sceneMode = false
|
2021-03-03 18:35:51 +08:00
|
|
|
this.$emit('switchComponent', { name: '' })
|
2021-03-03 15:06:52 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
clickAddData(param) {
|
|
|
|
// console.log(param);
|
|
|
|
switch (param.type) {
|
|
|
|
case 'db':
|
2021-03-08 11:35:28 +08:00
|
|
|
this.addData('AddDB')
|
2021-03-03 15:06:52 +08:00
|
|
|
break
|
|
|
|
case 'sql':
|
2021-03-08 11:35:28 +08:00
|
|
|
this.addData('AddSQL')
|
2021-03-03 15:06:52 +08:00
|
|
|
break
|
|
|
|
case 'excel':
|
2021-04-07 18:49:01 +08:00
|
|
|
this.addData('AddExcel')
|
2021-03-03 15:06:52 +08:00
|
|
|
break
|
|
|
|
case 'custom':
|
2021-04-07 18:49:01 +08:00
|
|
|
this.addData('AddCustom')
|
2021-03-03 15:06:52 +08:00
|
|
|
break
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
beforeClickAddData(type) {
|
|
|
|
return {
|
|
|
|
'type': type
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-03-08 11:35:28 +08:00
|
|
|
addData(name) {
|
|
|
|
this.$emit('switchComponent', { name: name, param: this.currGroup })
|
2021-03-03 15:06:52 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
sceneClick(data, node) {
|
2021-04-28 17:30:18 +08:00
|
|
|
this.$emit('switchComponent', { name: 'ViewTable', param: data.id })
|
2021-03-03 15:06:52 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
refresh() {
|
|
|
|
const path = this.$route.path
|
|
|
|
if (path === '/dataset/table') {
|
|
|
|
this.sceneMode = true
|
|
|
|
const sceneId = this.$store.state.dataset.sceneData
|
|
|
|
getScene(sceneId).then(res => {
|
2021-03-03 18:20:59 +08:00
|
|
|
this.currGroup = res.data
|
2021-03-03 15:06:52 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.el-divider--horizontal {
|
|
|
|
margin: 12px 0
|
|
|
|
}
|
|
|
|
|
|
|
|
.search-input {
|
|
|
|
padding: 12px 0;
|
|
|
|
}
|
|
|
|
|
2021-03-30 12:24:27 +08:00
|
|
|
.custom-tree-container{
|
|
|
|
margin-top: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tree-list>>>.el-tree-node__expand-icon.is-leaf{
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
2021-03-03 15:06:52 +08:00
|
|
|
.custom-tree-node {
|
2021-03-30 18:11:32 +08:00
|
|
|
flex: 1;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
font-size: 14px;
|
|
|
|
padding-right:8px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.custom-tree-node-list {
|
2021-03-03 15:06:52 +08:00
|
|
|
flex: 1;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
font-size: 14px;
|
2021-03-30 12:24:27 +08:00
|
|
|
padding:0 8px;
|
2021-03-03 15:06:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
.custom-position {
|
|
|
|
flex: 1;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
font-size: 14px;
|
|
|
|
flex-flow: row nowrap;
|
|
|
|
}
|
|
|
|
|
|
|
|
.form-item {
|
|
|
|
margin-bottom: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.title-css {
|
|
|
|
height: 26px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.title-text {
|
|
|
|
line-height: 26px;
|
|
|
|
}
|
|
|
|
</style>
|