@gingkoo/pandora-metabase 1.0.0-alpha.8 → 1.0.0
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/lib/es/index.js +566 -321
- package/lib/es/index.js.map +1 -1
- package/lib/es/store/types.d.ts +6 -4
- package/lib/es/types.d.ts +2 -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,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @gingkoo/pandora-metabase v1.0.0
|
|
2
|
+
* @gingkoo/pandora-metabase v1.0.0
|
|
3
3
|
*/
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import * as React from 'react';
|
|
@@ -8,12 +8,12 @@ import cloneDeep from 'lodash/cloneDeep';
|
|
|
8
8
|
import cx from 'classnames';
|
|
9
9
|
import { Tooltip, Button, Modal, Input, DatePicker, Dropdown, InputNumber, Select, Modal2, Toast } 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';
|
|
@@ -1074,7 +1258,7 @@ const useStore = () => {
|
|
|
1074
1258
|
};
|
|
1075
1259
|
// 是否显示主表后面的字段按钮 (如果下面 没有聚合,或者选了聚合但是聚合里面没有选值的时候显示 主表字段按钮)
|
|
1076
1260
|
const showMainColumn = useMemo(() => {
|
|
1077
|
-
return metaList
|
|
1261
|
+
return metaList?.map((item, groupIndex) => {
|
|
1078
1262
|
// 过滤出所有汇总类型的项
|
|
1079
1263
|
const summarizeItems = item.list.filter(v => v.type === TypeEnum.summarize);
|
|
1080
1264
|
// 如果没有汇总项,默认显示主列
|
|
@@ -1129,7 +1313,7 @@ const useStore = () => {
|
|
|
1129
1313
|
columns = await fetchColumnsFn.current(extra, datasourceId);
|
|
1130
1314
|
setColumns(tableName, columns);
|
|
1131
1315
|
}
|
|
1132
|
-
const _columns = columns
|
|
1316
|
+
const _columns = columns?.map(v => {
|
|
1133
1317
|
return {
|
|
1134
1318
|
...v,
|
|
1135
1319
|
fieldUuid: v.fieldAlias || uuidv4('field')
|
|
@@ -1143,21 +1327,56 @@ const useStore = () => {
|
|
|
1143
1327
|
_setMeta(newMeta);
|
|
1144
1328
|
};
|
|
1145
1329
|
// 回显
|
|
1146
|
-
|
|
1330
|
+
// 设置column
|
|
1331
|
+
const setQuotes = newMeta => {
|
|
1332
|
+
newMeta.table1 = {
|
|
1333
|
+
...newMeta.table1,
|
|
1334
|
+
fieldAlias: newMeta.table1.fieldAlias || newMeta.table1.column,
|
|
1335
|
+
fieldUuid: newMeta.table1.fieldUuid || uuidv4('field'),
|
|
1336
|
+
quotes: newMeta.table1.quotes || newMeta.table1.column,
|
|
1337
|
+
tableUuid: newMeta.table1.tableUuid || uuidv4('table')
|
|
1338
|
+
};
|
|
1339
|
+
newMeta.table2 = {
|
|
1340
|
+
...newMeta.table2,
|
|
1341
|
+
fieldAlias: newMeta.table2.fieldAlias || newMeta.table2.column,
|
|
1342
|
+
fieldUuid: newMeta.table2.fieldUuid || uuidv4('field'),
|
|
1343
|
+
quotes: newMeta.table2.quotes || newMeta.table2.column,
|
|
1344
|
+
tableUuid: newMeta.table2.tableUuid || uuidv4('table')
|
|
1345
|
+
};
|
|
1346
|
+
newMeta.expressions = newMeta.expressions?.map(v => {
|
|
1347
|
+
return {
|
|
1348
|
+
...v,
|
|
1349
|
+
left_fieldAlias: v.left_fieldAlias || v.left_column,
|
|
1350
|
+
left_fieldUuid: v.left_fieldUuid || uuidv4('field'),
|
|
1351
|
+
left_quotes: v.left_quotes || v.left_column,
|
|
1352
|
+
right_fieldAlias: v.right_fieldAlias || v.right_column,
|
|
1353
|
+
right_fieldUuid: v.right_fieldUuid || uuidv4('field'),
|
|
1354
|
+
right_quotes: v.right_quotes || v.right_column
|
|
1355
|
+
};
|
|
1356
|
+
});
|
|
1357
|
+
return newMeta;
|
|
1358
|
+
};
|
|
1359
|
+
const setPreData = data => {
|
|
1147
1360
|
if (data.length) {
|
|
1148
|
-
let _metaList = data
|
|
1361
|
+
let _metaList = data?.map((item, groupIndex) => {
|
|
1149
1362
|
let newList = item.list?.map((v, i) => {
|
|
1150
|
-
let newMeta =
|
|
1363
|
+
let newMeta = item.list;
|
|
1364
|
+
if (v.table) {
|
|
1365
|
+
v.table.tableUuid = v.table.tableUuid || uuidv4('table');
|
|
1366
|
+
}
|
|
1367
|
+
if (v.type === TypeEnum.joinData) {
|
|
1368
|
+
newMeta[i] = setQuotes(newMeta[i]);
|
|
1369
|
+
}
|
|
1151
1370
|
// 设置右侧column
|
|
1152
1371
|
if (v.table2?.datasourceId && v.columns.length < 1) {
|
|
1153
|
-
fetchColumns(newMeta[i].table2, newMeta[i].table2.datasourceId, columns => {
|
|
1372
|
+
fetchColumns(newMeta[i].table2, newMeta[i].table2.datasourceId, (columns = []) => {
|
|
1154
1373
|
if (v.isSubquery) {
|
|
1155
1374
|
let newColumns = [];
|
|
1156
1375
|
const items = getSubColumns(v.subquery);
|
|
1157
|
-
newColumns = items
|
|
1158
|
-
newMeta[i].columns = newColumns;
|
|
1376
|
+
newColumns = items?.flatMap(item => item.columns);
|
|
1377
|
+
newMeta[i].columns = newColumns || [];
|
|
1159
1378
|
} else {
|
|
1160
|
-
newMeta[i].columns = columns;
|
|
1379
|
+
newMeta[i].columns = columns || [];
|
|
1161
1380
|
}
|
|
1162
1381
|
setMeta(newMeta, groupIndex);
|
|
1163
1382
|
});
|
|
@@ -1167,15 +1386,18 @@ const useStore = () => {
|
|
|
1167
1386
|
}
|
|
1168
1387
|
// 设置column
|
|
1169
1388
|
if (v.table?.datasourceId && v.columns.length < 1) {
|
|
1170
|
-
fetchColumns(newMeta[i].table, newMeta[i].table.datasourceId, columns => {
|
|
1389
|
+
fetchColumns(newMeta[i].table, newMeta[i].table.datasourceId, (columns = []) => {
|
|
1171
1390
|
if (v.isSubquery) {
|
|
1172
1391
|
let newColumns = [];
|
|
1173
1392
|
const items = getSubColumns(v.subquery);
|
|
1174
1393
|
newColumns = items.flatMap(item => item.columns);
|
|
1175
|
-
newMeta[i].columns = newColumns;
|
|
1394
|
+
newMeta[i].columns = newColumns || [];
|
|
1176
1395
|
} else {
|
|
1177
|
-
newMeta[i].columns = columns;
|
|
1396
|
+
newMeta[i].columns = columns || [];
|
|
1178
1397
|
}
|
|
1398
|
+
// if (v.type === TypeEnum.joinData) {
|
|
1399
|
+
// newMeta[i] = setQuotes(newMeta[i]);
|
|
1400
|
+
// }
|
|
1179
1401
|
setMeta(newMeta, groupIndex);
|
|
1180
1402
|
});
|
|
1181
1403
|
return {
|
|
@@ -1349,7 +1571,7 @@ const useStore = () => {
|
|
|
1349
1571
|
setMeta(_metaList, groupIndex);
|
|
1350
1572
|
};
|
|
1351
1573
|
const setColumns = (tableId, columns) => {
|
|
1352
|
-
const _columns = columns
|
|
1574
|
+
const _columns = columns?.map(v => {
|
|
1353
1575
|
return {
|
|
1354
1576
|
...v,
|
|
1355
1577
|
fieldUuid: v.fieldUuid || uuidv4('field')
|
|
@@ -1374,46 +1596,10 @@ const useStore = () => {
|
|
|
1374
1596
|
const getDataset = datasourceId => {
|
|
1375
1597
|
return _cacheSource2TableMap[datasourceId] || [];
|
|
1376
1598
|
};
|
|
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
1599
|
const reset = () => {
|
|
1414
1600
|
// setSourceList([]);
|
|
1415
1601
|
_setMeta(defaultMeta);
|
|
1416
|
-
setToolbar(defaultToolbar);
|
|
1602
|
+
// setToolbar(defaultToolbar);
|
|
1417
1603
|
set_cacheSource2TableMap({});
|
|
1418
1604
|
set_cacheColumnsMap({});
|
|
1419
1605
|
};
|
|
@@ -1467,41 +1653,10 @@ const useStore = () => {
|
|
|
1467
1653
|
_setShowSubquery,
|
|
1468
1654
|
constantList,
|
|
1469
1655
|
setConstantList,
|
|
1470
|
-
changeAlias,
|
|
1471
1656
|
popupContainer
|
|
1472
1657
|
};
|
|
1473
1658
|
};
|
|
1474
1659
|
|
|
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
1660
|
register('en', {
|
|
1506
1661
|
'data.pleaseSelectDataTable': 'please select data table',
|
|
1507
1662
|
'data.calculatingNow': 'calculating now...',
|
|
@@ -1838,111 +1993,9 @@ const Loading = ({
|
|
|
1838
1993
|
});
|
|
1839
1994
|
};
|
|
1840
1995
|
|
|
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";
|
|
1996
|
+
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
1997
|
styleInject(css_248z$d);
|
|
1843
1998
|
|
|
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
1999
|
const Wrapper = ({
|
|
1947
2000
|
children,
|
|
1948
2001
|
className
|
|
@@ -2114,13 +2167,13 @@ const LeftJoinIcon = ({
|
|
|
2114
2167
|
})
|
|
2115
2168
|
});
|
|
2116
2169
|
const InnerJoinIcon = ({
|
|
2117
|
-
width:
|
|
2118
|
-
height:
|
|
2170
|
+
width: _width10 = 32,
|
|
2171
|
+
height: _height10 = 32,
|
|
2119
2172
|
style
|
|
2120
2173
|
}) => jsx("svg", {
|
|
2121
2174
|
viewBox: '0 0 32 32',
|
|
2122
|
-
width:
|
|
2123
|
-
height:
|
|
2175
|
+
width: _width10,
|
|
2176
|
+
height: _height10,
|
|
2124
2177
|
fill: 'currentcolor',
|
|
2125
2178
|
role: 'img',
|
|
2126
2179
|
"aria-label": 'join_inner icon',
|
|
@@ -2130,13 +2183,13 @@ const InnerJoinIcon = ({
|
|
|
2130
2183
|
})
|
|
2131
2184
|
});
|
|
2132
2185
|
const UpArrowIcon = ({
|
|
2133
|
-
width:
|
|
2134
|
-
height:
|
|
2186
|
+
width: _width11 = 16,
|
|
2187
|
+
height: _height11 = 17
|
|
2135
2188
|
}) => jsx("svg", {
|
|
2136
2189
|
className: 'sort-arrow',
|
|
2137
2190
|
viewBox: '0 0 32 34',
|
|
2138
|
-
width:
|
|
2139
|
-
height:
|
|
2191
|
+
width: _width11,
|
|
2192
|
+
height: _height11,
|
|
2140
2193
|
fill: 'currentcolor',
|
|
2141
2194
|
role: 'img',
|
|
2142
2195
|
"aria-label": 'arrow_up icon',
|
|
@@ -2145,13 +2198,13 @@ const UpArrowIcon = ({
|
|
|
2145
2198
|
})
|
|
2146
2199
|
});
|
|
2147
2200
|
const DownArrowIcon = ({
|
|
2148
|
-
width:
|
|
2149
|
-
height:
|
|
2201
|
+
width: _width12 = 16,
|
|
2202
|
+
height: _height12 = 17
|
|
2150
2203
|
}) => jsx("svg", {
|
|
2151
2204
|
className: 'sort-arrow',
|
|
2152
2205
|
viewBox: '0 0 32 34',
|
|
2153
|
-
width:
|
|
2154
|
-
height:
|
|
2206
|
+
width: _width12,
|
|
2207
|
+
height: _height12,
|
|
2155
2208
|
fill: 'currentcolor',
|
|
2156
2209
|
role: 'img',
|
|
2157
2210
|
"aria-label": 'arrow_down icon',
|
|
@@ -2160,13 +2213,13 @@ const DownArrowIcon = ({
|
|
|
2160
2213
|
})
|
|
2161
2214
|
});
|
|
2162
2215
|
const CloseIcon = ({
|
|
2163
|
-
width:
|
|
2164
|
-
height:
|
|
2216
|
+
width: _width13 = 16,
|
|
2217
|
+
height: _height13 = 16
|
|
2165
2218
|
}) => jsx("svg", {
|
|
2166
2219
|
className: 'closeIcon',
|
|
2167
2220
|
viewBox: '0 0 32 32',
|
|
2168
|
-
width:
|
|
2169
|
-
height:
|
|
2221
|
+
width: _width13,
|
|
2222
|
+
height: _height13,
|
|
2170
2223
|
fill: 'currentcolor',
|
|
2171
2224
|
role: 'img',
|
|
2172
2225
|
"aria-label": 'close icon',
|
|
@@ -2175,12 +2228,12 @@ const CloseIcon = ({
|
|
|
2175
2228
|
})
|
|
2176
2229
|
});
|
|
2177
2230
|
const AddIcon = ({
|
|
2178
|
-
width:
|
|
2179
|
-
height:
|
|
2231
|
+
width: _width14 = 16,
|
|
2232
|
+
height: _height14 = 16
|
|
2180
2233
|
}) => jsx("svg", {
|
|
2181
2234
|
viewBox: '0 0 32 32',
|
|
2182
|
-
width:
|
|
2183
|
-
height:
|
|
2235
|
+
width: _width14,
|
|
2236
|
+
height: _height14,
|
|
2184
2237
|
fill: 'currentcolor',
|
|
2185
2238
|
role: 'img',
|
|
2186
2239
|
"aria-label": 'add icon',
|
|
@@ -2189,12 +2242,12 @@ const AddIcon = ({
|
|
|
2189
2242
|
})
|
|
2190
2243
|
});
|
|
2191
2244
|
const TableIcon = ({
|
|
2192
|
-
width:
|
|
2193
|
-
height:
|
|
2245
|
+
width: _width15 = 18,
|
|
2246
|
+
height: _height15 = 18
|
|
2194
2247
|
}) => jsx("svg", {
|
|
2195
2248
|
viewBox: '0 0 32 32',
|
|
2196
|
-
width:
|
|
2197
|
-
height:
|
|
2249
|
+
width: _width15,
|
|
2250
|
+
height: _height15,
|
|
2198
2251
|
fill: 'currentcolor',
|
|
2199
2252
|
role: 'img',
|
|
2200
2253
|
"aria-label": 'table2 icon',
|
|
@@ -2203,12 +2256,12 @@ const TableIcon = ({
|
|
|
2203
2256
|
})
|
|
2204
2257
|
});
|
|
2205
2258
|
const SearchIcon = ({
|
|
2206
|
-
width:
|
|
2207
|
-
height:
|
|
2259
|
+
width: _width16 = 16,
|
|
2260
|
+
height: _height16 = 16
|
|
2208
2261
|
}) => jsx("svg", {
|
|
2209
2262
|
viewBox: '0 0 32 32',
|
|
2210
|
-
width:
|
|
2211
|
-
height:
|
|
2263
|
+
width: _width16,
|
|
2264
|
+
height: _height16,
|
|
2212
2265
|
fill: 'currentcolor',
|
|
2213
2266
|
role: 'img',
|
|
2214
2267
|
"aria-label": 'search icon',
|
|
@@ -3427,6 +3480,87 @@ class TokenizedInput extends React__default.Component {
|
|
|
3427
3480
|
}
|
|
3428
3481
|
}
|
|
3429
3482
|
|
|
3483
|
+
// 获取元素translate x y值
|
|
3484
|
+
const getComputedTranslate = obj => {
|
|
3485
|
+
if (!window.getComputedStyle) return {
|
|
3486
|
+
x: 0,
|
|
3487
|
+
y: 0
|
|
3488
|
+
};
|
|
3489
|
+
var style = getComputedStyle(obj),
|
|
3490
|
+
transform = style.transform || style.webkitTransform || style.mozTransform;
|
|
3491
|
+
var mat = transform.match(/^matrix3d\((.+)\)$/);
|
|
3492
|
+
if (mat) {
|
|
3493
|
+
return {
|
|
3494
|
+
x: parseFloat(mat[1].split(', ')[12]),
|
|
3495
|
+
y: parseFloat(mat[1].split(', ')[13])
|
|
3496
|
+
};
|
|
3497
|
+
}
|
|
3498
|
+
mat = transform.match(/^matrix\((.+)\)$/);
|
|
3499
|
+
if (mat) {
|
|
3500
|
+
return {
|
|
3501
|
+
x: parseFloat(mat[1].split(', ')[4]),
|
|
3502
|
+
y: parseFloat(mat[1].split(', ')[5])
|
|
3503
|
+
};
|
|
3504
|
+
}
|
|
3505
|
+
return {
|
|
3506
|
+
x: 0,
|
|
3507
|
+
y: 0
|
|
3508
|
+
};
|
|
3509
|
+
};
|
|
3510
|
+
// 获取元素距离浏览器顶部的距离
|
|
3511
|
+
const getElementTop = elem => {
|
|
3512
|
+
if (!elem) return 0;
|
|
3513
|
+
let elemTop = elem.offsetTop;
|
|
3514
|
+
let pElem = elem.offsetParent;
|
|
3515
|
+
while (pElem != null) {
|
|
3516
|
+
elemTop += pElem.offsetTop;
|
|
3517
|
+
if (pElem.style.transform) {
|
|
3518
|
+
elemTop += getComputedTranslate(pElem).y;
|
|
3519
|
+
}
|
|
3520
|
+
pElem = pElem.offsetParent;
|
|
3521
|
+
}
|
|
3522
|
+
return elemTop;
|
|
3523
|
+
};
|
|
3524
|
+
// 获取元素距离浏览器顶部的距离
|
|
3525
|
+
const getElementLeft = elem => {
|
|
3526
|
+
if (!elem) return 0;
|
|
3527
|
+
let elemLeft = elem.offsetLeft;
|
|
3528
|
+
let pElem = elem.offsetParent;
|
|
3529
|
+
while (pElem != null) {
|
|
3530
|
+
elemLeft += pElem.offsetLeft;
|
|
3531
|
+
if (pElem.style.transform) {
|
|
3532
|
+
elemLeft += getComputedTranslate(pElem).x;
|
|
3533
|
+
}
|
|
3534
|
+
pElem = pElem.offsetParent;
|
|
3535
|
+
}
|
|
3536
|
+
return elemLeft;
|
|
3537
|
+
};
|
|
3538
|
+
// 获取元素可见范围内高度
|
|
3539
|
+
const getContainerVisibleHeight = container => {
|
|
3540
|
+
if (!container) return 0;
|
|
3541
|
+
const rect = container.getBoundingClientRect();
|
|
3542
|
+
const windowHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
3543
|
+
// 元素顶部在视口上方 -> 不可见
|
|
3544
|
+
if (rect.bottom < 0) return 0;
|
|
3545
|
+
// 元素底部在视口下方 -> 不可见
|
|
3546
|
+
if (rect.top > windowHeight) return 0;
|
|
3547
|
+
// 可见区域的 top 和 bottom
|
|
3548
|
+
const visibleTop = Math.max(rect.top, 0);
|
|
3549
|
+
const visibleBottom = Math.min(rect.bottom, windowHeight);
|
|
3550
|
+
// 可见高度
|
|
3551
|
+
return visibleBottom - visibleTop;
|
|
3552
|
+
};
|
|
3553
|
+
const getScrollTop = elem => {
|
|
3554
|
+
return elem?.scrollTop || document.documentElement.scrollTop;
|
|
3555
|
+
};
|
|
3556
|
+
// 浏览器可视宽高
|
|
3557
|
+
const getWindowSize = () => {
|
|
3558
|
+
return {
|
|
3559
|
+
width: document.body.clientWidth,
|
|
3560
|
+
height: document.body.clientHeight
|
|
3561
|
+
};
|
|
3562
|
+
};
|
|
3563
|
+
|
|
3430
3564
|
class WinResetEvent {
|
|
3431
3565
|
eventStack = {};
|
|
3432
3566
|
funcId = 0;
|
|
@@ -3467,7 +3601,9 @@ const Portal = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3467
3601
|
initRef.current = true;
|
|
3468
3602
|
}
|
|
3469
3603
|
useEffect(() => {
|
|
3470
|
-
|
|
3604
|
+
setTimeout(() => {
|
|
3605
|
+
didUpdate?.(props, containerRef.current);
|
|
3606
|
+
}, 0);
|
|
3471
3607
|
});
|
|
3472
3608
|
useEffect(() => {
|
|
3473
3609
|
return () => {
|
|
@@ -3593,6 +3729,7 @@ function generateTrigger(PortalComponent) {
|
|
|
3593
3729
|
borderRadius: 6
|
|
3594
3730
|
},
|
|
3595
3731
|
onClick: e => this.props.closable && e.stopPropagation(),
|
|
3732
|
+
onMouseDown: e => e.stopPropagation(),
|
|
3596
3733
|
children: /*#__PURE__*/React.cloneElement(this.props.children, {
|
|
3597
3734
|
key: posKey,
|
|
3598
3735
|
didUpdate: this.didUpdate
|
|
@@ -3652,7 +3789,7 @@ styleInject(css_248z$9);
|
|
|
3652
3789
|
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
3790
|
styleInject(css_248z$8);
|
|
3654
3791
|
|
|
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";
|
|
3792
|
+
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
3793
|
styleInject(css_248z$7);
|
|
3657
3794
|
|
|
3658
3795
|
// 选择表中参数
|
|
@@ -3661,11 +3798,21 @@ const SelectColumn = ({
|
|
|
3661
3798
|
groupIndex,
|
|
3662
3799
|
onChange
|
|
3663
3800
|
}) => {
|
|
3664
|
-
const [columns, setColumns] = useState(
|
|
3801
|
+
const [columns, setColumns] = useState([]);
|
|
3802
|
+
const [originList, setOriginList] = useState(_data.slice());
|
|
3665
3803
|
const store = useStore$1();
|
|
3804
|
+
const [filterVal, setFilterVal] = useState('');
|
|
3805
|
+
useEffect(() => {
|
|
3806
|
+
let newList = cloneDeep(originList.slice());
|
|
3807
|
+
setColumns(newList.filter(v => ~(v.name + (v.name_zh || '')).toLocaleLowerCase().indexOf(filterVal.toLocaleLowerCase())));
|
|
3808
|
+
}, [filterVal, originList]);
|
|
3809
|
+
function onInput(e) {
|
|
3810
|
+
let val = e.target.value;
|
|
3811
|
+
setFilterVal(val);
|
|
3812
|
+
}
|
|
3666
3813
|
const isAllSelect = useMemo(() => {
|
|
3667
|
-
return
|
|
3668
|
-
}, [
|
|
3814
|
+
return originList.filter(v => v.select).length === originList.length;
|
|
3815
|
+
}, [originList]);
|
|
3669
3816
|
const AllSelectElement = useMemo(() => {
|
|
3670
3817
|
if (isAllSelect) {
|
|
3671
3818
|
return jsxs(Fragment, {
|
|
@@ -3684,8 +3831,14 @@ const SelectColumn = ({
|
|
|
3684
3831
|
}
|
|
3685
3832
|
}, [isAllSelect]);
|
|
3686
3833
|
function onSelect(columns) {
|
|
3834
|
+
const originalData = cloneDeep(originList); // 原始数据
|
|
3835
|
+
const mergedColumns = originalData.map(item => {
|
|
3836
|
+
const match = columns.find(col => col.fieldUuid === item.fieldUuid);
|
|
3837
|
+
return match ? cloneDeep(match) : item; // 可选:是否需要深拷贝 match
|
|
3838
|
+
});
|
|
3687
3839
|
setColumns(columns);
|
|
3688
|
-
|
|
3840
|
+
setOriginList(mergedColumns);
|
|
3841
|
+
typeof onChange === 'function' && onChange(mergedColumns);
|
|
3689
3842
|
}
|
|
3690
3843
|
const onChangeFieldAlias = (val, i) => {
|
|
3691
3844
|
let fieldAlias = val || '';
|
|
@@ -3706,10 +3859,14 @@ const SelectColumn = ({
|
|
|
3706
3859
|
newMetaList = changeFieldAlias(newMetaList, newColumns[i]);
|
|
3707
3860
|
store.setMeta(newMetaList, groupIndex);
|
|
3708
3861
|
onSelect(newColumns);
|
|
3709
|
-
|
|
3862
|
+
setTimeout(() => {
|
|
3863
|
+
store.setClosable(true);
|
|
3864
|
+
}, 0);
|
|
3710
3865
|
},
|
|
3711
3866
|
onCancel: () => {
|
|
3712
|
-
|
|
3867
|
+
setTimeout(() => {
|
|
3868
|
+
store.setClosable(true);
|
|
3869
|
+
}, 0);
|
|
3713
3870
|
}
|
|
3714
3871
|
});
|
|
3715
3872
|
};
|
|
@@ -3729,6 +3886,18 @@ const SelectColumn = ({
|
|
|
3729
3886
|
onSelect(newColumns);
|
|
3730
3887
|
},
|
|
3731
3888
|
children: AllSelectElement
|
|
3889
|
+
}), jsxs("div", {
|
|
3890
|
+
className: cx(`Sqb-SelectColumn-search m-2 rounded-lg`),
|
|
3891
|
+
children: [jsx("span", {
|
|
3892
|
+
className: 'px-2',
|
|
3893
|
+
children: jsx(SearchIcon, {})
|
|
3894
|
+
}), jsx("input", {
|
|
3895
|
+
type: 'text',
|
|
3896
|
+
autoFocus: true,
|
|
3897
|
+
className: 'p-1',
|
|
3898
|
+
placeholder: __('data.search'),
|
|
3899
|
+
onInput: onInput
|
|
3900
|
+
})]
|
|
3732
3901
|
}), Array.isArray(columns) && columns.map((v, i) => {
|
|
3733
3902
|
return jsxs("div", {
|
|
3734
3903
|
className: 'pb-2 px-2 flex items-center',
|
|
@@ -3797,10 +3966,10 @@ const SelectJoinColumn = ({
|
|
|
3797
3966
|
}) => {
|
|
3798
3967
|
const store = useStore$1();
|
|
3799
3968
|
const [value, setValue] = useState(_value); // 当前选择的字段
|
|
3800
|
-
const [curTable, setCurTable] = useState(_value.
|
|
3969
|
+
const [curTable, setCurTable] = useState(_value.tableUuid); // 当前选择的表
|
|
3801
3970
|
const [curColumn, setCurColumn] = useState(_value.name); // 当前选择的字段
|
|
3802
3971
|
const [tableList, setTableList] = useState(_data.map((v, i) => {
|
|
3803
|
-
let open = !i && !_value.
|
|
3972
|
+
let open = !i && !_value.tableUuid ? true : v.tableUuid === _value.tableUuid; // TODO.这里只判断表名相等 没有用了 因为表上面加了一层数据源 先这样吧
|
|
3804
3973
|
return {
|
|
3805
3974
|
...v,
|
|
3806
3975
|
open,
|
|
@@ -3810,12 +3979,12 @@ const SelectJoinColumn = ({
|
|
|
3810
3979
|
}));
|
|
3811
3980
|
useEffect(() => {
|
|
3812
3981
|
setValue(_value);
|
|
3813
|
-
setCurTable(_value.
|
|
3982
|
+
setCurTable(_value.tableUuid);
|
|
3814
3983
|
setCurColumn(_value.name);
|
|
3815
3984
|
}, [_value]);
|
|
3816
3985
|
useEffect(() => {
|
|
3817
3986
|
setTableList(_data.map((v, i) => {
|
|
3818
|
-
let open = !i && !_value.
|
|
3987
|
+
let open = !i && !_value.tableUuid ? true : v.tableUuid === _value.tableUuid; // TODO.这里只判断表名相等 没有用了 因为表上面加了一层数据源 先这样吧
|
|
3819
3988
|
return {
|
|
3820
3989
|
...v,
|
|
3821
3990
|
open,
|
|
@@ -3875,12 +4044,12 @@ const SelectJoinColumn = ({
|
|
|
3875
4044
|
if (open) {
|
|
3876
4045
|
setTableList(newTables.map(v => ({
|
|
3877
4046
|
...v,
|
|
3878
|
-
open:
|
|
4047
|
+
open: tableUuid === v.tableUuid ? false : v.open
|
|
3879
4048
|
})));
|
|
3880
4049
|
} else {
|
|
3881
4050
|
setTableList(newTables.map(v => ({
|
|
3882
4051
|
...v,
|
|
3883
|
-
open:
|
|
4052
|
+
open: tableUuid === v.tableUuid || v.alias === SummarizeAlias$1
|
|
3884
4053
|
})));
|
|
3885
4054
|
}
|
|
3886
4055
|
},
|
|
@@ -3942,7 +4111,7 @@ const SelectJoinColumn = ({
|
|
|
3942
4111
|
className: cx(`Sqb-List-section`),
|
|
3943
4112
|
children: jsxs("div", {
|
|
3944
4113
|
className: cx(`Sqb-List-item mx-2`, {
|
|
3945
|
-
active: curColumn === name && curTable ===
|
|
4114
|
+
active: curColumn === name && curTable === tableUuid
|
|
3946
4115
|
}),
|
|
3947
4116
|
onClick: () => {
|
|
3948
4117
|
if (isGroup && typeof onGroup === 'function') {
|
|
@@ -3950,7 +4119,7 @@ const SelectJoinColumn = ({
|
|
|
3950
4119
|
let quotes = name;
|
|
3951
4120
|
return onGroup({
|
|
3952
4121
|
..._value,
|
|
3953
|
-
tableUuid:
|
|
4122
|
+
tableUuid: tableUuid || _value.tableUuid,
|
|
3954
4123
|
...v,
|
|
3955
4124
|
table,
|
|
3956
4125
|
tableId,
|
|
@@ -3964,7 +4133,7 @@ const SelectJoinColumn = ({
|
|
|
3964
4133
|
}
|
|
3965
4134
|
typeof onSelect === 'function' && onSelect({
|
|
3966
4135
|
..._value,
|
|
3967
|
-
tableUuid:
|
|
4136
|
+
tableUuid: tableUuid || _value.tableUuid,
|
|
3968
4137
|
...v,
|
|
3969
4138
|
table,
|
|
3970
4139
|
tableId,
|
|
@@ -4802,7 +4971,7 @@ const SelectSummarize = ({
|
|
|
4802
4971
|
availableData = data.map(v => {
|
|
4803
4972
|
return {
|
|
4804
4973
|
...v,
|
|
4805
|
-
columns: v.columns.filter(o => o.database_type && NUMBER_GROUP.includes(o.database_type))
|
|
4974
|
+
columns: v.columns.filter(o => o.database_type && (NUMBER_GROUP.includes(o.database_type) || (condition === '最大值' || condition === '最小值') && DATE_GROUP.includes(o.database_type)))
|
|
4806
4975
|
};
|
|
4807
4976
|
}).filter(v => v.columns.length);
|
|
4808
4977
|
}
|
|
@@ -5485,6 +5654,7 @@ const TableData = props => {
|
|
|
5485
5654
|
} = props;
|
|
5486
5655
|
const store = useStore$1();
|
|
5487
5656
|
let selected = Boolean(meta.table.name);
|
|
5657
|
+
let subQuerySelected = Boolean(meta.subquery?.[0]?.table?.name);
|
|
5488
5658
|
function selectTable(e) {
|
|
5489
5659
|
!meta.readonly && store.setPopup({
|
|
5490
5660
|
visible: true,
|
|
@@ -5550,6 +5720,77 @@ const TableData = props => {
|
|
|
5550
5720
|
onCancel: () => {}
|
|
5551
5721
|
});
|
|
5552
5722
|
};
|
|
5723
|
+
// 子查询弹窗
|
|
5724
|
+
const showSubQuery = (val = []) => {
|
|
5725
|
+
const {
|
|
5726
|
+
subToolbar,
|
|
5727
|
+
toolbar,
|
|
5728
|
+
...other
|
|
5729
|
+
} = store.preProps;
|
|
5730
|
+
let newMetaList = store.metaList[groupIndex].list.slice()[0];
|
|
5731
|
+
let oldList = cloneDeep(newMetaList.subquery);
|
|
5732
|
+
let _toolbar = subToolbar || toolbar;
|
|
5733
|
+
_toolbar = _toolbar.filter(v => v !== 'group'); // 子查询不需要分组
|
|
5734
|
+
let o = Modal2.openModal({
|
|
5735
|
+
title: __('SqlQueryBuilder.subquery'),
|
|
5736
|
+
transparentMask: true,
|
|
5737
|
+
content: jsx(Fragment, {
|
|
5738
|
+
children: jsx(SqlVisionBuilder, {
|
|
5739
|
+
...other,
|
|
5740
|
+
showSubquery: store._showSubquery,
|
|
5741
|
+
toolbar: _toolbar,
|
|
5742
|
+
btnText: __('SqlQueryBuilder.confirm'),
|
|
5743
|
+
value: val,
|
|
5744
|
+
onOk: newList => {
|
|
5745
|
+
try {
|
|
5746
|
+
// 子查询未改变不做操作
|
|
5747
|
+
if (isEqual(newList, oldList)) {
|
|
5748
|
+
o.close();
|
|
5749
|
+
return;
|
|
5750
|
+
}
|
|
5751
|
+
newMetaList.subquery = newList;
|
|
5752
|
+
newMetaList.table = {
|
|
5753
|
+
...newList[0].table,
|
|
5754
|
+
alias: newMetaList.table.alias || '',
|
|
5755
|
+
tableUuid: uuidv4('table')
|
|
5756
|
+
};
|
|
5757
|
+
const items = getSubColumns(newList);
|
|
5758
|
+
const newColumns = items.flatMap(item => item.columns);
|
|
5759
|
+
newMetaList.columns = newColumns;
|
|
5760
|
+
// (newMeta[index] as MetaJoin).expressions = [];
|
|
5761
|
+
store.setMeta([newMetaList], groupIndex);
|
|
5762
|
+
o.close();
|
|
5763
|
+
} catch (e) {
|
|
5764
|
+
console.warn(e);
|
|
5765
|
+
} finally {
|
|
5766
|
+
o.close();
|
|
5767
|
+
}
|
|
5768
|
+
}
|
|
5769
|
+
})
|
|
5770
|
+
}),
|
|
5771
|
+
onClose: () => {}
|
|
5772
|
+
});
|
|
5773
|
+
};
|
|
5774
|
+
// 切换子查询
|
|
5775
|
+
const switchSubQuery = () => {
|
|
5776
|
+
let newMetaList = store.metaList[groupIndex].list.slice()[0];
|
|
5777
|
+
newMetaList.isSubquery = !newMetaList.isSubquery;
|
|
5778
|
+
//重置表数据
|
|
5779
|
+
newMetaList.subquery = [];
|
|
5780
|
+
newMetaList.table = {
|
|
5781
|
+
name: '',
|
|
5782
|
+
// 表名
|
|
5783
|
+
tableUuid: '',
|
|
5784
|
+
id: '',
|
|
5785
|
+
// 表名
|
|
5786
|
+
alias: '',
|
|
5787
|
+
// 表别名
|
|
5788
|
+
datasourceName: '',
|
|
5789
|
+
// 数据源名
|
|
5790
|
+
datasourceId: '' // 数据源id
|
|
5791
|
+
};
|
|
5792
|
+
store.setMeta([newMetaList], groupIndex);
|
|
5793
|
+
};
|
|
5553
5794
|
return jsx(Wrapper, {
|
|
5554
5795
|
className: `Sqb-item`,
|
|
5555
5796
|
children: jsxs("div", {
|
|
@@ -5560,7 +5801,29 @@ const TableData = props => {
|
|
|
5560
5801
|
className: `Sqb-item--content`,
|
|
5561
5802
|
children: jsxs("div", {
|
|
5562
5803
|
className: `Sqb-NotebookCell`,
|
|
5563
|
-
children: [jsxs("div", {
|
|
5804
|
+
children: [meta.isSubquery ? jsxs("div", {
|
|
5805
|
+
className: cx(`Sqb-TableName`, {
|
|
5806
|
+
notSelected: !subQuerySelected
|
|
5807
|
+
}),
|
|
5808
|
+
onClick: () => {
|
|
5809
|
+
showSubQuery(meta.subquery);
|
|
5810
|
+
},
|
|
5811
|
+
children: [subQuerySelected && jsx(Tooltip, {
|
|
5812
|
+
title: __('SqlQueryBuilder.alias'),
|
|
5813
|
+
children: jsx(Button, {
|
|
5814
|
+
className: ':Sqb-TableName-as',
|
|
5815
|
+
shape: 'circle',
|
|
5816
|
+
iconOnly: true,
|
|
5817
|
+
primary: true,
|
|
5818
|
+
icon: 'As',
|
|
5819
|
+
size: 'small',
|
|
5820
|
+
onClick: e => {
|
|
5821
|
+
e.stopPropagation();
|
|
5822
|
+
onChangeTableAlias(meta.table?.alias || '');
|
|
5823
|
+
}
|
|
5824
|
+
})
|
|
5825
|
+
}), subQuerySelected ? `${(meta.subquery?.[0]).table.datasourceName}.${(meta.subquery?.[0]).table.name} ${meta.table?.alias ? `as ${meta.table?.alias}` : ''} ` : __('SqlQueryBuilder.setSubQuery')]
|
|
5826
|
+
}) : jsxs("div", {
|
|
5564
5827
|
className: cx(`Sqb-TableName`, {
|
|
5565
5828
|
notSelected: !selected
|
|
5566
5829
|
}),
|
|
@@ -5580,7 +5843,19 @@ const TableData = props => {
|
|
|
5580
5843
|
}
|
|
5581
5844
|
})
|
|
5582
5845
|
}), selected ? `${meta.table.datasourceName}.${meta.table.name} ${meta.table?.alias ? `as ${meta.table?.alias}` : ''}` : __('SqlQueryBuilder.pickTable')]
|
|
5583
|
-
}),
|
|
5846
|
+
}), store.showSubquery && jsx(Tooltip, {
|
|
5847
|
+
title: __('SqlQueryBuilder.switchSubQuery'),
|
|
5848
|
+
children: jsx(Button, {
|
|
5849
|
+
disabled: meta.readonly,
|
|
5850
|
+
primary: meta.isSubquery,
|
|
5851
|
+
ghost: true,
|
|
5852
|
+
className: cx('mr-2 operator-icon', {
|
|
5853
|
+
['subquery-icon']: !meta.isSubquery
|
|
5854
|
+
}),
|
|
5855
|
+
icon: jsx(RelatedWork, {}),
|
|
5856
|
+
onClick: switchSubQuery
|
|
5857
|
+
})
|
|
5858
|
+
}), selected && store.showFields && jsx("div", {
|
|
5584
5859
|
className: `Sqb-TableColumns`,
|
|
5585
5860
|
onClick: selectColumns,
|
|
5586
5861
|
children: __('SqlQueryBuilder.columns')
|
|
@@ -5595,33 +5870,6 @@ const TableData = props => {
|
|
|
5595
5870
|
};
|
|
5596
5871
|
|
|
5597
5872
|
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
5873
|
var FlagLocation;
|
|
5626
5874
|
(function (FlagLocation) {
|
|
5627
5875
|
FlagLocation["TABLE_1"] = "table1";
|
|
@@ -5646,11 +5894,11 @@ const JoinData = props => {
|
|
|
5646
5894
|
let table2Selected = Boolean(meta.table2.name);
|
|
5647
5895
|
let subQuerySelected = Boolean(meta.subquery?.[0]?.table?.name);
|
|
5648
5896
|
let columnsSelected = meta.table1.quotes && meta.table2.quotes;
|
|
5649
|
-
useEffect(() => {
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
}, []);
|
|
5897
|
+
// useEffect(() => {
|
|
5898
|
+
// let newMetaList = store.metaList[groupIndex].list.slice();
|
|
5899
|
+
// newMetaList[index] = setQuotes(meta);
|
|
5900
|
+
// store.setMeta(newMetaList, groupIndex);
|
|
5901
|
+
// }, []);
|
|
5654
5902
|
function selectColumns(e) {
|
|
5655
5903
|
let columns = meta.columns;
|
|
5656
5904
|
!meta.readonly && store.setPopup({
|
|
@@ -5887,7 +6135,8 @@ const JoinData = props => {
|
|
|
5887
6135
|
id = '',
|
|
5888
6136
|
fieldAlias = '',
|
|
5889
6137
|
fieldUuid = '',
|
|
5890
|
-
quotes
|
|
6138
|
+
quotes,
|
|
6139
|
+
tableUuid
|
|
5891
6140
|
} = record;
|
|
5892
6141
|
let newMeta = store.metaList[groupIndex].list.slice();
|
|
5893
6142
|
if (alias === SummarizeAlias$1) {
|
|
@@ -5903,6 +6152,7 @@ const JoinData = props => {
|
|
|
5903
6152
|
if (newMeta[index][type].alias !== alias) {
|
|
5904
6153
|
newMeta[index][type].alias = alias;
|
|
5905
6154
|
newMeta[index][type].name = table;
|
|
6155
|
+
newMeta[index][type].tableUuid = tableUuid;
|
|
5906
6156
|
newMeta[index][type].datasourceId = datasourceId;
|
|
5907
6157
|
newMeta[index][type].datasourceName = datasourceName;
|
|
5908
6158
|
newMeta[index].expressions = [];
|
|
@@ -6150,11 +6400,9 @@ const JoinData = props => {
|
|
|
6150
6400
|
let oldList = cloneDeep(newMeta[index].subquery);
|
|
6151
6401
|
let _toolbar = subToolbar || toolbar;
|
|
6152
6402
|
_toolbar = _toolbar.filter(v => v !== 'group'); // 子查询不需要分组
|
|
6153
|
-
let zIndex = store.popupContainer.current ? getMaxZIndexInParents(store.popupContainer.current) : 0;
|
|
6154
6403
|
let o = Modal2.openModal({
|
|
6155
6404
|
title: __('SqlQueryBuilder.subquery'),
|
|
6156
6405
|
transparentMask: true,
|
|
6157
|
-
zIndex: Number(zIndex),
|
|
6158
6406
|
content: jsx(Fragment, {
|
|
6159
6407
|
children: jsx(SqlVisionBuilder, {
|
|
6160
6408
|
...other,
|
|
@@ -6171,14 +6419,14 @@ const JoinData = props => {
|
|
|
6171
6419
|
}
|
|
6172
6420
|
newMeta[index].subquery = newList;
|
|
6173
6421
|
newMeta[index].table2 = {
|
|
6174
|
-
...newList[0].table
|
|
6175
|
-
fieldAlias: '',
|
|
6176
|
-
fieldUuid: ''
|
|
6422
|
+
...newList[0].table
|
|
6177
6423
|
};
|
|
6178
6424
|
const items = getSubColumns(newList);
|
|
6179
6425
|
const newColumns = items.flatMap(item => item.columns);
|
|
6180
6426
|
newMeta[index].columns = newColumns;
|
|
6181
6427
|
newMeta[index].expressions = [];
|
|
6428
|
+
// 关联表变了 下面模块全部删除
|
|
6429
|
+
newMeta = newMeta.filter((v, i) => i <= index);
|
|
6182
6430
|
store.setMeta(newMeta, groupIndex);
|
|
6183
6431
|
o.close();
|
|
6184
6432
|
} catch (e) {
|
|
@@ -6293,7 +6541,7 @@ const JoinData = props => {
|
|
|
6293
6541
|
onChangeTableAlias(meta.table2?.alias || '');
|
|
6294
6542
|
}
|
|
6295
6543
|
})
|
|
6296
|
-
}), subQuerySelected ? `${meta.subquery?.[0].table.datasourceName}.${meta.subquery?.[0].table.name} ${meta.table2?.alias ? `as ${meta.table2?.alias}` : ''} ` : __('SqlQueryBuilder.setSubQuery')]
|
|
6544
|
+
}), subQuerySelected ? `${(meta.subquery?.[0]).table.datasourceName}.${(meta.subquery?.[0]).table.name} ${meta.table2?.alias ? `as ${meta.table2?.alias}` : ''} ` : __('SqlQueryBuilder.setSubQuery')]
|
|
6297
6545
|
}) : jsxs("div", {
|
|
6298
6546
|
className: cx(`Sqb-TableName`, {
|
|
6299
6547
|
notSelected: !table2Selected
|
|
@@ -6457,14 +6705,13 @@ const JoinData = props => {
|
|
|
6457
6705
|
left_fieldUuid: '',
|
|
6458
6706
|
left_quotes: '',
|
|
6459
6707
|
left_string: '',
|
|
6460
|
-
left_isString: false,
|
|
6461
6708
|
left_type: 'field',
|
|
6462
6709
|
left_constant: '',
|
|
6463
6710
|
right_fieldAlias: '',
|
|
6464
6711
|
right_fieldUuid: '',
|
|
6465
6712
|
right_quotes: '',
|
|
6466
6713
|
right_string: '',
|
|
6467
|
-
right_isString: false,
|
|
6714
|
+
// right_isString: false,
|
|
6468
6715
|
right_type: 'field',
|
|
6469
6716
|
right_constant: ''
|
|
6470
6717
|
});
|
|
@@ -6504,14 +6751,13 @@ const JoinData = props => {
|
|
|
6504
6751
|
left_fieldUuid: '',
|
|
6505
6752
|
left_quotes: '',
|
|
6506
6753
|
left_string: '',
|
|
6507
|
-
left_isString: false,
|
|
6508
6754
|
left_type: 'field',
|
|
6509
6755
|
left_constant: '',
|
|
6510
6756
|
right_fieldAlias: '',
|
|
6511
6757
|
right_fieldUuid: '',
|
|
6512
6758
|
right_quotes: '',
|
|
6513
6759
|
right_string: '',
|
|
6514
|
-
right_isString: false,
|
|
6760
|
+
// right_isString: false,
|
|
6515
6761
|
right_constant: '',
|
|
6516
6762
|
right_type: 'field'
|
|
6517
6763
|
}];
|
|
@@ -7202,11 +7448,9 @@ const CustomColumn = props => {
|
|
|
7202
7448
|
const showSubQuery = (e, i) => {
|
|
7203
7449
|
let newMeta = store.metaList[groupIndex].list.slice();
|
|
7204
7450
|
const _value = newMeta[index].customColumn[i] || [];
|
|
7205
|
-
let zIndex = store.popupContainer.current ? getMaxZIndexInParents(store.popupContainer.current) : 0;
|
|
7206
7451
|
let o = Modal2.openModal({
|
|
7207
7452
|
title: __('SqlQueryBuilder.customExpression'),
|
|
7208
7453
|
transparentMask: true,
|
|
7209
|
-
zIndex: Number(zIndex),
|
|
7210
7454
|
content: jsx(Fragment, {
|
|
7211
7455
|
children: jsx(Provider, {
|
|
7212
7456
|
value: store,
|
|
@@ -7360,6 +7604,9 @@ const Filter = props => {
|
|
|
7360
7604
|
let {
|
|
7361
7605
|
filter
|
|
7362
7606
|
} = meta;
|
|
7607
|
+
const {
|
|
7608
|
+
notExistsColumns
|
|
7609
|
+
} = store.preProps;
|
|
7363
7610
|
React__default.useRef(null);
|
|
7364
7611
|
let index = findIndex(store.metaList[groupIndex].list, meta);
|
|
7365
7612
|
let notSelected = !meta.filter.length;
|
|
@@ -7469,7 +7716,7 @@ const Filter = props => {
|
|
|
7469
7716
|
showNotExists(i, '');
|
|
7470
7717
|
return;
|
|
7471
7718
|
}
|
|
7472
|
-
let data = getColumns();
|
|
7719
|
+
let data = [...getColumns(), ...cloneDeep(notExistsColumns || [])];
|
|
7473
7720
|
store.setPopup({
|
|
7474
7721
|
visible: true,
|
|
7475
7722
|
node: e.currentTarget,
|
|
@@ -7487,8 +7734,8 @@ const Filter = props => {
|
|
|
7487
7734
|
function handleAdd(e) {
|
|
7488
7735
|
let node = e.currentTarget;
|
|
7489
7736
|
let newMeta = store.metaList[groupIndex].list.slice();
|
|
7490
|
-
let data = getColumns();
|
|
7491
|
-
let _index = node.getAttribute('v-index');
|
|
7737
|
+
let data = [...getColumns(), ...cloneDeep(notExistsColumns || [])];
|
|
7738
|
+
let _index = Number(node.getAttribute('v-index'));
|
|
7492
7739
|
let _type = node.getAttribute('v-type');
|
|
7493
7740
|
let value = {
|
|
7494
7741
|
table: '',
|
|
@@ -7524,15 +7771,16 @@ const Filter = props => {
|
|
|
7524
7771
|
content: jsx(SelectFilter, {
|
|
7525
7772
|
data: data,
|
|
7526
7773
|
value: value,
|
|
7527
|
-
onChange:
|
|
7774
|
+
onChange: val => {
|
|
7528
7775
|
if (_type) {
|
|
7529
7776
|
if (_type === 'before') {
|
|
7530
|
-
newMeta[index].filter.splice(_index, 0,
|
|
7777
|
+
newMeta[index].filter.splice(_index, 0, val);
|
|
7531
7778
|
} else {
|
|
7532
|
-
newMeta[index].filter
|
|
7779
|
+
console.log('🚀 ~ ', newMeta[index].filter);
|
|
7780
|
+
newMeta[index].filter.splice(_index + 1, 0, val);
|
|
7533
7781
|
}
|
|
7534
7782
|
} else {
|
|
7535
|
-
newMeta[index].filter.push(
|
|
7783
|
+
newMeta[index].filter.push(val);
|
|
7536
7784
|
}
|
|
7537
7785
|
store.setMeta(newMeta, groupIndex);
|
|
7538
7786
|
closePopup();
|
|
@@ -7574,18 +7822,18 @@ const Filter = props => {
|
|
|
7574
7822
|
} = store.preProps;
|
|
7575
7823
|
let newMeta = store.metaList[groupIndex].list.slice();
|
|
7576
7824
|
let index = findIndex(store.metaList[groupIndex].list, meta);
|
|
7577
|
-
let _value = position ? [] : newMeta[index].filter[i]?.
|
|
7578
|
-
let oldList = position ? [] : cloneDeep(newMeta[index].filter[i]?.
|
|
7825
|
+
let _value = position ? [] : newMeta[index].filter[i]?.notExists || [];
|
|
7826
|
+
let oldList = position ? [] : cloneDeep(newMeta[index].filter[i]?.notExists || []);
|
|
7579
7827
|
let _toolbar = notExistsToolbar || toolbar;
|
|
7580
7828
|
_toolbar = _toolbar.filter(v => v !== 'group'); // 子查询不需要分组
|
|
7581
|
-
let
|
|
7829
|
+
let notExistsColumns = getColumns();
|
|
7582
7830
|
let o = Modal2.openModal({
|
|
7583
7831
|
title: 'NOT EXISTS',
|
|
7584
7832
|
transparentMask: true,
|
|
7585
|
-
zIndex: Number(zIndex),
|
|
7586
7833
|
content: jsx(Fragment, {
|
|
7587
7834
|
children: jsx(SqlVisionBuilder, {
|
|
7588
7835
|
...other,
|
|
7836
|
+
notExistsColumns: notExistsColumns,
|
|
7589
7837
|
showFields: false,
|
|
7590
7838
|
showSubquery: false,
|
|
7591
7839
|
toolbar: _toolbar,
|
|
@@ -7599,8 +7847,8 @@ const Filter = props => {
|
|
|
7599
7847
|
return;
|
|
7600
7848
|
}
|
|
7601
7849
|
const _tem = {
|
|
7602
|
-
|
|
7603
|
-
quotes:
|
|
7850
|
+
notExists: newList,
|
|
7851
|
+
quotes: buildSqlQuery(newList),
|
|
7604
7852
|
condition: '',
|
|
7605
7853
|
table: '',
|
|
7606
7854
|
tableId: '',
|
|
@@ -7742,7 +7990,7 @@ const Filter = props => {
|
|
|
7742
7990
|
}, i) : jsxs("div", {
|
|
7743
7991
|
className: `Sqb-TableName purple-name`,
|
|
7744
7992
|
onClick: e => handleUpdate(e, i),
|
|
7745
|
-
children: [v.quotes, jsx("span", {
|
|
7993
|
+
children: [v.type === Filter_TypeEnum.NOT_EXISTS ? 'not exitis ( * )' : v.quotes, jsx("span", {
|
|
7746
7994
|
style: {
|
|
7747
7995
|
fontSize: 0
|
|
7748
7996
|
},
|
|
@@ -7786,7 +8034,7 @@ const Filter = props => {
|
|
|
7786
8034
|
if (typeof v === 'string') {
|
|
7787
8035
|
return v;
|
|
7788
8036
|
} else if (v.type === Filter_TypeEnum.NOT_EXISTS) {
|
|
7789
|
-
return
|
|
8037
|
+
return `${buildSqlQuery(v.notExists)}`;
|
|
7790
8038
|
} else {
|
|
7791
8039
|
return v.quotes;
|
|
7792
8040
|
}
|
|
@@ -7921,7 +8169,7 @@ const GroupBy = props => {
|
|
|
7921
8169
|
const fieldAlias = `${v.alias}__${v.name}`;
|
|
7922
8170
|
return {
|
|
7923
8171
|
...v,
|
|
7924
|
-
sql: `${v.alias}.${v.realName || v.name}
|
|
8172
|
+
sql: `${v.alias}.${v.realName || v.name}`,
|
|
7925
8173
|
fieldAlias: fieldAlias
|
|
7926
8174
|
};
|
|
7927
8175
|
});
|
|
@@ -7973,7 +8221,7 @@ const GroupBy = props => {
|
|
|
7973
8221
|
const fieldAlias = `${v.alias}__${v.name}`;
|
|
7974
8222
|
return {
|
|
7975
8223
|
...v,
|
|
7976
|
-
sql: `${v.alias}.${v.realName || v.name}
|
|
8224
|
+
sql: `${v.alias}.${v.realName || v.name}`,
|
|
7977
8225
|
fieldAlias: fieldAlias,
|
|
7978
8226
|
fieldUuid: uuidv4('field'),
|
|
7979
8227
|
summarizeType: MetaSummarize_Enum.BY
|
|
@@ -8457,8 +8705,8 @@ const Sort = props => {
|
|
|
8457
8705
|
let value = {
|
|
8458
8706
|
table: '',
|
|
8459
8707
|
tableId: '',
|
|
8460
|
-
tableUuid:
|
|
8461
|
-
fieldUuid:
|
|
8708
|
+
tableUuid: '',
|
|
8709
|
+
fieldUuid: '',
|
|
8462
8710
|
fieldAlias: '',
|
|
8463
8711
|
alias: '',
|
|
8464
8712
|
name: '',
|
|
@@ -8817,7 +9065,6 @@ const Metabase = props => {
|
|
|
8817
9065
|
await onOk?.(_metaList);
|
|
8818
9066
|
setSaveLoading(false);
|
|
8819
9067
|
};
|
|
8820
|
-
let zIndex = store.popupContainer.current ? getMaxZIndexInParents(store.popupContainer.current) : null;
|
|
8821
9068
|
return (
|
|
8822
9069
|
// @ts-ignore
|
|
8823
9070
|
jsx(VisualBox, {
|
|
@@ -8863,7 +9110,6 @@ const Metabase = props => {
|
|
|
8863
9110
|
visible: store.popupData.visible,
|
|
8864
9111
|
node: store.popupData.node,
|
|
8865
9112
|
closable: store.popupClosable,
|
|
8866
|
-
zIndex: zIndex ? String(zIndex) : null,
|
|
8867
9113
|
hideVisible: () => {
|
|
8868
9114
|
store.setPopup({
|
|
8869
9115
|
visible: false
|
|
@@ -8875,7 +9121,6 @@ const Metabase = props => {
|
|
|
8875
9121
|
visible: store.popupData2.visible,
|
|
8876
9122
|
node: store.popupData2.node,
|
|
8877
9123
|
closable: store.popupClosable2,
|
|
8878
|
-
zIndex: zIndex ? String(zIndex) : null,
|
|
8879
9124
|
hideVisible: () => {
|
|
8880
9125
|
store.setClosable(true);
|
|
8881
9126
|
store.setPopup2({
|