Commit c7abb5e1 by zhaochengxiang

变更目录

parent 47700a11
......@@ -4,23 +4,47 @@ import { Button, Modal, Spin, Tree, AutoComplete } from 'antd'
import { dispatch } from '../../../model'
import { generateList } from './tree'
import produce from 'immer'
import { highlightSearchContentByTerms, showMessage } from '../../../util'
import { highlightSearchContentByTerms, showMessage, showNotifaction } from '../../../util'
const FC = (props) => {
const { visible, items, onCancel } = props
const [waiting, setWaiting] = React.useState(false)
const [loading, setLoading] = React.useState(false)
const basicRef = React.useRef()
const close = (refresh = false) => {
setWaiting(false)
setLoading(false)
onCancel?.(refresh)
}
const save = () => {
const checkedKeys = basicRef.current?.getCheckedKeys()
if ((checkedKeys??[]).length === 0) {
showMessage('warn', '请先选择资产目录')
return
}
setWaiting(true)
dispatch({
type: 'assetmanage.loadDataAssets',
payload: {
params: {
dirId: checkedKeys.join(","),
},
data: (items??[]).map(item => item.id)
},
callback: data => {
setWaiting(false)
if (data?.message) {
showNotifaction('提示', data?.message, 5)
}
onCancel?.(true)
},
error: () => {
setWaiting(false)
}
})
}
const footer = React.useMemo(() => {
......@@ -45,7 +69,7 @@ const FC = (props) => {
centered destroyOnClose
onCancel={() => { close() }}
>
<Spin spinning={loading || waiting}>
<Spin spinning={waiting}>
<Basic ref={basicRef} items={items} />
</Spin>
</Modal>
......@@ -64,8 +88,13 @@ const Basic = React.forwardRef(function ({ items }, ref) {
const [options, setOptions] = React.useState()
const [keyword, setKeyword] = React.useState()
React.useImperativeHandle(ref, () => ({
getCheckedKeys: () => checkedKeys
}), [checkedKeys])
React.useEffect(() => {
getTreeData()
getAssetPaths()
}, [])
const treeData = React.useMemo(() => {
......@@ -90,6 +119,20 @@ const Basic = React.forwardRef(function ({ items }, ref) {
return []
}, [data])
const getAssetPaths = () => {
if ((items??[]).length > 0) {
dispatch({
type: 'assetmanage.getAssetPaths',
payload: {
dataAssetId: items[0].id,
},
callback: data => {
setCheckedKeys((data??[]).map(item => item.dirId))
}
})
}
}
const getTreeData = () => {
setLoading(true)
dispatch({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment