2021-03-03 15:06:52 +08:00
|
|
|
<template>
|
|
|
|
<el-col>
|
|
|
|
<el-row>
|
|
|
|
<el-row style="height: 26px;">
|
|
|
|
<span v-show="false">{{ tableId }}</span>
|
|
|
|
<span style="line-height: 26px;">
|
|
|
|
{{ table.name }}
|
|
|
|
</span>
|
|
|
|
<el-row style="float: right">
|
|
|
|
<el-button size="mini" @click="edit">
|
|
|
|
{{ $t('dataset.edit') }}
|
|
|
|
</el-button>
|
2021-03-03 18:35:51 +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-03-11 14:36:02 +08:00
|
|
|
<el-divider />
|
2021-03-03 15:06:52 +08:00
|
|
|
|
|
|
|
<el-tabs v-model="tabActive">
|
|
|
|
<el-tab-pane :label="$t('dataset.data_preview')" name="dataPreview">
|
2021-03-11 14:36:02 +08:00
|
|
|
<tab-data-preview :table="table" :fields="fields" :data="data" />
|
2021-03-03 15:06:52 +08:00
|
|
|
</el-tab-pane>
|
|
|
|
<el-tab-pane :label="$t('dataset.join_view')" name="joinView">
|
|
|
|
关联视图 TODO
|
|
|
|
</el-tab-pane>
|
2021-03-11 10:37:58 +08:00
|
|
|
<el-tab-pane v-if="table.mode === 1" :label="$t('dataset.update_info')" name="updateInfo">
|
2021-03-11 14:36:02 +08:00
|
|
|
<update-info :table="table" />
|
2021-03-03 15:06:52 +08:00
|
|
|
</el-tab-pane>
|
|
|
|
</el-tabs>
|
|
|
|
|
2021-03-25 17:09:44 +08:00
|
|
|
<el-dialog :title="table.name" :visible.sync="editField" :fullscreen="true" :show-close="false" class="dialog-css">
|
2021-03-03 15:06:52 +08:00
|
|
|
<el-table :data="tableFields" size="mini" max-height="600px">
|
|
|
|
<el-table-column property="type" :label="$t('dataset.field_type')" width="100">
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<span v-if="scope.row.deType === 0">{{ $t('dataset.text') }}</span>
|
|
|
|
<span v-if="scope.row.deType === 1">{{ $t('dataset.time') }}</span>
|
|
|
|
<span v-if="scope.row.deType === 2">{{ $t('dataset.value') }}</span>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column property="name" :label="$t('dataset.field_name')" width="180">
|
|
|
|
<template slot-scope="scope">
|
2021-03-11 14:36:02 +08:00
|
|
|
<el-input v-model="scope.row.name" size="mini" />
|
2021-03-03 15:06:52 +08:00
|
|
|
</template>
|
|
|
|
</el-table-column>
|
2021-03-11 14:36:02 +08:00
|
|
|
<el-table-column property="originName" :label="$t('dataset.field_origin_name')" width="180" />
|
2021-03-03 15:06:52 +08:00
|
|
|
<el-table-column property="checked" :label="$t('dataset.field_check')" width="80">
|
|
|
|
<template slot-scope="scope">
|
2021-03-11 14:36:02 +08:00
|
|
|
<el-checkbox v-model="scope.row.checked" />
|
2021-03-03 15:06:52 +08:00
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<!--下面这一列占位-->
|
2021-03-11 14:36:02 +08:00
|
|
|
<el-table-column property="" />
|
2021-03-03 15:06:52 +08:00
|
|
|
</el-table>
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
<el-button size="mini" @click="closeEdit">{{ $t('dataset.cancel') }}</el-button>
|
|
|
|
<el-button type="primary" size="mini" @click="saveEdit">{{ $t('dataset.confirm') }}</el-button>
|
|
|
|
</div>
|
|
|
|
</el-dialog>
|
|
|
|
|
2021-03-03 18:35:51 +08:00
|
|
|
<!-- <el-dialog title="view" :visible.sync="createViewDialog" :fullscreen="true">-->
|
|
|
|
<!-- <chart-edit/>-->
|
|
|
|
<!-- </el-dialog>-->
|
2021-03-03 15:06:52 +08:00
|
|
|
</el-row>
|
|
|
|
</el-col>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-03-03 18:35:51 +08:00
|
|
|
import { getTable, getPreviewData, fieldList, batchEdit } from '@/api/dataset/dataset'
|
2021-03-03 15:06:52 +08:00
|
|
|
import TabDataPreview from './TabDataPreview'
|
|
|
|
import UpdateInfo from './UpdateInfo'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'ViewTable',
|
|
|
|
components: { UpdateInfo, TabDataPreview },
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
createViewDialog: false,
|
|
|
|
editField: false,
|
|
|
|
table: {
|
|
|
|
name: ''
|
|
|
|
},
|
|
|
|
fields: [],
|
|
|
|
data: [],
|
|
|
|
tabActive: 'dataPreview',
|
|
|
|
tableFields: []
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
tableId() {
|
|
|
|
this.initTable(this.$store.state.dataset.table)
|
|
|
|
return this.$store.state.dataset.table
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {},
|
|
|
|
mounted() {
|
2021-03-03 21:45:30 +08:00
|
|
|
this.initTable(this.$store.state.dataset.table)
|
2021-03-03 15:06:52 +08:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
initTable(id) {
|
|
|
|
console.log(id)
|
|
|
|
if (id !== null) {
|
|
|
|
this.fields = []
|
|
|
|
this.data = []
|
2021-03-03 18:35:51 +08:00
|
|
|
getTable(id).then(response => {
|
2021-03-03 15:06:52 +08:00
|
|
|
this.table = response.data
|
|
|
|
this.initPreviewData()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
initPreviewData() {
|
|
|
|
if (this.table.id) {
|
2021-03-03 18:35:51 +08:00
|
|
|
getPreviewData(this.table).then(response => {
|
2021-03-03 15:06:52 +08:00
|
|
|
this.fields = response.data.fields
|
|
|
|
this.data = response.data.data
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
initTableFields() {
|
2021-03-03 18:35:51 +08:00
|
|
|
fieldList(this.table.id).then(response => {
|
2021-03-03 15:06:52 +08:00
|
|
|
this.tableFields = response.data
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
edit() {
|
|
|
|
this.editField = true
|
|
|
|
// 请求当前表的所有字段,进行编辑
|
|
|
|
this.initTableFields()
|
|
|
|
},
|
|
|
|
|
|
|
|
// createChart() {
|
|
|
|
// console.log(this.table);
|
|
|
|
// this.createViewDialog = true;
|
|
|
|
// },
|
|
|
|
|
|
|
|
saveEdit() {
|
|
|
|
console.log(this.tableFields)
|
2021-03-03 18:35:51 +08:00
|
|
|
batchEdit(this.tableFields).then(response => {
|
2021-03-03 15:06:52 +08:00
|
|
|
this.closeEdit()
|
|
|
|
this.initTable(this.table.id)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
closeEdit() {
|
|
|
|
this.editField = false
|
|
|
|
this.tableFields = []
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.el-divider--horizontal {
|
|
|
|
margin: 12px 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.form-item {
|
|
|
|
margin-bottom: 6px;
|
|
|
|
}
|
2021-03-25 17:09:44 +08:00
|
|
|
|
|
|
|
.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;
|
|
|
|
}
|
|
|
|
.dialog-css >>> .el-dialog__footer {
|
|
|
|
padding-top: 30px;
|
|
|
|
}
|
2021-03-03 15:06:52 +08:00
|
|
|
</style>
|