فهرست منبع

fix: #9227 修复新增分类/子分类 表单检验以及loading状态

jackhoo_98 3 سال پیش
والد
کامیت
7d3ddf02eb
1فایلهای تغییر یافته به همراه2 افزوده شده و 3 حذف شده
  1. 2 3
      src/pages/device/Category/Save/index.tsx

+ 2 - 3
src/pages/device/Category/Save/index.tsx

@@ -62,24 +62,23 @@ const Save = (props: Props) => {
   });
 
   const save = async () => {
-    setLoading(true);
     const value: CategoryItem = await form.submit();
     if (!!state.parentId) {
       value.parentId = state.parentId;
     }
+    setLoading(true);
     const resp = props.data.id
       ? await service.update(value as CategoryItem)
       : ((await service.save(value as any)) as Response<CategoryItem>);
     if (resp.status === 200) {
       onlyMessage('操作成功');
-      setLoading(false);
       if (props.reload) {
         props.reload();
       }
     } else {
       onlyMessage('操作失败', 'error');
-      setLoading(false);
     }
+    setLoading(false);
     props.close();
   };