Commit 9106c8d8 by zhaochengxiang

复核

parent 672c07c8
......@@ -2,9 +2,11 @@ import React from 'react'
import { Modal, Button, Spin, Form, Radio } from 'antd'
import { dispatch } from '../../../model'
import { checkMenuAdmit } from '../../../util'
import { AnchorDirId, AnchorId } from '../../../util/constant'
const FC = (props) => {
const { items, visible, onCancel } = props
const { items, visible, onCancel, type = 'single' } = props
const [waiting, setWaiting] = React.useState(false)
const basicRef = React.useRef()
......@@ -62,7 +64,7 @@ const FC = (props) => {
onCancel={() => { close() }}
>
<Spin spinning={waiting} >
<Basic ref={basicRef} items={items} />
<Basic ref={basicRef} items={items} type={type} />
</Spin>
</Modal>
)
......@@ -70,7 +72,8 @@ const FC = (props) => {
export default FC
export const Basic = React.forwardRef(function ({ items }, ref) {
export const Basic = React.forwardRef(function ({ items, type }, ref) {
const [relations, setRelations] = React.useState([])
const [form] = Form.useForm()
React.useImperativeHandle(ref, () => ({
......@@ -79,6 +82,12 @@ export const Basic = React.forwardRef(function ({ items }, ref) {
},
}), [form])
React.useEffect(() => {
if (type === 'single') {
getRelations()
}
}, [])
const checkInfo = React.useMemo(() => {
const toBeCheckCount = (items??[]).filter(item => (item.allowButtons??[]).findIndex(item => item==='check') !== -1).length
const noNeedToBeCheckCount = (items??[]).filter(item => (item.allowButtons??[]).findIndex(item => item==='check') === -1).length
......@@ -86,6 +95,34 @@ export const Basic = React.forwardRef(function ({ items }, ref) {
return `已选数据:${(items??[]).length} 无需复核:${noNeedToBeCheckCount} 待复核:${toBeCheckCount}`
}, [items])
const getRelations = () => {
if ((items??[]).length > 0) {
dispatch({
type: 'assetmanage.getResourceRelations',
payload: {
dataAssetId: items[0].id,
},
callback: data => {
setRelations(data??[])
}
})
}
}
const jumpToRelation = (relation) => {
const timestamp = new Date().getTime()
if (relation.resourceType==='innerSource'||relation.resourceType==='outerSource') {
if (checkMenuAdmit('asset-resource-browse')) {
window.open(`/center-home/menu/asset-resource-browse?${AnchorId}=${relation?.dataAssetId}&${AnchorDirId}=${relation?.dirId}&timestamp=${timestamp}`)
}
} else if (relation.resourceType==='dataAsset') {
if (checkMenuAdmit('asset-browse')) {
window.open(`/center-home/menu/asset-browse?${AnchorId}=${relation?.dataAssetId}&${AnchorDirId}=${relation?.dirId}&timestamp=${timestamp}`)
}
}
}
const onValuesChange = (changedValues, allValues) => {
console.log('all values', allValues)
}
......@@ -93,23 +130,39 @@ export const Basic = React.forwardRef(function ({ items }, ref) {
return (
<Form
form={form}
labelCol={{ span: 3 }}
wrapperCol={{ span: 21 }}
labelCol={{ span: 4 }}
wrapperCol={{ span: 20 }}
autoComplete="off"
onValuesChange={onValuesChange}
>
<Form.Item style={{ marginBottom: 5 }}>
<span>{checkInfo}</span>
</Form.Item>
{
type === 'multiple' && <Form.Item style={{ marginBottom: 5 }}>
<span>{checkInfo}</span>
</Form.Item>
}
<Form.Item
name='status'
rules={[{ required: true, message: '请选择复核方式!' }]}
style={{ marginBottom: 5 }}
>
<Radio.Group>
<Radio value="checked"> 验证通过 </Radio>
<Radio value="changeToNotAsset"> 转为非资产 </Radio>
</Radio.Group>
</Form.Item>
{
type === 'single' && <Form.Item label='关联资产' style={{ marginBottom: 5 }}>
<div className='flex' style={{ flexDirection: 'column', lineHeight: '32px' }}>
{
(relations??[]).map((item, index) => {
return (
<a key={index} onClick={() => {jumpToRelation(item)}}>{item.dataAssetName}</a>
);
})
}
</div>
</Form.Item>
}
</Form>
)
})
\ No newline at end of file
......@@ -123,6 +123,7 @@ const FC = (props) => {
})
const [checkAssetsParams, setCheckAssetsParams] = React.useState({
visible: false,
type: undefined,
items: undefined
})
......@@ -650,6 +651,7 @@ const FC = (props) => {
const onCheckClick = () => {
setCheckAssetsParams({
visible: true,
type: 'multiple',
items: selectedRows
})
}
......@@ -778,6 +780,7 @@ const FC = (props) => {
const onRightCheckClick = () => {
setCheckAssetsParams({
visible: true,
type: 'single',
items: [rightRow]
})
}
......
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