w-vue-middle
Version:
统一公共服务组件
768 lines (758 loc) • 14.1 kB
JavaScript
/*
* @Author: Jason Liu
* @Date: 2023-07-27 16:12:54
* @Desc:
*/
export function getSymbolsData(e) {
if (e == 'value') {
return {
id: `${new Date().getTime()}`,
type: 'value', //节点类型 字段:column 操作符:symbol 数值:value 函数:fun
data: undefined,
fieldType: 'S', //S:字符 SS:字符数组 N:数字 NS:数字数组 DT:时间
};
} else if (e == 'order') {
return {
id: `${new Date().getTime()}`,
type: 'symbol', //节点类型 字段:column 操作符:symbol 数值:value 函数:fun
data: 'Order By',
};
} else if (e == 'sort') {
return {
id: `${new Date().getTime()}`,
type: 'sort', //节点类型 字段:column 操作符:symbol 数值:value 函数:fun
data: 'DESC',
};
} else {
let options = undefined;
switch (e) {
case 'in':
options = [
{
id: `${new Date().getTime()}1`,
type: 'symbol', //节点类型 字段:column 操作符:symbol 数值:value 函数:fun
data: '(',
options: undefined,
},
{
id: `${new Date().getTime()}2`,
type: 'value', //节点类型 字段:column 操作符:symbol 数值:value 函数:fun
data: undefined,
fieldType: 'string',
},
{
id: `${new Date().getTime()}3`,
type: 'symbol', //节点类型 字段:column 操作符:symbol 数值:value 函数:fun
data: ')',
options: undefined,
},
];
break;
case '(':
options = [
{
id: `${new Date().getTime()}1`,
type: 'symbol', //节点类型 字段:column 操作符:symbol 数值:value 函数:fun
data: ')',
options: undefined,
},
];
break;
}
return {
id: `${new Date().getTime()}`,
type: 'symbol', //节点类型 字段:column 操作符:symbol 数值:value 函数:fun
data: e,
options: options,
};
}
}
/**
* @Author: Jason Liu
* @description: 获取函数项
*/
export function getFunctionData(row) {
return {
id: `${new Date().getTime()}`,
type: 'fun', //节点类型 字段:column 操作符:symbol 数值:value 函数:fun
name: row.name,
use: row.use,
desc: row.desc,
isGroup: row.isGroup,
options: row.options.map((item, i) => {
return {
id: `${new Date().getTime()}${i}`,
type: item.type, //节点类型 字段:column 操作符:symbol 数值:value 函数:fun
data: item.data,
options: undefined,
};
}),
};
}
/**
* @Author: Jason Liu
* @description: 获取函数项
*/
export function getColumnData(row) {
const {
tableName,
parentId,
code,
name,
columnName,
position,
defaultValue,
dataElementCode,
valueDomainCode,
dataSystemCode,
} = row;
return {
id: `${new Date().getTime()}`,
type: 'column', //节点类型 字段:column 操作符:symbol 数值:value 函数:fun
tableId: parentId, //表格ID
tableName,
parentId,
code,
name,
columnName,
position,
defaultValue,
dataElementCode,
valueDomainCode,
dataSystemCode,
};
}
/**
* @Author: Jason Liu
* @description: 获取函数项
*/
export function getTableData(row) {
return {
...row,
id: `${new Date().getTime()}`,
type: 'table', //节点类型 字段:column 操作符:symbol 数值:value 函数:fun
columns: undefined,
children: undefined,
_X_ROW_KEY: undefined,
};
}
/**
* @Author: Jason Liu
* @description: 可视化参数
*/
export const symbols = [
',',
'+',
'-',
'*',
'/',
'=',
'!=',
'>',
'<',
'>=',
'<=',
'(',
')',
'in',
'and',
'or',
'value',
];
/**
* @Author: Jason Liu
* @description: 内置参数
*/
export const builts = [
'like',
'as',
'order',
'sort',
'between',
'case',
'when',
'then',
'else',
'end',
'join',
'left join',
'right join',
'inner join',
'on',
'union',
'union all',
'null',
'isnull',
'notnull',
'select',
'from',
'where',
];
export const functionList = [
{
name: 'CONCAT',
use: 'CONCAT(x,y)',
desc: $t('连接字符串X和Y'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ',',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'INSERT',
use: 'INSERT(x,y,len,z)',
desc: $t('从X中查找str,可以指定从start开始,也可以指定从n开始'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ',',
},
{
type: 'symbol',
data: ',',
},
{
type: 'symbol',
data: ',',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'LENGTH',
use: 'LENGTH(X)',
desc: $t('返回X的长度'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'LOWER',
use: 'LOWER(x)',
desc: $t('X转换成小写'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'UPPER',
use: 'UPPER(x)',
desc: $t('X转换成大写'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'LTRIM',
use: 'LTRIM(x)',
desc: $t('把X的左边截去trim_str字符串,缺省截去空格'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'RTRIM',
use: 'RTRIM(x)',
desc: $t('把X的右边截去trim_str字符串,缺省截去空格'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'TRIM',
use: 'TRIM(x)',
desc: $t('把X的两边截去trim_str字符串,缺省截去空格'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'REPLACE',
use: 'REPLACE(x,old,new)',
desc: $t('在X中查找old,并替换成new'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ',',
},
{
type: 'symbol',
data: ',',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'SUBSTR',
use: 'SUBSTR(x,n,len)',
desc: $t('返回X的字串,从start处开始,截取length个字符,缺省length,默认到结尾'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ',',
},
{
type: 'symbol',
data: ',',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'ABS',
use: 'ABS(x)',
desc: $t('X的绝对值'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'ACOS',
use: 'ACOS(x)',
desc: $t('X的反余弦'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'COS',
use: 'COS(x)',
desc: $t('余弦'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'CEIL',
use: 'CEIL(x)',
desc: $t('大于或等于X的最小值'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'FLOOR',
use: 'FLOOR(x)',
desc: $t('小于或等于X的最大值'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'LOG',
use: 'LOG(x,y)',
desc: $t('X为底Y的对数'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ',',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'MOD',
use: 'MOD(x,y)',
desc: $t('X除以Y的余数'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ',',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'ROUND',
use: 'ROUND(x[,y])',
desc: $t('X在第Y位四舍五入'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ',',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'SQRT',
use: 'SQRT(x)',
desc: $t('X的平方根'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ',',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'TRUNC',
use: 'TRUNC(x[,y])',
desc: $t('X在第Y位截断'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'AVG',
use: 'AVG(x)',
desc: $t('取平均值'),
isGroup: true,
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'SUM',
use: 'SUM(x)',
desc: $t('求和'),
isGroup: true,
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'MIN',
use: 'MIN(x)',
desc: $t('最小值'),
isGroup: true,
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'COUNT',
use: 'COUNT(x)',
desc: $t('数据统计'),
isGroup: true,
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'MAX',
use: 'MAX(x)',
desc: $t('最大值'),
isGroup: true,
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'NOW',
use: 'NOW()',
desc: $t('当前日期'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'ROW_NUMBER',
use: 'ROW_NUMBER()',
desc: $t('生成一个独表,序号以每个分区的第一行开头'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ')',
},
{
type: 'symbol',
data: 'over',
},
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: 'Partition By',
},
{
type: 'symbol',
data: 'Order By',
},
{
type: 'sort',
data: 'DESC',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'DATE_FORMAT',
use: 'DATE_FORMAT(timestamp, string)',
desc: $t('日期转字符串'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ',',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'TO_DATE',
use: 'TO_DATE(string1, string2)',
desc: $t('字符串转日期'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ',',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'TIMESTAMPDIFF',
use: 'TIMESTAMPDIFF(timepointunit, timepoint1,timepoint2)',
desc: $t('字符串转日期'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ',',
},
{
type: 'symbol',
data: ',',
},
{
type: 'symbol',
data: ')',
},
],
},
{
name: 'COALESCE',
use: 'COALESCE(expression,value1,value2……,valuen)',
desc: $t('进行空值处理'),
options: [
{
type: 'symbol',
data: '(',
},
{
type: 'symbol',
data: ',',
},
{
type: 'symbol',
data: ',',
},
{
type: 'symbol',
data: ')',
},
],
},
];