2021-06-19 11:42:14 +08:00
|
|
|
<template>
|
2021-07-01 10:47:28 +08:00
|
|
|
<el-col class="tree-style">
|
2021-03-03 15:06:52 +08:00
|
|
|
<!-- group -->
|
2021-11-25 15:17:00 +08:00
|
|
|
<el-col>
|
2021-03-03 15:06:52 +08:00
|
|
|
<el-row class="title-css">
|
|
|
|
<span class="title-text">
|
|
|
|
{{ $t('dataset.datalist') }}
|
|
|
|
</span>
|
2021-11-18 18:16:43 +08:00
|
|
|
<el-button icon="el-icon-plus" type="text" size="mini" style="float: right;" @click="add('group')" />
|
2021-03-03 15:06:52 +08:00
|
|
|
</el-row>
|
2021-03-11 14:36:02 +08:00
|
|
|
<el-divider />
|
2021-03-03 15:06:52 +08:00
|
|
|
|
2021-11-25 15:17:00 +08:00
|
|
|
<el-row style="margin-bottom: 10px">
|
|
|
|
<el-col :span="16">
|
|
|
|
<el-input
|
|
|
|
v-model="filterText"
|
|
|
|
size="mini"
|
|
|
|
:placeholder="$t('commons.search')"
|
|
|
|
prefix-icon="el-icon-search"
|
|
|
|
clearable
|
|
|
|
class="main-area-input"
|
|
|
|
/>
|
|
|
|
</el-col>
|
|
|
|
<el-col :span="8">
|
|
|
|
<el-dropdown>
|
|
|
|
<el-button size="mini" type="primary">
|
|
|
|
{{ searchMap[searchType] }}<i class="el-icon-arrow-down el-icon--right" />
|
|
|
|
</el-button>
|
|
|
|
<el-dropdown-menu slot="dropdown">
|
|
|
|
<el-dropdown-item @click.native="searchTypeClick('all')">{{ $t('commons.all') }}</el-dropdown-item>
|
|
|
|
<el-dropdown-item @click.native="searchTypeClick('folder')">{{ this.$t('commons.folder') }}
|
|
|
|
</el-dropdown-item>
|
|
|
|
</el-dropdown-menu>
|
|
|
|
</el-dropdown>
|
|
|
|
</el-col>
|
2021-06-21 16:24:16 +08:00
|
|
|
</el-row>
|
2021-03-03 15:06:52 +08:00
|
|
|
|
|
|
|
<el-col class="custom-tree-container">
|
|
|
|
<div class="block">
|
|
|
|
<el-tree
|
2021-11-25 15:17:00 +08:00
|
|
|
ref="datasetTreeRef"
|
2021-03-03 15:06:52 +08:00
|
|
|
: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"
|
2021-06-19 11:42:14 +08:00
|
|
|
highlight-current
|
2021-11-25 15:17:00 +08:00
|
|
|
:expand-on-click-node="true"
|
|
|
|
:filter-node-method="filterNode"
|
2021-12-06 11:54:34 +08:00
|
|
|
@node-expand="nodeExpand"
|
|
|
|
@node-collapse="nodeCollapse"
|
2021-03-03 15:06:52 +08:00
|
|
|
@node-click="nodeClick"
|
|
|
|
>
|
2021-11-25 15:17:00 +08:00
|
|
|
<span v-if="data.modelInnerType === 'group'" slot-scope="{ node, data }" class="custom-tree-node father">
|
2021-05-07 18:29:15 +08:00
|
|
|
<span style="display: flex;flex: 1;width: 0;">
|
2021-06-21 12:38:04 +08:00
|
|
|
<span>
|
|
|
|
<i class="el-icon-folder" />
|
|
|
|
</span>
|
2021-06-04 17:16:50 +08:00
|
|
|
<span style="margin-left: 6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" :title="data.name">{{ data.name }}</span>
|
2021-03-03 15:06:52 +08:00
|
|
|
</span>
|
2021-06-08 15:00:13 +08:00
|
|
|
<span v-if="hasDataPermission('manage',data.privileges)" class="child">
|
2021-11-25 15:17:00 +08:00
|
|
|
<span v-if="data.modelInnerType ==='group'" @click.stop>
|
2021-03-03 15:06:52 +08:00
|
|
|
<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">
|
2021-06-19 12:07:16 +08:00
|
|
|
<el-dropdown-item icon="el-icon-folder-add" :command="beforeClickAdd('group',data,node)">
|
2021-06-19 11:42:14 +08:00
|
|
|
<span style="font-size: 13px;">{{ $t('dataset.group') }}</span>
|
2021-03-03 15:06:52 +08:00
|
|
|
</el-dropdown-item>
|
2021-06-19 12:07:16 +08:00
|
|
|
<el-dropdown-item icon="el-icon-circle-plus">
|
2021-06-19 11:42:14 +08:00
|
|
|
<el-dropdown size="small" placement="right-start" @command="clickAddData">
|
|
|
|
<span class="el-dropdown-link inner-dropdown-menu">
|
|
|
|
<span>
|
|
|
|
<span style="font-size: 13px;">{{ $t('dataset.add_table') }}</span>
|
|
|
|
</span>
|
|
|
|
<i class="el-icon-arrow-right el-icon--right" />
|
|
|
|
</span>
|
|
|
|
<el-dropdown-menu slot="dropdown">
|
|
|
|
<el-dropdown-item :command="beforeClickAddData('db',data)">
|
|
|
|
<svg-icon icon-class="ds-db" class="ds-icon-db" />
|
|
|
|
{{ $t('dataset.db_data') }}
|
|
|
|
</el-dropdown-item>
|
|
|
|
<el-dropdown-item :command="beforeClickAddData('sql',data)">
|
|
|
|
<svg-icon icon-class="ds-sql" class="ds-icon-sql" />
|
|
|
|
{{ $t('dataset.sql_data') }}
|
|
|
|
</el-dropdown-item>
|
2021-07-23 10:54:44 +08:00
|
|
|
<el-dropdown-item :command="beforeClickAddData('excel',data)" :disabled="!kettleRunning">
|
2021-06-19 11:42:14 +08:00
|
|
|
<svg-icon icon-class="ds-excel" class="ds-icon-excel" />
|
|
|
|
{{ $t('dataset.excel_data') }}
|
|
|
|
</el-dropdown-item>
|
2021-12-22 11:42:44 +08:00
|
|
|
<el-dropdown-item v-show="!hideCustomDs" :command="beforeClickAddData('custom',data)">
|
2021-12-06 09:59:00 +08:00
|
|
|
<svg-icon icon-class="ds-custom" class="ds-icon-custom" />
|
|
|
|
{{ $t('dataset.custom_data') }}
|
|
|
|
</el-dropdown-item>
|
2021-12-02 14:58:42 +08:00
|
|
|
<el-dropdown-item :command="beforeClickAddData('union',data)">
|
|
|
|
<svg-icon icon-class="ds-union" class="ds-icon-union" />
|
|
|
|
{{ $t('dataset.union_data') }}
|
2021-06-19 11:42:14 +08:00
|
|
|
</el-dropdown-item>
|
|
|
|
</el-dropdown-menu>
|
|
|
|
</el-dropdown>
|
2021-03-03 15:06:52 +08:00
|
|
|
</el-dropdown-item>
|
|
|
|
</el-dropdown-menu>
|
|
|
|
</el-dropdown>
|
|
|
|
</span>
|
2021-06-04 17:16:50 +08:00
|
|
|
<span style="margin-left: 12px;" @click.stop>
|
2021-03-03 15:06:52 +08:00
|
|
|
<el-dropdown trigger="click" size="small" @command="clickMore">
|
|
|
|
<span class="el-dropdown-link">
|
|
|
|
<el-button
|
|
|
|
icon="el-icon-more"
|
|
|
|
type="text"
|
|
|
|
size="small"
|
|
|
|
/>
|
|
|
|
</span>
|
2021-06-04 17:16:50 +08:00
|
|
|
<el-dropdown-menu slot="dropdown">
|
2021-03-03 15:06:52 +08:00
|
|
|
<el-dropdown-item icon="el-icon-edit-outline" :command="beforeClickMore('rename',data,node)">
|
|
|
|
{{ $t('dataset.rename') }}
|
|
|
|
</el-dropdown-item>
|
2021-06-09 10:16:58 +08:00
|
|
|
<el-dropdown-item icon="el-icon-right" :command="beforeClickMore('move',data,node)">
|
|
|
|
{{ $t('dataset.move_to') }}
|
|
|
|
</el-dropdown-item>
|
2021-03-03 15:06:52 +08:00
|
|
|
<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>
|
2021-06-19 11:42:14 +08:00
|
|
|
<span v-else slot-scope="{ node, data }" class="custom-tree-node-list father">
|
|
|
|
<span style="display: flex;flex: 1;width: 0;">
|
|
|
|
<span>
|
2021-11-29 17:21:02 +08:00
|
|
|
<svg-icon v-if="data.modelInnerType === 'db'" icon-class="ds-db" class="ds-icon-db" />
|
|
|
|
<svg-icon v-if="data.modelInnerType === 'sql'" icon-class="ds-sql" class="ds-icon-sql" />
|
|
|
|
<svg-icon v-if="data.modelInnerType === 'excel'" icon-class="ds-excel" class="ds-icon-excel" />
|
|
|
|
<svg-icon v-if="data.modelInnerType === 'custom'" icon-class="ds-custom" class="ds-icon-custom" />
|
|
|
|
<svg-icon v-if="data.modelInnerType === 'union'" icon-class="ds-union" class="ds-icon-union" />
|
2021-06-19 11:42:14 +08:00
|
|
|
</span>
|
2021-11-25 15:17:00 +08:00
|
|
|
<span v-if="data.modelInnerType === 'db' || data.modelInnerType === 'sql'">
|
2021-06-19 11:42:14 +08:00
|
|
|
<span v-if="data.mode === 0" style="margin-left: 6px"><i class="el-icon-s-operation" /></span>
|
|
|
|
<span v-if="data.mode === 1" style="margin-left: 6px"><i class="el-icon-alarm-clock" /></span>
|
|
|
|
</span>
|
|
|
|
<span style="margin-left: 6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" :title="data.name">{{ data.name }}</span>
|
|
|
|
</span>
|
|
|
|
<span v-if="hasDataPermission('manage',data.privileges)" class="child">
|
|
|
|
<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)">
|
|
|
|
{{ $t('dataset.rename') }}
|
|
|
|
</el-dropdown-item>
|
|
|
|
<el-dropdown-item icon="el-icon-right" :command="beforeClickMore('moveDs',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>
|
2021-03-03 15:06:52 +08:00
|
|
|
</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-12-30 13:29:16 +08:00
|
|
|
<el-form ref="groupForm" :model="groupForm" :rules="groupFormRules" @submit.native.prevent @keypress.enter.native="saveGroup(groupForm)">
|
2021-03-03 15:06:52 +08:00
|
|
|
<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>
|
|
|
|
|
2021-06-19 11:42:14 +08:00
|
|
|
<el-dialog v-dialogDrag :title="$t('dataset.table')" :visible="editTable" :show-close="false" width="30%">
|
2021-12-30 13:29:16 +08:00
|
|
|
<el-form ref="tableForm" :model="tableForm" :rules="tableFormRules" @submit.native.prevent @keypress.enter.native="saveTable(tableForm)">
|
2021-06-19 11:42:14 +08:00
|
|
|
<el-form-item :label="$t('commons.name')" prop="name">
|
|
|
|
<el-input v-model="tableForm.name" />
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
<el-button size="mini" @click="closeTable()">{{ $t('dataset.cancel') }}</el-button>
|
|
|
|
<el-button type="primary" size="mini" @click="saveTable(tableForm)">{{ $t('dataset.confirm') }}
|
2021-03-03 15:06:52 +08:00
|
|
|
</el-button>
|
2021-06-19 11:42:14 +08:00
|
|
|
</div>
|
|
|
|
</el-dialog>
|
2021-06-09 10:16:58 +08:00
|
|
|
|
2021-06-21 11:18:38 +08:00
|
|
|
<!--移动分组-->
|
2021-06-09 10:16:58 +08:00
|
|
|
<el-dialog v-dialogDrag :title="moveDialogTitle" :visible="moveGroup" :show-close="false" width="30%" class="dialog-css">
|
|
|
|
<group-move-selector :item="groupForm" @targetGroup="targetGroup" />
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
<el-button size="mini" @click="closeMoveGroup()">{{ $t('dataset.cancel') }}</el-button>
|
|
|
|
<el-button :disabled="groupMoveConfirmDisabled" type="primary" size="mini" @click="saveMoveGroup(tGroup)">{{ $t('dataset.confirm') }}
|
|
|
|
</el-button>
|
|
|
|
</div>
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
<!--移动数据集-->
|
|
|
|
<el-dialog v-dialogDrag :title="moveDialogTitle" :visible="moveDs" :show-close="false" width="30%" class="dialog-css">
|
|
|
|
<ds-move-selector :item="dsForm" @targetDs="targetDs" />
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
<el-button size="mini" @click="closeMoveDs()">{{ $t('dataset.cancel') }}</el-button>
|
|
|
|
<el-button :disabled="dsMoveConfirmDisabled" type="primary" size="mini" @click="saveMoveDs(tDs)">{{ $t('dataset.confirm') }}
|
|
|
|
</el-button>
|
|
|
|
</div>
|
|
|
|
</el-dialog>
|
2021-03-03 15:06:52 +08:00
|
|
|
</el-col>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-11-18 18:16:43 +08:00
|
|
|
import { loadTable, getScene, addGroup, delGroup, delTable, post, isKettleRunning, alter } from '@/api/dataset/dataset'
|
2021-06-09 10:16:58 +08:00
|
|
|
import GroupMoveSelector from './GroupMoveSelector'
|
|
|
|
import DsMoveSelector from './DsMoveSelector'
|
2021-11-25 15:17:00 +08:00
|
|
|
import { queryAuthModel } from '@/api/authModel/authModel'
|
2021-03-03 18:35:51 +08:00
|
|
|
|
2021-03-03 15:06:52 +08:00
|
|
|
export default {
|
|
|
|
name: 'Group',
|
2021-06-09 10:16:58 +08:00
|
|
|
components: { GroupMoveSelector, DsMoveSelector },
|
2021-06-19 11:42:14 +08:00
|
|
|
props: {
|
|
|
|
saveStatus: {
|
|
|
|
type: Object,
|
|
|
|
required: false,
|
|
|
|
default: null
|
|
|
|
}
|
|
|
|
},
|
2021-03-03 15:06:52 +08:00
|
|
|
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: '',
|
2021-06-10 15:13:37 +08:00
|
|
|
pid: '0',
|
2021-03-03 15:06:52 +08:00
|
|
|
level: 0,
|
|
|
|
type: '',
|
|
|
|
children: [],
|
|
|
|
sort: 'type desc,name asc'
|
|
|
|
},
|
2021-06-09 10:16:58 +08:00
|
|
|
dsForm: {
|
|
|
|
name: '',
|
2021-06-10 15:13:37 +08:00
|
|
|
pid: '0',
|
2021-06-09 10:16:58 +08:00
|
|
|
level: 0,
|
|
|
|
type: '',
|
|
|
|
children: [],
|
|
|
|
sort: 'type desc,name asc'
|
|
|
|
},
|
2021-03-03 15:06:52 +08:00
|
|
|
tableForm: {
|
|
|
|
name: '',
|
|
|
|
mode: '',
|
|
|
|
sort: 'type asc,create_time desc,name asc'
|
|
|
|
},
|
|
|
|
groupFormRules: {
|
|
|
|
name: [
|
2021-05-18 13:55:00 +08:00
|
|
|
{ required: true, message: this.$t('commons.input_content'), trigger: 'change' },
|
|
|
|
{ max: 50, message: this.$t('commons.char_can_not_more_50'), trigger: 'change' }
|
2021-03-03 15:06:52 +08:00
|
|
|
]
|
|
|
|
},
|
|
|
|
tableFormRules: {
|
|
|
|
name: [
|
2021-05-18 13:47:17 +08:00
|
|
|
{ required: true, message: this.$t('commons.input_content'), trigger: 'change' },
|
2021-05-18 13:55:00 +08:00
|
|
|
{ max: 50, message: this.$t('commons.char_can_not_more_50'), trigger: 'change' }
|
2021-03-03 15:06:52 +08:00
|
|
|
]
|
2021-06-09 10:16:58 +08:00
|
|
|
},
|
|
|
|
moveGroup: false,
|
|
|
|
tGroup: {},
|
|
|
|
moveDs: false,
|
|
|
|
tDs: {},
|
|
|
|
groupMoveConfirmDisabled: true,
|
|
|
|
dsMoveConfirmDisabled: true,
|
2021-06-19 11:42:14 +08:00
|
|
|
moveDialogTitle: '',
|
|
|
|
treeProps: {
|
|
|
|
label: 'name',
|
|
|
|
children: 'children',
|
2021-06-20 11:38:12 +08:00
|
|
|
isLeaf: 'isLeaf',
|
|
|
|
id: 'id',
|
|
|
|
parentId: 'pid'
|
2021-06-19 11:42:14 +08:00
|
|
|
},
|
2021-07-23 10:54:44 +08:00
|
|
|
isTreeSearch: false,
|
2021-11-25 15:17:00 +08:00
|
|
|
kettleRunning: false,
|
|
|
|
searchPids: [], // 查询命中的pid
|
|
|
|
filterText: '',
|
|
|
|
searchType: 'all',
|
|
|
|
searchMap: {
|
|
|
|
all: this.$t('commons.all'),
|
|
|
|
folder: this.$t('commons.folder')
|
|
|
|
}
|
2021-03-03 15:06:52 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2021-12-22 11:42:44 +08:00
|
|
|
hideCustomDs: function() {
|
|
|
|
return this.$store.getters.hideCustomDs
|
|
|
|
}
|
2021-03-03 15:06:52 +08:00
|
|
|
},
|
|
|
|
watch: {
|
2021-06-19 11:42:14 +08:00
|
|
|
saveStatus() {
|
2021-11-25 15:17:00 +08:00
|
|
|
this.treeNode()
|
|
|
|
},
|
|
|
|
filterText(val) {
|
|
|
|
this.searchPids = []
|
|
|
|
this.$refs.datasetTreeRef.filter(val)
|
|
|
|
},
|
|
|
|
searchType(val) {
|
|
|
|
this.searchPids = []
|
|
|
|
this.$refs.datasetTreeRef.filter(this.filterText)
|
2021-03-30 12:24:27 +08:00
|
|
|
}
|
2021-03-03 15:06:52 +08:00
|
|
|
},
|
2021-10-08 17:22:21 +08:00
|
|
|
created() {
|
|
|
|
this.kettleState()
|
|
|
|
},
|
2021-03-03 15:06:52 +08:00
|
|
|
mounted() {
|
2021-11-29 14:54:24 +08:00
|
|
|
this.treeNode(true)
|
2021-03-03 15:06:52 +08:00
|
|
|
this.refresh()
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
clickAdd(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
|
|
|
|
}
|
|
|
|
},
|
2021-07-23 10:54:44 +08:00
|
|
|
kettleState() {
|
|
|
|
isKettleRunning().then(res => {
|
|
|
|
this.kettleRunning = res.data
|
|
|
|
})
|
|
|
|
},
|
2021-03-03 15:06:52 +08:00
|
|
|
clickMore(param) {
|
|
|
|
switch (param.type) {
|
|
|
|
case 'rename':
|
2021-11-25 15:17:00 +08:00
|
|
|
this.add(param.data.modelInnerType)
|
2021-03-03 15:06:52 +08:00
|
|
|
this.groupForm = JSON.parse(JSON.stringify(param.data))
|
|
|
|
break
|
|
|
|
case 'move':
|
2021-06-09 10:16:58 +08:00
|
|
|
this.moveTo(param.data)
|
|
|
|
this.groupForm = JSON.parse(JSON.stringify(param.data))
|
|
|
|
break
|
|
|
|
case 'moveDs':
|
|
|
|
this.moveToDs(param.data)
|
|
|
|
this.dsForm = JSON.parse(JSON.stringify(param.data))
|
2021-03-03 15:06:52 +08:00
|
|
|
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) {
|
|
|
|
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
|
|
|
|
})
|
2021-11-25 15:17:00 +08:00
|
|
|
this.expandedArray.push(group.pid)
|
2021-11-29 14:54:24 +08:00
|
|
|
this.treeNode()
|
2021-03-03 15:06:52 +08:00
|
|
|
})
|
|
|
|
} else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
saveTable(table) {
|
|
|
|
table.mode = parseInt(table.mode)
|
2021-11-25 15:17:00 +08:00
|
|
|
const _this = this
|
2021-03-03 15:06:52 +08:00
|
|
|
this.$refs['tableForm'].validate((valid) => {
|
|
|
|
if (valid) {
|
2021-06-08 12:16:55 +08:00
|
|
|
table.isRename = true
|
2021-08-30 16:18:03 +08:00
|
|
|
alter(table).then(response => {
|
2021-03-03 15:06:52 +08:00
|
|
|
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
|
|
|
|
})
|
2021-11-29 11:35:51 +08:00
|
|
|
_this.expandedArray.push(table.sceneId)
|
|
|
|
_this.$refs.datasetTreeRef.setCurrentKey(table.id)
|
2021-11-25 15:17:00 +08:00
|
|
|
_this.treeNode()
|
2021-06-23 17:44:47 +08:00
|
|
|
this.$store.dispatch('dataset/setTable', new Date().getTime())
|
2021-03-03 15:06:52 +08:00
|
|
|
})
|
|
|
|
} else {
|
|
|
|
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
|
|
|
|
})
|
2021-11-29 14:54:24 +08:00
|
|
|
this.treeNode()
|
2021-12-30 10:18:54 +08:00
|
|
|
this.$emit('switchComponent', { name: '' })
|
2021-03-03 15:06:52 +08:00
|
|
|
})
|
|
|
|
}).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
|
|
|
|
})
|
2021-11-29 14:54:24 +08:00
|
|
|
this.treeNode()
|
2021-12-30 10:18:54 +08:00
|
|
|
this.$emit('switchComponent', { name: '' })
|
2021-06-23 17:44:47 +08:00
|
|
|
this.$store.dispatch('dataset/setTable', new Date().getTime())
|
2021-03-03 15:06:52 +08:00
|
|
|
})
|
|
|
|
}).catch(() => {
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
close() {
|
2021-06-02 16:16:20 +08:00
|
|
|
this.$refs['groupForm'].resetFields()
|
2021-03-03 15:06:52 +08:00
|
|
|
this.editGroup = false
|
|
|
|
this.groupForm = {
|
|
|
|
name: '',
|
2021-06-10 15:13:37 +08:00
|
|
|
pid: '0',
|
2021-03-03 15:06:52 +08:00
|
|
|
level: 0,
|
|
|
|
type: '',
|
|
|
|
children: [],
|
|
|
|
sort: 'type desc,name asc'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
closeTable() {
|
|
|
|
this.editTable = false
|
|
|
|
this.tableForm = {
|
|
|
|
name: ''
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-11-29 14:54:24 +08:00
|
|
|
treeNode(cache) {
|
|
|
|
const modelInfo = localStorage.getItem('dataset-tree')
|
|
|
|
const userCache = (modelInfo && cache)
|
|
|
|
if (userCache) {
|
|
|
|
this.tData = JSON.parse(modelInfo)
|
|
|
|
}
|
|
|
|
queryAuthModel({ modelType: 'dataset' }, !userCache).then(res => {
|
|
|
|
localStorage.setItem('dataset-tree', JSON.stringify(res.data))
|
|
|
|
if (!userCache) {
|
|
|
|
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) {
|
2021-11-25 15:17:00 +08:00
|
|
|
if (data.modelInnerType !== 'group') {
|
2021-07-06 19:26:15 +08:00
|
|
|
this.$emit('switchComponent', { name: 'ViewTable', param: data })
|
2021-03-03 15:06:52 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
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) {
|
2021-06-19 11:42:14 +08:00
|
|
|
this.currGroup = param.data
|
|
|
|
this.$store.dispatch('dataset/setSceneData', this.currGroup.id)
|
2021-03-03 15:06:52 +08:00
|
|
|
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
|
2021-11-19 18:42:59 +08:00
|
|
|
case 'union':
|
2021-11-18 18:16:43 +08:00
|
|
|
this.addData('AddUnion')
|
|
|
|
break
|
2021-03-03 15:06:52 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-06-19 11:42:14 +08:00
|
|
|
beforeClickAddData(type, data) {
|
2021-03-03 15:06:52 +08:00
|
|
|
return {
|
2021-06-19 11:42:14 +08:00
|
|
|
'type': type,
|
|
|
|
'data': data
|
2021-03-03 15:06:52 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
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
|
|
|
})
|
|
|
|
}
|
2021-06-09 10:16:58 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
nodeExpand(data) {
|
|
|
|
if (data.id) {
|
|
|
|
this.expandedArray.push(data.id)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
nodeCollapse(data) {
|
|
|
|
if (data.id) {
|
|
|
|
this.expandedArray.splice(this.expandedArray.indexOf(data.id), 1)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
moveTo(data) {
|
|
|
|
this.moveGroup = true
|
|
|
|
this.moveDialogTitle = this.$t('dataset.m1') + (data.name.length > 10 ? (data.name.substr(0, 10) + '...') : data.name) + this.$t('dataset.m2')
|
|
|
|
},
|
|
|
|
closeMoveGroup() {
|
|
|
|
this.moveGroup = false
|
|
|
|
this.groupForm = {
|
|
|
|
name: '',
|
2021-06-10 15:13:37 +08:00
|
|
|
pid: '0',
|
2021-06-09 10:16:58 +08:00
|
|
|
level: 0,
|
|
|
|
type: '',
|
|
|
|
children: [],
|
|
|
|
sort: 'type desc,name asc'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
saveMoveGroup() {
|
|
|
|
this.groupForm.pid = this.tGroup.id
|
|
|
|
addGroup(this.groupForm).then(res => {
|
|
|
|
this.closeMoveGroup()
|
2021-11-25 15:17:00 +08:00
|
|
|
this.treeNode()
|
2021-06-09 10:16:58 +08:00
|
|
|
})
|
|
|
|
},
|
|
|
|
targetGroup(val) {
|
|
|
|
this.tGroup = val
|
|
|
|
this.groupMoveConfirmDisabled = false
|
|
|
|
},
|
|
|
|
|
|
|
|
moveToDs(data) {
|
|
|
|
this.moveDs = true
|
|
|
|
this.moveDialogTitle = this.$t('dataset.m1') + (data.name.length > 10 ? (data.name.substr(0, 10) + '...') : data.name) + this.$t('dataset.m2')
|
|
|
|
},
|
|
|
|
closeMoveDs() {
|
|
|
|
this.moveDs = false
|
|
|
|
this.dsForm = {
|
|
|
|
name: '',
|
2021-06-10 15:13:37 +08:00
|
|
|
pid: '0',
|
2021-06-09 10:16:58 +08:00
|
|
|
level: 0,
|
|
|
|
type: '',
|
|
|
|
children: [],
|
|
|
|
sort: 'type desc,name asc'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
saveMoveDs() {
|
2021-10-20 11:32:05 +08:00
|
|
|
const newSceneId = this.tDs.id
|
|
|
|
this.dsForm.sceneId = newSceneId
|
2021-06-09 10:16:58 +08:00
|
|
|
this.dsForm.isRename = true
|
2021-08-30 16:18:03 +08:00
|
|
|
alter(this.dsForm).then(res => {
|
2021-06-09 10:16:58 +08:00
|
|
|
this.closeMoveDs()
|
2021-11-25 15:17:00 +08:00
|
|
|
this.expandedArray.push(newSceneId)
|
|
|
|
this.treeNode()
|
2021-06-09 10:16:58 +08:00
|
|
|
})
|
|
|
|
},
|
|
|
|
targetDs(val) {
|
|
|
|
this.tDs = val
|
|
|
|
if (this.tDs.type === 'group') {
|
2021-06-19 11:42:14 +08:00
|
|
|
this.dsMoveConfirmDisabled = false
|
2021-06-09 10:16:58 +08:00
|
|
|
} else {
|
|
|
|
this.dsMoveConfirmDisabled = false
|
|
|
|
}
|
2021-06-19 11:42:14 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
loadNode(node, resolve) {
|
|
|
|
if (!this.isTreeSearch) {
|
|
|
|
if (node.level > 0) {
|
|
|
|
this.tables = []
|
|
|
|
this.tableData = []
|
|
|
|
if (node.data.id) {
|
|
|
|
post('/dataset/table/listAndGroup', {
|
|
|
|
sort: 'type asc,name asc,create_time desc',
|
|
|
|
sceneId: node.data.id
|
|
|
|
}).then(res => {
|
|
|
|
this.tables = res.data
|
|
|
|
this.tableData = JSON.parse(JSON.stringify(this.tables))
|
|
|
|
resolve(this.tableData)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2021-06-21 16:24:16 +08:00
|
|
|
} else {
|
2021-06-30 18:13:36 +08:00
|
|
|
node.data.children ? resolve(node.data.children) : resolve([])
|
2021-06-19 11:42:14 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-06-21 16:24:16 +08:00
|
|
|
getTreeData(val) {
|
|
|
|
if (val) {
|
|
|
|
this.isTreeSearch = true
|
|
|
|
this.searchTree(val)
|
|
|
|
} else {
|
|
|
|
this.isTreeSearch = false
|
2021-11-29 14:54:24 +08:00
|
|
|
this.treeNode()
|
2021-06-21 16:24:16 +08:00
|
|
|
}
|
2021-11-25 15:17:00 +08:00
|
|
|
},
|
|
|
|
filterNode(value, data) {
|
|
|
|
if (!value) return true
|
|
|
|
if (this.searchType === 'folder') {
|
|
|
|
if (data.modelInnerType === 'group' && data.label.indexOf(value) !== -1) {
|
|
|
|
this.searchPids.push(data.id)
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
if (this.searchPids.indexOf(data.pid) !== -1) {
|
|
|
|
if (data.modelInnerType === 'group') {
|
|
|
|
this.searchPids.push(data.id)
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return data.label.indexOf(value) !== -1
|
2021-06-21 16:24:16 +08:00
|
|
|
}
|
2021-11-25 15:17:00 +08:00
|
|
|
return false
|
|
|
|
},
|
|
|
|
searchTypeClick(searchTypeInfo) {
|
|
|
|
this.searchType = searchTypeInfo
|
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;
|
|
|
|
}
|
2021-06-04 17:16:50 +08:00
|
|
|
|
|
|
|
.scene-title{
|
|
|
|
width: 100%;
|
|
|
|
display: flex;
|
|
|
|
}
|
|
|
|
.scene-title-name{
|
|
|
|
width: 100%;
|
|
|
|
overflow: hidden;
|
|
|
|
display: inline-block;
|
|
|
|
white-space: nowrap;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
}
|
2021-06-08 15:00:13 +08:00
|
|
|
.father .child {
|
2021-08-04 11:57:39 +08:00
|
|
|
visibility: hidden;
|
2021-06-08 15:00:13 +08:00
|
|
|
}
|
|
|
|
.father:hover .child {
|
2021-08-04 11:57:39 +08:00
|
|
|
visibility: visible;
|
2021-06-08 15:00:13 +08:00
|
|
|
}
|
2021-06-09 10:16:58 +08:00
|
|
|
|
|
|
|
.dialog-css >>> .el-dialog__body {
|
|
|
|
padding: 10px 20px 20px;
|
|
|
|
}
|
2021-06-19 11:42:14 +08:00
|
|
|
|
|
|
|
.inner-dropdown-menu{
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
|
|
|
width: 100%
|
|
|
|
}
|
2021-07-01 10:47:28 +08:00
|
|
|
.tree-style {
|
|
|
|
padding: 10px 15px;
|
|
|
|
height: 100%;
|
|
|
|
overflow-y: auto;
|
|
|
|
}
|
2021-03-03 15:06:52 +08:00
|
|
|
</style>
|