|
@@ -3,7 +3,7 @@ import React, { useEffect } from 'react'
|
|
|
import { connect } from 'dva'
|
|
import { connect } from 'dva'
|
|
|
|
|
|
|
|
const LazyCascader = props => {
|
|
const LazyCascader = props => {
|
|
|
- const { options, dispatch, ...resetProps } = props
|
|
|
|
|
|
|
+ const { options, dispatch, onSelect, ...resetProps } = props
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
if (!options.length) {
|
|
if (!options.length) {
|
|
|
dispatch({
|
|
dispatch({
|
|
@@ -12,10 +12,10 @@ const LazyCascader = props => {
|
|
|
}
|
|
}
|
|
|
}, [])
|
|
}, [])
|
|
|
|
|
|
|
|
- // const onChange = value => {
|
|
|
|
|
- // const [province = '', city = '', area = ''] = value
|
|
|
|
|
- // onSelect({ province, city, area })
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ const handleOnChange = value => {
|
|
|
|
|
+ const [province = '', city = '', area = ''] = value
|
|
|
|
|
+ onSelect({ province, city, area })
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
const loadData = selectedOptions => {
|
|
const loadData = selectedOptions => {
|
|
|
const targetOption = selectedOptions[selectedOptions.length - 1]
|
|
const targetOption = selectedOptions[selectedOptions.length - 1]
|
|
@@ -32,7 +32,7 @@ const LazyCascader = props => {
|
|
|
<Cascader
|
|
<Cascader
|
|
|
{...resetProps}
|
|
{...resetProps}
|
|
|
options={options}
|
|
options={options}
|
|
|
- // onChange={onChange}
|
|
|
|
|
|
|
+ onChange={handleOnChange}
|
|
|
loadData={loadData}
|
|
loadData={loadData}
|
|
|
fieldNames={{ label: 'name', value: 'id' }}
|
|
fieldNames={{ label: 'name', value: 'id' }}
|
|
|
changeOnSelect
|
|
changeOnSelect
|