Browse Source

fix: bug#8845、9511

xieyonghong 3 năm trước cách đây
mục cha
commit
21ae0438c1

+ 12 - 4
src/components/Metadata/ArrayParam/index.tsx

@@ -8,7 +8,11 @@ import JsonParam from '@/components/Metadata/JsonParam';
 import EnumParam from '@/components/Metadata/EnumParam';
 import BooleanEnum from '@/components/Metadata/BooleanParam';
 
-const ArrayParam = () => {
+interface Props {
+  isFunction?: boolean;
+}
+
+const ArrayParam = (props: Props) => {
   const SchemaField = createSchemaField({
     components: {
       FormItem,
@@ -82,7 +86,7 @@ const ArrayParam = () => {
               dependencies: ['.type'],
               fulfill: {
                 state: {
-                  visible: "{{['float','double'].includes($deps[0])}}",
+                  visible: !props.isFunction && "{{['float','double'].includes($deps[0])}}",
                 },
               },
             },
@@ -104,7 +108,8 @@ const ArrayParam = () => {
               dependencies: ['.type'],
               fulfill: {
                 state: {
-                  visible: "{{['int','float','long','double'].includes($deps[0])}}",
+                  visible:
+                    !props.isFunction && "{{['int','float','long','double'].includes($deps[0])}}",
                 },
               },
             },
@@ -161,7 +166,7 @@ const ArrayParam = () => {
                   dependencies: ['..type'],
                   fulfill: {
                     state: {
-                      visible: "{{['string','password'].includes($deps[0])}}",
+                      visible: !props.isFunction && "{{['string','password'].includes($deps[0])}}",
                     },
                   },
                 },
@@ -217,6 +222,9 @@ const ArrayParam = () => {
             type: 'void',
             'x-decorator': 'FormItem',
             'x-component': 'JsonParam',
+            'x-component-props': {
+              isFunction: props.isFunction,
+            },
             'x-reactions': {
               dependencies: ['.type'],
               fulfill: {

+ 3 - 0
src/components/Metadata/JsonParam/index.tsx

@@ -201,6 +201,9 @@ const JsonParam = observer((props: Props) => {
                       }),
                       'x-decorator': 'FormItem',
                       'x-component': 'ArrayParam',
+                      'x-component-props': {
+                        isFunction: props.isFunction,
+                      },
                       'x-reactions': {
                         dependencies: ['..valueType.type'],
                         fulfill: {

+ 27 - 0
src/components/SearchComponent/index.less

@@ -26,6 +26,19 @@
       }
     }
   }
+  .small-action {
+    gap: 48px;
+    justify-content: flex-start;
+    width: 100%;
+
+    .more {
+      position: relative;
+    }
+
+    .advance {
+      right: 0;
+    }
+  }
 
   .form {
     :global {
@@ -51,6 +64,20 @@
     }
   }
 
+  .small-size {
+    flex-wrap: wrap;
+    :global {
+      .ant-formily-grid-layout {
+        grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
+        width: 100%;
+      }
+      .ant-formily-item {
+        width: 100%;
+        margin-bottom: 24px;
+      }
+    }
+  }
+
   .history {
     width: 176px;
   }

+ 18 - 2
src/components/SearchComponent/index.tsx

@@ -36,6 +36,7 @@ import classnames from 'classnames';
 import { onlyMessage, randomString } from '@/utils/util';
 import { useHistory, useLocation } from 'umi';
 import { Empty } from '@/components';
+import { useSize } from 'ahooks';
 
 const ui2Server = (source: SearchTermsUI): SearchTermsServer => [
   { terms: source.terms1 },
@@ -195,6 +196,8 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
   const [history, setHistory] = useState([]);
   const [logVisible, setLogVisible] = useState<boolean>(false);
   const uiParamRef = useRef(initParam);
+  const formDivRef = useRef(null);
+  const formDivSize = useSize(formDivRef);
 
   const form = useMemo(
     () =>
@@ -840,9 +843,22 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
         wrapperCol={18}
         onAutoSubmit={() => (SearchBtn.advance ? handleSearch : handleSearch(false))}
       >
-        <div className={expand && styles.simple}>
+        <div
+          className={classnames({
+            [styles.simple]: expand,
+            [styles['small-size']]:
+              formDivSize?.width && expand && model !== 'simple' && formDivSize.width < 1000,
+          })}
+          ref={formDivRef}
+        >
           <SchemaField schema={expand ? simpleSchema : schema} />
-          <div className={styles.action} style={{ marginTop: expand ? 0 : -12 }}>
+          <div
+            className={classnames(styles.action, {
+              [styles['small-action']]:
+                formDivSize?.width && expand && model !== 'simple' && formDivSize.width < 1000,
+            })}
+            style={{ marginTop: expand ? 0 : -12 }}
+          >
             <Space>
               {enableSave ? SearchBtn.advance : SearchBtn.simple}
               {enableSave && SaveBtn}

+ 12 - 5
src/pages/rule-engine/Scene/Save/index.tsx

@@ -1,14 +1,14 @@
 import { PageContainer } from '@ant-design/pro-layout';
-import { Button, Card, Form, FormInstance, Input } from 'antd';
+import { Card, Form, FormInstance, Input } from 'antd';
 import useLocation from '@/hooks/route/useLocation';
 import Device from '../Save/device/index';
 import Manual from '../Save/manual/index';
 import Timer from '../Save/timer/index';
-import { Ellipsis, TitleComponent } from '@/components';
+import { Ellipsis, PermissionButton, TitleComponent } from '@/components';
 import { observable } from '@formily/reactive';
 import { observer } from '@formily/react';
 import type { FormModelType } from '@/pages/rule-engine/Scene/typings';
-import { useEffect, useCallback, useState } from 'react';
+import React, { useEffect, useCallback, useState } from 'react';
 import { service } from '@/pages/rule-engine/Scene';
 import './index.less';
 import { onlyMessage, randomString } from '@/utils/util';
@@ -75,6 +75,7 @@ export default observer(() => {
   const history = useHistory();
   const [form] = Form.useForm();
   const [saveLoading, setSaveLoading] = useState(false);
+  const { permission, getOtherPermission } = PermissionButton.usePermission('rule-engine/Scene');
 
   const FormModelInit = () => {
     FormModel.current = {
@@ -230,9 +231,15 @@ export default observer(() => {
             <Input.TextArea showCount maxLength={200} placeholder={'请输入说明'} rows={4} />
           </Form.Item>
           <Form.Item>
-            <Button type="primary" htmlType="submit" onClick={submit} loading={saveLoading}>
+            <PermissionButton
+              key={'update'}
+              type={'primary'}
+              isPermission={getOtherPermission([permission.update, permission.add])}
+              onClick={submit}
+              loading={saveLoading}
+            >
               保存
-            </Button>
+            </PermissionButton>
           </Form.Item>
         </Form>
       </Card>