2021-03-03 15:06:52 +08:00
|
|
|
<template>
|
2021-04-28 17:30:18 +08:00
|
|
|
<el-row style="height: 100%;overflow-y: hidden;width: 100%;">
|
2021-07-06 19:26:15 +08:00
|
|
|
<!-- <span v-show="false">{{ tableRefresh }}</span>-->
|
2021-04-28 17:30:18 +08:00
|
|
|
<el-row style="height: 26px;">
|
2021-10-20 11:32:05 +08:00
|
|
|
<span class="title-text" style="line-height: 26px;">
|
|
|
|
{{ table.name }}
|
|
|
|
</span>
|
2021-04-28 17:30:18 +08:00
|
|
|
<el-popover
|
|
|
|
placement="right-start"
|
|
|
|
width="400"
|
|
|
|
trigger="click"
|
|
|
|
@show="showTab"
|
|
|
|
@hide="hideTab"
|
|
|
|
>
|
|
|
|
<dataset-chart-detail type="dataset" :data="table" :tab-status="tabStatus" />
|
2021-10-20 17:12:09 +08:00
|
|
|
<!-- <svg-icon slot="reference" class="title-text" icon-class="more_v" style="cursor: pointer;" />-->
|
|
|
|
<i slot="reference" class="el-icon-warning icon-class" style="margin-left: 4px;cursor: pointer;font-size: 14px;" />
|
2021-04-28 17:30:18 +08:00
|
|
|
</el-popover>
|
2021-07-06 19:26:15 +08:00
|
|
|
<el-row v-if="hasDataPermission('manage',param.privileges)" style="float: right">
|
2021-06-08 12:30:26 +08:00
|
|
|
<el-dropdown v-if="table.type ==='excel'" style="margin-right: 10px;" size="small" trigger="click" @command="clickEditExcel">
|
|
|
|
<el-button size="mini">
|
2021-06-08 11:12:40 +08:00
|
|
|
{{ $t('dataset.edit_excel') }}
|
|
|
|
</el-button>
|
|
|
|
<el-dropdown-menu slot="dropdown">
|
|
|
|
<el-dropdown-item :command="beforeEditExcel('0')">
|
|
|
|
{{ $t('dataset.excel_replace') }}
|
|
|
|
</el-dropdown-item>
|
|
|
|
<el-dropdown-item :command="beforeEditExcel('1')">
|
|
|
|
{{ $t('dataset.excel_add') }}
|
|
|
|
</el-dropdown-item>
|
|
|
|
</el-dropdown-menu>
|
|
|
|
</el-dropdown>
|
2021-05-12 14:45:13 +08:00
|
|
|
<el-button v-if="table.type ==='custom'" size="mini" @click="editCustom">
|
|
|
|
{{ $t('dataset.edit_custom_table') }}
|
|
|
|
</el-button>
|
2021-04-28 17:30:18 +08:00
|
|
|
<el-button v-if="table.type ==='sql'" size="mini" @click="editSql">
|
|
|
|
{{ $t('dataset.edit_sql') }}
|
|
|
|
</el-button>
|
2021-07-27 16:58:03 +08:00
|
|
|
<!-- <el-button size="mini" @click="edit">-->
|
|
|
|
<!-- {{ $t('dataset.edit_field') }}-->
|
|
|
|
<!-- </el-button>-->
|
2021-04-28 17:30:18 +08:00
|
|
|
<!-- <el-button size="mini" type="primary" @click="createChart">-->
|
|
|
|
<!-- {{$t('dataset.create_view')}}-->
|
|
|
|
<!-- </el-button>-->
|
2021-03-03 15:06:52 +08:00
|
|
|
</el-row>
|
|
|
|
</el-row>
|
2021-04-28 17:30:18 +08:00
|
|
|
<el-divider />
|
|
|
|
|
2021-07-29 15:56:59 +08:00
|
|
|
<el-tabs v-model="tabActive" @tab-click="tabClick">
|
2021-04-28 17:30:18 +08:00
|
|
|
<el-tab-pane :label="$t('dataset.data_preview')" name="dataPreview">
|
2021-07-06 19:26:15 +08:00
|
|
|
<tab-data-preview :param="param" :table="table" :fields="fields" :data="data" :page="page" :form="tableViewRowForm" @reSearch="reSearch" />
|
2021-04-28 17:30:18 +08:00
|
|
|
</el-tab-pane>
|
2021-07-27 16:58:03 +08:00
|
|
|
<el-tab-pane :label="$t('dataset.field_manage')" name="fieldEdit">
|
|
|
|
<field-edit :param="param" />
|
|
|
|
</el-tab-pane>
|
2021-11-03 11:14:14 +08:00
|
|
|
<el-tab-pane v-if="table.type !== 'custom' && !(table.type === 'sql' && table.mode === 0)" :label="$t('dataset.join_view')" name="joinView">
|
2021-07-06 19:26:15 +08:00
|
|
|
<union-view :param="param" :table="table" />
|
2021-04-28 17:30:18 +08:00
|
|
|
</el-tab-pane>
|
2021-07-23 18:35:37 +08:00
|
|
|
<el-tab-pane v-if="table.mode === 1 && (table.type === 'excel' || table.type === 'db' || table.type === 'sql')" :label="$t('dataset.update_info')" name="updateInfo">
|
2021-10-31 18:11:40 +08:00
|
|
|
<update-info v-if="tabActive=='updateInfo'" :param="param" :table="table" />
|
2021-04-28 17:30:18 +08:00
|
|
|
</el-tab-pane>
|
|
|
|
</el-tabs>
|
|
|
|
</el-row>
|
2021-03-03 15:06:52 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-07-29 15:56:59 +08:00
|
|
|
import { post } from '@/api/dataset/dataset'
|
2021-03-03 15:06:52 +08:00
|
|
|
import TabDataPreview from './TabDataPreview'
|
|
|
|
import UpdateInfo from './UpdateInfo'
|
2021-04-15 11:55:30 +08:00
|
|
|
import DatasetChartDetail from '../common/DatasetChartDetail'
|
2021-05-07 14:51:40 +08:00
|
|
|
import UnionView from './UnionView'
|
2021-07-27 16:58:03 +08:00
|
|
|
import FieldEdit from './FieldEdit'
|
2021-03-03 15:06:52 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'ViewTable',
|
2021-07-27 16:58:03 +08:00
|
|
|
components: { FieldEdit, UnionView, DatasetChartDetail, UpdateInfo, TabDataPreview },
|
2021-04-28 17:30:18 +08:00
|
|
|
props: {
|
|
|
|
param: {
|
2021-07-06 19:26:15 +08:00
|
|
|
type: Object,
|
2021-04-28 17:30:18 +08:00
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
2021-03-03 15:06:52 +08:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
table: {
|
|
|
|
name: ''
|
|
|
|
},
|
|
|
|
fields: [],
|
|
|
|
data: [],
|
2021-04-28 17:30:18 +08:00
|
|
|
page: {
|
|
|
|
page: 1,
|
|
|
|
pageSize: 100,
|
|
|
|
show: 1000
|
|
|
|
},
|
2021-03-03 15:06:52 +08:00
|
|
|
tabActive: 'dataPreview',
|
2021-04-02 11:36:01 +08:00
|
|
|
tableViewRowForm: {
|
|
|
|
row: 1000
|
2021-04-15 11:55:30 +08:00
|
|
|
},
|
2021-04-29 15:43:15 +08:00
|
|
|
tabStatus: false
|
2021-03-03 15:06:52 +08:00
|
|
|
}
|
|
|
|
},
|
2021-06-23 17:44:47 +08:00
|
|
|
computed: {
|
2021-07-06 16:32:38 +08:00
|
|
|
// tableRefresh() {
|
|
|
|
// this.initTable(this.param)
|
|
|
|
// return this.$store.state.dataset.table
|
|
|
|
// }
|
2021-06-23 17:44:47 +08:00
|
|
|
},
|
2021-04-28 17:30:18 +08:00
|
|
|
watch: {
|
|
|
|
'param': function() {
|
2021-07-27 16:58:03 +08:00
|
|
|
this.tabActive = 'dataPreview'
|
2021-07-06 19:26:15 +08:00
|
|
|
this.initTable(this.param.id)
|
2021-03-03 15:06:52 +08:00
|
|
|
}
|
2021-07-03 18:01:30 +08:00
|
|
|
},
|
|
|
|
created() {
|
|
|
|
|
2021-03-03 15:06:52 +08:00
|
|
|
},
|
|
|
|
mounted() {
|
2021-07-06 19:26:15 +08:00
|
|
|
this.initTable(this.param.id)
|
2021-03-03 15:06:52 +08:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
initTable(id) {
|
2021-07-27 18:04:17 +08:00
|
|
|
this.resetPage()
|
2021-04-02 11:36:01 +08:00
|
|
|
this.tableViewRowForm.row = 1000
|
2021-03-03 15:06:52 +08:00
|
|
|
if (id !== null) {
|
|
|
|
this.fields = []
|
|
|
|
this.data = []
|
2021-07-27 19:13:22 +08:00
|
|
|
post('/dataset/table/getWithPermission/' + id, null).then(response => {
|
2021-03-03 15:06:52 +08:00
|
|
|
this.table = response.data
|
2021-04-28 17:30:18 +08:00
|
|
|
this.initPreviewData(this.page)
|
2021-06-23 17:44:47 +08:00
|
|
|
}).catch(res => {
|
|
|
|
this.$emit('switchComponent', { name: '' })
|
2021-03-03 15:06:52 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-04-28 17:30:18 +08:00
|
|
|
initPreviewData(page) {
|
2021-03-03 15:06:52 +08:00
|
|
|
if (this.table.id) {
|
2021-04-02 11:36:01 +08:00
|
|
|
this.table.row = this.tableViewRowForm.row
|
2021-07-30 17:44:44 +08:00
|
|
|
post('/dataset/table/getPreviewData/' + page.page + '/' + page.pageSize, this.table, true, 30000).then(response => {
|
2021-03-03 15:06:52 +08:00
|
|
|
this.fields = response.data.fields
|
|
|
|
this.data = response.data.data
|
2021-04-28 17:30:18 +08:00
|
|
|
this.page = response.data.page
|
2021-06-08 11:12:40 +08:00
|
|
|
if (response.data.status === 'warnning') {
|
2021-05-25 17:51:35 +08:00
|
|
|
this.$warning(response.data.msg, 3000)
|
2021-05-25 17:48:29 +08:00
|
|
|
}
|
2021-06-08 11:12:40 +08:00
|
|
|
if (response.data.status === 'error') {
|
2021-05-25 17:51:35 +08:00
|
|
|
this.$error(response.data.msg, 3000)
|
|
|
|
}
|
2021-05-25 17:41:23 +08:00
|
|
|
}).catch(response => {
|
|
|
|
this.fields = []
|
|
|
|
this.data = []
|
|
|
|
this.page = {
|
|
|
|
page: 1,
|
|
|
|
pageSize: 100,
|
|
|
|
show: 0
|
2021-05-25 17:48:29 +08:00
|
|
|
}
|
2021-03-03 15:06:52 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
edit() {
|
2021-04-29 15:43:15 +08:00
|
|
|
this.$emit('switchComponent', { name: 'FieldEdit', param: { table: this.table }})
|
2021-03-25 18:09:44 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
editSql() {
|
2021-07-15 11:05:11 +08:00
|
|
|
this.$emit('switchComponent', { name: 'AddSQL', param: { id: this.table.sceneId, tableId: this.table.id, table: this.table }})
|
2021-04-02 11:36:01 +08:00
|
|
|
},
|
2021-05-12 14:45:13 +08:00
|
|
|
editCustom() {
|
2021-07-15 11:05:11 +08:00
|
|
|
this.$emit('switchComponent', { name: 'AddCustom', param: { id: this.table.sceneId, tableId: this.table.id, table: this.table }})
|
2021-05-12 14:45:13 +08:00
|
|
|
},
|
2021-04-02 11:36:01 +08:00
|
|
|
|
|
|
|
reSearch(val) {
|
2021-04-28 17:30:18 +08:00
|
|
|
this.tableViewRowForm = val.form
|
|
|
|
this.initPreviewData(val.page)
|
2021-04-15 11:55:30 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
showTab() {
|
|
|
|
this.tabStatus = true
|
|
|
|
},
|
|
|
|
hideTab() {
|
|
|
|
this.tabStatus = false
|
2021-06-08 11:12:40 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
clickEditExcel(param) {
|
|
|
|
// console.log(param);
|
|
|
|
switch (param.type) {
|
|
|
|
case '0':
|
2021-06-08 11:30:26 +08:00
|
|
|
this.$emit('switchComponent', { name: 'AddExcel', param: { id: this.table.sceneId, tableId: this.table.id, editType: 0, table: this.table }})
|
2021-06-08 11:12:40 +08:00
|
|
|
break
|
|
|
|
case '1':
|
2021-06-08 11:30:26 +08:00
|
|
|
this.$emit('switchComponent', { name: 'AddExcel', param: { id: this.table.sceneId, tableId: this.table.id, editType: 1, table: this.table }})
|
2021-06-08 11:12:40 +08:00
|
|
|
break
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
beforeEditExcel(type) {
|
|
|
|
return {
|
|
|
|
'type': type
|
|
|
|
}
|
2021-07-03 18:01:30 +08:00
|
|
|
},
|
|
|
|
msg2Current(sourceParam) {
|
|
|
|
this.tabActive = 'updateInfo'
|
|
|
|
this.table.msgTaskId = sourceParam.taskId
|
2021-07-27 18:04:17 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
resetPage() {
|
|
|
|
this.page = {
|
|
|
|
page: 1,
|
|
|
|
pageSize: 100,
|
|
|
|
show: 1000
|
|
|
|
}
|
2021-07-29 15:56:59 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
tabClick() {
|
|
|
|
if (this.tabActive === 'dataPreview') {
|
|
|
|
this.initTable(this.param.id)
|
|
|
|
}
|
2021-03-03 15:06:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.el-divider--horizontal {
|
|
|
|
margin: 12px 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.form-item {
|
|
|
|
margin-bottom: 6px;
|
|
|
|
}
|
2021-10-20 17:12:09 +08:00
|
|
|
.icon-class{
|
|
|
|
color:#6c6c6c;
|
|
|
|
}
|
|
|
|
.blackTheme .icon-class{
|
|
|
|
color: #cccccc;
|
|
|
|
}
|
2021-03-03 15:06:52 +08:00
|
|
|
</style>
|