@gingkoo/pandora-metabase 1.0.23 → 1.0.24
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/cjs/components/dialog/custom-editor/index.js +2 -2
- package/lib/cjs/components/dialog/expression/index.js +1 -1
- package/lib/cjs/components/dialog/formula/index.d.ts +10 -0
- package/lib/cjs/components/dialog/formula/index.js +242 -0
- package/lib/cjs/components/dialog/formula/index.less +81 -0
- package/lib/cjs/components/dialog/formula/utils.d.ts +7 -0
- package/lib/cjs/components/dialog/formula/utils.js +45 -0
- package/lib/cjs/components/dialog/formula-list/index.d.ts +2 -2
- package/lib/cjs/components/dialog/formula-list/index.js +87 -29
- package/lib/cjs/components/dialog/formula-list/utils.d.ts +14 -1
- package/lib/cjs/components/dialog/formula-list/utils.js +159 -2
- package/lib/cjs/components/metabase/index.less +1 -0
- package/lib/cjs/components/modules/enum/filter-enum.d.ts +7 -2
- package/lib/cjs/components/modules/enum/filter-enum.js +8 -2
- package/lib/cjs/components/modules/join-data.js +27 -2
- package/lib/cjs/hooks/patch.js +77 -75
- package/lib/cjs/hooks/use-state.js +33 -27
- package/lib/cjs/index.js +3 -1
- package/lib/cjs/locale/en.js +4 -2
- package/lib/cjs/locale/zh.js +4 -2
- package/lib/cjs/store/helper.d.ts +1 -2
- package/lib/cjs/store/helper.js +1 -76
- package/lib/cjs/store/types.d.ts +36 -2
- package/lib/cjs/store/types.js +3 -0
- package/lib/cjs/types.d.ts +2 -1
- package/lib/cjs/utils.js +2 -1
- package/lib/es/components/dialog/custom-editor/index.js +2 -2
- package/lib/es/components/dialog/expression/index.js +1 -1
- package/lib/es/components/dialog/formula/index.d.ts +10 -0
- package/lib/es/components/dialog/formula/index.js +236 -0
- package/lib/es/components/dialog/formula/index.less +81 -0
- package/lib/es/components/dialog/formula/utils.d.ts +7 -0
- package/lib/es/components/dialog/formula/utils.js +37 -0
- package/lib/es/components/dialog/formula-list/index.d.ts +2 -2
- package/lib/es/components/dialog/formula-list/index.js +84 -26
- package/lib/es/components/dialog/formula-list/utils.d.ts +14 -1
- package/lib/es/components/dialog/formula-list/utils.js +160 -2
- package/lib/es/components/metabase/index.less +1 -0
- package/lib/es/components/modules/enum/filter-enum.d.ts +7 -2
- package/lib/es/components/modules/enum/filter-enum.js +8 -2
- package/lib/es/components/modules/join-data.js +27 -2
- package/lib/es/hooks/patch.js +77 -75
- package/lib/es/hooks/use-state.js +33 -27
- package/lib/es/index.js +3 -1
- package/lib/es/locale/en.js +4 -2
- package/lib/es/locale/zh.js +4 -2
- package/lib/es/store/helper.d.ts +1 -2
- package/lib/es/store/helper.js +0 -75
- package/lib/es/store/types.d.ts +36 -2
- package/lib/es/store/types.js +3 -0
- package/lib/es/types.d.ts +2 -1
- package/lib/es/types.js +18 -1
- package/lib/es/utils.js +2 -1
- package/package.json +1 -1
- package/lib/cjs/components/dialog/formula-list/enum.d.ts +0 -39
- package/lib/cjs/components/dialog/formula-list/enum.js +0 -123
- package/lib/es/components/dialog/formula-list/enum.d.ts +0 -39
- package/lib/es/components/dialog/formula-list/enum.js +0 -117
|
@@ -4,9 +4,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.operatorList = exports.isOk = exports.insertTemplateAt = exports.getTemplateItem = exports.customTypes = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
|
|
9
|
+
var _locale = require("../../../locale");
|
|
9
10
|
var _types = require("../../../store/types");
|
|
11
|
+
// import { FUNCTION_TEMPLATES } from '../function/utils';
|
|
10
12
|
/**
|
|
11
13
|
*
|
|
12
14
|
* @param type 当前选择的类型
|
|
@@ -14,7 +16,7 @@ var _types = require("../../../store/types");
|
|
|
14
16
|
* @param index 需要讲模版插入的位置
|
|
15
17
|
* @returns
|
|
16
18
|
*/
|
|
17
|
-
var
|
|
19
|
+
var insertTemplateAt = exports.insertTemplateAt = function insertTemplateAt(oldType, type, list, index) {
|
|
18
20
|
var temList = [];
|
|
19
21
|
var needChange = ['RANK()', 'DENSE_RANK()', 'ROW_NUMBER()', 'when', 'case', 'then'].includes(oldType);
|
|
20
22
|
// 只改变类型不需要插入模版
|
|
@@ -123,4 +125,159 @@ var getTemplate = exports.getTemplate = function getTemplate(oldType, type, list
|
|
|
123
125
|
}
|
|
124
126
|
list.splice.apply(list, [index + 1, 0].concat((0, _toConsumableArray2["default"])(temList)));
|
|
125
127
|
return list;
|
|
128
|
+
};
|
|
129
|
+
var operatorList = exports.operatorList = ['and', 'or', '(', ')', ',', '+', '-', '*', '/', '!=', '<=', '>=', '<', '>', '=', 'case', 'when', 'then', 'else', 'end', 'DESC', 'ASC', 'OVER', 'PARTITION BY', 'ORDER BY', 'RANK()', 'DENSE_RANK()', 'ROW_NUMBER()'];
|
|
130
|
+
var customTypes = exports.customTypes = [
|
|
131
|
+
// 字段
|
|
132
|
+
{
|
|
133
|
+
value: _types.AtomsTypeEnum.FIELD,
|
|
134
|
+
label: (0, _locale.__)('customColumn.field')
|
|
135
|
+
},
|
|
136
|
+
// 表达式
|
|
137
|
+
{
|
|
138
|
+
value: _types.AtomsTypeEnum.EXPRESSION,
|
|
139
|
+
label: (0, _locale.__)('customColumn.expression')
|
|
140
|
+
},
|
|
141
|
+
// 输入框
|
|
142
|
+
{
|
|
143
|
+
value: _types.AtomsTypeEnum.INPUT_STRING,
|
|
144
|
+
label: (0, _locale.__)('customColumn.input')
|
|
145
|
+
},
|
|
146
|
+
// 数字输入框
|
|
147
|
+
{
|
|
148
|
+
value: _types.AtomsTypeEnum.INPUT_NUMBER,
|
|
149
|
+
label: (0, _locale.__)('customColumn.numberInput')
|
|
150
|
+
},
|
|
151
|
+
// 数字输入框
|
|
152
|
+
{
|
|
153
|
+
value: _types.AtomsTypeEnum.CONSTANT,
|
|
154
|
+
label: (0, _locale.__)('customColumn.constant')
|
|
155
|
+
},
|
|
156
|
+
// 连接符
|
|
157
|
+
{
|
|
158
|
+
value: _types.AtomsTypeEnum.OPERATOR,
|
|
159
|
+
label: (0, _locale.__)('customColumn.operator'),
|
|
160
|
+
children: operatorList
|
|
161
|
+
},
|
|
162
|
+
// 函数
|
|
163
|
+
{
|
|
164
|
+
value: _types.AtomsTypeEnum.FORMULA,
|
|
165
|
+
label: (0, _locale.__)('customColumn.formula'),
|
|
166
|
+
children: operatorList
|
|
167
|
+
}];
|
|
168
|
+
var getTemplateItem = exports.getTemplateItem = function getTemplateItem(type) {
|
|
169
|
+
var temItem;
|
|
170
|
+
// 字段
|
|
171
|
+
if (type === _types.AtomsTypeEnum.FIELD) {
|
|
172
|
+
temItem = {
|
|
173
|
+
fieldName: '',
|
|
174
|
+
// 字段名
|
|
175
|
+
fieldNameZh: '',
|
|
176
|
+
// 字段中文名
|
|
177
|
+
fieldAlias: '',
|
|
178
|
+
// 别名
|
|
179
|
+
fieldUuid: '',
|
|
180
|
+
// uuid
|
|
181
|
+
fieldId: '',
|
|
182
|
+
// 字段id
|
|
183
|
+
// quotes?: string; // 字段展示的 不知道有没有用
|
|
184
|
+
tableName: '',
|
|
185
|
+
// 表名
|
|
186
|
+
tableNameZh: '',
|
|
187
|
+
tableId: '',
|
|
188
|
+
// 表名
|
|
189
|
+
tableAlias: '',
|
|
190
|
+
// 别名
|
|
191
|
+
tableUuid: '',
|
|
192
|
+
// 表唯一标识
|
|
193
|
+
datasourceName: '',
|
|
194
|
+
// 数据源名
|
|
195
|
+
datasourceId: '',
|
|
196
|
+
// 数据源id
|
|
197
|
+
type: _types.AtomsTypeEnum.FIELD
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
// 表达式
|
|
201
|
+
else if (type === _types.AtomsTypeEnum.EXPRESSION || type === _types.AtomsTypeEnum.JOIN_DEFAULT) {
|
|
202
|
+
return {
|
|
203
|
+
lhs: [],
|
|
204
|
+
rhs: [],
|
|
205
|
+
condition: '',
|
|
206
|
+
quotes: '',
|
|
207
|
+
type: type
|
|
208
|
+
};
|
|
209
|
+
} else if (type === _types.AtomsTypeEnum.EXISTS || type === _types.AtomsTypeEnum.NOT_EXISTS) {
|
|
210
|
+
return {
|
|
211
|
+
quotes: '',
|
|
212
|
+
// 展示用户看的 组装的文字
|
|
213
|
+
notExists: [],
|
|
214
|
+
type: type
|
|
215
|
+
};
|
|
216
|
+
} else if (type === _types.AtomsTypeEnum.UNKNOWN) {
|
|
217
|
+
return {
|
|
218
|
+
// quotes: '', // 展示用户看的 组装的文字
|
|
219
|
+
// notExists: [],
|
|
220
|
+
val: '',
|
|
221
|
+
type: type
|
|
222
|
+
};
|
|
223
|
+
} else if (type === _types.AtomsTypeEnum.INPUT_NUMBER) {
|
|
224
|
+
return {
|
|
225
|
+
val: 0,
|
|
226
|
+
type: type
|
|
227
|
+
};
|
|
228
|
+
} else if (type === _types.AtomsTypeEnum.INPUT_NUMBER_LIST || type === _types.AtomsTypeEnum.INPUT_STRING_LIST) {
|
|
229
|
+
temItem = {
|
|
230
|
+
val: [],
|
|
231
|
+
type: type
|
|
232
|
+
};
|
|
233
|
+
} else if (type === _types.AtomsTypeEnum.FORMULA) {
|
|
234
|
+
temItem = {
|
|
235
|
+
args: [],
|
|
236
|
+
// params: FUNCTION_TEMPLATES?.[type]?.params || [],
|
|
237
|
+
// arity: FUNCTION_TEMPLATES?.[type]?.arity || {},
|
|
238
|
+
name: '',
|
|
239
|
+
quotes: '',
|
|
240
|
+
type: type
|
|
241
|
+
};
|
|
242
|
+
} else if (type === _types.AtomsTypeEnum.COLLECTION) {
|
|
243
|
+
return {
|
|
244
|
+
list: [],
|
|
245
|
+
quotes: '',
|
|
246
|
+
type: type
|
|
247
|
+
};
|
|
248
|
+
} else {
|
|
249
|
+
// 其他
|
|
250
|
+
temItem = {
|
|
251
|
+
val: '',
|
|
252
|
+
type: type
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
return temItem;
|
|
256
|
+
};
|
|
257
|
+
var _isOk = exports.isOk = function isOk(rhsVal) {
|
|
258
|
+
return rhsVal.every(function (v) {
|
|
259
|
+
if (v.type === _types.AtomsTypeEnum.UNKNOWN) {
|
|
260
|
+
return false;
|
|
261
|
+
} else if (v.type === _types.AtomsTypeEnum.JOIN_DEFAULT) {
|
|
262
|
+
// 这个情况应该是不存在的
|
|
263
|
+
return true; // 或者根据业务逻辑决定是否算“有效”
|
|
264
|
+
} else if (v.type === _types.AtomsTypeEnum.FIELD) {
|
|
265
|
+
return Boolean(v.fieldName); // 确保 fieldName 存在且非空
|
|
266
|
+
} else if (v.type === _types.AtomsTypeEnum.EXPRESSION || v.type === _types.AtomsTypeEnum.EXISTS || v.type === _types.AtomsTypeEnum.NOT_EXISTS) {
|
|
267
|
+
return Boolean(v.quotes); // 确保 quotes 存在
|
|
268
|
+
} else if (v.type === _types.AtomsTypeEnum.INPUT_STRING_LIST) {
|
|
269
|
+
return Array.isArray(v.val) && v.val.every(function (vv) {
|
|
270
|
+
return Boolean(vv);
|
|
271
|
+
});
|
|
272
|
+
} else if (v.type === _types.AtomsTypeEnum.COLLECTION) {
|
|
273
|
+
return _isOk(v.list || []);
|
|
274
|
+
} else if (v.type === _types.AtomsTypeEnum.FORMULA) {
|
|
275
|
+
if (!v.quotes) {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
return _isOk(v.args || []);
|
|
279
|
+
} else {
|
|
280
|
+
return Boolean(v.val); // 兜底,确保 val 存在
|
|
281
|
+
}
|
|
282
|
+
});
|
|
126
283
|
};
|
|
@@ -28,7 +28,12 @@ export declare enum FunctionEnum {
|
|
|
28
28
|
'COALESCE' = "coalesce"
|
|
29
29
|
}
|
|
30
30
|
export declare const operatorList: string[];
|
|
31
|
-
export declare const customTypes: {
|
|
31
|
+
export declare const customTypes: ({
|
|
32
32
|
value: AtomsTypeEnum;
|
|
33
33
|
label: any;
|
|
34
|
-
|
|
34
|
+
children?: undefined;
|
|
35
|
+
} | {
|
|
36
|
+
value: AtomsTypeEnum;
|
|
37
|
+
label: any;
|
|
38
|
+
children: string[];
|
|
39
|
+
})[];
|
|
@@ -104,12 +104,12 @@ var customTypes = exports.customTypes = [
|
|
|
104
104
|
// 输入框
|
|
105
105
|
{
|
|
106
106
|
value: _types.AtomsTypeEnum.INPUT_STRING,
|
|
107
|
-
label: (0, _locale.__)('
|
|
107
|
+
label: (0, _locale.__)('customColumn.input')
|
|
108
108
|
},
|
|
109
109
|
// 数字输入框
|
|
110
110
|
{
|
|
111
111
|
value: _types.AtomsTypeEnum.INPUT_NUMBER,
|
|
112
|
-
label: (0, _locale.__)('
|
|
112
|
+
label: (0, _locale.__)('customColumn.numberInput')
|
|
113
113
|
},
|
|
114
114
|
// 表达式
|
|
115
115
|
{
|
|
@@ -121,6 +121,12 @@ var customTypes = exports.customTypes = [
|
|
|
121
121
|
value: _types.AtomsTypeEnum.OPERATOR,
|
|
122
122
|
label: (0, _locale.__)('customColumn.operator')
|
|
123
123
|
},
|
|
124
|
+
// 函数
|
|
125
|
+
{
|
|
126
|
+
value: _types.AtomsTypeEnum.FORMULA,
|
|
127
|
+
label: (0, _locale.__)('customColumn.formula'),
|
|
128
|
+
children: operatorList
|
|
129
|
+
},
|
|
124
130
|
// EXISTS
|
|
125
131
|
{
|
|
126
132
|
value: _types.AtomsTypeEnum.NOT_EXISTS,
|
|
@@ -693,10 +693,10 @@ var JoinData = function JoinData(props) {
|
|
|
693
693
|
// value={(((newMeta[index] as MetaJoin).expressions[_ind] as AtomsExpression)[position])[`type`]}
|
|
694
694
|
list: [{
|
|
695
695
|
value: _types.AtomsTypeEnum.INPUT_STRING,
|
|
696
|
-
label: (0, _locale.__)('
|
|
696
|
+
label: (0, _locale.__)('customColumn.input')
|
|
697
697
|
}, {
|
|
698
698
|
value: _types.AtomsTypeEnum.INPUT_NUMBER,
|
|
699
|
-
label: (0, _locale.__)('
|
|
699
|
+
label: (0, _locale.__)('customColumn.numberInput')
|
|
700
700
|
}, {
|
|
701
701
|
value: _types.AtomsTypeEnum.CONSTANT,
|
|
702
702
|
label: (0, _locale.__)('customColumn.constant')
|
|
@@ -1362,6 +1362,31 @@ var JoinData = function JoinData(props) {
|
|
|
1362
1362
|
})]
|
|
1363
1363
|
}, i);
|
|
1364
1364
|
}
|
|
1365
|
+
// if (v.type === AtomsTypeEnum.COLLECTION) {
|
|
1366
|
+
// return (
|
|
1367
|
+
// <FormulaList
|
|
1368
|
+
// // check={formulaList?.[fun.name]?.args?.[i]?.check || ''}
|
|
1369
|
+
// value={v.list}
|
|
1370
|
+
// data={data}
|
|
1371
|
+
// ref={ref}
|
|
1372
|
+
// onChange={(data, _quotes) => {
|
|
1373
|
+
// const _args = cloneDeep(fun.args);
|
|
1374
|
+
// (_args[i] as AtomsCollection).list = data;
|
|
1375
|
+
// (_args[i] as AtomsCollection).quotes = _quotes || '';
|
|
1376
|
+
// const quotes = (_args as AtomsCollection[])
|
|
1377
|
+
// .map((v) => {
|
|
1378
|
+
// return v.quotes;
|
|
1379
|
+
// })
|
|
1380
|
+
// .join(' , ');
|
|
1381
|
+
// setFun({
|
|
1382
|
+
// ...fun,
|
|
1383
|
+
// quotes: fun.name + ' ( ' + quotes + ' ) ',
|
|
1384
|
+
// args: _args,
|
|
1385
|
+
// });
|
|
1386
|
+
// }}
|
|
1387
|
+
// ></FormulaList>
|
|
1388
|
+
// );
|
|
1389
|
+
// }
|
|
1365
1390
|
})), ((_meta$table9 = meta.table2) === null || _meta$table9 === void 0 ? void 0 : _meta$table9.name) && ((_meta$table0 = meta.table1) === null || _meta$table0 === void 0 ? void 0 : _meta$table0.name) && (((_meta$expressions2 = meta.expressions) === null || _meta$expressions2 === void 0 ? void 0 : _meta$expressions2.length) || 0) < 1 && (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
|
|
1366
1391
|
title: (0, _locale.__)('SqlQueryBuilder.add'),
|
|
1367
1392
|
children: (0, _jsxRuntime.jsx)(_pandora.Dropdown, {
|
package/lib/cjs/hooks/patch.js
CHANGED
|
@@ -11,33 +11,35 @@ var _utils = require("../utils");
|
|
|
11
11
|
var _types = require("../store/types");
|
|
12
12
|
var _enum = require("../store/enum");
|
|
13
13
|
var dataPatch = exports.dataPatch = function dataPatch(newMeta) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (item
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
14
|
+
// let item = newMeta.expressions?.[0] || {};
|
|
15
|
+
// if (item?.type && Object.values(AtomsTypeEnum).includes(item.type)) {
|
|
16
|
+
// if (item.type === AtomsTypeEnum.EXPRESSION && item.lhs) {
|
|
17
|
+
// return newMeta;
|
|
18
|
+
// }
|
|
19
|
+
// }
|
|
21
20
|
newMeta.subquery = _patchMetas(newMeta.subquery);
|
|
22
21
|
return newMeta;
|
|
23
22
|
};
|
|
24
23
|
var joinDataPatch = exports.joinDataPatch = function joinDataPatch(newMeta) {
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
if (item
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
24
|
+
var _fields, _fields2, _fields3, _fields4, _newMeta$expressions;
|
|
25
|
+
// let item = newMeta.expressions?.[0] || {};
|
|
26
|
+
// if (item?.type && Object.values(AtomsTypeEnum).includes(item.type)) {
|
|
27
|
+
// if (
|
|
28
|
+
// (item.type === AtomsTypeEnum.EXPRESSION || item.type === AtomsTypeEnum.JOIN_DEFAULT) &&
|
|
29
|
+
// item.lhs
|
|
30
|
+
// ) {
|
|
31
|
+
// return newMeta;
|
|
32
|
+
// }
|
|
33
|
+
// if (item.type === AtomsTypeEnum.EXISTS && !item.tableUuid) {
|
|
34
|
+
// return newMeta;
|
|
35
|
+
// }
|
|
36
|
+
// if (item.type === AtomsTypeEnum.NOT_EXISTS && !item.tableUuid) {
|
|
37
|
+
// return newMeta;
|
|
38
|
+
// }
|
|
39
|
+
// if (item.type === AtomsTypeEnum.FIELD && item.fieldName) {
|
|
40
|
+
// return newMeta;
|
|
41
|
+
// }
|
|
42
|
+
// }
|
|
41
43
|
// if (
|
|
42
44
|
// newMeta.expressions?.[0]?.type &&
|
|
43
45
|
// Object.values(AtomsTypeEnum).includes(newMeta.expressions[0].type)
|
|
@@ -127,7 +129,7 @@ var joinDataPatch = exports.joinDataPatch = function joinDataPatch(newMeta) {
|
|
|
127
129
|
type: 'default' // 默认是字段模式
|
|
128
130
|
}];
|
|
129
131
|
}
|
|
130
|
-
var expressions = ((_newMeta$
|
|
132
|
+
var expressions = ((_newMeta$expressions = newMeta.expressions) === null || _newMeta$expressions === void 0 ? void 0 : _newMeta$expressions.map(function (v) {
|
|
131
133
|
var _left_fields, _right_fields;
|
|
132
134
|
var left_fields = v.left_fields || [];
|
|
133
135
|
var right_fields = v.right_fields || [];
|
|
@@ -268,23 +270,23 @@ var joinDataPatch = exports.joinDataPatch = function joinDataPatch(newMeta) {
|
|
|
268
270
|
return newMeta;
|
|
269
271
|
};
|
|
270
272
|
var filterPatch = exports.filterPatch = function filterPatch(newMeta) {
|
|
271
|
-
var _newMeta$filter
|
|
272
|
-
|
|
273
|
-
if (item
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
var _filter = (_newMeta$
|
|
273
|
+
var _newMeta$filter;
|
|
274
|
+
// let item = newMeta.filter?.[0] || {};
|
|
275
|
+
// if (item?.type && Object.values(AtomsTypeEnum).includes(item.type)) {
|
|
276
|
+
// if (item.type === AtomsTypeEnum.EXPRESSION && item.lhs) {
|
|
277
|
+
// return newMeta;
|
|
278
|
+
// }
|
|
279
|
+
// if (item.type === AtomsTypeEnum.EXISTS && !item.tableUuid) {
|
|
280
|
+
// return newMeta;
|
|
281
|
+
// }
|
|
282
|
+
// if (item.type === AtomsTypeEnum.NOT_EXISTS && !item.tableUuid) {
|
|
283
|
+
// return newMeta;
|
|
284
|
+
// }
|
|
285
|
+
// if (item.type === AtomsTypeEnum.FIELD && item.fieldName) {
|
|
286
|
+
// return newMeta;
|
|
287
|
+
// }
|
|
288
|
+
// }
|
|
289
|
+
var _filter = (_newMeta$filter = newMeta.filter) === null || _newMeta$filter === void 0 ? void 0 : _newMeta$filter.map(function (v) {
|
|
288
290
|
// 表达式
|
|
289
291
|
var tem;
|
|
290
292
|
if (typeof v === 'string') {
|
|
@@ -376,23 +378,23 @@ var filterPatch = exports.filterPatch = function filterPatch(newMeta) {
|
|
|
376
378
|
return newMeta;
|
|
377
379
|
};
|
|
378
380
|
var customColumnPatch = exports.customColumnPatch = function customColumnPatch(newMeta) {
|
|
379
|
-
var _newMeta$customColumn
|
|
380
|
-
|
|
381
|
-
if (item
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
}
|
|
395
|
-
newMeta.customColumn = (newMeta === null || newMeta === void 0 || (_newMeta$
|
|
381
|
+
var _newMeta$customColumn;
|
|
382
|
+
// let item = newMeta.customColumn?.[0]?.formulaList?.[0] || {};
|
|
383
|
+
// if (item?.type && Object.values(AtomsTypeEnum).includes(item.type)) {
|
|
384
|
+
// if (item.type === AtomsTypeEnum.EXPRESSION && item.lhs) {
|
|
385
|
+
// return newMeta;
|
|
386
|
+
// }
|
|
387
|
+
// if (item.type === AtomsTypeEnum.EXISTS && !item.tableUuid) {
|
|
388
|
+
// return newMeta;
|
|
389
|
+
// }
|
|
390
|
+
// if (item.type === AtomsTypeEnum.NOT_EXISTS && !item.tableUuid) {
|
|
391
|
+
// return newMeta;
|
|
392
|
+
// }
|
|
393
|
+
// if (item.type === AtomsTypeEnum.FIELD && item.fieldName) {
|
|
394
|
+
// return newMeta;
|
|
395
|
+
// }
|
|
396
|
+
// }
|
|
397
|
+
newMeta.customColumn = (newMeta === null || newMeta === void 0 || (_newMeta$customColumn = newMeta.customColumn) === null || _newMeta$customColumn === void 0 ? void 0 : _newMeta$customColumn.map(function (v) {
|
|
396
398
|
var _formulaList = v.formulaList.map(function (formula) {
|
|
397
399
|
var tem = formula;
|
|
398
400
|
if (formula.type === 'expression') {
|
|
@@ -509,23 +511,23 @@ var customColumnPatch = exports.customColumnPatch = function customColumnPatch(n
|
|
|
509
511
|
return newMeta;
|
|
510
512
|
};
|
|
511
513
|
var sortPatch = exports.sortPatch = function sortPatch(newMeta) {
|
|
512
|
-
var _newMeta$sort
|
|
513
|
-
|
|
514
|
-
if (item
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
}
|
|
528
|
-
var _sort = (_newMeta$
|
|
514
|
+
var _newMeta$sort;
|
|
515
|
+
// let item = newMeta.sort?.[0].expression?.[0] || {};
|
|
516
|
+
// if (item?.type && Object.values(AtomsTypeEnum).includes(item.type)) {
|
|
517
|
+
// if (item.type === AtomsTypeEnum.EXPRESSION && item.lhs) {
|
|
518
|
+
// return newMeta;
|
|
519
|
+
// }
|
|
520
|
+
// if (item.type === AtomsTypeEnum.EXISTS && !item.tableUuid) {
|
|
521
|
+
// return newMeta;
|
|
522
|
+
// }
|
|
523
|
+
// if (item.type === AtomsTypeEnum.NOT_EXISTS && !item.tableUuid) {
|
|
524
|
+
// return newMeta;
|
|
525
|
+
// }
|
|
526
|
+
// if (item.type === AtomsTypeEnum.FIELD && item.fieldName) {
|
|
527
|
+
// return newMeta;
|
|
528
|
+
// }
|
|
529
|
+
// }
|
|
530
|
+
var _sort = (_newMeta$sort = newMeta.sort) === null || _newMeta$sort === void 0 ? void 0 : _newMeta$sort.map(function (v) {
|
|
529
531
|
return {
|
|
530
532
|
expression: [{
|
|
531
533
|
fieldName: v.name,
|
|
@@ -77,50 +77,54 @@ var useStore = function useStore() {
|
|
|
77
77
|
_useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
|
|
78
78
|
constantList = _useState14[0],
|
|
79
79
|
setConstantList = _useState14[1]; //常量列表
|
|
80
|
-
var _useState15 = (0, _react.useState)(
|
|
80
|
+
var _useState15 = (0, _react.useState)([]),
|
|
81
81
|
_useState16 = (0, _slicedToArray2["default"])(_useState15, 2),
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
formulaTemplates = _useState16[0],
|
|
83
|
+
setFormulaTemplates = _useState16[1]; //公式配置数组
|
|
84
84
|
var _useState17 = (0, _react.useState)(false),
|
|
85
85
|
_useState18 = (0, _slicedToArray2["default"])(_useState17, 2),
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
var _useState19 = (0, _react.useState)(
|
|
86
|
+
ignoreGroupByType = _useState18[0],
|
|
87
|
+
setIgnoreGroupByType = _useState18[1]; // 忽略groupBy类型
|
|
88
|
+
var _useState19 = (0, _react.useState)(false),
|
|
89
89
|
_useState20 = (0, _slicedToArray2["default"])(_useState19, 2),
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
filterCustomType = _useState20[0],
|
|
91
|
+
setfilterCustomType = _useState20[1]; // 过滤器自定义类型
|
|
92
92
|
var _useState21 = (0, _react.useState)({}),
|
|
93
93
|
_useState22 = (0, _slicedToArray2["default"])(_useState21, 2),
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
var _useState23 = (0, _react.useState)(
|
|
94
|
+
_cacheSource2TableMap = _useState22[0],
|
|
95
|
+
set_cacheSource2TableMap = _useState22[1]; //数据源id 对应数据集列表
|
|
96
|
+
var _useState23 = (0, _react.useState)({}),
|
|
97
97
|
_useState24 = (0, _slicedToArray2["default"])(_useState23, 2),
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
var _useState25 = (0, _react.useState)(
|
|
98
|
+
_cacheColumnsMap = _useState24[0],
|
|
99
|
+
set_cacheColumnsMap = _useState24[1]; //数据源id 对应数据集列表
|
|
100
|
+
var _useState25 = (0, _react.useState)(defaultMeta),
|
|
101
|
+
_useState26 = (0, _slicedToArray2["default"])(_useState25, 2),
|
|
102
|
+
metaList = _useState26[0],
|
|
103
|
+
_setMeta = _useState26[1]; //数据源id 对应数据集列表
|
|
104
|
+
var _useState27 = (0, _react.useState)({
|
|
101
105
|
visible: false,
|
|
102
106
|
node: null,
|
|
103
107
|
content: null
|
|
104
108
|
}),
|
|
105
|
-
|
|
106
|
-
popupData =
|
|
107
|
-
setPopup =
|
|
108
|
-
var
|
|
109
|
+
_useState28 = (0, _slicedToArray2["default"])(_useState27, 2),
|
|
110
|
+
popupData = _useState28[0],
|
|
111
|
+
setPopup = _useState28[1]; //弹窗
|
|
112
|
+
var _useState29 = (0, _react.useState)({
|
|
109
113
|
visible: false,
|
|
110
114
|
node: null,
|
|
111
115
|
content: null
|
|
112
116
|
}),
|
|
113
|
-
_useState28 = (0, _slicedToArray2["default"])(_useState27, 2),
|
|
114
|
-
popupData2 = _useState28[0],
|
|
115
|
-
setPopup2 = _useState28[1]; //弹窗
|
|
116
|
-
var _useState29 = (0, _react.useState)(true),
|
|
117
117
|
_useState30 = (0, _slicedToArray2["default"])(_useState29, 2),
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
popupData2 = _useState30[0],
|
|
119
|
+
setPopup2 = _useState30[1]; //弹窗
|
|
120
120
|
var _useState31 = (0, _react.useState)(true),
|
|
121
121
|
_useState32 = (0, _slicedToArray2["default"])(_useState31, 2),
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
popupClosable = _useState32[0],
|
|
123
|
+
setClosable = _useState32[1]; //是否可关闭 如果弹框里面再弹框 则不可关闭
|
|
124
|
+
var _useState33 = (0, _react.useState)(true),
|
|
125
|
+
_useState34 = (0, _slicedToArray2["default"])(_useState33, 2),
|
|
126
|
+
popupClosable2 = _useState34[0],
|
|
127
|
+
setClosable2 = _useState34[1]; //是否可关闭 如果弹框里面再弹框 则不可关闭
|
|
124
128
|
// 外层ref
|
|
125
129
|
var popupContainer = (0, _react.useRef)();
|
|
126
130
|
// const [fetchDatasetFn, setFetchDatasetFn] = useState<(id: string) => Promise<any>>(
|
|
@@ -592,7 +596,9 @@ var useStore = function useStore() {
|
|
|
592
596
|
ignoreGroupByType: ignoreGroupByType,
|
|
593
597
|
setIgnoreGroupByType: setIgnoreGroupByType,
|
|
594
598
|
filterCustomType: filterCustomType,
|
|
595
|
-
setfilterCustomType: setfilterCustomType
|
|
599
|
+
setfilterCustomType: setfilterCustomType,
|
|
600
|
+
formulaTemplates: formulaTemplates,
|
|
601
|
+
setFormulaTemplates: setFormulaTemplates
|
|
596
602
|
};
|
|
597
603
|
};
|
|
598
604
|
var _default = exports["default"] = useStore;
|
package/lib/cjs/index.js
CHANGED
|
@@ -48,6 +48,7 @@ var SqlVisionBuilder = _react["default"].forwardRef(function (props, ref) {
|
|
|
48
48
|
_props$subShowSubquer = props.subShowSubquery,
|
|
49
49
|
subShowSubquery = _props$subShowSubquer === void 0 ? false : _props$subShowSubquer,
|
|
50
50
|
constantList = props.constantList,
|
|
51
|
+
formulaTemplates = props.formulaTemplates,
|
|
51
52
|
_props$ignoreGroupByT = props.ignoreGroupByType,
|
|
52
53
|
ignoreGroupByType = _props$ignoreGroupByT === void 0 ? false : _props$ignoreGroupByT,
|
|
53
54
|
_props$filterCustomTy = props.filterCustomType,
|
|
@@ -75,9 +76,10 @@ var SqlVisionBuilder = _react["default"].forwardRef(function (props, ref) {
|
|
|
75
76
|
store.setShowSubquery(showSubquery);
|
|
76
77
|
store._setShowSubquery(subShowSubquery);
|
|
77
78
|
store.setConstantList(constantList || []);
|
|
79
|
+
store.setFormulaTemplates(formulaTemplates || []);
|
|
78
80
|
store.setIgnoreGroupByType(ignoreGroupByType);
|
|
79
81
|
store.setfilterCustomType(filterCustomType);
|
|
80
|
-
}, [showFields, fieldNameTpl, tableNameTpl, toolbar, showSubquery, subShowSubquery, constantList, ignoreGroupByType, filterCustomType]);
|
|
82
|
+
}, [showFields, fieldNameTpl, tableNameTpl, toolbar, showSubquery, subShowSubquery, constantList, formulaTemplates, ignoreGroupByType, filterCustomType]);
|
|
81
83
|
_react["default"].useImperativeHandle(ref, function () {
|
|
82
84
|
return {
|
|
83
85
|
// setDatasource: (list) => {
|
package/lib/cjs/locale/en.js
CHANGED
|
@@ -39,8 +39,10 @@ var _default = exports["default"] = (0, _index.register)('en', {
|
|
|
39
39
|
'SqlQueryBuilder.customExpression': 'customExpression',
|
|
40
40
|
'SqlQueryBuilder.pickTable': 'Select data table...',
|
|
41
41
|
'SqlQueryBuilder.pickConstant': 'Select constant...',
|
|
42
|
-
'
|
|
43
|
-
'
|
|
42
|
+
'customColumn.input': 'Input',
|
|
43
|
+
'customColumn.numberInput': 'Number input',
|
|
44
|
+
'customColumn.formula': 'Formula',
|
|
45
|
+
'customColumn.selectFormula': 'Select formula...',
|
|
44
46
|
'SqlQueryBuilder.switchSubQuery': 'Open subquery',
|
|
45
47
|
'SqlQueryBuilder.setSubQuery': 'Set Subquery...',
|
|
46
48
|
'SqlQueryBuilder.subquery': 'Subquery',
|
package/lib/cjs/locale/zh.js
CHANGED
|
@@ -39,8 +39,6 @@ var _default = exports["default"] = (0, _index.register)('zh', {
|
|
|
39
39
|
'SqlQueryBuilder.customExpression': '自定义表达方式',
|
|
40
40
|
'SqlQueryBuilder.pickTable': '选择数据表...',
|
|
41
41
|
'SqlQueryBuilder.pickConstant': '选择常量...',
|
|
42
|
-
'SqlQueryBuilder.input': '输入框',
|
|
43
|
-
'SqlQueryBuilder.numberInput': '数字输入框',
|
|
44
42
|
'SqlQueryBuilder.switchSubQuery': '切换子查询',
|
|
45
43
|
'SqlQueryBuilder.setSubQuery': '设置子查询...',
|
|
46
44
|
'SqlQueryBuilder.subquery': '子查询',
|
|
@@ -71,6 +69,10 @@ var _default = exports["default"] = (0, _index.register)('zh', {
|
|
|
71
69
|
'customColumn.selectExpression': '选择表达式',
|
|
72
70
|
'customColumn.selectOtherSyntax': '选择其他语法',
|
|
73
71
|
'customColumn.selectCustomInput': '选择自定义输入框',
|
|
72
|
+
'customColumn.formula': '公式',
|
|
73
|
+
'customColumn.selectFormula': '选择公式...',
|
|
74
|
+
'customColumn.input': '输入框',
|
|
75
|
+
'customColumn.numberInput': '数字输入框',
|
|
74
76
|
'filter.addFilter': '添加过滤器',
|
|
75
77
|
'filter.confirm': '确认',
|
|
76
78
|
'filter.pleaseEnter': '请输入',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MetaListType, MetaSummarize_Group
|
|
1
|
+
import { MetaListType, MetaSummarize_Group } from './types';
|
|
2
2
|
export declare const SummarizeAlias = "source";
|
|
3
3
|
export declare const summarizeToSql: (arr: MetaSummarize_Group[], record: MetaSummarize_Group) => {
|
|
4
4
|
sql: string;
|
|
@@ -6,4 +6,3 @@ export declare const summarizeToSql: (arr: MetaSummarize_Group[], record: MetaSu
|
|
|
6
6
|
};
|
|
7
7
|
export declare const compressionStructure: (data: MetaListType[]) => string;
|
|
8
8
|
export declare const restoreStructure: (data: string) => MetaListType[];
|
|
9
|
-
export declare const getTemItem: (type: AtomsTypeEnum) => AtomsItem;
|