Commit 9106c8d8 by zhaochengxiang

复核

parent 672c07c8
...@@ -2,9 +2,11 @@ import React from 'react' ...@@ -2,9 +2,11 @@ import React from 'react'
import { Modal, Button, Spin, Form, Radio } from 'antd' import { Modal, Button, Spin, Form, Radio } from 'antd'
import { dispatch } from '../../../model' import { dispatch } from '../../../model'
import { checkMenuAdmit } from '../../../util'
import { AnchorDirId, AnchorId } from '../../../util/constant'
const FC = (props) => { const FC = (props) => {
const { items, visible, onCancel } = props const { items, visible, onCancel, type = 'single' } = props
const [waiting, setWaiting] = React.useState(false) const [waiting, setWaiting] = React.useState(false)
const basicRef = React.useRef() const basicRef = React.useRef()
...@@ -62,7 +64,7 @@ const FC = (props) => { ...@@ -62,7 +64,7 @@ const FC = (props) => {
onCancel={() => { close() }} onCancel={() => { close() }}
> >
<Spin spinning={waiting} > <Spin spinning={waiting} >
<Basic ref={basicRef} items={items} /> <Basic ref={basicRef} items={items} type={type} />
</Spin> </Spin>
</Modal> </Modal>
) )
...@@ -70,7 +72,8 @@ const FC = (props) => { ...@@ -70,7 +72,8 @@ const FC = (props) => {
export default FC 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() const [form] = Form.useForm()
React.useImperativeHandle(ref, () => ({ React.useImperativeHandle(ref, () => ({
...@@ -79,6 +82,12 @@ export const Basic = React.forwardRef(function ({ items }, ref) { ...@@ -79,6 +82,12 @@ export const Basic = React.forwardRef(function ({ items }, ref) {
}, },
}), [form]) }), [form])
React.useEffect(() => {
if (type === 'single') {
getRelations()
}
}, [])
const checkInfo = React.useMemo(() => { const checkInfo = React.useMemo(() => {
const toBeCheckCount = (items??[]).filter(item => (item.allowButtons??[]).findIndex(item => item==='check') !== -1).length 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 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) { ...@@ -86,6 +95,34 @@ export const Basic = React.forwardRef(function ({ items }, ref) {
return `已选数据:${(items??[]).length} 无需复核:${noNeedToBeCheckCount} 待复核:${toBeCheckCount}` return `已选数据:${(items??[]).length} 无需复核:${noNeedToBeCheckCount} 待复核:${toBeCheckCount}`
}, [items]) }, [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) => { const onValuesChange = (changedValues, allValues) => {
console.log('all values', allValues) console.log('all values', allValues)
} }
...@@ -93,23 +130,39 @@ export const Basic = React.forwardRef(function ({ items }, ref) { ...@@ -93,23 +130,39 @@ export const Basic = React.forwardRef(function ({ items }, ref) {
return ( return (
<Form <Form
form={form} form={form}
labelCol={{ span: 3 }} labelCol={{ span: 4 }}
wrapperCol={{ span: 21 }} wrapperCol={{ span: 20 }}
autoComplete="off" autoComplete="off"
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
> >
<Form.Item style={{ marginBottom: 5 }}> {
type === 'multiple' && <Form.Item style={{ marginBottom: 5 }}>
<span>{checkInfo}</span> <span>{checkInfo}</span>
</Form.Item> </Form.Item>
}
<Form.Item <Form.Item
name='status' name='status'
rules={[{ required: true, message: '请选择复核方式!' }]} rules={[{ required: true, message: '请选择复核方式!' }]}
style={{ marginBottom: 5 }}
> >
<Radio.Group> <Radio.Group>
<Radio value="checked"> 验证通过 </Radio> <Radio value="checked"> 验证通过 </Radio>
<Radio value="changeToNotAsset"> 转为非资产 </Radio> <Radio value="changeToNotAsset"> 转为非资产 </Radio>
</Radio.Group> </Radio.Group>
</Form.Item> </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> </Form>
) )
}) })
\ No newline at end of file
...@@ -123,6 +123,7 @@ const FC = (props) => { ...@@ -123,6 +123,7 @@ const FC = (props) => {
}) })
const [checkAssetsParams, setCheckAssetsParams] = React.useState({ const [checkAssetsParams, setCheckAssetsParams] = React.useState({
visible: false, visible: false,
type: undefined,
items: undefined items: undefined
}) })
...@@ -650,6 +651,7 @@ const FC = (props) => { ...@@ -650,6 +651,7 @@ const FC = (props) => {
const onCheckClick = () => { const onCheckClick = () => {
setCheckAssetsParams({ setCheckAssetsParams({
visible: true, visible: true,
type: 'multiple',
items: selectedRows items: selectedRows
}) })
} }
...@@ -778,6 +780,7 @@ const FC = (props) => { ...@@ -778,6 +780,7 @@ const FC = (props) => {
const onRightCheckClick = () => { const onRightCheckClick = () => {
setCheckAssetsParams({ setCheckAssetsParams({
visible: true, visible: true,
type: 'single',
items: [rightRow] 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