Commit 57d2e62e by 放生的三文鱼

增加资产草稿详情

parent 53dd6146
......@@ -80,6 +80,10 @@ export function* getDataAssetDetail(payload) {
return yield call(service.getDataAssetDetail, payload);
}
export function* getDraftDataAssetDetail(payload) {
return yield call(service.getDraftDataAssetDetail, payload)
}
export function* listDataAssetsByPage(payload) {
return yield call(service.listDataAssetsByPage, payload);
}
......
......@@ -346,5 +346,10 @@ export function deleteDraftDataAsset(payload) {
return PostJSON('/dataassetmanager/draftApi/deleteDrafts', payload);
}
// /draftApi/getDraftDetail
export function getDraftDataAssetDetail(payload) {
return PostJSON('/dataassetmanager/draftApi/getDraftDetail', payload);
}
......@@ -18,7 +18,7 @@ const AssetManagementTable = () => {
const [draftParams, setDraftParams] = React.useState({
visible: false,
dirId: "",
id:'',
draftId:'',
templateType: "",
});
const {
......@@ -146,7 +146,7 @@ const AssetManagementTable = () => {
setDraftParams({
visible: false,
dirId: "",
id:'',
draftId:'',
templateType: "",
});
}}
......
......@@ -8,6 +8,8 @@ import {
} from "../../../../service/dataassetmanager";
import { AssetItem } from "../../AssetManage/Component/AssetTable";
import { showMessage } from "../../../../util";
import LocalStorage from 'local-storage';
import { appId } from "../../../../App";
const { Text } = Typography;
// ../standardmanage/hooks/sourceMap
......@@ -32,6 +34,10 @@ export function useGetAssetDraft({ setDraftParams }) {
const res = await getTemplates();
setTemplates(res);
setCurrentTemplate(res?.[0]?.type);
LocalStorage.set(`templateType-${appId}`, res?.[0]?.type);
let event = new Event("storage");
event.key = "assetTemplateChange";
window?.dispatchEvent(event);
setLoading(false);
} catch (error) {
setLoading(false);
......@@ -187,7 +193,7 @@ export function useGetAssetDraft({ setDraftParams }) {
setDraftParams({
visible: true,
dirId: record?.dirId,
id: record?.id,
draftId: record?.id,
templateType: currentTemplate,
});
};
......
......@@ -27,7 +27,7 @@ import AttributeMaintain from './AttributeMaintain';
import './AssetAction.less';
const AssetAction = (props) => {
const { id, dirId, action, terms, onChange, reference, form, onMetadataChange, onElementsChange, readonly = false, permissionId ,templateType} = props;
const { id, dirId, draftId,action, terms, onChange, reference, form, onMetadataChange, onElementsChange, readonly = false, permissionId ,templateType} = props;
const [ currentAction, setCurrentAction ] = useState(action);
const [ assetParams, setAssetParams ] = useState({ assets: {}, attributes: [], attributesFoldMap: {} });
......@@ -167,7 +167,12 @@ const AssetAction = (props) => {
// getElements();
} else {
setCurrentAction('detail');
if ((id||'')!=='') {
if(draftId){
setPagination({...pagination, pageNum: 1});
getElements();
getDraftData()
}
else if ((id||'')!=='') {
setPagination({...pagination, pageNum: 1});
getElements();
getAssetPaths();
......@@ -336,7 +341,6 @@ const AssetAction = (props) => {
}
const getElements = ( cb = null ) => {
console.log('data',templateType)
dispatch({
type: (currentAction==='add')?'assetmanage.listElementsAndFillValue':'assetmanage.listElements',
payload: (currentAction==='add')?{
......@@ -462,6 +466,86 @@ const AssetAction = (props) => {
})
}
// 获取草稿数据
const getDraftData = (userElements=null) => {
setLoading(true);
dispatch({
type: 'assetmanage.getDraftDataAssetDetail',
payload: {
params: {
draftId
}
},
callback: data => {
setLoading(false);
const metadataIndex = data?.elements?.findIndex(item => item.name === '资产项');
if (metadataIndex !== -1) {
let metadataValue = data?.elements[metadataIndex].value;
try {
setMetadata(JSON.parse(metadataValue));
getMetadataAttributes();
getMetadataStandardList();
} catch(error) {
}
}
if (userElements) {
const userElementIds = [];
(userElements||[]).forEach(element => {
userElementIds.push(element?.id);
});
const filterElements = (data?.elements||[]).filter(element => userElementIds.indexOf(element?.id) !== -1);
data = { ...data, elements: filterElements };
}
setElements(data?.elements||[]);
onElementsChange && onElementsChange(data?.elements||[]);
setMetadataId(data?.metadataId||'');
onMetadataChange && onMetadataChange(data?.metadataId||'');
const _attributes = [];
(data?.elements||[]).forEach(element => {
if (_attributes.indexOf(element.type) === -1) {
_attributes.push(element.type||'');
}
})
let newAttributesFoldMap = {...attributesFoldMap};
(_attributes||[]).forEach(attribute => {
if (newAttributesFoldMap[attribute]===undefined || newAttributesFoldMap[attribute]===null) {
newAttributesFoldMap[attribute] = true;
}
})
setAssetParams({ assets: data, attributes: _attributes, attributesFoldMap: newAttributesFoldMap });
if ((_attributes??[]).length > 0) {
setCurrentAttribute(_attributes[0])
}
let _fieldsValue = {};
(data.elements||[]).forEach(element => {
_fieldsValue[element.name] = element.value||'';
if (element.name === '主题域分组') {
setCurrentDomainGroup(element.value);
} else if (element.name === '主题域') {
setCurrentBussinessDomain(element.value);
}
})
form?.setFieldsValue(_fieldsValue);
},
error: () => {
setLoading(false);
}
})
}
const getMetadataAttributes = () => {
setMetadata(prevMetadata => {
const ids = prevMetadata?.columnItems.map(item => item.metadataColumnId);
......
import React from 'react';
import { Drawer, Form } from 'antd';
import { getTemplateType } from '../../../../util/axios';
import AssetAction from './AssetAction';
const AssetDetailDrawer = (props) => {
const { onCancel, visible, id, dirId, reference, templateType='', draftId='' } = props;
const [ form ] = Form.useForm();
const currentTemplateType = templateType || getTemplateType();
return (
<Drawer
visible={ visible }
......@@ -20,7 +20,7 @@ const AssetDetailDrawer = (props) => {
}}
>
{
visible && <AssetAction templateType={templateType} reference={reference} form={form} id={id} dirId={dirId} draftId={draftId} action='detail' onChange={() => {
visible && <AssetAction templateType={currentTemplateType} reference={reference} form={form} id={id} dirId={dirId} draftId={draftId} action='detail' onChange={() => {
onCancel?.(true);
}} />
}
......
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