Commit e7e8280f by zhaochengxiang

资产详情改造

parent af606786
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
import { $hostParams, ContextPath } from './util'; import { $hostParams, ContextPath } from './util';
import loadable from "./util/loadable"; import loadable from "./util/loadable";
import { AssetMountReference } from './util/constant'; import { AssetBrowseReference, AssetMountReference } from './util/constant';
export const AppContext = React.createContext(); export const AppContext = React.createContext();
...@@ -22,7 +22,7 @@ const AssetBrowse = loadable(()=> import('./view/Manage/AssetBrowse')); ...@@ -22,7 +22,7 @@ const AssetBrowse = loadable(()=> import('./view/Manage/AssetBrowse'));
const AssetRecycle = loadable(()=> import('./view/Manage/AssetRecycle')); const AssetRecycle = loadable(()=> import('./view/Manage/AssetRecycle'));
const DatasourceManage = loadable(()=> import('./view/Manage/DatasourceManage')); const DatasourceManage = loadable(()=> import('./view/Manage/DatasourceManage'));
const AssetDetailPage = loadable(()=> import('./view/Manage/AssetManage/Component/AssetDetailPage')); const AssetDetailPage = loadable(()=> import('./view/Manage/AssetManage/Component/AssetDetailPage'));
const AssetDetail = loadable(()=> import('./view/Manage/AssetManage/Component/AssetDetail')); const AssetAction = loadable(()=> import('./view/Manage/AssetManage/Component/AssetAction'));
const ImportAction = loadable(()=> import('./view/Manage/Model/Component/ImportAction')); const ImportAction = loadable(()=> import('./view/Manage/Model/Component/ImportAction'));
const EditModel = loadable(()=> import('./view/Manage/Model/Component/EditModel')); const EditModel = loadable(()=> import('./view/Manage/Model/Component/EditModel'));
const EditTemplate = loadable(()=> import('./view/Manage/ModelConfig/Component/EditTemplate')); const EditTemplate = loadable(()=> import('./view/Manage/ModelConfig/Component/EditTemplate'));
...@@ -90,11 +90,12 @@ export class App extends React.Component { ...@@ -90,11 +90,12 @@ export class App extends React.Component {
setGlobalState, setGlobalState,
onGlobalStateChange onGlobalStateChange
}}> }}>
<AssetDetail <AssetAction reference={AssetBrowseReference} id={id} action='detail' terms={terms} readonly={true} />
{/* <AssetDetail
reference='full-search' reference='full-search'
id={id} id={id}
terms={terms} terms={terms}
/> /> */}
</AppContext.Provider> </AppContext.Provider>
); );
} }
......
import * as service from '../service/dataassetmanager'; import * as service from '../service/dataassetmanager';
import * as metadataService from '../service/metadata';
import { call } from 'redux-saga/effects'; import { call } from 'redux-saga/effects';
export function* importElement(payload) { export function* importElement(payload) {
...@@ -265,3 +267,15 @@ export function* startFlow(payload) { ...@@ -265,3 +267,15 @@ export function* startFlow(payload) {
export function* getSystems(payload) { export function* getSystems(payload) {
return yield call(service.getSystems, payload); return yield call(service.getSystems, payload);
} }
export function* getMetadataAttributes(payload) {
return yield call(metadataService.getAttributes, payload);
}
export function* exportMetadataAttributes(payload) {
return yield call(metadataService.exportAttributes, payload);
}
export function* importMetadataAttributes(payload) {
return yield call(metadataService.importAttributes, payload);
}
\ No newline at end of file
import { GetJSON } from "../util/axios" import { GetJSON, PostJSON, callFetchRaw, PostFile } from "../util/axios"
export function queryDatabase(payload) { export function queryDatabase(payload) {
return GetJSON("/metadatarepo/rest/tag/getDatabaseBySystemCode", payload); return GetJSON("/metadatarepo/rest/tag/getDatabaseBySystemCode", payload);
...@@ -19,3 +19,15 @@ export function queryAllFields(payload) { ...@@ -19,3 +19,15 @@ export function queryAllFields(payload) {
export function getSystemAllGraph(payload) { export function getSystemAllGraph(payload) {
return GetJSON("/metadatarelation/getSystemAllGraph", payload); return GetJSON("/metadatarelation/getSystemAllGraph", payload);
} }
export function getAttributes(payload) {
return PostJSON("/metadatarepo/rest/metadata/getByIdList", payload);
}
export function exportAttributes(payload) {
return callFetchRaw('post', '/metadatarepo/rest/download/exportList', payload)
}
export function importAttributes(payload) {
return PostFile("/metadatarepo/rest/import/add", payload);
}
\ No newline at end of file
import axios from 'axios'; import axios from 'axios';
import qs from 'qs';
import { IsArr, showMessage, isSzseEnv } from './index'; import { IsArr, showMessage, isSzseEnv } from './index';
...@@ -163,3 +164,28 @@ export function PostFile(url, payload) { ...@@ -163,3 +164,28 @@ export function PostFile(url, payload) {
callback callback
) )
} }
const config = {
baseURL,
headers: {
'Content-Type': 'application/json',
},
cache: 'no-cache',
// `paramsSerializer` is an optional function in charge of serializing `params`
// (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/)
paramsSerializer: function (params: any) {
// return qs.stringify(params, { arrayFormat: 'repeat' })
return qs.stringify(params, { arrayFormat: 'brackets' })
},
}
export const callFetchRaw = (method, url, options) => {
const { body: data, ...reqConfig } = options
return axios.request({
method,
url,
data,
...config,
...reqConfig
})
}
\ No newline at end of file
import { AxiosResponse } from "axios"
export default function (res: AxiosResponse<any>) {
const blob = res.data
const headers = res.headers
let tempName = headers["content-disposition"]
?.split(";")?.[1]
?.split("filename=")?.[1];
tempName = decodeURI(tempName);
// const blob = new Blob([content], { type: 'application/octet-stream' })
var url = (window.URL && window.URL.createObjectURL) ? window.URL.createObjectURL(blob) : window.webkitURL.createObjectURL(blob);
const link = document.createElement('a');
link.style.display = 'none';
link.href = url;
link.setAttribute('download', tempName); //or any other extension
document.body.appendChild(link);
link.click();
URL.revokeObjectURL(link.href) // 释放URL 对象
document.body.removeChild(link)
}
\ No newline at end of file
.asset-action {
.yy-table-tbody > tr > td {
padding: 8px 8px !important;
}
}
\ No newline at end of file
...@@ -4,7 +4,7 @@ import { Drawer, Form } from 'antd'; ...@@ -4,7 +4,7 @@ import { Drawer, Form } from 'antd';
import AssetAction from './AssetAction'; import AssetAction from './AssetAction';
const AssetDetailDrawer = (props) => { const AssetDetailDrawer = (props) => {
const { onCancel, visible, id, dirId } = props; const { onCancel, visible, id, dirId, reference } = props;
const [ form ] = Form.useForm(); const [ form ] = Form.useForm();
...@@ -13,7 +13,7 @@ const AssetDetailDrawer = (props) => { ...@@ -13,7 +13,7 @@ const AssetDetailDrawer = (props) => {
forceRender forceRender
visible={ visible } visible={ visible }
title='资产详情' title='资产详情'
width={600} width={830}
placement="right" placement="right"
closable={ true } closable={ true }
onClose={() => { onClose={() => {
...@@ -21,7 +21,7 @@ const AssetDetailDrawer = (props) => { ...@@ -21,7 +21,7 @@ const AssetDetailDrawer = (props) => {
}} }}
> >
{ {
visible && <AssetAction form={form} id={id} dirId={dirId} action='detail' readOnly onChange={() => { visible && <AssetAction reference={reference} form={form} id={id} dirId={dirId} action='detail' onChange={() => {
onCancel?.(true); onCancel?.(true);
}} /> }} />
} }
......
...@@ -515,31 +515,31 @@ const AssetTable = (props) => { ...@@ -515,31 +515,31 @@ const AssetTable = (props) => {
}, 500) }, 500)
} }
if (reference === AssetManageReference) { // if (reference === AssetManageReference) {
if (remoteRelationRef.current) { // if (remoteRelationRef.current) {
const index = _assets.findIndex((asset) => asset.id === remoteRelationRef.current.dataAssetId); // const index = _assets.findIndex((asset) => asset.id === remoteRelationRef.current.dataAssetId);
remoteRelationRef.current = null; // remoteRelationRef.current = null;
if (index === -1) { // if (index === -1) {
setSelectItem(_assets.length>0?_assets[0]:{}); // setSelectItem(_assets.length>0?_assets[0]:{});
onSelect && onSelect(_assets.length>0?_assets[0].id:'', _assets.length>0?_assets[0].dirId:''); // onSelect && onSelect(_assets.length>0?_assets[0].id:'', _assets.length>0?_assets[0].dirId:'');
} else { // } else {
setSelectItem(_assets[index]); // setSelectItem(_assets[index]);
onSelect && onSelect(_assets[index].id, _assets[index].dirId); // onSelect && onSelect(_assets[index].id, _assets[index].dirId);
} // }
} else if ((selectItem?.id||'') !=='') { // } else if ((selectItem?.id||'') !=='') {
const index = _assets.findIndex((asset) => asset.id === selectItem?.id); // const index = _assets.findIndex((asset) => asset.id === selectItem?.id);
if (index === -1) { // if (index === -1) {
setSelectItem(_assets.length>0?_assets[0]:{}); // setSelectItem(_assets.length>0?_assets[0]:{});
onSelect && onSelect(_assets.length>0?_assets[0].id:'', _assets.length>0?_assets[0].dirId:''); // onSelect && onSelect(_assets.length>0?_assets[0].id:'', _assets.length>0?_assets[0].dirId:'');
} // }
} else { // } else {
setSelectItem(_assets.length>0?_assets[0]:{}); // setSelectItem(_assets.length>0?_assets[0]:{});
onSelect && onSelect(_assets.length>0?_assets[0].id:'', _assets.length>0?_assets[0].dirId:''); // onSelect && onSelect(_assets.length>0?_assets[0].id:'', _assets.length>0?_assets[0].dirId:'');
} // }
} // }
setTotal(data.total||0); setTotal(data.total||0);
onCountChange && onCountChange(data.total||0); onCountChange && onCountChange(data.total||0);
...@@ -943,7 +943,7 @@ const AssetTable = (props) => { ...@@ -943,7 +943,7 @@ const AssetTable = (props) => {
<Space size={15}> <Space size={15}>
{ {
//栏目和自定义目录 不允许新增资产 //栏目和自定义目录 不允许新增资产
(reference===AssetManageReference && nodeLevel!==1 && nodeType!=='custom') && <Button onClick={addAsset}>新增</Button> // (reference===AssetManageReference && nodeLevel!==1 && nodeType!=='custom') && <Button onClick={addAsset}>新增</Button>
} }
{ {
...@@ -1052,9 +1052,7 @@ const AssetTable = (props) => { ...@@ -1052,9 +1052,7 @@ const AssetTable = (props) => {
setSelectItem(record); setSelectItem(record);
onSelect && onSelect(record?.id, record?.dirId); onSelect && onSelect(record?.id, record?.dirId);
if (reference !== AssetManageReference) {
setAssetDetailDrawerVisible(true); setAssetDetailDrawerVisible(true);
}
}, },
onContextMenu: event => { onContextMenu: event => {
if ((reference===AssetManageReference||(reference===AssetBrowseReference&&record.hasPermission)) && (record.resourceState==='uncombed'||record.resourceState==='notRelatedAsset')) { if ((reference===AssetManageReference||(reference===AssetBrowseReference&&record.hasPermission)) && (record.resourceState==='uncombed'||record.resourceState==='notRelatedAsset')) {
...@@ -1136,6 +1134,7 @@ const AssetTable = (props) => { ...@@ -1136,6 +1134,7 @@ const AssetTable = (props) => {
id={selectItem?.id} id={selectItem?.id}
dirId={selectItem?.dirId} dirId={selectItem?.dirId}
visible={assetDetailDrawerVisible} visible={assetDetailDrawerVisible}
reference={reference}
onCancel={onAssetDetailDrawerCancel} onCancel={onAssetDetailDrawerCancel}
/> />
<AssetDeleteModal <AssetDeleteModal
......
import React, { useCallback, useImperativeHandle, useRef } from "react";
import { showMessage } from "../../../../util";
export interface UploadType {
chooseFile: () => void
}
export default React.forwardRef<UploadType, { accept: string, upload: (files: FileList) => void }>(function ({ accept, upload }, ref) {
const input = useRef<HTMLInputElement>(null)
useImperativeHandle(ref, () => ({
chooseFile: () => {
input.current!.click();
}
}), [])
const onChange: React.ChangeEventHandler<HTMLInputElement> = useCallback((e) => {
console.log('files', e.target.files)
if (e.target.files) { //console.debug(input.current!.files)
e.preventDefault();
let file = e.target.files[0]
if (file) {
const fileSize = file.size
const isLt5G = fileSize / 1024 / 1024 / 1024 < 5
if (!isLt5G) {
showMessage('warn', '上传文件大小不超过5G')
return
}
}
e.target.files && upload(e.target.files)
}
}, [upload])
const onInputClick: React.MouseEventHandler<HTMLInputElement> = useCallback((e) => {
input.current!.value = null
}, [])
return <input ref={input} type="file" multiple={false} accept={accept ?? "image/png"} style={{ visibility: 'hidden' }}
onChange={onChange}
onClick={onInputClick}
/>
})
\ No newline at end of file
...@@ -96,10 +96,10 @@ const AssetManage = (props) => { ...@@ -96,10 +96,10 @@ const AssetManage = (props) => {
{ expandTree ? <CaretLeftOutlined /> : <CaretRightOutlined /> } { expandTree ? <CaretLeftOutlined /> : <CaretRightOutlined /> }
</div> </div>
</div> </div>
<Separate width='15px' /> {/* <Separate width='15px' />
<div className='right'> <div className='right'>
<AssetAction form={form} id={assetId} dirId={assetDirId} action='detail' onChange={onAssetActionChange} /> <AssetAction form={form} id={assetId} dirId={assetDirId} action='detail' onChange={onAssetActionChange} />
</div> </div> */}
</div> </div>
) )
} }
......
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