Bladeren bron

Merge pull request #737 from jetlinks/next-hub

Next hub
胡彪 3 jaren geleden
bovenliggende
commit
abf0746934

+ 18 - 9
src/components/ProTableCard/index.tsx

@@ -237,15 +237,16 @@ const ProTableCard = <
               resp = await request(newParam, sort, filter);
             }
             setLoading(false);
-            setTotal(resp.result ? resp.result.total : 0);
+            const result = {
+              data: resp.result ? resp.result.data : [],
+              pageIndex: resp.result ? resp.result.pageIndex : 0,
+              pageSize: resp.result ? resp.result.pageSize : 0,
+              total: resp.result ? resp.result.total : 0,
+            };
+            setTotal(result.total);
             return {
               code: resp.message,
-              result: {
-                data: resp.result ? resp.result.data : [],
-                pageIndex: resp.result ? resp.result.pageIndex : 0,
-                pageSize: resp.result ? resp.result.pageSize : 0,
-                total: resp.result ? resp.result.total : 0,
-              },
+              result,
               status: resp.status,
             };
           }
@@ -319,9 +320,17 @@ const ProTableCard = <
               pageSizeOptions={pageSizeOptions}
               pageSize={pageSize}
               showTotal={(num) => {
-                const minSize = pageIndex * pageSize + 1;
                 const MaxSize = (pageIndex + 1) * pageSize;
-                return `第 ${minSize} - ${MaxSize > num ? num : MaxSize} 条/总共 ${num} 条`;
+                const max = MaxSize > num ? num : MaxSize;
+
+                const minSize = pageIndex * pageSize + 1;
+                const pageIndexInt =
+                  parseInt(num / pageSize) === num / pageSize
+                    ? num / pageSize - 1
+                    : parseInt(num / pageSize);
+                const min = minSize > num ? pageIndexInt * pageSize + 1 : minSize;
+
+                return `第 ${min} - ${max} 条/总共 ${num} 条`;
               }}
             />
           )}

+ 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 }} />

+ 1 - 0
src/pages/system/Department/Tree/tree.tsx

@@ -366,6 +366,7 @@ export default (props: TreeProps) => {
                           sortIndex: nodeData.children ? nodeData.children.length + 1 : 1,
                         });
                         setVisible(true);
+                        setTreeDataList(treeData);
                       }}
                     >
                       <PlusCircleOutlined />