@gingkoo/pandora-metabase 1.0.0-alpha.17 → 1.0.0-alpha.19
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 +208 -106
- package/lib/es/index.js.map +1 -1
- package/lib/es/store/types.d.ts +4 -3
- package/lib/es/utils.d.ts +2 -1
- package/package.json +1 -1
package/lib/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @gingkoo/pandora-metabase v1.0.0-alpha.
|
|
2
|
+
* @gingkoo/pandora-metabase v1.0.0-alpha.19
|
|
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({});
|
|
@@ -724,8 +724,12 @@ const changeTableAlias = (list, curObj) => {
|
|
|
724
724
|
alias
|
|
725
725
|
} = cloneDeep(curObj);
|
|
726
726
|
const newList = cloneDeep(list);
|
|
727
|
-
newList
|
|
728
|
-
if (v.type === TypeEnum.data)
|
|
727
|
+
newList?.map(v => {
|
|
728
|
+
if (v.type === TypeEnum.data) {
|
|
729
|
+
if (v.table.tableUuid === tableUuid) {
|
|
730
|
+
v.table.alias = alias;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
729
733
|
if (v.type === TypeEnum.joinData) {
|
|
730
734
|
if (v.table1.tableUuid === tableUuid) {
|
|
731
735
|
v.table1.alias = alias;
|
|
@@ -809,12 +813,15 @@ const changeTableAlias = (list, curObj) => {
|
|
|
809
813
|
// }
|
|
810
814
|
// }
|
|
811
815
|
item.table2.alias = alias;
|
|
812
|
-
item.table2.sql = '';
|
|
816
|
+
// item.table2.sql = '';
|
|
813
817
|
}
|
|
814
818
|
});
|
|
815
819
|
}
|
|
820
|
+
if (v.subquery) {
|
|
821
|
+
v.subquery = changeTableAlias(v.subquery || [], curObj);
|
|
822
|
+
}
|
|
816
823
|
});
|
|
817
|
-
return newList;
|
|
824
|
+
return newList || [];
|
|
818
825
|
};
|
|
819
826
|
const changeFieldAlias = (list, curObj) => {
|
|
820
827
|
const {
|
|
@@ -1005,6 +1012,27 @@ function reassembleByUnion(target = []) {
|
|
|
1005
1012
|
}
|
|
1006
1013
|
return result;
|
|
1007
1014
|
}
|
|
1015
|
+
const buildSqlQuery = data => {
|
|
1016
|
+
if (!data || data.length === 0) return '';
|
|
1017
|
+
let sqlClauses = ['not exitis ( '];
|
|
1018
|
+
data.forEach(item => {
|
|
1019
|
+
if (item.type === TypeEnum.data) {
|
|
1020
|
+
const meta = item;
|
|
1021
|
+
const tableName = meta.table.name;
|
|
1022
|
+
const alias = meta.table.alias ? `AS ${meta.table.alias}` : '';
|
|
1023
|
+
const dataSource = meta.table.datasourceName;
|
|
1024
|
+
sqlClauses.push(`SELECT ${tableName} ${alias} FROM ${dataSource}`);
|
|
1025
|
+
}
|
|
1026
|
+
if (item.type === TypeEnum.filter) {
|
|
1027
|
+
const filterStrings = item.filter.map(f => f.quotes).filter(Boolean); // 排除空条件
|
|
1028
|
+
if (filterStrings.length > 0) {
|
|
1029
|
+
sqlClauses.push(`WHERE ${filterStrings.join(' AND ')}`);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
});
|
|
1033
|
+
// 简单拼接 SQL 片段
|
|
1034
|
+
return sqlClauses.join(' ') + ' )' + ';';
|
|
1035
|
+
};
|
|
1008
1036
|
|
|
1009
1037
|
let metaKey = 1;
|
|
1010
1038
|
const SummarizeAlias = 'source';
|
|
@@ -1146,28 +1174,29 @@ const useStore = () => {
|
|
|
1146
1174
|
};
|
|
1147
1175
|
// 回显
|
|
1148
1176
|
// 设置column
|
|
1149
|
-
const setQuotes =
|
|
1150
|
-
let newMeta = cloneDeep(_meta);
|
|
1177
|
+
const setQuotes = newMeta => {
|
|
1151
1178
|
newMeta.table1 = {
|
|
1152
1179
|
...newMeta.table1,
|
|
1153
1180
|
fieldAlias: newMeta.table1.fieldAlias || newMeta.table1.column,
|
|
1154
|
-
fieldUuid: newMeta.table1.fieldUuid ||
|
|
1155
|
-
quotes: newMeta.table1.quotes || newMeta.table1.column
|
|
1181
|
+
fieldUuid: newMeta.table1.fieldUuid || uuidv4('field'),
|
|
1182
|
+
quotes: newMeta.table1.quotes || newMeta.table1.column,
|
|
1183
|
+
tableUuid: newMeta.table1.tableUuid || uuidv4('table')
|
|
1156
1184
|
};
|
|
1157
1185
|
newMeta.table2 = {
|
|
1158
1186
|
...newMeta.table2,
|
|
1159
1187
|
fieldAlias: newMeta.table2.fieldAlias || newMeta.table2.column,
|
|
1160
|
-
fieldUuid: newMeta.table2.fieldUuid ||
|
|
1161
|
-
quotes: newMeta.table2.quotes || newMeta.table2.column
|
|
1188
|
+
fieldUuid: newMeta.table2.fieldUuid || uuidv4('field'),
|
|
1189
|
+
quotes: newMeta.table2.quotes || newMeta.table2.column,
|
|
1190
|
+
tableUuid: newMeta.table2.tableUuid || uuidv4('table')
|
|
1162
1191
|
};
|
|
1163
1192
|
newMeta.expressions = newMeta.expressions?.map(v => {
|
|
1164
1193
|
return {
|
|
1165
1194
|
...v,
|
|
1166
|
-
left_fieldAlias: v.
|
|
1167
|
-
left_fieldUuid: v.
|
|
1195
|
+
left_fieldAlias: v.left_fieldAlias || v.left_column,
|
|
1196
|
+
left_fieldUuid: v.left_fieldUuid || uuidv4('field'),
|
|
1168
1197
|
left_quotes: v.left_quotes || v.left_column,
|
|
1169
1198
|
right_fieldAlias: v.right_fieldAlias || v.right_column,
|
|
1170
|
-
right_fieldUuid: v.right_fieldUuid ||
|
|
1199
|
+
right_fieldUuid: v.right_fieldUuid || uuidv4('field'),
|
|
1171
1200
|
right_quotes: v.right_quotes || v.right_column
|
|
1172
1201
|
};
|
|
1173
1202
|
});
|
|
@@ -1178,6 +1207,12 @@ const useStore = () => {
|
|
|
1178
1207
|
let _metaList = data?.map((item, groupIndex) => {
|
|
1179
1208
|
let newList = item.list?.map((v, i) => {
|
|
1180
1209
|
let newMeta = item.list;
|
|
1210
|
+
if (v.table) {
|
|
1211
|
+
v.table.tableUuid = v.table.tableUuid || uuidv4('table');
|
|
1212
|
+
}
|
|
1213
|
+
if (v.type === TypeEnum.joinData) {
|
|
1214
|
+
newMeta[i] = setQuotes(newMeta[i]);
|
|
1215
|
+
}
|
|
1181
1216
|
// 设置右侧column
|
|
1182
1217
|
if (v.table2?.datasourceId && v.columns.length < 1) {
|
|
1183
1218
|
fetchColumns(newMeta[i].table2, newMeta[i].table2.datasourceId, (columns = []) => {
|
|
@@ -1189,9 +1224,6 @@ const useStore = () => {
|
|
|
1189
1224
|
} else {
|
|
1190
1225
|
newMeta[i].columns = columns || [];
|
|
1191
1226
|
}
|
|
1192
|
-
if (v.type === TypeEnum.joinData) {
|
|
1193
|
-
newMeta[i] = setQuotes(newMeta[i]);
|
|
1194
|
-
}
|
|
1195
1227
|
setMeta(newMeta, groupIndex);
|
|
1196
1228
|
});
|
|
1197
1229
|
return {
|
|
@@ -1209,9 +1241,9 @@ const useStore = () => {
|
|
|
1209
1241
|
} else {
|
|
1210
1242
|
newMeta[i].columns = columns || [];
|
|
1211
1243
|
}
|
|
1212
|
-
if (v.type === TypeEnum.joinData) {
|
|
1213
|
-
|
|
1214
|
-
}
|
|
1244
|
+
// if (v.type === TypeEnum.joinData) {
|
|
1245
|
+
// newMeta[i] = setQuotes(newMeta[i]);
|
|
1246
|
+
// }
|
|
1215
1247
|
setMeta(newMeta, groupIndex);
|
|
1216
1248
|
});
|
|
1217
1249
|
return {
|
|
@@ -1410,46 +1442,10 @@ const useStore = () => {
|
|
|
1410
1442
|
const getDataset = datasourceId => {
|
|
1411
1443
|
return _cacheSource2TableMap[datasourceId] || [];
|
|
1412
1444
|
};
|
|
1413
|
-
const changeAlias = (groupIndex, alias) => {
|
|
1414
|
-
let newMetaList = metaList.slice();
|
|
1415
|
-
const _list = newMetaList[groupIndex].list;
|
|
1416
|
-
if (_list.length > 0) {
|
|
1417
|
-
_list.forEach(item => {
|
|
1418
|
-
if (item.type === TypeEnum.joinData && item.table2.alias === alias) {
|
|
1419
|
-
item.table2.alias = alias;
|
|
1420
|
-
} else if (item.type === TypeEnum.data && item.table.alias === alias) {
|
|
1421
|
-
item.table.alias = alias;
|
|
1422
|
-
} else if (item.type === TypeEnum.filter) {
|
|
1423
|
-
//过滤器
|
|
1424
|
-
item.filter.forEach(filterItem => {
|
|
1425
|
-
if (filterItem.alias === alias) {
|
|
1426
|
-
filterItem.alias = alias;
|
|
1427
|
-
}
|
|
1428
|
-
});
|
|
1429
|
-
} else if (item.type === TypeEnum.summarize) {
|
|
1430
|
-
// 汇总
|
|
1431
|
-
item.alias = alias;
|
|
1432
|
-
item.by.forEach(byItem => {
|
|
1433
|
-
if (byItem.alias === alias) {
|
|
1434
|
-
byItem.alias = alias;
|
|
1435
|
-
}
|
|
1436
|
-
});
|
|
1437
|
-
item.group.forEach(groupItem => {
|
|
1438
|
-
if (groupItem.alias === alias) {
|
|
1439
|
-
groupItem.alias = alias;
|
|
1440
|
-
groupItem.sql = alias;
|
|
1441
|
-
}
|
|
1442
|
-
});
|
|
1443
|
-
}
|
|
1444
|
-
});
|
|
1445
|
-
newMetaList[groupIndex].list = _list;
|
|
1446
|
-
_setMeta(newMetaList);
|
|
1447
|
-
}
|
|
1448
|
-
};
|
|
1449
1445
|
const reset = () => {
|
|
1450
1446
|
// setSourceList([]);
|
|
1451
1447
|
_setMeta(defaultMeta);
|
|
1452
|
-
setToolbar(defaultToolbar);
|
|
1448
|
+
// setToolbar(defaultToolbar);
|
|
1453
1449
|
set_cacheSource2TableMap({});
|
|
1454
1450
|
set_cacheColumnsMap({});
|
|
1455
1451
|
};
|
|
@@ -1503,7 +1499,6 @@ const useStore = () => {
|
|
|
1503
1499
|
_setShowSubquery,
|
|
1504
1500
|
constantList,
|
|
1505
1501
|
setConstantList,
|
|
1506
|
-
changeAlias,
|
|
1507
1502
|
popupContainer
|
|
1508
1503
|
};
|
|
1509
1504
|
};
|
|
@@ -1874,7 +1869,7 @@ const Loading = ({
|
|
|
1874
1869
|
});
|
|
1875
1870
|
};
|
|
1876
1871
|
|
|
1877
|
-
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";
|
|
1872
|
+
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";
|
|
1878
1873
|
styleInject(css_248z$d);
|
|
1879
1874
|
|
|
1880
1875
|
// 获取元素translate x y值
|
|
@@ -3688,7 +3683,7 @@ styleInject(css_248z$9);
|
|
|
3688
3683
|
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";
|
|
3689
3684
|
styleInject(css_248z$8);
|
|
3690
3685
|
|
|
3691
|
-
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";
|
|
3686
|
+
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";
|
|
3692
3687
|
styleInject(css_248z$7);
|
|
3693
3688
|
|
|
3694
3689
|
// 选择表中参数
|
|
@@ -3697,11 +3692,21 @@ const SelectColumn = ({
|
|
|
3697
3692
|
groupIndex,
|
|
3698
3693
|
onChange
|
|
3699
3694
|
}) => {
|
|
3700
|
-
const [columns, setColumns] = useState(
|
|
3695
|
+
const [columns, setColumns] = useState([]);
|
|
3696
|
+
const [originList, setOriginList] = useState(_data.slice());
|
|
3701
3697
|
const store = useStore$1();
|
|
3698
|
+
const [filterVal, setFilterVal] = useState('');
|
|
3699
|
+
useEffect(() => {
|
|
3700
|
+
let newList = cloneDeep(originList.slice());
|
|
3701
|
+
setColumns(newList.filter(v => ~(v.name + (v.name_zh || '')).toLocaleLowerCase().indexOf(filterVal.toLocaleLowerCase())));
|
|
3702
|
+
}, [filterVal, originList]);
|
|
3703
|
+
function onInput(e) {
|
|
3704
|
+
let val = e.target.value;
|
|
3705
|
+
setFilterVal(val);
|
|
3706
|
+
}
|
|
3702
3707
|
const isAllSelect = useMemo(() => {
|
|
3703
|
-
return
|
|
3704
|
-
}, [
|
|
3708
|
+
return originList.filter(v => v.select).length === originList.length;
|
|
3709
|
+
}, [originList]);
|
|
3705
3710
|
const AllSelectElement = useMemo(() => {
|
|
3706
3711
|
if (isAllSelect) {
|
|
3707
3712
|
return jsxs(Fragment, {
|
|
@@ -3720,8 +3725,14 @@ const SelectColumn = ({
|
|
|
3720
3725
|
}
|
|
3721
3726
|
}, [isAllSelect]);
|
|
3722
3727
|
function onSelect(columns) {
|
|
3728
|
+
const originalData = cloneDeep(originList); // 原始数据
|
|
3729
|
+
const mergedColumns = originalData.map(item => {
|
|
3730
|
+
const match = columns.find(col => col.fieldUuid === item.fieldUuid);
|
|
3731
|
+
return match ? cloneDeep(match) : item; // 可选:是否需要深拷贝 match
|
|
3732
|
+
});
|
|
3723
3733
|
setColumns(columns);
|
|
3724
|
-
|
|
3734
|
+
setOriginList(mergedColumns);
|
|
3735
|
+
typeof onChange === 'function' && onChange(mergedColumns);
|
|
3725
3736
|
}
|
|
3726
3737
|
const onChangeFieldAlias = (val, i) => {
|
|
3727
3738
|
let fieldAlias = val || '';
|
|
@@ -3765,6 +3776,18 @@ const SelectColumn = ({
|
|
|
3765
3776
|
onSelect(newColumns);
|
|
3766
3777
|
},
|
|
3767
3778
|
children: AllSelectElement
|
|
3779
|
+
}), jsxs("div", {
|
|
3780
|
+
className: cx(`Sqb-SelectColumn-search m-2 rounded-lg`),
|
|
3781
|
+
children: [jsx("span", {
|
|
3782
|
+
className: 'px-2',
|
|
3783
|
+
children: jsx(SearchIcon, {})
|
|
3784
|
+
}), jsx("input", {
|
|
3785
|
+
type: 'text',
|
|
3786
|
+
autoFocus: true,
|
|
3787
|
+
className: 'p-1',
|
|
3788
|
+
placeholder: __('data.search'),
|
|
3789
|
+
onInput: onInput
|
|
3790
|
+
})]
|
|
3768
3791
|
}), Array.isArray(columns) && columns.map((v, i) => {
|
|
3769
3792
|
return jsxs("div", {
|
|
3770
3793
|
className: 'pb-2 px-2 flex items-center',
|
|
@@ -4838,7 +4861,7 @@ const SelectSummarize = ({
|
|
|
4838
4861
|
availableData = data.map(v => {
|
|
4839
4862
|
return {
|
|
4840
4863
|
...v,
|
|
4841
|
-
columns: v.columns.filter(o => o.database_type && NUMBER_GROUP.includes(o.database_type))
|
|
4864
|
+
columns: v.columns.filter(o => o.database_type && (NUMBER_GROUP.includes(o.database_type) || (condition === '最大值' || condition === '最小值') && DATE_GROUP.includes(o.database_type)))
|
|
4842
4865
|
};
|
|
4843
4866
|
}).filter(v => v.columns.length);
|
|
4844
4867
|
}
|
|
@@ -5521,6 +5544,7 @@ const TableData = props => {
|
|
|
5521
5544
|
} = props;
|
|
5522
5545
|
const store = useStore$1();
|
|
5523
5546
|
let selected = Boolean(meta.table.name);
|
|
5547
|
+
let subQuerySelected = Boolean(meta.subquery?.[0]?.table?.name);
|
|
5524
5548
|
function selectTable(e) {
|
|
5525
5549
|
!meta.readonly && store.setPopup({
|
|
5526
5550
|
visible: true,
|
|
@@ -5586,6 +5610,77 @@ const TableData = props => {
|
|
|
5586
5610
|
onCancel: () => {}
|
|
5587
5611
|
});
|
|
5588
5612
|
};
|
|
5613
|
+
// 子查询弹窗
|
|
5614
|
+
const showSubQuery = (val = []) => {
|
|
5615
|
+
const {
|
|
5616
|
+
subToolbar,
|
|
5617
|
+
toolbar,
|
|
5618
|
+
...other
|
|
5619
|
+
} = store.preProps;
|
|
5620
|
+
let newMetaList = store.metaList[groupIndex].list.slice()[0];
|
|
5621
|
+
let oldList = cloneDeep(newMetaList.subquery);
|
|
5622
|
+
let _toolbar = subToolbar || toolbar;
|
|
5623
|
+
_toolbar = _toolbar.filter(v => v !== 'group'); // 子查询不需要分组
|
|
5624
|
+
let zIndex = store.popupContainer.current ? getMaxZIndexInParents(store.popupContainer.current) : 0;
|
|
5625
|
+
let o = Modal2.openModal({
|
|
5626
|
+
title: __('SqlQueryBuilder.subquery'),
|
|
5627
|
+
transparentMask: true,
|
|
5628
|
+
zIndex: Number(zIndex),
|
|
5629
|
+
content: jsx(Fragment, {
|
|
5630
|
+
children: jsx(SqlVisionBuilder, {
|
|
5631
|
+
...other,
|
|
5632
|
+
showSubquery: store._showSubquery,
|
|
5633
|
+
toolbar: _toolbar,
|
|
5634
|
+
btnText: __('SqlQueryBuilder.confirm'),
|
|
5635
|
+
value: val,
|
|
5636
|
+
onOk: newList => {
|
|
5637
|
+
try {
|
|
5638
|
+
// 子查询未改变不做操作
|
|
5639
|
+
if (isEqual(newList, oldList)) {
|
|
5640
|
+
o.close();
|
|
5641
|
+
return;
|
|
5642
|
+
}
|
|
5643
|
+
newMetaList.subquery = newList;
|
|
5644
|
+
newMetaList.table = {
|
|
5645
|
+
...newList[0].table
|
|
5646
|
+
};
|
|
5647
|
+
const items = getSubColumns(newList);
|
|
5648
|
+
const newColumns = items.flatMap(item => item.columns);
|
|
5649
|
+
newMetaList.columns = newColumns;
|
|
5650
|
+
// (newMeta[index] as MetaJoin).expressions = [];
|
|
5651
|
+
store.setMeta([newMetaList], groupIndex);
|
|
5652
|
+
o.close();
|
|
5653
|
+
} catch (e) {
|
|
5654
|
+
console.warn(e);
|
|
5655
|
+
} finally {
|
|
5656
|
+
o.close();
|
|
5657
|
+
}
|
|
5658
|
+
}
|
|
5659
|
+
})
|
|
5660
|
+
}),
|
|
5661
|
+
onClose: () => {}
|
|
5662
|
+
});
|
|
5663
|
+
};
|
|
5664
|
+
// 切换子查询
|
|
5665
|
+
const switchSubQuery = () => {
|
|
5666
|
+
let newMetaList = store.metaList[groupIndex].list.slice()[0];
|
|
5667
|
+
newMetaList.isSubquery = !newMetaList.isSubquery;
|
|
5668
|
+
//重置表数据
|
|
5669
|
+
newMetaList.subquery = [];
|
|
5670
|
+
newMetaList.table = {
|
|
5671
|
+
name: '',
|
|
5672
|
+
// 表名
|
|
5673
|
+
tableUuid: '',
|
|
5674
|
+
id: '',
|
|
5675
|
+
// 表名
|
|
5676
|
+
alias: '',
|
|
5677
|
+
// 表别名
|
|
5678
|
+
datasourceName: '',
|
|
5679
|
+
// 数据源名
|
|
5680
|
+
datasourceId: '' // 数据源id
|
|
5681
|
+
};
|
|
5682
|
+
store.setMeta([newMetaList], groupIndex);
|
|
5683
|
+
};
|
|
5589
5684
|
return jsx(Wrapper, {
|
|
5590
5685
|
className: `Sqb-item`,
|
|
5591
5686
|
children: jsxs("div", {
|
|
@@ -5596,7 +5691,29 @@ const TableData = props => {
|
|
|
5596
5691
|
className: `Sqb-item--content`,
|
|
5597
5692
|
children: jsxs("div", {
|
|
5598
5693
|
className: `Sqb-NotebookCell`,
|
|
5599
|
-
children: [jsxs("div", {
|
|
5694
|
+
children: [meta.isSubquery ? jsxs("div", {
|
|
5695
|
+
className: cx(`Sqb-TableName`, {
|
|
5696
|
+
notSelected: !subQuerySelected
|
|
5697
|
+
}),
|
|
5698
|
+
onClick: () => {
|
|
5699
|
+
showSubQuery(meta.subquery);
|
|
5700
|
+
},
|
|
5701
|
+
children: [subQuerySelected && jsx(Tooltip, {
|
|
5702
|
+
title: __('SqlQueryBuilder.alias'),
|
|
5703
|
+
children: jsx(Button, {
|
|
5704
|
+
className: ':Sqb-TableName-as',
|
|
5705
|
+
shape: 'circle',
|
|
5706
|
+
iconOnly: true,
|
|
5707
|
+
primary: true,
|
|
5708
|
+
icon: 'As',
|
|
5709
|
+
size: 'small',
|
|
5710
|
+
onClick: e => {
|
|
5711
|
+
e.stopPropagation();
|
|
5712
|
+
onChangeTableAlias(meta.table?.alias || '');
|
|
5713
|
+
}
|
|
5714
|
+
})
|
|
5715
|
+
}), subQuerySelected ? `${(meta.subquery?.[0]).table.datasourceName}.${(meta.subquery?.[0]).table.name} ${meta.table?.alias ? `as ${meta.table?.alias}` : ''} ` : __('SqlQueryBuilder.setSubQuery')]
|
|
5716
|
+
}) : jsxs("div", {
|
|
5600
5717
|
className: cx(`Sqb-TableName`, {
|
|
5601
5718
|
notSelected: !selected
|
|
5602
5719
|
}),
|
|
@@ -5616,7 +5733,19 @@ const TableData = props => {
|
|
|
5616
5733
|
}
|
|
5617
5734
|
})
|
|
5618
5735
|
}), selected ? `${meta.table.datasourceName}.${meta.table.name} ${meta.table?.alias ? `as ${meta.table?.alias}` : ''}` : __('SqlQueryBuilder.pickTable')]
|
|
5619
|
-
}),
|
|
5736
|
+
}), store.showSubquery && jsx(Tooltip, {
|
|
5737
|
+
title: __('SqlQueryBuilder.switchSubQuery'),
|
|
5738
|
+
children: jsx(Button, {
|
|
5739
|
+
disabled: meta.readonly,
|
|
5740
|
+
primary: meta.isSubquery,
|
|
5741
|
+
ghost: true,
|
|
5742
|
+
className: cx('mr-2 operator-icon', {
|
|
5743
|
+
['subquery-icon']: !meta.isSubquery
|
|
5744
|
+
}),
|
|
5745
|
+
icon: jsx(RelatedWork, {}),
|
|
5746
|
+
onClick: switchSubQuery
|
|
5747
|
+
})
|
|
5748
|
+
}), selected && store.showFields && jsx("div", {
|
|
5620
5749
|
className: `Sqb-TableColumns`,
|
|
5621
5750
|
onClick: selectColumns,
|
|
5622
5751
|
children: __('SqlQueryBuilder.columns')
|
|
@@ -5631,33 +5760,6 @@ const TableData = props => {
|
|
|
5631
5760
|
};
|
|
5632
5761
|
|
|
5633
5762
|
const PrevResult$1 = 'Previous results';
|
|
5634
|
-
function setQuotes(_meta) {
|
|
5635
|
-
let newMeta = cloneDeep(_meta);
|
|
5636
|
-
newMeta.table1 = {
|
|
5637
|
-
...newMeta.table1,
|
|
5638
|
-
fieldAlias: newMeta.table1.fieldAlias || newMeta.table1.column,
|
|
5639
|
-
fieldUuid: newMeta.table1.fieldUuid || newMeta.table1.column_id,
|
|
5640
|
-
quotes: newMeta.table1.quotes || newMeta.table1.column
|
|
5641
|
-
};
|
|
5642
|
-
newMeta.table2 = {
|
|
5643
|
-
...newMeta.table2,
|
|
5644
|
-
fieldAlias: newMeta.table2.fieldAlias || newMeta.table2.column,
|
|
5645
|
-
fieldUuid: newMeta.table2.fieldUuid || newMeta.table2.column_id,
|
|
5646
|
-
quotes: newMeta.table2.quotes || newMeta.table2.column
|
|
5647
|
-
};
|
|
5648
|
-
newMeta.expressions = newMeta.expressions?.map(v => {
|
|
5649
|
-
return {
|
|
5650
|
-
...v,
|
|
5651
|
-
left_fieldAlias: v.fieldAlias || v.left_column,
|
|
5652
|
-
left_fieldUuid: v.fieldUuid || v.left_column_id,
|
|
5653
|
-
left_quotes: v.left_quotes || v.left_column,
|
|
5654
|
-
right_fieldAlias: v.right_fieldAlias || v.right_column,
|
|
5655
|
-
right_fieldUuid: v.right_fieldUuid || v.right_column_id,
|
|
5656
|
-
right_quotes: v.right_quotes || v.right_column
|
|
5657
|
-
};
|
|
5658
|
-
});
|
|
5659
|
-
return newMeta;
|
|
5660
|
-
}
|
|
5661
5763
|
var FlagLocation;
|
|
5662
5764
|
(function (FlagLocation) {
|
|
5663
5765
|
FlagLocation["TABLE_1"] = "table1";
|
|
@@ -5682,11 +5784,11 @@ const JoinData = props => {
|
|
|
5682
5784
|
let table2Selected = Boolean(meta.table2.name);
|
|
5683
5785
|
let subQuerySelected = Boolean(meta.subquery?.[0]?.table?.name);
|
|
5684
5786
|
let columnsSelected = meta.table1.quotes && meta.table2.quotes;
|
|
5685
|
-
useEffect(() => {
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
}, []);
|
|
5787
|
+
// useEffect(() => {
|
|
5788
|
+
// let newMetaList = store.metaList[groupIndex].list.slice();
|
|
5789
|
+
// newMetaList[index] = setQuotes(meta);
|
|
5790
|
+
// store.setMeta(newMetaList, groupIndex);
|
|
5791
|
+
// }, []);
|
|
5690
5792
|
function selectColumns(e) {
|
|
5691
5793
|
let columns = meta.columns;
|
|
5692
5794
|
!meta.readonly && store.setPopup({
|
|
@@ -6329,7 +6431,7 @@ const JoinData = props => {
|
|
|
6329
6431
|
onChangeTableAlias(meta.table2?.alias || '');
|
|
6330
6432
|
}
|
|
6331
6433
|
})
|
|
6332
|
-
}), subQuerySelected ? `${meta.subquery?.[0].table.datasourceName}.${meta.subquery?.[0].table.name} ${meta.table2?.alias ? `as ${meta.table2?.alias}` : ''} ` : __('SqlQueryBuilder.setSubQuery')]
|
|
6434
|
+
}), subQuerySelected ? `${(meta.subquery?.[0]).table.datasourceName}.${(meta.subquery?.[0]).table.name} ${meta.table2?.alias ? `as ${meta.table2?.alias}` : ''} ` : __('SqlQueryBuilder.setSubQuery')]
|
|
6333
6435
|
}) : jsxs("div", {
|
|
6334
6436
|
className: cx(`Sqb-TableName`, {
|
|
6335
6437
|
notSelected: !table2Selected
|
|
@@ -6499,7 +6601,7 @@ const JoinData = props => {
|
|
|
6499
6601
|
right_fieldUuid: '',
|
|
6500
6602
|
right_quotes: '',
|
|
6501
6603
|
right_string: '',
|
|
6502
|
-
right_isString: false,
|
|
6604
|
+
// right_isString: false,
|
|
6503
6605
|
right_type: 'field',
|
|
6504
6606
|
right_constant: ''
|
|
6505
6607
|
});
|
|
@@ -6545,7 +6647,7 @@ const JoinData = props => {
|
|
|
6545
6647
|
right_fieldUuid: '',
|
|
6546
6648
|
right_quotes: '',
|
|
6547
6649
|
right_string: '',
|
|
6548
|
-
right_isString: false,
|
|
6650
|
+
// right_isString: false,
|
|
6549
6651
|
right_constant: '',
|
|
6550
6652
|
right_type: 'field'
|
|
6551
6653
|
}];
|
|
@@ -7634,7 +7736,7 @@ const Filter = props => {
|
|
|
7634
7736
|
}
|
|
7635
7737
|
const _tem = {
|
|
7636
7738
|
subquery: newList,
|
|
7637
|
-
quotes:
|
|
7739
|
+
quotes: buildSqlQuery(newList),
|
|
7638
7740
|
condition: '',
|
|
7639
7741
|
table: '',
|
|
7640
7742
|
tableId: '',
|
|
@@ -7820,7 +7922,7 @@ const Filter = props => {
|
|
|
7820
7922
|
if (typeof v === 'string') {
|
|
7821
7923
|
return v;
|
|
7822
7924
|
} else if (v.type === Filter_TypeEnum.NOT_EXISTS) {
|
|
7823
|
-
return
|
|
7925
|
+
return `${buildSqlQuery(v.subquery)}`;
|
|
7824
7926
|
} else {
|
|
7825
7927
|
return v.quotes;
|
|
7826
7928
|
}
|