Преглед изворни кода

fix: bug#9659、9538、8337

xieyonghong пре 3 година
родитељ
комит
2cb5a2f1f9

+ 7 - 7
src/components/FRuleEditor/Operator/index.less

@@ -22,13 +22,13 @@
       justify-content: space-between;
       width: 220px;
 
-      .add {
-        display: none;
-      }
-
-      &:hover .add {
-        display: block;
-      }
+      //.add {
+      //  display: none;
+      //}
+      //
+      //&:hover .add {
+      //  display: block;
+      //}
 
       .parent {
         display: none;

+ 0 - 2
src/components/FRuleEditor/Operator/index.tsx

@@ -77,7 +77,6 @@ const Operator = (props: Props) => {
             <div className={node.children?.length > 0 ? styles.parent : styles.add}>
               {node.type === 'property' ? (
                 <Popover
-                  open={visible}
                   placement="right"
                   title="请选择使用值"
                   onOpenChange={setVisible}
@@ -110,7 +109,6 @@ const Operator = (props: Props) => {
                       </Tooltip>
                     </Space>
                   }
-                  trigger="click"
                 >
                   <a onClick={() => setVisible(true)}>添加</a>
                 </Popover>

+ 5 - 4
src/pages/rule-engine/Scene/Save/components/Buttons/ParamsDropdown.tsx

@@ -30,7 +30,7 @@ export interface ParamsDropdownProps {
 interface MenusProps {
   value: any;
   options?: any[];
-  onChange: (value: any, lb: any) => void;
+  onChange: (value: any, lb: any, node) => void;
 }
 
 const Menus = (props: MenusProps) => {
@@ -50,10 +50,11 @@ const Menus = (props: MenusProps) => {
         selectedKeys={value ? [value] : undefined}
         items={props.options}
         onClick={({ key, item }: { key: any; item: any }) => {
+          console.log(item.props);
           const _item = props.options?.find((a) => a.value === item.props.value);
           setValue(key);
           if (_item) {
-            props.onChange(_item.value, _item.label);
+            props.onChange(_item.value, _item.label, item.props);
           }
         }}
       />
@@ -111,8 +112,8 @@ export default (props: ParamsDropdownProps) => {
             <Menus
               value={_value}
               options={props.metricsOptions}
-              onChange={(v, l) => {
-                onValueChange(v, l);
+              onChange={(v, l, node) => {
+                onValueChange(v, l, node);
                 setOpen(false);
               }}
             />

+ 18 - 9
src/pages/rule-engine/Scene/Save/terms/paramsItem.tsx

@@ -57,7 +57,6 @@ const handleOptions = (options: any[]): any[] => {
 };
 
 const DoubleFilter = ['nbtw', 'btw', 'in', 'nin'];
-
 export const handleOptionsLabel = (data: any, type?: string) => {
   if (data && isArray(data)) {
     try {
@@ -277,7 +276,7 @@ const ParamsItem = observer((props: ParamsItemProps) => {
             const _value = {
               ...value,
             };
-            if (value && DoubleFilter.includes(v!)) {
+            if (value && DoubleFilter.includes(v!) && !metricsOptions.length) {
               _value.value = [undefined, undefined];
             } else {
               _value.value = undefined;
@@ -294,7 +293,7 @@ const ParamsItem = observer((props: ParamsItemProps) => {
             });
           }}
         />
-        {DoubleFilter.includes(termType) ? (
+        {DoubleFilter.includes(termType) && !metricsOptions.length ? (
           <>
             <ParamsDropdown
               options={valueOptions}
@@ -370,15 +369,25 @@ const ParamsItem = observer((props: ParamsItemProps) => {
             placeholder="参数值"
             valueType={valueType}
             value={value}
-            onChange={(v, lb) => {
-              setValue({
-                ...v,
-              });
+            onChange={(v, lb, item) => {
+              const _value = { ...v };
+              if (item) {
+                _value.metric = item.id;
+              }
+              setValue(_value);
               ValueRef.current.value = v;
-              labelCache.current[2] = { 0: lb };
+              if (!!metricsOptions.length) {
+                if (DoubleFilter.includes(termType)) {
+                  labelCache.current[2] = { 0: v?.value[0], 1: v?.value[1] };
+                } else {
+                  labelCache.current[2] = { 0: lb };
+                }
+              } else {
+                labelCache.current[2] = { 0: lb };
+              }
               labelCache.current[3] = props.data.type;
               props.onLabelChange?.([...labelCache.current]);
-              valueEventChange(v);
+              valueEventChange(_value);
             }}
             icon={<AIcon type={'icon-canshu'} />}
           />