Explorar el Código

perf: 优化锁库代码

lanjianrong hace 4 años
padre
commit
e49f4fd381
Se han modificado 1 ficheros con 39 adiciones y 33 borrados
  1. 39 33
      src/pages/Product/Lock/LockStore/components/LocksDetail/TabList.jsx

+ 39 - 33
src/pages/Product/Lock/LockStore/components/LocksDetail/TabList.jsx

@@ -103,40 +103,38 @@ const LockTabList = props => {
     toggleDrawer(true)
   }
 
-  const RenderLongleCon = ({ longleService }) => {
+  const renderLongleCon = longleService => {
     const { NewKeyNum } = longleService
     if (!NewKeyNum) return null
     let newLongleService
     if (!Array.isArray(NewKeyNum)) {
       newLongleService = NewKeyNum.split('->')
     }
+    const renderNewLog = () => {
+      if (newLongleService[1] && !longleService.newLongleId) {
+        return `${newLongleService[0]} -> ${newLongleService[1]}`
+      }
+      if (newLongleService[1] && longleService.newLongleId) {
+        return (
+          <>
+            {`${newLongleService[0]} ->`}
+            <span
+              className="textPurple text-hex-967bbd cursor-pointer"
+              onClick={() => showLongleClick(longleService.newLongleId)}
+            >
+              {newLongleService[1]}
+            </span>
+          </>
+        )
+      }
+      return newLongleService[0]
+    }
     return (
       <>
-        {showProductsStatus.includes(longleService.status) ? (
+        {showProductsStatus.includes(longleService.status) && (
           <ProductLabel data={longleService.product} />
-        ) : null}
-        {showNewLongleStatus.includes(longleService.status) ? (
-          <>
-            {newLongleService[1] ? (
-              <>
-                {!longleService.newLongleId === true ? (
-                  <>{`${newLongleService[0]} -> ${newLongleService[1]}`}</>
-                ) : (
-                  <>
-                    {newLongleService[0]} {'->'}
-                    <span
-                      className="textPurple text-hex-967bbd cursor-pointer"
-                      onClick={() => showLongleClick(longleService.newLongleId)}>
-                      {newLongleService[1]}
-                    </span>
-                  </>
-                )}
-              </>
-            ) : (
-              <>{newLongleService[0]}</>
-            )}
-          </>
-        ) : null}
+        )}
+        {showNewLongleStatus.includes(longleService.status) && renderNewLog()}
         {showMarkStatus.includes(longleService.status) ? <span>{longleService.mark}</span> : null}
       </>
     )
@@ -176,7 +174,8 @@ const LockTabList = props => {
                         {servicelogEnum[item.status]}{' '}
                         <span
                           className="textPurple text-hex-967bbd cursor-pointer"
-                          onClick={handleClientClick}>
+                          onClick={handleClientClick}
+                        >
                           {item.status !== 6 ? <>{item.client}</> : null}
                         </span>
                         <br />
@@ -189,7 +188,8 @@ const LockTabList = props => {
                         /> */}
                       </Col>
                       <Col span="16">
-                        <RenderLongleCon longleService={item} />
+                        {renderLongleCon(item)}
+                        {/* <RenderLongleCon longleService={item} /> */}
                         {hasAddPerm &&
                         (item.status === 3 ||
                           item.status === 4 ||
@@ -199,7 +199,8 @@ const LockTabList = props => {
                             title="确认删除"
                             onConfirm={() => delLonglelog(item.id)}
                             okText="确认"
-                            cancelText="取消">
+                            cancelText="取消"
+                          >
                             <Button className="mt-2" type="primary" ghost size="small" danger>
                               删除
                             </Button>
@@ -223,7 +224,8 @@ const LockTabList = props => {
             className="mr-3px"
             onClick={() =>
               setAddLonglelog({ ...setAddLonglelog, visible: true, type: lockTypeEnum.RECEIVE })
-            }>
+            }
+          >
             接收
           </Button>
         ) : null}
@@ -235,7 +237,8 @@ const LockTabList = props => {
             className="mr-3px"
             onClick={() =>
               setAddLonglelog({ ...setAddLonglelog, visible: true, type: lockTypeEnum.SALE })
-            }>
+            }
+          >
             借销赠
           </Button>
         ) : null}
@@ -262,7 +265,8 @@ const LockTabList = props => {
                 visible: true,
                 type: lockTypeEnum.CHANGE
               })
-            }>
+            }
+          >
             更换
           </Button>
         ) : null}
@@ -274,7 +278,8 @@ const LockTabList = props => {
             className="mr-1"
             onClick={() =>
               setAddLonglelog({ ...setAddLonglelog, visible: true, type: lockTypeEnum.RECOVER })
-            }>
+            }
+          >
             收回
           </Button>
         ) : null}
@@ -284,7 +289,8 @@ const LockTabList = props => {
           size="small"
           onClick={() =>
             setAddLonglelog({ ...setAddLonglelog, visible: true, type: lockTypeEnum.REMARK })
-          }>
+          }
+        >
           备注
         </Button>