|
|
@@ -1,11 +1,12 @@
|
|
|
import consts from '@/basic/consts'
|
|
|
import { editFormApi } from '@/services/common'
|
|
|
-import { Input, Row, Col, Select } from 'antd'
|
|
|
+import { Input, Row, Col } from 'antd'
|
|
|
import React, { useState, useEffect, useRef } from 'react'
|
|
|
import LazyCascader from '../../LazyCascader'
|
|
|
import { connect } from 'dva'
|
|
|
import './index.less'
|
|
|
import useOptions from './useOptions'
|
|
|
+import ChangeSelect from '@/pages/Customer/Company/components/ChangeSelect'
|
|
|
|
|
|
const EditableFormItem = ({
|
|
|
type,
|
|
|
@@ -32,7 +33,12 @@ const EditableFormItem = ({
|
|
|
useEffect(() => {
|
|
|
// 处于编辑状态自动聚焦, 级联有问题暂无解决办法
|
|
|
if (editing && iRef.current) {
|
|
|
- iRef.current.focus()
|
|
|
+ if (iRef.current.selectRef) {
|
|
|
+ // select选择器相关
|
|
|
+ iRef.current.selectRef.current.focus()
|
|
|
+ } else {
|
|
|
+ iRef.current.focus()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 对级联数据初始化, key一定要是district!!
|
|
|
@@ -106,25 +112,7 @@ const EditableFormItem = ({
|
|
|
)
|
|
|
break
|
|
|
case 'select':
|
|
|
- cell = (
|
|
|
- <Select
|
|
|
- defaultValue={val}
|
|
|
- ref={iRef}
|
|
|
- onBlur={save}
|
|
|
- options={options}
|
|
|
- defaultOpen={true}
|
|
|
- mode={Array.isArray(val) ? 'multiple' : null}
|
|
|
- onChange={(value, option) => {
|
|
|
- const local = Array.isArray(option)
|
|
|
- ? option.reduce((prev, curr) => {
|
|
|
- return prev + curr.label
|
|
|
- }, '')
|
|
|
- : options.label
|
|
|
- save({ currentTarget: { value, local } })
|
|
|
- }}
|
|
|
- className="zh-width-100P"
|
|
|
- />
|
|
|
- )
|
|
|
+ cell = <ChangeSelect ref={iRef} defaultValue={val} options={options} onSave={save} />
|
|
|
break
|
|
|
case 'textarea':
|
|
|
cell = (
|
|
|
@@ -154,6 +142,9 @@ const EditableFormItem = ({
|
|
|
if (editCellType === 'cascader') {
|
|
|
content = extraVal || dataSource.local
|
|
|
}
|
|
|
+ if (editCellType === 'select') {
|
|
|
+ content = extraVal || dataSource.nature
|
|
|
+ }
|
|
|
cell = (
|
|
|
<div className="editable-cell-value-wrap" onClick={toggleEdit}>
|
|
|
{content}
|