@gingkoo/pandora-metabase 1.0.92 → 1.0.94

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/index.js CHANGED
@@ -27,6 +27,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
27
27
  * 2、关联如果动了表或者删除了 下面的关联都删除
28
28
  * 3、关联如果动了表或者删除了 下面对应排序用到的对应的字段也删除 todo. 未完成 因为有可能关联里面选一样的表 还不知道怎么搞
29
29
  */
30
+ var EMPTY_ARRAY = [];
30
31
  var SqlVisionBuilder = _react["default"].forwardRef(function (props, ref) {
31
32
  var _props$loading = props.loading,
32
33
  loading = _props$loading === void 0 ? false : _props$loading,
@@ -36,6 +37,7 @@ var SqlVisionBuilder = _react["default"].forwardRef(function (props, ref) {
36
37
  getColumns = props.getColumns,
37
38
  onChange = props.onChange,
38
39
  getModuleDiffCode = props.getModuleDiffCode,
40
+ getExistsError = props.getExistsError,
39
41
  _props$tableNameTpl = props.tableNameTpl,
40
42
  tableNameTpl = _props$tableNameTpl === void 0 ? '${name}' : _props$tableNameTpl,
41
43
  _props$fieldNameTpl = props.fieldNameTpl,
@@ -43,11 +45,11 @@ var SqlVisionBuilder = _react["default"].forwardRef(function (props, ref) {
43
45
  _props$toolbar = props.toolbar,
44
46
  toolbar = _props$toolbar === void 0 ? ['filter', 'summarize', 'joinData', 'customColumn', 'sort', 'rowLimit'] : _props$toolbar,
45
47
  _props$value = props.value,
46
- value = _props$value === void 0 ? [] : _props$value,
48
+ value = _props$value === void 0 ? EMPTY_ARRAY : _props$value,
47
49
  _props$sourceList = props.sourceList,
48
- sourceList = _props$sourceList === void 0 ? [] : _props$sourceList,
50
+ sourceList = _props$sourceList === void 0 ? EMPTY_ARRAY : _props$sourceList,
49
51
  _props$exitSourceList = props.exitSourceList,
50
- exitSourceList = _props$exitSourceList === void 0 ? [] : _props$exitSourceList,
52
+ exitSourceList = _props$exitSourceList === void 0 ? EMPTY_ARRAY : _props$exitSourceList,
51
53
  _props$showSubquery = props.showSubquery,
52
54
  showSubquery = _props$showSubquery === void 0 ? true : _props$showSubquery,
53
55
  _props$subShowSubquer = props.subShowSubquery,
@@ -80,13 +82,14 @@ var SqlVisionBuilder = _react["default"].forwardRef(function (props, ref) {
80
82
  _props$moduleCopy = props.moduleCopy,
81
83
  moduleCopy = _props$moduleCopy === void 0 ? false : _props$moduleCopy,
82
84
  _props$operatorList = props.operatorList,
83
- operatorList = _props$operatorList === void 0 ? [] : _props$operatorList;
85
+ operatorList = _props$operatorList === void 0 ? EMPTY_ARRAY : _props$operatorList;
84
86
  var store = (0, _useState["default"])();
85
87
  (0, _react.useEffect)(function () {
86
88
  getTables && store.setFetchDatasetFn(getTables);
87
89
  getColumns && store.setFetchColumnsFn(getColumns);
88
90
  onChange && store.setFetchChangeFn(onChange);
89
91
  getModuleDiffCode && store.setFetchDiffFn(getModuleDiffCode);
92
+ getExistsError && store.setExistsErrorFn(getExistsError);
90
93
  }, []);
91
94
  (0, _react.useEffect)(function () {
92
95
  store.setProps(props);
@@ -122,7 +125,7 @@ var SqlVisionBuilder = _react["default"].forwardRef(function (props, ref) {
122
125
  store.setModuleDiff(moduleDiff);
123
126
  store.setIsSubquery(isSubquery);
124
127
  store.setModuleCopy(moduleCopy);
125
- store.setOperatorList(operatorList);
128
+ store.setOperatorList(operatorList || []);
126
129
  }, [showFields, fieldNameTpl, tableNameTpl, toolbar, showSubquery, subShowSubquery, constantList, formulaTemplates, ignoreGroupByType, filterCustomType, isExit, tableEnableAlias, fieldEnableAlias, groupByEnableAlias, isSelectFields, tableFlat, copyType, metabaseCopy, moduleDiff, isSubquery, moduleCopy, operatorList]);
127
130
  _react["default"].useImperativeHandle(ref, function () {
128
131
  return {
@@ -59,6 +59,7 @@ export interface MetabaseProps {
59
59
  oldCode: string;
60
60
  newCode: string;
61
61
  }>;
62
+ getExistsError?: () => Promise<any[]>;
62
63
  operatorList?: any[];
63
64
  }
64
65
  export interface OptionItem {
@@ -30,6 +30,14 @@ export declare const patchData: (metas: MetaListType[]) => MetaListType[];
30
30
  export declare function reassembleByUnion(target?: any[]): any[];
31
31
  export declare const buildSqlQuery: (data: MetaListType[] | undefined, type: string) => string;
32
32
  export declare const isError: (item: AtomsItem | AtomsItem[], data: DataType[]) => boolean;
33
+ /**
34
+ * 在嵌套结构 root 中查找是否存在一个对象,使得 target 是该对象的子集
35
+ * @param root 可能包含任意层数组/对象的根数据
36
+ * @param target 目标对象(可能只包含部分字段)
37
+ * @returns 是否存在
38
+ */
39
+ export declare function containsSubset(root: unknown, target: Record<string, unknown>): boolean;
40
+ export declare const isExistsError: (meta: any[], errorList: any[]) => boolean;
33
41
  export declare const changeCopyField: (items: AtomsItem[], data: any[]) => AtomsItem[];
34
42
  export declare const changeExistsCopyField: (list: MetaListType[], data: any[]) => MetaListType[];
35
43
  export declare const metaIsCheck: (data: any[], item: any) => boolean;
package/lib/cjs/utils.js CHANGED
@@ -4,11 +4,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.isError = exports.isCanPaste = exports.getSubColumns = exports.getMetaTabels = exports.getHelper = exports.getColumnsTables = exports.findMetaKey = exports.findIndex = exports.changeTableAlias = exports.changeFieldAlias = exports.changeExistsCopyField = exports.changeCopyField = exports.buildSqlQuery = void 0;
7
+ exports.changeTableAlias = exports.changeFieldAlias = exports.changeExistsCopyField = exports.changeCopyField = exports.buildSqlQuery = void 0;
8
+ exports.containsSubset = containsSubset;
9
+ exports.isExistsError = exports.isError = exports.isCanPaste = exports.getSubColumns = exports.getMetaTabels = exports.getHelper = exports.getColumnsTables = exports.findMetaKey = exports.findIndex = void 0;
8
10
  exports.isValidSQLAlias = isValidSQLAlias;
9
11
  exports.patchData = exports.metaIsCheck = void 0;
10
12
  exports.reassembleByUnion = reassembleByUnion;
11
13
  exports.splitByUnion = splitByUnion;
14
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/typeof"));
12
15
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
13
16
  var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/createForOfIteratorHelper"));
14
17
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
@@ -734,7 +737,8 @@ var _isError = exports.isError = function isError(item, data) {
734
737
  tableId = _item$tableId === void 0 ? '' : _item$tableId,
735
738
  _item$tableAlias = item.tableAlias,
736
739
  tableAlias = _item$tableAlias === void 0 ? '' : _item$tableAlias,
737
- fieldName = item.fieldName;
740
+ fieldName = item.fieldName,
741
+ fieldId = item.fieldId;
738
742
  var _datasourceId = datasourceId || 'source'; // 默认为source
739
743
  if (tableId === 'source') {
740
744
  _datasourceId = 'source';
@@ -750,13 +754,13 @@ var _isError = exports.isError = function isError(item, data) {
750
754
  } else {
751
755
  var _tables$_datasourceId2;
752
756
  return tables === null || tables === void 0 || (_tables$_datasourceId2 = tables[_datasourceId]) === null || _tables$_datasourceId2 === void 0 || (_tables$_datasourceId2 = _tables$_datasourceId2[tableId]) === null || _tables$_datasourceId2 === void 0 ? void 0 : _tables$_datasourceId2.every(function (field) {
753
- return field.name !== fieldName;
757
+ return field.name !== fieldName || field.id !== fieldId;
754
758
  });
755
759
  }
756
760
  } else {
757
761
  var _tables$_datasourceId3;
758
762
  var hasField = (tables === null || tables === void 0 || (_tables$_datasourceId3 = tables[_datasourceId]) === null || _tables$_datasourceId3 === void 0 || (_tables$_datasourceId3 = _tables$_datasourceId3[tableId + tableAlias]) === null || _tables$_datasourceId3 === void 0 || (_tables$_datasourceId3 = _tables$_datasourceId3.filter(function (v) {
759
- return v.name === fieldName;
763
+ return v.name === fieldName && v.id === fieldId;
760
764
  })) === null || _tables$_datasourceId3 === void 0 ? void 0 : _tables$_datasourceId3.length) > 0;
761
765
  return !hasField; // 注意:返回 true 表示“有错误”
762
766
  }
@@ -777,14 +781,101 @@ var _isError = exports.isError = function isError(item, data) {
777
781
  }
778
782
  return false; // 其他类型默认无错误
779
783
  };
784
+ /**
785
+ * 深度判断 sub 是否是 obj 的子集(递归比较所有可枚举自有属性)
786
+ * @param sub 可能包含部分属性的对象
787
+ * @param obj 待比较的对象
788
+ * @param visited 用于处理循环引用的 WeakSet
789
+ */
790
+ function isSubset(sub, obj) {
791
+ var visited = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new WeakSet();
792
+ // 基本类型或引用相同
793
+ if (sub === obj) return true;
794
+ // 如果任一不是对象/数组,或者为 null,则不相等(sub 为基本类型时,上面已经比较过,这里只处理对象不等的情况)
795
+ if ((0, _typeof2["default"])(sub) !== 'object' || sub === null || (0, _typeof2["default"])(obj) !== 'object' || obj === null) {
796
+ return false;
797
+ }
798
+ // 避免循环引用
799
+ if (visited.has(sub) || visited.has(obj)) return false;
800
+ visited.add(sub);
801
+ visited.add(obj);
802
+ // 处理数组
803
+ if (Array.isArray(sub)) {
804
+ if (!Array.isArray(obj) || sub.length !== obj.length) return false;
805
+ for (var i = 0; i < sub.length; i++) {
806
+ if (!isSubset(sub[i], obj[i], visited)) return false;
807
+ }
808
+ return true;
809
+ }
810
+ // 普通对象:遍历 sub 的每个键
811
+ for (var key in sub) {
812
+ if (Object.prototype.hasOwnProperty.call(sub, key)) {
813
+ // obj 必须包含该键
814
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) return false;
815
+ // 递归比较值
816
+ if (!isSubset(sub[key], obj[key], visited)) return false;
817
+ }
818
+ }
819
+ return true;
820
+ }
821
+ /**
822
+ * 在嵌套结构 root 中查找是否存在一个对象,使得 target 是该对象的子集
823
+ * @param root 可能包含任意层数组/对象的根数据
824
+ * @param target 目标对象(可能只包含部分字段)
825
+ * @returns 是否存在
826
+ */
827
+ function containsSubset(root, target) {
828
+ var visited = new WeakSet();
829
+ function search(current) {
830
+ if (current && (0, _typeof2["default"])(current) === 'object') {
831
+ // 避免循环引用
832
+ if (visited.has(current)) return false;
833
+ visited.add(current);
834
+ // 如果是普通对象(非数组),先检查是否包含 target 子集
835
+ if (!Array.isArray(current) && isSubset(target, current)) {
836
+ return true;
837
+ }
838
+ // 继续深入遍历子元素
839
+ if (Array.isArray(current)) {
840
+ var _iterator2 = (0, _createForOfIteratorHelper2["default"])(current),
841
+ _step2;
842
+ try {
843
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
844
+ var item = _step2.value;
845
+ if (search(item)) return true;
846
+ }
847
+ } catch (err) {
848
+ _iterator2.e(err);
849
+ } finally {
850
+ _iterator2.f();
851
+ }
852
+ } else {
853
+ for (var key in current) {
854
+ if (Object.prototype.hasOwnProperty.call(current, key)) {
855
+ if (search(current[key])) return true;
856
+ }
857
+ }
858
+ }
859
+ }
860
+ return false;
861
+ }
862
+ return search(root);
863
+ }
864
+ // 判断当前meta中是否含有errorList
865
+ var isExistsError = exports.isExistsError = function isExistsError(meta, errorList) {
866
+ var _meta = (0, _cloneDeep3["default"])(meta);
867
+ return errorList.some(function (error) {
868
+ return containsSubset(_meta, error);
869
+ });
870
+ };
780
871
  // 设置新字段信息
781
872
  function setNewField(field, data) {
782
873
  console.log('🚀 ~ setNewField ~ field:', field);
783
- var _iterator2 = (0, _createForOfIteratorHelper2["default"])(data),
784
- _step2;
874
+ var _iterator3 = (0, _createForOfIteratorHelper2["default"])(data),
875
+ _step3;
785
876
  try {
786
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
787
- var table = _step2.value;
877
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
878
+ var table = _step3.value;
788
879
  // 第一步:判断表名是否一致
789
880
  if (table.name !== field.tableName) {
790
881
  continue;
@@ -812,9 +903,9 @@ function setNewField(field, data) {
812
903
  break;
813
904
  }
814
905
  } catch (err) {
815
- _iterator2.e(err);
906
+ _iterator3.e(err);
816
907
  } finally {
817
- _iterator2.f();
908
+ _iterator3.f();
818
909
  }
819
910
  console.log('🚀 ~ setNewField ~ field:', field);
820
911
  return field;
@@ -9,8 +9,9 @@ import './index.less';
9
9
  import FormulaList from '../formula-list';
10
10
  import { AddIcon, CloseIcon } from '../../icons';
11
11
  import { isOk } from '../formula-list/utils';
12
+ import ItemName from '../../modules/components/item-name';
12
13
  import { __ } from '../../../locale';
13
- import { getTemArgs, getObjTem, getParamActions, getQuotes } from './utils';
14
+ import { getTemArgs, getObjTem, getParamActions, getQuotes, formulaName, formulaIsError } from './utils';
14
15
  import Styled from 'styled-components';
15
16
  // import { OptionsTypeEnum, customTypes, otherList, operatorList, functionList } from './enum';
16
17
  import { AtomsTypeEnum, FormulaTypeEnum } from '../../../store/types';
@@ -126,36 +127,39 @@ var CaseEditor = React.forwardRef(function (props, ref) {
126
127
  children: "\u8BF7\u5148\u9009\u62E9\u516C\u5F0F\uFF0C\u5207\u6362\u516C\u5F0F\u65F6\u4F1A\u91CD\u7F6E\u53C2\u6570"
127
128
  }), _jsx("div", {
128
129
  className: 'Sqb-NotebookCell formula-name',
129
- children: _jsx(Select, {
130
- triggerProps: {
131
- clickToClose: true
132
- },
133
- value: fun.id || fun.name,
134
- triggerElement: function triggerElement(value) {
135
- var _formulaList$fun$id;
136
- return _jsx("div", {
137
- className: cx("Sqb-TableName Sqb-TableName-OPERATOR", {
138
- notSelected: !fun.name
139
- }),
140
- children: fun.id ? (_formulaList$fun$id = formulaList[fun.id]) === null || _formulaList$fun$id === void 0 ? void 0 : _formulaList$fun$id.name : __('customColumn.selectFormula')
141
- });
142
- },
143
- onChange: function onChange(val) {
144
- handleFunName(val);
145
- },
146
- children: (_store$formulaTemplat = store.formulaTemplates) === null || _store$formulaTemplat === void 0 ? void 0 : _store$formulaTemplat.map(function (options, index) {
147
- return _jsx(Select.OptGroup, {
148
- label: options.name,
149
- children: Array.from(options.children || []).map(function (option, ind) {
150
- return _jsx(Select.Option, {
151
- value: option.id,
152
- children: option.name
153
- }, option.id || String(option.name + ind));
154
- })
155
- }, index);
156
- // <Select.Option key={index} value={option.name}>
157
- // {option.name}
158
- // </Select.Option>
130
+ children: _jsx(ItemName, {
131
+ isError: formulaIsError(fun, formulaList),
132
+ message: '公式丢失',
133
+ children: _jsx(Select, {
134
+ triggerProps: {
135
+ clickToClose: true
136
+ },
137
+ value: fun.id || fun.name,
138
+ triggerElement: function triggerElement(value) {
139
+ return _jsx("div", {
140
+ className: cx("Sqb-TableName Sqb-TableName-OPERATOR", {
141
+ notSelected: !fun.name
142
+ }),
143
+ children: formulaName(fun, formulaList) || __('customColumn.selectFormula')
144
+ });
145
+ },
146
+ onChange: function onChange(val) {
147
+ handleFunName(val);
148
+ },
149
+ children: (_store$formulaTemplat = store.formulaTemplates) === null || _store$formulaTemplat === void 0 ? void 0 : _store$formulaTemplat.map(function (options, index) {
150
+ return _jsx(Select.OptGroup, {
151
+ label: options.name,
152
+ children: Array.from(options.children || []).map(function (option, ind) {
153
+ return _jsx(Select.Option, {
154
+ value: option.id,
155
+ children: option.name
156
+ }, option.id || String(option.name + ind));
157
+ })
158
+ }, index);
159
+ // <Select.Option key={index} value={option.name}>
160
+ // {option.name}
161
+ // </Select.Option>
162
+ })
159
163
  })
160
164
  })
161
165
  }), fun.name && _jsxs("div", {
@@ -5,4 +5,6 @@ export declare function getParamActions(params: AtomsItem[], arity?: Arity): {
5
5
  canAdd: boolean;
6
6
  canDel: boolean;
7
7
  };
8
+ export declare const formulaName: (fun: any, formulaList: any) => any;
8
9
  export declare const getQuotes: (fun: any, _args: AtomsItem[], formulaList: any) => string;
10
+ export declare const formulaIsError: (fun: any, formulaList: any) => boolean;
@@ -56,8 +56,12 @@ export function getParamActions(params, arity) {
56
56
  canDel: len > effectiveMin // 大于 min 才能删
57
57
  };
58
58
  }
59
+ // 获取公式名称 如果找不到 用传入的name
60
+ export var formulaName = function formulaName(fun, formulaList) {
61
+ var obj = formulaList[fun.id] || formulaList[fun.name];
62
+ return (obj === null || obj === void 0 ? void 0 : obj.name) || fun.name;
63
+ };
59
64
  export var getQuotes = function getQuotes(fun, _args, formulaList) {
60
- var _formulaList$fun$id;
61
65
  var quotes = _args === null || _args === void 0 ? void 0 : _args.map(function (v) {
62
66
  var quotes = v.list.map(function (vv, i) {
63
67
  if (vv !== null && vv !== void 0 && vv.quotes) {
@@ -70,5 +74,10 @@ export var getQuotes = function getQuotes(fun, _args, formulaList) {
70
74
  }).join(' ');
71
75
  return quotes;
72
76
  }).join(' , ');
73
- return ((_formulaList$fun$id = formulaList[fun.id]) === null || _formulaList$fun$id === void 0 ? void 0 : _formulaList$fun$id.name) + ' ( ' + quotes + ' ) ';
77
+ // let obj = formulaList[fun.id] || formulaList[fun.name];
78
+ return formulaName(fun, formulaList) + ' ( ' + quotes + ' ) ';
79
+ };
80
+ export var formulaIsError = function formulaIsError(fun, formulaList) {
81
+ var obj = fun.id ? formulaList[fun.id] : formulaList[fun.name];
82
+ return !(obj !== null && obj !== void 0 && obj.name);
74
83
  };
@@ -15,12 +15,12 @@ import cx from 'classnames';
15
15
  import Metabase from '../../../index';
16
16
  import { __ } from '../../../locale';
17
17
  import isEqual from 'lodash/isEqual';
18
- import { getObjTem, getQuotes } from '../formula/utils';
18
+ import { getObjTem, getQuotes, formulaIsError } from '../formula/utils';
19
19
  import { AtomsTypeEnum, FormulaTypeEnum } from '../../../store/types';
20
20
  import { ColumnsPopupThemeEnum } from '../../../store/enum';
21
21
  import { Select, Input, Modal2, Modal, InputNumber, Radio, Space, Button, Checkbox, Tooltip } from '@gingkoo/pandora';
22
22
  import cloneDeep from 'lodash/cloneDeep';
23
- import { buildSqlQuery, isError, changeCopyField } from '../../../utils';
23
+ import { buildSqlQuery, isError, changeCopyField, isExistsError } from '../../../utils';
24
24
  import Formula from '../formula';
25
25
  import { AddIcon, CloseIcon } from '../../icons';
26
26
  import { Expression, SelectColumnMultiple } from '../../dialog';
@@ -59,8 +59,6 @@ var FormulaList = forwardRef(function (props, ref) {
59
59
  onChange = props.onChange,
60
60
  _props$customTypes = props.customTypes,
61
61
  _customTypes = _props$customTypes === void 0 ? customTypes : _props$customTypes,
62
- _props$operatorList = props.operatorList,
63
- _operatorList = _props$operatorList === void 0 ? store.operatorList : _props$operatorList,
64
62
  _props$isCustom = props.isCustom,
65
63
  isCustom = _props$isCustom === void 0 ? false : _props$isCustom,
66
64
  _props$showPreview = props.showPreview,
@@ -615,20 +613,23 @@ var FormulaList = forwardRef(function (props, ref) {
615
613
  var itemDom = function itemDom(v, index) {
616
614
  var type = v.type;
617
615
  if (v.type === AtomsTypeEnum.NOT_EXISTS || v.type === AtomsTypeEnum.EXISTS) {
618
- return _jsxs("div", {
619
- className: "Sqb-TableName purple-name",
620
- onClick: function onClick(e) {
621
- return showNotExists(index);
622
- },
623
- children: [v.type, " ( * )", _jsx("span", {
624
- style: {
625
- fontSize: 0
626
- },
616
+ return _jsx(ItemName, {
617
+ isError: isExistsError(v.notExists, store.existsError),
618
+ children: _jsxs("div", {
619
+ className: "Sqb-TableName purple-name",
627
620
  onClick: function onClick(e) {
628
- return handleDel(e, index);
621
+ return showNotExists(index);
629
622
  },
630
- children: _jsx(CloseIcon, {})
631
- })]
623
+ children: [v.type, " ( * )", _jsx("span", {
624
+ style: {
625
+ fontSize: 0
626
+ },
627
+ onClick: function onClick(e) {
628
+ return handleDel(e, index);
629
+ },
630
+ children: _jsx(CloseIcon, {})
631
+ })]
632
+ }, index)
632
633
  }, index);
633
634
  } else if (v.type === AtomsTypeEnum.SUB_QUERY) {
634
635
  return _jsxs("div", {
@@ -738,7 +739,7 @@ var FormulaList = forwardRef(function (props, ref) {
738
739
  onChange: function onChange(val) {
739
740
  handleConstant(val, index);
740
741
  },
741
- children: _operatorList.map(function (option, index) {
742
+ children: operatorList.map(function (option, index) {
742
743
  return _jsx(Select.Option, {
743
744
  value: option,
744
745
  children: option
@@ -747,24 +748,35 @@ var FormulaList = forwardRef(function (props, ref) {
747
748
  });
748
749
  } else if (type === AtomsTypeEnum.CONSTANT) {
749
750
  //常量
750
- return _jsxs("div", {
751
- className: cx("Sqb-TableName", {
752
- notSelected: !v.val
753
- }),
754
- "v-index": index,
755
- "v-val": v.id || v.val,
756
- onClick: selectConstant,
757
- children: [v.val || v.id ? getConstantLabel(store.constantList, v.id || v.val) : __('SqlQueryBuilder.pickConstant'), _jsx("span", {
758
- style: {
759
- fontSize: 0
760
- },
761
- onClick: function onClick(e) {
762
- return handleDel(e, index);
763
- },
764
- children: _jsx(CloseIcon, {})
765
- })]
751
+ return _jsx(ItemName, {
752
+ isError: (v.id || v.val) && !getConstantLabel(store.constantList, v.id || v.val),
753
+ message: "\u5E38\u91CF\u4E22\u5931",
754
+ children: _jsxs("div", {
755
+ className: cx("Sqb-TableName", {
756
+ notSelected: !v.val
757
+ }),
758
+ "v-index": index,
759
+ "v-val": v.id || v.val,
760
+ onClick: selectConstant,
761
+ children: [getConstantLabel(store.constantList, v.id || v.val, v.val) || __('SqlQueryBuilder.pickConstant'), _jsx("span", {
762
+ style: {
763
+ fontSize: 0
764
+ },
765
+ onClick: function onClick(e) {
766
+ return handleDel(e, index);
767
+ },
768
+ children: _jsx(CloseIcon, {})
769
+ })]
770
+ })
766
771
  }, index);
767
772
  } else if (type === AtomsTypeEnum.EXPRESSION) {
773
+ if (~['早于', '晚于', '在'].indexOf(v.condition) && v.rhs.length > 1) {
774
+ var _caseList$index$quote;
775
+ var _caseList = caseList.slice();
776
+ _caseList[index].rhs = [_caseList[index].rhs[0]];
777
+ _caseList[index].quotes = (_caseList$index$quote = _caseList[index].quotes.split(' || ')) === null || _caseList$index$quote === void 0 ? void 0 : _caseList$index$quote[0];
778
+ setCaseList(_caseList);
779
+ }
768
780
  // 表达式
769
781
  return _jsx(ItemName, {
770
782
  isError: isError(v, data),
@@ -789,7 +801,8 @@ var FormulaList = forwardRef(function (props, ref) {
789
801
  } else if (type === AtomsTypeEnum.FORMULA) {
790
802
  // 公式
791
803
  return _jsx(ItemName, {
792
- isError: isError(v, data),
804
+ isError: isError(v, data) || formulaIsError(v, formulaList),
805
+ message: formulaIsError(v, formulaList) ? '公式丢失' : '',
793
806
  children: _jsxs("div", {
794
807
  className: cx("Sqb-TableName gray-name"),
795
808
  onClick: function onClick(e) {
@@ -26,4 +26,4 @@ export declare function validateExpressionIntegrity(list: AtomsItem[]): {
26
26
  isCase?: boolean;
27
27
  isOver?: boolean;
28
28
  };
29
- export declare const getConstantLabel: (list: any[], val: string) => any;
29
+ export declare const getConstantLabel: (list: any[], val: string, defaultVal?: string) => any;
@@ -460,10 +460,10 @@ export function validateExpressionIntegrity(list) {
460
460
  isError: false
461
461
  };
462
462
  }
463
- export var getConstantLabel = function getConstantLabel(list, val) {
463
+ export var getConstantLabel = function getConstantLabel(list, val, defaultVal) {
464
464
  var _list$filter;
465
465
  var _list = _toConsumableArray(list);
466
466
  return ((_list$filter = _list.filter(function (v) {
467
467
  return v.value === val;
468
- })) === null || _list$filter === void 0 || (_list$filter = _list$filter[0]) === null || _list$filter === void 0 ? void 0 : _list$filter.label) || '';
468
+ })) === null || _list$filter === void 0 || (_list$filter = _list$filter[0]) === null || _list$filter === void 0 ? void 0 : _list$filter.label) || defaultVal || '';
469
469
  };
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  interface HeaderProps {
3
3
  children: React.ReactNode;
4
4
  isError: boolean;
5
+ message?: string;
5
6
  }
6
7
  declare const ItemName: (props: HeaderProps) => import("react/jsx-runtime").JSX.Element;
7
8
  export default ItemName;
@@ -4,11 +4,12 @@ import { ExclamationCircleFill } from '@gingkoo/pandora-icons';
4
4
  import { __ } from '../../../locale';
5
5
  var ItemName = function ItemName(props) {
6
6
  var children = props.children,
7
- isError = props.isError;
7
+ isError = props.isError,
8
+ message = props.message;
8
9
  return _jsx(Badge, {
9
10
  offset: [-8, 0],
10
11
  count: isError ? _jsx(Tooltip, {
11
- title: __('metabase.verify'),
12
+ title: message || __('metabase.verify'),
12
13
  children: _jsx(Button, {
13
14
  className: 'isError',
14
15
  style: {