lanjianrong 5 tahun lalu
induk
melakukan
6e295eab83

+ 16 - 2
src/components/EditableForm/editableForm.jsx

@@ -4,11 +4,25 @@ import EditableFormItem from './EditableFormItem'
 
 
 const EditableForm = ({ dataSource, columns }) => {
+  const newColumns = columns.map(item => {
+    const newItem = { ...item }
 
+    // 控制col span
+    if (!item.span) {
+      newItem.span = 24
+    }
+
+    // 默认编辑
+    if (!item.editable) {
+      newItem.editable = true
+    }
+
+    return newItem
+  })
   return (
       <Row>
-        {columns.map(column => (
-          <EditableFormItem key={column.dataIndex} label={column.label} dataIndex={column.dataIndex} record={dataSource[column.dataIndex]} span={column.span || 24 }/>
+        {newColumns.map(column => (
+          <EditableFormItem key={column.dataIndex} label={column.label} dataIndex={column.dataIndex} record={dataSource[column.dataIndex]} span={column.span} editable={column.editable}/>
         ))}
       </Row>
   )

+ 2 - 13
src/pages/Customer/Company/index.jsx

@@ -1,6 +1,6 @@
 import React from 'react'
-import { Card, Row, Col } from 'antd'
-import EditableForm, { EditableFormItem } from '@/components/EditableForm'
+import { Card } from 'antd'
+import EditableForm from '@/components/EditableForm'
 
 const Company = () => {
 
@@ -29,17 +29,6 @@ const Company = () => {
   return (
     <Card bordered={false}>
       <EditableForm dataSource={record} columns={columns} />
-
-      {/* <div>
-        <Row>
-          <Col span={12}>
-            <EditableFormItem label="名字" dataIndex="name" record="哈哈哈" widhth="50%" />
-          </Col>
-          <Col span={12}>
-            <EditableFormItem label="名字" dataIndex="name" record="哈哈哈" widhth="50%" />
-          </Col>
-        </Row>
-      </div> */}
     </Card>
   )
 }