@gingkoo/pandora-metabase 1.0.157-alpha.8 → 1.0.157
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/expression/index.js +46 -29
- package/lib/cjs/components/dialog/formula-list/index.js +1 -1
- package/lib/cjs/components/dialog/formula-list/utils.d.ts +1 -0
- package/lib/cjs/components/dialog/formula-list/utils.js +2 -2
- package/lib/cjs/utils/transformSql.js +22 -0
- package/lib/cjs/utils.js +2 -2
- package/lib/es/components/dialog/expression/index.js +47 -30
- package/lib/es/components/dialog/formula-list/index.js +1 -1
- package/lib/es/components/dialog/formula-list/utils.d.ts +1 -0
- package/lib/es/components/dialog/formula-list/utils.js +1 -1
- package/lib/es/utils/transformSql.js +22 -0
- package/lib/es/utils.js +2 -2
- package/package.json +1 -1
|
@@ -31,8 +31,14 @@ var _itemName = _interopRequireDefault(require("../../modules/components/item-na
|
|
|
31
31
|
var _dateFormatPicker = require("./date-format-picker");
|
|
32
32
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
33
33
|
var NUMBER_LIST = ['等于', '不等于', '大于', '小于', '介于之间', '大于或等于', '小于或等于', '为空', '不为空', '以...开始', '以...结束', '不以...开始', '不以...结束', 'In', 'Not In', '正则匹配'];
|
|
34
|
-
var STRING_LIST = ['等于', '不等于', '包含', '不包含', '为空', '不为空', '以...开始', '以...结束', '不以...开始', '不以...结束', 'In', 'Not In', '正则匹配'];
|
|
35
|
-
var DATE_LIST = ['等于', '
|
|
34
|
+
var STRING_LIST = ['等于', '不等于', '大于', '小于', '大于或等于', '小于或等于', '包含', '不包含', '为空', '不为空', '以...开始', '以...结束', '不以...开始', '不以...结束', 'In', 'Not In', '正则匹配'];
|
|
35
|
+
var DATE_LIST = ['等于', '大于', '小于', '大于或等于', '小于或等于', '介于之间', '是空的', '不为空'];
|
|
36
|
+
var DATE_VALUE_CONDITIONS = ['等于', '大于', '小于', '大于或等于', '小于或等于', '早于', '晚于', '在'];
|
|
37
|
+
var SWITCH_VALUE_TYPE_CONDITIONS = ['等于', '不等于', '大于', '小于', '大于或等于', '小于或等于'];
|
|
38
|
+
var LEGACY_DATE_CONDITION_MAP = {
|
|
39
|
+
早于: '小于',
|
|
40
|
+
晚于: '大于或等于'
|
|
41
|
+
};
|
|
36
42
|
var typeList = [{
|
|
37
43
|
key: _enum.SQL_COLUMN_TYPE.STRING,
|
|
38
44
|
label: _enum.SQL_COLUMN_TYPE.STRING
|
|
@@ -144,9 +150,10 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
144
150
|
if (~['无需结果'].indexOf(condition)) {
|
|
145
151
|
return false;
|
|
146
152
|
}
|
|
147
|
-
if (
|
|
153
|
+
if (_utils.EMPTY_RHS_CONDITIONS.has(condition)) {
|
|
148
154
|
return false;
|
|
149
155
|
}
|
|
156
|
+
if (!rhsVal.length) return true;
|
|
150
157
|
var isOk = rhsVal.every(function (v) {
|
|
151
158
|
if (v.type === _types.AtomsTypeEnum.INPUT_STRING || v.type === _types.AtomsTypeEnum.INPUT_NUMBER || v.type === _types.AtomsTypeEnum.CONSTANT) {
|
|
152
159
|
return v.val || v.val === 0;
|
|
@@ -206,6 +213,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
206
213
|
早于: 'filter.earlierThan',
|
|
207
214
|
晚于: 'filter.laterThan',
|
|
208
215
|
是空的: 'filter.isEmpty',
|
|
216
|
+
不是空的: 'filter.notEmpty',
|
|
209
217
|
In: 'filter.within',
|
|
210
218
|
'Not In': 'filter.withnotin',
|
|
211
219
|
无需结果: 'filter.notresults',
|
|
@@ -213,7 +221,18 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
213
221
|
}[v];
|
|
214
222
|
};
|
|
215
223
|
function generateQuotes(val, curColumn) {
|
|
216
|
-
|
|
224
|
+
if (_utils.EMPTY_RHS_CONDITIONS.has(condition)) {
|
|
225
|
+
var lhsName = getQuotesName(curColumn.lhs);
|
|
226
|
+
var isEmptyCondition = condition === '为空' || condition === '是空的';
|
|
227
|
+
if (_locale.isEn) {
|
|
228
|
+
return "".concat(lhsName, " ").concat(isEmptyCondition ? 'is empty' : 'not empty');
|
|
229
|
+
}
|
|
230
|
+
return "".concat(lhsName, " ").concat(isEmptyCondition ? '为空' : '不为空');
|
|
231
|
+
}
|
|
232
|
+
var _val = val[0] || {
|
|
233
|
+
val: '',
|
|
234
|
+
type: _types.AtomsTypeEnum.INPUT_STRING
|
|
235
|
+
};
|
|
217
236
|
var firstVal = '',
|
|
218
237
|
secondVal = '';
|
|
219
238
|
if (_val.type === _types.AtomsTypeEnum.INPUT_STRING) {
|
|
@@ -275,18 +294,6 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
275
294
|
} else {
|
|
276
295
|
quotes = getQuotesName(curColumn.lhs) + ' 是 ' + firstVal;
|
|
277
296
|
}
|
|
278
|
-
} else if (condition === '是空的') {
|
|
279
|
-
if (_locale.isEn) {
|
|
280
|
-
quotes = getQuotesName(curColumn.lhs) + ' is empty';
|
|
281
|
-
} else {
|
|
282
|
-
quotes = getQuotesName(curColumn.lhs) + ' 为空';
|
|
283
|
-
}
|
|
284
|
-
} else if (condition === '不是空的') {
|
|
285
|
-
if (_locale.isEn) {
|
|
286
|
-
quotes = getQuotesName(curColumn.lhs) + ' not empty';
|
|
287
|
-
} else {
|
|
288
|
-
quotes = getQuotesName(curColumn.lhs) + ' 不为空';
|
|
289
|
-
}
|
|
290
297
|
} else if (condition === '当前') {
|
|
291
298
|
if (firstVal === '天') {
|
|
292
299
|
if (_locale.isEn) {
|
|
@@ -347,11 +354,16 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
347
354
|
conditions = DATE_LIST;
|
|
348
355
|
type = _enum.SQL_GROUP_TYPE.DATE;
|
|
349
356
|
}
|
|
357
|
+
var nextCondition = LEGACY_DATE_CONDITION_MAP[condition];
|
|
358
|
+
if (type === _enum.SQL_GROUP_TYPE.DATE && nextCondition) {
|
|
359
|
+
setCondition(nextCondition);
|
|
360
|
+
}
|
|
350
361
|
if (isCustom) {
|
|
351
362
|
conditions = ['无需结果'].concat((0, _toConsumableArray2["default"])(conditions));
|
|
352
363
|
}
|
|
353
|
-
|
|
354
|
-
|
|
364
|
+
var isCompatibleDateEmptyCondition = type === _enum.SQL_GROUP_TYPE.DATE && (condition === '为空' || condition === '不是空的');
|
|
365
|
+
if (!conditions.includes(condition) && !nextCondition && !isCompatibleDateEmptyCondition) {
|
|
366
|
+
setDefaultVal(conditions[0], type);
|
|
355
367
|
}
|
|
356
368
|
return {
|
|
357
369
|
columnType: columnType,
|
|
@@ -360,6 +372,9 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
360
372
|
};
|
|
361
373
|
}
|
|
362
374
|
function renderFilter(type, conditionText) {
|
|
375
|
+
if (_utils.EMPTY_RHS_CONDITIONS.has(conditionText)) {
|
|
376
|
+
return null;
|
|
377
|
+
}
|
|
363
378
|
var _val = rhsVal[0];
|
|
364
379
|
var firstVal = '',
|
|
365
380
|
secondVal = '';
|
|
@@ -373,9 +388,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
373
388
|
firstVal = _val.val[0] || '';
|
|
374
389
|
secondVal = _val.val[1] || '';
|
|
375
390
|
}
|
|
376
|
-
if (
|
|
377
|
-
return null;
|
|
378
|
-
} else if (conditionText === '介于之间') {
|
|
391
|
+
if (conditionText === '介于之间') {
|
|
379
392
|
if (type === _enum.SQL_GROUP_TYPE.NUMBER) {
|
|
380
393
|
return (0, _jsxRuntime.jsxs)("div", {
|
|
381
394
|
style: {
|
|
@@ -504,7 +517,9 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
504
517
|
})
|
|
505
518
|
})]
|
|
506
519
|
});
|
|
507
|
-
} else if (
|
|
520
|
+
} else if (type === _enum.SQL_GROUP_TYPE.DATE && ~DATE_VALUE_CONDITIONS.filter(function (v) {
|
|
521
|
+
return v !== '等于';
|
|
522
|
+
}).indexOf(conditionText)) {
|
|
508
523
|
var _rhsVal$3, _rhsVal$4;
|
|
509
524
|
var _dateVal = ((_rhsVal$3 = rhsVal[0]) === null || _rhsVal$3 === void 0 ? void 0 : _rhsVal$3.type) === _types.AtomsTypeEnum.INPUT_STRING ? rhsVal[0].val : undefined;
|
|
510
525
|
var _dateFormat = ((_rhsVal$4 = rhsVal[0]) === null || _rhsVal$4 === void 0 ? void 0 : _rhsVal$4.type) === _types.AtomsTypeEnum.INPUT_STRING ? rhsVal[0].format : undefined;
|
|
@@ -649,10 +664,10 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
649
664
|
})
|
|
650
665
|
});
|
|
651
666
|
};
|
|
652
|
-
var onRepeat = function onRepeat(e) {
|
|
667
|
+
var onRepeat = function onRepeat(e, fieldType) {
|
|
653
668
|
var _rhsVal$7;
|
|
654
669
|
setParentClosable(false);
|
|
655
|
-
var inputAtomType = ((_rhsVal$7 = rhsVal[0]) === null || _rhsVal$7 === void 0 ? void 0 : _rhsVal$7.type) === _types.AtomsTypeEnum.INPUT_NUMBER ? _types.AtomsTypeEnum.INPUT_NUMBER : _types.AtomsTypeEnum.INPUT_STRING;
|
|
670
|
+
var inputAtomType = fieldType === _enum.SQL_GROUP_TYPE.NUMBER || ((_rhsVal$7 = rhsVal[0]) === null || _rhsVal$7 === void 0 ? void 0 : _rhsVal$7.type) === _types.AtomsTypeEnum.INPUT_NUMBER ? _types.AtomsTypeEnum.INPUT_NUMBER : _types.AtomsTypeEnum.INPUT_STRING;
|
|
656
671
|
store.setPopup2({
|
|
657
672
|
visible: true,
|
|
658
673
|
node: e.currentTarget,
|
|
@@ -883,7 +898,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
883
898
|
getPopupContainer: getCurrentPopupContainer,
|
|
884
899
|
onChange: function onChange(key) {
|
|
885
900
|
setCurColumn((0, _objectSpread2["default"])({}, curColumn));
|
|
886
|
-
setDefaultVal(key);
|
|
901
|
+
setDefaultVal(key, fieldType);
|
|
887
902
|
},
|
|
888
903
|
droplist: menu,
|
|
889
904
|
children: (0, _jsxRuntime.jsxs)(_pandora.Button, {
|
|
@@ -928,14 +943,16 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
928
943
|
children: renderFilter(fieldType, condition)
|
|
929
944
|
}, i);
|
|
930
945
|
}
|
|
931
|
-
}), ~
|
|
946
|
+
}), ~SWITCH_VALUE_TYPE_CONDITIONS.indexOf(condition) || fieldType === _enum.SQL_GROUP_TYPE.DATE && ~DATE_VALUE_CONDITIONS.indexOf(condition) ? (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
|
|
932
947
|
title: (0, _locale.__)('SqlQueryBuilder.switch'),
|
|
933
948
|
children: (0, _jsxRuntime.jsx)(_pandora.Button, {
|
|
934
949
|
primary: true,
|
|
935
950
|
ghost: true,
|
|
936
951
|
className: 'ml-2 operator-icon',
|
|
937
952
|
icon: (0, _jsxRuntime.jsx)(_pandoraIcons.Repeat, {}),
|
|
938
|
-
onClick:
|
|
953
|
+
onClick: function onClick(e) {
|
|
954
|
+
return onRepeat(e, fieldType);
|
|
955
|
+
}
|
|
939
956
|
})
|
|
940
957
|
}) : '']
|
|
941
958
|
}), (0, _jsxRuntime.jsx)("div", {
|
|
@@ -952,7 +969,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
952
969
|
})]
|
|
953
970
|
});
|
|
954
971
|
}
|
|
955
|
-
function setDefaultVal(_condition) {
|
|
972
|
+
function setDefaultVal(_condition, fieldType) {
|
|
956
973
|
var _rhsVal$0;
|
|
957
974
|
setCondition(_condition);
|
|
958
975
|
var inputAtomType = ((_rhsVal$0 = rhsVal[0]) === null || _rhsVal$0 === void 0 ? void 0 : _rhsVal$0.type) === _types.AtomsTypeEnum.INPUT_NUMBER ? _types.AtomsTypeEnum.INPUT_NUMBER : _types.AtomsTypeEnum.INPUT_STRING;
|
|
@@ -972,7 +989,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
972
989
|
val: '天',
|
|
973
990
|
type: _types.AtomsTypeEnum.INPUT_STRING
|
|
974
991
|
}]);
|
|
975
|
-
} else if (
|
|
992
|
+
} else if (fieldType === _enum.SQL_GROUP_TYPE.DATE && ~DATE_VALUE_CONDITIONS.indexOf(_condition)) {
|
|
976
993
|
setRhsVal([{
|
|
977
994
|
val: (0, _dayjs["default"])().format('YYYY-MM-DD HH:mm'),
|
|
978
995
|
type: _types.AtomsTypeEnum.INPUT_STRING,
|
|
@@ -2952,7 +2952,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
2952
2952
|
}
|
|
2953
2953
|
if (type === _types.AtomsTypeEnum.EXPRESSION) {
|
|
2954
2954
|
var quotes = (0, _utils2.getAtomDisplayText)(v);
|
|
2955
|
-
if (~['早于', '晚于', '在'].indexOf(v.condition) && v.rhs.length > 1) {
|
|
2955
|
+
if (~['大于', '小于', '大于或等于', '小于或等于', '早于', '晚于', '在'].indexOf(v.condition) && v.rhs.length > 1) {
|
|
2956
2956
|
var _getAtomDisplayText$s;
|
|
2957
2957
|
var nextList = caseList.slice();
|
|
2958
2958
|
nextList[index].rhs = [nextList[index].rhs[0]];
|
|
@@ -6,6 +6,7 @@ type ExpressionTable = {
|
|
|
6
6
|
tableUuid?: string;
|
|
7
7
|
columns?: any[];
|
|
8
8
|
};
|
|
9
|
+
export declare const EMPTY_RHS_CONDITIONS: Set<string>;
|
|
9
10
|
export declare const getExpressionDatabaseType: (expression: AtomsExpression, tables?: ExpressionTable[]) => string;
|
|
10
11
|
export declare const normalizeExpressionAtom: (expression: AtomsExpression, tables?: ExpressionTable[]) => AtomsExpression;
|
|
11
12
|
export declare const normalizeExpressionAtoms: (atoms?: AtomsItem[], tables?: ExpressionTable[]) => AtomsItem[];
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.operatorList = exports.normalizeExpressionAtoms = exports.normalizeExpressionAtom = exports.isOk = exports.insertTemplateAt = exports.getTemplateItem = exports.getExpressionDatabaseType = exports.getConstantLabel = exports.customTypes = void 0;
|
|
7
|
+
exports.operatorList = exports.normalizeExpressionAtoms = exports.normalizeExpressionAtom = exports.isOk = exports.insertTemplateAt = exports.getTemplateItem = exports.getExpressionDatabaseType = exports.getConstantLabel = exports.customTypes = exports.EMPTY_RHS_CONDITIONS = void 0;
|
|
8
8
|
exports.validateExpressionIntegrity = validateExpressionIntegrity;
|
|
9
9
|
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/createForOfIteratorHelper"));
|
|
10
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
|
|
@@ -12,7 +12,7 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/typeof
|
|
|
12
12
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
13
13
|
var _locale = require("../../../locale");
|
|
14
14
|
var _types = require("../../../store/types");
|
|
15
|
-
var EMPTY_RHS_CONDITIONS = new Set(['为空', '不为空', '是空的', '不是空的']);
|
|
15
|
+
var EMPTY_RHS_CONDITIONS = exports.EMPTY_RHS_CONDITIONS = new Set(['为空', '不为空', '是空的', '不是空的']);
|
|
16
16
|
var isSameValue = function isSameValue(left, right) {
|
|
17
17
|
return left !== undefined && left !== null && left !== '' && right !== undefined && right !== null && right !== '' && String(left) === String(right);
|
|
18
18
|
};
|
|
@@ -258,6 +258,18 @@ var _handleBaseType2Sql9 = exports.handleBaseType2Sql = function handleBaseType2
|
|
|
258
258
|
case '不等于':
|
|
259
259
|
_right_condition = "!= ".concat(_rightSql);
|
|
260
260
|
break;
|
|
261
|
+
case '大于':
|
|
262
|
+
_right_condition = "> ".concat(_rightSql);
|
|
263
|
+
break;
|
|
264
|
+
case '小于':
|
|
265
|
+
_right_condition = "< ".concat(_rightSql);
|
|
266
|
+
break;
|
|
267
|
+
case '大于或等于':
|
|
268
|
+
_right_condition = ">= ".concat(_rightSql);
|
|
269
|
+
break;
|
|
270
|
+
case '小于或等于':
|
|
271
|
+
_right_condition = "<= ".concat(_rightSql);
|
|
272
|
+
break;
|
|
261
273
|
case '包含':
|
|
262
274
|
_right_condition = "LIKE '%".concat(condition_1, "%'");
|
|
263
275
|
break;
|
|
@@ -444,19 +456,29 @@ var _handleBaseType2Sql9 = exports.handleBaseType2Sql = function handleBaseType2
|
|
|
444
456
|
case '等于':
|
|
445
457
|
_right_condition = "= ".concat(_condition_4);
|
|
446
458
|
break;
|
|
459
|
+
case '大于':
|
|
460
|
+
_right_condition = "> ".concat(_condition_4);
|
|
461
|
+
break;
|
|
462
|
+
case '小于':
|
|
447
463
|
case '早于':
|
|
448
464
|
_right_condition = "< ".concat(_condition_4);
|
|
449
465
|
break;
|
|
466
|
+
case '大于或等于':
|
|
450
467
|
case '晚于':
|
|
451
468
|
_right_condition = ">= ".concat(_condition_4);
|
|
452
469
|
break;
|
|
470
|
+
case '小于或等于':
|
|
471
|
+
_right_condition = "<= ".concat(_condition_4);
|
|
472
|
+
break;
|
|
453
473
|
case '介于之间':
|
|
454
474
|
_right_condition = "(".concat(_left_condition, " >= ").concat(_condition_4, " AND ").concat(_left_condition, " < ").concat(_condition_5, ")");
|
|
455
475
|
_left_condition = '';
|
|
456
476
|
break;
|
|
477
|
+
case '为空':
|
|
457
478
|
case '是空的':
|
|
458
479
|
_right_condition = "IS NULL";
|
|
459
480
|
break;
|
|
481
|
+
case '不为空':
|
|
460
482
|
case '不是空的':
|
|
461
483
|
_right_condition = "IS NOT NULL";
|
|
462
484
|
break;
|
package/lib/cjs/utils.js
CHANGED
|
@@ -951,10 +951,10 @@ var buildExpressionQuotes = function buildExpressionQuotes(item) {
|
|
|
951
951
|
if (condition === '在') {
|
|
952
952
|
return normalizeAtomQuotes("".concat(lhsText, " ").concat(_locale.isEn ? 'is' : '是', " ").concat(firstVal));
|
|
953
953
|
}
|
|
954
|
-
if (condition === '是空的') {
|
|
954
|
+
if (condition === '为空' || condition === '是空的') {
|
|
955
955
|
return normalizeAtomQuotes("".concat(lhsText, " ").concat(_locale.isEn ? 'is empty' : '为空'));
|
|
956
956
|
}
|
|
957
|
-
if (condition === '不是空的') {
|
|
957
|
+
if (condition === '不为空' || condition === '不是空的') {
|
|
958
958
|
return normalizeAtomQuotes("".concat(lhsText, " ").concat(_locale.isEn ? 'not empty' : '不为空'));
|
|
959
959
|
}
|
|
960
960
|
if (condition === '当前') {
|
|
@@ -19,12 +19,18 @@ import SelectColumnMultiple from '../select-column-multiple';
|
|
|
19
19
|
import { LeftArrowIcon } from '../../icons';
|
|
20
20
|
import { useStore } from '../../../hooks/use-provider';
|
|
21
21
|
import cloneDeep from 'lodash/cloneDeep';
|
|
22
|
-
import { getConstantLabel, normalizeExpressionAtom } from '../formula-list/utils';
|
|
22
|
+
import { EMPTY_RHS_CONDITIONS, getConstantLabel, normalizeExpressionAtom } from '../formula-list/utils';
|
|
23
23
|
import ItemName from '../../modules/components/item-name';
|
|
24
24
|
import { DateFormatPicker, DateRangeFormatPicker } from './date-format-picker';
|
|
25
25
|
var NUMBER_LIST = ['等于', '不等于', '大于', '小于', '介于之间', '大于或等于', '小于或等于', '为空', '不为空', '以...开始', '以...结束', '不以...开始', '不以...结束', 'In', 'Not In', '正则匹配'];
|
|
26
|
-
var STRING_LIST = ['等于', '不等于', '包含', '不包含', '为空', '不为空', '以...开始', '以...结束', '不以...开始', '不以...结束', 'In', 'Not In', '正则匹配'];
|
|
27
|
-
var DATE_LIST = ['等于', '
|
|
26
|
+
var STRING_LIST = ['等于', '不等于', '大于', '小于', '大于或等于', '小于或等于', '包含', '不包含', '为空', '不为空', '以...开始', '以...结束', '不以...开始', '不以...结束', 'In', 'Not In', '正则匹配'];
|
|
27
|
+
var DATE_LIST = ['等于', '大于', '小于', '大于或等于', '小于或等于', '介于之间', '是空的', '不为空'];
|
|
28
|
+
var DATE_VALUE_CONDITIONS = ['等于', '大于', '小于', '大于或等于', '小于或等于', '早于', '晚于', '在'];
|
|
29
|
+
var SWITCH_VALUE_TYPE_CONDITIONS = ['等于', '不等于', '大于', '小于', '大于或等于', '小于或等于'];
|
|
30
|
+
var LEGACY_DATE_CONDITION_MAP = {
|
|
31
|
+
早于: '小于',
|
|
32
|
+
晚于: '大于或等于'
|
|
33
|
+
};
|
|
28
34
|
var typeList = [{
|
|
29
35
|
key: SQL_COLUMN_TYPE.STRING,
|
|
30
36
|
label: SQL_COLUMN_TYPE.STRING
|
|
@@ -136,9 +142,10 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
136
142
|
if (~['无需结果'].indexOf(condition)) {
|
|
137
143
|
return false;
|
|
138
144
|
}
|
|
139
|
-
if (
|
|
145
|
+
if (EMPTY_RHS_CONDITIONS.has(condition)) {
|
|
140
146
|
return false;
|
|
141
147
|
}
|
|
148
|
+
if (!rhsVal.length) return true;
|
|
142
149
|
var isOk = rhsVal.every(function (v) {
|
|
143
150
|
if (v.type === AtomsTypeEnum.INPUT_STRING || v.type === AtomsTypeEnum.INPUT_NUMBER || v.type === AtomsTypeEnum.CONSTANT) {
|
|
144
151
|
return v.val || v.val === 0;
|
|
@@ -198,6 +205,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
198
205
|
早于: 'filter.earlierThan',
|
|
199
206
|
晚于: 'filter.laterThan',
|
|
200
207
|
是空的: 'filter.isEmpty',
|
|
208
|
+
不是空的: 'filter.notEmpty',
|
|
201
209
|
In: 'filter.within',
|
|
202
210
|
'Not In': 'filter.withnotin',
|
|
203
211
|
无需结果: 'filter.notresults',
|
|
@@ -205,7 +213,18 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
205
213
|
}[v];
|
|
206
214
|
};
|
|
207
215
|
function generateQuotes(val, curColumn) {
|
|
208
|
-
|
|
216
|
+
if (EMPTY_RHS_CONDITIONS.has(condition)) {
|
|
217
|
+
var lhsName = getQuotesName(curColumn.lhs);
|
|
218
|
+
var isEmptyCondition = condition === '为空' || condition === '是空的';
|
|
219
|
+
if (isEn) {
|
|
220
|
+
return "".concat(lhsName, " ").concat(isEmptyCondition ? 'is empty' : 'not empty');
|
|
221
|
+
}
|
|
222
|
+
return "".concat(lhsName, " ").concat(isEmptyCondition ? '为空' : '不为空');
|
|
223
|
+
}
|
|
224
|
+
var _val = val[0] || {
|
|
225
|
+
val: '',
|
|
226
|
+
type: AtomsTypeEnum.INPUT_STRING
|
|
227
|
+
};
|
|
209
228
|
var firstVal = '',
|
|
210
229
|
secondVal = '';
|
|
211
230
|
if (_val.type === AtomsTypeEnum.INPUT_STRING) {
|
|
@@ -267,18 +286,6 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
267
286
|
} else {
|
|
268
287
|
quotes = getQuotesName(curColumn.lhs) + ' 是 ' + firstVal;
|
|
269
288
|
}
|
|
270
|
-
} else if (condition === '是空的') {
|
|
271
|
-
if (isEn) {
|
|
272
|
-
quotes = getQuotesName(curColumn.lhs) + ' is empty';
|
|
273
|
-
} else {
|
|
274
|
-
quotes = getQuotesName(curColumn.lhs) + ' 为空';
|
|
275
|
-
}
|
|
276
|
-
} else if (condition === '不是空的') {
|
|
277
|
-
if (isEn) {
|
|
278
|
-
quotes = getQuotesName(curColumn.lhs) + ' not empty';
|
|
279
|
-
} else {
|
|
280
|
-
quotes = getQuotesName(curColumn.lhs) + ' 不为空';
|
|
281
|
-
}
|
|
282
289
|
} else if (condition === '当前') {
|
|
283
290
|
if (firstVal === '天') {
|
|
284
291
|
if (isEn) {
|
|
@@ -339,11 +346,16 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
339
346
|
conditions = DATE_LIST;
|
|
340
347
|
type = SQL_GROUP_TYPE.DATE;
|
|
341
348
|
}
|
|
349
|
+
var nextCondition = LEGACY_DATE_CONDITION_MAP[condition];
|
|
350
|
+
if (type === SQL_GROUP_TYPE.DATE && nextCondition) {
|
|
351
|
+
setCondition(nextCondition);
|
|
352
|
+
}
|
|
342
353
|
if (isCustom) {
|
|
343
354
|
conditions = ['无需结果'].concat(_toConsumableArray(conditions));
|
|
344
355
|
}
|
|
345
|
-
|
|
346
|
-
|
|
356
|
+
var isCompatibleDateEmptyCondition = type === SQL_GROUP_TYPE.DATE && (condition === '为空' || condition === '不是空的');
|
|
357
|
+
if (!conditions.includes(condition) && !nextCondition && !isCompatibleDateEmptyCondition) {
|
|
358
|
+
setDefaultVal(conditions[0], type);
|
|
347
359
|
}
|
|
348
360
|
return {
|
|
349
361
|
columnType: columnType,
|
|
@@ -352,6 +364,9 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
352
364
|
};
|
|
353
365
|
}
|
|
354
366
|
function renderFilter(type, conditionText) {
|
|
367
|
+
if (EMPTY_RHS_CONDITIONS.has(conditionText)) {
|
|
368
|
+
return null;
|
|
369
|
+
}
|
|
355
370
|
var _val = rhsVal[0];
|
|
356
371
|
var firstVal = '',
|
|
357
372
|
secondVal = '';
|
|
@@ -365,9 +380,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
365
380
|
firstVal = _val.val[0] || '';
|
|
366
381
|
secondVal = _val.val[1] || '';
|
|
367
382
|
}
|
|
368
|
-
if (
|
|
369
|
-
return null;
|
|
370
|
-
} else if (conditionText === '介于之间') {
|
|
383
|
+
if (conditionText === '介于之间') {
|
|
371
384
|
if (type === SQL_GROUP_TYPE.NUMBER) {
|
|
372
385
|
return _jsxs("div", {
|
|
373
386
|
style: {
|
|
@@ -496,7 +509,9 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
496
509
|
})
|
|
497
510
|
})]
|
|
498
511
|
});
|
|
499
|
-
} else if (
|
|
512
|
+
} else if (type === SQL_GROUP_TYPE.DATE && ~DATE_VALUE_CONDITIONS.filter(function (v) {
|
|
513
|
+
return v !== '等于';
|
|
514
|
+
}).indexOf(conditionText)) {
|
|
500
515
|
var _rhsVal$3, _rhsVal$4;
|
|
501
516
|
var _dateVal = ((_rhsVal$3 = rhsVal[0]) === null || _rhsVal$3 === void 0 ? void 0 : _rhsVal$3.type) === AtomsTypeEnum.INPUT_STRING ? rhsVal[0].val : undefined;
|
|
502
517
|
var _dateFormat = ((_rhsVal$4 = rhsVal[0]) === null || _rhsVal$4 === void 0 ? void 0 : _rhsVal$4.type) === AtomsTypeEnum.INPUT_STRING ? rhsVal[0].format : undefined;
|
|
@@ -641,10 +656,10 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
641
656
|
})
|
|
642
657
|
});
|
|
643
658
|
};
|
|
644
|
-
var onRepeat = function onRepeat(e) {
|
|
659
|
+
var onRepeat = function onRepeat(e, fieldType) {
|
|
645
660
|
var _rhsVal$7;
|
|
646
661
|
setParentClosable(false);
|
|
647
|
-
var inputAtomType = ((_rhsVal$7 = rhsVal[0]) === null || _rhsVal$7 === void 0 ? void 0 : _rhsVal$7.type) === AtomsTypeEnum.INPUT_NUMBER ? AtomsTypeEnum.INPUT_NUMBER : AtomsTypeEnum.INPUT_STRING;
|
|
662
|
+
var inputAtomType = fieldType === SQL_GROUP_TYPE.NUMBER || ((_rhsVal$7 = rhsVal[0]) === null || _rhsVal$7 === void 0 ? void 0 : _rhsVal$7.type) === AtomsTypeEnum.INPUT_NUMBER ? AtomsTypeEnum.INPUT_NUMBER : AtomsTypeEnum.INPUT_STRING;
|
|
648
663
|
store.setPopup2({
|
|
649
664
|
visible: true,
|
|
650
665
|
node: e.currentTarget,
|
|
@@ -875,7 +890,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
875
890
|
getPopupContainer: getCurrentPopupContainer,
|
|
876
891
|
onChange: function onChange(key) {
|
|
877
892
|
setCurColumn(_objectSpread({}, curColumn));
|
|
878
|
-
setDefaultVal(key);
|
|
893
|
+
setDefaultVal(key, fieldType);
|
|
879
894
|
},
|
|
880
895
|
droplist: menu,
|
|
881
896
|
children: _jsxs(Button, {
|
|
@@ -920,14 +935,16 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
920
935
|
children: renderFilter(fieldType, condition)
|
|
921
936
|
}, i);
|
|
922
937
|
}
|
|
923
|
-
}), ~
|
|
938
|
+
}), ~SWITCH_VALUE_TYPE_CONDITIONS.indexOf(condition) || fieldType === SQL_GROUP_TYPE.DATE && ~DATE_VALUE_CONDITIONS.indexOf(condition) ? _jsx(Tooltip, {
|
|
924
939
|
title: __('SqlQueryBuilder.switch'),
|
|
925
940
|
children: _jsx(Button, {
|
|
926
941
|
primary: true,
|
|
927
942
|
ghost: true,
|
|
928
943
|
className: 'ml-2 operator-icon',
|
|
929
944
|
icon: _jsx(Repeat, {}),
|
|
930
|
-
onClick:
|
|
945
|
+
onClick: function onClick(e) {
|
|
946
|
+
return onRepeat(e, fieldType);
|
|
947
|
+
}
|
|
931
948
|
})
|
|
932
949
|
}) : '']
|
|
933
950
|
}), _jsx("div", {
|
|
@@ -944,7 +961,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
944
961
|
})]
|
|
945
962
|
});
|
|
946
963
|
}
|
|
947
|
-
function setDefaultVal(_condition) {
|
|
964
|
+
function setDefaultVal(_condition, fieldType) {
|
|
948
965
|
var _rhsVal$0;
|
|
949
966
|
setCondition(_condition);
|
|
950
967
|
var inputAtomType = ((_rhsVal$0 = rhsVal[0]) === null || _rhsVal$0 === void 0 ? void 0 : _rhsVal$0.type) === AtomsTypeEnum.INPUT_NUMBER ? AtomsTypeEnum.INPUT_NUMBER : AtomsTypeEnum.INPUT_STRING;
|
|
@@ -964,7 +981,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
964
981
|
val: '天',
|
|
965
982
|
type: AtomsTypeEnum.INPUT_STRING
|
|
966
983
|
}]);
|
|
967
|
-
} else if (
|
|
984
|
+
} else if (fieldType === SQL_GROUP_TYPE.DATE && ~DATE_VALUE_CONDITIONS.indexOf(_condition)) {
|
|
968
985
|
setRhsVal([{
|
|
969
986
|
val: moment().format('YYYY-MM-DD HH:mm'),
|
|
970
987
|
type: AtomsTypeEnum.INPUT_STRING,
|
|
@@ -2943,7 +2943,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2943
2943
|
}
|
|
2944
2944
|
if (type === AtomsTypeEnum.EXPRESSION) {
|
|
2945
2945
|
var quotes = getAtomDisplayText(v);
|
|
2946
|
-
if (~['早于', '晚于', '在'].indexOf(v.condition) && v.rhs.length > 1) {
|
|
2946
|
+
if (~['大于', '小于', '大于或等于', '小于或等于', '早于', '晚于', '在'].indexOf(v.condition) && v.rhs.length > 1) {
|
|
2947
2947
|
var _getAtomDisplayText$s;
|
|
2948
2948
|
var nextList = caseList.slice();
|
|
2949
2949
|
nextList[index].rhs = [nextList[index].rhs[0]];
|
|
@@ -6,6 +6,7 @@ type ExpressionTable = {
|
|
|
6
6
|
tableUuid?: string;
|
|
7
7
|
columns?: any[];
|
|
8
8
|
};
|
|
9
|
+
export declare const EMPTY_RHS_CONDITIONS: Set<string>;
|
|
9
10
|
export declare const getExpressionDatabaseType: (expression: AtomsExpression, tables?: ExpressionTable[]) => string;
|
|
10
11
|
export declare const normalizeExpressionAtom: (expression: AtomsExpression, tables?: ExpressionTable[]) => AtomsExpression;
|
|
11
12
|
export declare const normalizeExpressionAtoms: (atoms?: AtomsItem[], tables?: ExpressionTable[]) => AtomsItem[];
|
|
@@ -4,7 +4,7 @@ import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
|
4
4
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
5
5
|
import { __ } from '../../../locale';
|
|
6
6
|
import { AtomsTypeEnum } from '../../../store/types';
|
|
7
|
-
var EMPTY_RHS_CONDITIONS = new Set(['为空', '不为空', '是空的', '不是空的']);
|
|
7
|
+
export var EMPTY_RHS_CONDITIONS = new Set(['为空', '不为空', '是空的', '不是空的']);
|
|
8
8
|
var isSameValue = function isSameValue(left, right) {
|
|
9
9
|
return left !== undefined && left !== null && left !== '' && right !== undefined && right !== null && right !== '' && String(left) === String(right);
|
|
10
10
|
};
|
|
@@ -251,6 +251,18 @@ var _handleBaseType2Sql9 = function handleBaseType2Sql(list) {
|
|
|
251
251
|
case '不等于':
|
|
252
252
|
_right_condition = "!= ".concat(_rightSql);
|
|
253
253
|
break;
|
|
254
|
+
case '大于':
|
|
255
|
+
_right_condition = "> ".concat(_rightSql);
|
|
256
|
+
break;
|
|
257
|
+
case '小于':
|
|
258
|
+
_right_condition = "< ".concat(_rightSql);
|
|
259
|
+
break;
|
|
260
|
+
case '大于或等于':
|
|
261
|
+
_right_condition = ">= ".concat(_rightSql);
|
|
262
|
+
break;
|
|
263
|
+
case '小于或等于':
|
|
264
|
+
_right_condition = "<= ".concat(_rightSql);
|
|
265
|
+
break;
|
|
254
266
|
case '包含':
|
|
255
267
|
_right_condition = "LIKE '%".concat(condition_1, "%'");
|
|
256
268
|
break;
|
|
@@ -437,19 +449,29 @@ var _handleBaseType2Sql9 = function handleBaseType2Sql(list) {
|
|
|
437
449
|
case '等于':
|
|
438
450
|
_right_condition = "= ".concat(_condition_4);
|
|
439
451
|
break;
|
|
452
|
+
case '大于':
|
|
453
|
+
_right_condition = "> ".concat(_condition_4);
|
|
454
|
+
break;
|
|
455
|
+
case '小于':
|
|
440
456
|
case '早于':
|
|
441
457
|
_right_condition = "< ".concat(_condition_4);
|
|
442
458
|
break;
|
|
459
|
+
case '大于或等于':
|
|
443
460
|
case '晚于':
|
|
444
461
|
_right_condition = ">= ".concat(_condition_4);
|
|
445
462
|
break;
|
|
463
|
+
case '小于或等于':
|
|
464
|
+
_right_condition = "<= ".concat(_condition_4);
|
|
465
|
+
break;
|
|
446
466
|
case '介于之间':
|
|
447
467
|
_right_condition = "(".concat(_left_condition, " >= ").concat(_condition_4, " AND ").concat(_left_condition, " < ").concat(_condition_5, ")");
|
|
448
468
|
_left_condition = '';
|
|
449
469
|
break;
|
|
470
|
+
case '为空':
|
|
450
471
|
case '是空的':
|
|
451
472
|
_right_condition = "IS NULL";
|
|
452
473
|
break;
|
|
474
|
+
case '不为空':
|
|
453
475
|
case '不是空的':
|
|
454
476
|
_right_condition = "IS NOT NULL";
|
|
455
477
|
break;
|
package/lib/es/utils.js
CHANGED
|
@@ -938,10 +938,10 @@ var buildExpressionQuotes = function buildExpressionQuotes(item) {
|
|
|
938
938
|
if (condition === '在') {
|
|
939
939
|
return normalizeAtomQuotes("".concat(lhsText, " ").concat(isEn ? 'is' : '是', " ").concat(firstVal));
|
|
940
940
|
}
|
|
941
|
-
if (condition === '是空的') {
|
|
941
|
+
if (condition === '为空' || condition === '是空的') {
|
|
942
942
|
return normalizeAtomQuotes("".concat(lhsText, " ").concat(isEn ? 'is empty' : '为空'));
|
|
943
943
|
}
|
|
944
|
-
if (condition === '不是空的') {
|
|
944
|
+
if (condition === '不为空' || condition === '不是空的') {
|
|
945
945
|
return normalizeAtomQuotes("".concat(lhsText, " ").concat(isEn ? 'not empty' : '不为空'));
|
|
946
946
|
}
|
|
947
947
|
if (condition === '当前') {
|