|
|
@@ -7,8 +7,6 @@ import './index.less'
|
|
|
const EditableFormItem = ({ label, dataIndex, record, dataId, span, editCellType }) => {
|
|
|
const [editing, setEditing] = useState(false)
|
|
|
const inputRef = useRef(null)
|
|
|
- const [val, setVal] = useState(record)
|
|
|
- // console.log(record)
|
|
|
// console.log(val)
|
|
|
useEffect(() => {
|
|
|
if (editing) {
|
|
|
@@ -30,17 +28,17 @@ const EditableFormItem = ({ label, dataIndex, record, dataId, span, editCellType
|
|
|
const { value = '' } = e.currentTarget
|
|
|
// debugger
|
|
|
toggleEdit()
|
|
|
- if (val === record) {
|
|
|
+ if (value === record) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
await handleConfirm(value)
|
|
|
}
|
|
|
|
|
|
- const handleOnChange = e => {
|
|
|
- const { value = '' } = e.currentTarget
|
|
|
- setVal(value)
|
|
|
- }
|
|
|
+ // const handleOnChange = e => {
|
|
|
+ // const { value = '' } = e.currentTarget
|
|
|
+ // setVal(value)
|
|
|
+ // }
|
|
|
|
|
|
let cell = null
|
|
|
|
|
|
@@ -53,21 +51,13 @@ const EditableFormItem = ({ label, dataIndex, record, dataId, span, editCellType
|
|
|
// cell = ()
|
|
|
break
|
|
|
default:
|
|
|
- cell = (
|
|
|
- <Input
|
|
|
- ref={inputRef}
|
|
|
- onPressEnter={save}
|
|
|
- onBlur={save}
|
|
|
- value={val}
|
|
|
- onChange={handleOnChange}
|
|
|
- />
|
|
|
- )
|
|
|
+ cell = <Input ref={inputRef} onPressEnter={save} onBlur={save} defaultValue={record} />
|
|
|
break
|
|
|
}
|
|
|
} else {
|
|
|
cell = (
|
|
|
<div className="editable-cell-value-wrap" onClick={toggleEdit}>
|
|
|
- {val}
|
|
|
+ {record}
|
|
|
</div>
|
|
|
)
|
|
|
}
|