Jelajahi Sumber

fix: #9282 通知配置 调试 修复模板切换数据异常问题

jackhoo_98 3 tahun lalu
induk
melakukan
3b78d54736
1 mengubah file dengan 13 tambahan dan 3 penghapusan
  1. 13 3
      src/pages/notice/Config/Debug/index.tsx

+ 13 - 3
src/pages/notice/Config/Debug/index.tsx

@@ -1,5 +1,5 @@
 import { Modal } from 'antd';
-import { useMemo, useRef } from 'react';
+import { useMemo, useRef, useState } from 'react';
 import { createForm, Field, onFieldReact, onFieldValueChange } from '@formily/core';
 import { createSchemaField, observer } from '@formily/react';
 import {
@@ -25,6 +25,7 @@ const Debug = observer(() => {
   // const location = useLocation<{ id: string }>();
   const id = state.current?.type; // (location as any).query?.id;
   const variableRef = useRef<any>([]);
+  const [loading, setLoading] = useState(false);
 
   const form = useMemo(
     () =>
@@ -44,6 +45,12 @@ const Debug = observer(() => {
                   state1.visible = true;
                   state1.value = _template?.variableDefinitions;
                 });
+              } else {
+                variableRef.current = [];
+                form1.setFieldState('variableDefinitions', (state1) => {
+                  state1.visible = true;
+                  state1.value = undefined;
+                });
               }
             });
 
@@ -162,6 +169,7 @@ const Debug = observer(() => {
       variableDefinitions: {
         title: '变量',
         type: 'string',
+        required: true,
         'x-decorator': 'FormItem',
         'x-component': 'ArrayTable',
         'x-component-props': {
@@ -230,7 +238,7 @@ const Debug = observer(() => {
     const templateId = data.templateId;
     // const list = Store.get('notice-template-list');
     // const _template = list.find((item: any) => item.id === templateId);
-
+    setLoading(true);
     const resp = await service.debug(
       state?.current.id,
       templateId,
@@ -248,8 +256,9 @@ const Debug = observer(() => {
     );
     if (resp.status === 200) {
       onlyMessage('操作成功!');
-      state.debug = false;
     }
+    state.debug = false;
+    setLoading(false);
   };
   return (
     <Modal
@@ -258,6 +267,7 @@ const Debug = observer(() => {
       visible={state.debug}
       onCancel={() => (state.debug = false)}
       onOk={start}
+      confirmLoading={loading}
     >
       <Form form={form} layout={'vertical'}>
         <SchemaField schema={schema} scope={{ getTemplate, useAsyncDataSource }} />