Commit 8f0a0408 by zhaochengxiang

草稿详情差异对比

parent f1cc21d5
......@@ -33,6 +33,7 @@ const FC = (props) => {
const [updateAssetParams, setUpdateAssetParams] = React.useState({
visible: false,
id: undefined,
dirId: undefined,
})
const [modal, contextHolder] = Modal.useModal();
......@@ -340,6 +341,7 @@ const FC = (props) => {
setUpdateAssetParams({
visible: true,
id: record?.id,
dirId: record?.dirId,
})
}
}
......@@ -374,6 +376,7 @@ const FC = (props) => {
setUpdateAssetParams({
visible: false,
id: undefined,
dirId: undefined,
})
refresh && getDrafts()
......
......@@ -65,6 +65,7 @@ const AssetAction = (props) => {
const [modal, contextHolder] = Modal.useModal();
const [permissions, setPermissions] = useState(undefined);
const [keyword, setKeyword] = useState('');
const [publishedAsset, setPublishedAsset] = useState();
const app = useContext(AppContext);
const uploadRef = useRef(undefined);
......@@ -226,6 +227,7 @@ const AssetAction = (props) => {
}
getAsset();
} else {
setMetadataId('');
setAssetParams({...assetParams, ...{assets: {}, attributes: []}});
......@@ -412,6 +414,10 @@ const AssetAction = (props) => {
callback: data => {
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 === '资产项');
if (metadataIndex !== -1) {
......@@ -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 = () => {
setMetadata(prevMetadata => {
const ids = prevMetadata?.columnItems.map(item => item.metadataColumnId);
......@@ -595,6 +615,27 @@ const AssetAction = (props) => {
setConfirmLoading(true);
if (reference === AssetDraftReference) {
dispatch({
type: 'assetmanage.updateDraft',
payload: {
params: {
isAdmin: true,
},
data: action==='add' ? { elements: newElements } : { ...assets, elements: newElements }
},
callback: () => {
setConfirmLoading(false);
setCurrentAction('detail');
getAsset();
showMessage("success",(action==='add')?"新增成功":"修改成功");
onChange && onChange();
},
error: () => {
setConfirmLoading(false);
}
})
} else {
dispatch({
type: 'assetmanage.checkCodeIsExist',
payload: {
......@@ -612,13 +653,6 @@ const AssetAction = (props) => {
operation: 'change',
}
if (reference === AssetDraftReference) {
url = 'assetmanage.updateDraft'
params = {
isAdmin: true,
}
}
dispatch({
type: url,
payload: {
......@@ -642,7 +676,7 @@ const AssetAction = (props) => {
setConfirmLoading(false);
}
})
}
} catch (errInfo) {
console.log('Validate Failed:', errInfo);
showMessage('warn', '请完成资产必填项')
......@@ -795,13 +829,13 @@ const AssetAction = (props) => {
return <Input disabled={element.manualMaintain==='否'} />;
}
const elementDetailComponent = (item) => {
const elementDetailComponent = (item, publishedItem) => {
if (item.name === '资产项') {
return <MetadataInfo config={false} value={item.value||''} terms={terms} />;
}
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==='更新人') {
......@@ -810,10 +844,16 @@ const AssetAction = (props) => {
users={users}
terms={terms}
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 = () => {
......@@ -957,6 +997,12 @@ const AssetAction = (props) => {
elements?.map((element, index) => {
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 (
<Descriptions.Item
key={index}
......@@ -994,7 +1040,7 @@ const AssetAction = (props) => {
: <React.Fragment>
<Row gutter={8} align='middle'>
<Col span={22}>
{ elementDetailComponent(element) }
{ elementDetailComponent(element, publishedElement) }
</Col>
{
element.interpretation && <Col span={2}>
......
import React from 'react';
import { Typography } from 'antd';
import { highlightSearchContentByTerms } from '../../../../util';
import { AppContext } from '../../../../App';
const FC = ({ value = '', terms = [] }) => {
const FC = ({ value = '', terms = [], publishedValue = '' }) => {
return (
<AppContext.Consumer>
{
......@@ -13,7 +14,10 @@ const FC = ({ value = '', terms = [] }) => {
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>
}
</AppContext.Consumer>
......
import React, { useState, useMemo, useEffect } from "react"
import {Select} from "antd"
import {Select, Typography} from "antd"
import debounce from 'lodash/debounce';
import { highlightSearchContentByTerms } from '../../../../util';
......@@ -8,7 +8,7 @@ const {Option} = Select
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)
......@@ -53,10 +53,25 @@ const SelectUser:React.FC=(props)=>{
)
}else if(type==='detail'){
try {
const user = users?.filter((item)=>(item.pernr===value))
return highlightSearchContentByTerms(`${user[0].nachn}(${user[0].pernr})`, terms);
const user = (users??[]).filter((item)=>(item.pernr===value))
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) {
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{
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