@gingkoo/pandora-metabase 1.0.14 → 1.0.15
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/common/SplitView/index.js +11 -12
- package/lib/cjs/components/dialog/custom-column/expression-editor.js +1 -2
- package/lib/cjs/components/dialog/custom-column/expressions/suggest.js +1 -1
- package/lib/cjs/components/dialog/custom-column/tokenizedI-input.js +1 -2
- package/lib/cjs/components/dialog/{select-filter → expression}/index.d.ts +4 -4
- package/lib/cjs/components/dialog/{select-filter → expression}/index.js +345 -206
- package/lib/cjs/components/dialog/formula-list/enum.d.ts +9 -13
- package/lib/cjs/components/dialog/formula-list/enum.js +83 -39
- package/lib/cjs/components/dialog/formula-list/index.d.ts +4 -1
- package/lib/cjs/components/dialog/formula-list/index.js +110 -126
- package/lib/cjs/components/dialog/formula-list/utils.js +77 -46
- package/lib/cjs/components/dialog/index.d.ts +2 -2
- package/lib/cjs/components/dialog/index.js +20 -20
- package/lib/cjs/components/dialog/select-column/index.js +43 -12
- package/lib/cjs/components/dialog/select-column-multiple/index.d.ts +54 -0
- package/lib/cjs/components/dialog/select-column-multiple/index.js +341 -0
- package/lib/cjs/components/dialog/select-column-multiple/index.less +246 -0
- package/lib/cjs/components/dialog/select-table/index.js +9 -7
- package/lib/cjs/components/icons.js +36 -36
- package/lib/cjs/components/metabase/index.js +6 -6
- package/lib/cjs/components/metabase/index.less +12 -1
- package/lib/cjs/components/modules/components/Wrapper.js +6 -6
- package/lib/cjs/components/modules/custom-column.js +12 -14
- package/lib/cjs/components/modules/enum/filter-enum.d.ts +34 -0
- package/lib/cjs/components/modules/enum/filter-enum.js +137 -0
- package/lib/cjs/components/modules/filter.js +43 -460
- package/lib/cjs/components/modules/join-data.js +892 -522
- package/lib/cjs/components/modules/permission-table.js +4 -0
- package/lib/cjs/components/modules/sort.js +102 -91
- package/lib/cjs/components/modules/summarize/group-by.js +47 -16
- package/lib/cjs/components/modules/summarize/select-index.js +48 -17
- package/lib/cjs/components/modules/table-data.js +13 -4
- package/lib/cjs/components/popup.js +1 -2
- package/lib/cjs/hooks/patch.d.ts +4 -0
- package/lib/cjs/hooks/patch.js +464 -0
- package/lib/cjs/hooks/use-state.js +73 -138
- package/lib/cjs/index.d.ts +0 -1
- package/lib/cjs/index.js +3 -21
- package/lib/cjs/locale/en.js +10 -3
- package/lib/cjs/locale/zh.js +12 -5
- package/lib/cjs/store/helper.d.ts +2 -3
- package/lib/cjs/store/helper.js +288 -233
- package/lib/cjs/store/types.d.ts +94 -71
- package/lib/cjs/store/types.js +17 -12
- package/lib/cjs/utils.d.ts +3 -3
- package/lib/cjs/utils.js +152 -187
- package/lib/es/common/SplitView/index.js +10 -10
- package/lib/es/components/dialog/custom-column/expressions/suggest.js +1 -1
- package/lib/es/components/dialog/{select-filter → expression}/index.d.ts +4 -4
- package/lib/es/components/dialog/{select-filter → expression}/index.js +343 -206
- package/lib/es/components/dialog/formula-list/enum.d.ts +9 -13
- package/lib/es/components/dialog/formula-list/enum.js +82 -38
- package/lib/es/components/dialog/formula-list/index.d.ts +4 -1
- package/lib/es/components/dialog/formula-list/index.js +115 -131
- package/lib/es/components/dialog/formula-list/utils.js +77 -46
- package/lib/es/components/dialog/index.d.ts +2 -2
- package/lib/es/components/dialog/index.js +3 -3
- package/lib/es/components/dialog/select-column/index.js +44 -13
- package/lib/es/components/dialog/select-column-multiple/index.d.ts +54 -0
- package/lib/es/components/dialog/select-column-multiple/index.js +335 -0
- package/lib/es/components/dialog/select-column-multiple/index.less +246 -0
- package/lib/es/components/dialog/select-table/index.js +9 -7
- package/lib/es/components/icons.js +36 -36
- package/lib/es/components/metabase/index.js +6 -6
- package/lib/es/components/metabase/index.less +12 -1
- package/lib/es/components/modules/components/Wrapper.js +6 -6
- package/lib/es/components/modules/custom-column.js +12 -14
- package/lib/es/components/modules/enum/filter-enum.d.ts +34 -0
- package/lib/es/components/modules/enum/filter-enum.js +131 -0
- package/lib/es/components/modules/filter.js +45 -463
- package/lib/es/components/modules/join-data.js +894 -524
- package/lib/es/components/modules/permission-table.js +4 -0
- package/lib/es/components/modules/sort.js +102 -91
- package/lib/es/components/modules/summarize/group-by.js +48 -17
- package/lib/es/components/modules/summarize/select-index.js +49 -18
- package/lib/es/components/modules/table-data.js +13 -4
- package/lib/es/hooks/patch.d.ts +4 -0
- package/lib/es/hooks/patch.js +457 -0
- package/lib/es/hooks/use-state.js +73 -138
- package/lib/es/index.d.ts +0 -1
- package/lib/es/index.js +1 -1
- package/lib/es/locale/en.js +10 -3
- package/lib/es/locale/zh.js +12 -5
- package/lib/es/store/helper.d.ts +2 -3
- package/lib/es/store/helper.js +288 -233
- package/lib/es/store/types.d.ts +94 -71
- package/lib/es/store/types.js +16 -11
- package/lib/es/utils.d.ts +3 -3
- package/lib/es/utils.js +154 -190
- package/package.json +1 -1
- package/lib/cjs/components/modules/filter copy.d.ts +0 -7
- package/lib/cjs/components/modules/filter copy.js +0 -178
- package/lib/es/components/modules/filter copy.d.ts +0 -7
- package/lib/es/components/modules/filter copy.js +0 -171
- /package/lib/cjs/components/dialog/{select-filter → expression}/index.less +0 -0
- /package/lib/es/components/dialog/{select-filter → expression}/index.less +0 -0
|
@@ -1,28 +1,16 @@
|
|
|
1
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
-
import
|
|
5
|
-
var _excluded = ["notExistsToolbar", "toolbar"];
|
|
6
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { useState } from 'react';
|
|
8
|
-
import cx from 'classnames';
|
|
9
|
-
import Metabase from '../../index';
|
|
10
|
-
import { Modal2 } from '@gingkoo/pandora';
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
4
|
import { __ } from '../../locale';
|
|
12
|
-
import isEqual from 'lodash/isEqual';
|
|
13
5
|
import cloneDeep from 'lodash/cloneDeep';
|
|
14
6
|
import { uuidv4 } from '../../utils/helper';
|
|
15
|
-
import { findIndex, getHelper
|
|
7
|
+
import { findIndex, getHelper } from '../../utils';
|
|
16
8
|
import { TypeEnum, SQL_COLUMN_TYPE } from '../../store/enum';
|
|
17
|
-
import
|
|
18
|
-
import { Filter_TypeEnum } from '../../store/types';
|
|
19
|
-
import { Select } from '@gingkoo/pandora';
|
|
9
|
+
import FormulaList from '../dialog/formula-list';
|
|
20
10
|
import Wrapper from './components/Wrapper';
|
|
21
|
-
import { AddIcon, CloseIcon } from '../icons';
|
|
22
11
|
import NextDom from './components/meta-icon';
|
|
23
12
|
import Header from './components/header';
|
|
24
|
-
import {
|
|
25
|
-
import arrow from './arrow.svg';
|
|
13
|
+
import { customTypes, operatorList } from './enum/filter-enum';
|
|
26
14
|
import { useStore } from '../../hooks/use-provider';
|
|
27
15
|
var Filter = function Filter(props) {
|
|
28
16
|
var meta = props.meta,
|
|
@@ -30,13 +18,10 @@ var Filter = function Filter(props) {
|
|
|
30
18
|
var store = useStore();
|
|
31
19
|
var filter = meta.filter;
|
|
32
20
|
var notExistsColumns = store.preProps.notExistsColumns;
|
|
33
|
-
|
|
21
|
+
// const filterCustomType = store.filterCustomType;
|
|
34
22
|
var index = findIndex(store.metaList[groupIndex].list, meta);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
38
|
-
ind = _useState2[0],
|
|
39
|
-
setInd = _useState2[1];
|
|
23
|
+
// let notSelected = !meta.filter.length;
|
|
24
|
+
// const [ind, setInd] = useState(-1);
|
|
40
25
|
function getColumns() {
|
|
41
26
|
var _getHelper = getHelper(store.metaList[groupIndex].list, meta),
|
|
42
27
|
ExistAboveGroupBy = _getHelper.ExistAboveGroupBy,
|
|
@@ -48,21 +33,23 @@ var Filter = function Filter(props) {
|
|
|
48
33
|
if (ExistAboveGroupBy) {
|
|
49
34
|
var _prevGroupBy$group, _prevGroupBy$by;
|
|
50
35
|
var _data = {
|
|
51
|
-
table: prevGroupBy.alias,
|
|
52
|
-
tableId: prevGroupBy.alias,
|
|
53
|
-
tableUuid: prevGroupBy.tableUuid,
|
|
54
36
|
alias: prevGroupBy.alias,
|
|
37
|
+
name: prevGroupBy.alias,
|
|
38
|
+
name_zh: prevGroupBy.alias,
|
|
39
|
+
// tableId: (prevGroupBy as MetaSummarize).alias,
|
|
40
|
+
id: prevGroupBy.alias,
|
|
41
|
+
tableUuid: prevGroupBy.tableUuid,
|
|
42
|
+
// alias: (prevGroupBy as MetaSummarize).alias,
|
|
55
43
|
datasourceId: mainTable.table.datasourceId,
|
|
56
44
|
datasourceName: mainTable.table.datasourceName,
|
|
57
45
|
columns: []
|
|
58
46
|
};
|
|
59
47
|
if (prevGroupBy !== null && prevGroupBy !== void 0 && (_prevGroupBy$group = prevGroupBy.group) !== null && _prevGroupBy$group !== void 0 && _prevGroupBy$group.length) {
|
|
60
48
|
_data.columns = _data.columns.concat(prevGroupBy.group.map(function (v) {
|
|
61
|
-
return _objectSpread(_objectSpread({
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
// name_zh: '',
|
|
49
|
+
return _objectSpread(_objectSpread({}, v), {}, {
|
|
50
|
+
name: v.name || v.quotes,
|
|
51
|
+
name_zh: v.name_zh || v.quotes,
|
|
52
|
+
id: v.id || v.fieldId,
|
|
66
53
|
database_type: (v === null || v === void 0 ? void 0 : v.database_type) || SQL_COLUMN_TYPE.FLOAT,
|
|
67
54
|
sql: v.sql,
|
|
68
55
|
special_type: '',
|
|
@@ -72,11 +59,10 @@ var Filter = function Filter(props) {
|
|
|
72
59
|
}
|
|
73
60
|
if (prevGroupBy !== null && prevGroupBy !== void 0 && (_prevGroupBy$by = prevGroupBy.by) !== null && _prevGroupBy$by !== void 0 && _prevGroupBy$by.length) {
|
|
74
61
|
_data.columns = _data.columns.concat(prevGroupBy.by.map(function (v) {
|
|
75
|
-
return _objectSpread(_objectSpread({
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
// name_zh: '',
|
|
62
|
+
return _objectSpread(_objectSpread({}, v), {}, {
|
|
63
|
+
name: v.name || v.quotes,
|
|
64
|
+
name_zh: v.name_zh || v.quotes,
|
|
65
|
+
id: v.id || v.fieldId,
|
|
80
66
|
database_type: (v === null || v === void 0 ? void 0 : v.database_type) || SQL_COLUMN_TYPE.FLOAT,
|
|
81
67
|
sql: v.sql,
|
|
82
68
|
special_type: '',
|
|
@@ -98,8 +84,9 @@ var Filter = function Filter(props) {
|
|
|
98
84
|
joinData.map(function (v) {
|
|
99
85
|
return {
|
|
100
86
|
alias: v.table2.alias,
|
|
101
|
-
|
|
102
|
-
|
|
87
|
+
name: v.table2.name,
|
|
88
|
+
name_zh: v.table2.name_zh,
|
|
89
|
+
id: v.table2.id,
|
|
103
90
|
tableUuid: v.table2.tableUuid || uuidv4('table'),
|
|
104
91
|
columns: v.columns,
|
|
105
92
|
datasourceId: mainTable.table.datasourceId,
|
|
@@ -113,8 +100,11 @@ var Filter = function Filter(props) {
|
|
|
113
100
|
if (v.type === TypeEnum.data) {
|
|
114
101
|
return {
|
|
115
102
|
alias: v.table.alias,
|
|
116
|
-
table: v.table.name,
|
|
117
|
-
|
|
103
|
+
// table: v.table.name,
|
|
104
|
+
name: v.table.name,
|
|
105
|
+
name_zh: v.table.name_zh,
|
|
106
|
+
// tableId: v.table.id,
|
|
107
|
+
id: v.table.id,
|
|
118
108
|
tableUuid: v.table.tableUuid || uuidv4('table'),
|
|
119
109
|
columns: v.columns,
|
|
120
110
|
datasourceId: mainTable.table.datasourceId,
|
|
@@ -123,8 +113,9 @@ var Filter = function Filter(props) {
|
|
|
123
113
|
} else if (v.type === TypeEnum.joinData) {
|
|
124
114
|
return {
|
|
125
115
|
alias: v.table2.alias,
|
|
126
|
-
|
|
127
|
-
|
|
116
|
+
name: v.table2.name,
|
|
117
|
+
name_zh: v.table2.name_zh,
|
|
118
|
+
id: v.table2.id,
|
|
128
119
|
tableUuid: v.table2.tableUuid || uuidv4('table'),
|
|
129
120
|
columns: v.columns,
|
|
130
121
|
datasourceId: mainTable.table.datasourceId,
|
|
@@ -136,331 +127,21 @@ var Filter = function Filter(props) {
|
|
|
136
127
|
};
|
|
137
128
|
}
|
|
138
129
|
}).filter(function (v) {
|
|
139
|
-
return v.
|
|
130
|
+
return v.name;
|
|
140
131
|
});
|
|
141
132
|
}
|
|
142
133
|
return data;
|
|
143
134
|
}
|
|
144
|
-
function handleUpdate(e, i) {
|
|
145
|
-
var newMeta = store.metaList[groupIndex].list.slice();
|
|
146
|
-
var val = filter[i];
|
|
147
|
-
if (val.type === Filter_TypeEnum.NOT_EXISTS || val.type === Filter_TypeEnum.EXISTS) {
|
|
148
|
-
showNotExists(i, '', val.type);
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
var data = [].concat(_toConsumableArray(getColumns()), _toConsumableArray(cloneDeep(notExistsColumns || [])));
|
|
152
|
-
store.setPopup({
|
|
153
|
-
visible: true,
|
|
154
|
-
node: e.currentTarget,
|
|
155
|
-
content: _jsx(SelectFilter, {
|
|
156
|
-
filterCustomType: filterCustomType,
|
|
157
|
-
data: data,
|
|
158
|
-
value: filter[i],
|
|
159
|
-
onChange: function onChange(data) {
|
|
160
|
-
newMeta[index].filter.splice(i, 1, data);
|
|
161
|
-
store.setMeta(newMeta, groupIndex);
|
|
162
|
-
closePopup();
|
|
163
|
-
}
|
|
164
|
-
})
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
function handleAdd(e) {
|
|
168
|
-
var node = e.currentTarget;
|
|
169
|
-
var newMeta = store.metaList[groupIndex].list.slice();
|
|
170
|
-
var data = [].concat(_toConsumableArray(getColumns()), _toConsumableArray(cloneDeep(notExistsColumns || [])));
|
|
171
|
-
var _index = Number(node.getAttribute('v-index'));
|
|
172
|
-
var _type = node.getAttribute('v-type');
|
|
173
|
-
var value = {
|
|
174
|
-
table: '',
|
|
175
|
-
// 表名
|
|
176
|
-
tableId: '',
|
|
177
|
-
// 表名
|
|
178
|
-
fieldUuid: '',
|
|
179
|
-
// 字段唯一id
|
|
180
|
-
fieldAlias: '',
|
|
181
|
-
//字段别名
|
|
182
|
-
tableUuid: '',
|
|
183
|
-
alias: '',
|
|
184
|
-
// 表的别名
|
|
185
|
-
name: '',
|
|
186
|
-
// 字段名
|
|
187
|
-
id: '',
|
|
188
|
-
// 字段名
|
|
189
|
-
database_type: '',
|
|
190
|
-
// 字段类型
|
|
191
|
-
condition: '',
|
|
192
|
-
// 选择条件
|
|
193
|
-
val: [],
|
|
194
|
-
// 选择结果 如果有两个 长度就为2
|
|
195
|
-
quotes: '',
|
|
196
|
-
// 前端显示用户看的文字
|
|
197
|
-
datasourceId: '',
|
|
198
|
-
datasourceName: '',
|
|
199
|
-
type: Filter_TypeEnum.EXPRESSION // 过滤类型
|
|
200
|
-
};
|
|
201
|
-
store.setPopup({
|
|
202
|
-
visible: true,
|
|
203
|
-
node: e.currentTarget,
|
|
204
|
-
content: _jsx(SelectFilter, {
|
|
205
|
-
filterCustomType: filterCustomType,
|
|
206
|
-
data: data,
|
|
207
|
-
value: value,
|
|
208
|
-
onChange: function onChange(val) {
|
|
209
|
-
if (_type) {
|
|
210
|
-
if (_type === 'before') {
|
|
211
|
-
newMeta[index].filter.splice(_index, 0, val);
|
|
212
|
-
} else {
|
|
213
|
-
console.log('🚀 ~ ', newMeta[index].filter);
|
|
214
|
-
newMeta[index].filter.splice(_index + 1, 0, val);
|
|
215
|
-
}
|
|
216
|
-
} else {
|
|
217
|
-
newMeta[index].filter.push(val);
|
|
218
|
-
}
|
|
219
|
-
store.setMeta(newMeta, groupIndex);
|
|
220
|
-
closePopup();
|
|
221
|
-
}
|
|
222
|
-
})
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
function handleDel(e, itemId) {
|
|
226
|
-
e.stopPropagation();
|
|
227
|
-
closePopup();
|
|
228
|
-
var newMeta = store.metaList[groupIndex].list.slice();
|
|
229
|
-
// @ts-ignore
|
|
230
|
-
newMeta[index].filter = filter.filter(function (_, i) {
|
|
231
|
-
return i !== itemId;
|
|
232
|
-
});
|
|
233
|
-
store.setMeta(newMeta, groupIndex);
|
|
234
|
-
}
|
|
235
135
|
function closePopup() {
|
|
236
136
|
store.setPopup({
|
|
237
137
|
visible: false
|
|
238
138
|
});
|
|
239
139
|
}
|
|
240
|
-
var
|
|
241
|
-
var addOperator = function addOperator(val, i, type) {
|
|
140
|
+
var selectFilter = function selectFilter(val) {
|
|
242
141
|
var newMeta = store.metaList[groupIndex].list.slice();
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
_filter.splice(i, 0, val);
|
|
246
|
-
} else {
|
|
247
|
-
_filter.splice(i + 1, 0, val);
|
|
248
|
-
}
|
|
249
|
-
newMeta[index].filter = _toConsumableArray(_filter);
|
|
250
|
-
setInd(-1);
|
|
251
|
-
};
|
|
252
|
-
// NotExists 窗口
|
|
253
|
-
var showNotExists = function showNotExists(i, position, type) {
|
|
254
|
-
var _newMeta$index$filter, _newMeta$index$filter2;
|
|
255
|
-
var _store$preProps = store.preProps,
|
|
256
|
-
notExistsToolbar = _store$preProps.notExistsToolbar,
|
|
257
|
-
toolbar = _store$preProps.toolbar,
|
|
258
|
-
other = _objectWithoutProperties(_store$preProps, _excluded);
|
|
259
|
-
var newMeta = store.metaList[groupIndex].list.slice();
|
|
260
|
-
var index = findIndex(store.metaList[groupIndex].list, meta);
|
|
261
|
-
var _value = position ? [] : ((_newMeta$index$filter = newMeta[index].filter[i]) === null || _newMeta$index$filter === void 0 ? void 0 : _newMeta$index$filter.notExists) || [];
|
|
262
|
-
var oldList = position ? [] : cloneDeep(((_newMeta$index$filter2 = newMeta[index].filter[i]) === null || _newMeta$index$filter2 === void 0 ? void 0 : _newMeta$index$filter2.notExists) || []);
|
|
263
|
-
var _toolbar = notExistsToolbar || toolbar;
|
|
264
|
-
_toolbar = _toolbar.filter(function (v) {
|
|
265
|
-
return v !== 'group';
|
|
266
|
-
}); // 子查询不需要分组
|
|
267
|
-
var notExistsColumns = getColumns();
|
|
268
|
-
var o = Modal2.openModal({
|
|
269
|
-
title: type === Filter_TypeEnum.EXISTS ? 'EXISTS' : 'NOT EXISTS',
|
|
270
|
-
transparentMask: true,
|
|
271
|
-
content: _jsx(_Fragment, {
|
|
272
|
-
children: _jsx(Metabase, _objectSpread(_objectSpread({}, other), {}, {
|
|
273
|
-
notExistsColumns: notExistsColumns,
|
|
274
|
-
showFields: false,
|
|
275
|
-
showSubquery: false,
|
|
276
|
-
toolbar: _toolbar,
|
|
277
|
-
btnText: __('SqlQueryBuilder.confirm'),
|
|
278
|
-
value: _value,
|
|
279
|
-
onOk: function onOk(newList) {
|
|
280
|
-
try {
|
|
281
|
-
// 子查询未改变不做操作
|
|
282
|
-
if (isEqual(newList, oldList)) {
|
|
283
|
-
o.close();
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
var _tem = {
|
|
287
|
-
notExists: newList,
|
|
288
|
-
quotes: buildSqlQuery(newList, type),
|
|
289
|
-
condition: '',
|
|
290
|
-
table: '',
|
|
291
|
-
tableId: '',
|
|
292
|
-
fieldUuid: uuidv4('field'),
|
|
293
|
-
// 字段唯一id
|
|
294
|
-
fieldAlias: '',
|
|
295
|
-
//字段别名
|
|
296
|
-
tableUuid: uuidv4('table'),
|
|
297
|
-
alias: '',
|
|
298
|
-
name: '',
|
|
299
|
-
id: '',
|
|
300
|
-
database_type: '',
|
|
301
|
-
val: [],
|
|
302
|
-
datasourceId: '',
|
|
303
|
-
datasourceName: '',
|
|
304
|
-
type: type
|
|
305
|
-
};
|
|
306
|
-
// 新增
|
|
307
|
-
if (i === -1) {
|
|
308
|
-
// 如果是新增子查询
|
|
309
|
-
newMeta[index].filter.push(_tem);
|
|
310
|
-
o.close();
|
|
311
|
-
} else if (position) {
|
|
312
|
-
//新增
|
|
313
|
-
if (position === 'before') {
|
|
314
|
-
newMeta[index].filter.splice(i, 0, _tem);
|
|
315
|
-
} else {
|
|
316
|
-
newMeta[index].filter.splice(i + 1, 0, _tem);
|
|
317
|
-
}
|
|
318
|
-
} else {
|
|
319
|
-
// 编辑
|
|
320
|
-
newMeta[index].filter[i] = _tem;
|
|
321
|
-
}
|
|
322
|
-
store.setMeta(newMeta, groupIndex);
|
|
323
|
-
o.close();
|
|
324
|
-
} catch (e) {
|
|
325
|
-
console.warn(e);
|
|
326
|
-
} finally {
|
|
327
|
-
o.close();
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}))
|
|
331
|
-
}),
|
|
332
|
-
onClose: function onClose() {}
|
|
333
|
-
});
|
|
142
|
+
newMeta[index].filter = val;
|
|
143
|
+
store.setMeta(newMeta, groupIndex);
|
|
334
144
|
};
|
|
335
|
-
// 过滤类型,子查询为完整的查询语句,表达式为单个字段
|
|
336
|
-
// 目前只支持表达式和子查询两种类型
|
|
337
|
-
var filterType = [
|
|
338
|
-
// {
|
|
339
|
-
// value: Filter_TypeEnum.FIELD,
|
|
340
|
-
// label: __('customColumn.field'),
|
|
341
|
-
// },
|
|
342
|
-
// {
|
|
343
|
-
// value: Filter_TypeEnum.INPUT,
|
|
344
|
-
// label: __('SqlQueryBuilder.input'),
|
|
345
|
-
// },
|
|
346
|
-
{
|
|
347
|
-
value: Filter_TypeEnum.EXPRESSION,
|
|
348
|
-
label: __('customColumn.expression') //表达式
|
|
349
|
-
}, {
|
|
350
|
-
value: Filter_TypeEnum.EXISTS,
|
|
351
|
-
label: 'EXISTS'
|
|
352
|
-
}, {
|
|
353
|
-
value: Filter_TypeEnum.NOT_EXISTS,
|
|
354
|
-
label: 'NOT EXISTS'
|
|
355
|
-
}];
|
|
356
|
-
// 选择过滤类型
|
|
357
|
-
function addSelectType(e) {
|
|
358
|
-
var _e = cloneDeep(e);
|
|
359
|
-
var node = _e.currentTarget;
|
|
360
|
-
var _index = node.getAttribute('v-index') || -1;
|
|
361
|
-
var _type = node.getAttribute('v-type');
|
|
362
|
-
store.setPopup({
|
|
363
|
-
visible: true,
|
|
364
|
-
node: e.currentTarget,
|
|
365
|
-
content: _jsx(SelectList, {
|
|
366
|
-
className: 'purple',
|
|
367
|
-
list: filterType,
|
|
368
|
-
onChange: function onChange(type) {
|
|
369
|
-
closePopup();
|
|
370
|
-
// 如果是新增子查询
|
|
371
|
-
if (type === Filter_TypeEnum.EXPRESSION) {
|
|
372
|
-
handleAdd(_e);
|
|
373
|
-
} else if (type === Filter_TypeEnum.NOT_EXISTS || type === Filter_TypeEnum.EXISTS) {
|
|
374
|
-
showNotExists(_index, _type, type);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
})
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
// const itemDom = (v: MetaFilter_Item, i: number) => {
|
|
381
|
-
// if (typeof v === 'string') {
|
|
382
|
-
// return (
|
|
383
|
-
// <div className={`Sqb-TableName purple-name`} key={i}>
|
|
384
|
-
// {v}
|
|
385
|
-
// <span style={{ fontSize: 0 }} onClick={(e) => handleDel(e, i)}>
|
|
386
|
-
// <CloseIcon />
|
|
387
|
-
// </span>
|
|
388
|
-
// </div>
|
|
389
|
-
// );
|
|
390
|
-
// }
|
|
391
|
-
// if (v.type === Filter_TypeEnum.NOT_EXISTS) {
|
|
392
|
-
// return (
|
|
393
|
-
// <div className={`Sqb-TableName purple-name`} key={i} onClick={(e) => handleUpdate(e, i)}>
|
|
394
|
-
// not exitis ( * )
|
|
395
|
-
// <span style={{ fontSize: 0 }} onClick={(e) => handleDel(e, i)}>
|
|
396
|
-
// <CloseIcon />
|
|
397
|
-
// </span>
|
|
398
|
-
// </div>
|
|
399
|
-
// );
|
|
400
|
-
// } else if (v.type === Filter_TypeEnum.EXPRESSION) {
|
|
401
|
-
// return (
|
|
402
|
-
// <div className={`Sqb-TableName purple-name`} key={i} onClick={(e) => handleUpdate(e, i)}>
|
|
403
|
-
// {v.quotes}
|
|
404
|
-
// <span style={{ fontSize: 0 }} onClick={(e) => handleDel(e, i)}>
|
|
405
|
-
// <CloseIcon />
|
|
406
|
-
// </span>
|
|
407
|
-
// </div>
|
|
408
|
-
// );
|
|
409
|
-
// }
|
|
410
|
-
// else if (v.type === Filter_TypeEnum.INPUT) {
|
|
411
|
-
// // 输入框
|
|
412
|
-
// return (
|
|
413
|
-
// <div className={cx(`Sqb-TableName notSelected `)}>
|
|
414
|
-
// <Input
|
|
415
|
-
// className={':Sqb-Custom-input'}
|
|
416
|
-
// value={v.operator}
|
|
417
|
-
// placeholder={__('SqlQueryBuilder.pleaseEnter')}
|
|
418
|
-
// size='large'
|
|
419
|
-
// onChange={(val) => {
|
|
420
|
-
// handleConstant(val, index);
|
|
421
|
-
// }}
|
|
422
|
-
// />
|
|
423
|
-
// <span style={{ fontSize: 0 }} onClick={(e) => handleDel(e, index)}>
|
|
424
|
-
// <CloseIcon />
|
|
425
|
-
// </span>
|
|
426
|
-
// </div>
|
|
427
|
-
// );
|
|
428
|
-
// } else if (v.type === Filter_TypeEnum.OPERATOR) {
|
|
429
|
-
// //连接符
|
|
430
|
-
// return (
|
|
431
|
-
// <Select
|
|
432
|
-
// triggerProps={{
|
|
433
|
-
// clickToClose: true,
|
|
434
|
-
// }}
|
|
435
|
-
// value={v.operator}
|
|
436
|
-
// triggerElement={(value) => {
|
|
437
|
-
// return (
|
|
438
|
-
// <div
|
|
439
|
-
// className={cx(`Sqb-TableName `, {
|
|
440
|
-
// notSelected: !v.operator,
|
|
441
|
-
// })}
|
|
442
|
-
// >
|
|
443
|
-
// {!v.operator && __('customColumn.selectOperator')}
|
|
444
|
-
// {v.operator}
|
|
445
|
-
// <span style={{ fontSize: 0 }} onClick={(e) => handleDel(e, index)}>
|
|
446
|
-
// <CloseIcon />
|
|
447
|
-
// </span>
|
|
448
|
-
// </div>
|
|
449
|
-
// );
|
|
450
|
-
// }}
|
|
451
|
-
// onChange={(val) => {
|
|
452
|
-
// handleConstant(val, index);
|
|
453
|
-
// }}
|
|
454
|
-
// >
|
|
455
|
-
// {operatorList.map((option, index) => (
|
|
456
|
-
// <Select.Option key={index + '' + ind} value={option}>
|
|
457
|
-
// {option}
|
|
458
|
-
// </Select.Option>
|
|
459
|
-
// ))}
|
|
460
|
-
// </Select>
|
|
461
|
-
// );
|
|
462
|
-
// }
|
|
463
|
-
// };
|
|
464
145
|
return _jsx(Wrapper, {
|
|
465
146
|
className: "Sqb-item",
|
|
466
147
|
children: _jsxs("div", {
|
|
@@ -474,114 +155,15 @@ var Filter = function Filter(props) {
|
|
|
474
155
|
}
|
|
475
156
|
}) : null, _jsx("div", {
|
|
476
157
|
className: "Sqb-item--content",
|
|
477
|
-
children:
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
},
|
|
487
|
-
onMouseLeave: function onMouseLeave() {
|
|
488
|
-
setInd(-1);
|
|
489
|
-
},
|
|
490
|
-
children: [_jsx(Select, {
|
|
491
|
-
trigger: 'hover',
|
|
492
|
-
triggerProps: {
|
|
493
|
-
clickToClose: true
|
|
494
|
-
},
|
|
495
|
-
triggerElement: function triggerElement() {
|
|
496
|
-
return _jsx("div", {
|
|
497
|
-
className: 'left-arrow',
|
|
498
|
-
onClick: addSelectType,
|
|
499
|
-
"v-index": i,
|
|
500
|
-
"v-type": 'before',
|
|
501
|
-
children: _jsx("img", {
|
|
502
|
-
src: arrow
|
|
503
|
-
})
|
|
504
|
-
});
|
|
505
|
-
},
|
|
506
|
-
onChange: function onChange(val) {
|
|
507
|
-
addOperator(val, i, 'before');
|
|
508
|
-
},
|
|
509
|
-
children: options.map(function (option) {
|
|
510
|
-
return _jsx(Select.Option, {
|
|
511
|
-
value: option,
|
|
512
|
-
children: option
|
|
513
|
-
}, option);
|
|
514
|
-
})
|
|
515
|
-
}), typeof v === 'string' ? _jsxs("div", {
|
|
516
|
-
className: "Sqb-TableName purple-name",
|
|
517
|
-
children: [v, _jsx("span", {
|
|
518
|
-
style: {
|
|
519
|
-
fontSize: 0
|
|
520
|
-
},
|
|
521
|
-
onClick: function onClick(e) {
|
|
522
|
-
return handleDel(e, i);
|
|
523
|
-
},
|
|
524
|
-
children: _jsx(CloseIcon, {})
|
|
525
|
-
})]
|
|
526
|
-
}, i) : _jsxs("div", {
|
|
527
|
-
className: "Sqb-TableName purple-name",
|
|
528
|
-
onClick: function onClick(e) {
|
|
529
|
-
return handleUpdate(e, i);
|
|
530
|
-
},
|
|
531
|
-
children: [v.type === Filter_TypeEnum.NOT_EXISTS ? 'not exitis ( * )' : v.type === Filter_TypeEnum.EXISTS ? 'exitis ( * )' : v.quotes, _jsx("span", {
|
|
532
|
-
style: {
|
|
533
|
-
fontSize: 0
|
|
534
|
-
},
|
|
535
|
-
onClick: function onClick(e) {
|
|
536
|
-
return handleDel(e, i);
|
|
537
|
-
},
|
|
538
|
-
children: _jsx(CloseIcon, {})
|
|
539
|
-
})]
|
|
540
|
-
}, i), _jsx(Select, {
|
|
541
|
-
trigger: 'hover',
|
|
542
|
-
triggerProps: {
|
|
543
|
-
clickToClose: true
|
|
544
|
-
},
|
|
545
|
-
triggerElement: function triggerElement(value) {
|
|
546
|
-
return _jsx("div", {
|
|
547
|
-
className: 'right-arrow',
|
|
548
|
-
onClick: addSelectType,
|
|
549
|
-
"v-index": i,
|
|
550
|
-
"v-type": 'after',
|
|
551
|
-
children: _jsx("img", {
|
|
552
|
-
src: arrow
|
|
553
|
-
})
|
|
554
|
-
});
|
|
555
|
-
},
|
|
556
|
-
onChange: function onChange(val) {
|
|
557
|
-
addOperator(val, i, 'after');
|
|
558
|
-
},
|
|
559
|
-
children: options.map(function (option) {
|
|
560
|
-
return _jsx(Select.Option, {
|
|
561
|
-
value: option,
|
|
562
|
-
children: option
|
|
563
|
-
}, option);
|
|
564
|
-
})
|
|
565
|
-
})]
|
|
566
|
-
}, i);
|
|
567
|
-
}), _jsx("div", {
|
|
568
|
-
className: cx("Sqb-TableName purple-name", {
|
|
569
|
-
notSelected: notSelected
|
|
570
|
-
}),
|
|
571
|
-
onClick: addSelectType,
|
|
572
|
-
children: notSelected ? __('filter.addFiltersToNarrowDownYourAnswers') : _jsx(AddIcon, {})
|
|
573
|
-
}), Array.from(filter).length > 0 && _jsxs("p", {
|
|
574
|
-
className: 'Sqb-NotebookCell-preview',
|
|
575
|
-
children: ["\u9884\u89C8\uFF1A", filter.map(function (v, i) {
|
|
576
|
-
if (typeof v === 'string') {
|
|
577
|
-
return v;
|
|
578
|
-
} else if (v.type === Filter_TypeEnum.NOT_EXISTS || v.type === Filter_TypeEnum.EXISTS) {
|
|
579
|
-
return "".concat(buildSqlQuery(v.notExists, v.type));
|
|
580
|
-
} else {
|
|
581
|
-
return v.quotes;
|
|
582
|
-
}
|
|
583
|
-
}).join(' ')]
|
|
584
|
-
})]
|
|
158
|
+
children: _jsx(FormulaList, {
|
|
159
|
+
customTypes: customTypes,
|
|
160
|
+
operatorList: operatorList,
|
|
161
|
+
value: filter,
|
|
162
|
+
data: [].concat(_toConsumableArray(getColumns()), _toConsumableArray(cloneDeep(notExistsColumns || []))),
|
|
163
|
+
exitData: getColumns(),
|
|
164
|
+
onChange: function onChange(val) {
|
|
165
|
+
selectFilter(val);
|
|
166
|
+
}
|
|
585
167
|
})
|
|
586
168
|
}), _jsx(NextDom, {
|
|
587
169
|
meta: meta,
|