lanjianrong 5 年之前
父節點
當前提交
c5e58e7764
共有 1 個文件被更改,包括 10 次插入4 次删除
  1. 10 4
      src/components/EditableForm/editableFormItem.jsx

+ 10 - 4
src/components/EditableForm/editableFormItem.jsx

@@ -26,22 +26,28 @@ const EditableFormItem = ({ label, dataIndex, record, dataId, span = 24 }) => {
   }
   }
   const save = async e => {
   const save = async e => {
     const { value = '' } = e.currentTarget
     const { value = '' } = e.currentTarget
+    // debugger
     toggleEdit()
     toggleEdit()
-    if (value === val) {
+    if (val === record) {
       return
       return
     }
     }
-    setVal(value)
+
     await handleConfirm(value)
     await handleConfirm(value)
   }
   }
 
 
+  const handleOnChange = e => {
+    const { value = '' } = e.currentTarget
+    setVal(value)
+  }
+
   const cell = editing ? (
   const cell = editing ? (
     // <Form.Item name={dataIndex} noStyle initialValue={record}>
     // <Form.Item name={dataIndex} noStyle initialValue={record}>
     //   <Input ref={inputRef} onPressEnter={save} onBlur={save} />
     //   <Input ref={inputRef} onPressEnter={save} onBlur={save} />
     // </Form.Item>
     // </Form.Item>
-    <Input ref={inputRef} onPressEnter={save} onBlur={save} value={val} />
+    <Input ref={inputRef} onPressEnter={save} onBlur={save} value={val} onChange={handleOnChange} />
   ) : (
   ) : (
     <div className="editable-cell-value-wrap" onClick={toggleEdit}>
     <div className="editable-cell-value-wrap" onClick={toggleEdit}>
-      {record}
+      {val}
     </div>
     </div>
   )
   )