forked from github/dataease
feat(数据集): 数据集字段支持公式运算等操作(UI和CRUD)
This commit is contained in:
parent
def4161c88
commit
b99d9e2d8b
@ -0,0 +1,21 @@
|
||||
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;
|
||||
}
|
@ -0,0 +1,530 @@
|
||||
package io.dataease.base.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DatasetTableFunctionExample {
|
||||
protected String orderByClause;
|
||||
|
||||
protected boolean distinct;
|
||||
|
||||
protected List<Criteria> oredCriteria;
|
||||
|
||||
public DatasetTableFunctionExample() {
|
||||
oredCriteria = new ArrayList<Criteria>();
|
||||
}
|
||||
|
||||
public void setOrderByClause(String orderByClause) {
|
||||
this.orderByClause = orderByClause;
|
||||
}
|
||||
|
||||
public String getOrderByClause() {
|
||||
return orderByClause;
|
||||
}
|
||||
|
||||
public void setDistinct(boolean distinct) {
|
||||
this.distinct = distinct;
|
||||
}
|
||||
|
||||
public boolean isDistinct() {
|
||||
return distinct;
|
||||
}
|
||||
|
||||
public List<Criteria> getOredCriteria() {
|
||||
return oredCriteria;
|
||||
}
|
||||
|
||||
public void or(Criteria criteria) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
|
||||
public Criteria or() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
oredCriteria.add(criteria);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public Criteria createCriteria() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
if (oredCriteria.size() == 0) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected Criteria createCriteriaInternal() {
|
||||
Criteria criteria = new Criteria();
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
oredCriteria.clear();
|
||||
orderByClause = null;
|
||||
distinct = false;
|
||||
}
|
||||
|
||||
protected abstract static class GeneratedCriteria {
|
||||
protected List<Criterion> criteria;
|
||||
|
||||
protected GeneratedCriteria() {
|
||||
super();
|
||||
criteria = new ArrayList<Criterion>();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return criteria.size() > 0;
|
||||
}
|
||||
|
||||
public List<Criterion> getAllCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public List<Criterion> getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition) {
|
||||
if (condition == null) {
|
||||
throw new RuntimeException("Value for condition cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value, String property) {
|
||||
if (value == null) {
|
||||
throw new RuntimeException("Value for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value1, Object value2, String property) {
|
||||
if (value1 == null || value2 == null) {
|
||||
throw new RuntimeException("Between values for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value1, value2));
|
||||
}
|
||||
|
||||
public Criteria andIdIsNull() {
|
||||
addCriterion("id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIsNotNull() {
|
||||
addCriterion("id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdEqualTo(Long value) {
|
||||
addCriterion("id =", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotEqualTo(Long value) {
|
||||
addCriterion("id <>", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThan(Long value) {
|
||||
addCriterion("id >", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("id >=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThan(Long value) {
|
||||
addCriterion("id <", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThanOrEqualTo(Long value) {
|
||||
addCriterion("id <=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIn(List<Long> values) {
|
||||
addCriterion("id in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotIn(List<Long> values) {
|
||||
addCriterion("id not in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdBetween(Long value1, Long value2) {
|
||||
addCriterion("id between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotBetween(Long value1, Long value2) {
|
||||
addCriterion("id not between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIsNull() {
|
||||
addCriterion("`name` is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIsNotNull() {
|
||||
addCriterion("`name` is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameEqualTo(String value) {
|
||||
addCriterion("`name` =", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotEqualTo(String value) {
|
||||
addCriterion("`name` <>", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameGreaterThan(String value) {
|
||||
addCriterion("`name` >", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("`name` >=", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameLessThan(String value) {
|
||||
addCriterion("`name` <", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameLessThanOrEqualTo(String value) {
|
||||
addCriterion("`name` <=", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameLike(String value) {
|
||||
addCriterion("`name` like", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotLike(String value) {
|
||||
addCriterion("`name` not like", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIn(List<String> values) {
|
||||
addCriterion("`name` in", values, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotIn(List<String> values) {
|
||||
addCriterion("`name` not in", values, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameBetween(String value1, String value2) {
|
||||
addCriterion("`name` between", value1, value2, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotBetween(String value1, String value2) {
|
||||
addCriterion("`name` not between", value1, value2, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncIsNull() {
|
||||
addCriterion("func is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncIsNotNull() {
|
||||
addCriterion("func is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncEqualTo(String value) {
|
||||
addCriterion("func =", value, "func");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncNotEqualTo(String value) {
|
||||
addCriterion("func <>", value, "func");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncGreaterThan(String value) {
|
||||
addCriterion("func >", value, "func");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("func >=", value, "func");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncLessThan(String value) {
|
||||
addCriterion("func <", value, "func");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncLessThanOrEqualTo(String value) {
|
||||
addCriterion("func <=", value, "func");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncLike(String value) {
|
||||
addCriterion("func like", value, "func");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncNotLike(String value) {
|
||||
addCriterion("func not like", value, "func");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncIn(List<String> values) {
|
||||
addCriterion("func in", values, "func");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncNotIn(List<String> values) {
|
||||
addCriterion("func not in", values, "func");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncBetween(String value1, String value2) {
|
||||
addCriterion("func between", value1, value2, "func");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncNotBetween(String value1, String value2) {
|
||||
addCriterion("func not between", value1, value2, "func");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDbTypeIsNull() {
|
||||
addCriterion("db_type is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDbTypeIsNotNull() {
|
||||
addCriterion("db_type is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDbTypeEqualTo(String value) {
|
||||
addCriterion("db_type =", value, "dbType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDbTypeNotEqualTo(String value) {
|
||||
addCriterion("db_type <>", value, "dbType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDbTypeGreaterThan(String value) {
|
||||
addCriterion("db_type >", value, "dbType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDbTypeGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("db_type >=", value, "dbType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDbTypeLessThan(String value) {
|
||||
addCriterion("db_type <", value, "dbType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDbTypeLessThanOrEqualTo(String value) {
|
||||
addCriterion("db_type <=", value, "dbType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDbTypeLike(String value) {
|
||||
addCriterion("db_type like", value, "dbType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDbTypeNotLike(String value) {
|
||||
addCriterion("db_type not like", value, "dbType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDbTypeIn(List<String> values) {
|
||||
addCriterion("db_type in", values, "dbType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDbTypeNotIn(List<String> values) {
|
||||
addCriterion("db_type not in", values, "dbType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDbTypeBetween(String value1, String value2) {
|
||||
addCriterion("db_type between", value1, value2, "dbType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDbTypeNotBetween(String value1, String value2) {
|
||||
addCriterion("db_type not between", value1, value2, "dbType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncTypeIsNull() {
|
||||
addCriterion("func_type is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncTypeIsNotNull() {
|
||||
addCriterion("func_type is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncTypeEqualTo(Integer value) {
|
||||
addCriterion("func_type =", value, "funcType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncTypeNotEqualTo(Integer value) {
|
||||
addCriterion("func_type <>", value, "funcType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncTypeGreaterThan(Integer value) {
|
||||
addCriterion("func_type >", value, "funcType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncTypeGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("func_type >=", value, "funcType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncTypeLessThan(Integer value) {
|
||||
addCriterion("func_type <", value, "funcType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncTypeLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("func_type <=", value, "funcType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncTypeIn(List<Integer> values) {
|
||||
addCriterion("func_type in", values, "funcType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncTypeNotIn(List<Integer> values) {
|
||||
addCriterion("func_type not in", values, "funcType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncTypeBetween(Integer value1, Integer value2) {
|
||||
addCriterion("func_type between", value1, value2, "funcType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFuncTypeNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("func_type not between", value1, value2, "funcType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
||||
protected Criteria() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criterion {
|
||||
private String condition;
|
||||
|
||||
private Object value;
|
||||
|
||||
private Object secondValue;
|
||||
|
||||
private boolean noValue;
|
||||
|
||||
private boolean singleValue;
|
||||
|
||||
private boolean betweenValue;
|
||||
|
||||
private boolean listValue;
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.typeHandler = null;
|
||||
this.noValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.typeHandler = typeHandler;
|
||||
if (value instanceof List<?>) {
|
||||
this.listValue = true;
|
||||
} else {
|
||||
this.singleValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value) {
|
||||
this(condition, value, null);
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.secondValue = secondValue;
|
||||
this.typeHandler = typeHandler;
|
||||
this.betweenValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
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);
|
||||
}
|
@ -0,0 +1,270 @@
|
||||
<?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>
|
@ -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);
|
||||
|
@ -0,0 +1,27 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -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,10 @@ 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()));
|
||||
}
|
||||
datasetTableFieldMapper.insert(datasetTableField);
|
||||
} else {
|
||||
datasetTableFieldMapper.updateByPrimaryKeySelective(datasetTableField);
|
||||
@ -86,4 +91,8 @@ public class DataSetTableFieldsService {
|
||||
public DatasetTableField get(String id) {
|
||||
return datasetTableFieldMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public void delete(String id) {
|
||||
datasetTableFieldMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
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;
|
||||
|
@ -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"/>-->
|
||||
|
@ -986,7 +986,8 @@ 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'
|
||||
},
|
||||
datasource: {
|
||||
datasource: 'Data Source',
|
||||
|
@ -986,7 +986,8 @@ export default {
|
||||
data_type: '數據類型',
|
||||
click_ref_field: '點擊引用字段',
|
||||
click_ref_function: '點擊引用函數',
|
||||
field_manage: '字段管理'
|
||||
field_manage: '字段管理',
|
||||
edit_calc_field: '編輯計算字段'
|
||||
},
|
||||
datasource: {
|
||||
datasource: '數據源',
|
||||
|
@ -986,7 +986,8 @@ export default {
|
||||
data_type: '数据类型',
|
||||
click_ref_field: '点击引用字段',
|
||||
click_ref_function: '点击引用函数',
|
||||
field_manage: '字段管理'
|
||||
field_manage: '字段管理',
|
||||
edit_calc_field: '编辑计算字段'
|
||||
},
|
||||
datasource: {
|
||||
datasource: '数据源',
|
||||
|
@ -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>
|
||||
|
@ -33,12 +33,12 @@
|
||||
<el-table :data="tableFields.dimensionListData" size="mini">
|
||||
<el-table-column property="checked" :label="$t('dataset.field_check')" width="60">
|
||||
<template slot-scope="scope">
|
||||
<el-checkbox v-model="scope.row.checked" :disabled="!hasDataPermission('manage',param.privileges)" @change="saveEdit" />
|
||||
<el-checkbox v-model="scope.row.checked" :disabled="!hasDataPermission('manage',param.privileges)" @change="saveEdit(scope.row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column property="name" :label="$t('dataset.field_name')" width="180">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.name" size="mini" :disabled="!hasDataPermission('manage',param.privileges)" @blur="saveEdit" @keyup.enter.native="saveEdit" />
|
||||
<el-input v-model="scope.row.name" size="mini" :disabled="!hasDataPermission('manage',param.privileges)" @blur="saveEdit(scope.row)" @keyup.enter.native="saveEdit(scope.row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="!(param.mode === 0 && param.type === 'custom')" property="originName" :label="$t('dataset.field_origin_name')" width="100">
|
||||
@ -50,7 +50,7 @@
|
||||
</el-table-column>
|
||||
<el-table-column property="deType" :label="$t('dataset.field_type')" width="140">
|
||||
<template slot-scope="scope">
|
||||
<el-select v-model="scope.row.deType" size="mini" style="display: inline-block;width: 26px;" :disabled="!hasDataPermission('manage',param.privileges)" @change="saveEdit">
|
||||
<el-select v-model="scope.row.deType" size="mini" style="display: inline-block;width: 26px;" :disabled="!hasDataPermission('manage',param.privileges)" @change="saveEdit(scope.row)">
|
||||
<el-option
|
||||
v-for="item in fields"
|
||||
:key="item.value"
|
||||
@ -125,7 +125,8 @@
|
||||
</el-table-column>
|
||||
<el-table-column property="" :label="$t('dataset.operator')">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="small">编辑</el-button>
|
||||
<el-button v-if="scope.row.extField !== 0" :disabled="!hasDataPermission('manage',param.privileges)" type="text" size="mini" @click="editField(scope.row)">{{ $t('dataset.edit') }}</el-button>
|
||||
<el-button v-if="scope.row.extField !== 0" :disabled="!hasDataPermission('manage',param.privileges)" type="text" size="mini" @click="deleteField(scope.row)">{{ $t('dataset.delete') }}</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -135,12 +136,12 @@
|
||||
<el-table :data="tableFields.quotaListData" size="mini">
|
||||
<el-table-column property="checked" :label="$t('dataset.field_check')" width="60">
|
||||
<template slot-scope="scope">
|
||||
<el-checkbox v-model="scope.row.checked" :disabled="!hasDataPermission('manage',param.privileges)" @change="saveEdit" />
|
||||
<el-checkbox v-model="scope.row.checked" :disabled="!hasDataPermission('manage',param.privileges)" @change="saveEdit(scope.row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column property="name" :label="$t('dataset.field_name')" width="180">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.name" size="mini" :disabled="!hasDataPermission('manage',param.privileges)" @blur="saveEdit" @keyup.enter.native="saveEdit" />
|
||||
<el-input v-model="scope.row.name" size="mini" :disabled="!hasDataPermission('manage',param.privileges)" @blur="saveEdit(scope.row)" @keyup.enter.native="saveEdit(scope.row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="!(param.mode === 0 && param.type === 'custom')" property="originName" :label="$t('dataset.field_origin_name')" width="100">
|
||||
@ -152,7 +153,7 @@
|
||||
</el-table-column>
|
||||
<el-table-column property="deType" :label="$t('dataset.field_type')" width="140">
|
||||
<template slot-scope="scope">
|
||||
<el-select v-model="scope.row.deType" size="mini" style="display: inline-block;width: 26px;" :disabled="!hasDataPermission('manage',param.privileges)" @change="saveEdit">
|
||||
<el-select v-model="scope.row.deType" size="mini" style="display: inline-block;width: 26px;" :disabled="!hasDataPermission('manage',param.privileges)" @change="saveEdit(scope.row)">
|
||||
<el-option
|
||||
v-for="item in fields"
|
||||
:key="item.value"
|
||||
@ -227,7 +228,8 @@
|
||||
</el-table-column>
|
||||
<el-table-column property="" :label="$t('dataset.operator')">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="small">编辑</el-button>
|
||||
<el-button v-if="scope.row.extField !== 0" :disabled="!hasDataPermission('manage',param.privileges)" type="text" size="mini" @click="editField(scope.row)">{{ $t('dataset.edit') }}</el-button>
|
||||
<el-button v-if="scope.row.extField !== 0" :disabled="!hasDataPermission('manage',param.privileges)" type="text" size="mini" @click="deleteField(scope.row)">{{ $t('dataset.delete') }}</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -240,20 +242,16 @@
|
||||
:show-close="false"
|
||||
class="dialog-css"
|
||||
:destroy-on-close="true"
|
||||
:title="$t('dataset.add_calc_field')"
|
||||
:title="currEditField.id?$t('dataset.edit_calc_field'):$t('dataset.add_calc_field')"
|
||||
append-to-body
|
||||
>
|
||||
<calc-field-edit :param="param" :table-fields="tableFields" />
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button size="mini" @click="closeCalcField">{{ $t('chart.cancel') }}</el-button>
|
||||
<el-button type="primary" size="mini">{{ $t('chart.confirm') }}</el-button>
|
||||
</div>
|
||||
<calc-field-edit :param="param" :table-fields="tableFields" :field="currEditField" @onEditClose="closeCalcField" />
|
||||
</el-dialog>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { batchEdit, fieldListDQ } from '@/api/dataset/dataset'
|
||||
import { post, fieldListDQ } from '@/api/dataset/dataset'
|
||||
import CalcFieldEdit from './CalcFieldEdit'
|
||||
export default {
|
||||
name: 'FieldEdit',
|
||||
@ -282,7 +280,8 @@ export default {
|
||||
],
|
||||
fieldActiveNames: ['d', 'q'],
|
||||
searchField: '',
|
||||
editCalcField: false
|
||||
editCalcField: false,
|
||||
currEditField: {}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@ -316,11 +315,15 @@ export default {
|
||||
this.filterField(this.searchField)
|
||||
})
|
||||
},
|
||||
saveEdit() {
|
||||
saveEdit(item) {
|
||||
// console.log(this.tableFields)
|
||||
const list = this.tableFields.dimensionListData.concat(this.tableFields.quotaListData)
|
||||
batchEdit(list).then(response => {
|
||||
// this.closeEdit()
|
||||
// const list = this.tableFields.dimensionListData.concat(this.tableFields.quotaListData)
|
||||
// batchEdit(list).then(response => {
|
||||
// // this.closeEdit()
|
||||
// this.initField()
|
||||
// })
|
||||
|
||||
post('/dataset/field/save', item).then(response => {
|
||||
this.initField()
|
||||
})
|
||||
},
|
||||
@ -331,15 +334,17 @@ export default {
|
||||
} else if (val === 'q') {
|
||||
item.groupType = 'd'
|
||||
}
|
||||
this.saveEdit()
|
||||
this.saveEdit(item)
|
||||
},
|
||||
|
||||
addCalcField() {
|
||||
this.currEditField = {}
|
||||
this.editCalcField = true
|
||||
},
|
||||
|
||||
closeCalcField() {
|
||||
this.editCalcField = false
|
||||
this.initField()
|
||||
},
|
||||
|
||||
filterField(val) {
|
||||
@ -350,6 +355,29 @@ export default {
|
||||
this.tableFields.dimensionListData = JSON.parse(JSON.stringify(this.tableFields.dimensionList))
|
||||
this.tableFields.quotaListData = JSON.parse(JSON.stringify(this.tableFields.quotaList))
|
||||
}
|
||||
},
|
||||
|
||||
editField(item) {
|
||||
this.currEditField = item
|
||||
this.editCalcField = true
|
||||
},
|
||||
|
||||
deleteField(item) {
|
||||
this.$confirm(this.$t('dataset.confirm_delete'), this.$t('chart.tips'), {
|
||||
confirmButtonText: this.$t('dataset.confirm'),
|
||||
cancelButtonText: this.$t('dataset.cancel'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
post('/dataset/field/delete/' + item.id, null).then(response => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: this.$t('chart.delete_success'),
|
||||
showClose: true
|
||||
})
|
||||
this.initField()
|
||||
})
|
||||
}).catch(() => {
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -401,7 +429,4 @@ export default {
|
||||
.dialog-css>>>.el-dialog{
|
||||
width: 800px!important;
|
||||
}
|
||||
.dialog-css>>>.el-dialog__footer{
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
</style>
|
||||
|
Loading…
Reference in New Issue
Block a user