提交 3db9e411 authored 作者: taojinlong's avatar taojinlong

Merge branch 'dev' of github.com:dataease/dataease into dev

package io.dataease.base.domain;
import java.io.Serializable;
import lombok.Data;
@Data
public class DatasetTableFunction implements Serializable {
private Long id;
private String name;
private String func;
private String dbType;
private Integer funcType;
private String desc;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package io.dataease.base.mapper;
import io.dataease.base.domain.DatasetTableFunction;
import io.dataease.base.domain.DatasetTableFunctionExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface DatasetTableFunctionMapper {
long countByExample(DatasetTableFunctionExample example);
int deleteByExample(DatasetTableFunctionExample example);
int deleteByPrimaryKey(Long id);
int insert(DatasetTableFunction record);
int insertSelective(DatasetTableFunction record);
List<DatasetTableFunction> selectByExampleWithBLOBs(DatasetTableFunctionExample example);
List<DatasetTableFunction> selectByExample(DatasetTableFunctionExample example);
DatasetTableFunction selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") DatasetTableFunction record, @Param("example") DatasetTableFunctionExample example);
int updateByExampleWithBLOBs(@Param("record") DatasetTableFunction record, @Param("example") DatasetTableFunctionExample example);
int updateByExample(@Param("record") DatasetTableFunction record, @Param("example") DatasetTableFunctionExample example);
int updateByPrimaryKeySelective(DatasetTableFunction record);
int updateByPrimaryKeyWithBLOBs(DatasetTableFunction record);
int updateByPrimaryKey(DatasetTableFunction record);
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.dataease.base.mapper.DatasetTableFunctionMapper">
<resultMap id="BaseResultMap" type="io.dataease.base.domain.DatasetTableFunction">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="func" jdbcType="VARCHAR" property="func" />
<result column="db_type" jdbcType="VARCHAR" property="dbType" />
<result column="func_type" jdbcType="INTEGER" property="funcType" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.dataease.base.domain.DatasetTableFunction">
<result column="desc" jdbcType="LONGVARCHAR" property="desc" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, `name`, func, db_type, func_type
</sql>
<sql id="Blob_Column_List">
`desc`
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.dataease.base.domain.DatasetTableFunctionExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from dataset_table_function
<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.DatasetTableFunctionExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from dataset_table_function
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from dataset_table_function
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from dataset_table_function
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="io.dataease.base.domain.DatasetTableFunctionExample">
delete from dataset_table_function
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.dataease.base.domain.DatasetTableFunction">
insert into dataset_table_function (id, `name`, func,
db_type, func_type, `desc`
)
values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{func,jdbcType=VARCHAR},
#{dbType,jdbcType=VARCHAR}, #{funcType,jdbcType=INTEGER}, #{desc,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.dataease.base.domain.DatasetTableFunction">
insert into dataset_table_function
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="name != null">
`name`,
</if>
<if test="func != null">
func,
</if>
<if test="dbType != null">
db_type,
</if>
<if test="funcType != null">
func_type,
</if>
<if test="desc != null">
`desc`,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="func != null">
#{func,jdbcType=VARCHAR},
</if>
<if test="dbType != null">
#{dbType,jdbcType=VARCHAR},
</if>
<if test="funcType != null">
#{funcType,jdbcType=INTEGER},
</if>
<if test="desc != null">
#{desc,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.dataease.base.domain.DatasetTableFunctionExample" resultType="java.lang.Long">
select count(*) from dataset_table_function
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update dataset_table_function
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.name != null">
`name` = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.func != null">
func = #{record.func,jdbcType=VARCHAR},
</if>
<if test="record.dbType != null">
db_type = #{record.dbType,jdbcType=VARCHAR},
</if>
<if test="record.funcType != null">
func_type = #{record.funcType,jdbcType=INTEGER},
</if>
<if test="record.desc != null">
`desc` = #{record.desc,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update dataset_table_function
set id = #{record.id,jdbcType=BIGINT},
`name` = #{record.name,jdbcType=VARCHAR},
func = #{record.func,jdbcType=VARCHAR},
db_type = #{record.dbType,jdbcType=VARCHAR},
func_type = #{record.funcType,jdbcType=INTEGER},
`desc` = #{record.desc,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update dataset_table_function
set id = #{record.id,jdbcType=BIGINT},
`name` = #{record.name,jdbcType=VARCHAR},
func = #{record.func,jdbcType=VARCHAR},
db_type = #{record.dbType,jdbcType=VARCHAR},
func_type = #{record.funcType,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.dataease.base.domain.DatasetTableFunction">
update dataset_table_function
<set>
<if test="name != null">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="func != null">
func = #{func,jdbcType=VARCHAR},
</if>
<if test="dbType != null">
db_type = #{dbType,jdbcType=VARCHAR},
</if>
<if test="funcType != null">
func_type = #{funcType,jdbcType=INTEGER},
</if>
<if test="desc != null">
`desc` = #{desc,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.dataease.base.domain.DatasetTableFunction">
update dataset_table_function
set `name` = #{name,jdbcType=VARCHAR},
func = #{func,jdbcType=VARCHAR},
db_type = #{dbType,jdbcType=VARCHAR},
func_type = #{funcType,jdbcType=INTEGER},
`desc` = #{desc,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="io.dataease.base.domain.DatasetTableFunction">
update dataset_table_function
set `name` = #{name,jdbcType=VARCHAR},
func = #{func,jdbcType=VARCHAR},
db_type = #{dbType,jdbcType=VARCHAR},
func_type = #{funcType,jdbcType=INTEGER}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
package io.dataease.controller.chart;
import io.dataease.base.domain.ChartViewWithBLOBs;
import io.dataease.commons.utils.AuthUtils;
import io.dataease.controller.request.chart.ChartExtRequest;
import io.dataease.controller.request.chart.ChartViewRequest;
import io.dataease.dto.chart.ChartViewDTO;
......@@ -68,6 +69,12 @@ public class ChartViewController {
@PostMapping("/getOneWithPermission/{id}")
public ChartViewDTO getOneWithPermission(@PathVariable String id, @RequestBody ChartExtRequest requestList) throws Exception {
return chartViewService.getData(id, requestList);
//如果能获取用户 则添加对应的权限
ChartViewDTO dto = chartViewService.getData(id, requestList);
if(dto!=null && AuthUtils.getUser()!=null){
ChartViewDTO permissionDto = chartViewService.getOneWithPermission(dto.getId());
dto.setPrivileges(permissionDto.getPrivileges());
}
return dto;
}
}
......@@ -51,6 +51,16 @@ public class DataSetTableFieldController {
dataSetTableFieldsService.batchEdit(list);
}
@PostMapping("save")
public DatasetTableField save(@RequestBody DatasetTableField datasetTableField) {
return dataSetTableFieldsService.save(datasetTableField);
}
@PostMapping("delete/{id}")
public void delete(@PathVariable String id) {
dataSetTableFieldsService.delete(id);
}
@PostMapping("fieldValues/{fieldId}")
public List<Object> fieldValues(@PathVariable String fieldId) {
return dataSetFieldService.fieldValues(fieldId);
......
package io.dataease.controller.dataset;
import io.dataease.base.domain.DatasetTableFunction;
import io.dataease.service.dataset.DatasetFunctionService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* @Author gin
* @Date 2021/7/29 11:58 上午
*/
@RestController
@RequestMapping("dataset/function")
public class DatasetFunctionController {
@Resource
private DatasetFunctionService datasetFunctionService;
@PostMapping("listByTableId/{tableId}")
public List<DatasetTableFunction> listByTableId(@PathVariable String tableId) {
return datasetFunctionService.listByTableId(tableId);
}
}
......@@ -315,12 +315,6 @@ public class ChartViewService {
BeanUtils.copyBean(dto, view);
dto.setData(map);
dto.setSql(datasourceRequest.getQuery());
//如果能获取用户 则添加对应的权限
if(AuthUtils.getUser()!=null){
ChartViewDTO permissionDto = getOneWithPermission(dto.getId());
dto.setPrivileges(permissionDto.getPrivileges());
}
return dto;
}
......
......@@ -3,6 +3,7 @@ package io.dataease.service.dataset;
import io.dataease.base.domain.DatasetTableField;
import io.dataease.base.domain.DatasetTableFieldExample;
import io.dataease.base.mapper.DatasetTableFieldMapper;
import io.dataease.commons.utils.DorisTableUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -32,6 +33,13 @@ public class DataSetTableFieldsService {
public DatasetTableField save(DatasetTableField datasetTableField) {
if (StringUtils.isEmpty(datasetTableField.getId())) {
datasetTableField.setId(UUID.randomUUID().toString());
// 若dataeasename为空,则用MD5(id)作为dataeasename
if (StringUtils.isEmpty(datasetTableField.getDataeaseName())) {
datasetTableField.setDataeaseName(DorisTableUtils.dorisFieldName(datasetTableField.getId()));
}
if (ObjectUtils.isEmpty(datasetTableField.getLastSyncTime())) {
datasetTableField.setLastSyncTime(System.currentTimeMillis());
}
datasetTableFieldMapper.insert(datasetTableField);
} else {
datasetTableFieldMapper.updateByPrimaryKeySelective(datasetTableField);
......@@ -86,4 +94,8 @@ public class DataSetTableFieldsService {
public DatasetTableField get(String id) {
return datasetTableFieldMapper.selectByPrimaryKey(id);
}
public void delete(String id) {
datasetTableFieldMapper.deleteByPrimaryKey(id);
}
}
package io.dataease.service.dataset;
import io.dataease.base.domain.*;
import io.dataease.base.mapper.DatasetTableFunctionMapper;
import io.dataease.commons.utils.DorisTableUtils;
import io.dataease.datasource.service.DatasourceService;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.UUID;
/**
* @Author gin
* @Date 2021/7/29 11:58 上午
*/
@Service
public class DatasetFunctionService {
@Resource
private DatasetTableFunctionMapper datasetTableFunctionMapper;
@Resource
private DataSetTableService dataSetTableService;
@Resource
private DatasourceService datasourceService;
public DatasetTableFunction get(Long id) {
return datasetTableFunctionMapper.selectByPrimaryKey(id);
}
public List<DatasetTableFunction> list(DatasetTableFunction datasetTableFunction) {
DatasetTableFunctionExample datasetTableFunctionExample = new DatasetTableFunctionExample();
DatasetTableFunctionExample.Criteria criteria = datasetTableFunctionExample.createCriteria();
if (StringUtils.isNotEmpty(datasetTableFunction.getDbType())) {
criteria.andDbTypeEqualTo(datasetTableFunction.getDbType());
}
return datasetTableFunctionMapper.selectByExampleWithBLOBs(datasetTableFunctionExample);
}
public List<DatasetTableFunction> listByTableId(String id) {
DatasetTable datasetTable = dataSetTableService.get(id);
String dbType;
if (datasetTable.getMode() == 0) {
Datasource datasource = datasourceService.get(datasetTable.getDataSourceId());
dbType = datasource.getType();
} else {
dbType = "doris";
}
DatasetTableFunction datasetTableFunction = new DatasetTableFunction();
datasetTableFunction.setDbType(dbType);
return list(datasetTableFunction);
}
}
......@@ -2939,3 +2939,62 @@ INSERT INTO `area_mapping` VALUES (2897, '澳门特别行政区', '156820000', '
COMMIT;
SET FOREIGN_KEY_CHECKS = 1;
ALTER TABLE `dataset_table_field` MODIFY COLUMN `origin_name` LONGTEXT;
/*
Navicat Premium Data Transfer
Source Server : local
Source Server Type : MySQL
Source Server Version : 50730
Source Host : 127.0.0.1:3306
Source Schema : dataease
Target Server Type : MySQL
Target Server Version : 50730
File Encoding : 65001
Date: 29/07/2021 11:55:10
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for dataset_table_function
-- ----------------------------
DROP TABLE IF EXISTS `dataset_table_function`;
CREATE TABLE `dataset_table_function` (
`id` bigint(20) NOT NULL COMMENT 'ID',
`name` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '函数名称',
`func` varchar(500) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '函数表达式',
`db_type` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '所属数据库',
`func_type` int(10) DEFAULT NULL COMMENT '函数类型:0-聚合函数;1-快速计算函数;2-数学和三角函数;3-日期函数;4-文本函数;5-逻辑函数;6-其它函数',
`desc` longtext COLLATE utf8mb4_bin COMMENT '描述',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
-- ----------------------------
-- Records of dataset_table_function
-- ----------------------------
BEGIN;
INSERT INTO `dataset_table_function` VALUES (1, 'ABS', 'ABS(x)', 'mysql', 2, '返回x的绝对值');
INSERT INTO `dataset_table_function` VALUES (2, 'PI', 'PI()', 'mysql', 2, '返回圆周率π,默认显示6位小数');
INSERT INTO `dataset_table_function` VALUES (3, 'CHAR_LENGTH', 'CHAR_LENGTH(str)', 'mysql', 4, '计算字符串字符个数');
INSERT INTO `dataset_table_function` VALUES (4, 'TRIM', 'TRIM(s)', 'mysql', 4, '返回字符串s删除了两边空格之后的字符串');
INSERT INTO `dataset_table_function` VALUES (5, 'REPLACE', 'REPLACE(s,s1,s2)', 'mysql', 4, '返回一个字符串,用字符串s2替代字符串s中所有的字符串s1');
INSERT INTO `dataset_table_function` VALUES (6, 'SUBSTRING', 'SUBSTRING(s,n,len)', 'mysql', 4, '获取从字符串s中的第n个位置开始长度为len的字符串');
INSERT INTO `dataset_table_function` VALUES (7, 'IF', 'IF(expr,v1,v2)', 'mysql', 5, '如果expr是TRUE则返回v1,否则返回v2');
INSERT INTO `dataset_table_function` VALUES (8, 'IFNULL', 'IFNULL(v1,v2)', 'mysql', 5, '如果v1不为NULL,则返回v1,否则返回v2');
INSERT INTO `dataset_table_function` VALUES (9, 'FLOOR', 'FLOOR(x)', 'mysql', 2, '返回不大于x的最大整数');
INSERT INTO `dataset_table_function` VALUES (10, 'ROUND', 'ROUND(x)', 'mysql', 2, '返回离x最近的整数');
INSERT INTO `dataset_table_function` VALUES (11, 'ROUND', 'ROUND(x,y)', 'mysql', 2, '保留x小数点后y位的值,但截断时要进行四舍五入');
INSERT INTO `dataset_table_function` VALUES (12, 'ABS', 'ABS(x)', 'doris', 2, '返回x的绝对值');
INSERT INTO `dataset_table_function` VALUES (13, 'SUBSTR', 'SUBSTR(char, position, substring_length)', 'oracle', 4, '获取从字符串char中的第position个位置开始长度为substring_lenght的字符串');
COMMIT;
SET FOREIGN_KEY_CHECKS = 1;
DROP FUNCTION IF EXISTS `GET_CHART_VIEW_COPY_NAME`;
delimiter ;;
CREATE DEFINER=`root`@`%` FUNCTION `GET_CHART_VIEW_COPY_NAME`(chartId varchar(255)) RETURNS varchar(255) CHARSET utf8
CREATE FUNCTION `GET_CHART_VIEW_COPY_NAME`(chartId varchar(255)) RETURNS varchar(255) CHARSET utf8
READS SQL DATA
BEGIN
......
......@@ -64,7 +64,7 @@
<!--要生成的数据库表 -->
<table tableName="chart_view"/>
<table tableName="dataset_table_function"/>
<!-- <table tableName="sys_dict"/>-->
<!-- <table tableName="sys_dict_item"/>-->
<!-- <table tableName="dataset_table_field"/>-->
......
......@@ -4,7 +4,6 @@
<el-dropdown trigger="click" @mouseup="handleMouseUp">
<slot name="icon" />
<el-dropdown-menu>
this is test
<el-dropdown-item v-if="curComponent&&editFilter.includes(curComponent.type)" icon="el-icon-edit-outline" @click.native="edit">{{ $t('panel.edit') }}</el-dropdown-item>
<el-dropdown-item icon="el-icon-document-copy" @click.native="copy">{{ $t('panel.copy') }}</el-dropdown-item>
<el-dropdown-item icon="el-icon-delete" @click.native="deleteComponent">{{ $t('panel.delete') }}</el-dropdown-item>
......
......@@ -986,7 +986,9 @@ export default {
data_type: 'Data Type',
click_ref_field: 'Click Quote Field',
click_ref_function: 'Click Quote Function',
field_manage: 'Field Manage'
field_manage: 'Field Manage',
edit_calc_field: 'Edit calc field',
calc_field: 'Calc Field'
},
datasource: {
datasource: 'Data Source',
......
......@@ -986,7 +986,9 @@ export default {
data_type: '數據類型',
click_ref_field: '點擊引用字段',
click_ref_function: '點擊引用函數',
field_manage: '字段管理'
field_manage: '字段管理',
edit_calc_field: '編輯計算字段',
calc_field: '計算字段'
},
datasource: {
datasource: '數據源',
......
......@@ -986,7 +986,9 @@ export default {
data_type: '数据类型',
click_ref_field: '点击引用字段',
click_ref_function: '点击引用函数',
field_manage: '字段管理'
field_manage: '字段管理',
edit_calc_field: '编辑计算字段',
calc_field: '计算字段'
},
datasource: {
datasource: '数据源',
......
......@@ -908,7 +908,9 @@ export default {
this.data = response.data.data
// console.log(JSON.stringify(this.chart))
this.httpRequest.status = true
this.param.privileges = this.chart.privileges
if (this.chart.privileges) {
this.param.privileges = this.chart.privileges
}
}).catch(err => {
this.resetView()
this.httpRequest.status = err.response.data.success
......
......@@ -14,7 +14,7 @@
<span>{{ $t('dataset.field_exp') }}</span>
<codemirror
ref="myCm"
v-model="fieldExp"
v-model="fieldForm.originName"
class="codemirror"
:options="cmOption"
@ready="onCmReady"
......@@ -67,7 +67,7 @@
:disabled="true"
>
<transition-group>
<span v-for="item in tableFields.dimensionList" :key="item.id" class="item-dimension" :title="item.name" @click="insertParamToCodeMirror(item.id)">
<span v-for="item in tableFields.dimensionList.filter(ele => ele.extField === 0)" :key="item.id" class="item-dimension" :title="item.name" @click="insertParamToCodeMirror('['+item.id+']')">
<svg-icon v-if="item.deType === 0" icon-class="field_text" class="field-icon-text" />
<svg-icon v-if="item.deType === 1" icon-class="field_time" class="field-icon-time" />
<svg-icon v-if="item.deType === 2 || item.deType === 3" icon-class="field_value" class="field-icon-value" />
......@@ -87,7 +87,7 @@
:disabled="true"
>
<transition-group>
<span v-for="item in tableFields.quotaList" :key="item.id" class="item-quota" :title="item.name" @click="insertParamToCodeMirror(item.id)">
<span v-for="item in tableFields.quotaList.filter(ele => ele.extField === 0)" :key="item.id" class="item-quota" :title="item.name" @click="insertParamToCodeMirror('['+item.id+']')">
<svg-icon v-if="item.deType === 0" icon-class="field_text" class="field-icon-text" />
<svg-icon v-if="item.deType === 1" icon-class="field_time" class="field-icon-time" />
<svg-icon v-if="item.deType === 2 || item.deType === 3" icon-class="field_value" class="field-icon-value" />
......@@ -101,11 +101,31 @@
<el-col :span="12" style="height: 100%">
<span>{{ $t('dataset.click_ref_function') }}</span>
<el-row class="padding-lr function-height">
<span v-for="(item,index) in functions" :key="index" class="function-style" @click="insertParamToCodeMirror(item.name)">{{ item.name }}</span>
<el-popover
v-for="(item,index) in functions"
:key="index"
class="function-pop"
placement="right"
width="200"
trigger="hover"
:open-delay="500"
>
<p class="pop-title">{{ item.name }}</p>
<p class="pop-info">{{ item.func }}</p>
<p class="pop-info">{{ item.desc }}</p>
<span slot="reference" class="function-style" :title="item.func" @click="insertParamToCodeMirror(item.func)">{{ item.func }}</span>
</el-popover>
</el-row>
</el-col>
</el-col>
</el-row>
<el-row>
<div class="dialog-button">
<el-button size="mini" @click="closeCalcField">{{ $t('dataset.cancel') }}</el-button>
<el-button :disabled="!fieldForm.name || !fieldForm.originName" type="primary" size="mini" @click="saveCalcField">{{ $t('dataset.confirm') }}</el-button>
</div>
</el-row>
</el-row>
</template>
......@@ -134,6 +154,7 @@ import 'codemirror/keymap/emacs.js'
import 'codemirror/addon/hint/show-hint.css'
import 'codemirror/addon/hint/sql-hint'
import 'codemirror/addon/hint/show-hint'
import { post } from '../../../api/dataset/dataset'
export default {
name: 'CalcFieldEdit',
......@@ -146,16 +167,26 @@ export default {
tableFields: {
type: Object,
required: true
},
field: {
type: Object,
required: true
}
},
data() {
return {
fieldForm: {
id: null,
name: '',
groupType: 'd',
deType: 0
deType: 0,
originName: '',
tableId: this.param.id,
checked: 1,
columnIndex: this.tableFields.dimensionList.length + this.tableFields.quotaList.length,
size: 0,
extField: 2
},
fieldExp: '',
cmOption: {
tabSize: 2,
styleActiveLine: true,
......@@ -174,33 +205,7 @@ export default {
{ label: this.$t('dataset.value') + '(' + this.$t('dataset.float') + ')', value: 3 },
{ label: this.$t('dataset.location'), value: 5 }
],
functions: [
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' },
{ name: 'ABS(n)' }
]
functions: []
}
},
computed: {
......@@ -208,10 +213,23 @@ export default {
return this.$refs.myCm.codemirror
}
},
watch: {
'param': function() {
this.initFunctions()
},
'field': function() {
if (this.field.id) {
this.fieldForm = JSON.parse(JSON.stringify(this.field))
} else {
this.fieldForm = JSON.parse(JSON.stringify(this.fieldForm))
}
}
},
mounted() {
this.$refs.myCm.codemirror.on('keypress', () => {
this.$refs.myCm.codemirror.showHint()
})
this.initFunctions()
},
methods: {
onCmReady(cm) {
......@@ -222,7 +240,7 @@ export default {
},
onCmCodeChange(newCode) {
// console.log(newCode)
this.fieldExp = newCode
this.fieldForm.originName = newCode
},
insertParamToCodeMirror(param) {
const pos1 = this.$refs.myCm.codemirror.getCursor()
......@@ -230,6 +248,26 @@ export default {
pos2.line = pos1.line
pos2.ch = pos1.ch
this.$refs.myCm.codemirror.replaceRange(param, pos2)
},
initFunctions() {
post('/dataset/function/listByTableId/' + this.param.id, null).then(response => {
this.functions = response.data
})
},
closeCalcField() {
this.$emit('onEditClose', {})
},
saveCalcField() {
if (!this.fieldForm.id) {
this.fieldForm.type = this.fieldForm.deType
this.fieldForm.deExtractType = this.fieldForm.deType
}
post('/dataset/field/save', this.fieldForm).then(response => {
this.closeCalcField()
})
}
}
}
......@@ -329,9 +367,28 @@ export default {
padding: 2px 4px;
cursor: pointer;
margin: 4px 0;
overflow-x: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.function-height{
height: calc(100% - 20px);
overflow: auto;
}
.function-pop>>>.el-popover{
padding: 6px!important;
}
.pop-title{
margin: 6px 0 0 0;
font-size: 14px;
font-weight: 500;
}
.pop-info{
margin: 6px 0 0 0;
font-size: 10px;
}
.dialog-button{
float: right;
margin-top: 10px;
}
</style>
......@@ -44,7 +44,7 @@
</el-row>
<el-divider />
<el-tabs v-model="tabActive" @tab-click="initTable(param.id)">
<el-tabs v-model="tabActive" @tab-click="tabClick">
<el-tab-pane :label="$t('dataset.data_preview')" name="dataPreview">
<tab-data-preview :param="param" :table="table" :fields="fields" :data="data" :page="page" :form="tableViewRowForm" @reSearch="reSearch" />
</el-tab-pane>
......@@ -62,7 +62,7 @@
</template>
<script>
import { getTable, post } from '@/api/dataset/dataset'
import { post } from '@/api/dataset/dataset'
import TabDataPreview from './TabDataPreview'
import UpdateInfo from './UpdateInfo'
import DatasetChartDetail from '../common/DatasetChartDetail'
......@@ -207,6 +207,12 @@ export default {
pageSize: 100,
show: 1000
}
},
tabClick() {
if (this.tabActive === 'dataPreview') {
this.initTable(this.param.id)
}
}
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论