@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,51 +4,53 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
|
|
|
4
4
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
5
|
var _excluded = ["notExistsToolbar", "toolbar"];
|
|
6
6
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
-
import {
|
|
7
|
+
import { useState, forwardRef } from 'react';
|
|
8
8
|
import cx from 'classnames';
|
|
9
9
|
// import './index.less';
|
|
10
10
|
import Metabase from '../../../index';
|
|
11
11
|
import { __ } from '../../../locale';
|
|
12
12
|
import isEqual from 'lodash/isEqual';
|
|
13
|
-
import { getTemplate } from './utils';
|
|
14
|
-
import { customTypes, operatorList } from './enum';
|
|
15
13
|
import { AtomsTypeEnum } from '../../../store/types';
|
|
16
14
|
import { ColumnsPopupThemeEnum } from '../../../store/enum';
|
|
17
15
|
import { Select, Input, Modal2, InputNumber } from '@gingkoo/pandora';
|
|
18
16
|
import cloneDeep from 'lodash/cloneDeep';
|
|
19
|
-
import { getTemItem } from '../../../store/helper';
|
|
20
17
|
import { buildSqlQuery } from '../../../utils';
|
|
18
|
+
import Formula from '../formula';
|
|
21
19
|
import { AddIcon, CloseIcon } from '../../icons';
|
|
22
20
|
import { Expression, SelectColumnMultiple } from '../../dialog';
|
|
21
|
+
import { customTypes, operatorList, insertTemplateAt, getTemplateItem } from './utils';
|
|
23
22
|
import SelectList from '../../dialog/select-list';
|
|
24
23
|
import arrow from './arrow.svg';
|
|
25
|
-
import { useStore } from '../../../hooks/use-provider';
|
|
24
|
+
import { useStore, Provider } from '../../../hooks/use-provider';
|
|
26
25
|
var FormulaList = forwardRef(function (props, ref) {
|
|
27
26
|
var value = props.value,
|
|
28
27
|
data = props.data,
|
|
29
|
-
isCustom = props.isCustom,
|
|
30
28
|
exitData = props.exitData,
|
|
31
29
|
onChange = props.onChange,
|
|
32
30
|
_props$customTypes = props.customTypes,
|
|
33
31
|
_customTypes = _props$customTypes === void 0 ? customTypes : _props$customTypes,
|
|
34
32
|
_props$operatorList = props.operatorList,
|
|
35
|
-
_operatorList = _props$operatorList === void 0 ? operatorList : _props$operatorList
|
|
36
|
-
|
|
33
|
+
_operatorList = _props$operatorList === void 0 ? operatorList : _props$operatorList,
|
|
34
|
+
check = props.check;
|
|
35
|
+
var caseList = value || [];
|
|
36
|
+
var setCaseList = function setCaseList(data) {
|
|
37
|
+
var quotes = data.map(function (v, i) {
|
|
38
|
+
if (v !== null && v !== void 0 && v.quotes) {
|
|
39
|
+
return v === null || v === void 0 ? void 0 : v.quotes;
|
|
40
|
+
} else if (v !== null && v !== void 0 && v.fieldName) {
|
|
41
|
+
return v === null || v === void 0 ? void 0 : v.fieldName;
|
|
42
|
+
} else {
|
|
43
|
+
return v.val;
|
|
44
|
+
}
|
|
45
|
+
}).join(' ');
|
|
46
|
+
onChange === null || onChange === void 0 || onChange(data, quotes);
|
|
47
|
+
};
|
|
48
|
+
var _useState = useState(-1),
|
|
37
49
|
_useState2 = _slicedToArray(_useState, 2),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// useEffect(() => {
|
|
41
|
-
// setCaseList(value);
|
|
42
|
-
// }, [value]);
|
|
43
|
-
var _useState3 = useState(-1),
|
|
44
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
45
|
-
ind = _useState4[0],
|
|
46
|
-
setInd = _useState4[1];
|
|
50
|
+
ind = _useState2[0],
|
|
51
|
+
setInd = _useState2[1];
|
|
47
52
|
var store = useStore();
|
|
48
53
|
var filterCustomType = store.filterCustomType;
|
|
49
|
-
useEffect(function () {
|
|
50
|
-
onChange === null || onChange === void 0 || onChange(caseList);
|
|
51
|
-
}, [caseList]);
|
|
52
54
|
function closePopup() {
|
|
53
55
|
store.setPopup({
|
|
54
56
|
visible: false
|
|
@@ -79,7 +81,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
79
81
|
var _caseList = caseList.slice();
|
|
80
82
|
var oldType = _caseList[i].val;
|
|
81
83
|
_caseList[i].val = val;
|
|
82
|
-
_caseList =
|
|
84
|
+
_caseList = insertTemplateAt(oldType, val, _caseList, i);
|
|
83
85
|
setCaseList(_caseList);
|
|
84
86
|
};
|
|
85
87
|
// 表达式
|
|
@@ -113,7 +115,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
113
115
|
// 添加
|
|
114
116
|
var addOperator = function addOperator(type, index, position) {
|
|
115
117
|
var _caseList = caseList.slice() || [];
|
|
116
|
-
var temItem =
|
|
118
|
+
var temItem = getTemplateItem(type);
|
|
117
119
|
if (position === 'add') {
|
|
118
120
|
_caseList.push(temItem);
|
|
119
121
|
} else if (position === 'before') {
|
|
@@ -195,6 +197,33 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
195
197
|
})
|
|
196
198
|
});
|
|
197
199
|
}
|
|
200
|
+
// 函数弹窗
|
|
201
|
+
var showFunction = function showFunction(e, i) {
|
|
202
|
+
var _value = caseList[i];
|
|
203
|
+
var o = Modal2.openModal({
|
|
204
|
+
title: __('customColumn.formula'),
|
|
205
|
+
transparentMask: true,
|
|
206
|
+
content: _jsx(_Fragment, {
|
|
207
|
+
children: _jsx(Provider, {
|
|
208
|
+
value: store,
|
|
209
|
+
children: _jsx(Formula, {
|
|
210
|
+
data: data,
|
|
211
|
+
value: _value,
|
|
212
|
+
onCancel: function onCancel() {
|
|
213
|
+
o.close();
|
|
214
|
+
},
|
|
215
|
+
onOk: function onOk(data) {
|
|
216
|
+
var _caseList = caseList.slice();
|
|
217
|
+
_caseList[i] = data;
|
|
218
|
+
setCaseList(_caseList);
|
|
219
|
+
o.close();
|
|
220
|
+
}
|
|
221
|
+
})
|
|
222
|
+
})
|
|
223
|
+
}),
|
|
224
|
+
onClose: function onClose() {}
|
|
225
|
+
});
|
|
226
|
+
};
|
|
198
227
|
// 分段
|
|
199
228
|
var itemDom = function itemDom(v, index) {
|
|
200
229
|
var type = v.type;
|
|
@@ -312,14 +341,22 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
312
341
|
});
|
|
313
342
|
} else if (type === AtomsTypeEnum.CONSTANT) {
|
|
314
343
|
//常量
|
|
315
|
-
return
|
|
344
|
+
return _jsxs("div", {
|
|
316
345
|
className: cx("Sqb-TableName", {
|
|
317
346
|
notSelected: !v.val
|
|
318
347
|
}),
|
|
319
348
|
"v-index": index,
|
|
320
349
|
"v-val": v.val,
|
|
321
350
|
onClick: selectConstant,
|
|
322
|
-
children: v.val ? v.val : __('SqlQueryBuilder.pickConstant')
|
|
351
|
+
children: [v.val ? v.val : __('SqlQueryBuilder.pickConstant'), _jsx("span", {
|
|
352
|
+
style: {
|
|
353
|
+
fontSize: 0
|
|
354
|
+
},
|
|
355
|
+
onClick: function onClick(e) {
|
|
356
|
+
return handleDel(e, index);
|
|
357
|
+
},
|
|
358
|
+
children: _jsx(CloseIcon, {})
|
|
359
|
+
})]
|
|
323
360
|
}, index);
|
|
324
361
|
} else if (type === AtomsTypeEnum.EXPRESSION) {
|
|
325
362
|
// 表达式
|
|
@@ -330,7 +367,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
330
367
|
onClick: function onClick(e) {
|
|
331
368
|
return handleExpression(e, index, v);
|
|
332
369
|
},
|
|
333
|
-
children: [
|
|
370
|
+
children: [v.quotes ? v.quotes : __('customColumn.selectExpression'), _jsx("span", {
|
|
334
371
|
style: {
|
|
335
372
|
fontSize: 0
|
|
336
373
|
},
|
|
@@ -340,6 +377,23 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
340
377
|
children: _jsx(CloseIcon, {})
|
|
341
378
|
})]
|
|
342
379
|
});
|
|
380
|
+
} else if (type === AtomsTypeEnum.FORMULA) {
|
|
381
|
+
// 公式
|
|
382
|
+
return _jsxs("div", {
|
|
383
|
+
className: "Sqb-TableName gray-name",
|
|
384
|
+
onClick: function onClick(e) {
|
|
385
|
+
return showFunction(e, index);
|
|
386
|
+
},
|
|
387
|
+
children: [v.quotes ? v.quotes : __('customColumn.selectFormula'), _jsx("span", {
|
|
388
|
+
style: {
|
|
389
|
+
fontSize: 0
|
|
390
|
+
},
|
|
391
|
+
onClick: function onClick(e) {
|
|
392
|
+
return handleDel(e, index);
|
|
393
|
+
},
|
|
394
|
+
children: _jsx(CloseIcon, {})
|
|
395
|
+
})]
|
|
396
|
+
}, index);
|
|
343
397
|
} else {
|
|
344
398
|
return _jsx(Select, {
|
|
345
399
|
triggerProps: {
|
|
@@ -482,7 +536,11 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
482
536
|
})
|
|
483
537
|
})]
|
|
484
538
|
}), _jsxs("p", {
|
|
485
|
-
className:
|
|
539
|
+
className: "mb-2 font-bold uppercase tracking-wider",
|
|
540
|
+
style: {
|
|
541
|
+
fontSize: 12,
|
|
542
|
+
color: '#949aab'
|
|
543
|
+
},
|
|
486
544
|
children: ["\u9884\u89C8\uFF1A", caseList.map(function (v, i) {
|
|
487
545
|
if (v !== null && v !== void 0 && v.quotes) {
|
|
488
546
|
return v === null || v === void 0 ? void 0 : v.quotes;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AtomsTypeEnum, AtomsItem } from '../../../store/types';
|
|
1
2
|
/**
|
|
2
3
|
*
|
|
3
4
|
* @param type 当前选择的类型
|
|
@@ -5,4 +6,16 @@
|
|
|
5
6
|
* @param index 需要讲模版插入的位置
|
|
6
7
|
* @returns
|
|
7
8
|
*/
|
|
8
|
-
export declare const
|
|
9
|
+
export declare const insertTemplateAt: (oldType: string, type: string, list: any[], index: number) => any[];
|
|
10
|
+
export declare const operatorList: string[];
|
|
11
|
+
export declare const customTypes: ({
|
|
12
|
+
value: AtomsTypeEnum;
|
|
13
|
+
label: any;
|
|
14
|
+
children?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
value: AtomsTypeEnum;
|
|
17
|
+
label: any;
|
|
18
|
+
children: string[];
|
|
19
|
+
})[];
|
|
20
|
+
export declare const getTemplateItem: (type: AtomsTypeEnum) => AtomsItem;
|
|
21
|
+
export declare const isOk: (rhsVal: AtomsItem[]) => boolean;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import { __ } from '../../../locale';
|
|
2
3
|
import { AtomsTypeEnum } from '../../../store/types';
|
|
4
|
+
// import { FUNCTION_TEMPLATES } from '../function/utils';
|
|
3
5
|
/**
|
|
4
6
|
*
|
|
5
7
|
* @param type 当前选择的类型
|
|
@@ -7,7 +9,7 @@ import { AtomsTypeEnum } from '../../../store/types';
|
|
|
7
9
|
* @param index 需要讲模版插入的位置
|
|
8
10
|
* @returns
|
|
9
11
|
*/
|
|
10
|
-
export var
|
|
12
|
+
export var insertTemplateAt = function insertTemplateAt(oldType, type, list, index) {
|
|
11
13
|
var temList = [];
|
|
12
14
|
var needChange = ['RANK()', 'DENSE_RANK()', 'ROW_NUMBER()', 'when', 'case', 'then'].includes(oldType);
|
|
13
15
|
// 只改变类型不需要插入模版
|
|
@@ -116,4 +118,160 @@ export var getTemplate = function getTemplate(oldType, type, list, index) {
|
|
|
116
118
|
}
|
|
117
119
|
list.splice.apply(list, [index + 1, 0].concat(_toConsumableArray(temList)));
|
|
118
120
|
return list;
|
|
119
|
-
};
|
|
121
|
+
};
|
|
122
|
+
export var operatorList = ['and', 'or', '(', ')', ',', '+', '-', '*', '/', '!=', '<=', '>=', '<', '>', '=', 'case', 'when', 'then', 'else', 'end', 'DESC', 'ASC', 'OVER', 'PARTITION BY', 'ORDER BY', 'RANK()', 'DENSE_RANK()', 'ROW_NUMBER()'];
|
|
123
|
+
export var customTypes = [
|
|
124
|
+
// 字段
|
|
125
|
+
{
|
|
126
|
+
value: AtomsTypeEnum.FIELD,
|
|
127
|
+
label: __('customColumn.field')
|
|
128
|
+
},
|
|
129
|
+
// 表达式
|
|
130
|
+
{
|
|
131
|
+
value: AtomsTypeEnum.EXPRESSION,
|
|
132
|
+
label: __('customColumn.expression')
|
|
133
|
+
},
|
|
134
|
+
// 输入框
|
|
135
|
+
{
|
|
136
|
+
value: AtomsTypeEnum.INPUT_STRING,
|
|
137
|
+
label: __('customColumn.input')
|
|
138
|
+
},
|
|
139
|
+
// 数字输入框
|
|
140
|
+
{
|
|
141
|
+
value: AtomsTypeEnum.INPUT_NUMBER,
|
|
142
|
+
label: __('customColumn.numberInput')
|
|
143
|
+
},
|
|
144
|
+
// 数字输入框
|
|
145
|
+
{
|
|
146
|
+
value: AtomsTypeEnum.CONSTANT,
|
|
147
|
+
label: __('customColumn.constant')
|
|
148
|
+
},
|
|
149
|
+
// 连接符
|
|
150
|
+
{
|
|
151
|
+
value: AtomsTypeEnum.OPERATOR,
|
|
152
|
+
label: __('customColumn.operator'),
|
|
153
|
+
children: operatorList
|
|
154
|
+
},
|
|
155
|
+
// 函数
|
|
156
|
+
{
|
|
157
|
+
value: AtomsTypeEnum.FORMULA,
|
|
158
|
+
label: __('customColumn.formula'),
|
|
159
|
+
children: operatorList
|
|
160
|
+
}];
|
|
161
|
+
export var getTemplateItem = function getTemplateItem(type) {
|
|
162
|
+
var temItem;
|
|
163
|
+
// 字段
|
|
164
|
+
if (type === AtomsTypeEnum.FIELD) {
|
|
165
|
+
temItem = {
|
|
166
|
+
fieldName: '',
|
|
167
|
+
// 字段名
|
|
168
|
+
fieldNameZh: '',
|
|
169
|
+
// 字段中文名
|
|
170
|
+
fieldAlias: '',
|
|
171
|
+
// 别名
|
|
172
|
+
fieldUuid: '',
|
|
173
|
+
// uuid
|
|
174
|
+
fieldId: '',
|
|
175
|
+
// 字段id
|
|
176
|
+
// quotes?: string; // 字段展示的 不知道有没有用
|
|
177
|
+
tableName: '',
|
|
178
|
+
// 表名
|
|
179
|
+
tableNameZh: '',
|
|
180
|
+
tableId: '',
|
|
181
|
+
// 表名
|
|
182
|
+
tableAlias: '',
|
|
183
|
+
// 别名
|
|
184
|
+
tableUuid: '',
|
|
185
|
+
// 表唯一标识
|
|
186
|
+
datasourceName: '',
|
|
187
|
+
// 数据源名
|
|
188
|
+
datasourceId: '',
|
|
189
|
+
// 数据源id
|
|
190
|
+
type: AtomsTypeEnum.FIELD
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
// 表达式
|
|
194
|
+
else if (type === AtomsTypeEnum.EXPRESSION || type === AtomsTypeEnum.JOIN_DEFAULT) {
|
|
195
|
+
return {
|
|
196
|
+
lhs: [],
|
|
197
|
+
rhs: [],
|
|
198
|
+
condition: '',
|
|
199
|
+
quotes: '',
|
|
200
|
+
type: type
|
|
201
|
+
};
|
|
202
|
+
} else if (type === AtomsTypeEnum.EXISTS || type === AtomsTypeEnum.NOT_EXISTS) {
|
|
203
|
+
return {
|
|
204
|
+
quotes: '',
|
|
205
|
+
// 展示用户看的 组装的文字
|
|
206
|
+
notExists: [],
|
|
207
|
+
type: type
|
|
208
|
+
};
|
|
209
|
+
} else if (type === AtomsTypeEnum.UNKNOWN) {
|
|
210
|
+
return {
|
|
211
|
+
// quotes: '', // 展示用户看的 组装的文字
|
|
212
|
+
// notExists: [],
|
|
213
|
+
val: '',
|
|
214
|
+
type: type
|
|
215
|
+
};
|
|
216
|
+
} else if (type === AtomsTypeEnum.INPUT_NUMBER) {
|
|
217
|
+
return {
|
|
218
|
+
val: 0,
|
|
219
|
+
type: type
|
|
220
|
+
};
|
|
221
|
+
} else if (type === AtomsTypeEnum.INPUT_NUMBER_LIST || type === AtomsTypeEnum.INPUT_STRING_LIST) {
|
|
222
|
+
temItem = {
|
|
223
|
+
val: [],
|
|
224
|
+
type: type
|
|
225
|
+
};
|
|
226
|
+
} else if (type === AtomsTypeEnum.FORMULA) {
|
|
227
|
+
temItem = {
|
|
228
|
+
args: [],
|
|
229
|
+
// params: FUNCTION_TEMPLATES?.[type]?.params || [],
|
|
230
|
+
// arity: FUNCTION_TEMPLATES?.[type]?.arity || {},
|
|
231
|
+
name: '',
|
|
232
|
+
quotes: '',
|
|
233
|
+
type: type
|
|
234
|
+
};
|
|
235
|
+
} else if (type === AtomsTypeEnum.COLLECTION) {
|
|
236
|
+
return {
|
|
237
|
+
list: [],
|
|
238
|
+
quotes: '',
|
|
239
|
+
type: type
|
|
240
|
+
};
|
|
241
|
+
} else {
|
|
242
|
+
// 其他
|
|
243
|
+
temItem = {
|
|
244
|
+
val: '',
|
|
245
|
+
type: type
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
return temItem;
|
|
249
|
+
};
|
|
250
|
+
var _isOk = function isOk(rhsVal) {
|
|
251
|
+
return rhsVal.every(function (v) {
|
|
252
|
+
if (v.type === AtomsTypeEnum.UNKNOWN) {
|
|
253
|
+
return false;
|
|
254
|
+
} else if (v.type === AtomsTypeEnum.JOIN_DEFAULT) {
|
|
255
|
+
// 这个情况应该是不存在的
|
|
256
|
+
return true; // 或者根据业务逻辑决定是否算“有效”
|
|
257
|
+
} else if (v.type === AtomsTypeEnum.FIELD) {
|
|
258
|
+
return Boolean(v.fieldName); // 确保 fieldName 存在且非空
|
|
259
|
+
} else if (v.type === AtomsTypeEnum.EXPRESSION || v.type === AtomsTypeEnum.EXISTS || v.type === AtomsTypeEnum.NOT_EXISTS) {
|
|
260
|
+
return Boolean(v.quotes); // 确保 quotes 存在
|
|
261
|
+
} else if (v.type === AtomsTypeEnum.INPUT_STRING_LIST) {
|
|
262
|
+
return Array.isArray(v.val) && v.val.every(function (vv) {
|
|
263
|
+
return Boolean(vv);
|
|
264
|
+
});
|
|
265
|
+
} else if (v.type === AtomsTypeEnum.COLLECTION) {
|
|
266
|
+
return _isOk(v.list || []);
|
|
267
|
+
} else if (v.type === AtomsTypeEnum.FORMULA) {
|
|
268
|
+
if (!v.quotes) {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
return _isOk(v.args || []);
|
|
272
|
+
} else {
|
|
273
|
+
return Boolean(v.val); // 兜底,确保 val 存在
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
export { _isOk as isOk };
|
|
@@ -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
|
+
})[];
|
|
@@ -98,12 +98,12 @@ export var customTypes = [
|
|
|
98
98
|
// 输入框
|
|
99
99
|
{
|
|
100
100
|
value: AtomsTypeEnum.INPUT_STRING,
|
|
101
|
-
label: __('
|
|
101
|
+
label: __('customColumn.input')
|
|
102
102
|
},
|
|
103
103
|
// 数字输入框
|
|
104
104
|
{
|
|
105
105
|
value: AtomsTypeEnum.INPUT_NUMBER,
|
|
106
|
-
label: __('
|
|
106
|
+
label: __('customColumn.numberInput')
|
|
107
107
|
},
|
|
108
108
|
// 表达式
|
|
109
109
|
{
|
|
@@ -115,6 +115,12 @@ export var customTypes = [
|
|
|
115
115
|
value: AtomsTypeEnum.OPERATOR,
|
|
116
116
|
label: __('customColumn.operator')
|
|
117
117
|
},
|
|
118
|
+
// 函数
|
|
119
|
+
{
|
|
120
|
+
value: AtomsTypeEnum.FORMULA,
|
|
121
|
+
label: __('customColumn.formula'),
|
|
122
|
+
children: operatorList
|
|
123
|
+
},
|
|
118
124
|
// EXISTS
|
|
119
125
|
{
|
|
120
126
|
value: AtomsTypeEnum.NOT_EXISTS,
|
|
@@ -687,10 +687,10 @@ var JoinData = function JoinData(props) {
|
|
|
687
687
|
// value={(((newMeta[index] as MetaJoin).expressions[_ind] as AtomsExpression)[position])[`type`]}
|
|
688
688
|
list: [{
|
|
689
689
|
value: AtomsTypeEnum.INPUT_STRING,
|
|
690
|
-
label: __('
|
|
690
|
+
label: __('customColumn.input')
|
|
691
691
|
}, {
|
|
692
692
|
value: AtomsTypeEnum.INPUT_NUMBER,
|
|
693
|
-
label: __('
|
|
693
|
+
label: __('customColumn.numberInput')
|
|
694
694
|
}, {
|
|
695
695
|
value: AtomsTypeEnum.CONSTANT,
|
|
696
696
|
label: __('customColumn.constant')
|
|
@@ -1356,6 +1356,31 @@ var JoinData = function JoinData(props) {
|
|
|
1356
1356
|
})]
|
|
1357
1357
|
}, i);
|
|
1358
1358
|
}
|
|
1359
|
+
// if (v.type === AtomsTypeEnum.COLLECTION) {
|
|
1360
|
+
// return (
|
|
1361
|
+
// <FormulaList
|
|
1362
|
+
// // check={formulaList?.[fun.name]?.args?.[i]?.check || ''}
|
|
1363
|
+
// value={v.list}
|
|
1364
|
+
// data={data}
|
|
1365
|
+
// ref={ref}
|
|
1366
|
+
// onChange={(data, _quotes) => {
|
|
1367
|
+
// const _args = cloneDeep(fun.args);
|
|
1368
|
+
// (_args[i] as AtomsCollection).list = data;
|
|
1369
|
+
// (_args[i] as AtomsCollection).quotes = _quotes || '';
|
|
1370
|
+
// const quotes = (_args as AtomsCollection[])
|
|
1371
|
+
// .map((v) => {
|
|
1372
|
+
// return v.quotes;
|
|
1373
|
+
// })
|
|
1374
|
+
// .join(' , ');
|
|
1375
|
+
// setFun({
|
|
1376
|
+
// ...fun,
|
|
1377
|
+
// quotes: fun.name + ' ( ' + quotes + ' ) ',
|
|
1378
|
+
// args: _args,
|
|
1379
|
+
// });
|
|
1380
|
+
// }}
|
|
1381
|
+
// ></FormulaList>
|
|
1382
|
+
// );
|
|
1383
|
+
// }
|
|
1359
1384
|
})), ((_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 && _jsx(Tooltip, {
|
|
1360
1385
|
title: __('SqlQueryBuilder.add'),
|
|
1361
1386
|
children: _jsx(Dropdown, {
|