|
@@ -1,27 +1,36 @@
|
|
|
import { getAuthCache } from '@/utils/auth'
|
|
import { getAuthCache } from '@/utils/auth'
|
|
|
import { CASCADER_HISTORY_KEY } from '@/utils/cache/cacheEnum'
|
|
import { CASCADER_HISTORY_KEY } from '@/utils/cache/cacheEnum'
|
|
|
import { isUnDef } from '@/utils/is'
|
|
import { isUnDef } from '@/utils/is'
|
|
|
|
|
+import type { CascaderProps } from 'antd'
|
|
|
import { Cascader, Divider, Tag } from 'antd'
|
|
import { Cascader, Divider, Tag } from 'antd'
|
|
|
import React, { forwardRef, useEffect, useState, useLayoutEffect } from 'react'
|
|
import React, { forwardRef, useEffect, useState, useLayoutEffect } from 'react'
|
|
|
import { connect } from 'umi'
|
|
import { connect } from 'umi'
|
|
|
|
|
+import type { Dispatch } from 'umi'
|
|
|
import styles from './index.less'
|
|
import styles from './index.less'
|
|
|
-import { serializeRecord } from './util'
|
|
|
|
|
|
|
+import { saveRecordToAuth } from './util'
|
|
|
|
|
+import type { CascaderRef } from 'antd/lib/cascader'
|
|
|
|
|
|
|
|
-const CLazyCascader = props => {
|
|
|
|
|
- const {
|
|
|
|
|
- refinstance,
|
|
|
|
|
- options,
|
|
|
|
|
- dispatch,
|
|
|
|
|
- value,
|
|
|
|
|
- onChange,
|
|
|
|
|
- changeOnSelect = false,
|
|
|
|
|
- popupVisible = false,
|
|
|
|
|
- showFooter = false,
|
|
|
|
|
- defaultValue,
|
|
|
|
|
- onBlur,
|
|
|
|
|
- isEditFormItem,
|
|
|
|
|
- ...resetProps
|
|
|
|
|
- } = props
|
|
|
|
|
|
|
+type LazyCascaderProps<T> = {
|
|
|
|
|
+ refinstance: CascaderRef
|
|
|
|
|
+ dispatch: Dispatch
|
|
|
|
|
+ isEditFormItem?: boolean
|
|
|
|
|
+ showFooter?: boolean
|
|
|
|
|
+} & CascaderProps<T>
|
|
|
|
|
+
|
|
|
|
|
+function CLazyCascader<T>({
|
|
|
|
|
+ refinstance,
|
|
|
|
|
+ options,
|
|
|
|
|
+ dispatch,
|
|
|
|
|
+ value,
|
|
|
|
|
+ onChange,
|
|
|
|
|
+ changeOnSelect = false,
|
|
|
|
|
+ popupVisible = false,
|
|
|
|
|
+ showFooter = false,
|
|
|
|
|
+ defaultValue,
|
|
|
|
|
+ onBlur,
|
|
|
|
|
+ isEditFormItem,
|
|
|
|
|
+ ...resetProps
|
|
|
|
|
+}: LazyCascaderProps<T>) {
|
|
|
const [visible, setVisible] = useState(popupVisible)
|
|
const [visible, setVisible] = useState(popupVisible)
|
|
|
|
|
|
|
|
const [historyRecord, setHistoryRecord] = useState(
|
|
const [historyRecord, setHistoryRecord] = useState(
|
|
@@ -48,7 +57,7 @@ const CLazyCascader = props => {
|
|
|
const len = nvalue?.length
|
|
const len = nvalue?.length
|
|
|
if (len === 3) {
|
|
if (len === 3) {
|
|
|
const { name, id } = selectedOptions[2]
|
|
const { name, id } = selectedOptions[2]
|
|
|
- const htr = serializeRecord(
|
|
|
|
|
|
|
+ const htr = saveRecordToAuth(
|
|
|
name,
|
|
name,
|
|
|
id,
|
|
id,
|
|
|
selectedOptions.map(item => ({ id: item.id, name: item.name }))
|
|
selectedOptions.map(item => ({ id: item.id, name: item.name }))
|
|
@@ -128,8 +137,7 @@ const CLazyCascader = props => {
|
|
|
item.value.map(v => v.id),
|
|
item.value.map(v => v.id),
|
|
|
item.value
|
|
item.value
|
|
|
)
|
|
)
|
|
|
- }
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ }>
|
|
|
<Tag>{item.name}</Tag>
|
|
<Tag>{item.name}</Tag>
|
|
|
</div>
|
|
</div>
|
|
|
))}
|
|
))}
|