@gingkoo/pandora-metabase 1.0.0-alpha.6 → 1.0.0-alpha.8

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/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @gingkoo/pandora-metabase v1.0.0-alpha.6
2
+ * @gingkoo/pandora-metabase v1.0.0-alpha.8
3
3
  */
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import * as React from 'react';
@@ -466,15 +466,15 @@ const handleNesting = data => {
466
466
  if (customColumn && customColumn.customColumn.length) {
467
467
  obj.customColumns = customColumn.customColumn.map(v => {
468
468
  return {
469
- alias: v.name,
470
- formula: v.formula.replace(/\[.*?\]/g, column => {
471
- let str = column.substr(1, column.length - 2);
472
- if (~str.indexOf('->')) {
473
- let _str = str.replace(/ /g, '').split('->');
474
- return `${_str[0]}.${_str[1]}`;
475
- }
476
- return str;
477
- })
469
+ alias: v.name
470
+ // formula: v.formula.replace(/\[.*?\]/g, (column: string): string => {
471
+ // let str = column.substr(1, column.length - 2);
472
+ // if (~str.indexOf('->')) {
473
+ // let _str = str.replace(/ /g, '').split('->');
474
+ // return `${_str[0]}.${_str[1]}`;
475
+ // }
476
+ // return str;
477
+ // }),
478
478
  };
479
479
  });
480
480
  }
@@ -625,9 +625,8 @@ const getSubColumns = metaList => {
625
625
  metaKey: -1,
626
626
  type: TypeEnum.customColumn,
627
627
  customColumn: [{
628
- name: '',
629
- // 用户起的别名
630
- formula: '' // 公式}];
628
+ name: '' // 用户起的别名
629
+ // formula: '', // 公式}];
631
630
  }]
632
631
  };
633
632
  let {
@@ -649,7 +648,7 @@ const getSubColumns = metaList => {
649
648
  return {
650
649
  name_zh: v.quotes,
651
650
  ...v,
652
- name: v.quotes,
651
+ name: v.fieldAlias,
653
652
  realName: v.sql?.split(' AS ')?.[1] || '',
654
653
  // name_zh: '',
655
654
  database_type: v?.database_type || SQL_COLUMN_TYPE.FLOAT,
@@ -663,7 +662,7 @@ const getSubColumns = metaList => {
663
662
  return {
664
663
  name_zh: v.quotes,
665
664
  ...v,
666
- name: v.quotes,
665
+ name: v.fieldAlias,
667
666
  realName: v.sql?.split(' AS ')?.[1] || '',
668
667
  // name_zh: '',
669
668
  database_type: v?.database_type || SQL_COLUMN_TYPE.FLOAT,
@@ -731,6 +730,9 @@ const changeTableAlias = (list, curObj) => {
731
730
  if (v.table1.tableUuid === tableUuid) {
732
731
  v.table1.alias = alias;
733
732
  }
733
+ if (v.table2.tableUuid === tableUuid) {
734
+ v.table2.alias = alias;
735
+ }
734
736
  }
735
737
  if (v.type === TypeEnum.customColumn) {
736
738
  v.customColumn.map(item => {
@@ -774,22 +776,40 @@ const changeTableAlias = (list, curObj) => {
774
776
  if (v.type === TypeEnum.filter) {
775
777
  v.filter.map(item => {
776
778
  if (item.tableUuid === tableUuid) {
777
- if (item.alias === SummarizeAlias$1) {
778
- //有groupBy 特殊处理
779
- const {
780
- prevGroupBy
781
- } = getHelper(list, v);
782
- let groupBy = prevGroupBy?.by.filter(v => v.fieldUuid === item.fieldUuid)[0] || prevGroupBy?.group.filter(v => v.fieldUuid === item.fieldUuid)[0] || null;
783
- groupBy.alias = alias;
784
- const sql = groupBy.sql;
785
- if (groupBy) {
786
- item.sql = sql;
787
- item.groupSql = sql;
788
- }
789
- } else {
790
- item.alias = alias;
791
- item.sql = '';
792
- }
779
+ // if (item.alias === SummarizeAlias) {
780
+ // //有groupBy 特殊处理
781
+ // const { prevGroupBy } = getHelper(list, v);
782
+ // let groupBy: any =
783
+ // prevGroupBy?.by.filter((v) => v.fieldUuid === item.fieldUuid)[0] ||
784
+ // prevGroupBy?.group.filter((v) => v.fieldUuid === item.fieldUuid)[0] ||
785
+ // null;
786
+ // groupBy.alias = alias;
787
+ // const sql = groupBy.sql;
788
+ // if (groupBy) {
789
+ // item.sql = sql;
790
+ // item.groupSql = sql;
791
+ // }
792
+ // }
793
+ item.alias = alias;
794
+ item.sql = '';
795
+ }
796
+ if (item.table2 && item.table2.tableUuid === tableUuid) {
797
+ // if (item.table2.alias === SummarizeAlias) {
798
+ // //有groupBy 特殊处理
799
+ // const { prevGroupBy } = getHelper(list, v);
800
+ // let groupBy: any =
801
+ // prevGroupBy?.by.filter((v) => v.fieldUuid === item.table2?.fieldUuid)[0] ||
802
+ // prevGroupBy?.group.filter((v) => v.fieldUuid === item.table2?.fieldUuid)[0] ||
803
+ // null;
804
+ // groupBy.alias = alias;
805
+ // const sql = groupBy.sql;
806
+ // if (groupBy) {
807
+ // item.table2.sql = sql;
808
+ // item.table2.groupSql = sql;
809
+ // }
810
+ // }
811
+ item.table2.alias = alias;
812
+ item.table2.sql = '';
793
813
  }
794
814
  });
795
815
  }
@@ -804,7 +824,25 @@ const changeFieldAlias = (list, curObj) => {
804
824
  const newList = cloneDeep(list);
805
825
  newList.map(v => {
806
826
  if (v.type === TypeEnum.data) ;
807
- if (v.type === TypeEnum.joinData) ;
827
+ if (v.type === TypeEnum.joinData) {
828
+ if (v.table1.fieldUuid === fieldUuid) {
829
+ v.table1.fieldAlias = fieldAlias;
830
+ }
831
+ if (v.table2.fieldUuid === fieldUuid) {
832
+ v.table2.fieldAlias = fieldAlias;
833
+ }
834
+ v.expressions.map(column => {
835
+ if (column.left_fieldUuid === fieldUuid) {
836
+ column.left_fieldAlias = fieldAlias;
837
+ }
838
+ if (column.right_fieldUuid === fieldUuid) {
839
+ column.right_fieldAlias = fieldAlias;
840
+ }
841
+ });
842
+ // if (v.table1.tableUuid === tableUuid) {
843
+ // v.table1.alias = alias;
844
+ // }
845
+ }
808
846
  if (v.type === TypeEnum.customColumn) {
809
847
  v.customColumn.map(item => {
810
848
  item.formulaList?.map(formula => {
@@ -863,6 +901,23 @@ const changeFieldAlias = (list, curObj) => {
863
901
  }
864
902
  }
865
903
  }
904
+ if (item.table2 && item.table2.fieldUuid === fieldUuid) {
905
+ item.table2.fieldAlias = fieldAlias;
906
+ // if (item.table2.alias === SummarizeAlias) {
907
+ // //有groupBy 特殊处理
908
+ // const { prevGroupBy } = getHelper(list, v);
909
+ // let groupBy: any =
910
+ // prevGroupBy?.by.filter((v) => v.fieldUuid === item.table2?.fieldUuid)[0] ||
911
+ // prevGroupBy?.group.filter((v) => v.fieldUuid === item.table2?.fieldUuid)[0] ||
912
+ // null;
913
+ // groupBy.fieldAlias = fieldAlias;
914
+ // const sql = groupBy.sql;
915
+ // if (groupBy) {
916
+ // item.table2.sql = sql;
917
+ // item.table2.groupSql = sql;
918
+ // }
919
+ // }
920
+ }
866
921
  });
867
922
  }
868
923
  });
@@ -1019,18 +1074,18 @@ const useStore = () => {
1019
1074
  };
1020
1075
  // 是否显示主表后面的字段按钮 (如果下面 没有聚合,或者选了聚合但是聚合里面没有选值的时候显示 主表字段按钮)
1021
1076
  const showMainColumn = useMemo(() => {
1022
- // 先将二维数组拍平为一维数组
1023
- const flatMetaList = metaList.flatMap(group => group.list);
1024
- // 过滤出所有汇总类型的项
1025
- const summarizeItems = flatMetaList.filter(v => v.type === TypeEnum.summarize);
1026
- // 如果没有汇总项,默认显示主列
1027
- if (summarizeItems.length === 0) {
1028
- return true;
1029
- }
1030
- // 如果只有一个汇总项,并且 group 和 by 都为空,则也显示主列
1031
- const onlyItem = summarizeItems[0];
1032
- const hasGroupOrBy = Array.isArray(onlyItem.group) && onlyItem.group.length > 0 || Array.isArray(onlyItem.by) && onlyItem.by.length > 0;
1033
- return !hasGroupOrBy;
1077
+ return metaList.map((item, groupIndex) => {
1078
+ // 过滤出所有汇总类型的项
1079
+ const summarizeItems = item.list.filter(v => v.type === TypeEnum.summarize);
1080
+ // 如果没有汇总项,默认显示主列
1081
+ if (summarizeItems.length === 0) {
1082
+ return true;
1083
+ }
1084
+ // 如果只有一个汇总项,并且 group 和 by 都为空,则也显示主列
1085
+ const onlyItem = summarizeItems[0];
1086
+ const hasGroupOrBy = Array.isArray(onlyItem.group) && onlyItem.group.length > 0 || Array.isArray(onlyItem.by) && onlyItem.by.length > 0;
1087
+ return !hasGroupOrBy;
1088
+ });
1034
1089
  }, [metaList]);
1035
1090
  // const showMainColumn = useMemo(() => {
1036
1091
  // let summarizeList = metaList.filter((v) => v.type === TypeEnum.summarize);
@@ -1158,8 +1213,8 @@ const useStore = () => {
1158
1213
  tableUuid: '',
1159
1214
  datasourceId: '',
1160
1215
  datasourceName: '',
1161
- column: '',
1162
- column_id: ''
1216
+ fieldAlias: '',
1217
+ fieldUuid: ''
1163
1218
  };
1164
1219
  if (index === 1) {
1165
1220
  table1 = {
@@ -1168,8 +1223,8 @@ const useStore = () => {
1168
1223
  alias: mainTable.table.alias,
1169
1224
  datasourceId: mainTable.table.datasourceId,
1170
1225
  datasourceName: mainTable.table.datasourceName,
1171
- column: '',
1172
- column_id: ''
1226
+ fieldAlias: '',
1227
+ fieldUuid: ''
1173
1228
  };
1174
1229
  }
1175
1230
  item = {
@@ -1184,8 +1239,8 @@ const useStore = () => {
1184
1239
  tableUuid: '',
1185
1240
  datasourceId: '',
1186
1241
  datasourceName: '',
1187
- column: '',
1188
- column_id: ''
1242
+ fieldAlias: '',
1243
+ fieldUuid: ''
1189
1244
  },
1190
1245
  columns: [],
1191
1246
  expressions: []
@@ -3962,7 +4017,8 @@ const SelectFilterColumn = ({
3962
4017
  value,
3963
4018
  onChange,
3964
4019
  didUpdate,
3965
- isCustom: _isCustom = false
4020
+ isCustom: _isCustom = false,
4021
+ container: _container = null
3966
4022
  }) => {
3967
4023
  const [curColumn, setCurColumn] = useState(value);
3968
4024
  const [condition, setCondition] = useState(value.condition);
@@ -4379,6 +4435,7 @@ const SelectFilterColumn = ({
4379
4435
  store.setPopup2({
4380
4436
  visible: true,
4381
4437
  node: e.currentTarget,
4438
+ container: _container,
4382
4439
  content: jsx(SelectList, {
4383
4440
  value: valType,
4384
4441
  list: store.constantList || [],
@@ -4401,6 +4458,7 @@ const SelectFilterColumn = ({
4401
4458
  store.setPopup2({
4402
4459
  visible: true,
4403
4460
  node: e.currentTarget,
4461
+ container: _container,
4404
4462
  content: jsx(SelectList, {
4405
4463
  value: valType,
4406
4464
  list: [{
@@ -4435,6 +4493,7 @@ const SelectFilterColumn = ({
4435
4493
  store.setPopup2({
4436
4494
  visible: true,
4437
4495
  node: e.currentTarget,
4496
+ container: _container,
4438
4497
  content: jsx(SelectJoinColumn, {
4439
4498
  data: [..._data],
4440
4499
  value: value,
@@ -5521,7 +5580,7 @@ const TableData = props => {
5521
5580
  }
5522
5581
  })
5523
5582
  }), selected ? `${meta.table.datasourceName}.${meta.table.name} ${meta.table?.alias ? `as ${meta.table?.alias}` : ''}` : __('SqlQueryBuilder.pickTable')]
5524
- }), selected && store.showMainColumn && store.showFields && jsx("div", {
5583
+ }), selected && store.showMainColumn[groupIndex] && store.showFields && jsx("div", {
5525
5584
  className: `Sqb-TableColumns`,
5526
5585
  onClick: selectColumns,
5527
5586
  children: __('SqlQueryBuilder.columns')
@@ -5536,6 +5595,33 @@ const TableData = props => {
5536
5595
  };
5537
5596
 
5538
5597
  const PrevResult$1 = 'Previous results';
5598
+ function setQuotes(_meta) {
5599
+ let newMeta = cloneDeep(_meta);
5600
+ newMeta.table1 = {
5601
+ ...newMeta.table1,
5602
+ fieldAlias: newMeta.table1.fieldAlias || newMeta.table1.column,
5603
+ fieldUuid: newMeta.table1.fieldUuid || newMeta.table1.column_id,
5604
+ quotes: newMeta.table1.quotes || newMeta.table1.column
5605
+ };
5606
+ newMeta.table2 = {
5607
+ ...newMeta.table2,
5608
+ fieldAlias: newMeta.table2.fieldAlias || newMeta.table2.column,
5609
+ fieldUuid: newMeta.table2.fieldUuid || newMeta.table2.column_id,
5610
+ quotes: newMeta.table2.quotes || newMeta.table2.column
5611
+ };
5612
+ newMeta.expressions = newMeta.expressions.map(v => {
5613
+ return {
5614
+ ...v,
5615
+ left_fieldAlias: v.fieldAlias || v.left_column,
5616
+ left_fieldUuid: v.fieldUuid || v.left_column_id,
5617
+ left_quotes: v.left_quotes || v.left_column,
5618
+ right_fieldAlias: v.right_fieldAlias || v.right_column,
5619
+ right_fieldUuid: v.right_fieldUuid || v.right_column_id,
5620
+ right_quotes: v.right_quotes || v.right_column
5621
+ };
5622
+ });
5623
+ return newMeta;
5624
+ }
5539
5625
  var FlagLocation;
5540
5626
  (function (FlagLocation) {
5541
5627
  FlagLocation["TABLE_1"] = "table1";
@@ -5543,8 +5629,8 @@ var FlagLocation;
5543
5629
  })(FlagLocation || (FlagLocation = {}));
5544
5630
  var ExpressionsEnum;
5545
5631
  (function (ExpressionsEnum) {
5546
- ExpressionsEnum["LEFT"] = "left_column";
5547
- ExpressionsEnum["RIGHT"] = "right_column";
5632
+ ExpressionsEnum["LEFT"] = "left";
5633
+ ExpressionsEnum["RIGHT"] = "right";
5548
5634
  })(ExpressionsEnum || (ExpressionsEnum = {}));
5549
5635
  const JoinData = props => {
5550
5636
  const {
@@ -5559,7 +5645,12 @@ const JoinData = props => {
5559
5645
  let table1Selected = Boolean(meta.table1.name);
5560
5646
  let table2Selected = Boolean(meta.table2.name);
5561
5647
  let subQuerySelected = Boolean(meta.subquery?.[0]?.table?.name);
5562
- let columnsSelected = meta.table1.column && meta.table2.column;
5648
+ let columnsSelected = meta.table1.quotes && meta.table2.quotes;
5649
+ useEffect(() => {
5650
+ let newMetaList = store.metaList[groupIndex].list.slice();
5651
+ newMetaList[index] = setQuotes(meta);
5652
+ store.setMeta(newMetaList, groupIndex);
5653
+ }, []);
5563
5654
  function selectColumns(e) {
5564
5655
  let columns = meta.columns;
5565
5656
  !meta.readonly && store.setPopup({
@@ -5628,8 +5719,9 @@ const JoinData = props => {
5628
5719
  name: tableName,
5629
5720
  tableUuid: data.tableUuid || uuidv4('table'),
5630
5721
  alias,
5631
- column: '',
5632
- column_id: '',
5722
+ fieldAlias: '',
5723
+ fieldUuid: '',
5724
+ quotes: '',
5633
5725
  datasourceId: data.datasourceId,
5634
5726
  datasourceName: data.datasourceName
5635
5727
  };
@@ -5672,8 +5764,9 @@ const JoinData = props => {
5672
5764
  let type = node.getAttribute('v-data');
5673
5765
  let data = [];
5674
5766
  let value = {
5675
- name: meta[type].column,
5676
- id: meta[type].column_id,
5767
+ name: meta[type].quotes || meta[type].fieldAlias,
5768
+ quotes: meta[type].quotes,
5769
+ id: meta[type].fieldUuid,
5677
5770
  table: meta[type].name,
5678
5771
  tableId: meta[type].id,
5679
5772
  fieldUuid: meta[type].fieldUuid || uuidv4('field'),
@@ -5791,11 +5884,21 @@ const JoinData = props => {
5791
5884
  sql,
5792
5885
  datasourceId,
5793
5886
  datasourceName,
5794
- id = ''
5887
+ id = '',
5888
+ fieldAlias = '',
5889
+ fieldUuid = '',
5890
+ quotes
5795
5891
  } = record;
5796
5892
  let newMeta = store.metaList[groupIndex].list.slice();
5797
- newMeta[index][type].column = name;
5798
- newMeta[index][type].column_id = id;
5893
+ if (alias === SummarizeAlias$1) {
5894
+ newMeta[index][type].fieldAlias = fieldAlias;
5895
+ newMeta[index][type].fieldUuid = fieldUuid;
5896
+ newMeta[index][type].quotes = quotes;
5897
+ } else {
5898
+ newMeta[index][type].fieldAlias = name;
5899
+ newMeta[index][type].fieldUuid = id;
5900
+ newMeta[index][type].quotes = name;
5901
+ }
5799
5902
  if (type === FlagLocation.TABLE_1) {
5800
5903
  if (newMeta[index][type].alias !== alias) {
5801
5904
  newMeta[index][type].alias = alias;
@@ -5823,8 +5926,8 @@ const JoinData = props => {
5823
5926
  let index = findIndex(store.metaList[groupIndex].list, meta);
5824
5927
  let table_type = type === ExpressionsEnum.LEFT ? FlagLocation.TABLE_1 : FlagLocation.TABLE_2;
5825
5928
  let value = {
5826
- name: meta.expressions[_ind][type],
5827
- id: meta.expressions[_ind][`${type}_id`],
5929
+ name: meta.expressions[_ind][`${type}_quotes`] || meta.expressions[_ind][`${type}_fieldAlias`],
5930
+ id: meta.expressions[_ind][`${type}_fieldUuid`],
5828
5931
  table: meta[table_type].name,
5829
5932
  fieldUuid: meta[table_type].fieldUuid || uuidv4('field'),
5830
5933
  fieldAlias: meta[table_type].fieldAlias || '',
@@ -5949,11 +6052,23 @@ const JoinData = props => {
5949
6052
  sql,
5950
6053
  datasourceId,
5951
6054
  datasourceName,
5952
- id = ''
6055
+ id = '',
6056
+ fieldAlias,
6057
+ fieldUuid,
6058
+ quotes = ''
5953
6059
  } = record;
5954
6060
  let newMeta = store.metaList[groupIndex].list.slice();
5955
- newMeta[index].expressions[_ind][type] = name;
5956
- newMeta[index].expressions[_ind][`${type}_id`] = id;
6061
+ if (alias === SummarizeAlias$1) {
6062
+ newMeta[index].expressions[_ind][`${type}_fieldAlias`] = fieldAlias;
6063
+ newMeta[index].expressions[_ind][`${type}_fieldUuid`] = fieldUuid;
6064
+ newMeta[index].expressions[_ind][`${type}_quotes`] = quotes;
6065
+ } else {
6066
+ newMeta[index].expressions[_ind][`${type}_fieldAlias`] = name;
6067
+ newMeta[index].expressions[_ind][`${type}_fieldUuid`] = id;
6068
+ newMeta[index].expressions[_ind][`${type}_quotes`] = name;
6069
+ }
6070
+ // (newMeta[index] as MetaJoin).expressions[_ind][type] = name;
6071
+ // (newMeta[index] as MetaJoin).expressions[_ind][`${type}_id`] = id;
5957
6072
  store.setMeta(newMeta, groupIndex);
5958
6073
  store.setPopup({
5959
6074
  visible: false
@@ -6057,8 +6172,8 @@ const JoinData = props => {
6057
6172
  newMeta[index].subquery = newList;
6058
6173
  newMeta[index].table2 = {
6059
6174
  ...newList[0].table,
6060
- column: '',
6061
- column_id: ''
6175
+ fieldAlias: '',
6176
+ fieldUuid: ''
6062
6177
  };
6063
6178
  const items = getSubColumns(newList);
6064
6179
  const newColumns = items.flatMap(item => item.columns);
@@ -6083,8 +6198,9 @@ const JoinData = props => {
6083
6198
  let newMeta = store.metaList[groupIndex].list.slice();
6084
6199
  newMeta[index].isSubquery = !newMeta[index].isSubquery;
6085
6200
  newMeta[index].table2 = {
6086
- column: '',
6087
- column_id: '',
6201
+ quotes: '',
6202
+ fieldAlias: '',
6203
+ fieldUuid: '',
6088
6204
  name: '',
6089
6205
  // 表名
6090
6206
  tableUuid: '',
@@ -6217,23 +6333,23 @@ const JoinData = props => {
6217
6333
  children: "on"
6218
6334
  }), jsx("div", {
6219
6335
  className: cx(`Sqb-TableName`, {
6220
- notSelected: !meta.table1.column
6336
+ notSelected: !meta.table1.quotes
6221
6337
  }),
6222
6338
  "v-data": FlagLocation.TABLE_1,
6223
6339
  onClick: selectJoinColumn,
6224
- children: meta.table1.column ? meta.table1.column : __('SqlQueryBuilder.pickTable')
6340
+ children: meta.table1.quotes ? meta.table1.quotes : __('SqlQueryBuilder.pickTable')
6225
6341
  }), jsx("span", {
6226
6342
  className: 'mr-2 text-gray-500',
6227
6343
  children: "="
6228
6344
  }), jsx("div", {
6229
6345
  className: cx(`Sqb-TableName`, {
6230
- notSelected: !meta.table2.column
6346
+ notSelected: !meta.table2.quotes
6231
6347
  }),
6232
6348
  "v-data": FlagLocation.TABLE_2,
6233
6349
  onClick: selectJoinColumn,
6234
- children: meta.table2.column ? meta.table2.column : __('SqlQueryBuilder.pickTable')
6350
+ children: meta.table2.quotes ? meta.table2.quotes : __('SqlQueryBuilder.pickTable')
6235
6351
  })]
6236
- }), meta.table1.column_id && meta.table2.column_id && meta.expressions?.map((v, i) => {
6352
+ }), meta.table1.fieldUuid && meta.table2.fieldUuid && meta.expressions?.map((v, i) => {
6237
6353
  return jsxs("div", {
6238
6354
  className: cx(`Sqb-where block`),
6239
6355
  children: [jsx("span", {
@@ -6262,12 +6378,12 @@ const JoinData = props => {
6262
6378
  children: v.left_constant ? v.left_constant : __('SqlQueryBuilder.pickConstant')
6263
6379
  }), (!v.left_type || v.left_type === 'field') && jsx("div", {
6264
6380
  className: cx(`Sqb-TableName`, {
6265
- notSelected: !v.left_column
6381
+ notSelected: !v.left_quotes
6266
6382
  }),
6267
6383
  "v-data": ExpressionsEnum.LEFT,
6268
6384
  "v-index": i,
6269
6385
  onClick: selectMoreJoinColumn,
6270
- children: v.left_column ? v.left_column : __('SqlQueryBuilder.pickTable')
6386
+ children: v.left_quotes ? v.left_quotes : __('SqlQueryBuilder.pickTable')
6271
6387
  }), jsx(Tooltip, {
6272
6388
  title: __('SqlQueryBuilder.switch'),
6273
6389
  children: jsx(Button, {
@@ -6306,12 +6422,12 @@ const JoinData = props => {
6306
6422
  children: v.right_constant ? v.right_constant : __('SqlQueryBuilder.pickConstant')
6307
6423
  }), (!v.right_type || v.right_type === 'field') && jsx("div", {
6308
6424
  className: cx(`Sqb-TableName`, {
6309
- notSelected: !v.right_column
6425
+ notSelected: !v.right_quotes
6310
6426
  }),
6311
6427
  "v-data": ExpressionsEnum.RIGHT,
6312
6428
  "v-index": i,
6313
6429
  onClick: selectMoreJoinColumn,
6314
- children: v.right_column ? v.right_column : __('SqlQueryBuilder.pickTable')
6430
+ children: v.right_quotes ? v.right_quotes : __('SqlQueryBuilder.pickTable')
6315
6431
  }), jsx(Tooltip, {
6316
6432
  title: __('SqlQueryBuilder.switch'),
6317
6433
  children: jsx(Button, {
@@ -6337,14 +6453,16 @@ const JoinData = props => {
6337
6453
  let newMeta = store.metaList[groupIndex].list.slice();
6338
6454
  newMeta[index].expressions.splice(i + 1, 0, {
6339
6455
  operator: 'and',
6340
- left_column: '',
6341
- left_column_id: '',
6456
+ left_fieldAlias: '',
6457
+ left_fieldUuid: '',
6458
+ left_quotes: '',
6342
6459
  left_string: '',
6343
6460
  left_isString: false,
6344
6461
  left_type: 'field',
6345
6462
  left_constant: '',
6346
- right_column: '',
6347
- right_column_id: '',
6463
+ right_fieldAlias: '',
6464
+ right_fieldUuid: '',
6465
+ right_quotes: '',
6348
6466
  right_string: '',
6349
6467
  right_isString: false,
6350
6468
  right_type: 'field',
@@ -6369,7 +6487,7 @@ const JoinData = props => {
6369
6487
  })
6370
6488
  })]
6371
6489
  }, i);
6372
- }), meta.table1.column_id && meta.table2.column_id && (meta.expressions?.length || 0) < 1 && jsx(Tooltip, {
6490
+ }), meta.table1.fieldUuid && meta.table2.fieldUuid && (meta.expressions?.length || 0) < 1 && jsx(Tooltip, {
6373
6491
  title: __('SqlQueryBuilder.add'),
6374
6492
  children: jsx(Button, {
6375
6493
  disabled: meta.readonly,
@@ -6382,14 +6500,16 @@ const JoinData = props => {
6382
6500
  let newMeta = store.metaList[groupIndex].list.slice();
6383
6501
  newMeta[index].expressions = [{
6384
6502
  operator: 'and',
6385
- left_column: '',
6386
- left_column_id: '',
6503
+ left_fieldAlias: '',
6504
+ left_fieldUuid: '',
6505
+ left_quotes: '',
6387
6506
  left_string: '',
6388
6507
  left_isString: false,
6389
6508
  left_type: 'field',
6390
6509
  left_constant: '',
6391
- right_column: '',
6392
- right_column_id: '',
6510
+ right_fieldAlias: '',
6511
+ right_fieldUuid: '',
6512
+ right_quotes: '',
6393
6513
  right_string: '',
6394
6514
  right_isString: false,
6395
6515
  right_constant: '',
@@ -6540,12 +6660,12 @@ const CaseEditor = props => {
6540
6660
  onOk,
6541
6661
  onCancel
6542
6662
  } = props;
6543
- const [popup, setPopup] = useState({
6544
- visible: false
6545
- }); // 弹框信息
6663
+ // const [popup, setPopup] = useState<PopupType>({ visible: false }); // 弹框信息
6546
6664
  const [caseList, setCaseList] = useState(value.formulaList || []);
6547
6665
  const [name, setName] = useState(value?.name || ''); // 表达式名字
6548
6666
  const [ind, setInd] = useState(-1);
6667
+ const ref = useRef(null);
6668
+ const store = useStore$1();
6549
6669
  const filterCase = useMemo(() => {
6550
6670
  const hasCase = caseList.some(item => item.type === OptionsTypeEnum.OTHER && item.operator === 'case');
6551
6671
  if (hasCase) {
@@ -6557,24 +6677,22 @@ const CaseEditor = props => {
6557
6677
  const usable = useMemo(() => {
6558
6678
  return Array.from(caseList).length > 0 && name;
6559
6679
  }, [caseList, name]);
6560
- const popupContent = useMemo(() => {
6561
- let {
6562
- visible,
6563
- content
6564
- } = popup;
6565
- if (!visible) return null;
6566
- return content;
6567
- }, [popup]);
6680
+ // const popupContent = useMemo(() => {
6681
+ // let { visible, content } = popup;
6682
+ // if (!visible) return null;
6683
+ // return content;
6684
+ // }, [popup]);
6568
6685
  function closePopup() {
6569
- setPopup({
6686
+ store.setPopup({
6570
6687
  visible: false
6571
6688
  });
6572
6689
  }
6573
6690
  // 字段
6574
6691
  function handleField(e, i, val) {
6575
- setPopup({
6692
+ store.setPopup({
6576
6693
  visible: true,
6577
6694
  node: e.currentTarget,
6695
+ container: ref.current,
6578
6696
  content: jsx(SelectJoinColumn, {
6579
6697
  data: data,
6580
6698
  value: val,
@@ -6604,11 +6722,13 @@ const CaseEditor = props => {
6604
6722
  };
6605
6723
  // 表达式
6606
6724
  function handleExpression(e, i, val) {
6607
- setPopup({
6725
+ store.setPopup({
6608
6726
  visible: true,
6609
6727
  node: e.currentTarget,
6728
+ container: ref.current,
6610
6729
  content: jsx(SelectFilter, {
6611
6730
  isCustom: true,
6731
+ container: ref.current,
6612
6732
  data: data,
6613
6733
  value: val,
6614
6734
  onChange: data => {
@@ -6661,8 +6781,7 @@ const CaseEditor = props => {
6661
6781
  const _onOk = () => {
6662
6782
  typeof onOk === 'function' && onOk?.({
6663
6783
  name,
6664
- formulaList: caseList,
6665
- formula: ''
6784
+ formulaList: caseList
6666
6785
  });
6667
6786
  };
6668
6787
  // 分段
@@ -6810,6 +6929,7 @@ const CaseEditor = props => {
6810
6929
  };
6811
6930
  return jsxs("div", {
6812
6931
  className: 'custom-box',
6932
+ ref: ref,
6813
6933
  children: [jsx(VisualBox$1, {
6814
6934
  children: jsx("div", {
6815
6935
  className: `Sqb-item Sqb-case-editor mb-2 mt-2`,
@@ -6947,13 +7067,6 @@ const CaseEditor = props => {
6947
7067
  })]
6948
7068
  })
6949
7069
  })
6950
- }), jsx(Popup, {
6951
- visible: popup.visible,
6952
- closable: true,
6953
- node: popup.node,
6954
- innerSpacing: popup.innerSpacing,
6955
- hideVisible: closePopup,
6956
- children: popupContent
6957
7070
  }), jsx("div", {
6958
7071
  className: `btns p-4`,
6959
7072
  children: jsxs("div", {
@@ -7085,7 +7198,7 @@ const CustomColumn = props => {
7085
7198
  }
7086
7199
  return data;
7087
7200
  }
7088
- // 子查询弹窗
7201
+ // 自定义弹窗
7089
7202
  const showSubQuery = (e, i) => {
7090
7203
  let newMeta = store.metaList[groupIndex].list.slice();
7091
7204
  const _value = newMeta[index].customColumn[i] || [];
@@ -7353,7 +7466,7 @@ const Filter = props => {
7353
7466
  let newMeta = store.metaList[groupIndex].list.slice();
7354
7467
  let val = filter[i];
7355
7468
  if (val.type === Filter_TypeEnum.NOT_EXISTS) {
7356
- showSubQuery(i, '');
7469
+ showNotExists(i, '');
7357
7470
  return;
7358
7471
  }
7359
7472
  let data = getColumns();
@@ -7452,10 +7565,10 @@ const Filter = props => {
7452
7565
  newMeta[index].filter = [..._filter];
7453
7566
  setInd(-1);
7454
7567
  };
7455
- // 子查询弹窗
7456
- const showSubQuery = (i, position) => {
7568
+ // NotExists 窗口
7569
+ const showNotExists = (i, position) => {
7457
7570
  const {
7458
- subToolbar,
7571
+ notExistsToolbar,
7459
7572
  toolbar,
7460
7573
  ...other
7461
7574
  } = store.preProps;
@@ -7463,7 +7576,7 @@ const Filter = props => {
7463
7576
  let index = findIndex(store.metaList[groupIndex].list, meta);
7464
7577
  let _value = position ? [] : newMeta[index].filter[i]?.subquery || [];
7465
7578
  let oldList = position ? [] : cloneDeep(newMeta[index].filter[i]?.subquery || []);
7466
- let _toolbar = subToolbar || toolbar;
7579
+ let _toolbar = notExistsToolbar || toolbar;
7467
7580
  _toolbar = _toolbar.filter(v => v !== 'group'); // 子查询不需要分组
7468
7581
  let zIndex = store.popupContainer.current ? getMaxZIndexInParents(store.popupContainer.current) : null;
7469
7582
  let o = Modal2.openModal({
@@ -7562,7 +7675,7 @@ const Filter = props => {
7562
7675
  if (type === Filter_TypeEnum.EXPRESSION) {
7563
7676
  handleAdd(_e);
7564
7677
  } else if (type === Filter_TypeEnum.NOT_EXISTS) {
7565
- showSubQuery(_index, _type);
7678
+ showNotExists(_index, _type);
7566
7679
  }
7567
7680
  }
7568
7681
  })
@@ -7839,8 +7952,8 @@ const GroupBy = props => {
7839
7952
  quotes: '',
7840
7953
  datasourceId: '',
7841
7954
  datasourceName: '',
7842
- column: '',
7843
- column_id: '',
7955
+ // column: '',
7956
+ // column_id: '',
7844
7957
  summarizeType: MetaSummarize_Enum.BY
7845
7958
  };
7846
7959
  store.setPopup({
@@ -8101,8 +8214,8 @@ const SelectIndex = props => {
8101
8214
  quotes: '',
8102
8215
  datasourceId: '',
8103
8216
  datasourceName: '',
8104
- column: '',
8105
- column_id: '',
8217
+ // column: '',
8218
+ // column_id: '',
8106
8219
  summarizeType: MetaSummarize_Enum.GROUP
8107
8220
  };
8108
8221
  store.setPopup({
@@ -8746,7 +8859,7 @@ const Metabase = props => {
8746
8859
  onClick: onSave,
8747
8860
  children: btnText || __('SqlQueryBuilder.visualize')
8748
8861
  }) : null, store.popupContainer.current && jsx(Popup, {
8749
- container: store.popupContainer.current,
8862
+ container: store.popupData.container || store.popupContainer.current,
8750
8863
  visible: store.popupData.visible,
8751
8864
  node: store.popupData.node,
8752
8865
  closable: store.popupClosable,
@@ -8758,7 +8871,7 @@ const Metabase = props => {
8758
8871
  },
8759
8872
  children: popupContent
8760
8873
  }), store.popupContainer.current && jsx(Popup, {
8761
- container: store.popupContainer.current,
8874
+ container: store.popupData2.container || store.popupContainer.current,
8762
8875
  visible: store.popupData2.visible,
8763
8876
  node: store.popupData2.node,
8764
8877
  closable: store.popupClosable2,