Jelajahi Sumber

feat: ProductLabel组件修改

lanjianrong 5 tahun lalu
induk
melakukan
3427d85e28

+ 2 - 4
src/components/PopContent/Locks/LockForm.jsx

@@ -1,12 +1,10 @@
 import React, { useEffect } from 'react'
 import { Row, Col, Divider } from 'antd'
+
 // import EditableForm from '@/components/EditableForm'
 
 const LockForm = props => {
   const { longle } = props
-  const productArr = longle.product
-  console.log(productArr)
-  // useEffect(() => {}, [longle])
   return (
     <div>
       <Row>
@@ -23,7 +21,7 @@ const LockForm = props => {
         <Col span={18}>{longle.keyNum}</Col>
         <Divider />
         <Col span={6}>产品</Col>
-        <Col span={18}>{longle.product}</Col>
+        <Col span={18} />
         <Divider />
         <Col span={6}>期限</Col>
         <Col span={18}>{longle.allotedTime}</Col>

+ 21 - 27
src/pages/Product/Lock/Lockstore/index.jsx

@@ -6,6 +6,24 @@ import consts from '@/consts'
 import { queryLock } from '@/services/lock'
 import Locks from '@/components/PopContent/Locks'
 
+// 渲染产品标签
+export const ProductLabel = ({ data }) => {
+  if (!data) return <></>
+  let newData = data
+  if (!Array.isArray(data)) {
+    newData = data.split('+')
+  }
+  return (
+    <div>
+      {newData.map((item, index) => (
+        <Tag key={index} color="#886ab5">
+          {item}
+        </Tag>
+      ))}
+    </div>
+  )
+}
+
 const Lockstore = props => {
   const { collapsed } = props
   const needSubtractHeight = 48 + 48 + 48 + 64 + 24 + 32 // 需要被裁掉的高度
@@ -62,17 +80,9 @@ const Lockstore = props => {
       dataIndex: 'product',
       key: 'product',
       width: 350,
-      render: (text, record) => {
-        const productArr = text.split('+')
-        return (
-          <div>
-            {productArr.map((item, index) => (
-              <Tag key={index} color="#886ab5">
-                {item}
-              </Tag>
-            ))}
-          </div>
-        )
+      render: text => {
+        // const productArr = text.split('+')
+        return <ProductLabel data={text} />
       }
     },
     {
@@ -133,20 +143,4 @@ const Lockstore = props => {
   )
 }
 
-// 渲染产品标签
-export const RenderProductLabel = product => {
-  let newProduct = product
-  if (!Array.isArray(product)) {
-    newProduct = product.split('+')
-  }
-  return (
-    <div>
-      {newProduct.map((item, index) => (
-        <Tag key={index} color="#886ab5">
-          {item}
-        </Tag>
-      ))}
-    </div>
-  )
-}
 export default Lockstore