@gingkoo/pandora-metabase 1.0.14 → 1.0.16

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.
Files changed (96) hide show
  1. package/lib/cjs/common/SplitView/index.js +11 -12
  2. package/lib/cjs/components/dialog/custom-column/expression-editor.js +1 -2
  3. package/lib/cjs/components/dialog/custom-column/expressions/suggest.js +1 -1
  4. package/lib/cjs/components/dialog/custom-column/tokenizedI-input.js +1 -2
  5. package/lib/cjs/components/dialog/{select-filter → expression}/index.d.ts +4 -4
  6. package/lib/cjs/components/dialog/{select-filter → expression}/index.js +345 -206
  7. package/lib/cjs/components/dialog/formula-list/enum.d.ts +9 -13
  8. package/lib/cjs/components/dialog/formula-list/enum.js +83 -39
  9. package/lib/cjs/components/dialog/formula-list/index.d.ts +4 -1
  10. package/lib/cjs/components/dialog/formula-list/index.js +110 -126
  11. package/lib/cjs/components/dialog/formula-list/utils.js +77 -46
  12. package/lib/cjs/components/dialog/index.d.ts +2 -2
  13. package/lib/cjs/components/dialog/index.js +20 -20
  14. package/lib/cjs/components/dialog/select-column/index.js +43 -12
  15. package/lib/cjs/components/dialog/select-column-multiple/index.d.ts +54 -0
  16. package/lib/cjs/components/dialog/select-column-multiple/index.js +341 -0
  17. package/lib/cjs/components/dialog/select-column-multiple/index.less +246 -0
  18. package/lib/cjs/components/dialog/select-table/index.js +9 -7
  19. package/lib/cjs/components/icons.js +36 -36
  20. package/lib/cjs/components/metabase/index.js +6 -6
  21. package/lib/cjs/components/metabase/index.less +12 -1
  22. package/lib/cjs/components/modules/components/Wrapper.js +6 -6
  23. package/lib/cjs/components/modules/custom-column.js +12 -14
  24. package/lib/cjs/components/modules/enum/filter-enum.d.ts +34 -0
  25. package/lib/cjs/components/modules/enum/filter-enum.js +137 -0
  26. package/lib/cjs/components/modules/filter.js +43 -460
  27. package/lib/cjs/components/modules/join-data.js +863 -525
  28. package/lib/cjs/components/modules/permission-table.js +4 -0
  29. package/lib/cjs/components/modules/sort.js +102 -91
  30. package/lib/cjs/components/modules/summarize/group-by.js +47 -16
  31. package/lib/cjs/components/modules/summarize/select-index.js +48 -17
  32. package/lib/cjs/components/modules/table-data.js +13 -4
  33. package/lib/cjs/components/popup.js +1 -2
  34. package/lib/cjs/hooks/patch.d.ts +4 -0
  35. package/lib/cjs/hooks/patch.js +464 -0
  36. package/lib/cjs/hooks/use-state.js +73 -138
  37. package/lib/cjs/index.d.ts +0 -1
  38. package/lib/cjs/index.js +3 -21
  39. package/lib/cjs/locale/en.js +9 -2
  40. package/lib/cjs/locale/zh.js +11 -4
  41. package/lib/cjs/store/helper.d.ts +2 -3
  42. package/lib/cjs/store/helper.js +288 -233
  43. package/lib/cjs/store/types.d.ts +94 -71
  44. package/lib/cjs/store/types.js +17 -12
  45. package/lib/cjs/utils.d.ts +3 -3
  46. package/lib/cjs/utils.js +152 -187
  47. package/lib/es/common/SplitView/index.js +10 -10
  48. package/lib/es/components/dialog/custom-column/expressions/suggest.js +1 -1
  49. package/lib/es/components/dialog/{select-filter → expression}/index.d.ts +4 -4
  50. package/lib/es/components/dialog/{select-filter → expression}/index.js +343 -206
  51. package/lib/es/components/dialog/formula-list/enum.d.ts +9 -13
  52. package/lib/es/components/dialog/formula-list/enum.js +82 -38
  53. package/lib/es/components/dialog/formula-list/index.d.ts +4 -1
  54. package/lib/es/components/dialog/formula-list/index.js +115 -131
  55. package/lib/es/components/dialog/formula-list/utils.js +77 -46
  56. package/lib/es/components/dialog/index.d.ts +2 -2
  57. package/lib/es/components/dialog/index.js +3 -3
  58. package/lib/es/components/dialog/select-column/index.js +44 -13
  59. package/lib/es/components/dialog/select-column-multiple/index.d.ts +54 -0
  60. package/lib/es/components/dialog/select-column-multiple/index.js +335 -0
  61. package/lib/es/components/dialog/select-column-multiple/index.less +246 -0
  62. package/lib/es/components/dialog/select-table/index.js +9 -7
  63. package/lib/es/components/icons.js +36 -36
  64. package/lib/es/components/metabase/index.js +6 -6
  65. package/lib/es/components/metabase/index.less +12 -1
  66. package/lib/es/components/modules/components/Wrapper.js +6 -6
  67. package/lib/es/components/modules/custom-column.js +12 -14
  68. package/lib/es/components/modules/enum/filter-enum.d.ts +34 -0
  69. package/lib/es/components/modules/enum/filter-enum.js +131 -0
  70. package/lib/es/components/modules/filter.js +45 -463
  71. package/lib/es/components/modules/join-data.js +865 -527
  72. package/lib/es/components/modules/permission-table.js +4 -0
  73. package/lib/es/components/modules/sort.js +102 -91
  74. package/lib/es/components/modules/summarize/group-by.js +48 -17
  75. package/lib/es/components/modules/summarize/select-index.js +49 -18
  76. package/lib/es/components/modules/table-data.js +13 -4
  77. package/lib/es/hooks/patch.d.ts +4 -0
  78. package/lib/es/hooks/patch.js +457 -0
  79. package/lib/es/hooks/use-state.js +73 -138
  80. package/lib/es/index.d.ts +0 -1
  81. package/lib/es/index.js +1 -1
  82. package/lib/es/locale/en.js +9 -2
  83. package/lib/es/locale/zh.js +11 -4
  84. package/lib/es/store/helper.d.ts +2 -3
  85. package/lib/es/store/helper.js +288 -233
  86. package/lib/es/store/types.d.ts +94 -71
  87. package/lib/es/store/types.js +16 -11
  88. package/lib/es/utils.d.ts +3 -3
  89. package/lib/es/utils.js +154 -190
  90. package/package.json +1 -1
  91. package/lib/cjs/components/modules/filter copy.d.ts +0 -7
  92. package/lib/cjs/components/modules/filter copy.js +0 -178
  93. package/lib/es/components/modules/filter copy.d.ts +0 -7
  94. package/lib/es/components/modules/filter copy.js +0 -171
  95. /package/lib/cjs/components/dialog/{select-filter → expression}/index.less +0 -0
  96. /package/lib/es/components/dialog/{select-filter → expression}/index.less +0 -0
@@ -25,6 +25,7 @@ var PermissionTable = function PermissionTable(props) {
25
25
  if (ExistAboveGroupBy) {
26
26
  var _data = {
27
27
  name: prevGroupBy.alias,
28
+ name_zh: prevGroupBy.alias,
28
29
  id: prevGroupBy.alias,
29
30
  tableUuid: uuidv4('table'),
30
31
  alias: prevGroupBy.alias,
@@ -42,6 +43,7 @@ var PermissionTable = function PermissionTable(props) {
42
43
  return {
43
44
  alias: v.table2.alias,
44
45
  name: v.table2.name,
46
+ name_zh: v.table2.name_zh,
45
47
  tableUuid: v.table2.tableUuid,
46
48
  id: v.table2.id,
47
49
  datasourceId: v.table2.datasourceId,
@@ -55,6 +57,7 @@ var PermissionTable = function PermissionTable(props) {
55
57
  mo.push({
56
58
  alias: v.table.alias,
57
59
  name: v.table.name,
60
+ name_zh: v.table.name_zh,
58
61
  id: v.table.id,
59
62
  tableUuid: v.table.tableUuid,
60
63
  datasourceId: v.table.datasourceId,
@@ -64,6 +67,7 @@ var PermissionTable = function PermissionTable(props) {
64
67
  mo.push({
65
68
  alias: v.table2.alias,
66
69
  name: v.table2.name,
70
+ name_zh: v.table2.name_zh,
67
71
  id: v.table2.id,
68
72
  tableUuid: v.table2.tableUuid,
69
73
  datasourceId: v.table2.datasourceId,
@@ -4,11 +4,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  import cx from 'classnames';
5
5
  import { __ } from '../../locale';
6
6
  import { findIndex, getHelper } from '../../utils';
7
- import { SummarizeAlias } from '../../store/helper';
8
7
  import { ColumnsPopupThemeEnum, TypeEnum, SortEnum, SQL_COLUMN_TYPE } from '../../store/enum';
8
+ import { AtomsTypeEnum } from '../../store/types';
9
9
  import { uuidv4 } from '../../utils/helper';
10
10
  import { AddIcon, CloseIcon, UpArrowIcon, DownArrowIcon } from '../icons';
11
- import { SelectJoinColumn } from '../dialog';
11
+ import { SelectColumnMultiple } from '../dialog';
12
12
  import Wrapper from './components/Wrapper';
13
13
  import NextDom from './components/meta-icon';
14
14
  import Header from './components/header';
@@ -27,18 +27,20 @@ var Sort = function Sort(props) {
27
27
  if (ExistAboveGroupBy) {
28
28
  var _prevGroupBy$group, _prevGroupBy$by;
29
29
  var _data = {
30
- table: prevGroupBy.alias,
31
- tableId: prevGroupBy.alias,
32
- tableUuid: prevGroupBy.tableUuid || uuidv4('table'),
33
30
  alias: prevGroupBy.alias,
31
+ name_zh: prevGroupBy.alias,
32
+ name: prevGroupBy.alias,
33
+ id: prevGroupBy.alias,
34
+ tableUuid: prevGroupBy.tableUuid || uuidv4('table'),
35
+ // alias: (prevGroupBy as MetaSummarize).alias,
34
36
  columns: []
35
37
  };
36
38
  if (prevGroupBy !== null && prevGroupBy !== void 0 && (_prevGroupBy$group = prevGroupBy.group) !== null && _prevGroupBy$group !== void 0 && _prevGroupBy$group.length) {
37
39
  _data.columns = _data.columns.concat(prevGroupBy.group.map(function (v) {
38
- return _objectSpread(_objectSpread({
39
- name_zh: v.quotes
40
- }, v), {}, {
41
- name: v.quotes,
40
+ return _objectSpread(_objectSpread({}, v), {}, {
41
+ name: v.name || v.quotes,
42
+ name_zh: v.name_zh || v.quotes,
43
+ id: v.id || v.fieldId,
42
44
  // name_zh: '',
43
45
  database_type: (v === null || v === void 0 ? void 0 : v.database_type) || SQL_COLUMN_TYPE.FLOAT,
44
46
  special_type: '',
@@ -49,11 +51,10 @@ var Sort = function Sort(props) {
49
51
  }
50
52
  if (prevGroupBy !== null && prevGroupBy !== void 0 && (_prevGroupBy$by = prevGroupBy.by) !== null && _prevGroupBy$by !== void 0 && _prevGroupBy$by.length) {
51
53
  _data.columns = _data.columns.concat(prevGroupBy.by.map(function (v) {
52
- return _objectSpread(_objectSpread({
53
- name_zh: v.quotes
54
- }, v), {}, {
55
- name: v.quotes,
56
- // name_zh: '',
54
+ return _objectSpread(_objectSpread({}, v), {}, {
55
+ name: v.name || v.quotes,
56
+ name_zh: v.name_zh || v.quotes,
57
+ id: v.id || v.fieldId,
57
58
  database_type: (v === null || v === void 0 ? void 0 : v.database_type) || SQL_COLUMN_TYPE.FLOAT,
58
59
  special_type: '',
59
60
  sql: v.sql,
@@ -68,18 +69,22 @@ var Sort = function Sort(props) {
68
69
  if (v.type === TypeEnum.data) {
69
70
  return {
70
71
  alias: v.table.alias,
71
- table: v.table.name,
72
+ name: v.table.name,
73
+ name_zh: v.table.name_zh,
72
74
  tableUuid: v.table.tableUuid,
73
- tableId: v.table.id,
75
+ id: v.table.id,
74
76
  columns: v.columns
75
77
  };
76
78
  } else if (v.type === TypeEnum.joinData) {
77
79
  return {
78
80
  alias: v.table2.alias,
79
- table: v.table2.name,
81
+ name: v.table2.name,
82
+ name_zh: v.table2.name_zh,
80
83
  tableUuid: v.table2.tableUuid,
81
- tableId: v.table2.id,
82
- columns: v.columns
84
+ id: v.table2.id,
85
+ columns: v.columns,
86
+ datasourceId: v.table2.datasourceId,
87
+ datasourceName: v.table2.datasourceName
83
88
  };
84
89
  } else {
85
90
  return {
@@ -87,7 +92,7 @@ var Sort = function Sort(props) {
87
92
  };
88
93
  }
89
94
  }).filter(function (v) {
90
- return v.table;
95
+ return v.name;
91
96
  });
92
97
  }
93
98
  return data;
@@ -95,30 +100,20 @@ var Sort = function Sort(props) {
95
100
  function addSortColumn(e) {
96
101
  var node = e.currentTarget || e.target;
97
102
  var newMeta = store.metaList[groupIndex].list.slice();
98
- var value = {
99
- table: '',
100
- tableId: '',
101
- tableUuid: '',
102
- fieldUuid: '',
103
- fieldAlias: '',
104
- alias: '',
105
- name: '',
106
- id: '',
107
- database_type: '',
108
- datasourceId: '',
109
- // 数据源id
110
- datasourceName: '' // 数据源名
111
- };
112
103
  var data = getColumns();
113
104
  // ② 过滤掉已经选择的 排序参数
114
105
  var selectedSort = {}; // {tableAlias: [columnName, columnName]}
115
106
  //@ts-ignore
116
107
  newMeta[index].sort.forEach(function (v) {
117
- if (selectedSort[v.alias]) {
118
- selectedSort[v.alias].push(v.name);
119
- } else {
120
- selectedSort[v.alias] = [v.name];
121
- }
108
+ v.expression.forEach(function (vv) {
109
+ if (vv.type === AtomsTypeEnum.FIELD) {
110
+ if (selectedSort[vv.fieldName]) {
111
+ selectedSort[vv.tableAlias].push(vv.fieldName);
112
+ } else {
113
+ selectedSort[vv.tableAlias] = [vv.fieldName];
114
+ }
115
+ }
116
+ });
122
117
  });
123
118
  data = data.map(function (v) {
124
119
  if (v.alias in selectedSort) {
@@ -134,59 +129,69 @@ var Sort = function Sort(props) {
134
129
  store.setPopup({
135
130
  visible: true,
136
131
  node: node,
137
- content: _jsx(SelectJoinColumn, {
132
+ content: _jsx(SelectColumnMultiple, {
138
133
  data: data,
139
- value: value,
134
+ value: [],
135
+ multiple: false,
140
136
  theme: ColumnsPopupThemeEnum.greenGrass,
141
- onSelect: function onSelect(record) {
142
- var table = record.table,
143
- name = record.name,
144
- tableId = record.tableId,
145
- tableUuid = record.tableUuid,
146
- id = record.id,
147
- alias = record.alias,
148
- sql = record.sql;
149
- if (alias === SummarizeAlias) {
150
- var _sql$split;
151
- var aliasColumns = (sql === null || sql === void 0 || (_sql$split = sql.split(' AS ')) === null || _sql$split === void 0 ? void 0 : _sql$split[1]) || '';
152
- if (store.metaList[groupIndex].list[index - 1].type === TypeEnum.summarize) {
153
- //@ts-ignore
154
- newMeta[index].sort = [].concat(_toConsumableArray(newMeta[index].sort), [{
155
- table: table,
156
- tableId: tableId,
157
- tableUuid: tableUuid,
158
- id: id,
159
- alias: alias,
160
- name: name,
161
- sort: SortEnum.asc,
162
- sql: aliasColumns
163
- }]);
164
- } else {
165
- //@ts-ignore
166
- newMeta[index].sort = [].concat(_toConsumableArray(newMeta[index].sort), [{
167
- table: table,
168
- id: id,
169
- tableId: tableId,
170
- tableUuid: tableUuid,
171
- alias: alias,
172
- name: name,
173
- sort: SortEnum.asc,
174
- sql: "".concat(SummarizeAlias, ".").concat(aliasColumns)
175
- }]);
176
- }
177
- } else {
178
- //@ts-ignore
179
- newMeta[index].sort = [].concat(_toConsumableArray(newMeta[index].sort), [{
180
- table: table,
181
- tableId: tableId,
182
- tableUuid: tableUuid,
183
- id: id,
184
- alias: alias,
185
- name: name,
186
- sort: SortEnum.asc,
187
- sql: "".concat(alias, ".").concat(name)
188
- }]);
189
- }
137
+ onSelect: function onSelect(fields) {
138
+ newMeta[index].sort = [].concat(_toConsumableArray(newMeta[index].sort), [{
139
+ expression: fields,
140
+ sort: SortEnum.asc
141
+ }]);
142
+ // let { table, name, tableId, tableUuid, id, alias, sql } = record;
143
+ // if (alias === SummarizeAlias) {
144
+ // let aliasColumns = (sql as string)?.split(' AS ')?.[1] || '';
145
+ // if (store.metaList[groupIndex].list[index - 1].type === TypeEnum.summarize) {
146
+ // //@ts-ignore
147
+ // newMeta[index].sort = [
148
+ // //@ts-ignore
149
+ // ...newMeta[index].sort,
150
+ // {
151
+ // table,
152
+ // tableId,
153
+ // tableUuid,
154
+ // id,
155
+ // alias,
156
+ // name,
157
+ // sort: SortEnum.asc,
158
+ // sql: aliasColumns,
159
+ // },
160
+ // ];
161
+ // } else {
162
+ // //@ts-ignore
163
+ // newMeta[index].sort = [
164
+ // //@ts-ignore
165
+ // ...newMeta[index].sort,
166
+ // {
167
+ // table,
168
+ // id,
169
+ // tableId,
170
+ // tableUuid,
171
+ // alias,
172
+ // name,
173
+ // sort: SortEnum.asc,
174
+ // sql: `${SummarizeAlias}.${aliasColumns}`,
175
+ // },
176
+ // ];
177
+ // }
178
+ // } else {
179
+ // //@ts-ignore
180
+ // newMeta[index].sort = [
181
+ // //@ts-ignore
182
+ // ...newMeta[index].sort,
183
+ // {
184
+ // table,
185
+ // tableId,
186
+ // tableUuid,
187
+ // id,
188
+ // alias,
189
+ // name,
190
+ // sort: SortEnum.asc,
191
+ // sql: `${alias}.${name}`,
192
+ // },
193
+ // ];
194
+ // }
190
195
  store.setMeta(newMeta, groupIndex);
191
196
  store.setPopup({
192
197
  visible: false
@@ -217,6 +222,12 @@ var Sort = function Sort(props) {
217
222
  });
218
223
  store.setMeta(newMeta, groupIndex);
219
224
  }
225
+ var getName = function getName() {
226
+ var expression = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
227
+ return expression.map(function (v) {
228
+ return v.fieldName;
229
+ }).join(' || ');
230
+ };
220
231
  return _jsx(Wrapper, {
221
232
  className: cx("Sqb-item"),
222
233
  children: _jsxs("div", {
@@ -237,7 +248,7 @@ var Sort = function Sort(props) {
237
248
  onClick: function onClick() {
238
249
  return handleSort(i);
239
250
  },
240
- children: [v.sort === SortEnum.asc ? _jsx(UpArrowIcon, {}) : _jsx(DownArrowIcon, {}), v.name, _jsx("span", {
251
+ children: [v.sort === SortEnum.asc ? _jsx(UpArrowIcon, {}) : _jsx(DownArrowIcon, {}), getName(v.expression), _jsx("span", {
241
252
  style: {
242
253
  fontSize: 0
243
254
  },
@@ -1,4 +1,6 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
1
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
2
4
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
5
  import cx from 'classnames';
4
6
  import { __ } from '../../../locale';
@@ -6,7 +8,7 @@ import { findIndex, getHelper } from '../../../utils';
6
8
  import { TypeEnum, ColumnsPopupThemeEnum, SQL_COLUMN_TYPE } from '../../../store/enum';
7
9
  import { MetaSummarize_Enum } from '../../../store/types';
8
10
  import SelectJoinColumn from '../../dialog/select-join-column';
9
- import { Tooltip, Button, Modal, Input } from '@gingkoo/pandora';
11
+ import { Tooltip, Button, Modal, Input, Toast } from '@gingkoo/pandora';
10
12
  import { uuidv4 } from '../../../utils/helper';
11
13
  import { changeFieldAlias } from '../../../utils';
12
14
  import { AddIcon, CloseIcon } from '../../icons';
@@ -36,10 +38,10 @@ var GroupBy = function GroupBy(props) {
36
38
  if (prevGroupBy !== null && prevGroupBy !== void 0 && (_prevGroupBy$group = prevGroupBy.group) !== null && _prevGroupBy$group !== void 0 && _prevGroupBy$group.length) {
37
39
  _data.columns = _data.columns.concat(prevGroupBy.group.map(function (v) {
38
40
  var _v$sql;
39
- return _objectSpread(_objectSpread({
40
- name_zh: v.quotes
41
- }, v), {}, {
42
- name: v.quotes,
41
+ return _objectSpread(_objectSpread({}, v), {}, {
42
+ name: v.name || v.quotes,
43
+ name_zh: v.name_zh || v.quotes,
44
+ id: v.id || v.fieldId,
43
45
  realName: ((_v$sql = v.sql) === null || _v$sql === void 0 || (_v$sql = _v$sql.split(' AS ')) === null || _v$sql === void 0 ? void 0 : _v$sql[1]) || '',
44
46
  // name_zh: '',
45
47
  database_type: (v === null || v === void 0 ? void 0 : v.database_type) || SQL_COLUMN_TYPE.FLOAT,
@@ -51,10 +53,10 @@ var GroupBy = function GroupBy(props) {
51
53
  if (prevGroupBy !== null && prevGroupBy !== void 0 && (_prevGroupBy$by = prevGroupBy.by) !== null && _prevGroupBy$by !== void 0 && _prevGroupBy$by.length) {
52
54
  _data.columns = _data.columns.concat(prevGroupBy.by.map(function (v) {
53
55
  var _v$sql2;
54
- return _objectSpread(_objectSpread({
55
- name_zh: v.quotes
56
- }, v), {}, {
57
- name: v.quotes,
56
+ return _objectSpread(_objectSpread({}, v), {}, {
57
+ name: v.name || v.quotes,
58
+ name_zh: v.name_zh || v.quotes,
59
+ id: v.id || v.fieldId,
58
60
  realName: ((_v$sql2 = v.sql) === null || _v$sql2 === void 0 || (_v$sql2 = _v$sql2.split(' AS ')) === null || _v$sql2 === void 0 ? void 0 : _v$sql2[1]) || '',
59
61
  // name_zh: '',
60
62
  database_type: (v === null || v === void 0 ? void 0 : v.database_type) || SQL_COLUMN_TYPE.FLOAT,
@@ -159,6 +161,7 @@ var GroupBy = function GroupBy(props) {
159
161
  alias: '',
160
162
  fieldAlias: '',
161
163
  fieldUuid: '',
164
+ fieldId: '',
162
165
  name: '',
163
166
  id: '',
164
167
  sql: '',
@@ -228,14 +231,42 @@ var GroupBy = function GroupBy(props) {
228
231
  fieldAlias = val;
229
232
  }
230
233
  }),
231
- onOk: function onOk() {
232
- var newMeta = store.metaList[groupIndex].list.slice();
233
- // @ts-ignore
234
- newMeta[index].by[i].sql = newMeta[index].by[i].sql.split('AS ')[0] + "AS ".concat(fieldAlias); //修改sql
235
- newMeta[index].by[i].fieldAlias = fieldAlias;
236
- newMeta = changeFieldAlias(newMeta, newMeta[index].by[i]);
237
- store.setMeta(newMeta, groupIndex);
238
- },
234
+ onOk: function () {
235
+ var _onOk = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
236
+ var newMeta;
237
+ return _regeneratorRuntime.wrap(function (_context) {
238
+ while (1) switch (_context.prev = _context.next) {
239
+ case 0:
240
+ if (fieldAlias) {
241
+ _context.next = 1;
242
+ break;
243
+ }
244
+ Toast.warning(__('SqlQueryBuilder.aliasCannotEmpty'));
245
+ return _context.abrupt("return", false);
246
+ case 1:
247
+ if (!(fieldAlias.length > 30)) {
248
+ _context.next = 2;
249
+ break;
250
+ }
251
+ Toast.warning('别名长度不能超过30');
252
+ return _context.abrupt("return", false);
253
+ case 2:
254
+ newMeta = store.metaList[groupIndex].list.slice(); // @ts-ignore
255
+ newMeta[index].by[i].sql = newMeta[index].by[i].sql.split('AS ')[0] + "AS ".concat(fieldAlias); //修改sql
256
+ newMeta[index].by[i].fieldAlias = fieldAlias;
257
+ newMeta = changeFieldAlias(newMeta, newMeta[index].by[i]);
258
+ store.setMeta(newMeta, groupIndex);
259
+ case 3:
260
+ case "end":
261
+ return _context.stop();
262
+ }
263
+ }, _callee);
264
+ }));
265
+ function onOk() {
266
+ return _onOk.apply(this, arguments);
267
+ }
268
+ return onOk;
269
+ }(),
239
270
  onCancel: function onCancel() {}
240
271
  });
241
272
  };
@@ -1,11 +1,13 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
1
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
2
4
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
5
  import cx from 'classnames';
4
6
  import { __ } from '../../../locale';
5
7
  import { findIndex, getHelper } from '../../../utils';
6
8
  import { TypeEnum, SQL_COLUMN_TYPE } from '../../../store/enum';
7
9
  import { summarizeToSql } from '../../../store/helper';
8
- import { Tooltip, Button, Modal, Input } from '@gingkoo/pandora';
10
+ import { Tooltip, Button, Modal, Input, Toast } from '@gingkoo/pandora';
9
11
  import { uuidv4 } from '../../../utils/helper';
10
12
  import { MetaSummarize_Enum } from '../../../store/types';
11
13
  import { changeFieldAlias } from '../../../utils';
@@ -37,10 +39,10 @@ var SelectIndex = function SelectIndex(props) {
37
39
  if (prevGroupBy !== null && prevGroupBy !== void 0 && (_prevGroupBy$group = prevGroupBy.group) !== null && _prevGroupBy$group !== void 0 && _prevGroupBy$group.length) {
38
40
  _data.columns = _data.columns.concat(prevGroupBy.group.map(function (v) {
39
41
  var _v$sql;
40
- return _objectSpread(_objectSpread({
41
- name_zh: v.quotes
42
- }, v), {}, {
43
- name: v.quotes,
42
+ return _objectSpread(_objectSpread({}, v), {}, {
43
+ name: v.name || v.quotes,
44
+ name_zh: v.name_zh || v.quotes,
45
+ id: v.id || v.fieldId,
44
46
  fieldUuid: uuidv4('field'),
45
47
  fieldAlias: v.fieldAlias || '',
46
48
  realName: ((_v$sql = v.sql) === null || _v$sql === void 0 || (_v$sql = _v$sql.split(' AS ')) === null || _v$sql === void 0 ? void 0 : _v$sql[1]) || '',
@@ -54,10 +56,10 @@ var SelectIndex = function SelectIndex(props) {
54
56
  if (prevGroupBy !== null && prevGroupBy !== void 0 && (_prevGroupBy$by = prevGroupBy.by) !== null && _prevGroupBy$by !== void 0 && _prevGroupBy$by.length) {
55
57
  _data.columns = _data.columns.concat(prevGroupBy.by.map(function (v) {
56
58
  var _v$sql2;
57
- return _objectSpread(_objectSpread({
58
- name_zh: v.quotes
59
- }, v), {}, {
60
- name: v.quotes,
59
+ return _objectSpread(_objectSpread({}, v), {}, {
60
+ name: v.name || v.quotes,
61
+ name_zh: v.name_zh || v.quotes,
62
+ id: v.id || v.fieldId,
61
63
  realName: ((_v$sql2 = v.sql) === null || _v$sql2 === void 0 || (_v$sql2 = _v$sql2.split(' AS ')) === null || _v$sql2 === void 0 ? void 0 : _v$sql2[1]) || '',
62
64
  // name_zh: '',
63
65
  database_type: (v === null || v === void 0 ? void 0 : v.database_type) || SQL_COLUMN_TYPE.FLOAT,
@@ -139,6 +141,7 @@ var SelectIndex = function SelectIndex(props) {
139
141
  sql = _summarizeToSql.sql,
140
142
  fieldAlias = _summarizeToSql.fieldAlias;
141
143
  return _objectSpread(_objectSpread({}, v), {}, {
144
+ name: v.name || v.quotes,
142
145
  //@ts-ignore
143
146
  sql: sql,
144
147
  fieldAlias: fieldAlias
@@ -193,7 +196,7 @@ var SelectIndex = function SelectIndex(props) {
193
196
  sql = _summarizeToSql2.sql,
194
197
  fieldAlias = _summarizeToSql2.fieldAlias;
195
198
  return _objectSpread(_objectSpread({}, v), {}, {
196
- // @ts-ignore
199
+ name: v.name || v.quotes,
197
200
  sql: sql,
198
201
  fieldUuid: uuidv4('field'),
199
202
  fieldAlias: fieldAlias,
@@ -236,14 +239,42 @@ var SelectIndex = function SelectIndex(props) {
236
239
  }
237
240
  }),
238
241
  icon: false,
239
- onOk: function onOk() {
240
- var newMeta = store.metaList[groupIndex].list.slice();
241
- // @ts-ignore
242
- newMeta[index].group[i].fieldAlias = fieldAlias;
243
- newMeta[index].group[i].sql = newMeta[index].group[i].sql.split('AS ')[0] + "AS ".concat(fieldAlias); //修改sql
244
- newMeta = changeFieldAlias(newMeta, newMeta[index].group[i]);
245
- store.setMeta(newMeta, groupIndex);
246
- },
242
+ onOk: function () {
243
+ var _onOk = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
244
+ var newMeta;
245
+ return _regeneratorRuntime.wrap(function (_context) {
246
+ while (1) switch (_context.prev = _context.next) {
247
+ case 0:
248
+ if (fieldAlias) {
249
+ _context.next = 1;
250
+ break;
251
+ }
252
+ Toast.warning(__('SqlQueryBuilder.aliasCannotEmpty'));
253
+ return _context.abrupt("return", false);
254
+ case 1:
255
+ if (!(fieldAlias.length > 30)) {
256
+ _context.next = 2;
257
+ break;
258
+ }
259
+ Toast.warning('别名长度不能超过30');
260
+ return _context.abrupt("return", false);
261
+ case 2:
262
+ newMeta = store.metaList[groupIndex].list.slice(); // @ts-ignore
263
+ newMeta[index].group[i].fieldAlias = fieldAlias;
264
+ newMeta[index].group[i].sql = newMeta[index].group[i].sql.split('AS ')[0] + "AS ".concat(fieldAlias); //修改sql
265
+ newMeta = changeFieldAlias(newMeta, newMeta[index].group[i]);
266
+ store.setMeta(newMeta, groupIndex);
267
+ case 3:
268
+ case "end":
269
+ return _context.stop();
270
+ }
271
+ }, _callee);
272
+ }));
273
+ function onOk() {
274
+ return _onOk.apply(this, arguments);
275
+ }
276
+ return onOk;
277
+ }(),
247
278
  onCancel: function onCancel() {}
248
279
  });
249
280
  };
@@ -84,21 +84,28 @@ var TableData = function TableData(props) {
84
84
  onOk: function () {
85
85
  var _onOk = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
86
86
  var newMetaList;
87
- return _regeneratorRuntime.wrap(function _callee$(_context) {
87
+ return _regeneratorRuntime.wrap(function (_context) {
88
88
  while (1) switch (_context.prev = _context.next) {
89
89
  case 0:
90
90
  if (alias) {
91
- _context.next = 5;
91
+ _context.next = 1;
92
92
  break;
93
93
  }
94
94
  Toast.warning(__('SqlQueryBuilder.aliasCannotEmpty'));
95
95
  return _context.abrupt("return", false);
96
- case 5:
96
+ case 1:
97
+ if (!(alias.length > 30)) {
98
+ _context.next = 2;
99
+ break;
100
+ }
101
+ Toast.warning('别名长度不能超过30');
102
+ return _context.abrupt("return", false);
103
+ case 2:
97
104
  newMetaList = store.metaList[groupIndex].list.slice(); // @ts-ignore
98
105
  newMetaList[0].table.alias = alias;
99
106
  newMetaList = changeTableAlias(newMetaList, newMetaList[0].table);
100
107
  store.setMeta(newMetaList, groupIndex);
101
- case 9:
108
+ case 3:
102
109
  case "end":
103
110
  return _context.stop();
104
111
  }
@@ -175,6 +182,8 @@ var TableData = function TableData(props) {
175
182
  newMetaList.table = {
176
183
  name: '',
177
184
  // 表名
185
+ name_zh: '',
186
+ // 表名
178
187
  tableUuid: '',
179
188
  id: '',
180
189
  // 表名
@@ -0,0 +1,4 @@
1
+ export declare const joinDataPatch: (newMeta: any) => any;
2
+ export declare const filterPatch: (newMeta: any) => any;
3
+ export declare const customColumnPatch: (newMeta: any) => any;
4
+ export declare const sortPatch: (newMeta: any) => any;