forked from github/dataease
feat(数据集): 数据库表:mysql直连模式,表字段 类型 数据 读取展示
This commit is contained in:
parent
923d7509a2
commit
9272a0b954
@ -19,5 +19,7 @@ public class DatasetTable implements Serializable {
|
|||||||
|
|
||||||
private Long createTime;
|
private Long createTime;
|
||||||
|
|
||||||
|
private String info;
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
}
|
}
|
@ -16,15 +16,21 @@ public interface DatasetTableMapper {
|
|||||||
|
|
||||||
int insertSelective(DatasetTable record);
|
int insertSelective(DatasetTable record);
|
||||||
|
|
||||||
|
List<DatasetTable> selectByExampleWithBLOBs(DatasetTableExample example);
|
||||||
|
|
||||||
List<DatasetTable> selectByExample(DatasetTableExample example);
|
List<DatasetTable> selectByExample(DatasetTableExample example);
|
||||||
|
|
||||||
DatasetTable selectByPrimaryKey(String id);
|
DatasetTable selectByPrimaryKey(String id);
|
||||||
|
|
||||||
int updateByExampleSelective(@Param("record") DatasetTable record, @Param("example") DatasetTableExample example);
|
int updateByExampleSelective(@Param("record") DatasetTable record, @Param("example") DatasetTableExample example);
|
||||||
|
|
||||||
|
int updateByExampleWithBLOBs(@Param("record") DatasetTable record, @Param("example") DatasetTableExample example);
|
||||||
|
|
||||||
int updateByExample(@Param("record") DatasetTable record, @Param("example") DatasetTableExample example);
|
int updateByExample(@Param("record") DatasetTable record, @Param("example") DatasetTableExample example);
|
||||||
|
|
||||||
int updateByPrimaryKeySelective(DatasetTable record);
|
int updateByPrimaryKeySelective(DatasetTable record);
|
||||||
|
|
||||||
|
int updateByPrimaryKeyWithBLOBs(DatasetTable record);
|
||||||
|
|
||||||
int updateByPrimaryKey(DatasetTable record);
|
int updateByPrimaryKey(DatasetTable record);
|
||||||
}
|
}
|
@ -10,6 +10,9 @@
|
|||||||
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
|
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
|
||||||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.dataease.base.domain.DatasetTable">
|
||||||
|
<result column="info" jdbcType="LONGVARCHAR" property="info" />
|
||||||
|
</resultMap>
|
||||||
<sql id="Example_Where_Clause">
|
<sql id="Example_Where_Clause">
|
||||||
<where>
|
<where>
|
||||||
<foreach collection="oredCriteria" item="criteria" separator="or">
|
<foreach collection="oredCriteria" item="criteria" separator="or">
|
||||||
@ -71,6 +74,25 @@
|
|||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, `name`, scene_id, data_source_id, `type`, create_by, create_time
|
id, `name`, scene_id, data_source_id, `type`, create_by, create_time
|
||||||
</sql>
|
</sql>
|
||||||
|
<sql id="Blob_Column_List">
|
||||||
|
info
|
||||||
|
</sql>
|
||||||
|
<select id="selectByExampleWithBLOBs" parameterType="io.dataease.base.domain.DatasetTableExample" resultMap="ResultMapWithBLOBs">
|
||||||
|
select
|
||||||
|
<if test="distinct">
|
||||||
|
distinct
|
||||||
|
</if>
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
,
|
||||||
|
<include refid="Blob_Column_List" />
|
||||||
|
from dataset_table
|
||||||
|
<if test="_parameter != null">
|
||||||
|
<include refid="Example_Where_Clause" />
|
||||||
|
</if>
|
||||||
|
<if test="orderByClause != null">
|
||||||
|
order by ${orderByClause}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
<select id="selectByExample" parameterType="io.dataease.base.domain.DatasetTableExample" resultMap="BaseResultMap">
|
<select id="selectByExample" parameterType="io.dataease.base.domain.DatasetTableExample" resultMap="BaseResultMap">
|
||||||
select
|
select
|
||||||
<if test="distinct">
|
<if test="distinct">
|
||||||
@ -85,9 +107,11 @@
|
|||||||
order by ${orderByClause}
|
order by ${orderByClause}
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
|
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
|
||||||
select
|
select
|
||||||
<include refid="Base_Column_List" />
|
<include refid="Base_Column_List" />
|
||||||
|
,
|
||||||
|
<include refid="Blob_Column_List" />
|
||||||
from dataset_table
|
from dataset_table
|
||||||
where id = #{id,jdbcType=VARCHAR}
|
where id = #{id,jdbcType=VARCHAR}
|
||||||
</select>
|
</select>
|
||||||
@ -104,10 +128,10 @@
|
|||||||
<insert id="insert" parameterType="io.dataease.base.domain.DatasetTable">
|
<insert id="insert" parameterType="io.dataease.base.domain.DatasetTable">
|
||||||
insert into dataset_table (id, `name`, scene_id,
|
insert into dataset_table (id, `name`, scene_id,
|
||||||
data_source_id, `type`, create_by,
|
data_source_id, `type`, create_by,
|
||||||
create_time)
|
create_time, info)
|
||||||
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{sceneId,jdbcType=VARCHAR},
|
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{sceneId,jdbcType=VARCHAR},
|
||||||
#{dataSourceId,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR},
|
#{dataSourceId,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR},
|
||||||
#{createTime,jdbcType=BIGINT})
|
#{createTime,jdbcType=BIGINT}, #{info,jdbcType=LONGVARCHAR})
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertSelective" parameterType="io.dataease.base.domain.DatasetTable">
|
<insert id="insertSelective" parameterType="io.dataease.base.domain.DatasetTable">
|
||||||
insert into dataset_table
|
insert into dataset_table
|
||||||
@ -133,6 +157,9 @@
|
|||||||
<if test="createTime != null">
|
<if test="createTime != null">
|
||||||
create_time,
|
create_time,
|
||||||
</if>
|
</if>
|
||||||
|
<if test="info != null">
|
||||||
|
info,
|
||||||
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="id != null">
|
<if test="id != null">
|
||||||
@ -156,6 +183,9 @@
|
|||||||
<if test="createTime != null">
|
<if test="createTime != null">
|
||||||
#{createTime,jdbcType=BIGINT},
|
#{createTime,jdbcType=BIGINT},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="info != null">
|
||||||
|
#{info,jdbcType=LONGVARCHAR},
|
||||||
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
<select id="countByExample" parameterType="io.dataease.base.domain.DatasetTableExample" resultType="java.lang.Long">
|
<select id="countByExample" parameterType="io.dataease.base.domain.DatasetTableExample" resultType="java.lang.Long">
|
||||||
@ -188,11 +218,28 @@
|
|||||||
<if test="record.createTime != null">
|
<if test="record.createTime != null">
|
||||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="record.info != null">
|
||||||
|
info = #{record.info,jdbcType=LONGVARCHAR},
|
||||||
|
</if>
|
||||||
</set>
|
</set>
|
||||||
<if test="_parameter != null">
|
<if test="_parameter != null">
|
||||||
<include refid="Update_By_Example_Where_Clause" />
|
<include refid="Update_By_Example_Where_Clause" />
|
||||||
</if>
|
</if>
|
||||||
</update>
|
</update>
|
||||||
|
<update id="updateByExampleWithBLOBs" parameterType="map">
|
||||||
|
update dataset_table
|
||||||
|
set id = #{record.id,jdbcType=VARCHAR},
|
||||||
|
`name` = #{record.name,jdbcType=VARCHAR},
|
||||||
|
scene_id = #{record.sceneId,jdbcType=VARCHAR},
|
||||||
|
data_source_id = #{record.dataSourceId,jdbcType=VARCHAR},
|
||||||
|
`type` = #{record.type,jdbcType=VARCHAR},
|
||||||
|
create_by = #{record.createBy,jdbcType=VARCHAR},
|
||||||
|
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||||
|
info = #{record.info,jdbcType=LONGVARCHAR}
|
||||||
|
<if test="_parameter != null">
|
||||||
|
<include refid="Update_By_Example_Where_Clause" />
|
||||||
|
</if>
|
||||||
|
</update>
|
||||||
<update id="updateByExample" parameterType="map">
|
<update id="updateByExample" parameterType="map">
|
||||||
update dataset_table
|
update dataset_table
|
||||||
set id = #{record.id,jdbcType=VARCHAR},
|
set id = #{record.id,jdbcType=VARCHAR},
|
||||||
@ -227,9 +274,23 @@
|
|||||||
<if test="createTime != null">
|
<if test="createTime != null">
|
||||||
create_time = #{createTime,jdbcType=BIGINT},
|
create_time = #{createTime,jdbcType=BIGINT},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="info != null">
|
||||||
|
info = #{info,jdbcType=LONGVARCHAR},
|
||||||
|
</if>
|
||||||
</set>
|
</set>
|
||||||
where id = #{id,jdbcType=VARCHAR}
|
where id = #{id,jdbcType=VARCHAR}
|
||||||
</update>
|
</update>
|
||||||
|
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.dataease.base.domain.DatasetTable">
|
||||||
|
update dataset_table
|
||||||
|
set `name` = #{name,jdbcType=VARCHAR},
|
||||||
|
scene_id = #{sceneId,jdbcType=VARCHAR},
|
||||||
|
data_source_id = #{dataSourceId,jdbcType=VARCHAR},
|
||||||
|
`type` = #{type,jdbcType=VARCHAR},
|
||||||
|
create_by = #{createBy,jdbcType=VARCHAR},
|
||||||
|
create_time = #{createTime,jdbcType=BIGINT},
|
||||||
|
info = #{info,jdbcType=LONGVARCHAR}
|
||||||
|
where id = #{id,jdbcType=VARCHAR}
|
||||||
|
</update>
|
||||||
<update id="updateByPrimaryKey" parameterType="io.dataease.base.domain.DatasetTable">
|
<update id="updateByPrimaryKey" parameterType="io.dataease.base.domain.DatasetTable">
|
||||||
update dataset_table
|
update dataset_table
|
||||||
set `name` = #{name,jdbcType=VARCHAR},
|
set `name` = #{name,jdbcType=VARCHAR},
|
||||||
|
@ -2,6 +2,7 @@ package io.dataease.controller.dataset;
|
|||||||
|
|
||||||
import io.dataease.base.domain.DatasetTable;
|
import io.dataease.base.domain.DatasetTable;
|
||||||
import io.dataease.controller.request.dataset.DataSetTableRequest;
|
import io.dataease.controller.request.dataset.DataSetTableRequest;
|
||||||
|
import io.dataease.datasource.dto.TableFiled;
|
||||||
import io.dataease.service.dataset.DataSetTableService;
|
import io.dataease.service.dataset.DataSetTableService;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -42,4 +43,14 @@ public class DataSetTableController {
|
|||||||
public DatasetTable get(@PathVariable String id) {
|
public DatasetTable get(@PathVariable String id) {
|
||||||
return dataSetTableService.get(id);
|
return dataSetTableService.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("getFields")
|
||||||
|
public List<TableFiled> getFields(@RequestBody DataSetTableRequest dataSetTableRequest) throws Exception {
|
||||||
|
return dataSetTableService.getFields(dataSetTableRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("getData")
|
||||||
|
public List<Object> getData(@RequestBody DataSetTableRequest dataSetTableRequest) throws Exception {
|
||||||
|
return dataSetTableService.getData(dataSetTableRequest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package io.dataease.dto.dataset;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author gin
|
||||||
|
* @Date 2021/2/23 8:47 下午
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
public class DataTableInfoDTO {
|
||||||
|
private String table;
|
||||||
|
private String sql;
|
||||||
|
}
|
@ -1,11 +1,20 @@
|
|||||||
package io.dataease.service.dataset;
|
package io.dataease.service.dataset;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.nacos.common.util.UuidUtils;
|
import com.alibaba.nacos.common.util.UuidUtils;
|
||||||
|
import com.google.gson.Gson;
|
||||||
import io.dataease.base.domain.DatasetTable;
|
import io.dataease.base.domain.DatasetTable;
|
||||||
import io.dataease.base.domain.DatasetTableExample;
|
import io.dataease.base.domain.DatasetTableExample;
|
||||||
|
import io.dataease.base.domain.Datasource;
|
||||||
import io.dataease.base.mapper.DatasetTableMapper;
|
import io.dataease.base.mapper.DatasetTableMapper;
|
||||||
import io.dataease.commons.utils.BeanUtils;
|
import io.dataease.base.mapper.DatasourceMapper;
|
||||||
import io.dataease.controller.request.dataset.DataSetTableRequest;
|
import io.dataease.controller.request.dataset.DataSetTableRequest;
|
||||||
|
import io.dataease.datasource.dto.TableFiled;
|
||||||
|
import io.dataease.datasource.provider.DatasourceProvider;
|
||||||
|
import io.dataease.datasource.provider.ProviderFactory;
|
||||||
|
import io.dataease.datasource.request.DatasourceRequest;
|
||||||
|
import io.dataease.dto.dataset.DataTableInfoDTO;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -20,6 +29,8 @@ import java.util.List;
|
|||||||
public class DataSetTableService {
|
public class DataSetTableService {
|
||||||
@Resource
|
@Resource
|
||||||
private DatasetTableMapper datasetTableMapper;
|
private DatasetTableMapper datasetTableMapper;
|
||||||
|
@Resource
|
||||||
|
private DatasourceMapper datasourceMapper;
|
||||||
|
|
||||||
public void batchInsert(List<DatasetTable> datasetTable) {
|
public void batchInsert(List<DatasetTable> datasetTable) {
|
||||||
for (DatasetTable table : datasetTable) {
|
for (DatasetTable table : datasetTable) {
|
||||||
@ -31,9 +42,14 @@ public class DataSetTableService {
|
|||||||
if (StringUtils.isEmpty(datasetTable.getId())) {
|
if (StringUtils.isEmpty(datasetTable.getId())) {
|
||||||
datasetTable.setId(UuidUtils.generateUuid());
|
datasetTable.setId(UuidUtils.generateUuid());
|
||||||
datasetTable.setCreateTime(System.currentTimeMillis());
|
datasetTable.setCreateTime(System.currentTimeMillis());
|
||||||
|
DataTableInfoDTO dataTableInfoDTO = new DataTableInfoDTO();
|
||||||
|
if (StringUtils.equalsIgnoreCase("db", datasetTable.getType())) {
|
||||||
|
dataTableInfoDTO.setTable(datasetTable.getName());
|
||||||
|
}
|
||||||
|
datasetTable.setInfo(new Gson().toJson(dataTableInfoDTO));
|
||||||
datasetTableMapper.insert(datasetTable);
|
datasetTableMapper.insert(datasetTable);
|
||||||
} else {
|
} else {
|
||||||
datasetTableMapper.updateByPrimaryKey(datasetTable);
|
datasetTableMapper.updateByPrimaryKeyWithBLOBs(datasetTable);
|
||||||
}
|
}
|
||||||
return datasetTable;
|
return datasetTable;
|
||||||
}
|
}
|
||||||
@ -48,10 +64,42 @@ public class DataSetTableService {
|
|||||||
if (StringUtils.isNotEmpty(dataSetTableRequest.getSort())) {
|
if (StringUtils.isNotEmpty(dataSetTableRequest.getSort())) {
|
||||||
datasetTableExample.setOrderByClause(dataSetTableRequest.getSort());
|
datasetTableExample.setOrderByClause(dataSetTableRequest.getSort());
|
||||||
}
|
}
|
||||||
return datasetTableMapper.selectByExample(datasetTableExample);
|
return datasetTableMapper.selectByExampleWithBLOBs(datasetTableExample);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatasetTable get(String id) {
|
public DatasetTable get(String id) {
|
||||||
return datasetTableMapper.selectByPrimaryKey(id);
|
return datasetTableMapper.selectByPrimaryKey(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<TableFiled> getFields(DataSetTableRequest dataSetTableRequest) throws Exception {
|
||||||
|
Datasource ds = datasourceMapper.selectByPrimaryKey(dataSetTableRequest.getDataSourceId());
|
||||||
|
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType());
|
||||||
|
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||||
|
datasourceRequest.setDatasource(ds);
|
||||||
|
datasourceRequest.setTable(new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class).getTable());
|
||||||
|
return datasourceProvider.getTableFileds(datasourceRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Object> getData(DataSetTableRequest dataSetTableRequest) throws Exception {
|
||||||
|
Datasource ds = datasourceMapper.selectByPrimaryKey(dataSetTableRequest.getDataSourceId());
|
||||||
|
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType());
|
||||||
|
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||||
|
datasourceRequest.setDatasource(ds);
|
||||||
|
String table = new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class).getTable();
|
||||||
|
datasourceRequest.setQuery("SELECT * FROM " + table + " LIMIT 0,100;");
|
||||||
|
|
||||||
|
List<TableFiled> fields = getFields(dataSetTableRequest);
|
||||||
|
List<String[]> data = datasourceProvider.getData(datasourceRequest);
|
||||||
|
|
||||||
|
JSONArray jsonArray = new JSONArray();
|
||||||
|
data.forEach(ele -> {
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
for (int i = 0; i < ele.length; i++) {
|
||||||
|
jsonObject.put(fields.get(i).getFieldName(), ele[i]);
|
||||||
|
}
|
||||||
|
jsonArray.add(jsonObject);
|
||||||
|
});
|
||||||
|
|
||||||
|
return jsonArray;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ CREATE TABLE IF NOT EXISTS `dataset_table` (
|
|||||||
`scene_id` varchar(50) NOT NULL COMMENT '场景ID',
|
`scene_id` varchar(50) NOT NULL COMMENT '场景ID',
|
||||||
`data_source_id` varchar(50) NOT NULL COMMENT '数据源ID',
|
`data_source_id` varchar(50) NOT NULL COMMENT '数据源ID',
|
||||||
`type` varchar(50) COMMENT 'db,sql,excel,custom',
|
`type` varchar(50) COMMENT 'db,sql,excel,custom',
|
||||||
|
`info` longtext COMMENT '表原始信息',
|
||||||
`create_by` varchar(50) COMMENT '创建人ID',
|
`create_by` varchar(50) COMMENT '创建人ID',
|
||||||
`create_time` bigint(13) COMMENT '创建时间',
|
`create_time` bigint(13) COMMENT '创建时间',
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
|
@ -2,22 +2,15 @@
|
|||||||
<el-col>
|
<el-col>
|
||||||
<el-table
|
<el-table
|
||||||
size="mini"
|
size="mini"
|
||||||
:data="tableData"
|
:data="data"
|
||||||
border
|
border
|
||||||
style="width: 100%">
|
style="width: 100%;">
|
||||||
<el-table-column
|
<el-table-column
|
||||||
prop="date"
|
width="180px"
|
||||||
label="日期"
|
v-for="field in fields"
|
||||||
width="180">
|
:key="field.fieldName"
|
||||||
</el-table-column>
|
:prop="field.fieldName"
|
||||||
<el-table-column
|
:label="field.fieldName">
|
||||||
prop="name"
|
|
||||||
label="姓名"
|
|
||||||
width="180">
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column
|
|
||||||
prop="address"
|
|
||||||
label="地址">
|
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
</el-col>
|
</el-col>
|
||||||
@ -25,6 +18,11 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
|
props: {
|
||||||
|
table: Object,
|
||||||
|
fields: Array,
|
||||||
|
data: Array
|
||||||
|
},
|
||||||
name: "TabDataPreview",
|
name: "TabDataPreview",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
<el-tabs v-model="tabActive">
|
<el-tabs v-model="tabActive">
|
||||||
<el-tab-pane :label="$t('dataset.data_preview')" name="dataPreview">
|
<el-tab-pane :label="$t('dataset.data_preview')" name="dataPreview">
|
||||||
<tab-data-preview/>
|
<tab-data-preview :table="table" :fields="fields" :data="data"/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="tab2" name="tab2">
|
<el-tab-pane label="tab2" name="tab2">
|
||||||
tab2
|
tab2
|
||||||
@ -46,7 +46,9 @@ export default {
|
|||||||
table: {
|
table: {
|
||||||
name: ''
|
name: ''
|
||||||
},
|
},
|
||||||
tabActive: 'dataPreview'
|
fields: [],
|
||||||
|
data: [],
|
||||||
|
tabActive: 'dataPreview',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -66,13 +68,35 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initTable(id) {
|
initTable(id) {
|
||||||
|
console.log(id);
|
||||||
if (id !== null) {
|
if (id !== null) {
|
||||||
|
this.data = [];
|
||||||
this.$post('/dataset/table/get/' + id, null, response => {
|
this.$post('/dataset/table/get/' + id, null, response => {
|
||||||
this.table = response.data;
|
this.table = response.data;
|
||||||
|
this.initTableFields();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
initTableFields() {
|
||||||
|
if (this.table.id) {
|
||||||
|
this.$post('/dataset/table/getFields', this.table, response => {
|
||||||
|
// console.log(response.data);
|
||||||
|
this.fields = response.data;
|
||||||
|
this.initTableData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
initTableData() {
|
||||||
|
if (this.table.id) {
|
||||||
|
this.$post('/dataset/table/getData', this.table, response => {
|
||||||
|
// console.log(response.data);
|
||||||
|
this.data = response.data;
|
||||||
|
console.log(this.data)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
resetTable() {
|
resetTable() {
|
||||||
this.table = {
|
this.table = {
|
||||||
name: ''
|
name: ''
|
||||||
|
Loading…
Reference in New Issue
Block a user