Commit 8f0a0408 by zhaochengxiang

草稿详情差异对比

parent f1cc21d5
...@@ -33,6 +33,7 @@ const FC = (props) => { ...@@ -33,6 +33,7 @@ const FC = (props) => {
const [updateAssetParams, setUpdateAssetParams] = React.useState({ const [updateAssetParams, setUpdateAssetParams] = React.useState({
visible: false, visible: false,
id: undefined, id: undefined,
dirId: undefined,
}) })
const [modal, contextHolder] = Modal.useModal(); const [modal, contextHolder] = Modal.useModal();
...@@ -340,6 +341,7 @@ const FC = (props) => { ...@@ -340,6 +341,7 @@ const FC = (props) => {
setUpdateAssetParams({ setUpdateAssetParams({
visible: true, visible: true,
id: record?.id, id: record?.id,
dirId: record?.dirId,
}) })
} }
} }
...@@ -374,6 +376,7 @@ const FC = (props) => { ...@@ -374,6 +376,7 @@ const FC = (props) => {
setUpdateAssetParams({ setUpdateAssetParams({
visible: false, visible: false,
id: undefined, id: undefined,
dirId: undefined,
}) })
refresh && getDrafts() refresh && getDrafts()
......
...@@ -65,6 +65,7 @@ const AssetAction = (props) => { ...@@ -65,6 +65,7 @@ const AssetAction = (props) => {
const [modal, contextHolder] = Modal.useModal(); const [modal, contextHolder] = Modal.useModal();
const [permissions, setPermissions] = useState(undefined); const [permissions, setPermissions] = useState(undefined);
const [keyword, setKeyword] = useState(''); const [keyword, setKeyword] = useState('');
const [publishedAsset, setPublishedAsset] = useState();
const app = useContext(AppContext); const app = useContext(AppContext);
const uploadRef = useRef(undefined); const uploadRef = useRef(undefined);
...@@ -226,6 +227,7 @@ const AssetAction = (props) => { ...@@ -226,6 +227,7 @@ const AssetAction = (props) => {
} }
getAsset(); getAsset();
} else { } else {
setMetadataId(''); setMetadataId('');
setAssetParams({...assetParams, ...{assets: {}, attributes: []}}); setAssetParams({...assetParams, ...{assets: {}, attributes: []}});
...@@ -412,6 +414,10 @@ const AssetAction = (props) => { ...@@ -412,6 +414,10 @@ const AssetAction = (props) => {
callback: data => { callback: data => {
setLoading(false); setLoading(false);
if (reference === AssetDraftReference && data?.dataAssetId && (data?.dirIds??[]).length > 0) {
getPublishedAsset(data?.dataAssetId, data?.dirIds[0])
}
const metadataIndex = data?.elements?.findIndex(item => item.name === '资产项'); const metadataIndex = data?.elements?.findIndex(item => item.name === '资产项');
if (metadataIndex !== -1) { if (metadataIndex !== -1) {
...@@ -456,6 +462,20 @@ const AssetAction = (props) => { ...@@ -456,6 +462,20 @@ const AssetAction = (props) => {
}) })
} }
const getPublishedAsset = (id, dirId) => {
dispatch({
type: 'assetmanage.getDataAssetDetail',
payload: {
dataAssetId: id,
dirId: dirId,
checkPermission: false
},
callback: data => {
setPublishedAsset(data)
}
})
}
const getMetadataAttributes = () => { const getMetadataAttributes = () => {
setMetadata(prevMetadata => { setMetadata(prevMetadata => {
const ids = prevMetadata?.columnItems.map(item => item.metadataColumnId); const ids = prevMetadata?.columnItems.map(item => item.metadataColumnId);
...@@ -595,54 +615,68 @@ const AssetAction = (props) => { ...@@ -595,54 +615,68 @@ const AssetAction = (props) => {
setConfirmLoading(true); setConfirmLoading(true);
dispatch({ if (reference === AssetDraftReference) {
type: 'assetmanage.checkCodeIsExist', dispatch({
payload: { type: 'assetmanage.updateDraft',
data: action==='add' ? { elements: newElements } : { ...assets, elements: newElements } payload: {
}, params: {
callback: isExist => { isAdmin: true,
if (isExist === 'true') { },
data: action==='add' ? { elements: newElements } : { ...assets, elements: newElements }
},
callback: () => {
setConfirmLoading(false); setConfirmLoading(false);
showMessage('warn', '已存在相同的资产目录编号,请重新输入'); setCurrentAction('detail');
} else { getAsset();
let url = 'assetmanage.saveAsDraft' showMessage("success",(action==='add')?"新增成功":"修改成功");
let params = { onChange && onChange();
dirId, },
metadataId: metadataId??'', error: () => {
operation: 'change', setConfirmLoading(false);
} }
})
if (reference === AssetDraftReference) { } else {
url = 'assetmanage.updateDraft' dispatch({
params = { type: 'assetmanage.checkCodeIsExist',
isAdmin: true, payload: {
data: action==='add' ? { elements: newElements } : { ...assets, elements: newElements }
},
callback: isExist => {
if (isExist === 'true') {
setConfirmLoading(false);
showMessage('warn', '已存在相同的资产目录编号,请重新输入');
} else {
let url = 'assetmanage.saveAsDraft'
let params = {
dirId,
metadataId: metadataId??'',
operation: 'change',
} }
dispatch({
type: url,
payload: {
params,
data: action==='add' ? { elements: newElements } : { ...assets, elements: newElements }
},
callback: () => {
setConfirmLoading(false);
setCurrentAction('detail');
getAsset();
showMessage("success",(action==='add')?"新增成功":"修改成功");
onChange && onChange();
},
error: () => {
setConfirmLoading(false);
}
})
} }
},
dispatch({ error: () => {
type: url, setConfirmLoading(false);
payload: {
params,
data: action==='add' ? { elements: newElements } : { ...assets, elements: newElements }
},
callback: () => {
setConfirmLoading(false);
setCurrentAction('detail');
getAsset();
showMessage("success",(action==='add')?"新增成功":"修改成功");
onChange && onChange();
},
error: () => {
setConfirmLoading(false);
}
})
} }
}, })
error: () => { }
setConfirmLoading(false);
}
})
} catch (errInfo) { } catch (errInfo) {
console.log('Validate Failed:', errInfo); console.log('Validate Failed:', errInfo);
showMessage('warn', '请完成资产必填项') showMessage('warn', '请完成资产必填项')
...@@ -795,13 +829,13 @@ const AssetAction = (props) => { ...@@ -795,13 +829,13 @@ const AssetAction = (props) => {
return <Input disabled={element.manualMaintain==='否'} />; return <Input disabled={element.manualMaintain==='否'} />;
} }
const elementDetailComponent = (item) => { const elementDetailComponent = (item, publishedItem) => {
if (item.name === '资产项') { if (item.name === '资产项') {
return <MetadataInfo config={false} value={item.value||''} terms={terms} />; return <MetadataInfo config={false} value={item.value||''} terms={terms} />;
} }
if (item.name === '指标标准编码') { if (item.name === '指标标准编码') {
return <IndexCode value={item.value||''} terms={terms} />; return <IndexCode value={item.value||''} terms={terms} publishedValue={publishedItem?.value} />;
} }
if (item.name==='数据关键用户' || item.name?.toLowerCase()==='业务数据owner' || item.name?.toLowerCase()==='it责任人' || item.name==='创建人' || item.name==='更新人') { if (item.name==='数据关键用户' || item.name?.toLowerCase()==='业务数据owner' || item.name?.toLowerCase()==='it责任人' || item.name==='创建人' || item.name==='更新人') {
...@@ -810,10 +844,16 @@ const AssetAction = (props) => { ...@@ -810,10 +844,16 @@ const AssetAction = (props) => {
users={users} users={users}
terms={terms} terms={terms}
value={item.value||''} value={item.value||''}
publishedValue={publishedItem?.value}
/> />
} }
return <span className='text-color'>{highlightSearchContentByTerms(item.value||'', terms)}</span>; return <span>
<Typography.Text>{highlightSearchContentByTerms(item.value||'', terms)}</Typography.Text>
{
publishedItem?.value && publishedItem?.value!==item.value && <Typography.Text className='ml-2' type='danger'><del>{publishedItem?.value}</del></Typography.Text>
}
</span>;
} }
const onExportClick = () => { const onExportClick = () => {
...@@ -957,6 +997,12 @@ const AssetAction = (props) => { ...@@ -957,6 +997,12 @@ const AssetAction = (props) => {
elements?.map((element, index) => { elements?.map((element, index) => {
if (element.type!==attribute || element.name === '资产项') return null; if (element.type!==attribute || element.name === '资产项') return null;
const _index = (publishedAsset?.elements??[]).findIndex(item => item.name===element.name)
let publishedElement = null;
if (_index !== -1) {
publishedElement = publishedAsset?.elements[_index];
}
return ( return (
<Descriptions.Item <Descriptions.Item
key={index} key={index}
...@@ -994,7 +1040,7 @@ const AssetAction = (props) => { ...@@ -994,7 +1040,7 @@ const AssetAction = (props) => {
: <React.Fragment> : <React.Fragment>
<Row gutter={8} align='middle'> <Row gutter={8} align='middle'>
<Col span={22}> <Col span={22}>
{ elementDetailComponent(element) } { elementDetailComponent(element, publishedElement) }
</Col> </Col>
{ {
element.interpretation && <Col span={2}> element.interpretation && <Col span={2}>
......
import React from 'react'; import React from 'react';
import { Typography } from 'antd';
import { highlightSearchContentByTerms } from '../../../../util'; import { highlightSearchContentByTerms } from '../../../../util';
import { AppContext } from '../../../../App'; import { AppContext } from '../../../../App';
const FC = ({ value = '', terms = [] }) => { const FC = ({ value = '', terms = [], publishedValue = '' }) => {
return ( return (
<AppContext.Consumer> <AppContext.Consumer>
{ {
...@@ -13,7 +14,10 @@ const FC = ({ value = '', terms = [] }) => { ...@@ -13,7 +14,10 @@ const FC = ({ value = '', terms = [] }) => {
data: { name: value } data: { name: value }
}) })
}}> }}>
<span>{highlightSearchContentByTerms(value, terms)}</span> <Typography.Text>{highlightSearchContentByTerms(value, terms)}</Typography.Text>
{
publishedValue && (publishedValue !== value) && <Typography.Text className='ml-2' type='danger'><del>{publishedValue}</del></Typography.Text>
}
</a> </a>
} }
</AppContext.Consumer> </AppContext.Consumer>
......
import React, { useState, useMemo, useEffect } from "react" import React, { useState, useMemo, useEffect } from "react"
import {Select} from "antd" import {Select, Typography} from "antd"
import debounce from 'lodash/debounce'; import debounce from 'lodash/debounce';
import { highlightSearchContentByTerms } from '../../../../util'; import { highlightSearchContentByTerms } from '../../../../util';
...@@ -8,7 +8,7 @@ const {Option} = Select ...@@ -8,7 +8,7 @@ const {Option} = Select
const SelectUser:React.FC=(props)=>{ const SelectUser:React.FC=(props)=>{
const {value,onChange,users,type,loading, terms} = props const {value,onChange,users,type,loading, terms,publishedValue} = props
const [searchValue, setSearchValue] = useState(undefined) const [searchValue, setSearchValue] = useState(undefined)
...@@ -53,10 +53,25 @@ const SelectUser:React.FC=(props)=>{ ...@@ -53,10 +53,25 @@ const SelectUser:React.FC=(props)=>{
) )
}else if(type==='detail'){ }else if(type==='detail'){
try { try {
const user = users?.filter((item)=>(item.pernr===value)) const user = (users??[]).filter((item)=>(item.pernr===value))
return highlightSearchContentByTerms(`${user[0].nachn}(${user[0].pernr})`, terms); let publishedUser = null;
if (publishedValue && publishedValue !== value) {
publishedUser = (users??[]).filter((item)=>(item.pernr===publishedValue))
}
return <span>
<Typography.Text>{highlightSearchContentByTerms(`${user[0].nachn}(${user[0].pernr})`, terms)}</Typography.Text>
{
publishedUser && <Typography.Text className='ml-2' type='danger'><del>{`${publishedUser[0].nachn}(${publishedUser[0].pernr})`}</del></Typography.Text>
}
</span>;
} catch (error) { } catch (error) {
return highlightSearchContentByTerms(value, terms) return <span>
<Typography.Text>{highlightSearchContentByTerms(value, terms)}</Typography.Text>
{
publishedValue && publishedValue!==value && <Typography.Text className='ml-2' type='danger'><del>{publishedValue}</del></Typography.Text>
}
</span>
} }
}else{ }else{
return null return null
......
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