@gingkoo/pandora-metabase 1.0.0-alpha.9 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/lib/es/components/dialog/select-summarize/index.d.ts +2 -1
- package/lib/es/index.js +576 -308
- package/lib/es/index.js.map +1 -1
- package/lib/es/store/types.d.ts +6 -3
- package/lib/es/types.d.ts +3 -0
- package/lib/es/utils/helper-dom.d.ts +0 -1
- package/lib/es/utils.d.ts +3 -2
- package/package.json +4 -4
package/lib/es/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @gingkoo/pandora-metabase v1.0.
|
|
2
|
+
* @gingkoo/pandora-metabase v1.0.1
|
|
3
3
|
*/
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import React__default, { useContext, createContext, useState, useRef, useMemo, useEffect, forwardRef, useImperativeHandle } from 'react';
|
|
7
7
|
import cloneDeep from 'lodash/cloneDeep';
|
|
8
8
|
import cx from 'classnames';
|
|
9
|
-
import { Tooltip, Button, Modal, Input, DatePicker, Dropdown, InputNumber, Select,
|
|
9
|
+
import { Tooltip, Button, Modal, Input, DatePicker, Dropdown, InputNumber, Select, Toast, Modal2 } from '@gingkoo/pandora';
|
|
10
10
|
import Styled from 'styled-components';
|
|
11
|
+
import { ChevronODown, Repeat, Function, RelatedWork, FfPlus, FfLine } from '@gingkoo/pandora-icons';
|
|
12
|
+
import isEqual from 'lodash/isEqual';
|
|
11
13
|
import 'underscore';
|
|
12
14
|
import ReactDOM from 'react-dom';
|
|
13
15
|
import ReactDOMServer from 'react-dom/server';
|
|
14
|
-
import { ChevronODown, Repeat, Function, RelatedWork, FfPlus, FfLine } from '@gingkoo/pandora-icons';
|
|
15
16
|
import moment from 'dayjs';
|
|
16
|
-
import isEqual from 'lodash/isEqual';
|
|
17
17
|
|
|
18
18
|
// 创建 Context
|
|
19
19
|
const Context = /*#__PURE__*/createContext({});
|
|
@@ -154,6 +154,36 @@ var EleComponentEnum;
|
|
|
154
154
|
EleComponentEnum["select"] = "select";
|
|
155
155
|
})(EleComponentEnum || (EleComponentEnum = {}));
|
|
156
156
|
|
|
157
|
+
//获取指定名称的cookie值
|
|
158
|
+
function getCookie(name) {
|
|
159
|
+
// (^| )name=([^;]*)(;|$),match[0]为与整个正则表达式匹配的字符串,match[i]为正则表达式捕获数组相匹配的数组;
|
|
160
|
+
var arr = document.cookie.match(new RegExp('(^| )' + name + '=([^;]*)(;|$)'));
|
|
161
|
+
if (arr != null) {
|
|
162
|
+
console.log(arr);
|
|
163
|
+
return arr[2];
|
|
164
|
+
}
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const locales = {};
|
|
169
|
+
const activeLocale = getCookie('LOCALE') || 'zh';
|
|
170
|
+
const isEn = activeLocale === 'en';
|
|
171
|
+
const register = (name, data) => {
|
|
172
|
+
if (name in locales) {
|
|
173
|
+
console.warn(`[i18n] ${name} has been registered`);
|
|
174
|
+
} else {
|
|
175
|
+
locales[name] = data;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
const __ = name => {
|
|
179
|
+
if (activeLocale in locales) {
|
|
180
|
+
return locales[activeLocale][name] || '';
|
|
181
|
+
} else {
|
|
182
|
+
console.warn(`[i18n] locale not found`);
|
|
183
|
+
return '';
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
157
187
|
// import { SummarizeAlias } from './index';
|
|
158
188
|
const SummarizeAlias$1 = 'source';
|
|
159
189
|
const NUMBER_GROUP$1 = [SQL_COLUMN_TYPE.FLOAT, SQL_COLUMN_TYPE.LONG, SQL_COLUMN_TYPE.CURRENCY];
|
|
@@ -340,7 +370,8 @@ const summarizeToSql = (arr, record) => {
|
|
|
340
370
|
});
|
|
341
371
|
as = as + (count ? '_' + (count + 1) : '');
|
|
342
372
|
return {
|
|
343
|
-
sql: sql
|
|
373
|
+
sql: sql,
|
|
374
|
+
// + ' AS ' + as,
|
|
344
375
|
fieldAlias: as
|
|
345
376
|
};
|
|
346
377
|
};
|
|
@@ -648,7 +679,9 @@ const getSubColumns = metaList => {
|
|
|
648
679
|
return {
|
|
649
680
|
name_zh: v.quotes,
|
|
650
681
|
...v,
|
|
651
|
-
name: v.fieldAlias,
|
|
682
|
+
name: v.fieldAlias || v.name,
|
|
683
|
+
fieldAlias: '',
|
|
684
|
+
// fieldUuid: uuidv4('field'),
|
|
652
685
|
realName: v.sql?.split(' AS ')?.[1] || '',
|
|
653
686
|
// name_zh: '',
|
|
654
687
|
database_type: v?.database_type || SQL_COLUMN_TYPE.FLOAT,
|
|
@@ -662,7 +695,9 @@ const getSubColumns = metaList => {
|
|
|
662
695
|
return {
|
|
663
696
|
name_zh: v.quotes,
|
|
664
697
|
...v,
|
|
665
|
-
name: v.fieldAlias,
|
|
698
|
+
name: v.fieldAlias || v.name,
|
|
699
|
+
fieldAlias: '',
|
|
700
|
+
// fieldUuid: uuidv4('field'),
|
|
666
701
|
realName: v.sql?.split(' AS ')?.[1] || '',
|
|
667
702
|
// name_zh: '',
|
|
668
703
|
database_type: v?.database_type || SQL_COLUMN_TYPE.FLOAT,
|
|
@@ -679,10 +714,18 @@ const getSubColumns = metaList => {
|
|
|
679
714
|
data = data.concat(
|
|
680
715
|
// @ts-ignore
|
|
681
716
|
joinData.map(v => {
|
|
717
|
+
const columns = v.columns.map(column => {
|
|
718
|
+
return {
|
|
719
|
+
...column,
|
|
720
|
+
name: column.fieldAlias || column.name,
|
|
721
|
+
fieldAlias: ''
|
|
722
|
+
// fieldUuid: uuidv4('field'),
|
|
723
|
+
};
|
|
724
|
+
});
|
|
682
725
|
return {
|
|
683
726
|
alias: v.table2.alias,
|
|
684
727
|
table: v.table2.name,
|
|
685
|
-
columns:
|
|
728
|
+
columns: columns
|
|
686
729
|
};
|
|
687
730
|
}));
|
|
688
731
|
}
|
|
@@ -690,16 +733,51 @@ const getSubColumns = metaList => {
|
|
|
690
733
|
// @ts-ignore
|
|
691
734
|
data = metaList.slice().map(v => {
|
|
692
735
|
if (v.type === TypeEnum.data) {
|
|
736
|
+
const columns = v.columns.map(column => {
|
|
737
|
+
return {
|
|
738
|
+
...column,
|
|
739
|
+
name: column.fieldAlias || column.name,
|
|
740
|
+
fieldAlias: ''
|
|
741
|
+
// fieldUuid: uuidv4('field'),
|
|
742
|
+
};
|
|
743
|
+
}).filter(item => item.select);
|
|
693
744
|
return {
|
|
694
745
|
alias: v.table.alias,
|
|
695
746
|
table: v.table.name,
|
|
696
|
-
columns:
|
|
747
|
+
columns: columns
|
|
697
748
|
};
|
|
698
749
|
} else if (v.type === TypeEnum.joinData) {
|
|
750
|
+
const columns = v.columns.map(column => {
|
|
751
|
+
return {
|
|
752
|
+
...column,
|
|
753
|
+
name: column.fieldAlias || column.name,
|
|
754
|
+
fieldAlias: ''
|
|
755
|
+
// fieldUuid: uuidv4('field'),
|
|
756
|
+
};
|
|
757
|
+
}).filter(item => item.select);
|
|
699
758
|
return {
|
|
700
759
|
alias: v.table2.alias,
|
|
701
760
|
table: v.table2.name,
|
|
702
|
-
columns:
|
|
761
|
+
columns: columns
|
|
762
|
+
};
|
|
763
|
+
} else if (v.type === TypeEnum.customColumn) {
|
|
764
|
+
const {
|
|
765
|
+
customColumn
|
|
766
|
+
} = v;
|
|
767
|
+
const columns = customColumn.map(v => {
|
|
768
|
+
return {
|
|
769
|
+
database_type: SQL_COLUMN_TYPE.STRING,
|
|
770
|
+
name_zh: v.name,
|
|
771
|
+
name: v.name,
|
|
772
|
+
select: true,
|
|
773
|
+
fieldAlias: ''
|
|
774
|
+
// fieldUuid: uuidv4('field'),
|
|
775
|
+
};
|
|
776
|
+
});
|
|
777
|
+
return {
|
|
778
|
+
columns: columns,
|
|
779
|
+
alias: '',
|
|
780
|
+
table: __('SqlQueryBuilder.customColumn')
|
|
703
781
|
};
|
|
704
782
|
} else {
|
|
705
783
|
return {
|
|
@@ -724,8 +802,12 @@ const changeTableAlias = (list, curObj) => {
|
|
|
724
802
|
alias
|
|
725
803
|
} = cloneDeep(curObj);
|
|
726
804
|
const newList = cloneDeep(list);
|
|
727
|
-
newList
|
|
728
|
-
if (v.type === TypeEnum.data)
|
|
805
|
+
return newList?.map(v => {
|
|
806
|
+
if (v.type === TypeEnum.data) {
|
|
807
|
+
if (v.table.tableUuid === tableUuid) {
|
|
808
|
+
v.table.alias = alias;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
729
811
|
if (v.type === TypeEnum.joinData) {
|
|
730
812
|
if (v.table1.tableUuid === tableUuid) {
|
|
731
813
|
v.table1.alias = alias;
|
|
@@ -769,7 +851,7 @@ const changeTableAlias = (list, curObj) => {
|
|
|
769
851
|
v.by.map(by => {
|
|
770
852
|
if (by.tableUuid === tableUuid) {
|
|
771
853
|
by.alias = alias;
|
|
772
|
-
by.sql = `${by.alias}.${by.realName || by.name}
|
|
854
|
+
by.sql = `${by.alias}.${by.realName || by.name}`;
|
|
773
855
|
}
|
|
774
856
|
});
|
|
775
857
|
}
|
|
@@ -809,12 +891,21 @@ const changeTableAlias = (list, curObj) => {
|
|
|
809
891
|
// }
|
|
810
892
|
// }
|
|
811
893
|
item.table2.alias = alias;
|
|
812
|
-
item.table2.sql = '';
|
|
894
|
+
// item.table2.sql = '';
|
|
813
895
|
}
|
|
896
|
+
// if (item.subquery) {
|
|
897
|
+
// item.subquery = changeTableAlias(item.subquery || [], curObj);
|
|
898
|
+
// }
|
|
814
899
|
});
|
|
815
900
|
}
|
|
816
|
-
|
|
817
|
-
|
|
901
|
+
// if ((v as MetaData | MetaJoin).subquery) {
|
|
902
|
+
// (v as MetaData | MetaJoin).subquery = changeTableAlias(
|
|
903
|
+
// (v as MetaData | MetaJoin).subquery || [],
|
|
904
|
+
// curObj,
|
|
905
|
+
// );
|
|
906
|
+
// }
|
|
907
|
+
return v;
|
|
908
|
+
}) || [];
|
|
818
909
|
};
|
|
819
910
|
const changeFieldAlias = (list, curObj) => {
|
|
820
911
|
const {
|
|
@@ -822,7 +913,7 @@ const changeFieldAlias = (list, curObj) => {
|
|
|
822
913
|
fieldAlias
|
|
823
914
|
} = cloneDeep(curObj);
|
|
824
915
|
const newList = cloneDeep(list);
|
|
825
|
-
newList
|
|
916
|
+
return newList?.map(v => {
|
|
826
917
|
if (v.type === TypeEnum.data) ;
|
|
827
918
|
if (v.type === TypeEnum.joinData) {
|
|
828
919
|
if (v.table1.fieldUuid === fieldUuid) {
|
|
@@ -879,7 +970,7 @@ const changeFieldAlias = (list, curObj) => {
|
|
|
879
970
|
v.by.map(by => {
|
|
880
971
|
if (by.fieldUuid === fieldUuid) {
|
|
881
972
|
by.fieldAlias = fieldAlias;
|
|
882
|
-
by.sql = `${by.alias}.${by.realName || by.name}
|
|
973
|
+
by.sql = `${by.alias}.${by.realName || by.name}`;
|
|
883
974
|
}
|
|
884
975
|
});
|
|
885
976
|
}
|
|
@@ -893,9 +984,9 @@ const changeFieldAlias = (list, curObj) => {
|
|
|
893
984
|
prevGroupBy
|
|
894
985
|
} = getHelper(list, v);
|
|
895
986
|
let groupBy = prevGroupBy?.by.filter(v => v.fieldUuid === item.fieldUuid)[0] || prevGroupBy?.group.filter(v => v.fieldUuid === item.fieldUuid)[0] || null;
|
|
896
|
-
groupBy.fieldAlias = fieldAlias;
|
|
897
|
-
const sql = groupBy.sql;
|
|
898
987
|
if (groupBy) {
|
|
988
|
+
groupBy.fieldAlias = fieldAlias;
|
|
989
|
+
const sql = groupBy.sql;
|
|
899
990
|
item.sql = sql;
|
|
900
991
|
item.groupSql = sql;
|
|
901
992
|
}
|
|
@@ -918,12 +1009,18 @@ const changeFieldAlias = (list, curObj) => {
|
|
|
918
1009
|
// }
|
|
919
1010
|
// }
|
|
920
1011
|
}
|
|
1012
|
+
if (item.notExists) {
|
|
1013
|
+
item.notExists = changeFieldAlias(item.notExists || [], curObj);
|
|
1014
|
+
}
|
|
921
1015
|
});
|
|
922
1016
|
}
|
|
923
|
-
|
|
924
|
-
|
|
1017
|
+
return {
|
|
1018
|
+
...v
|
|
1019
|
+
};
|
|
1020
|
+
}) || [];
|
|
925
1021
|
};
|
|
926
1022
|
function splitByUnion(data) {
|
|
1023
|
+
if (!data) return [];
|
|
927
1024
|
const original = cloneDeep(data);
|
|
928
1025
|
const result = [];
|
|
929
1026
|
let i = 0;
|
|
@@ -959,7 +1056,8 @@ function splitByUnion(data) {
|
|
|
959
1056
|
}
|
|
960
1057
|
return result;
|
|
961
1058
|
}
|
|
962
|
-
function reassembleByUnion(target) {
|
|
1059
|
+
function reassembleByUnion(target = []) {
|
|
1060
|
+
if (!target) return [];
|
|
963
1061
|
const result = [];
|
|
964
1062
|
let i = 0;
|
|
965
1063
|
const len = target.length;
|
|
@@ -1003,6 +1101,92 @@ function reassembleByUnion(target) {
|
|
|
1003
1101
|
}
|
|
1004
1102
|
return result;
|
|
1005
1103
|
}
|
|
1104
|
+
// export const buildSqlQuery = (data?: MetaListType[]): string => {
|
|
1105
|
+
// if (!data || data.length === 0) return '';
|
|
1106
|
+
// let sqlClauses: string[] = ['not exitis ( '];
|
|
1107
|
+
// data.forEach((item) => {
|
|
1108
|
+
// if (item.type === TypeEnum.data) {
|
|
1109
|
+
// const meta = item as MetaData;
|
|
1110
|
+
// const tableName = meta.table.name;
|
|
1111
|
+
// const alias = meta.table.alias ? `AS ${meta.table.alias}` : '';
|
|
1112
|
+
// const dataSource = meta.table.datasourceName;
|
|
1113
|
+
// sqlClauses.push(`SELECT 1 FROM ${dataSource}.${tableName} ${alias}`);
|
|
1114
|
+
// }
|
|
1115
|
+
// if (item.type === TypeEnum.joinData) {
|
|
1116
|
+
// const meta = item as MetaJoin;
|
|
1117
|
+
// const table1 = meta.table1.alias ? meta.table1.alias : meta.table1.name;
|
|
1118
|
+
// const table2 = `${meta.table2.datasourceName}.${meta.table2.name}`;
|
|
1119
|
+
// const alias2 = meta.table2.alias ? meta.table2.alias : '';
|
|
1120
|
+
// joins.push(`LEFT JOIN ${table2} ${alias2} ON ${table1}.${meta.columns[0]?.name} = ${alias2}.${meta.columns[0]?.name}`);
|
|
1121
|
+
// }
|
|
1122
|
+
// if (item.type === TypeEnum.filter) {
|
|
1123
|
+
// const filterStrings = (item as MetaFilter).filter.map((f) => f.quotes).filter(Boolean); // 排除空条件
|
|
1124
|
+
// if (filterStrings.length > 0) {
|
|
1125
|
+
// sqlClauses.push(`WHERE ${filterStrings.join(' AND ')}`);
|
|
1126
|
+
// }
|
|
1127
|
+
// }
|
|
1128
|
+
// });
|
|
1129
|
+
// // 简单拼接 SQL 片段
|
|
1130
|
+
// return sqlClauses.join(' ') + ' )' + ';';
|
|
1131
|
+
// };
|
|
1132
|
+
const buildSqlQuery = data => {
|
|
1133
|
+
if (!data || data.length === 0) return '';
|
|
1134
|
+
let sqlClauses = ['NOT EXISTS ('];
|
|
1135
|
+
let tables = [];
|
|
1136
|
+
let joins = [];
|
|
1137
|
+
let wheres = [];
|
|
1138
|
+
data.forEach(item => {
|
|
1139
|
+
if (item.type === TypeEnum.data) {
|
|
1140
|
+
const meta = item;
|
|
1141
|
+
const tableName = `${meta.table.name}`;
|
|
1142
|
+
const alias = meta.table.alias ? ` AS ${meta.table.alias}` : '';
|
|
1143
|
+
tables.push(`${tableName}${alias}`);
|
|
1144
|
+
}
|
|
1145
|
+
if (item.type === TypeEnum.joinData) {
|
|
1146
|
+
const meta = item;
|
|
1147
|
+
const table2Name = `${meta.table2.name}`;
|
|
1148
|
+
const alias2 = meta.table2.alias ? ` AS ${meta.table2.alias}` : '';
|
|
1149
|
+
const table2 = `${meta.table2.alias || meta.table2.name}`;
|
|
1150
|
+
const table1 = `${meta.table1.alias || meta.table1.name}`;
|
|
1151
|
+
joins.push(`LEFT JOIN ${table2Name}${alias2} ON ${table1}.${meta.table1.fieldAlias} = ${table2}.${meta.table2.fieldAlias}`);
|
|
1152
|
+
if (Array.isArray(item.expressions) && item.expressions.length > 0) {
|
|
1153
|
+
item.expressions.forEach(expression => {
|
|
1154
|
+
let left = '',
|
|
1155
|
+
right = '';
|
|
1156
|
+
if (expression.left_type === 'field') {
|
|
1157
|
+
left = `${table1}.${expression.left_fieldAlias}`;
|
|
1158
|
+
} else {
|
|
1159
|
+
left = expression.left_string;
|
|
1160
|
+
}
|
|
1161
|
+
if (expression.right_type === 'field') {
|
|
1162
|
+
right = `${table2}.${expression.right_fieldAlias}`;
|
|
1163
|
+
} else {
|
|
1164
|
+
right = expression.right_string;
|
|
1165
|
+
}
|
|
1166
|
+
joins.push(`AND ${left} = ${right}`);
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
if (item.type === TypeEnum.filter) {
|
|
1171
|
+
const filterStrings = item.filter.map(f => f.quotes).filter(Boolean);
|
|
1172
|
+
if (filterStrings.length > 0) {
|
|
1173
|
+
wheres.push(...filterStrings);
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
});
|
|
1177
|
+
// 构建子查询
|
|
1178
|
+
if (tables.length > 0) {
|
|
1179
|
+
sqlClauses.push(`SELECT 1 FROM ${tables[0]}`);
|
|
1180
|
+
if (joins.length > 0) {
|
|
1181
|
+
sqlClauses.push(joins.join(' '));
|
|
1182
|
+
}
|
|
1183
|
+
if (wheres.length > 0) {
|
|
1184
|
+
sqlClauses.push(`WHERE ${wheres.join(' AND ')}`);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
sqlClauses.push(')');
|
|
1188
|
+
return sqlClauses.join(' ') + ';';
|
|
1189
|
+
};
|
|
1006
1190
|
|
|
1007
1191
|
let metaKey = 1;
|
|
1008
1192
|
const SummarizeAlias = 'source';
|
|
@@ -1040,6 +1224,7 @@ const useStore = () => {
|
|
|
1040
1224
|
const [tableNameTpl, setTableNameTpl] = useState('${name}'); //显示字段
|
|
1041
1225
|
const [sourceList, setSourceList] = useState([]); //数据源列表
|
|
1042
1226
|
const [constantList, setConstantList] = useState([]); //常量列表
|
|
1227
|
+
const [ignoreGroupByType, setIgnoreGroupByType] = useState(false); // 忽略groupBy类型
|
|
1043
1228
|
const [_cacheSource2TableMap, set_cacheSource2TableMap] = useState({}); //数据源id 对应数据集列表
|
|
1044
1229
|
const [_cacheColumnsMap, set_cacheColumnsMap] = useState({}); //数据源id 对应数据集列表
|
|
1045
1230
|
const [metaList, _setMeta] = useState(defaultMeta); //数据源id 对应数据集列表
|
|
@@ -1074,7 +1259,7 @@ const useStore = () => {
|
|
|
1074
1259
|
};
|
|
1075
1260
|
// 是否显示主表后面的字段按钮 (如果下面 没有聚合,或者选了聚合但是聚合里面没有选值的时候显示 主表字段按钮)
|
|
1076
1261
|
const showMainColumn = useMemo(() => {
|
|
1077
|
-
return metaList
|
|
1262
|
+
return metaList?.map((item, groupIndex) => {
|
|
1078
1263
|
// 过滤出所有汇总类型的项
|
|
1079
1264
|
const summarizeItems = item.list.filter(v => v.type === TypeEnum.summarize);
|
|
1080
1265
|
// 如果没有汇总项,默认显示主列
|
|
@@ -1129,7 +1314,7 @@ const useStore = () => {
|
|
|
1129
1314
|
columns = await fetchColumnsFn.current(extra, datasourceId);
|
|
1130
1315
|
setColumns(tableName, columns);
|
|
1131
1316
|
}
|
|
1132
|
-
const _columns = columns
|
|
1317
|
+
const _columns = columns?.map(v => {
|
|
1133
1318
|
return {
|
|
1134
1319
|
...v,
|
|
1135
1320
|
fieldUuid: v.fieldAlias || uuidv4('field')
|
|
@@ -1143,21 +1328,56 @@ const useStore = () => {
|
|
|
1143
1328
|
_setMeta(newMeta);
|
|
1144
1329
|
};
|
|
1145
1330
|
// 回显
|
|
1146
|
-
|
|
1331
|
+
// 设置column
|
|
1332
|
+
const setQuotes = newMeta => {
|
|
1333
|
+
newMeta.table1 = {
|
|
1334
|
+
...newMeta.table1,
|
|
1335
|
+
fieldAlias: newMeta.table1.fieldAlias || newMeta.table1.column,
|
|
1336
|
+
fieldUuid: newMeta.table1.fieldUuid || uuidv4('field'),
|
|
1337
|
+
quotes: newMeta.table1.quotes || newMeta.table1.column,
|
|
1338
|
+
tableUuid: newMeta.table1.tableUuid || uuidv4('table')
|
|
1339
|
+
};
|
|
1340
|
+
newMeta.table2 = {
|
|
1341
|
+
...newMeta.table2,
|
|
1342
|
+
fieldAlias: newMeta.table2.fieldAlias || newMeta.table2.column,
|
|
1343
|
+
fieldUuid: newMeta.table2.fieldUuid || uuidv4('field'),
|
|
1344
|
+
quotes: newMeta.table2.quotes || newMeta.table2.column,
|
|
1345
|
+
tableUuid: newMeta.table2.tableUuid || uuidv4('table')
|
|
1346
|
+
};
|
|
1347
|
+
newMeta.expressions = newMeta.expressions?.map(v => {
|
|
1348
|
+
return {
|
|
1349
|
+
...v,
|
|
1350
|
+
left_fieldAlias: v.left_fieldAlias || v.left_column,
|
|
1351
|
+
left_fieldUuid: v.left_fieldUuid || uuidv4('field'),
|
|
1352
|
+
left_quotes: v.left_quotes || v.left_column,
|
|
1353
|
+
right_fieldAlias: v.right_fieldAlias || v.right_column,
|
|
1354
|
+
right_fieldUuid: v.right_fieldUuid || uuidv4('field'),
|
|
1355
|
+
right_quotes: v.right_quotes || v.right_column
|
|
1356
|
+
};
|
|
1357
|
+
});
|
|
1358
|
+
return newMeta;
|
|
1359
|
+
};
|
|
1360
|
+
const setPreData = data => {
|
|
1147
1361
|
if (data.length) {
|
|
1148
|
-
let _metaList = data
|
|
1362
|
+
let _metaList = data?.map((item, groupIndex) => {
|
|
1149
1363
|
let newList = item.list?.map((v, i) => {
|
|
1150
|
-
let newMeta =
|
|
1364
|
+
let newMeta = item.list;
|
|
1365
|
+
if (v.table) {
|
|
1366
|
+
v.table.tableUuid = v.table.tableUuid || uuidv4('table');
|
|
1367
|
+
}
|
|
1368
|
+
if (v.type === TypeEnum.joinData) {
|
|
1369
|
+
newMeta[i] = setQuotes(newMeta[i]);
|
|
1370
|
+
}
|
|
1151
1371
|
// 设置右侧column
|
|
1152
1372
|
if (v.table2?.datasourceId && v.columns.length < 1) {
|
|
1153
|
-
fetchColumns(newMeta[i].table2, newMeta[i].table2.datasourceId, columns => {
|
|
1373
|
+
fetchColumns(newMeta[i].table2, newMeta[i].table2.datasourceId, (columns = []) => {
|
|
1154
1374
|
if (v.isSubquery) {
|
|
1155
1375
|
let newColumns = [];
|
|
1156
1376
|
const items = getSubColumns(v.subquery);
|
|
1157
|
-
newColumns = items
|
|
1158
|
-
newMeta[i].columns = newColumns;
|
|
1377
|
+
newColumns = items?.flatMap(item => item.columns);
|
|
1378
|
+
newMeta[i].columns = newColumns || [];
|
|
1159
1379
|
} else {
|
|
1160
|
-
newMeta[i].columns = columns;
|
|
1380
|
+
newMeta[i].columns = columns || [];
|
|
1161
1381
|
}
|
|
1162
1382
|
setMeta(newMeta, groupIndex);
|
|
1163
1383
|
});
|
|
@@ -1167,15 +1387,18 @@ const useStore = () => {
|
|
|
1167
1387
|
}
|
|
1168
1388
|
// 设置column
|
|
1169
1389
|
if (v.table?.datasourceId && v.columns.length < 1) {
|
|
1170
|
-
fetchColumns(newMeta[i].table, newMeta[i].table.datasourceId, columns => {
|
|
1390
|
+
fetchColumns(newMeta[i].table, newMeta[i].table.datasourceId, (columns = []) => {
|
|
1171
1391
|
if (v.isSubquery) {
|
|
1172
1392
|
let newColumns = [];
|
|
1173
1393
|
const items = getSubColumns(v.subquery);
|
|
1174
1394
|
newColumns = items.flatMap(item => item.columns);
|
|
1175
|
-
newMeta[i].columns = newColumns;
|
|
1395
|
+
newMeta[i].columns = newColumns || [];
|
|
1176
1396
|
} else {
|
|
1177
|
-
newMeta[i].columns = columns;
|
|
1397
|
+
newMeta[i].columns = columns || [];
|
|
1178
1398
|
}
|
|
1399
|
+
// if (v.type === TypeEnum.joinData) {
|
|
1400
|
+
// newMeta[i] = setQuotes(newMeta[i]);
|
|
1401
|
+
// }
|
|
1179
1402
|
setMeta(newMeta, groupIndex);
|
|
1180
1403
|
});
|
|
1181
1404
|
return {
|
|
@@ -1349,7 +1572,7 @@ const useStore = () => {
|
|
|
1349
1572
|
setMeta(_metaList, groupIndex);
|
|
1350
1573
|
};
|
|
1351
1574
|
const setColumns = (tableId, columns) => {
|
|
1352
|
-
const _columns = columns
|
|
1575
|
+
const _columns = columns?.map(v => {
|
|
1353
1576
|
return {
|
|
1354
1577
|
...v,
|
|
1355
1578
|
fieldUuid: v.fieldUuid || uuidv4('field')
|
|
@@ -1374,46 +1597,10 @@ const useStore = () => {
|
|
|
1374
1597
|
const getDataset = datasourceId => {
|
|
1375
1598
|
return _cacheSource2TableMap[datasourceId] || [];
|
|
1376
1599
|
};
|
|
1377
|
-
const changeAlias = (groupIndex, alias) => {
|
|
1378
|
-
let newMetaList = metaList.slice();
|
|
1379
|
-
const _list = newMetaList[groupIndex].list;
|
|
1380
|
-
if (_list.length > 0) {
|
|
1381
|
-
_list.forEach(item => {
|
|
1382
|
-
if (item.type === TypeEnum.joinData && item.table2.alias === alias) {
|
|
1383
|
-
item.table2.alias = alias;
|
|
1384
|
-
} else if (item.type === TypeEnum.data && item.table.alias === alias) {
|
|
1385
|
-
item.table.alias = alias;
|
|
1386
|
-
} else if (item.type === TypeEnum.filter) {
|
|
1387
|
-
//过滤器
|
|
1388
|
-
item.filter.forEach(filterItem => {
|
|
1389
|
-
if (filterItem.alias === alias) {
|
|
1390
|
-
filterItem.alias = alias;
|
|
1391
|
-
}
|
|
1392
|
-
});
|
|
1393
|
-
} else if (item.type === TypeEnum.summarize) {
|
|
1394
|
-
// 汇总
|
|
1395
|
-
item.alias = alias;
|
|
1396
|
-
item.by.forEach(byItem => {
|
|
1397
|
-
if (byItem.alias === alias) {
|
|
1398
|
-
byItem.alias = alias;
|
|
1399
|
-
}
|
|
1400
|
-
});
|
|
1401
|
-
item.group.forEach(groupItem => {
|
|
1402
|
-
if (groupItem.alias === alias) {
|
|
1403
|
-
groupItem.alias = alias;
|
|
1404
|
-
groupItem.sql = alias;
|
|
1405
|
-
}
|
|
1406
|
-
});
|
|
1407
|
-
}
|
|
1408
|
-
});
|
|
1409
|
-
newMetaList[groupIndex].list = _list;
|
|
1410
|
-
_setMeta(newMetaList);
|
|
1411
|
-
}
|
|
1412
|
-
};
|
|
1413
1600
|
const reset = () => {
|
|
1414
1601
|
// setSourceList([]);
|
|
1415
1602
|
_setMeta(defaultMeta);
|
|
1416
|
-
setToolbar(defaultToolbar);
|
|
1603
|
+
// setToolbar(defaultToolbar);
|
|
1417
1604
|
set_cacheSource2TableMap({});
|
|
1418
1605
|
set_cacheColumnsMap({});
|
|
1419
1606
|
};
|
|
@@ -1467,41 +1654,12 @@ const useStore = () => {
|
|
|
1467
1654
|
_setShowSubquery,
|
|
1468
1655
|
constantList,
|
|
1469
1656
|
setConstantList,
|
|
1470
|
-
|
|
1471
|
-
|
|
1657
|
+
popupContainer,
|
|
1658
|
+
ignoreGroupByType,
|
|
1659
|
+
setIgnoreGroupByType
|
|
1472
1660
|
};
|
|
1473
1661
|
};
|
|
1474
1662
|
|
|
1475
|
-
//获取指定名称的cookie值
|
|
1476
|
-
function getCookie(name) {
|
|
1477
|
-
// (^| )name=([^;]*)(;|$),match[0]为与整个正则表达式匹配的字符串,match[i]为正则表达式捕获数组相匹配的数组;
|
|
1478
|
-
var arr = document.cookie.match(new RegExp('(^| )' + name + '=([^;]*)(;|$)'));
|
|
1479
|
-
if (arr != null) {
|
|
1480
|
-
console.log(arr);
|
|
1481
|
-
return arr[2];
|
|
1482
|
-
}
|
|
1483
|
-
return null;
|
|
1484
|
-
}
|
|
1485
|
-
|
|
1486
|
-
const locales = {};
|
|
1487
|
-
const activeLocale = getCookie('LOCALE') || 'zh';
|
|
1488
|
-
const isEn = activeLocale === 'en';
|
|
1489
|
-
const register = (name, data) => {
|
|
1490
|
-
if (name in locales) {
|
|
1491
|
-
console.warn(`[i18n] ${name} has been registered`);
|
|
1492
|
-
} else {
|
|
1493
|
-
locales[name] = data;
|
|
1494
|
-
}
|
|
1495
|
-
};
|
|
1496
|
-
const __ = name => {
|
|
1497
|
-
if (activeLocale in locales) {
|
|
1498
|
-
return locales[activeLocale][name] || '';
|
|
1499
|
-
} else {
|
|
1500
|
-
console.warn(`[i18n] locale not found`);
|
|
1501
|
-
return '';
|
|
1502
|
-
}
|
|
1503
|
-
};
|
|
1504
|
-
|
|
1505
1663
|
register('en', {
|
|
1506
1664
|
'data.pleaseSelectDataTable': 'please select data table',
|
|
1507
1665
|
'data.calculatingNow': 'calculating now...',
|
|
@@ -1549,6 +1707,7 @@ register('en', {
|
|
|
1549
1707
|
'SqlQueryBuilder.visualize': 'visualize',
|
|
1550
1708
|
'SqlQueryBuilder.selectColumnAll': 'select all',
|
|
1551
1709
|
'SqlQueryBuilder.alias': 'alias',
|
|
1710
|
+
'SqlQueryBuilder.aliasCannotEmpty': 'Alias cannot be empty',
|
|
1552
1711
|
'customColumn.operator': 'operator',
|
|
1553
1712
|
'customColumn.field': 'field',
|
|
1554
1713
|
'customColumn.constant': 'constant',
|
|
@@ -1693,6 +1852,7 @@ register('zh', {
|
|
|
1693
1852
|
'SqlQueryBuilder.visualize': '可视化',
|
|
1694
1853
|
'SqlQueryBuilder.selectColumnAll': '全选',
|
|
1695
1854
|
'SqlQueryBuilder.alias': '别名',
|
|
1855
|
+
'SqlQueryBuilder.aliasCannotEmpty': '别名不能为空',
|
|
1696
1856
|
'customColumn.operator': '运算符',
|
|
1697
1857
|
'customColumn.field': '字段',
|
|
1698
1858
|
'customColumn.constant': '常量',
|
|
@@ -1838,111 +1998,9 @@ const Loading = ({
|
|
|
1838
1998
|
});
|
|
1839
1999
|
};
|
|
1840
2000
|
|
|
1841
|
-
var css_248z$d = ".mx-4 {\n margin-left: 1rem;\n margin-right: 1rem;\n}\n.m-2 {\n margin: 0.5rem;\n}\n.mx-2 {\n margin-left: 0.5rem;\n margin-right: 0.5rem;\n}\n.ml-2 {\n margin-left: 0.5rem;\n}\n.mt-2 {\n margin-top: 0.5rem;\n}\n.mb-2 {\n margin-bottom: 0.5rem;\n}\n.mt-4 {\n margin-top: 1rem;\n}\n.ml-4 {\n margin-left: 1rem;\n}\n.mr-4 {\n margin-right: 1rem;\n}\n.mr-2 {\n margin-right: 0.5rem;\n}\n.pt-2 {\n padding-top: 0.5rem;\n}\n.pb-2 {\n padding-bottom: 0.5rem;\n}\n.px-2 {\n padding-left: 0.5rem;\n padding-right: 0.5rem;\n}\n.p-4 {\n padding: 1rem;\n}\n.p-2 {\n padding: 0.5rem;\n}\n.px-2 {\n padding-left: 0.5rem;\n padding-right: 0.5rem;\n}\n.pb-4 {\n padding-bottom: 1rem;\n}\n.pt-4 {\n padding-top: 1rem;\n}\n.block {\n display: block;\n}\n.w-full {\n width: 100%;\n}\n.font-bold {\n font-weight: 700;\n}\n.uppercase {\n text-transform: uppercase;\n}\n.tracking-wider {\n letter-spacing: 0.05em;\n}\n.relative {\n position: relative;\n}\n.absolute {\n position: absolute;\n}\n.top-0 {\n top: 0px;\n}\n.left-0 {\n left: 0;\n}\n.rounded-lg {\n border-radius: 0.5rem;\n}\n.text-gray-500 {\n color: #6b7280;\n}\n.flex {\n display: flex;\n}\n.items-center {\n align-items: center;\n}\n.justify-center {\n justify-content: center;\n}\n.visual-box {\n position: relative;\n width: 100%;\n height: 100%;\n overflow-y: scroll;\n overflow-x: hidden;\n transition: all 0.3s;\n z-index: 3;\n background-color: #fff;\n}\n.Sqb {\n padding: 0 20px 50px;\n}\n.Sqb-list {\n padding-top: 1.5rem;\n}\n.Sqb-hover-parent {\n margin-bottom: 16px;\n padding-bottom: 16px;\n}\n.Sqb-item {\n font-size: 14px;\n}\n.Sqb-item--text {\n color: #509ee3;\n width: 66.6667%;\n box-sizing: border-box;\n margin-bottom: 8px;\n display: flex;\n align-items: center;\n font-weight: 600;\n}\n.Sqb-item--text.purple-text {\n color: #7172ad;\n}\n.Sqb-item--text.gray-text {\n color: #93a1ab;\n}\n.Sqb-item--text.green-text {\n color: #88bf4d;\n}\n.Sqb-item-close {\n width: 16px;\n height: 16px;\n color: #b8bbc3;\n margin-left: auto;\n visibility: hidden;\n cursor: pointer;\n}\n.Sqb-item--content {\n width: 66.6667%;\n box-sizing: border-box;\n}\n.Sqb-item--content .Sqb-Filter-item {\n position: relative;\n margin: 0 10px;\n}\n.Sqb-item--content .Sqb-Filter-item .right-arrow,\n.Sqb-item--content .Sqb-Filter-item .left-arrow {\n position: absolute;\n top: 0;\n height: 40px;\n width: 30px;\n display: flex;\n align-items: center;\n justify-content: center;\n opacity: 0.4;\n cursor: pointer;\n transform: scale(0);\n transition: all 0.3s;\n}\n.Sqb-item--content .Sqb-Filter-item .right-arrow img,\n.Sqb-item--content .Sqb-Filter-item .left-arrow img {\n transform: scale(0.8);\n}\n.Sqb-item--content .Sqb-Filter-item .right-arrow:hover,\n.Sqb-item--content .Sqb-Filter-item .left-arrow:hover {\n opacity: 1;\n}\n.Sqb-item--content .Sqb-Filter-item .left-arrow {\n transform: rotate(180deg) scale(0);\n transform-origin: 50% 50%;\n left: -30px;\n}\n.Sqb-item--content .Sqb-Filter-item .right-arrow {\n right: -20px;\n}\n.Sqb-item--content .Sqb-Filter-item.hover .left-arrow {\n transform: rotate(180deg) scale(1);\n}\n.Sqb-item--content .Sqb-Filter-item.hover .right-arrow {\n transform: scale(1);\n}\n.Sqb-item--content .Sqb-NotebookCell {\n box-sizing: border-box;\n padding: 16px 16px 8px;\n color: #509ee3;\n display: flex;\n flex-wrap: wrap;\n -webkit-box-align: center;\n align-items: center;\n border-radius: 8px;\n background-color: rgba(80, 158, 227, 0.1);\n}\n.Sqb-item--content .Sqb-NotebookCell-preview {\n flex-shrink: 0;\n width: 100%;\n}\n.Sqb-item--content .Sqb-NotebookCell.gray-bg {\n background-color: rgba(147, 161, 171, 0.1);\n}\n.Sqb-item--content .Sqb-NotebookCell.green-bg {\n background-color: rgba(136, 191, 77, 0.1);\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName {\n position: relative;\n border: 2px solid transparent;\n border-radius: 6px;\n color: white;\n background-color: #509ee3;\n transition: background 300ms linear 0s,\n border 300ms linear 0s;\n box-sizing: border-box;\n margin-bottom: 8px;\n margin-right: 8px;\n padding: 8px;\n display: flex;\n -webkit-box-align: center;\n align-items: center;\n cursor: pointer;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName-as {\n position: absolute;\n right: 0;\n top: 0;\n transform: translate(50%, -50%);\n margin: 0;\n border: none;\n border-radius: 50%;\n width: 20px;\n height: 20px;\n font-size: 12px;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName-input {\n margin-bottom: 9px;\n margin-right: 8px;\n padding: 9px;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName::selection {\n color: #ffffff;\n background-color: #d489ac;\n text-shadow: none;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName:hover {\n background-color: rgba(80, 158, 227, 0.8);\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.noClick {\n cursor: default;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.noClick:hover {\n background-color: #509ee3;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.notSelected {\n border: 2px solid rgba(80, 158, 227, 0.25);\n color: #509ee3;\n background-color: transparent;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.notSelected:hover {\n border-color: rgba(80, 158, 227, 0.8);\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.purple-name {\n color: white;\n background-color: #7172ad;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.purple-name:hover {\n background-color: rgba(113, 114, 173, 0.8);\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.purple-name svg.closeIcon {\n opacity: 0.6;\n margin-left: 8px;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.purple-name.notSelected {\n border: 2px solid rgba(113, 114, 173, 0.25);\n color: #7172ad;\n background-color: transparent;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.purple-name.notSelected:hover {\n border-color: rgba(113, 114, 173, 0.8);\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.gray-name {\n color: white;\n background-color: #93a1ab;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.gray-name:hover {\n background-color: rgba(147, 161, 171, 0.8);\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.gray-name svg.sort-arrow {\n margin-right: 0.5rem;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.gray-name svg.closeIcon {\n opacity: 0.6;\n margin-left: 8px;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.green-name {\n color: white;\n background-color: #88bf4d;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.green-name:hover {\n background-color: rgba(136, 191, 77, 0.8);\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.green-name svg.closeIcon {\n opacity: 0.6;\n margin-left: 8px;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.green-name.notSelected {\n border: 2px solid rgba(136, 191, 77, 0.25);\n color: #88bf4d;\n background-color: transparent;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.green-name.notSelected:hover {\n border-color: rgba(136, 191, 77, 0.8);\n}\n.Sqb-item--content .Sqb-NotebookCell .ant-input-number {\n margin-bottom: 0.5rem;\n}\n.Sqb-item--content .Sqb-NotebookCell .ant-input-number .ant-input-number-input {\n height: 32px;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-where {\n box-sizing: border-box;\n display: flex;\n -webkit-box-align: center;\n align-items: center;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-where.block {\n width: 100%;\n}\n.Sqb-item--content .Sqb-NotebookCell .operator-icon,\n.Sqb-item--content .Sqb-NotebookCell .operator-icon button {\n font-size: 18px !important;\n border: none !important;\n}\n.Sqb-item--content .Sqb-NotebookCell .subquery-icon {\n color: #93a1ab;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableColumns {\n font-weight: 600;\n margin-bottom: 0.5rem;\n margin-left: auto;\n cursor: pointer;\n}\n.Sqb-item--content .flex-row {\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n align-items: center;\n flex-direction: row;\n}\n.Sqb-item--content .flex-row .Sqb-NotebookCell {\n width: 50%;\n}\n.Sqb-item--content .flex-row .pass {\n color: #88bf4d;\n margin: 4px 16px;\n font-size: 600;\n}\n.Sqb-item--func {\n box-sizing: border-box;\n margin-top: 8px;\n}\n.Sqb-item--func .Sqb-button {\n display: inline-block;\n box-sizing: border-box;\n text-decoration: none;\n cursor: pointer;\n font-weight: bold;\n padding: 12px 16px;\n border-radius: 6px;\n margin-right: 16px;\n margin-top: 16px;\n border: none;\n transition: background 300ms ease 0s;\n flex-shrink: 0;\n color: #93a1ab;\n background-color: #ffffff;\n}\n.Sqb-item--func .Sqb-button:hover {\n color: #7e8f9b;\n background-color: #eceff0;\n}\n.Sqb-item--func .Sqb-button > div {\n min-width: 60px;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n display: flex;\n}\n.Sqb-item--func .Sqb-button > div svg {\n flex-shrink: 0;\n}\n.Sqb-item--func .Sqb-button > div div {\n margin-top: 0.5rem;\n}\n.Sqb-item--func .Sqb-button.filter {\n color: #7172ad;\n background-color: #e0e0ed;\n}\n.Sqb-item--func .Sqb-button.filter:hover {\n color: #5d5ea0;\n background-color: #cccce1;\n}\n.Sqb-item--func .Sqb-button.summarize {\n color: #88bf4d;\n background-color: #d8eac5;\n}\n.Sqb-item--func .Sqb-button.summarize:hover {\n color: #79ae3f;\n background-color: #cae2af;\n}\n.Sqb-item--func .Sqb-button.joinData {\n color: #509ee3;\n background-color: #f1f7fd;\n}\n.Sqb-item--func .Sqb-button.joinData:hover {\n color: #328dde;\n background-color: #d4e7f8;\n}\n.Sqb-item--func .Sqb-button.small {\n margin-right: 8px;\n margin-top: 0;\n padding: 0.5rem;\n}\n.Sqb-item--func .Sqb-button.small > div {\n min-width: 0;\n}\n.Sqb-item--func .Sqb-button.small > div svg {\n width: 14px;\n height: 14px;\n}\n.Sqb-item--func .Sqb-button.small > div div {\n display: none;\n}\n.Sqb-item:hover .Sqb-item-close {\n visibility: visible;\n}\n.Sqb > .Sqb-btn {\n min-width: 220px;\n height: 36px;\n border-radius: 6px;\n color: #ffffff;\n background-color: #509ee3 !important;\n border: 1px solid #509ee3;\n}\n.Sqb > .Sqb-btn:hover {\n background-color: rgba(80, 158, 227, 0.8) !important;\n}\n";
|
|
2001
|
+
var css_248z$d = ".mx-4 {\n margin-left: 1rem;\n margin-right: 1rem;\n}\n.m-2 {\n margin: 0.5rem;\n}\n.mx-2 {\n margin-left: 0.5rem;\n margin-right: 0.5rem;\n}\n.ml-2 {\n margin-left: 0.5rem;\n}\n.mt-2 {\n margin-top: 0.5rem;\n}\n.mb-2 {\n margin-bottom: 0.5rem;\n}\n.mt-4 {\n margin-top: 1rem;\n}\n.ml-4 {\n margin-left: 1rem;\n}\n.mr-4 {\n margin-right: 1rem;\n}\n.mr-2 {\n margin-right: 0.5rem;\n}\n.pt-2 {\n padding-top: 0.5rem;\n}\n.pb-2 {\n padding-bottom: 0.5rem;\n}\n.px-2 {\n padding-left: 0.5rem;\n padding-right: 0.5rem;\n}\n.p-4 {\n padding: 1rem;\n}\n.p-2 {\n padding: 0.5rem;\n}\n.p-1 {\n padding: 0.25rem;\n}\n.px-2 {\n padding-left: 0.5rem;\n padding-right: 0.5rem;\n}\n.pb-4 {\n padding-bottom: 1rem;\n}\n.pt-4 {\n padding-top: 1rem;\n}\n.block {\n display: block;\n}\n.w-full {\n width: 100%;\n}\n.font-bold {\n font-weight: 700;\n}\n.uppercase {\n text-transform: uppercase;\n}\n.tracking-wider {\n letter-spacing: 0.05em;\n}\n.relative {\n position: relative;\n}\n.absolute {\n position: absolute;\n}\n.top-0 {\n top: 0px;\n}\n.left-0 {\n left: 0;\n}\n.rounded-lg {\n border-radius: 0.5rem;\n}\n.text-gray-500 {\n color: #6b7280;\n}\n.flex {\n display: flex;\n}\n.items-center {\n align-items: center;\n}\n.justify-center {\n justify-content: center;\n}\n.visual-box {\n position: relative;\n width: 100%;\n height: 100%;\n overflow-y: scroll;\n overflow-x: hidden;\n transition: all 0.3s;\n z-index: 3;\n background-color: #fff;\n}\n.Sqb {\n padding: 0 20px 50px;\n}\n.Sqb-list {\n padding-top: 1.5rem;\n}\n.Sqb-hover-parent {\n margin-bottom: 16px;\n padding-bottom: 16px;\n}\n.Sqb-item {\n font-size: 14px;\n}\n.Sqb-item--text {\n color: #509ee3;\n width: 66.6667%;\n box-sizing: border-box;\n margin-bottom: 8px;\n display: flex;\n align-items: center;\n font-weight: 600;\n}\n.Sqb-item--text.purple-text {\n color: #7172ad;\n}\n.Sqb-item--text.gray-text {\n color: #93a1ab;\n}\n.Sqb-item--text.green-text {\n color: #88bf4d;\n}\n.Sqb-item-close {\n width: 16px;\n height: 16px;\n color: #b8bbc3;\n margin-left: auto;\n visibility: hidden;\n cursor: pointer;\n}\n.Sqb-item--content {\n width: 66.6667%;\n box-sizing: border-box;\n}\n.Sqb-item--content .Sqb-Filter-item {\n position: relative;\n margin: 0 10px;\n}\n.Sqb-item--content .Sqb-Filter-item .right-arrow,\n.Sqb-item--content .Sqb-Filter-item .left-arrow {\n position: absolute;\n top: 0;\n height: 40px;\n width: 30px;\n display: flex;\n align-items: center;\n justify-content: center;\n opacity: 0.4;\n cursor: pointer;\n transform: scale(0);\n transition: all 0.3s;\n}\n.Sqb-item--content .Sqb-Filter-item .right-arrow img,\n.Sqb-item--content .Sqb-Filter-item .left-arrow img {\n transform: scale(0.8);\n}\n.Sqb-item--content .Sqb-Filter-item .right-arrow:hover,\n.Sqb-item--content .Sqb-Filter-item .left-arrow:hover {\n opacity: 1;\n}\n.Sqb-item--content .Sqb-Filter-item .left-arrow {\n transform: rotate(180deg) scale(0);\n transform-origin: 50% 50%;\n left: -30px;\n}\n.Sqb-item--content .Sqb-Filter-item .right-arrow {\n right: -20px;\n}\n.Sqb-item--content .Sqb-Filter-item.hover .left-arrow {\n transform: rotate(180deg) scale(1);\n}\n.Sqb-item--content .Sqb-Filter-item.hover .right-arrow {\n transform: scale(1);\n}\n.Sqb-item--content .Sqb-NotebookCell {\n box-sizing: border-box;\n padding: 16px 16px 8px;\n color: #509ee3;\n display: flex;\n flex-wrap: wrap;\n -webkit-box-align: center;\n align-items: center;\n border-radius: 8px;\n background-color: rgba(80, 158, 227, 0.1);\n}\n.Sqb-item--content .Sqb-NotebookCell-preview {\n flex-shrink: 0;\n width: 100%;\n}\n.Sqb-item--content .Sqb-NotebookCell.gray-bg {\n background-color: rgba(147, 161, 171, 0.1);\n}\n.Sqb-item--content .Sqb-NotebookCell.green-bg {\n background-color: rgba(136, 191, 77, 0.1);\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName {\n position: relative;\n border: 2px solid transparent;\n border-radius: 6px;\n color: white;\n background-color: #509ee3;\n transition: background 300ms linear 0s,\n border 300ms linear 0s;\n box-sizing: border-box;\n margin-bottom: 8px;\n margin-right: 8px;\n padding: 8px;\n display: flex;\n -webkit-box-align: center;\n align-items: center;\n cursor: pointer;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName-as {\n position: absolute;\n right: 0;\n top: 0;\n transform: translate(50%, -50%);\n margin: 0;\n border: none;\n border-radius: 50%;\n width: 20px;\n height: 20px;\n font-size: 12px;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName-input {\n margin-bottom: 9px;\n margin-right: 8px;\n padding: 9px;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName::selection {\n color: #ffffff;\n background-color: #d489ac;\n text-shadow: none;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName:hover {\n background-color: rgba(80, 158, 227, 0.8);\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.noClick {\n cursor: default;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.noClick:hover {\n background-color: #509ee3;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.notSelected {\n border: 2px solid rgba(80, 158, 227, 0.25);\n color: #509ee3;\n background-color: transparent;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.notSelected:hover {\n border-color: rgba(80, 158, 227, 0.8);\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.purple-name {\n color: white;\n background-color: #7172ad;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.purple-name:hover {\n background-color: rgba(113, 114, 173, 0.8);\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.purple-name svg.closeIcon {\n opacity: 0.6;\n margin-left: 8px;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.purple-name.notSelected {\n border: 2px solid rgba(113, 114, 173, 0.25);\n color: #7172ad;\n background-color: transparent;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.purple-name.notSelected:hover {\n border-color: rgba(113, 114, 173, 0.8);\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.gray-name {\n color: white;\n background-color: #93a1ab;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.gray-name:hover {\n background-color: rgba(147, 161, 171, 0.8);\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.gray-name svg.sort-arrow {\n margin-right: 0.5rem;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.gray-name svg.closeIcon {\n opacity: 0.6;\n margin-left: 8px;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.green-name {\n color: white;\n background-color: #88bf4d;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.green-name:hover {\n background-color: rgba(136, 191, 77, 0.8);\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.green-name svg.closeIcon {\n opacity: 0.6;\n margin-left: 8px;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.green-name.notSelected {\n border: 2px solid rgba(136, 191, 77, 0.25);\n color: #88bf4d;\n background-color: transparent;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableName.green-name.notSelected:hover {\n border-color: rgba(136, 191, 77, 0.8);\n}\n.Sqb-item--content .Sqb-NotebookCell .ant-input-number {\n margin-bottom: 0.5rem;\n}\n.Sqb-item--content .Sqb-NotebookCell .ant-input-number .ant-input-number-input {\n height: 32px;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-where {\n box-sizing: border-box;\n display: flex;\n -webkit-box-align: center;\n align-items: center;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-where.block {\n width: 100%;\n}\n.Sqb-item--content .Sqb-NotebookCell .operator-icon,\n.Sqb-item--content .Sqb-NotebookCell .operator-icon button {\n font-size: 18px !important;\n border: none !important;\n}\n.Sqb-item--content .Sqb-NotebookCell .subquery-icon {\n color: #93a1ab;\n}\n.Sqb-item--content .Sqb-NotebookCell .Sqb-TableColumns {\n font-weight: 600;\n margin-bottom: 0.5rem;\n margin-left: auto;\n cursor: pointer;\n}\n.Sqb-item--content .flex-row {\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n align-items: center;\n flex-direction: row;\n}\n.Sqb-item--content .flex-row .Sqb-NotebookCell {\n width: 50%;\n}\n.Sqb-item--content .flex-row .pass {\n color: #88bf4d;\n margin: 4px 16px;\n font-size: 600;\n}\n.Sqb-item--func {\n box-sizing: border-box;\n margin-top: 8px;\n}\n.Sqb-item--func .Sqb-button {\n display: inline-block;\n box-sizing: border-box;\n text-decoration: none;\n cursor: pointer;\n font-weight: bold;\n padding: 12px 16px;\n border-radius: 6px;\n margin-right: 16px;\n margin-top: 16px;\n border: none;\n transition: background 300ms ease 0s;\n flex-shrink: 0;\n color: #93a1ab;\n background-color: #ffffff;\n}\n.Sqb-item--func .Sqb-button:hover {\n color: #7e8f9b;\n background-color: #eceff0;\n}\n.Sqb-item--func .Sqb-button > div {\n min-width: 60px;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n display: flex;\n}\n.Sqb-item--func .Sqb-button > div svg {\n flex-shrink: 0;\n}\n.Sqb-item--func .Sqb-button > div div {\n margin-top: 0.5rem;\n}\n.Sqb-item--func .Sqb-button.filter {\n color: #7172ad;\n background-color: #e0e0ed;\n}\n.Sqb-item--func .Sqb-button.filter:hover {\n color: #5d5ea0;\n background-color: #cccce1;\n}\n.Sqb-item--func .Sqb-button.summarize {\n color: #88bf4d;\n background-color: #d8eac5;\n}\n.Sqb-item--func .Sqb-button.summarize:hover {\n color: #79ae3f;\n background-color: #cae2af;\n}\n.Sqb-item--func .Sqb-button.joinData {\n color: #509ee3;\n background-color: #f1f7fd;\n}\n.Sqb-item--func .Sqb-button.joinData:hover {\n color: #328dde;\n background-color: #d4e7f8;\n}\n.Sqb-item--func .Sqb-button.small {\n margin-right: 8px;\n margin-top: 0;\n padding: 0.5rem;\n}\n.Sqb-item--func .Sqb-button.small > div {\n min-width: 0;\n}\n.Sqb-item--func .Sqb-button.small > div svg {\n width: 14px;\n height: 14px;\n}\n.Sqb-item--func .Sqb-button.small > div div {\n display: none;\n}\n.Sqb-item:hover .Sqb-item-close {\n visibility: visible;\n}\n.Sqb > .Sqb-btn {\n min-width: 220px;\n height: 36px;\n border-radius: 6px;\n color: #ffffff;\n background-color: #509ee3 !important;\n border: 1px solid #509ee3;\n}\n.Sqb > .Sqb-btn:hover {\n background-color: rgba(80, 158, 227, 0.8) !important;\n}\n";
|
|
1842
2002
|
styleInject(css_248z$d);
|
|
1843
2003
|
|
|
1844
|
-
// 获取元素translate x y值
|
|
1845
|
-
const getComputedTranslate = obj => {
|
|
1846
|
-
if (!window.getComputedStyle) return {
|
|
1847
|
-
x: 0,
|
|
1848
|
-
y: 0
|
|
1849
|
-
};
|
|
1850
|
-
var style = getComputedStyle(obj),
|
|
1851
|
-
transform = style.transform || style.webkitTransform || style.mozTransform;
|
|
1852
|
-
var mat = transform.match(/^matrix3d\((.+)\)$/);
|
|
1853
|
-
if (mat) {
|
|
1854
|
-
return {
|
|
1855
|
-
x: parseFloat(mat[1].split(', ')[12]),
|
|
1856
|
-
y: parseFloat(mat[1].split(', ')[13])
|
|
1857
|
-
};
|
|
1858
|
-
}
|
|
1859
|
-
mat = transform.match(/^matrix\((.+)\)$/);
|
|
1860
|
-
if (mat) {
|
|
1861
|
-
return {
|
|
1862
|
-
x: parseFloat(mat[1].split(', ')[4]),
|
|
1863
|
-
y: parseFloat(mat[1].split(', ')[5])
|
|
1864
|
-
};
|
|
1865
|
-
}
|
|
1866
|
-
return {
|
|
1867
|
-
x: 0,
|
|
1868
|
-
y: 0
|
|
1869
|
-
};
|
|
1870
|
-
};
|
|
1871
|
-
// 获取元素距离浏览器顶部的距离
|
|
1872
|
-
const getElementTop = elem => {
|
|
1873
|
-
if (!elem) return 0;
|
|
1874
|
-
let elemTop = elem.offsetTop;
|
|
1875
|
-
let pElem = elem.offsetParent;
|
|
1876
|
-
while (pElem != null) {
|
|
1877
|
-
elemTop += pElem.offsetTop;
|
|
1878
|
-
if (pElem.style.transform) {
|
|
1879
|
-
elemTop += getComputedTranslate(pElem).y;
|
|
1880
|
-
}
|
|
1881
|
-
pElem = pElem.offsetParent;
|
|
1882
|
-
}
|
|
1883
|
-
return elemTop;
|
|
1884
|
-
};
|
|
1885
|
-
// 获取元素距离浏览器顶部的距离
|
|
1886
|
-
const getElementLeft = elem => {
|
|
1887
|
-
if (!elem) return 0;
|
|
1888
|
-
let elemLeft = elem.offsetLeft;
|
|
1889
|
-
let pElem = elem.offsetParent;
|
|
1890
|
-
while (pElem != null) {
|
|
1891
|
-
elemLeft += pElem.offsetLeft;
|
|
1892
|
-
if (pElem.style.transform) {
|
|
1893
|
-
elemLeft += getComputedTranslate(pElem).x;
|
|
1894
|
-
}
|
|
1895
|
-
pElem = pElem.offsetParent;
|
|
1896
|
-
}
|
|
1897
|
-
return elemLeft;
|
|
1898
|
-
};
|
|
1899
|
-
// 获取元素可见范围内高度
|
|
1900
|
-
const getContainerVisibleHeight = container => {
|
|
1901
|
-
if (!container) return 0;
|
|
1902
|
-
const rect = container.getBoundingClientRect();
|
|
1903
|
-
const windowHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
1904
|
-
// 元素顶部在视口上方 -> 不可见
|
|
1905
|
-
if (rect.bottom < 0) return 0;
|
|
1906
|
-
// 元素底部在视口下方 -> 不可见
|
|
1907
|
-
if (rect.top > windowHeight) return 0;
|
|
1908
|
-
// 可见区域的 top 和 bottom
|
|
1909
|
-
const visibleTop = Math.max(rect.top, 0);
|
|
1910
|
-
const visibleBottom = Math.min(rect.bottom, windowHeight);
|
|
1911
|
-
// 可见高度
|
|
1912
|
-
return visibleBottom - visibleTop;
|
|
1913
|
-
};
|
|
1914
|
-
const getScrollTop = elem => {
|
|
1915
|
-
return elem?.scrollTop || document.documentElement.scrollTop;
|
|
1916
|
-
};
|
|
1917
|
-
// 浏览器可视宽高
|
|
1918
|
-
const getWindowSize = () => {
|
|
1919
|
-
return {
|
|
1920
|
-
width: document.body.clientWidth,
|
|
1921
|
-
height: document.body.clientHeight
|
|
1922
|
-
};
|
|
1923
|
-
};
|
|
1924
|
-
// 获取元素父级最大的 z-index
|
|
1925
|
-
const getMaxZIndexInParents = element => {
|
|
1926
|
-
let currentElement = element;
|
|
1927
|
-
let maxZIndex = -Infinity;
|
|
1928
|
-
// 遍历当前元素及其所有父级元素
|
|
1929
|
-
while (currentElement && currentElement !== document.body) {
|
|
1930
|
-
// 获取当前元素的 z-index
|
|
1931
|
-
const zIndex = window.getComputedStyle(currentElement).zIndex;
|
|
1932
|
-
// 如果 z-index 是数字且比当前最大值大,则更新
|
|
1933
|
-
if (zIndex !== 'auto') {
|
|
1934
|
-
const zIndexNum = parseInt(zIndex, 10);
|
|
1935
|
-
if (!isNaN(zIndexNum) && zIndexNum > maxZIndex) {
|
|
1936
|
-
maxZIndex = zIndexNum;
|
|
1937
|
-
}
|
|
1938
|
-
}
|
|
1939
|
-
// 移动到父级元素
|
|
1940
|
-
currentElement = currentElement.parentElement;
|
|
1941
|
-
}
|
|
1942
|
-
// 如果没有显式设置的 z-index,返回 'auto' 或默认值
|
|
1943
|
-
return maxZIndex !== -Infinity ? maxZIndex : 'auto';
|
|
1944
|
-
};
|
|
1945
|
-
|
|
1946
2004
|
const Wrapper = ({
|
|
1947
2005
|
children,
|
|
1948
2006
|
className
|
|
@@ -3427,6 +3485,87 @@ class TokenizedInput extends React__default.Component {
|
|
|
3427
3485
|
}
|
|
3428
3486
|
}
|
|
3429
3487
|
|
|
3488
|
+
// 获取元素translate x y值
|
|
3489
|
+
const getComputedTranslate = obj => {
|
|
3490
|
+
if (!window.getComputedStyle) return {
|
|
3491
|
+
x: 0,
|
|
3492
|
+
y: 0
|
|
3493
|
+
};
|
|
3494
|
+
var style = getComputedStyle(obj),
|
|
3495
|
+
transform = style.transform || style.webkitTransform || style.mozTransform;
|
|
3496
|
+
var mat = transform.match(/^matrix3d\((.+)\)$/);
|
|
3497
|
+
if (mat) {
|
|
3498
|
+
return {
|
|
3499
|
+
x: parseFloat(mat[1].split(', ')[12]),
|
|
3500
|
+
y: parseFloat(mat[1].split(', ')[13])
|
|
3501
|
+
};
|
|
3502
|
+
}
|
|
3503
|
+
mat = transform.match(/^matrix\((.+)\)$/);
|
|
3504
|
+
if (mat) {
|
|
3505
|
+
return {
|
|
3506
|
+
x: parseFloat(mat[1].split(', ')[4]),
|
|
3507
|
+
y: parseFloat(mat[1].split(', ')[5])
|
|
3508
|
+
};
|
|
3509
|
+
}
|
|
3510
|
+
return {
|
|
3511
|
+
x: 0,
|
|
3512
|
+
y: 0
|
|
3513
|
+
};
|
|
3514
|
+
};
|
|
3515
|
+
// 获取元素距离浏览器顶部的距离
|
|
3516
|
+
const getElementTop = elem => {
|
|
3517
|
+
if (!elem) return 0;
|
|
3518
|
+
let elemTop = elem.offsetTop;
|
|
3519
|
+
let pElem = elem.offsetParent;
|
|
3520
|
+
while (pElem != null) {
|
|
3521
|
+
elemTop += pElem.offsetTop;
|
|
3522
|
+
if (pElem.style.transform) {
|
|
3523
|
+
elemTop += getComputedTranslate(pElem).y;
|
|
3524
|
+
}
|
|
3525
|
+
pElem = pElem.offsetParent;
|
|
3526
|
+
}
|
|
3527
|
+
return elemTop;
|
|
3528
|
+
};
|
|
3529
|
+
// 获取元素距离浏览器顶部的距离
|
|
3530
|
+
const getElementLeft = elem => {
|
|
3531
|
+
if (!elem) return 0;
|
|
3532
|
+
let elemLeft = elem.offsetLeft;
|
|
3533
|
+
let pElem = elem.offsetParent;
|
|
3534
|
+
while (pElem != null) {
|
|
3535
|
+
elemLeft += pElem.offsetLeft;
|
|
3536
|
+
if (pElem.style.transform) {
|
|
3537
|
+
elemLeft += getComputedTranslate(pElem).x;
|
|
3538
|
+
}
|
|
3539
|
+
pElem = pElem.offsetParent;
|
|
3540
|
+
}
|
|
3541
|
+
return elemLeft;
|
|
3542
|
+
};
|
|
3543
|
+
// 获取元素可见范围内高度
|
|
3544
|
+
const getContainerVisibleHeight = container => {
|
|
3545
|
+
if (!container) return 0;
|
|
3546
|
+
const rect = container.getBoundingClientRect();
|
|
3547
|
+
const windowHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
3548
|
+
// 元素顶部在视口上方 -> 不可见
|
|
3549
|
+
if (rect.bottom < 0) return 0;
|
|
3550
|
+
// 元素底部在视口下方 -> 不可见
|
|
3551
|
+
if (rect.top > windowHeight) return 0;
|
|
3552
|
+
// 可见区域的 top 和 bottom
|
|
3553
|
+
const visibleTop = Math.max(rect.top, 0);
|
|
3554
|
+
const visibleBottom = Math.min(rect.bottom, windowHeight);
|
|
3555
|
+
// 可见高度
|
|
3556
|
+
return visibleBottom - visibleTop;
|
|
3557
|
+
};
|
|
3558
|
+
const getScrollTop = elem => {
|
|
3559
|
+
return elem?.scrollTop || document.documentElement.scrollTop;
|
|
3560
|
+
};
|
|
3561
|
+
// 浏览器可视宽高
|
|
3562
|
+
const getWindowSize = () => {
|
|
3563
|
+
return {
|
|
3564
|
+
width: document.body.clientWidth,
|
|
3565
|
+
height: document.body.clientHeight
|
|
3566
|
+
};
|
|
3567
|
+
};
|
|
3568
|
+
|
|
3430
3569
|
class WinResetEvent {
|
|
3431
3570
|
eventStack = {};
|
|
3432
3571
|
funcId = 0;
|
|
@@ -3467,7 +3606,9 @@ const Portal = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3467
3606
|
initRef.current = true;
|
|
3468
3607
|
}
|
|
3469
3608
|
useEffect(() => {
|
|
3470
|
-
|
|
3609
|
+
setTimeout(() => {
|
|
3610
|
+
didUpdate?.(props, containerRef.current);
|
|
3611
|
+
}, 0);
|
|
3471
3612
|
});
|
|
3472
3613
|
useEffect(() => {
|
|
3473
3614
|
return () => {
|
|
@@ -3593,6 +3734,7 @@ function generateTrigger(PortalComponent) {
|
|
|
3593
3734
|
borderRadius: 6
|
|
3594
3735
|
},
|
|
3595
3736
|
onClick: e => this.props.closable && e.stopPropagation(),
|
|
3737
|
+
onMouseDown: e => e.stopPropagation(),
|
|
3596
3738
|
children: /*#__PURE__*/React.cloneElement(this.props.children, {
|
|
3597
3739
|
key: posKey,
|
|
3598
3740
|
didUpdate: this.didUpdate
|
|
@@ -3652,7 +3794,7 @@ styleInject(css_248z$9);
|
|
|
3652
3794
|
var css_248z$8 = ".function-tip__container {\n width: 448px;\n font-size: 14px;\n color: #4c5773;\n}\n.function-tip__container .function-name {\n background: #fffcf2;\n font-weight: 700;\n padding: 1rem;\n font-size: 14px;\n}\n.function-tip__container .function-desc {\n padding: 1rem;\n border-top: 1px solid #f0f0f0;\n}\n.function-tip__container .function-desc .desc {\n font-weight: 700;\n}\n.function-tip__container .function-desc .case {\n font-family: monospace;\n color: #949aab;\n background-color: #edf2f5;\n border-radius: 2px;\n padding: 0.2em 0.4em;\n line-height: 1.4em;\n white-space: pre-wrap;\n}\n.function-tip__container .funciton-parameter {\n padding: 1rem;\n border-top: 1px solid #f0f0f0;\n}\n.function-tip__container .funciton-parameter .key {\n color: #949aab;\n}\n.function-tip__container .funciton-parameter .explain {\n font-weight: 700;\n margin-top: 0.5rem;\n}\n";
|
|
3653
3795
|
styleInject(css_248z$8);
|
|
3654
3796
|
|
|
3655
|
-
var css_248z$7 = ".Sqb-SelectColumn--box {\n box-sizing: border-box;\n min-width: 1em;\n max-width: 300px;\n background-color: #ffffff;\n overflow: hidden;\n}\n.Sqb-SelectColumn--box .SelectColumn-border {\n border-bottom: 1px solid #f0f0f0;\n}\n.Sqb-SelectColumn--box .SelectColumn-border.events-none {\n pointer-events: none;\n opacity: 0.4;\n}\n.Sqb-SelectColumn--box > div {\n cursor: pointer;\n color: #4c5773;\n}\n.Sqb-SelectColumn--box > div .selected {\n width: 16px;\n height: 16px;\n background-color: #509ee3;\n border: 2px solid #509ee3;\n border-radius: 4px;\n color: #fff;\n}\n.Sqb-SelectColumn--box > div .no-select {\n width: 16px;\n height: 16px;\n background-color: white;\n border: 2px solid #b8bbc3;\n border-radius: 4px;\n color: #b8bbc3;\n}\n.Sqb-SelectColumn--box > div .Sqb-TableName-as {\n margin-left: auto;\n}\n";
|
|
3797
|
+
var css_248z$7 = ".Sqb-SelectColumn--box {\n box-sizing: border-box;\n min-width: 1em;\n max-width: 300px;\n background-color: #ffffff;\n overflow: hidden;\n}\n.Sqb-SelectColumn--box .SelectColumn-border {\n border-bottom: 1px solid #f0f0f0;\n}\n.Sqb-SelectColumn--box .SelectColumn-border.events-none {\n pointer-events: none;\n opacity: 0.4;\n}\n.Sqb-SelectColumn--box > div {\n cursor: pointer;\n color: #4c5773;\n}\n.Sqb-SelectColumn--box > div .selected {\n width: 16px;\n height: 16px;\n background-color: #509ee3;\n border: 2px solid #509ee3;\n border-radius: 4px;\n color: #fff;\n}\n.Sqb-SelectColumn--box > div .no-select {\n width: 16px;\n height: 16px;\n background-color: white;\n border: 2px solid #b8bbc3;\n border-radius: 4px;\n color: #b8bbc3;\n}\n.Sqb-SelectColumn--box > div .Sqb-TableName-as {\n margin-left: auto;\n}\n.Sqb-SelectColumn--box .Sqb-SelectColumn-search {\n display: flex;\n align-items: center;\n flex: 1 0 auto;\n color: #b8bbc3;\n background-color: #fff;\n border: 1px solid #f0f0f0;\n font-size: 14px;\n}\n.Sqb-SelectColumn--box .Sqb-SelectColumn-search span {\n line-height: 0;\n}\n.Sqb-SelectColumn--box .Sqb-SelectColumn-search input {\n box-shadow: none;\n outline: 0;\n border: none !important;\n background: transparent;\n color: #4c5773;\n font-size: 1em;\n font-weight: 600;\n}\n.Sqb-SelectColumn--box .Sqb-SelectColumn-search input::-webkit-input-placeholder {\n color: #b8bbc3;\n}\n.Sqb-SelectColumn--box .Sqb-SelectColumn-search input::-ms-input-placeholder {\n color: #b8bbc3;\n}\n";
|
|
3656
3798
|
styleInject(css_248z$7);
|
|
3657
3799
|
|
|
3658
3800
|
// 选择表中参数
|
|
@@ -3661,11 +3803,21 @@ const SelectColumn = ({
|
|
|
3661
3803
|
groupIndex,
|
|
3662
3804
|
onChange
|
|
3663
3805
|
}) => {
|
|
3664
|
-
const [columns, setColumns] = useState(
|
|
3806
|
+
const [columns, setColumns] = useState([]);
|
|
3807
|
+
const [originList, setOriginList] = useState(_data.slice());
|
|
3665
3808
|
const store = useStore$1();
|
|
3809
|
+
const [filterVal, setFilterVal] = useState('');
|
|
3810
|
+
useEffect(() => {
|
|
3811
|
+
let newList = cloneDeep(originList.slice());
|
|
3812
|
+
setColumns(newList.filter(v => ~(v.name + (v.name_zh || '')).toLocaleLowerCase().indexOf(filterVal.toLocaleLowerCase())));
|
|
3813
|
+
}, [filterVal, originList]);
|
|
3814
|
+
function onInput(e) {
|
|
3815
|
+
let val = e.target.value;
|
|
3816
|
+
setFilterVal(val);
|
|
3817
|
+
}
|
|
3666
3818
|
const isAllSelect = useMemo(() => {
|
|
3667
|
-
return
|
|
3668
|
-
}, [
|
|
3819
|
+
return originList.filter(v => v.select).length === originList.length;
|
|
3820
|
+
}, [originList]);
|
|
3669
3821
|
const AllSelectElement = useMemo(() => {
|
|
3670
3822
|
if (isAllSelect) {
|
|
3671
3823
|
return jsxs(Fragment, {
|
|
@@ -3684,8 +3836,14 @@ const SelectColumn = ({
|
|
|
3684
3836
|
}
|
|
3685
3837
|
}, [isAllSelect]);
|
|
3686
3838
|
function onSelect(columns) {
|
|
3839
|
+
const originalData = cloneDeep(originList); // 原始数据
|
|
3840
|
+
const mergedColumns = originalData.map(item => {
|
|
3841
|
+
const match = columns.find(col => col.fieldUuid === item.fieldUuid);
|
|
3842
|
+
return match ? cloneDeep(match) : item; // 可选:是否需要深拷贝 match
|
|
3843
|
+
});
|
|
3687
3844
|
setColumns(columns);
|
|
3688
|
-
|
|
3845
|
+
setOriginList(mergedColumns);
|
|
3846
|
+
typeof onChange === 'function' && onChange(mergedColumns);
|
|
3689
3847
|
}
|
|
3690
3848
|
const onChangeFieldAlias = (val, i) => {
|
|
3691
3849
|
let fieldAlias = val || '';
|
|
@@ -3706,10 +3864,14 @@ const SelectColumn = ({
|
|
|
3706
3864
|
newMetaList = changeFieldAlias(newMetaList, newColumns[i]);
|
|
3707
3865
|
store.setMeta(newMetaList, groupIndex);
|
|
3708
3866
|
onSelect(newColumns);
|
|
3709
|
-
|
|
3867
|
+
setTimeout(() => {
|
|
3868
|
+
store.setClosable(true);
|
|
3869
|
+
}, 0);
|
|
3710
3870
|
},
|
|
3711
3871
|
onCancel: () => {
|
|
3712
|
-
|
|
3872
|
+
setTimeout(() => {
|
|
3873
|
+
store.setClosable(true);
|
|
3874
|
+
}, 0);
|
|
3713
3875
|
}
|
|
3714
3876
|
});
|
|
3715
3877
|
};
|
|
@@ -3729,6 +3891,18 @@ const SelectColumn = ({
|
|
|
3729
3891
|
onSelect(newColumns);
|
|
3730
3892
|
},
|
|
3731
3893
|
children: AllSelectElement
|
|
3894
|
+
}), jsxs("div", {
|
|
3895
|
+
className: cx(`Sqb-SelectColumn-search m-2 rounded-lg`),
|
|
3896
|
+
children: [jsx("span", {
|
|
3897
|
+
className: 'px-2',
|
|
3898
|
+
children: jsx(SearchIcon, {})
|
|
3899
|
+
}), jsx("input", {
|
|
3900
|
+
type: 'text',
|
|
3901
|
+
autoFocus: true,
|
|
3902
|
+
className: 'p-1',
|
|
3903
|
+
placeholder: __('data.search'),
|
|
3904
|
+
onInput: onInput
|
|
3905
|
+
})]
|
|
3732
3906
|
}), Array.isArray(columns) && columns.map((v, i) => {
|
|
3733
3907
|
return jsxs("div", {
|
|
3734
3908
|
className: 'pb-2 px-2 flex items-center',
|
|
@@ -3797,10 +3971,10 @@ const SelectJoinColumn = ({
|
|
|
3797
3971
|
}) => {
|
|
3798
3972
|
const store = useStore$1();
|
|
3799
3973
|
const [value, setValue] = useState(_value); // 当前选择的字段
|
|
3800
|
-
const [curTable, setCurTable] = useState(_value.
|
|
3974
|
+
const [curTable, setCurTable] = useState(_value.tableUuid); // 当前选择的表
|
|
3801
3975
|
const [curColumn, setCurColumn] = useState(_value.name); // 当前选择的字段
|
|
3802
3976
|
const [tableList, setTableList] = useState(_data.map((v, i) => {
|
|
3803
|
-
let open = !i && !_value.
|
|
3977
|
+
let open = !i && !_value.tableUuid ? true : v.tableUuid === _value.tableUuid; // TODO.这里只判断表名相等 没有用了 因为表上面加了一层数据源 先这样吧
|
|
3804
3978
|
return {
|
|
3805
3979
|
...v,
|
|
3806
3980
|
open,
|
|
@@ -3810,12 +3984,12 @@ const SelectJoinColumn = ({
|
|
|
3810
3984
|
}));
|
|
3811
3985
|
useEffect(() => {
|
|
3812
3986
|
setValue(_value);
|
|
3813
|
-
setCurTable(_value.
|
|
3987
|
+
setCurTable(_value.tableUuid);
|
|
3814
3988
|
setCurColumn(_value.name);
|
|
3815
3989
|
}, [_value]);
|
|
3816
3990
|
useEffect(() => {
|
|
3817
3991
|
setTableList(_data.map((v, i) => {
|
|
3818
|
-
let open = !i && !_value.
|
|
3992
|
+
let open = !i && !_value.tableUuid ? true : v.tableUuid === _value.tableUuid; // TODO.这里只判断表名相等 没有用了 因为表上面加了一层数据源 先这样吧
|
|
3819
3993
|
return {
|
|
3820
3994
|
...v,
|
|
3821
3995
|
open,
|
|
@@ -3875,12 +4049,12 @@ const SelectJoinColumn = ({
|
|
|
3875
4049
|
if (open) {
|
|
3876
4050
|
setTableList(newTables.map(v => ({
|
|
3877
4051
|
...v,
|
|
3878
|
-
open:
|
|
4052
|
+
open: tableUuid === v.tableUuid ? false : v.open
|
|
3879
4053
|
})));
|
|
3880
4054
|
} else {
|
|
3881
4055
|
setTableList(newTables.map(v => ({
|
|
3882
4056
|
...v,
|
|
3883
|
-
open:
|
|
4057
|
+
open: tableUuid === v.tableUuid || v.alias === SummarizeAlias$1
|
|
3884
4058
|
})));
|
|
3885
4059
|
}
|
|
3886
4060
|
},
|
|
@@ -3942,7 +4116,7 @@ const SelectJoinColumn = ({
|
|
|
3942
4116
|
className: cx(`Sqb-List-section`),
|
|
3943
4117
|
children: jsxs("div", {
|
|
3944
4118
|
className: cx(`Sqb-List-item mx-2`, {
|
|
3945
|
-
active: curColumn === name && curTable ===
|
|
4119
|
+
active: curColumn === name && curTable === tableUuid
|
|
3946
4120
|
}),
|
|
3947
4121
|
onClick: () => {
|
|
3948
4122
|
if (isGroup && typeof onGroup === 'function') {
|
|
@@ -3950,7 +4124,7 @@ const SelectJoinColumn = ({
|
|
|
3950
4124
|
let quotes = name;
|
|
3951
4125
|
return onGroup({
|
|
3952
4126
|
..._value,
|
|
3953
|
-
tableUuid:
|
|
4127
|
+
tableUuid: tableUuid || _value.tableUuid,
|
|
3954
4128
|
...v,
|
|
3955
4129
|
table,
|
|
3956
4130
|
tableId,
|
|
@@ -3964,7 +4138,7 @@ const SelectJoinColumn = ({
|
|
|
3964
4138
|
}
|
|
3965
4139
|
typeof onSelect === 'function' && onSelect({
|
|
3966
4140
|
..._value,
|
|
3967
|
-
tableUuid:
|
|
4141
|
+
tableUuid: tableUuid || _value.tableUuid,
|
|
3968
4142
|
...v,
|
|
3969
4143
|
table,
|
|
3970
4144
|
tableId,
|
|
@@ -4380,7 +4554,7 @@ const SelectFilterColumn = ({
|
|
|
4380
4554
|
},
|
|
4381
4555
|
format: 'YYYY-MM-DD HH:mm',
|
|
4382
4556
|
className: 'w_300',
|
|
4383
|
-
value: moment(firstVal
|
|
4557
|
+
value: firstVal ? moment(firstVal) : '',
|
|
4384
4558
|
onChange: val => {
|
|
4385
4559
|
if (val) {
|
|
4386
4560
|
setVal([moment(val).format('YYYY-MM-DD HH:mm')]);
|
|
@@ -4781,7 +4955,8 @@ const SelectSummarize = ({
|
|
|
4781
4955
|
data,
|
|
4782
4956
|
value,
|
|
4783
4957
|
onChange,
|
|
4784
|
-
didUpdate
|
|
4958
|
+
didUpdate,
|
|
4959
|
+
ignoreGroupByType
|
|
4785
4960
|
}) => {
|
|
4786
4961
|
const [condition, setCondition] = useState(value.condition);
|
|
4787
4962
|
function goPrevPage() {
|
|
@@ -4797,12 +4972,12 @@ const SelectSummarize = ({
|
|
|
4797
4972
|
}
|
|
4798
4973
|
if (condition && !~Special.indexOf(condition)) {
|
|
4799
4974
|
let availableData = data.slice();
|
|
4800
|
-
if (condition !== '不重复值的总数') {
|
|
4975
|
+
if (condition !== '不重复值的总数' && !ignoreGroupByType) {
|
|
4801
4976
|
// 只能用数字类型做聚合
|
|
4802
4977
|
availableData = data.map(v => {
|
|
4803
4978
|
return {
|
|
4804
4979
|
...v,
|
|
4805
|
-
columns: v.columns.filter(o => o.database_type && NUMBER_GROUP.includes(o.database_type))
|
|
4980
|
+
columns: v.columns.filter(o => o.database_type && (NUMBER_GROUP.includes(o.database_type) || (condition === '最大值' || condition === '最小值') && DATE_GROUP.includes(o.database_type)))
|
|
4806
4981
|
};
|
|
4807
4982
|
}).filter(v => v.columns.length);
|
|
4808
4983
|
}
|
|
@@ -5485,6 +5660,7 @@ const TableData = props => {
|
|
|
5485
5660
|
} = props;
|
|
5486
5661
|
const store = useStore$1();
|
|
5487
5662
|
let selected = Boolean(meta.table.name);
|
|
5663
|
+
let subQuerySelected = Boolean(meta.subquery?.[0]?.table?.name);
|
|
5488
5664
|
function selectTable(e) {
|
|
5489
5665
|
!meta.readonly && store.setPopup({
|
|
5490
5666
|
visible: true,
|
|
@@ -5540,16 +5716,92 @@ const TableData = props => {
|
|
|
5540
5716
|
alias = val;
|
|
5541
5717
|
}
|
|
5542
5718
|
}),
|
|
5543
|
-
onOk: () => {
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5719
|
+
onOk: async () => {
|
|
5720
|
+
if (!alias) {
|
|
5721
|
+
Toast.warning(__('SqlQueryBuilder.aliasCannotEmpty'));
|
|
5722
|
+
return false;
|
|
5723
|
+
} else {
|
|
5724
|
+
let newMetaList = store.metaList[groupIndex].list.slice();
|
|
5725
|
+
// @ts-ignore
|
|
5726
|
+
newMetaList[0].table.alias = alias;
|
|
5727
|
+
newMetaList = changeTableAlias(newMetaList, newMetaList[0].table);
|
|
5728
|
+
store.setMeta(newMetaList, groupIndex);
|
|
5729
|
+
}
|
|
5549
5730
|
},
|
|
5550
5731
|
onCancel: () => {}
|
|
5551
5732
|
});
|
|
5552
5733
|
};
|
|
5734
|
+
// 子查询弹窗
|
|
5735
|
+
const showSubQuery = (val = []) => {
|
|
5736
|
+
const {
|
|
5737
|
+
subToolbar,
|
|
5738
|
+
toolbar,
|
|
5739
|
+
...other
|
|
5740
|
+
} = store.preProps;
|
|
5741
|
+
let newMetaList = store.metaList[groupIndex].list.slice()[0];
|
|
5742
|
+
let oldList = cloneDeep(newMetaList.subquery);
|
|
5743
|
+
let _toolbar = subToolbar || toolbar;
|
|
5744
|
+
_toolbar = _toolbar.filter(v => v !== 'group'); // 子查询不需要分组
|
|
5745
|
+
let o = Modal2.openModal({
|
|
5746
|
+
title: __('SqlQueryBuilder.subquery'),
|
|
5747
|
+
transparentMask: true,
|
|
5748
|
+
content: jsx(Fragment, {
|
|
5749
|
+
children: jsx(SqlVisionBuilder, {
|
|
5750
|
+
...other,
|
|
5751
|
+
showSubquery: store._showSubquery,
|
|
5752
|
+
toolbar: _toolbar,
|
|
5753
|
+
btnText: __('SqlQueryBuilder.confirm'),
|
|
5754
|
+
value: val,
|
|
5755
|
+
onOk: newList => {
|
|
5756
|
+
try {
|
|
5757
|
+
// 子查询未改变不做操作
|
|
5758
|
+
if (isEqual(newList, oldList)) {
|
|
5759
|
+
o.close();
|
|
5760
|
+
return;
|
|
5761
|
+
}
|
|
5762
|
+
newMetaList.subquery = newList;
|
|
5763
|
+
newMetaList.table = {
|
|
5764
|
+
...newList[0].table,
|
|
5765
|
+
alias: newMetaList.table.alias || newList[0].table.name + '_' + groupIndex + '_' + 0,
|
|
5766
|
+
tableUuid: uuidv4('table')
|
|
5767
|
+
};
|
|
5768
|
+
const items = getSubColumns(newList);
|
|
5769
|
+
const newColumns = items.flatMap(item => item.columns);
|
|
5770
|
+
newMetaList.columns = newColumns;
|
|
5771
|
+
// (newMeta[index] as MetaJoin).expressions = [];
|
|
5772
|
+
store.setMeta([newMetaList], groupIndex);
|
|
5773
|
+
o.close();
|
|
5774
|
+
} catch (e) {
|
|
5775
|
+
console.warn(e);
|
|
5776
|
+
} finally {
|
|
5777
|
+
o.close();
|
|
5778
|
+
}
|
|
5779
|
+
}
|
|
5780
|
+
})
|
|
5781
|
+
}),
|
|
5782
|
+
onClose: () => {}
|
|
5783
|
+
});
|
|
5784
|
+
};
|
|
5785
|
+
// 切换子查询
|
|
5786
|
+
const switchSubQuery = () => {
|
|
5787
|
+
let newMetaList = store.metaList[groupIndex].list.slice()[0];
|
|
5788
|
+
newMetaList.isSubquery = !newMetaList.isSubquery;
|
|
5789
|
+
//重置表数据
|
|
5790
|
+
newMetaList.subquery = [];
|
|
5791
|
+
newMetaList.table = {
|
|
5792
|
+
name: '',
|
|
5793
|
+
// 表名
|
|
5794
|
+
tableUuid: '',
|
|
5795
|
+
id: '',
|
|
5796
|
+
// 表名
|
|
5797
|
+
alias: '',
|
|
5798
|
+
// 表别名
|
|
5799
|
+
datasourceName: '',
|
|
5800
|
+
// 数据源名
|
|
5801
|
+
datasourceId: '' // 数据源id
|
|
5802
|
+
};
|
|
5803
|
+
store.setMeta([newMetaList], groupIndex);
|
|
5804
|
+
};
|
|
5553
5805
|
return jsx(Wrapper, {
|
|
5554
5806
|
className: `Sqb-item`,
|
|
5555
5807
|
children: jsxs("div", {
|
|
@@ -5560,7 +5812,29 @@ const TableData = props => {
|
|
|
5560
5812
|
className: `Sqb-item--content`,
|
|
5561
5813
|
children: jsxs("div", {
|
|
5562
5814
|
className: `Sqb-NotebookCell`,
|
|
5563
|
-
children: [jsxs("div", {
|
|
5815
|
+
children: [meta.isSubquery ? jsxs("div", {
|
|
5816
|
+
className: cx(`Sqb-TableName`, {
|
|
5817
|
+
notSelected: !subQuerySelected
|
|
5818
|
+
}),
|
|
5819
|
+
onClick: () => {
|
|
5820
|
+
showSubQuery(meta.subquery);
|
|
5821
|
+
},
|
|
5822
|
+
children: [subQuerySelected && jsx(Tooltip, {
|
|
5823
|
+
title: __('SqlQueryBuilder.alias'),
|
|
5824
|
+
children: jsx(Button, {
|
|
5825
|
+
className: ':Sqb-TableName-as',
|
|
5826
|
+
shape: 'circle',
|
|
5827
|
+
iconOnly: true,
|
|
5828
|
+
primary: true,
|
|
5829
|
+
icon: 'As',
|
|
5830
|
+
size: 'small',
|
|
5831
|
+
onClick: e => {
|
|
5832
|
+
e.stopPropagation();
|
|
5833
|
+
onChangeTableAlias(meta.table?.alias || '');
|
|
5834
|
+
}
|
|
5835
|
+
})
|
|
5836
|
+
}), subQuerySelected ? `${(meta.subquery?.[0]).table.datasourceName}.${(meta.subquery?.[0]).table.name} ${meta.table?.alias ? `as ${meta.table?.alias}` : ''} ` : __('SqlQueryBuilder.setSubQuery')]
|
|
5837
|
+
}) : jsxs("div", {
|
|
5564
5838
|
className: cx(`Sqb-TableName`, {
|
|
5565
5839
|
notSelected: !selected
|
|
5566
5840
|
}),
|
|
@@ -5580,7 +5854,19 @@ const TableData = props => {
|
|
|
5580
5854
|
}
|
|
5581
5855
|
})
|
|
5582
5856
|
}), selected ? `${meta.table.datasourceName}.${meta.table.name} ${meta.table?.alias ? `as ${meta.table?.alias}` : ''}` : __('SqlQueryBuilder.pickTable')]
|
|
5583
|
-
}),
|
|
5857
|
+
}), store.showSubquery && jsx(Tooltip, {
|
|
5858
|
+
title: __('SqlQueryBuilder.switchSubQuery'),
|
|
5859
|
+
children: jsx(Button, {
|
|
5860
|
+
disabled: meta.readonly,
|
|
5861
|
+
primary: meta.isSubquery,
|
|
5862
|
+
ghost: true,
|
|
5863
|
+
className: cx('mr-2 operator-icon', {
|
|
5864
|
+
['subquery-icon']: !meta.isSubquery
|
|
5865
|
+
}),
|
|
5866
|
+
icon: jsx(RelatedWork, {}),
|
|
5867
|
+
onClick: switchSubQuery
|
|
5868
|
+
})
|
|
5869
|
+
}), selected && store.showFields && jsx("div", {
|
|
5584
5870
|
className: `Sqb-TableColumns`,
|
|
5585
5871
|
onClick: selectColumns,
|
|
5586
5872
|
children: __('SqlQueryBuilder.columns')
|
|
@@ -5595,33 +5881,6 @@ const TableData = props => {
|
|
|
5595
5881
|
};
|
|
5596
5882
|
|
|
5597
5883
|
const PrevResult$1 = 'Previous results';
|
|
5598
|
-
function setQuotes(_meta) {
|
|
5599
|
-
let newMeta = cloneDeep(_meta);
|
|
5600
|
-
newMeta.table1 = {
|
|
5601
|
-
...newMeta.table1,
|
|
5602
|
-
fieldAlias: newMeta.table1.fieldAlias || newMeta.table1.column,
|
|
5603
|
-
fieldUuid: newMeta.table1.fieldUuid || newMeta.table1.column_id,
|
|
5604
|
-
quotes: newMeta.table1.quotes || newMeta.table1.column
|
|
5605
|
-
};
|
|
5606
|
-
newMeta.table2 = {
|
|
5607
|
-
...newMeta.table2,
|
|
5608
|
-
fieldAlias: newMeta.table2.fieldAlias || newMeta.table2.column,
|
|
5609
|
-
fieldUuid: newMeta.table2.fieldUuid || newMeta.table2.column_id,
|
|
5610
|
-
quotes: newMeta.table2.quotes || newMeta.table2.column
|
|
5611
|
-
};
|
|
5612
|
-
newMeta.expressions = newMeta.expressions.map(v => {
|
|
5613
|
-
return {
|
|
5614
|
-
...v,
|
|
5615
|
-
left_fieldAlias: v.fieldAlias || v.left_column,
|
|
5616
|
-
left_fieldUuid: v.fieldUuid || v.left_column_id,
|
|
5617
|
-
left_quotes: v.left_quotes || v.left_column,
|
|
5618
|
-
right_fieldAlias: v.right_fieldAlias || v.right_column,
|
|
5619
|
-
right_fieldUuid: v.right_fieldUuid || v.right_column_id,
|
|
5620
|
-
right_quotes: v.right_quotes || v.right_column
|
|
5621
|
-
};
|
|
5622
|
-
});
|
|
5623
|
-
return newMeta;
|
|
5624
|
-
}
|
|
5625
5884
|
var FlagLocation;
|
|
5626
5885
|
(function (FlagLocation) {
|
|
5627
5886
|
FlagLocation["TABLE_1"] = "table1";
|
|
@@ -5646,11 +5905,11 @@ const JoinData = props => {
|
|
|
5646
5905
|
let table2Selected = Boolean(meta.table2.name);
|
|
5647
5906
|
let subQuerySelected = Boolean(meta.subquery?.[0]?.table?.name);
|
|
5648
5907
|
let columnsSelected = meta.table1.quotes && meta.table2.quotes;
|
|
5649
|
-
useEffect(() => {
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
}, []);
|
|
5908
|
+
// useEffect(() => {
|
|
5909
|
+
// let newMetaList = store.metaList[groupIndex].list.slice();
|
|
5910
|
+
// newMetaList[index] = setQuotes(meta);
|
|
5911
|
+
// store.setMeta(newMetaList, groupIndex);
|
|
5912
|
+
// }, []);
|
|
5654
5913
|
function selectColumns(e) {
|
|
5655
5914
|
let columns = meta.columns;
|
|
5656
5915
|
!meta.readonly && store.setPopup({
|
|
@@ -5887,7 +6146,8 @@ const JoinData = props => {
|
|
|
5887
6146
|
id = '',
|
|
5888
6147
|
fieldAlias = '',
|
|
5889
6148
|
fieldUuid = '',
|
|
5890
|
-
quotes
|
|
6149
|
+
quotes,
|
|
6150
|
+
tableUuid
|
|
5891
6151
|
} = record;
|
|
5892
6152
|
let newMeta = store.metaList[groupIndex].list.slice();
|
|
5893
6153
|
if (alias === SummarizeAlias$1) {
|
|
@@ -5903,6 +6163,7 @@ const JoinData = props => {
|
|
|
5903
6163
|
if (newMeta[index][type].alias !== alias) {
|
|
5904
6164
|
newMeta[index][type].alias = alias;
|
|
5905
6165
|
newMeta[index][type].name = table;
|
|
6166
|
+
newMeta[index][type].tableUuid = tableUuid;
|
|
5906
6167
|
newMeta[index][type].datasourceId = datasourceId;
|
|
5907
6168
|
newMeta[index][type].datasourceName = datasourceName;
|
|
5908
6169
|
newMeta[index].expressions = [];
|
|
@@ -6150,11 +6411,9 @@ const JoinData = props => {
|
|
|
6150
6411
|
let oldList = cloneDeep(newMeta[index].subquery);
|
|
6151
6412
|
let _toolbar = subToolbar || toolbar;
|
|
6152
6413
|
_toolbar = _toolbar.filter(v => v !== 'group'); // 子查询不需要分组
|
|
6153
|
-
let zIndex = store.popupContainer.current ? getMaxZIndexInParents(store.popupContainer.current) : 0;
|
|
6154
6414
|
let o = Modal2.openModal({
|
|
6155
6415
|
title: __('SqlQueryBuilder.subquery'),
|
|
6156
6416
|
transparentMask: true,
|
|
6157
|
-
zIndex: Number(zIndex),
|
|
6158
6417
|
content: jsx(Fragment, {
|
|
6159
6418
|
children: jsx(SqlVisionBuilder, {
|
|
6160
6419
|
...other,
|
|
@@ -6172,13 +6431,14 @@ const JoinData = props => {
|
|
|
6172
6431
|
newMeta[index].subquery = newList;
|
|
6173
6432
|
newMeta[index].table2 = {
|
|
6174
6433
|
...newList[0].table,
|
|
6175
|
-
|
|
6176
|
-
fieldUuid: ''
|
|
6434
|
+
alias: newMeta[index].table2.alias || newList[0].table.name + '_' + groupIndex + '_' + index
|
|
6177
6435
|
};
|
|
6178
6436
|
const items = getSubColumns(newList);
|
|
6179
6437
|
const newColumns = items.flatMap(item => item.columns);
|
|
6180
6438
|
newMeta[index].columns = newColumns;
|
|
6181
6439
|
newMeta[index].expressions = [];
|
|
6440
|
+
// 关联表变了 下面模块全部删除
|
|
6441
|
+
newMeta = newMeta.filter((v, i) => i <= index);
|
|
6182
6442
|
store.setMeta(newMeta, groupIndex);
|
|
6183
6443
|
o.close();
|
|
6184
6444
|
} catch (e) {
|
|
@@ -6229,12 +6489,17 @@ const JoinData = props => {
|
|
|
6229
6489
|
alias = val;
|
|
6230
6490
|
}
|
|
6231
6491
|
}),
|
|
6232
|
-
onOk: () => {
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6492
|
+
onOk: async () => {
|
|
6493
|
+
if (!alias) {
|
|
6494
|
+
Toast.warning(__('SqlQueryBuilder.aliasCannotEmpty'));
|
|
6495
|
+
return false;
|
|
6496
|
+
} else {
|
|
6497
|
+
let index = findIndex(store.metaList[groupIndex].list, meta);
|
|
6498
|
+
let newMeta = store.metaList[groupIndex].list.slice();
|
|
6499
|
+
newMeta[index].table2.alias = alias;
|
|
6500
|
+
newMeta = changeTableAlias(newMeta, newMeta[index].table2);
|
|
6501
|
+
store.setMeta(newMeta, groupIndex);
|
|
6502
|
+
}
|
|
6238
6503
|
},
|
|
6239
6504
|
onCancel: () => {}
|
|
6240
6505
|
});
|
|
@@ -6293,7 +6558,7 @@ const JoinData = props => {
|
|
|
6293
6558
|
onChangeTableAlias(meta.table2?.alias || '');
|
|
6294
6559
|
}
|
|
6295
6560
|
})
|
|
6296
|
-
}), subQuerySelected ? `${meta.subquery?.[0].table.datasourceName}.${meta.subquery?.[0].table.name} ${meta.table2?.alias ? `as ${meta.table2?.alias}` : ''} ` : __('SqlQueryBuilder.setSubQuery')]
|
|
6561
|
+
}), subQuerySelected ? `${(meta.subquery?.[0]).table.datasourceName}.${(meta.subquery?.[0]).table.name} ${meta.table2?.alias ? `as ${meta.table2?.alias}` : ''} ` : __('SqlQueryBuilder.setSubQuery')]
|
|
6297
6562
|
}) : jsxs("div", {
|
|
6298
6563
|
className: cx(`Sqb-TableName`, {
|
|
6299
6564
|
notSelected: !table2Selected
|
|
@@ -6463,7 +6728,7 @@ const JoinData = props => {
|
|
|
6463
6728
|
right_fieldUuid: '',
|
|
6464
6729
|
right_quotes: '',
|
|
6465
6730
|
right_string: '',
|
|
6466
|
-
right_isString: false,
|
|
6731
|
+
// right_isString: false,
|
|
6467
6732
|
right_type: 'field',
|
|
6468
6733
|
right_constant: ''
|
|
6469
6734
|
});
|
|
@@ -6509,7 +6774,7 @@ const JoinData = props => {
|
|
|
6509
6774
|
right_fieldUuid: '',
|
|
6510
6775
|
right_quotes: '',
|
|
6511
6776
|
right_string: '',
|
|
6512
|
-
right_isString: false,
|
|
6777
|
+
// right_isString: false,
|
|
6513
6778
|
right_constant: '',
|
|
6514
6779
|
right_type: 'field'
|
|
6515
6780
|
}];
|
|
@@ -7200,11 +7465,9 @@ const CustomColumn = props => {
|
|
|
7200
7465
|
const showSubQuery = (e, i) => {
|
|
7201
7466
|
let newMeta = store.metaList[groupIndex].list.slice();
|
|
7202
7467
|
const _value = newMeta[index].customColumn[i] || [];
|
|
7203
|
-
let zIndex = store.popupContainer.current ? getMaxZIndexInParents(store.popupContainer.current) : 0;
|
|
7204
7468
|
let o = Modal2.openModal({
|
|
7205
7469
|
title: __('SqlQueryBuilder.customExpression'),
|
|
7206
7470
|
transparentMask: true,
|
|
7207
|
-
zIndex: Number(zIndex),
|
|
7208
7471
|
content: jsx(Fragment, {
|
|
7209
7472
|
children: jsx(Provider, {
|
|
7210
7473
|
value: store,
|
|
@@ -7358,6 +7621,9 @@ const Filter = props => {
|
|
|
7358
7621
|
let {
|
|
7359
7622
|
filter
|
|
7360
7623
|
} = meta;
|
|
7624
|
+
const {
|
|
7625
|
+
notExistsColumns
|
|
7626
|
+
} = store.preProps;
|
|
7361
7627
|
React__default.useRef(null);
|
|
7362
7628
|
let index = findIndex(store.metaList[groupIndex].list, meta);
|
|
7363
7629
|
let notSelected = !meta.filter.length;
|
|
@@ -7467,7 +7733,7 @@ const Filter = props => {
|
|
|
7467
7733
|
showNotExists(i, '');
|
|
7468
7734
|
return;
|
|
7469
7735
|
}
|
|
7470
|
-
let data = getColumns();
|
|
7736
|
+
let data = [...getColumns(), ...cloneDeep(notExistsColumns || [])];
|
|
7471
7737
|
store.setPopup({
|
|
7472
7738
|
visible: true,
|
|
7473
7739
|
node: e.currentTarget,
|
|
@@ -7485,8 +7751,8 @@ const Filter = props => {
|
|
|
7485
7751
|
function handleAdd(e) {
|
|
7486
7752
|
let node = e.currentTarget;
|
|
7487
7753
|
let newMeta = store.metaList[groupIndex].list.slice();
|
|
7488
|
-
let data = getColumns();
|
|
7489
|
-
let _index = node.getAttribute('v-index');
|
|
7754
|
+
let data = [...getColumns(), ...cloneDeep(notExistsColumns || [])];
|
|
7755
|
+
let _index = Number(node.getAttribute('v-index'));
|
|
7490
7756
|
let _type = node.getAttribute('v-type');
|
|
7491
7757
|
let value = {
|
|
7492
7758
|
table: '',
|
|
@@ -7522,15 +7788,16 @@ const Filter = props => {
|
|
|
7522
7788
|
content: jsx(SelectFilter, {
|
|
7523
7789
|
data: data,
|
|
7524
7790
|
value: value,
|
|
7525
|
-
onChange:
|
|
7791
|
+
onChange: val => {
|
|
7526
7792
|
if (_type) {
|
|
7527
7793
|
if (_type === 'before') {
|
|
7528
|
-
newMeta[index].filter.splice(_index, 0,
|
|
7794
|
+
newMeta[index].filter.splice(_index, 0, val);
|
|
7529
7795
|
} else {
|
|
7530
|
-
newMeta[index].filter
|
|
7796
|
+
console.log('🚀 ~ ', newMeta[index].filter);
|
|
7797
|
+
newMeta[index].filter.splice(_index + 1, 0, val);
|
|
7531
7798
|
}
|
|
7532
7799
|
} else {
|
|
7533
|
-
newMeta[index].filter.push(
|
|
7800
|
+
newMeta[index].filter.push(val);
|
|
7534
7801
|
}
|
|
7535
7802
|
store.setMeta(newMeta, groupIndex);
|
|
7536
7803
|
closePopup();
|
|
@@ -7572,18 +7839,18 @@ const Filter = props => {
|
|
|
7572
7839
|
} = store.preProps;
|
|
7573
7840
|
let newMeta = store.metaList[groupIndex].list.slice();
|
|
7574
7841
|
let index = findIndex(store.metaList[groupIndex].list, meta);
|
|
7575
|
-
let _value = position ? [] : newMeta[index].filter[i]?.
|
|
7576
|
-
let oldList = position ? [] : cloneDeep(newMeta[index].filter[i]?.
|
|
7842
|
+
let _value = position ? [] : newMeta[index].filter[i]?.notExists || [];
|
|
7843
|
+
let oldList = position ? [] : cloneDeep(newMeta[index].filter[i]?.notExists || []);
|
|
7577
7844
|
let _toolbar = notExistsToolbar || toolbar;
|
|
7578
7845
|
_toolbar = _toolbar.filter(v => v !== 'group'); // 子查询不需要分组
|
|
7579
|
-
let
|
|
7846
|
+
let notExistsColumns = getColumns();
|
|
7580
7847
|
let o = Modal2.openModal({
|
|
7581
7848
|
title: 'NOT EXISTS',
|
|
7582
7849
|
transparentMask: true,
|
|
7583
|
-
zIndex: Number(zIndex),
|
|
7584
7850
|
content: jsx(Fragment, {
|
|
7585
7851
|
children: jsx(SqlVisionBuilder, {
|
|
7586
7852
|
...other,
|
|
7853
|
+
notExistsColumns: notExistsColumns,
|
|
7587
7854
|
showFields: false,
|
|
7588
7855
|
showSubquery: false,
|
|
7589
7856
|
toolbar: _toolbar,
|
|
@@ -7597,8 +7864,8 @@ const Filter = props => {
|
|
|
7597
7864
|
return;
|
|
7598
7865
|
}
|
|
7599
7866
|
const _tem = {
|
|
7600
|
-
|
|
7601
|
-
quotes:
|
|
7867
|
+
notExists: newList,
|
|
7868
|
+
quotes: buildSqlQuery(newList),
|
|
7602
7869
|
condition: '',
|
|
7603
7870
|
table: '',
|
|
7604
7871
|
tableId: '',
|
|
@@ -7784,7 +8051,7 @@ const Filter = props => {
|
|
|
7784
8051
|
if (typeof v === 'string') {
|
|
7785
8052
|
return v;
|
|
7786
8053
|
} else if (v.type === Filter_TypeEnum.NOT_EXISTS) {
|
|
7787
|
-
return
|
|
8054
|
+
return `${buildSqlQuery(v.notExists)}`;
|
|
7788
8055
|
} else {
|
|
7789
8056
|
return v.quotes;
|
|
7790
8057
|
}
|
|
@@ -7919,7 +8186,7 @@ const GroupBy = props => {
|
|
|
7919
8186
|
const fieldAlias = `${v.alias}__${v.name}`;
|
|
7920
8187
|
return {
|
|
7921
8188
|
...v,
|
|
7922
|
-
sql: `${v.alias}.${v.realName || v.name}
|
|
8189
|
+
sql: `${v.alias}.${v.realName || v.name}`,
|
|
7923
8190
|
fieldAlias: fieldAlias
|
|
7924
8191
|
};
|
|
7925
8192
|
});
|
|
@@ -7971,7 +8238,7 @@ const GroupBy = props => {
|
|
|
7971
8238
|
const fieldAlias = `${v.alias}__${v.name}`;
|
|
7972
8239
|
return {
|
|
7973
8240
|
...v,
|
|
7974
|
-
sql: `${v.alias}.${v.realName || v.name}
|
|
8241
|
+
sql: `${v.alias}.${v.realName || v.name}`,
|
|
7975
8242
|
fieldAlias: fieldAlias,
|
|
7976
8243
|
fieldUuid: uuidv4('field'),
|
|
7977
8244
|
summarizeType: MetaSummarize_Enum.BY
|
|
@@ -8169,6 +8436,7 @@ const SelectIndex = props => {
|
|
|
8169
8436
|
content: jsx(SelectSummarize, {
|
|
8170
8437
|
data: data,
|
|
8171
8438
|
value: value,
|
|
8439
|
+
ignoreGroupByType: store.ignoreGroupByType,
|
|
8172
8440
|
onChange: data => {
|
|
8173
8441
|
//@ts-ignore
|
|
8174
8442
|
newMeta[index].group.splice(i, 1, data);
|
|
@@ -8222,6 +8490,7 @@ const SelectIndex = props => {
|
|
|
8222
8490
|
content: jsx(SelectSummarize, {
|
|
8223
8491
|
data: data,
|
|
8224
8492
|
value: value,
|
|
8493
|
+
ignoreGroupByType: store.ignoreGroupByType,
|
|
8225
8494
|
onChange: data => {
|
|
8226
8495
|
// @ts-ignore
|
|
8227
8496
|
newMeta[index].group.push(data);
|
|
@@ -8455,8 +8724,8 @@ const Sort = props => {
|
|
|
8455
8724
|
let value = {
|
|
8456
8725
|
table: '',
|
|
8457
8726
|
tableId: '',
|
|
8458
|
-
tableUuid:
|
|
8459
|
-
fieldUuid:
|
|
8727
|
+
tableUuid: '',
|
|
8728
|
+
fieldUuid: '',
|
|
8460
8729
|
fieldAlias: '',
|
|
8461
8730
|
alias: '',
|
|
8462
8731
|
name: '',
|
|
@@ -8815,7 +9084,6 @@ const Metabase = props => {
|
|
|
8815
9084
|
await onOk?.(_metaList);
|
|
8816
9085
|
setSaveLoading(false);
|
|
8817
9086
|
};
|
|
8818
|
-
let zIndex = store.popupContainer.current ? getMaxZIndexInParents(store.popupContainer.current) : null;
|
|
8819
9087
|
return (
|
|
8820
9088
|
// @ts-ignore
|
|
8821
9089
|
jsx(VisualBox, {
|
|
@@ -8861,7 +9129,6 @@ const Metabase = props => {
|
|
|
8861
9129
|
visible: store.popupData.visible,
|
|
8862
9130
|
node: store.popupData.node,
|
|
8863
9131
|
closable: store.popupClosable,
|
|
8864
|
-
zIndex: zIndex ? String(zIndex) : null,
|
|
8865
9132
|
hideVisible: () => {
|
|
8866
9133
|
store.setPopup({
|
|
8867
9134
|
visible: false
|
|
@@ -8873,7 +9140,6 @@ const Metabase = props => {
|
|
|
8873
9140
|
visible: store.popupData2.visible,
|
|
8874
9141
|
node: store.popupData2.node,
|
|
8875
9142
|
closable: store.popupClosable2,
|
|
8876
|
-
zIndex: zIndex ? String(zIndex) : null,
|
|
8877
9143
|
hideVisible: () => {
|
|
8878
9144
|
store.setClosable(true);
|
|
8879
9145
|
store.setPopup2({
|
|
@@ -8907,7 +9173,8 @@ const SqlVisionBuilder = /*#__PURE__*/React__default.forwardRef((props, ref) =>
|
|
|
8907
9173
|
showSubquery = true,
|
|
8908
9174
|
// 是否展示子查询
|
|
8909
9175
|
subShowSubquery = false,
|
|
8910
|
-
constantList
|
|
9176
|
+
constantList,
|
|
9177
|
+
ignoreGroupByType = false
|
|
8911
9178
|
} = props;
|
|
8912
9179
|
const store = useStore();
|
|
8913
9180
|
useEffect(() => {
|
|
@@ -8932,7 +9199,8 @@ const SqlVisionBuilder = /*#__PURE__*/React__default.forwardRef((props, ref) =>
|
|
|
8932
9199
|
store.setShowSubquery(showSubquery);
|
|
8933
9200
|
store._setShowSubquery(subShowSubquery);
|
|
8934
9201
|
store.setConstantList(constantList || []);
|
|
8935
|
-
|
|
9202
|
+
store.setIgnoreGroupByType(ignoreGroupByType);
|
|
9203
|
+
}, [showFields, fieldNameTpl, tableNameTpl, toolbar, showSubquery, subShowSubquery, constantList, ignoreGroupByType]);
|
|
8936
9204
|
React__default.useImperativeHandle(ref, () => ({
|
|
8937
9205
|
// setDatasource: (list) => {
|
|
8938
9206
|
// store.setSourceList(list);
|