Bläddra i källkod

feat: 软件锁相关功能加上按钮点击事件逻辑优化

outaozhen 4 år sedan
förälder
incheckning
4f1df6bf4f

+ 24 - 17
src/pages/Product/Lock/LockStore/components/LockDetail/OpreateLock.jsx

@@ -138,24 +138,31 @@ const OpreateLock = props => {
   }, [resetModalProps.visible, type])
 
   const handleonOk = () => {
-    form.validateFields().then(async values => {
-      if (type === lockTypeEnum.RECEIVE) {
-        const { code = -1 } = await apiReceiveLock({ longleId })
-        if (code === consts.RET_CODE.SUCCESS) {
-          message.success('接收成功')
-          resetModalProps.onCancel()
-          dispatch({
-            type: 'refresh/commitAction',
-            payload: {
-              main: 'software',
-              target: longleId
-            }
-          })
+    form
+      .validateFields()
+      .then(async values => {
+        setState({ ...state, loading: true })
+        if (type === lockTypeEnum.RECEIVE) {
+          const { code = -1 } = await apiReceiveLock({ longleId })
+          if (code === consts.RET_CODE.SUCCESS) {
+            message.success('接收成功')
+            onCancel()
+            dispatch({
+              type: 'refresh/commitAction',
+              payload: {
+                main: 'software',
+                target: longleId
+              }
+            })
+          }
+        } else {
+          const isSuccess = await onConfirm({ ...values, preserveStatus: type })
+          isSuccess && onCancel()
         }
-      } else {
-        onConfirm({ ...values, preserveStatus: type })
-      }
-    })
+      })
+      .finally(() => {
+        setState({ ...state, loading: false })
+      })
   }
 
   const checkGroupOnChange = e => {

+ 3 - 4
src/pages/Product/Lock/LockStore/components/LockDetail/TabList.jsx

@@ -22,8 +22,7 @@ const LockTabList = props => {
   const { TabPane } = Tabs
 
   const [addLonglelog, setAddLonglelog] = useState({
-    type: '',
-    visible: false
+    type: ''
   })
 
   const handleAddLonglelog = async values => {
@@ -33,14 +32,14 @@ const LockTabList = props => {
     })
     if (code === consts.RET_CODE.SUCCESS) {
       message.success('新增成功')
-      // 请求完了
-      setAddLonglelog({ ...addLonglelog, visible: false })
       // 刷新数据
       dispatch({
         type: 'refresh/commitAction',
         payload: actionPayload
       })
     }
+    // 请求完了
+    return code === consts.RET_CODE.SUCCESS
   }
 
   // 点击新软件锁详情