Commit 82cac42b by zhaochengxiang

增加服务

parent ee27b8a2
......@@ -15,7 +15,6 @@ const Signin = loadable(()=> import('./view/Signin'));
const Home = loadable(()=> import('./view/Home'));
const Manage = loadable(()=> import('./view/Manage'));
const Model = loadable(()=> import('./view/Manage/Model'));
const ModelConfig = loadable(()=> import('./view/Manage/ModelConfig'));
const AssetManage = loadable(()=> import('./view/Manage/AssetManage'));
const AssetResourceBrowse = loadable(()=> import('./view/Manage/AssetResourceBrowse'));
const AssetBrowse = loadable(()=> import('./view/Manage/AssetBrowse'));
......@@ -24,11 +23,10 @@ const DatasourceManage = loadable(()=> import('./view/Manage/DatasourceManage'))
const AssetDetailPage = loadable(()=> import('./view/Manage/AssetManage/Component/AssetDetailPage'));
const AssetDetail = loadable(()=> import('./view/Manage/AssetManage/Component/AssetDetail'));
const ImportAction = loadable(()=> import('./view/Manage/Model/Component/ImportAction'));
const EditModel = loadable(()=> import('./view/Manage/Model/Component/EditModel'));
const EditTemplate = loadable(()=> import('./view/Manage/ModelConfig/Component/EditTemplate'));
const AssetTree = loadable(()=> import('./view/Manage/AssetManage/Component/AssetManageTree'));
const DataMasterDefine = loadable(()=> import('./view/Manage/DataMaster/Define'));
const DataMasterManage = loadable(()=> import('./view/Manage/DataMaster/Manage'));
const DataService = loadable(()=> import('./view/Manage/Model'));
const DataServiceDetail = loadable(()=> import('./view/Manage/Model/Component/ServiceDetail'));
const GrantedDataServiceList = loadable(()=> import('./view/Manage/Model/Component/GrantedList'));
export class App extends React.Component {
constructor() {
......@@ -66,21 +64,6 @@ export class App extends React.Component {
id = hostParams.id||'';
terms = hostParams.terms||[];
}
if (message === 'showDataModelDetail') {
return (
<AppContext.Provider value={{
setGlobalState,
onGlobalStateChange
}}>
<ImportAction
modelerId={id}
action='detail'
terms={terms}
/>
</AppContext.Provider>
);
}
if (message === 'showAssetDetail') {
return (
......@@ -123,6 +106,57 @@ export class App extends React.Component {
);
}
if (message === 'showDataService' || message === 'showDataServiceManage') {
return (
<AppContext.Provider value={{
env: hostParams?.env,
user: hostParams?.user,
openAdmit: hostParams?.openAdmit,
openDetail: hostParams?.openDetail,
editServer: hostParams?.editServer,
applyServer: hostParams?.applyServer,
setGlobalState,
onGlobalStateChange
}}>
<DataService
isOnlyEnding={message==='showDataServiceManage'}
location={this.props.location}
/>
</AppContext.Provider>
);
}
if (message === 'showDataServiceDetail') {
return (
<AppContext.Provider value={{
setGlobalState,
onGlobalStateChange
}}>
<DataServiceDetail
id={id}
terms={terms}
/>
</AppContext.Provider>
);
}
if (message === 'showGrantedDataService') {
return (
<AppContext.Provider value={{
env: hostParams?.env,
user: hostParams?.user,
openAdmit: hostParams?.openAdmit,
openDetail: hostParams?.openDetail,
editServer: hostParams?.editServer,
applyServer: hostParams?.applyServer,
setGlobalState,
onGlobalStateChange
}}>
<GrantedDataServiceList/>
</AppContext.Provider>
);
}
return (
<AppContext.Provider value={{
env: hostParams?.env,
......@@ -135,29 +169,14 @@ export class App extends React.Component {
<Route path={`${ContextPath}/login`} component={Signin} exact />
<Route path={`${ContextPath}/home`} component={Home} />
<Route path={`${ContextPath}/manage`} component={Manage} />
<Route path={`${ContextPath}/data-model-action`} component={EditModel} exact />
<Route path={`${ContextPath}/model-template-action`} component={EditTemplate} exact />
<Route path={`${ContextPath}/asset-detail`} component={AssetDetailPage} exact />
<Route path={'/center-home/view/datasource-manage'} component={DatasourceManage} exact />
<Route path={'/center-home/view/data-model'} component={Model} exact />
<Route path={'/center-home/view/model-config'} component={ModelConfig} exact />
<Route path={'/center-home/view/asset-manage'} component={AssetManage} exact />
<Route path={'/center-home/view/asset-resource-browse'} component={AssetResourceBrowse} exact />
<Route path={'/center-home/view/asset-browse'} component={AssetBrowse} exact />
<Route path={'/center-home/view/asset-recycle'} component={AssetRecycle} exact />
<Route path={`${ContextPath}/asset-detail`} component={AssetDetailPage} exact />
<Route path={'/center-home/menu/datasource-manage'} component={DatasourceManage} exact />
<Route path={'/center-home/menu/data-model'} component={Model} exact />
<Route path={'/center-home/menu/model-config'} component={ModelConfig} exact />
<Route path={'/center-home/menu/asset-manage'} component={AssetManage} exact />
<Route path={'/center-home/menu/asset-resource-browse'} component={AssetResourceBrowse} exact />
<Route path={'/center-home/menu/asset-browse'} component={AssetBrowse} exact />
<Route path={'/center-home/menu/asset-recycle'} component={AssetRecycle} exact />
<Route path={'/center-home/menu/msd-define'} component={DataMasterDefine} exact />
<Route path={'/center-home/menu/msd-manage'} component={DataMasterManage} exact />
<Route path={'/center-home/data-model-action'} component={EditModel} exact />
<Route path={'/center-home/asset-detail'} component={AssetDetailPage} exact />
</Switch>
</Router>
......
......@@ -11,8 +11,9 @@ import * as datamodel from './datamodel';
import * as assetmanage from './assetmanage';
import * as tag from './tag';
import * as msd from './msd';
import * as pds from './pds';
const funcs = Connect({ user, datamodel, map, assetmanage, datasource, tag, msd })
const funcs = Connect({ user, datamodel, map, assetmanage, datasource, tag, msd, pds })
function* request(args) {
const { type, payload, callback, error } = args.args;
......
import * as pds from '../service/pds';
import { call } from 'redux-saga/effects';
export function* refreshCatalog(payload) {
return yield call(pds.refreshCatalog, payload);
}
export function* loadDataServiceCatalog() {
return yield call(pds.loadDataServiceCatalog)
}
export function* loadDataServiceCatalogServiceCount() {
return yield call(pds.loadDataServiceCatalogServiceCount)
}
export function* loadStateCatalog(payload) {
return yield call(pds.loadStateCatalog, payload);
}
export function* loadDataServiceStateCatalogServiceCount() {
return yield call(pds.loadDataServiceStateCatalogServiceCount)
}
export function* saveCatalog(payload) {
return yield call(pds.saveCatalog, payload);
}
export function* deleteCatalog(payload) {
return yield call(pds.deleteCatalog, payload);
}
export function* upDownCatalog(payload) {
return yield call(pds.upDownCatalog, payload);
}
export function* getServices(payload) {
return yield call(pds.getServices, payload);
}
export function* getGrantedServices(payload) {
return yield call(pds.getGrantedServices, payload)
}
export function* getStateServices(payload) {
return yield call(pds.getStateServices, payload)
}
export function* searchService(payload) {
return yield call(pds.searchService, payload)
}
export function* getDataService(payload) {
return yield call(pds.getDataService, payload)
}
export function* deleteService(payload) {
return yield call(pds.deleteService, payload);
}
export function* recatalogService(payload) {
return yield call(pds.recatalogService, payload);
}
export function* nextState(payload) {
return yield call(pds.nextState, payload);
}
export function* checkoutService(payload) {
return yield call(pds.checkoutService, payload);
}
export function* getCheckoutService(payload) {
return yield call(pds.getCheckoutService, payload)
}
export function* getServiceDigest(payload) {
return yield call(pds.getServiceDigest, payload)
}
export function* getVersions(payload) {
return yield call(pds.getVersions, payload)
}
export function* getDataServiceLocation(payload) {
return yield call(pds.getDataServiceLocation, payload)
}
export function* getSample(payload) {
return yield call(pds.getSample, payload)
}
export function* enableOData(payload) {
return yield call(pds.enableOData, payload)
}
export function* disableOData(payload) {
return yield call(pds.disableOData, payload)
}
export function* authorize(payload) {
return yield call(pds.authorize, payload)
}
export function* release(payload) {
return yield call(pds.release, payload)
}
export function* offline(payload) {
return yield call(pds.offline, payload);
}
export function* getSmartBiUrl(payload) {
return yield call(pds.getSmartBiUrl, payload)
}
export function* getOwners() {
return yield call(pds.getOwners)
}
export function* getDepartments() {
return yield call(pds.getDepartments)
}
export function* saveOwner(payload) {
return yield call(pds.saveOwner, payload)
}
export function* changeOwner(payload) {
return yield call(pds.changeOwner, payload)
}
export function* saveCols(payload) {
return yield call(pds.saveCols, payload);
}
export function* getCols(payload) {
return yield call(pds.getCols, payload);
}
export function* getAttrs(payload) {
return yield call(pds.getAttrs, payload);
}
export function* getJdbcInformation() {
return yield call(pds.getJdbcInformation);
}
export function* subscribe(payload) {
return yield call(pds.subscribe, payload);
}
export function* addImportWithConfirm(payload) {
return yield call(pds.addImportWithConfirm, payload);
}
export function* importConfirm(payload) {
return yield call(pds.importConfirm, payload);
}
export function* getImportLogs(payload) {
return yield call(pds.getImportLogs, payload);
}
export function* exportAll(payload) {
return yield call(pds.exportAll, payload);
}
\ No newline at end of file
......@@ -16,14 +16,6 @@ export const routes = [
text: '数据源管理',
},
{
name: 'data-model',
text: '模型设计',
},
{
name: 'model-config',
text: '模型配置',
},
{
name: 'asset-manage',
text: '资产管理',
},
......@@ -40,12 +32,8 @@ export const routes = [
text: '未挂载资产',
},
{
name: 'msd-define',
text: '主数据定义'
},
{
name: 'msd-manage',
text: '主数据管理'
name: 'data-service',
text: '服务管理',
},
]
}
......
import { PostFile, GetJSON, PostJSON, Post, Get, GetJSONRaw, callFetchRawByFormData, callFetchRaw } from "../util/axios"
import { ContextPath } from "../util";
export function refreshCatalog() {
return GetJSON("/pdataservice/pdsCURD/refreshDataServiceCatalog")
}
export function loadDataServiceCatalog() {
return GetJSON("/pdataservice/pdsCURD/loadDataServiceCatalog");
}
export function loadDataServiceCatalogServiceCount() {
return GetJSON("/pdataservice/pdsCURD/loadDataServiceCatalogServiceCount");
}
export function loadStateCatalog(payload) {
return GetJSON("/pdataservice/pdsCURD/loadDataServiceStateCatalog", payload)
}
export function loadDataServiceStateCatalogServiceCount() {
return GetJSON("/pdataservice/pdsCURD/loadDataServiceStateCatalogServiceCount");
}
export function saveCatalog(payload) {
return PostJSON("/pdataservice/pdsCURD/saveDataServiceCatalog", payload)
}
export function deleteCatalog(payload) {
return PostJSON("/pdataservice/pdsCURD/deleteDataServiceCatalog", payload)
}
export function upDownCatalog(payload) {
return GetJSON("/pdataservice/pdsCURD/upDownDataServiceCatalog", payload)
}
export function getServices(payload) {
return GetJSON("/pdataservice/pdsCURD/getCurrentDataServiceCatalog", payload)
}
export function getGrantedServices(payload) {
return GetJSON("/pdataservice/pdsCURD/getGrantedDataService", payload)
}
export function getStateServices(payload) {
return GetJSON("/pdataservice/pdsCURD/getCurrentDataServiceStateCatalog", payload)
}
export function searchService(payload) {
return GetJSON("/pdataservice/pdsCURD/searchPDSDataServicesByNaming", payload)
}
export function getDataService(payload) {
return GetJSON("/pdataservice/pdsCURD/getDataService", payload)
}
export function deleteService(payload) {
return PostJSON("/pdataservice/pdsCURD/deleteDataService", payload);
}
export function recatalogService(payload) {
return Post("/pdataservice/pdsCURD/recatalogDataService", payload);
}
export function nextState(payload) {
return GetJSON("/pdataservice/pdsCURD/nextState", payload);
}
export function checkoutService(payload) {
return PostJSON("/pdataservice/pdsCURD/checkOutDataService", payload)
}
export function getCheckoutService(payload) {
return GetJSON("/pdataservice/pdsCURD/getCheckoutDataService", payload)
}
export function getServiceDigest(payload) {
return GetJSON("/pdataservice/pdsCURD/getDataServiceDigest", payload)
}
export function getVersions(payload) {
return PostJSON("/pdataservice/pdsCURD/getVersions", payload)
}
export function getDataServiceLocation(payload) {
return GetJSON("/pdataservice/pdsCURD/getDataServiceLocation", payload)
}
export function getSample(payload) {
return PostJSON("/pdataservice/pdsCURD/getSample", payload)
}
export function enableOData(payload) {
return Post("/pdataservice/pdsOData/enableOData", payload)
}
export function disableOData(payload) {
return Post("/pdataservice/pdsOData/disableOData", payload)
}
export function authorize(payload) {
return PostJSON("/pdataservice/pdsWorkflow/kickoffAuthorize", payload)
}
export function release(payload) {
return PostJSON("/pdataservice/pdsWorkflow/kickoffRelease", payload)
}
export function offline(payload) {
return PostJSON("/pdataservice/pdsWorkflow/kickoffOffline", payload)
}
export function getSmartBiUrl(payload) {
return Get(`/${payload.url}`);
}
export function getOwners() {
return GetJSON("/informationmanagement/userData/findAll")
}
export function getDepartments() {
return GetJSON("/informationmanagement/userData/getAllDepartment")
}
export function saveOwner(payload) {
return GetJSON("/informationmanagement/userData/getUserDataAndInsert", payload);
}
export function changeOwner(payload) {
return PostJSON("/pdataservice/pdsCURD/changeOwnerOfDataService", payload)
}
export function saveCols(payload) {
return PostJSON("/pdataservice/pdsModel/saveVisibleTitle", payload);
}
export function getCols(payload) {
return GetJSON("/pdataservice/pdsModel/getVisibleTitle", payload);
}
export function getAttrs(payload) {
return GetJSON("/pdataservice/pdsModel/attrs", payload);
}
export function getJdbcInformation() {
return GetJSON('/pdataservice/pdsDriver/url');
}
export function subscribe(payload) {
return callFetchRawByFormData('post', '/pdataservice/pdsSub/subscribeMsg', payload);
}
export function addImportWithConfirm(payload) {
return PostFile("/pdataservice/pdsCURD/addWithConfirm", payload);
}
export function importConfirm(payload) {
return PostJSON("/pdataservice/pdsCURD/confirm", payload);
}
export function getImportLogs(payload) {
return GetJSON("/pdataservice/pdsCURD/log", payload);
}
export function exportAll(payload) {
return callFetchRaw('post', '/pdataservice/pdsCURD/export/all', payload)
}
\ No newline at end of file
......@@ -177,3 +177,47 @@ export function PostFile(url, payload, fileName='file') {
callback
)
}
export const callFetchRaw = (method, url, options) => {
const { params, ...reqConfig } = options;
const config = {
baseURL,
timeout: 300000,
cache: 'no-cache',
}
return axios.request({
method,
url,
params,
...config,
...reqConfig
})
}
export const callFetchRawByFormData = (method, url, options) => {
const { params, ...reqConfig } = options;
const config = {
baseURL,
timeout: 300000,
headers: {
'Content-Type': 'multipart/form-data',
},
cache: 'no-cache',
}
var bodyFormData = new FormData();
Object.keys(params||{}).forEach(key => {
bodyFormData.append(key, params[key]);
});
return axios.request({
method,
url,
data: bodyFormData,
...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
import { useEffect, useMemo, useState } from 'react';
import { Space, Button, Input, Pagination, Tooltip } from 'antd';
import { useContextMenu, Menu as RcMenu, Item as RcItem } from "react-contexify";
import ResizeableTable from '../../../ResizeableTable';
import DebounceInput from '../../../Model/Component/DebounceInput';
import { UpdateTemplateModal } from './UpdateTemplateModal';
import { inputWidth, showMessage } from '../../../../../util';
import './DefineTable.less';
import 'react-contexify/dist/ReactContexify.css';
import { dispatch } from '../../../../../model';
const InputDebounce = DebounceInput(300)(Input);
const DefineTable = (props) => {
const {nodeId} = props;
const [keyword, setKeyword] = useState('');
const [checkedKeys, setCheckedKeys] = useState([]);
const [isTemplateModalVisible, setIsTemplateModalVisible] = useState(false);
const [currentTemplate, setCurrentTemplate] = useState({});
const [action, setAction] = useState('');
const [loading, setLoading] = useState(false);
const [deleteLoading, setDeleteLoading] = useState(false);
const [tableData, setTableData] = useState([]);
const [total, setTotal] = useState(0);
const [pagination, setPagination] = useState({pageNum: 1, pageSize: 20});
const {pageNum, pageSize} = pagination;
useEffect(() => {
setCheckedKeys([]);
setPagination({...pagination, pageNum: 1});
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [nodeId])
useEffect(() => {
if (!nodeId || nodeId==='') {
setTableData([]);
setTotal(0);
} else {
getTemplates();
}
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [keyword, pagination])
const columns = useMemo(() => {
return ([
{
title: '序号',
dataIndex: 'key',
render: (text, record, index) => {
return (index+1).toString();
},
width: 60,
ellipsis: true,
},
{
title: '模版名称',
dataIndex: 'name',
width: 200,
ellipsis: true,
render: (text, record, index) => {
return <a onClick={() => {onItemClick(record);}}>{text}</a>
},
},
{
title: '模版中文名称',
dataIndex: 'cnName',
width: 200,
ellipsis: true,
},
{
title: '修改时间',
dataIndex: 'lastUpdateTime',
width: 200,
ellipsis: true,
},
{
title: '模版描述',
dataIndex: 'comment',
width: 200,
ellipsis: true,
}
]);
}, []);
const MENU_ID = 'data-master-table-contextmenu';
const { show } = useContextMenu({
id: MENU_ID,
});
const getTemplates = () => {
setLoading(true);
dispatch({
type: 'msd.getModels',
payload: {
params: {
nodeId,
keyword,
pageNum,
pageSize
}
},
callback: (data) => {
setLoading(false);
setTableData(data?.content||[]);
setTotal(data?.totalElements||0);
},
error: () => {
setLoading(false);
}
});
}
const onAddClick = () => {
setAction('add');
setCurrentTemplate(null);
setIsTemplateModalVisible(true);
}
const onItemClick = (record) => {
setAction('detail');
setCurrentTemplate(record);
setIsTemplateModalVisible(true);
}
const onTemplateModalCancel = (refresh = false) => {
setIsTemplateModalVisible(false);
if (refresh) {
getTemplates();
}
}
const onBatchDeleteClick = () => {
setDeleteLoading(true);
dispatch({
type: 'msd.deleteModels',
payload: {
params: {
modelIds: (checkedKeys||[]).join(',')
}
},
callback: (data) => {
setDeleteLoading(false);
showMessage('success', '删除成功');
getTemplates();
},
error: () => {
setDeleteLoading(false);
}
});
}
const onSearchInputChange = (value) => {
setKeyword(value);
}
const onTableSelectChange = keys => {
setCheckedKeys(keys);
};
const handleItemClick = ({ event, props, data, triggerEvent }) => {
const key = event.currentTarget.id;
if (key === 'update') {
setAction('update');
setIsTemplateModalVisible(true);
}
}
const changeCurrent = (page,size) => {
setCheckedKeys([]);
setPagination({ pageNum: page, pageSize: size });
}
const rowSelection = {
selectedRowKeys: checkedKeys,
onChange: onTableSelectChange,
};
return (
<div className='data-master-table'>
<div className='data-master-header px-3'>
<Space>
<Space>
<Button onClick={onAddClick}>新建</Button>
</Space>
<Space>
<Tooltip title={(checkedKeys||[]).length===0?'请先选择模版':''}>
<Button onClick={onBatchDeleteClick} disabled={(checkedKeys||[]).length===0} loading={deleteLoading}>删除</Button>
</Tooltip>
</Space>
</Space>
<InputDebounce
placeholder="请输入关键字"
allowClear
value={keyword}
onChange={onSearchInputChange}
style={{ width: inputWidth, marginLeft: 'auto' }}
/>
</div>
<div className='data-master-content p-3'>
<ResizeableTable
loading={loading}
rowKey='_id'
rowSelection={rowSelection}
columns={columns}
dataSource={tableData}
onRow={(record) => {
return {
onContextMenu: event => {
setCurrentTemplate(record);
show(event);
},
};
}}
pagination={false}
scroll={{ y: 'calc(100vh - 94px - 32px - 57px - 24px - 39px - 36px)' }}
/>
<Pagination
size="small"
className="text-center mt-3"
showSizeChanger
showQuickJumper
onChange={changeCurrent}
onShowSizeChange={changeCurrent}
current={pageNum}
pageSize={pageSize}
defaultCurrent={1}
total={total}
showTotal={total => `共 ${total} 条`}
/>
</div>
<UpdateTemplateModal
action={action}
nodeId={nodeId}
template={currentTemplate}
visible={isTemplateModalVisible}
onCancel={onTemplateModalCancel}
/>
<RcMenu id={MENU_ID}>
<RcItem id="update" onClick={handleItemClick}>
编辑
</RcItem>
</RcMenu>
</div>
);
}
export default DefineTable;
\ No newline at end of file
.data-master-table {
height: 100%;
.data-master-header {
display: flex;
flex: none;
height: 57px;
border-bottom: 1px solid #EFEFEF;
justify-content: space-between;
align-items: center;
}
}
\ No newline at end of file
import {useEffect, useMemo, useState, useRef} from 'react';
import {Tooltip, Spin, AutoComplete, Tree, Modal} from 'antd';
import {PlusOutlined, ReloadOutlined} from '@ant-design/icons';
import { useContextMenu, Menu as RcMenu, Item as RcItem } from "react-contexify";
import { dispatch } from '../../../../../model';
import {highlightSearchContentByTerms, showMessage} from '../../../../../util';
import UpdateDefineTreeNodeModal from './UpdateDefineTreeNodeModal';
import 'react-contexify/dist/ReactContexify.css';
import './DefineTree.less';
const {Option} = AutoComplete;
const DefineTree = (props) => {
const {onClick} = props;
const [loading, setLoading] = useState(false);
const [data, setData] = useState();
const [options, setOptions] = useState([]);
const [keyword, setKeyword] = useState('');
const [expandedKeys, setExpandedKeys] = useState([]);
const [selectedKeys, setSelectedKeys] = useState([]);
const [autoExpandParent, setAutoExpandParent] = useState(false);
const [updateNodeModalVisible, setUpdateNodeModalVisible] = useState(false);
const [updateNodeType, setUpdateNodeType] = useState('');
const [rightSelectNode, setRightSelectNode] = useState({});
const selectedKeysRef = useRef([]);
const [modal, contextHolder] = Modal.useModal();
const MENU_ID = 'msd-define-tree';
const { show } = useContextMenu({
id: MENU_ID,
});
useEffect(() => {
getTreeNodes();
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
const treeData = useMemo(() => {
const loop = (data) =>
(data||[]).map((item) => {
if (item.children) {
return {
title: item.name||'',
key: item._id||'',
origin: item,
children: loop(item.children),
};
}
return {
title: item.name||'',
key: item._id||'',
};
});
return loop(data);
}, [data])
const treeList = useMemo(() => {
const generateList = (data, list, path = null) => {
(data||[]).forEach(node => {
const {_id, name} = node;
const currentPath = path ? `${path}/${name}` : name;
list.push({key: _id, title: currentPath});
if (node.children) {
generateList(node.children, list, currentPath);
}
});
};
const newTreeList = [];
generateList(data, newTreeList);
return newTreeList;
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [data])
const selectNode = useMemo(() => {
const generateList = (data, list) => {
(data||[]).forEach(node => {
list.push({...node});
if (node.children) {
generateList(node.children, list);
}
});
};
const newTreeList = [];
generateList(data, newTreeList);
const filterNodes = newTreeList.filter(item => selectedKeys.indexOf(item._id)!==-1);
return (filterNodes||[]).length>0 ? filterNodes[0]:{};
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [data, selectedKeys])
const getTreeNodes = () => {
setLoading(true);
dispatch({
type: 'msd.getTreeNodes',
callback: (data) => {
setLoading(false);
setData(data||[]);
if ((selectedKeysRef.current||[]).length===0 && (data||[]).length>0) {
onTreeSelect([data[0]._id]);
}
if ((expandedKeys||[]).length===0 && (data||[]).length>0) {
setExpandedKeys([data[0]._id]);
} else {
setExpandedKeys(Array.from(new Set([...expandedKeys, ...selectedKeysRef.current])));
setAutoExpandParent(true);
}
},
error: () => {
setLoading(false);
}
})
}
const onAddClick = () => {
setUpdateNodeType('add');
setUpdateNodeModalVisible(true);
}
const onRefreshClick = () => {
getTreeNodes();
}
const updateNode = () => {
setUpdateNodeType('update');
setUpdateNodeModalVisible(true);
}
const upOrDownNode = (steps = 1) => {
setLoading(true);
dispatch({
type: 'msd.treeNodeSeq',
payload: {
params: {
id: rightSelectNode?._id||'',
steps
}
},
callback: () => {
rightSelectNode?._id && onTreeSelect([rightSelectNode?._id]);
getTreeNodes();
},
error: () => {
setLoading(false);
}
})
}
const deleteNode = () => {
modal.confirm({
title: '提示!',
content: '删除目录会删除相关的模版,您确定删除吗?',
onOk: () => {
setLoading(true);
dispatch({
type: 'msd.deleteTreeNode',
payload: {
params: {
nodeId: rightSelectNode?._id
}
},
callback: () => {
showMessage('success', '删除目录成功');
setLoading(false);
if (selectedKeysRef.current.indexOf(rightSelectNode?._id)!==-1) {
setSelectedKeys([]);
selectedKeysRef.current = [];
}
getTreeNodes();
},
error: () => {
setLoading(false);
}
});
}
});
}
const onAutoCompleteSearch = (searchText) => {
setKeyword(searchText);
setOptions(treeList.filter(item => item.title.indexOf(searchText)!==-1));
};
const onAutoCompleteSelect = (value, option) => {
const paths = value.split('/');
setKeyword(paths[paths.length-1]);
onTreeSelect([option.key]);
setExpandedKeys(Array.from(new Set([...expandedKeys, option.key])));
setAutoExpandParent(true);
};
const onAutoCompleteClear = () => {
setKeyword('');
}
const onTreeExpand = (expandedKeys) => {
setExpandedKeys(expandedKeys);
setAutoExpandParent(false);
}
const onTreeSelect = (selectedKeys) => {
if (selectedKeys.length === 0) {
return;
}
setSelectedKeys(selectedKeys);
selectedKeysRef.current = selectedKeys;
onClick && onClick(selectedKeys[0]);
}
const onUpdateNodeModalCancel = (refresh = false, nodeId = null) => {
setUpdateNodeModalVisible(false);
if (refresh) {
nodeId && onTreeSelect([nodeId]);
getTreeNodes();
}
}
return (
<div className='data-master-tree'>
<div className='header p-3'>
<Tooltip title="新增目录">
<PlusOutlined
className='default'
onClick={onAddClick}
style={{
fontSize:16,
cursor:'pointer',
flex: 1
}}
/>
</Tooltip>
<Tooltip title="刷新目录" className='ml-2'>
<ReloadOutlined
className='default'
onClick={onRefreshClick}
style={{
fontSize:16,
cursor:'pointer',
flex: 1
}}
/>
</Tooltip>
<div style={{flex: 3}} />
</div>
<div className='content p-3'>
<Spin spinning={loading}>
<AutoComplete
className='content-search'
allowClear
value={keyword}
onSelect={onAutoCompleteSelect}
onSearch={onAutoCompleteSearch}
onClear={onAutoCompleteClear}
>
{
(options||[]).map((item, index) => {
return (
<Option key={item.key} value={item.title}>
<div style={{ whiteSpace: 'normal' }}>
{highlightSearchContentByTerms(item.title, [keyword])}
</div>
</Option>
);
})
}
</AutoComplete>
<Tree
className='content-tree'
showLine
showIcon={false}
autoExpandParent={autoExpandParent}
treeData={treeData}
onExpand={onTreeExpand}
onSelect={onTreeSelect}
expandedKeys={expandedKeys}
selectedKeys={selectedKeys}
onRightClick={({event, node}) => {
setRightSelectNode(node?.origin);
show(event, {
position: {
x: event.clientX + 30,
y: event.clientY - 10
}
});
}}
/>
</Spin>
</div>
<UpdateDefineTreeNodeModal
visible={updateNodeModalVisible}
onCancel={onUpdateNodeModalCancel}
type={updateNodeType}
node={(updateNodeType==='add')?selectNode:rightSelectNode}
/>
<RcMenu id={MENU_ID}>
<RcItem id="edit" onClick={updateNode}>
修改目录
</RcItem>
<RcItem id="up" onClick={() => { upOrDownNode(-1); }}>
上移目录
</RcItem>
<RcItem id="down" onClick={() => { upOrDownNode(1); }}>
下移目录
</RcItem>
<RcItem id="delete" onClick={deleteNode}>
删除目录
</RcItem>
</RcMenu>
{contextHolder}
</div>
);
}
export default DefineTree;
\ No newline at end of file
@import '../../../../../variables.less';
.data-master-tree {
height: 100%;
.header {
display: inline-flex;
flex: none;
width: 100%;
height: 57px;
justify-content: flex-start;
align-items: center;
border-bottom: 1px solid #EFEFEF;
}
.content-search {
margin-bottom: 10px;
width: 100%;
}
.content-tree {
height: calc(100vh - @header-height - @breadcrumb-height - 25px - 57px - 66px);
overflow: auto;
}
}
\ No newline at end of file
import { Form, Input, Row, Col, Descriptions } from "antd";
const { TextArea } = Input;
const UpdateBasicInfo = (props) => {
const {form, editable, template} = props;
const formItemLayout = {
labelCol: {
xs: { span: 24 },
sm: { span: 6 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 18 },
},
};
return (
<div>
<h3>基本信息</h3>
{
editable ? <Form
form={form}
{...formItemLayout}
>
<Row gutter={10}>
<Col xs={24} sm={24} lg={12}>
<Form.Item label='中文名称' name='cnName' rules={[{ required: true, message: '请填写模版中文名称' }]}>
<Input />
</Form.Item>
</Col>
<Col xs={24} sm={24} lg={12}>
<Form.Item label='英文名称' name='name' rules={[{ required: true, message: '请填写模版名称' }]}>
<Input />
</Form.Item>
</Col>
<Col xs={24} sm={24} lg={12}>
<Form.Item label='模版描述' name='comment'>
<TextArea row={4} />
</Form.Item>
</Col>
</Row>
</Form> : <Descriptions column={2}>
<Descriptions.Item label={<div style={{ textAlign: 'right', width: 85 }}>中文名称</div>} >{template?.cnName||''}</Descriptions.Item>
<Descriptions.Item label={<div style={{ textAlign: 'right', width: 85 }}>英文名称</div>}>{template?.name||''}</Descriptions.Item>
<Descriptions.Item label={<div style={{ textAlign: 'right', width: 85 }}>模版描述</div>}>{template?.comment||''}</Descriptions.Item>
</Descriptions>
}
</div>
);
}
export default UpdateBasicInfo;
\ No newline at end of file
import { useState, useEffect } from 'react';
import { Modal, Form } from 'antd';
import UpdateNodeForm from './UpdateNodeForm';
import { dispatch } from '../../../../../model';
const UpdateDefineTreeNodeModal = (props) => {
const {visible, onCancel, type, node} = props;
const [confirmLoading, setConfirmLoading] = useState(false);
const [form] = Form.useForm();
useEffect(() => {
if (visible) {
if (type === 'add') {
form.setFieldsValue({action: node ? 'sub' : 'root', name: '', comment: ''});
} else {
form.setFieldsValue({action: '', name: node?.name||'', comment: node?.comment||''});
}
}
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [visible, node, type])
const handleCancel = () => {
setConfirmLoading(false);
form.setFields([{ name: 'name', errors: [] }, { name: 'comment', errors: [] }]);
onCancel && onCancel();
}
const handleOk = async () => {
setConfirmLoading(true);
try {
const values = await form.validateFields();
let payload = null;
if (type === 'add') {
payload = {
name: values.name||'',
comment: values.comment||'',
parentId: (values.action==='root')?'root':node?._id
};
} else {
payload = {
...node,
name: values.name||'',
comment: values.comment||'',
}
}
let url = (type === 'add')?'msd.addTreeNode':'msd.updateTreeNode';
dispatch({
type: url,
payload: {
data: payload
},
callback: id => {
setConfirmLoading(false);
onCancel && onCancel(true, id);
},
error: () => {
setConfirmLoading(false);
}
});
} catch (errInfo) {
setConfirmLoading(false);
}
}
return (
<Modal
confirmLoading={confirmLoading}
visible={visible}
title={type==='add'?"新增目录":"更新目录"}
onOk={handleOk}
onCancel={handleCancel}
>
<UpdateNodeForm type={type} node={node} form={form} />
</Modal>
);
}
export default UpdateDefineTreeNodeModal;
\ No newline at end of file
import { useMemo } from "react";
import { Form, Input, Radio } from 'antd';
const UpdateNodeForm = (props) => {
const {form, type, node} = props;
const radioDisable = useMemo(() => {
return !node;
}, [node])
const formItemLayout = {
labelCol: {
xs: { span: 24 },
sm: { span: 6 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 18 },
},
};
return (
<Form
{...formItemLayout}
form={form}
>
{
type==='add'&&<Form.Item label="目录类型" name="action">
<Radio.Group disabled={radioDisable} >
<Radio value='root'>根目录</Radio>
<Radio value='sub'>子目录</Radio>
</Radio.Group>
</Form.Item>
}
<Form.Item
label="名称"
name="name"
rules={[{ required: true, message: '请输入名称!' }]}
>
<Input />
</Form.Item>
<Form.Item
label="描述"
name="comment"
rules={[{ required: true, message: '请输入描述!' }]}
>
<Input />
</Form.Item>
</Form>
);
}
export default UpdateNodeForm;
\ No newline at end of file
import React, { useEffect, useMemo, useRef, useState } from 'react';
import { Modal, Form, Button } from "antd";
import UpdateBasicInfo from "./UpdateBasicInfo";
import UpdateField from "./UpdateField";
import { showMessage } from '../../../../../util';
import { dispatch } from '../../../../../model';
import './UpdateTemplateModal.less';
export const EditTemplateContext = React.createContext({
attrIsEditingFunction: null,
});
export const UpdateTemplateModal = (props) => {
const { visible, onCancel, action = 'add', template, nodeId } = props;
const [form] = Form.useForm();
const [fields, setFields] = useState([]);
const [confirmLoading, setConfirmLoading] = useState(false);
const attrIsEditingRef = useRef(false);
useEffect(() => {
if (visible) {
form?.setFieldsValue({name: template?.name||'', cnName: template?.cnName||'', comment: template?.comment||''});
setFields([]);
}
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [visible])
const title = useMemo(() => {
if (action === 'add') {
return '新建模版';
}
if (action === 'detail') {
return '模版详情';
}
if (action === 'update') {
return '编辑模版';
}
return '';
}, [action])
const attrIsEditingFunction = (value) => {
attrIsEditingRef.current = value;
}
const onFieldChange = (values) => {
setFields(values);
}
const save = (e) => {
e.stopPropagation();
if (attrIsEditingRef.current) {
showMessage("warn", '还有字段正在编辑,需先保存该字段!');
} else {
saveLogic();
}
}
const saveLogic = async () => {
try {
const row = await form.validateFields();
if ((fields||[]).length === 0) {
showMessage('warn', '请新增字段');
return;
}
setConfirmLoading(true);
let url = '', newTemplate = {};
if (action === 'add') {
url = 'msd.addModel';
newTemplate = {...row, nodeId: nodeId||''};
} else {
url = 'msd.updateModel';
newTemplate = {...template, ...row}
}
dispatch({
type: url,
payload: {
data: newTemplate
},
callback: id => {
(fields||[]).forEach((field, index) => {
field.parentId = id;
field.seq = index;
});
dispatch({
type: 'msd.saveColumns',
payload: {
params: {
modelId: id
},
data: fields
},
callback: () => {
setConfirmLoading(false);
onCancel && onCancel(true);
},
error: () => {
setConfirmLoading(false);
}
});
},
error: () => {
setConfirmLoading(false);
}
});
} catch (errInfo) {
console.log('Validate Failed:', errInfo);
}
}
return (
<EditTemplateContext.Provider value={{
attrIsEditingFunction,
}}>
<Modal
forceRender
className='update-template-modal'
width='80%'
title={title}
visible={visible}
onCancel={() => {onCancel && onCancel();}}
onOk={save}
footer={[
<Button key="cancel" onClick={() => {onCancel && onCancel();}}>
取消
</Button>,
action!=='detail' && <Button
key="ok"
type="primary"
loading={confirmLoading}
onClick={save}
>
确定
</Button>,
]}
>
<UpdateBasicInfo form={form} editable={action!=='detail'} template={template} />
<UpdateField editable={action!=='detail'} template={template} onChange={onFieldChange} visible={visible} />
</Modal>
</EditTemplateContext.Provider>
);
}
.update-template-modal {
.yy-modal-body {
max-height: 70vh;
overflow: auto;
}
.dynamic-delete-button {
position: relative;
top: 4px;
margin: 0 8px;
color: #999;
font-size: 24px;
cursor: pointer;
transition: all 0.3s;
}
.dynamic-delete-button:hover {
color: #777;
}
}
\ No newline at end of file
import { useMemo, useState } from 'react';
import classNames from 'classnames';
import { ResizableBox } from 'react-resizable';
import { CaretLeftOutlined, CaretRightOutlined } from '@ant-design/icons';
import DefineTree from './Component/DefineTree';
import DefineTable from './Component/DefineTable';
import './index.less';
const DataMasterDefine = (props) => {
const [collapse, setCollapse] = useState(false);
const [nodeId, setNodeId] = useState('');
const classes = useMemo(() => {
return classNames('data-master', {
'data-master-collapse': collapse,
});
}, [collapse]);
const onTreeClick = (value) => {
setNodeId(value);
}
const onCollapseClick = () => {
setCollapse(!collapse);
}
return (
<div className={classes}>
<ResizableBox
className='left-wrap'
width={230}
height={Infinity}
axis='x'
minConstraints={[230, Infinity]} maxConstraints={[Infinity, Infinity]}
>
<DefineTree onClick={onTreeClick} />
</ResizableBox>
<div className='left-collapse-wrap'>
<div className='left-collapse' onClick={onCollapseClick}>
{ collapse ? <CaretRightOutlined /> : <CaretLeftOutlined /> }
</div>
</div>
<div className='right-wrap'>
<DefineTable nodeId={nodeId} />
</div>
</div>
)
}
export default DataMasterDefine;
\ No newline at end of file
.data-master {
display: flex;
flex: auto;
height: 100%;
background-color: #fff;
.left-wrap {
flex: none;
overflow: hidden;
height: 100%;
border-right: 1px solid #EFEFEF;
}
.left-collapse-wrap {
flex: none;
position: relative;
width: 20px;
height: 100%;
.left-collapse {
display: inline-flex;
justify-content: center;
align-items: center;
left: 0;
right: 0;
background: #f2f5fc;
position: absolute;
top: calc(50% - 40px);
width: 12px;
height: 80px;
border-radius: 0 12px 12px 0;
-ms-transform: translateY(-50%);
transform: translateY(-50%);
cursor: pointer;
}
}
.right-wrap {
flex: 1;
overflow: hidden;
height: 100%;
}
}
.data-master-collapse {
.left-wrap {
width: 0 !important;
}
}
\ No newline at end of file
import React, { useState, useEffect } from 'react';
import { Button, Upload, Drawer, Pagination, Form, Spin } from 'antd';
import { UploadOutlined, DownloadOutlined } from '@ant-design/icons';
import ResizeableTable from '../../../ResizeableTable';
import { dispatch, dispatchLatest } from '../../../../../model';
import { showMessage, formatDate } from '../../../../../util';
const ExpandedRow = (props) => {
const {data} = props;
const [loading, setLoading] = useState(false);
const [log, setLog] = useState({});
useEffect(() => {
getLog();
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [data])
const getLog = () => {
setLoading(true);
dispatch({
type: 'msd.importLog',
payload: {
logId: data?.id
},
callback: data => {
setLoading(false);
setLog(data||{});
},
error: () => {
setLoading(false);
}
})
}
return <Spin spinning={loading}>
<p style={{ margin: 0 }}>{log?.message||''}</p>
</Spin>
}
const ImportDataDrawer = (props) => {
const { onCancel, onSuccess, visible, nodeId } = props;
const [ fileList, setFileList ] = useState([]);
const [ confirmLoading, setConfirmLoading ] = useState(false);
const [ loading, setLoading ] = useState(false);
const [ logs, setLogs ] = useState([]);
const [ pagination, setPagination ] = useState( { pageNum: 1, pageSize: 20 } );
const { pageNum, pageSize } = pagination;
const [ total, setTotal ] = useState(0);
const columns = [
{
title: '序号',
dataIndex: 'key',
render: (text, record, index) => {
return (index+1).toString();
},
width: 60,
ellipsis: true,
},
{
title: '开始时间',
dataIndex: 'startTime',
width: 170,
ellipsis: true,
render: (_, record, __) => {
return formatDate(record.startTime);
}
},
{
title: '结束时间',
dataIndex: 'endTime',
width: 170,
ellipsis: true,
render: (_, record, __) => {
return formatDate(record.endTime);
}
},
{
title: '耗时',
dataIndex: 'costTime',
width: 100,
ellipsis: true,
render: (_, record, __) => {
return record.costTime?`${Number(record.costTime/1000)}秒`:'';
}
},
{
title: '导入人',
dataIndex: 'operator',
width: 100,
ellipsis: true,
render: (text, record, __) => {
return text.split(':')[0];
}
},
{
title: '导入状态',
dataIndex: 'state',
width: 100,
ellipsis: true,
}
]
useEffect(() => {
if (visible) {
setPagination({ pageNum: 1, pageSize: 20 });
}
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [visible])
useEffect(() => {
if (visible) {
getLogs();
}
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [pagination])
const getLogs = () => {
setLoading(true);
dispatch({
type: 'msd.importLogs',
payload: {
modelId: nodeId,
page: pageNum,
size: pageSize
},
callback: data => {
setLoading(false);
setTotal(data.totalElements);
setLogs(data.content||[]);
},
error: () => {
setLoading(false);
}
})
}
const onRefreshClick = () => {
getLogs();
}
const changeCurrent = (page,size) => {
setPagination({ pageNum: page, pageSize: size });
}
const downloadTemplate = () => {
window.open(`/api/metadatarepo/rest/msdMgr/exportTemplate?modelId=${nodeId}`);
}
const uploadProps = {
onRemove: file => {
const index = fileList.indexOf(file);
const newFileList = fileList.slice();
newFileList.splice(index, 1);
setFileList(newFileList);
},
beforeUpload: file => {
setFileList([file]);
return false;
},
fileList: fileList || [],
accept: ".xlsx",
};
const handleOk = () => {
if ((fileList || []).length === 0) {
showMessage('info', '请先选择Excel文件上传');
return;
}
setConfirmLoading(true);
dispatchLatest({
type: 'msd.importData',
payload: {
params: {
modelId: nodeId,
},
fileList
},
callback: data => {
setConfirmLoading(false);
setFileList([]);
getLogs();
onSuccess && onSuccess();
},
error: () => {
setConfirmLoading(false);
}
})
}
const reset = () => {
setConfirmLoading(false);
setFileList([]);
}
return (
<Drawer
forceRender
visible={ visible }
title='主数据导入'
width={1000}
placement="right"
closable={ true }
onClose={() => {
reset();
onCancel && onCancel();
}}
>
<div className='mt-3'>
<Form layout='inline'>
<Form.Item label='Excel上传:'>
<Upload style={{ display: 'inline' }} {...uploadProps }>
<Button icon={
<UploadOutlined />}>
选择文件上传
</Button>
</Upload>
</Form.Item>
<Form.Item>
<Button type='primary' onClick={handleOk} loading={confirmLoading}>确定导入</Button>
</Form.Item>
<Form.Item>
<Button icon={<DownloadOutlined />} onClick={downloadTemplate }>
模版下载
</Button>
</Form.Item>
</Form>
</div>
<div className='d-flex my-3' style={{ justifyContent: 'space-between', alignItems: 'center' }}>
<h3 style={{ marginBottom: 0 }}>导入日志</h3>
<Button onClick={onRefreshClick}>刷新</Button>
</div>
<ResizeableTable
className='mt-3'
columns={columns}
rowKey={'id'}
dataSource={logs||[]}
pagination={false}
loading={loading}
expandable={{
expandedRowRender: record => <ExpandedRow data={record} />
}}
sticky
/>
<Pagination
className="text-center mt-3"
showSizeChanger
showQuickJumper
onChange={changeCurrent}
onShowSizeChange={changeCurrent}
current={pageNum}
pageSize={pageSize}
defaultCurrent={1}
total={total}
pageSizeOptions={[10,20]}
showTotal={total => `共 ${total} 条`}
/>
</Drawer>
)
}
export default ImportDataDrawer;
\ No newline at end of file
import { useMemo, useState, useEffect } from 'react';
import { Space, Button, Input, Pagination, Tooltip } from 'antd';
import { useContextMenu, Menu as RcMenu, Item as RcItem } from "react-contexify";
import ResizeableTable from '../../../ResizeableTable';
import DebounceInput from '../../../Model/Component/DebounceInput';
import UpdateDataMasterModal from './UpdateDataMasterModal';
import ImportDataDrawer from './ImportDataDrawer';
import { inputWidth, showMessage } from '../../../../../util';
import { dispatch } from '../../../../../model';
import '../../Define/Component/DefineTable.less';
import 'react-contexify/dist/ReactContexify.css';
const InputDebounce = DebounceInput(300)(Input);
const ManageTable = (props) => {
const {nodeId} = props;
const [keyword, setKeyword] = useState('');
const [checkedKeys, setCheckedKeys] = useState([]);
const [isDataMasterModalVisible, setIsDataMasterModalVisible] = useState(false);
const [currentData, setCurrentData] = useState(null);
const [action, setAction] = useState('');
const [loading, setLoading] = useState(false);
const [deleteLoading, setDeleteLoading] = useState(false);
const [fields, setFields] = useState([]);
const [tableData, setTableData] = useState([]);
const [total, setTotal] = useState(0);
const [pagination, setPagination] = useState({pageNum: 1, pageSize: 20});
const [importDataDrawerVisible, setImportDataDrawerVisible] = useState(false);
const {pageNum, pageSize} = pagination;
const columns = useMemo(() => {
const newColumns = [
{
title: '序号',
dataIndex: 'key',
render: (text, record, index) => {
return (index+1).toString();
},
width: 60,
ellipsis: true,
}
];
(fields||[]).forEach(item => {
newColumns.push({
title: item.name,
dataIndex: item.name,
width: 200,
ellipsis: true,
});
})
return newColumns;
}, [fields]);
const MENU_ID = 'data-master-manage-table-contextmenu';
const { show } = useContextMenu({
id: MENU_ID,
});
useEffect(() => {
setCheckedKeys([]);
setPagination({...pagination, pageNum: 1});
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [nodeId])
useEffect(() => {
if (!nodeId || nodeId==='') {
setFields([]);
setTableData([]);
setTotal(0);
} else {
getFiledsAndDatas();
}
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [keyword, pagination])
const getFiledsAndDatas = () => {
setLoading(true);
dispatch({
type: 'msd.getColumns',
payload: {
params: {
modelId: nodeId
}
},
callback: (data) => {
setFields(data||[]);
const newKeyList = [];
(data||[]).forEach(item => {
newKeyList.push(item.name||'');
});
dispatch({
type: 'msd.getDatas',
payload: {
params: {
modelId: nodeId,
keyList: newKeyList.join(','),
keyword,
pageNum,
pageSize
}
},
callback: (data) => {
setLoading(false);
setTableData(data?.content||[]);
setTotal(data?.totalElements||0);
},
error: () => {
setLoading(false);
}
});
},
error: () => {
setLoading(false);
}
});
}
const onAddClick = () => {
setAction('add');
setCurrentData(null);
setIsDataMasterModalVisible(true);
}
const onImportClick = () => {
setImportDataDrawerVisible(true);
}
const onDataMasterModalCancel = (refresh = false) => {
setIsDataMasterModalVisible(false);
if (refresh) {
getFiledsAndDatas();
}
}
const onBatchDeleteClick = () => {
setDeleteLoading(true);
dispatch({
type: 'msd.deleteDatas',
payload: {
data: checkedKeys||[]
},
callback: (data) => {
setDeleteLoading(false);
showMessage('success', '删除成功');
getFiledsAndDatas();
},
error: () => {
setDeleteLoading(false);
}
});
}
const onSearchInputChange = (value) => {
setKeyword(value);
}
const onTableSelectChange = keys => {
setCheckedKeys(keys);
};
const handleItemClick = ({ event, props, data, triggerEvent }) => {
const key = event.currentTarget.id;
if (key === 'detail') {
setAction('detail');
setIsDataMasterModalVisible(true);
} if (key === 'update') {
setAction('update');
setIsDataMasterModalVisible(true);
}
}
const changeCurrent = (page,size) => {
setCheckedKeys([]);
setPagination({ pageNum: page, pageSize: size });
}
const onImportDataDrawerCancel = () => {
setImportDataDrawerVisible(false);
}
const onImportDataSuccess = () => {
getFiledsAndDatas();
}
const rowSelection = {
selectedRowKeys: checkedKeys,
onChange: onTableSelectChange,
};
return (
<div className='data-master-table'>
<div className='data-master-header px-3'>
<Space>
<Space>
<Button onClick={onAddClick}>新建</Button>
</Space>
<Space>
<Button onClick={onImportClick}>导入</Button>
</Space>
<Space>
<Tooltip title={(checkedKeys||[]).length===0?'请先选择主数据':''}>
<Button onClick={onBatchDeleteClick} disabled={(checkedKeys||[]).length===0} loading={deleteLoading}>删除</Button>
</Tooltip>
</Space>
</Space>
<InputDebounce
placeholder="请输入关键字"
allowClear
value={keyword}
onChange={onSearchInputChange}
style={{ width: inputWidth, marginLeft: 'auto' }}
/>
</div>
<div className='data-master-content p-3'>
<ResizeableTable
rowKey='_id'
loading={loading}
rowSelection={rowSelection}
columns={columns}
dataSource={tableData}
onRow={(record) => {
return {
onContextMenu: event => {
setCurrentData(record);
show(event);
},
};
}}
pagination={false}
scroll={{ y: 'calc(100vh - 94px - 32px - 57px - 24px - 39px - 36px)' }}
/>
<Pagination
size="small"
className="text-center m-3"
showSizeChanger
showQuickJumper
onChange={changeCurrent}
onShowSizeChange={changeCurrent}
current={pageNum}
pageSize={pageSize}
defaultCurrent={1}
total={total}
showTotal={total => `共 ${total} 条`}
/>
</div>
<UpdateDataMasterModal
action={action}
data={currentData}
fields={fields}
nodeId={nodeId}
visible={isDataMasterModalVisible}
onCancel={onDataMasterModalCancel}
/>
<ImportDataDrawer
visible={importDataDrawerVisible}
nodeId={nodeId}
onCancel={onImportDataDrawerCancel}
onSuccess={onImportDataSuccess}
/>
<RcMenu id={MENU_ID}>
<RcItem id="detail" onClick={handleItemClick}>
详情
</RcItem>
<RcItem id="update" onClick={handleItemClick}>
编辑
</RcItem>
</RcMenu>
</div>
);
}
export default ManageTable;
\ No newline at end of file
import {useEffect, useMemo, useState, useRef} from 'react';
import {Tooltip, Spin, AutoComplete, Tree} from 'antd';
import {ReloadOutlined} from '@ant-design/icons';
import { dispatch } from '../../../../../model';
import {highlightSearchContentByTerms} from '../../../../../util';
import '../../Define/Component/DefineTree.less';
const {Option} = AutoComplete;
const ManageTree = (props) => {
const {onClick} = props;
const [loading, setLoading] = useState(false);
const [data, setData] = useState();
const [options, setOptions] = useState([]);
const [keyword, setKeyword] = useState('');
const [expandedKeys, setExpandedKeys] = useState([]);
const [selectedKeys, setSelectedKeys] = useState([]);
const [autoExpandParent, setAutoExpandParent] = useState(false);
const selectedKeysRef = useRef([]);
useEffect(() => {
getTreeNodes();
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
const treeData = useMemo(() => {
const loop = (data) =>
(data||[]).map((item) => {
if (item.children) {
return {
title: item.name||'',
key: item._id||'',
origin: item,
children: loop(item.children),
};
}
return {
title: item.name||'',
key: item._id||'',
};
});
return loop(data);
}, [data])
const treeList = useMemo(() => {
const generateList = (data, list, path = null) => {
(data||[]).forEach(node => {
const {_id, name} = node;
const currentPath = path ? `${path}/${name}` : name;
list.push({key: _id, title: currentPath});
if (node.children) {
generateList(node.children, list, currentPath);
}
});
};
const newTreeList = [];
generateList(data, newTreeList);
return newTreeList;
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [data])
const getTreeNodes = () => {
setLoading(true);
dispatch({
type: 'msd.getMgrTreeNodes',
callback: (data) => {
setLoading(false);
setData(data||[]);
const firstModelNodeId = findFirstModelNode(data||[]);
if ((selectedKeysRef.current||[]).length===0 && (data||[]).length>0) {
onTreeSelect([firstModelNodeId]);
}
if ((expandedKeys||[]).length===0 && (data||[]).length>0) {
setExpandedKeys([firstModelNodeId]);
setAutoExpandParent(true);
} else {
setExpandedKeys(Array.from(new Set([...expandedKeys, ...selectedKeysRef.current])));
setAutoExpandParent(true);
}
},
error: () => {
setLoading(false);
}
})
}
const onRefreshClick = () => {
getTreeNodes();
}
const onAutoCompleteSearch = (searchText) => {
setKeyword(searchText);
setOptions(treeList.filter(item => item.title.indexOf(searchText)!==-1));
};
const onAutoCompleteSelect = (value, option) => {
const paths = value.split('/');
setKeyword(paths[paths.length-1]);
if (isModelNode(option.key)) {
onTreeSelect([option.key]);
}
setExpandedKeys(Array.from(new Set([...expandedKeys, option.key])));
setAutoExpandParent(true);
};
const onAutoCompleteClear = () => {
setKeyword('');
}
const onTreeExpand = (expandedKeys) => {
setExpandedKeys(expandedKeys);
setAutoExpandParent(false);
}
const onTreeSelect = (selectedKeys, e = null) => {
if (selectedKeys.length === 0) {
return;
}
if (e && e?.node && !isModelNode(e?.node?.key)) {
return;
}
setSelectedKeys(selectedKeys);
selectedKeysRef.current = selectedKeys;
onClick && onClick(selectedKeys[0]);
}
const isModelNode = (value) => {
return ((value||'').indexOf('Model=') !== -1);
}
const findFirstModelNode = (values) => {
const generateList = (data, list) => {
(data||[]).forEach(node => {
list.push(node);
if (node.children) {
generateList(node.children, list);
}
});
};
const newTreeList = [];
generateList(values, newTreeList);
let firstModelNodeId = '';
newTreeList.some(item => {
if (isModelNode(item._id)) {
firstModelNodeId = item._id;
}
return isModelNode(item._id);
})
return firstModelNodeId;
}
return (
<div className='data-master-tree'>
<div className='header p-3'>
<Tooltip title="刷新目录" className='ml-2'>
<ReloadOutlined
className='default'
onClick={onRefreshClick}
style={{
fontSize:16,
cursor:'pointer',
flex: 1
}}
/>
</Tooltip>
<div style={{flex: 3}} />
</div>
<div className='content p-3'>
<Spin spinning={loading}>
<AutoComplete
className='content-search'
allowClear
value={keyword}
onSelect={onAutoCompleteSelect}
onSearch={onAutoCompleteSearch}
onClear={onAutoCompleteClear}
>
{
(options||[]).map((item, index) => {
return (
<Option key={item.key} value={item.title}>
<div style={{ whiteSpace: 'normal' }}>
{highlightSearchContentByTerms(item.title, [keyword])}
</div>
</Option>
);
})
}
</AutoComplete>
<Tree
className='content-tree'
showLine
showIcon={false}
autoExpandParent={autoExpandParent}
treeData={treeData}
onExpand={onTreeExpand}
onSelect={onTreeSelect}
expandedKeys={expandedKeys}
selectedKeys={selectedKeys}
/>
</Spin>
</div>
</div>
);
}
export default ManageTree;
\ No newline at end of file
import { useEffect, useState, useMemo } from "react";
import { Modal, Form, Input, Button, Descriptions } from "antd";
import { dispatch } from "../../../../../model";
import './UpdateDataMasterModal.less';
const UpdateDataMasterModal = (props) => {
const {visible, onCancel, data, fields, action = 'add', nodeId} = props;
const [confirmLoading, setConfirmLoading] = useState(false);
const [form] = Form.useForm();
const formItemLayout = {
labelCol: {
xs: { span: 24 },
sm: { span: 6 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 18 },
},
};
useEffect(() => {
if (visible) {
let newFieldsValue = {};
(fields||[]).forEach(item => {
newFieldsValue[item.name] = data?data[item.name]:'';
});
form?.setFieldsValue(newFieldsValue);
}
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [visible, data, fields])
const title = useMemo(() => {
if (action === 'add') {
return '新建主数据';
}
if (action === 'detail') {
return '主数据详情';
}
if (action === 'update') {
return '编辑主数据';
}
return '';
}, [action])
const onFormFinish = async() => {
try {
const row = await form.validateFields();
setConfirmLoading(true);
let url = '', newData = {};
if (action === 'add') {
url = 'msd.addData';
newData = row;
} else {
url = 'msd.updateData';
newData = {...data, ...row};
}
dispatch({
type: url,
payload: {
params: {
modelId: nodeId,
},
data: newData
},
callback: () => {
setConfirmLoading(false);
onCancel && onCancel(true);
},
error: () => {
setConfirmLoading(false);
}
});
} catch (errInfo) {
console.log('Validate Failed:', errInfo);
}
}
return (
<Modal
className='update-data-master-modal'
title={title}
visible={visible}
onCancel={() => { onCancel && onCancel(false); }}
onOk={onFormFinish}
footer={[
<Button key="cancel" onClick={() => {onCancel && onCancel();}}>
取消
</Button>,
action!=='detail' && <Button
key="ok"
type="primary"
loading={confirmLoading}
onClick={onFormFinish}
>
确定
</Button>,
]}
>
{
(action!=='detail') ? <Form
form={form}
{...formItemLayout}
>
{
(fields||[]).map((item, index) => {
return (
<Form.Item key={index} label={item.name} name={item.name} rules={[{ required: false }]}>
<Input />
</Form.Item>
)
})
}
</Form> : <Descriptions column={1}>
{
(fields||[]).map((item, index) => {
return (
<Descriptions.Item label={<div style={{ textAlign: 'right', width: 85 }}>{item.name||''}</div>} >{data?data[item.name||'']:''}</Descriptions.Item>
);
})
}
</Descriptions>
}
</Modal>
);
}
export default UpdateDataMasterModal;
\ No newline at end of file
.update-data-master-modal {
.yy-modal-body {
max-height: 70vh;
overflow: auto;
}
}
\ No newline at end of file
import { useMemo, useState } from 'react';
import classNames from 'classnames';
import { ResizableBox } from 'react-resizable';
import { CaretLeftOutlined, CaretRightOutlined } from '@ant-design/icons';
import ManageTree from './Component/ManageTree';
import ManageTable from './Component/ManageTable';
import '../Define/index.less';
const DataMasterManage = (props) => {
const [collapse, setCollapse] = useState(false);
const [nodeId, setNodeId] = useState('');
const classes = useMemo(() => {
return classNames('data-master', {
'data-master-collapse': collapse,
});
}, [collapse]);
const onTreeClick = (value) => {
setNodeId(value);
}
const onCollapseClick = () => {
setCollapse(!collapse);
}
return (
<div className={classes}>
<ResizableBox
className='left-wrap'
width={230}
height={Infinity}
axis='x'
minConstraints={[230, Infinity]} maxConstraints={[Infinity, Infinity]}
>
<ManageTree onClick={onTreeClick} />
</ResizableBox>
<div className='left-collapse-wrap'>
<div className='left-collapse' onClick={onCollapseClick}>
{ collapse ? <CaretRightOutlined /> : <CaretLeftOutlined /> }
</div>
</div>
<div className='right-wrap'>
<ManageTable nodeId={nodeId} />
</div>
</div>
)
}
export default DataMasterManage;
\ No newline at end of file
......@@ -2,40 +2,50 @@ import { useState, useEffect } from 'react';
import { Modal, Button, Switch, Row, Col, Checkbox, Typography } from 'antd';
import { dispatch } from '../../../../model';
const cols = [
{title: '模型名称', require: true},
{title: '中文名称'},
{title: '路径'},
{title: '状态'},
{title: '创建人'},
{title: '版本号'},
{title: '模型描述'},
];
import { showMessage } from '../../../../util';
const ColSettingModal = (props) => {
const {visible, onCancel} = props;
const [loadingAttrs, setLoadingAttrs] = useState(false);
const [attrs, setAttrs] = useState(undefined);
const [catagories, setCatagories] = useState(undefined);
const [checkedKeys, setCheckedKeys] = useState([]);
const [confirmLoading, setConfirmLoading] = useState(false);
useEffect(() => {
if (visible) {
getAttrs();
getPreference();
}
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [visible]);
const getAttrs = () => {
setLoadingAttrs(true);
dispatch({
type: 'pds.getAttrs',
payload: {
modelName: 'DataService'
},
callback: data => {
setAttrs(data);
setCatagories(Array.from(new Set((data||[]).map(item => item.status))));
setLoadingAttrs(false);
},
error: () => {
setLoadingAttrs(false);
}
})
}
const getPreference = () => {
dispatch({
type: 'datamodel.getPreference',
type: 'pds.getCols',
payload: {
modelName: 'DataService'
},
callback: data => {
if ((data.cols||'') === '') {
onCheckAllChange(true);
} else {
setCheckedKeys(data.cols.split(','));
}
setCheckedKeys(data?.map(item => item.titleCnName));
}
})
}
......@@ -44,14 +54,8 @@ const ColSettingModal = (props) => {
const newCheckedKeys = [];
if (checked) {
cols.forEach(col => {
newCheckedKeys.push(col.title);
});
} else {
cols.forEach(col => {
if (col.require) {
newCheckedKeys.push(col.title);
}
attrs?.forEach(col => {
newCheckedKeys.push(col.name);
});
}
......@@ -74,17 +78,24 @@ const ColSettingModal = (props) => {
}
const onModalOk = () => {
if ((checkedKeys||[]).length === 0) {
showMessage('warn', '不可进行全不选操作');
return;
}
setConfirmLoading(true);
dispatch({
type: 'datamodel.savePreference',
type: 'pds.saveCols',
payload: {
data: {
cols: checkedKeys.join(',')
}
params: {modelName: 'DataService'},
data: checkedKeys?.map(item => {
return { titleCnName: item }
})
},
callback: () => {
setConfirmLoading(false);
onCancel && onCancel(true);
showMessage('success', '操作成功');
},
error: () => {
setConfirmLoading(false);
......@@ -123,23 +134,35 @@ const ColSettingModal = (props) => {
/>
</div>
<div className='mt-3' style={{ maxHeight: 450, overflow: 'auto' }}>
<Row>
{
cols.map((col, index) => {
catagories?.map((catagory, index) => {
return (
<Col className='mb-3' key={index} md={6}>
<div className='d-flex'>
<Checkbox checked={ checkedKeys.indexOf(col.title||'')!==-1 } value={col.title} onChange={onCheckChange} disabled={col.require} >
</Checkbox>
<Typography.Paragraph className='ml-1' title={col.title} ellipsis>
{col.title}
</Typography.Paragraph>
<div key={index}>
<div className='flex' style={{ alignItems: 'center', padding: '5px 0 15px' }}>
<div style={{ width: 3, height: 14, backgroundColor: '#0069AC', marginRight: 5 }} />
<span style={{ fontWeight: 'bold', color: '#464646' }}>{catagory}</span>
</div>
</Col>
<Row>
{
attrs?.filter(col => col.status===catagory)?.map((col, index) => {
return (
<Col className='mb-3' key={index} md={6}>
<div className='d-flex'>
<Checkbox checked={ checkedKeys.indexOf(col.name||'')!==-1 } value={col.name} onChange={onCheckChange} >
</Checkbox>
<Typography.Paragraph className='ml-1' title={col.name} ellipsis>
{col.name}
</Typography.Paragraph>
</div>
</Col>
)
})
}
</Row>
</div>
)
})
}
</Row>
</div>
</Modal>
)
......
import React, { useState, useEffect } from 'react';
import { Modal, Button, Form, Descriptions, Space, Spin } from 'antd';
import { dispatch } from '../../../../model';
import SelectUsers from './SelectUsers';
import './ExchangeOwner.less';
const FC = ({ visible, id, onCancel }) => {
const [service, setService] = useState(undefined);
const [loading, setLoading] = useState(false);
const [loadingOwners, setLoadingOwners] = useState(false);
const [owners, setOwners] = useState(undefined);
const [currentOwner, setCurrentOwner] = useState(undefined);
useEffect(() => {
if (visible) {
getService();
getOwners();
}
}, [visible, id])
const getService = () => {
setLoading(true);
dispatch({
type: 'pds.getDataService',
payload: {
id
},
callback: (data) => {
setLoading(false);
setService(data);
setCurrentOwner(data?.editor);
},
error: () => {
setLoading(false);
}
})
}
const getOwners = () => {
setLoadingOwners(true);
dispatch({
type: 'pds.getOwners',
callback: (data) => {
setLoadingOwners(false);
setOwners(data);
},
error: () => {
setLoadingOwners(false);
}
})
}
const onOwnerChange = (value) => {
setCurrentOwner(value);
if (value) {
dispatch({
type: 'pds.saveOwner',
payload: {
jobNumber: value
}
})
}
}
const cancel = (refresh = false) => {
reset();
onCancel?.(refresh);
}
const onOk = () => {
setLoading(true);
dispatch({
type: 'pds.changeOwner',
payload: {
params: {
id,
ownerName: currentOwner
}
},
callback: () => {
setLoading(false);
cancel(true);
},
error: () => {
setLoading(false);
}
})
}
const reset = () => {
setService(undefined);
setLoading(false);
setLoadingOwners(false);
}
const footer = [
<Button
key="0"
onClick={() => { cancel() }}
>
取消
</Button>,
<Button
key="1"
type="primary"
onClick={onOk}
>
确定
</Button>,
];
return (
<Modal
className='exchange-owner'
visible={visible}
title='更换管理人'
width={800}
destroyOnClose
onCancel={() => { cancel() }}
footer={footer}
>
<Spin spinning={loading}>
<Descriptions title={<Space>
<div style={{ height: 18, width: 3, background: 'rgb(2, 105, 172)' }}></div>
<div>基本信息</div>
</Space>}>
<Descriptions.Item label="数据服务名称">{service?.name}</Descriptions.Item>
<Descriptions.Item label="数据服务技术名称">{service?.cnName}</Descriptions.Item>
<Descriptions.Item label="数据服务描述">{service?.remark}</Descriptions.Item>
</Descriptions>
<Descriptions title={<Space>
<div style={{ height: 18, width: 3, background: 'rgb(2, 105, 172)' }}></div>
<div>提供方信息</div>
</Space>} />
<Space>
<div>管理人:</div>
<div style={{ width: 200 }}>
<SelectUsers type='edit' loading={loadingOwners} users={owners} value={currentOwner} onChange={onOwnerChange} />
</div>
</Space>
</Spin>
</Modal>
)
}
export default FC;
\ No newline at end of file
.exchange-owner {
.yy-descriptions-header {
margin-bottom: 5px;
}
}
\ No newline at end of file
......@@ -30,14 +30,14 @@ const ModelNameColumn = (props) => {
ellipsis: true,
},
{
title: '字段中文名称',
title: '名称',
width: 160,
dataIndex: 'cnName',
editable: true,
ellipsis: true,
},
{
title: '字段英文名称',
title: '技术ID(英文名称)',
width: 160,
dataIndex: 'name',
editable: true,
......@@ -193,7 +193,7 @@ const ExpandedModelTable = (props) => {
}
},
{
title: '创建人',
title: '管理人',
dataIndex: 'editor',
width: 100,
ellipsis: true,
......
import React, { useEffect, useState, useContext, useMemo } from 'react';
import { Spin, Tooltip, Typography, Pagination, Table } from 'antd';
import { AppContext } from '../../../../App';
import { dispatch } from '../../../../model';
import { paginate } from '../../../../util';
const FC = (props) => {
const app = useContext(AppContext);
const [loading, setLoading] = useState(false);
const [data, setData] = useState([]);
const [pagination, setPagination] = useState({pageNum: 1, pageSize: 20});
const {pageNum, pageSize} = pagination;
const cols = [
{
title: '序号',
dataIndex: 'key',
render: (text, record, index) => {
return (index+1).toString();
},
width: 60,
ellipsis: true,
},
{
title: '数据服务资产编码',
dataIndex: 'code',
ellipsis: true,
render: (_, record) => record.basicInfo?.code
},
{
title: '数据服务名称',
dataIndex: 'name',
ellipsis: true,
render: (_, record) => record.basicInfo?.name
},
{
title: 'URI',
dataIndex: 'odata',
ellipsis: true,
render: (text, _, __) => {
return (
<React.Fragment>
{
text ? <div className='flex'>
<Tooltip title={text||''} overlayClassName='tooltip-common'>
<Typography.Text ellipsis={true}>
{text||''}
</Typography.Text>
</Tooltip>
<Typography.Text copyable={{ text }}></Typography.Text>
</div> : ''
}
</React.Fragment>
);
}
},
{
title: '操作',
dataIndex: 'action',
width: 80,
fixed: 'right',
render: (_, record) => {
return (
<a onClick={() => {
app.openDetail?.({ service: record })
}}>详情</a>
)
}
}
];
useEffect(() => {
getServices();
}, [])
const tableData = useMemo(() => {
if (data) {
return paginate(data, pagination.pageNum, pagination.pageSize);
}
return [];
}, [data, pagination])
const getServices = () => {
setLoading(true);
dispatch({
type: 'pds.getGrantedServices',
payload: {
namespace: `${app?.env?.domainId}`
},
callback: data => {
setLoading(false);
setData(data);
},
error: () => {
setLoading(false);
}
});
}
return (
<div>
<Table
extraColWidth={10}
loading={loading}
columns={cols||[]}
dataSource={tableData}
pagination={false}
scroll={{y: (tableData||[]).length===0?null:'calc(100vh - 121px - 57px - 24px - 38px - 44px)'}}
/>
<Pagination
className="text-center mt-3"
showSizeChanger
onChange={(_pageNum, _pageSize) => {
setPagination({ pageNum: _pageNum, pageSize: _pageSize || 20 });
}}
onShowSizeChange={(_pageNum, _pageSize) => {
setPagination({ pageNum: 1, pageSize: _pageSize });
}}
current={pageNum}
pageSize={pageSize}
defaultCurrent={1}
total={(data||[]).length}
showTotal={total => ` ${total} `}
/>
</div>
)
}
export default FC
\ No newline at end of file
......@@ -14,7 +14,7 @@ const HistoryAndVersionDrawer = (props) => {
title=''
placement="right"
closable={true}
width={'90%'}
width={'40%'}
onClose={() => {
onCancel && onCancel();
}}
......@@ -25,9 +25,9 @@ const HistoryAndVersionDrawer = (props) => {
<TabPane tab="版本历史" key="1">
<VersionHistory id={id} />
</TabPane>
<TabPane tab="版本对比" key="2">
{/* <TabPane tab="版本对比" key="2">
<VersionCompare id={id} />
</TabPane>
</TabPane> */}
</Tabs>
}
</Drawer>
......
......@@ -103,8 +103,6 @@ const AttributesSelect = ({ value = [], modelerData, onChange, mode = 'multiple'
})
}
console.log('currentAttributes', currentAttributes)
triggerChange(currentAttributes);
}
......@@ -523,7 +521,7 @@ const ImportActionHeader = (props) => {
>
<h2 className='mr-3' style={{ marginBottom: 0 }}>基本信息</h2>
{
onlyShowRequireChange ? <Button type='primary' size='small' onClick={onOnlyShowRequireChange}>展开<DownOutlined /></Button> : <Button type='primary' size='small' onClick={onOnlyShowRequireChange}>收起<UpOutlined /></Button>
onlyShowRequireChange ? <Button type='text' style={{ padding: 0, color: '#0069AC' }} onClick={onOnlyShowRequireChange}>展开<DownOutlined /></Button> : <Button type='text' style={{ padding: 0, color: '#0069AC' }} onClick={onOnlyShowRequireChange}>收起<UpOutlined /></Button>
}
</div>
{
......@@ -637,7 +635,7 @@ const ImportActionHeader = (props) => {
label="技术主键"
name="easyDataModelerPrimaryKey"
>
<AttributesSelect modelerData={modelerData} mode='tags' />
<AttributesSelect modelerData={modelerData} />
</Form.Item>
</Col>
<Col xs={24} sm={24} lg={12} xl={8}>
......
......@@ -882,7 +882,7 @@ const ImportActionIndex = (props) => {
onChange && onChange(newData);
},
//eslint-disable-next-line react-hooks/exhaustive-deps
[dataRef.current, onChange],
[dataRef.current],
);
const onSearchInputChange = (value) => {
......@@ -891,15 +891,15 @@ const ImportActionIndex = (props) => {
}
const displayMenu = (e) => {
show(e);
show({
event: e
})
}
const handleItemClick = ({ event, props, data, triggerEvent }) => {
const key = event.currentTarget.id;
if (key === 'up') {
const handleItemClick = ({ id, event, props }) => {
if (id === 'up') {
insertToFront(currentItem);
} else if (key === 'down') {
} else if (id === 'down') {
insertToBack(currentItem);
}
}
......
......@@ -167,33 +167,47 @@ export const EditableCell = ({
let editingComponent = null;
if (editing) {
let inputNode = <InputDebounce />;
if (inputType === 'check') {
inputNode = <Checkbox />;
} else if (inputType === 'textarea') {
inputNode = <Input.TextArea autoSize={{ minRows: 1, maxRows: 6 }} />;
} else if (inputType === 'datatype') {
inputNode = <DatatypeInput datatypes={datatypes} />;
}
if (dataIndex !== 'datatype') {
editingComponent = (
<Form.Item
name={dataIndex}
style={{
margin: 0,
}}
valuePropName={(inputType==='check')? 'checked': 'value'}
rules={[
{
required: (require===null)?false:require,
message: `请输入${colTitle}!`,
},
]}
>
{ inputNode }
</Form.Item>
);
const inputNode = inputType === 'check' ? <Checkbox /> : <InputDebounce />
editingComponent = (
<Form.Item
name={dataIndex}
style={{
margin: 0,
}}
valuePropName={(inputType==='check')? 'checked': 'value'}
rules={[
{
required: (require===null)?false:require,
message: `请输入${colTitle}!`,
},
]}
>
{ inputNode }
</Form.Item>
);
} else {
editingComponent = (
<Form.Item
name={dataIndex}
style={{
margin: 0,
}}
valuePropName={'value'}
rules={[
{
required: (require===null)?false:require,
message: `请输入${colTitle}!`,
},
]}
>
<DatatypeInput datatypes={datatypes} />
</Form.Item>
)
}
}
......@@ -440,9 +454,9 @@ export const ImportActionTable = (props) => {
render: (text, _, __) => {
return (
<Tooltip title={text||''}>
<Typography.Text ellipsis={true}>
<span>
{highlightSearchContentByTerms(text, termsRef.current)}
</Typography.Text>
</span>
</Tooltip>
)
}
......@@ -930,7 +944,7 @@ export const ImportActionTable = (props) => {
value?.setGlobalState && value?.setGlobalState({
message: 'data-govern-show-standard-create',
data: {
column: {...record, ...{ modelName: modelerData?.name, modelCnName: modelerData?.cnName }},
column: record,
type: record?.isPossibleNewRecommendedDefinition?.type
}
});
......@@ -1106,28 +1120,13 @@ export const ImportActionTable = (props) => {
if (!col.editable) {
return col;
}
let inputType = 'text';
if (
col.dataIndex==='notNull'||
col.dataIndex==='partOfDistributionKey' ||
col.dataIndex==='partOfPrimaryKeyLogically' ||
col.dataIndex==='needAttention' ||
col.dataIndex==='foreignKey'
) {
inputType = 'check';
} else if (col.dataIndex === 'remark') {
inputType = 'textarea';
} else if (col.dataIndex === 'datatype') {
inputType = 'datatype';
}
return {
...col,
onCell: (record) => ({
record,
dataIndex: col.dataIndex,
inputType,
inputType: (col.dataIndex==='notNull' || col.dataIndex==='partOfDistributionKey' || col.dataIndex==='partOfPrimaryKeyLogically' || col.dataIndex==='needAttention' || col.dataIndex==='foreignKey') ? 'check' : 'text',
colTitle: col.title,
editing: isEditing(record),
datatypes: supportedDatatypes,
......@@ -1175,7 +1174,7 @@ export const ImportActionTable = (props) => {
onChange && onChange(newData);
},
//eslint-disable-next-line react-hooks/exhaustive-deps
[moveRowRef.current, onChange],
[moveRowRef.current],
);
const onSearchInputChange = (value) => {
......@@ -1199,15 +1198,15 @@ export const ImportActionTable = (props) => {
}
const displayMenu = (e) => {
show(e);
show({
event: e
})
}
const handleItemClick = ({ event, props, data, triggerEvent }) => {
const key = event.currentTarget.id;
if (key === 'up') {
const handleItemClick = ({ id, event, props }) => {
if (id === 'up') {
insertToFront(currentItem);
} else if (key === 'down') {
} else if (id === 'down') {
insertToBack(currentItem);
}
}
......
......@@ -79,7 +79,7 @@ class ImportExcel extends React.Component {
</Col>
<Col span={6}>
<Button icon={<DownloadOutlined />} onClick={ this.downloadTemplate }>
下载
下载
</Button>
</Col>
</Row>
......
......@@ -281,7 +281,6 @@ class ImportMetadata extends React.Component {
<Pagination
showTotal={total => `共 ${total} 条`}
showSizeChanger
size="small"
pageSize={pageSizeDataTables}
pageSizeOptions={['20','60','100']}
current={pageNumDataTables}
......
import React from 'react'
import { Drawer, Form, Pagination, Divider, Upload, Button, Typography, Modal, Spin } from 'antd'
import { UploadOutlined, DownloadOutlined } from '@ant-design/icons'
import { dispatch } from '../../../../model'
import { AppContext } from '../../../../App'
import { showMessage } from '../../../../util'
import Table from '../../ResizeableTable'
const FC = (props) => {
const { onCancel, onSuccess, visible } = props
const [fileList, setFileList] = React.useState([])
const [confirmLoading, setConfirmLoading] = React.useState(false)
const [loading, setLoading] = React.useState(false)
const [logs, setLogs] = React.useState([])
const [pagination, setPagination] = React.useState({ pageNum: 1, pageSize: 20 })
const [total, setTotal] = React.useState(0)
const [users, setUsers] = React.useState([])
const [confirmParams, setConfirmParams] = React.useState({
visible: false,
message: undefined,
fileId: undefined,
})
const app = React.useContext(AppContext)
const columns = [
{
title: '序号',
dataIndex: 'key',
render: (text, record, index) => {
return (index+1).toString();
},
width: 60,
},
{
title: '开始时间',
dataIndex: 'startTime',
width: 200,
ellipsis: true,
render: (_, record) => record.startTime ? new Date(record.startTime).toLocaleString() : ''
},
{
title: '结束时间',
dataIndex: 'endTime',
width: 200,
ellipsis: true,
render: (_, record) => record.endTime ? new Date(record.endTime).toLocaleString() : ''
},
{
title: '耗时',
dataIndex: 'costTime',
width: 100,
ellipsis: true,
render: (_, record, __) => {
return record.costTime?`${Number(record.costTime/1000)}秒`:'';
}
},
{
title: '导入人',
dataIndex: 'operator',
width: 100,
ellipsis: true,
render: (_, record) => {
const temp = (record.operator??'').split(':')
if ((temp??[]).length >= 3) {
const user = (users??[]).filter((user)=>user.pernr === temp[2])
if (user && user.length > 0) {
return user[0].nachn?`${user[0].nachn}(${user[0].pernr})`:user[0].pernr
}
return temp[2]
}
return ''
}
},
{
title: '导入状态',
dataIndex: 'state',
ellipsis: true,
},
]
React.useEffect(() => {
if (visible) {
getLogs()
getUsers()
}
}, [visible])
const getUsers = () => {
dispatch({
type: 'pds.getOwners',
callback: (data) => {
setUsers(data);
}
})
}
const downloadTemplate = () => {
window.open('/api/pdataservice/pdsCURD/exportPDSDataServiceTemplate?model=DataService')
}
const getLogs = () => {
setLoading(true)
setPagination(prev => {
dispatch({
type: 'pds.getImportLogs',
payload: {
page: prev.pageNum,
size: prev.pageSize
},
callback: data => {
setLoading(false)
setTotal(data.totalElements)
setLogs(data.content||[])
},
error: () => {
setLoading(false)
}
})
return prev
})
}
const uploadProps = {
onRemove: file => {
const index = fileList.indexOf(file);
const newFileList = fileList.slice();
newFileList.splice(index, 1);
setFileList(newFileList);
},
beforeUpload: file => {
const isLt2OM = file.size / 1024 / 1024 < 20;
if (!isLt2OM) {
showMessage('error', '上传文件必须小于20M');
setFileList([]);
return false;
}
setFileList([file]);
return false;
},
fileList: fileList || [],
accept:".xlsx",
};
const handleOk = () => {
if ((fileList||[]).length === 0) {
showMessage('info', '请先选择文件上传')
return
}
setConfirmLoading(true)
dispatch({
type: 'pds.addImportWithConfirm',
payload: {
fileList: fileList,
params: {
namespace: app?.env?.domainId
},
},
callback: data => {
setConfirmLoading(false)
setFileList([])
if (data?.fileId) {
setConfirmParams({
visible: true,
message: data?.message,
fileId: data?.fileId,
})
} else {
showMessage('error', '上传文件失败')
}
},
error: () => {
setConfirmLoading(false)
}
})
}
const reset = () => {
setConfirmLoading(false)
setPagination({ pageNum: 1, pageSize: 20 })
setFileList([])
}
return (
<Drawer
visible={visible}
title='服务导入'
width={900}
placement="right"
closable
destroyOnClose
onClose={() => {
reset()
onCancel?.()
}}
>
<div className='mt-3'>
<Form layout='inline'>
<Form.Item label='Excel导入:'>
<Button className='mr-2' icon={<DownloadOutlined />} onClick={ downloadTemplate }>
模板下载
</Button>
<Upload style={{ display: 'inline' }} {...uploadProps }>
<Button icon={<UploadOutlined />}>
选择文件上传
</Button>
</Upload>
</Form.Item>
<Form.Item>
<Button type='primary' onClick={handleOk} loading={confirmLoading}>确定导入</Button>
</Form.Item>
<Button onClick={() => getLogs()} style={{ marginLeft: 'auto' }}>刷新日志</Button>
</Form>
</div>
<Divider orientation="left">导入日志</Divider>
<Table
className='mt-3'
columns={columns||[]}
rowKey={'id'}
dataSource={logs||[]}
pagination={false}
loading={loading}
expandable={{
expandedRowRender: record => <React.Fragment>
{record.message?.split('\n').map((info, index) => {
return <Typography.Paragraph key={index}>{info}</Typography.Paragraph>
})}
</React.Fragment>
}}
sticky
/>
<Pagination
className="text-center mt-3"
showSizeChanger
onChange={(_pageNum, _pageSize) => {
setPagination({ pageNum: _pageNum||1, pageSize: _pageSize || 20 });
getLogs();
}}
onShowSizeChange={(_pageNum, _pageSize) => {
setPagination({ pageNum: _pageNum || 1, pageSize: _pageSize || 20 });
getLogs();
}}
current={pagination.pageNum}
pageSize={pagination.pageSize}
defaultCurrent={1}
total={total}
showTotal={total => `共 ${total} 条`}
/>
<Confirm
{...confirmParams}
onCancel={(refresh) => {
setConfirmParams({
visible: false,
message: undefined,
fileId: undefined,
})
getLogs()
refresh && onSuccess?.()
}}
/>
</Drawer>
)
}
export default FC
const Confirm = ({ visible, message, fileId, onCancel }) => {
const [waiting, setWaiting] = React.useState(false)
const close = () => {
setWaiting(true)
dispatch({
type: 'pds.importConfirm',
payload: {
params: {
fileId,
isContinued: false,
},
},
callback: data => {
showMessage('success', '取消导入成功')
setWaiting(false)
onCancel?.()
},
error: () => {
setWaiting(false)
}
})
}
const save = () => {
setWaiting(true)
dispatch({
type: 'pds.importConfirm',
payload: {
params: {
fileId,
isContinued: true,
},
},
callback: data => {
showMessage('success', '上传文件成功,正在导入。。。')
setWaiting(false)
onCancel?.(true)
},
error: () => {
setWaiting(false)
}
})
}
const footer = React.useMemo(() => {
return [
<Button key={'cancel'}
onClick={() => close()}
>取消导入</Button>,
<Button key={'save'} type='primary'
disabled={waiting}
onClick={() => save()}
>继续导入</Button>
]
}, [close, save, waiting])
return (
<Modal
title='导入确认'
width={600}
visible={visible}
footer={footer}
destroyOnClose
maskClosable={false}
onCancel={() => {
close()
}}
bodyStyle={{
height: 400,
overflow: 'auto'
}}
>
<Spin spinning={waiting}>
{
(message??'').split('\n').map((info, index) => {
return <Typography.Paragraph key={index}>{info}</Typography.Paragraph>
})
}
</Spin>
</Modal>
)
}
\ No newline at end of file
import React, { useEffect, useState } from 'react';
import { Modal, Typography, Button, Space, Tooltip, Spin } from 'antd';
import { CopyOutlined, DownloadOutlined } from '@ant-design/icons';
import copy from 'copy-to-clipboard';
import { dispatch } from '../../../../model';
import { showMessage } from '../../../../util';
const FC = (props) => {
const { visible, onCancel } = props;
const [information, setInformation] = useState(undefined);
const [loading, setLoading] = useState(false);
useEffect(() => {
if (visible) {
getInformation();
}
}, [visible])
const getInformation = () => {
setLoading(true);
dispatch({
type: 'pds.getJdbcInformation',
callback: data => {
setLoading(false);
setInformation(data);
},
error: () => {
setLoading(false);
}
})
}
return (
<Modal
title='JDBC信息'
width={540}
visible={visible}
onCancel={onCancel}
footer={null}
>
<Spin spinning={loading}>
<div className='flex mb-3' style={{ justifyContent: 'space-between', alignItems: 'baseline' }}>
<div style={{ width: 400 }}>
<Typography.Text>
{`impala JDBC地址: ${information?.impala?.url}`}
</Typography.Text>
</div>
<Space>
<Tooltip title={information?.impala?.urlTip}>
<Button type='link' icon={<CopyOutlined />} onClick={() => {
if (information?.impala?.url) {
copy(information?.impala?.url);
showMessage('success', '复制成功');
}
}} />
</Tooltip>
<Tooltip title={information?.impala?.downloadTip}>
<Button type='link' icon={<DownloadOutlined />} onClick={() => {
if (information?.impala?.downloadUrl) {
copy(information?.impala?.downloadUrl);
showMessage('success', '复制成功');
}
}} />
</Tooltip>
</Space>
</div>
<div className='flex' style={{ justifyContent: 'space-between', alignItems: 'baseline' }}>
<div style={{ width: 400 }}>
<Typography.Text>
{`Hana JDBC地址: ${information?.hana?.url}`}
</Typography.Text>
</div>
<Space>
<Tooltip title={information?.hana?.urlTip}>
<Button type='link' icon={<CopyOutlined />} onClick={() => {
if (information?.hana?.url) {
copy(information?.hana?.url);
showMessage('success', '复制成功');
}
}} />
</Tooltip>
<Tooltip title={information?.hana?.downloadTip}>
<Button type='link' icon={<DownloadOutlined />} onClick={() => {
if (information?.hana?.downloadUrl) {
copy(information?.hana?.downloadUrl);
showMessage('success', '复制成功');
}
}} />
</Tooltip>
</Space>
</div>
</Spin>
</Modal>
)
}
export default FC;
\ No newline at end of file
......@@ -43,7 +43,7 @@ export const AttentionSvg = (props) => (
</defs>
<path
d="M826.027 34.133H197.973c-37.546 0-68.266 30.72-68.266 68.267v887.467L512 791.893l382.293 197.974V102.4c0-37.547-30.72-68.267-68.266-68.267zm-148.48 337.92L612.693 435.2c-3.413 3.413-5.12 10.24-5.12 15.36l15.36 87.04c1.707 13.653-11.946 23.893-23.893 17.067L520.533 512c-5.12-3.413-10.24-3.413-15.36 0l-78.506 42.667c-11.947 6.826-27.307-3.414-23.894-17.067l15.36-87.04c1.707-5.12 0-10.24-5.12-15.36l-64.853-63.147c-10.24-10.24-5.12-27.306 8.533-29.013l88.747-13.653c5.12 0 10.24-3.414 11.947-8.534l39.253-80.213c6.827-11.947 23.893-11.947 30.72 0l39.253 80.213c1.707 5.12 6.827 8.534 11.947 8.534l88.747 13.653c13.653 1.707 18.773 18.773 10.24 29.013z"
fill='#196AD2'
fill='#c7000b'
/>
</svg>
)
......
import React, { useEffect, useState } from 'react';
import { Modal, Button, Form, Input } from 'antd';
import { dispatch } from '../../../../model';
const FC = (props) => {
const {visible, service, onCancel} = props;
const [confirmLoading, setConfirmLoading] = useState(false);
const [form] = Form.useForm();
useEffect(() => {
if (visible) {
form?.setFieldsValue({name: service?.odata});
}
}, [visible])
const onOk = async() => {
try {
const row = await form.validateFields();
setConfirmLoading(true);
dispatch({
type: 'pds.enableOData',
payload: {
params: {
pdsDataServiceId: service?.id,
name: row.name,
}
},
callback: data => {
setConfirmLoading(false);
cancel(true);
},
error: () => {
setConfirmLoading(false);
}
});
} catch (errInfo) {
console.log('Validate Failed:', errInfo);
}
}
const reset = () => {
form.resetFields();
setConfirmLoading(false);
}
const cancel = (refresh = false) => {
reset();
onCancel?.(refresh);
}
const footer = [
<Button
key="0"
onClick={() => {cancel()}}
>
取消
</Button>,
<Button
key="1"
type="primary"
loading={confirmLoading}
onClick={onOk}
>
确定
</Button>,
];
return (
<Modal
forceRender
visible={visible}
title={`启用${service?.name}的OData`}
width={540}
onCancel={() => {cancel()}}
footer={footer}
>
<Form form={form}>
<Form.Item
name='name'
label='URI'
rules={[
{
required: true,
message: '请输入URI',
},
]}
>
<Input placeholder='请输入URI' />
</Form.Item>
</Form>
</Modal>
)
}
export default FC;
\ No newline at end of file
import React, { useEffect, useState } from 'react';
import React, { useState } from 'react';
import { Modal, Form, Input } from 'antd';
import LocalStorage from 'local-storage';
import { dispatch } from '../../../../model';
import { dispatchLatest } from '../../../../model';
import { showMessage, showNotifaction } from '../../../../util';
const UpdatePartitionModal = (props) => {
const { visible, onCancel, item, action = 'add' } = props;
const FC = (props) => {
const { visible, onCancel, ids } = props;
const [ form ] = Form.useForm();
const [ confirmLoading, setConfirmLoading ] = useState(false);
......@@ -20,38 +22,25 @@ const UpdatePartitionModal = (props) => {
},
};
useEffect(() => {
if (visible) {
if (action !== 'add') {
form.setFieldsValue({ name: item?.name||'', cnName: item?.cnName||'', partitionMethod: item?.partitionMethod||'', definition: item?.definition||'', remark: item?.remark||'' });
}
}
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [visible])
const handleOk = async () => {
try {
const values = await form.validateFields();
let newItem = null;
if (action === 'add') {
newItem = {...values};
} else {
newItem = {...item, ...values};
}
setConfirmLoading(true);
dispatch({
type: 'datamodel.savePartitionType',
dispatchLatest({
type: 'pds.offline',
payload: {
data: newItem
params: {
reason: values?.desc
},
data: ids
},
callback: data => {
setConfirmLoading(false);
callback: () => {
reset();
showMessage('success', '停用成功')
onCancel && onCancel(true);
},
error: () => {
......@@ -73,7 +62,7 @@ const UpdatePartitionModal = (props) => {
<Modal
forceRender
visible={visible}
title={action==='add'?'新增分区':'编辑分区'}
title='服务停用'
width={520}
confirmLoading={confirmLoading}
onCancel={() => {
......@@ -87,41 +76,15 @@ const UpdatePartitionModal = (props) => {
form={form}
>
<Form.Item
label="名称"
name="name"
rules={[{ required: true, message: '请输入分区名称' }]}
>
<Input />
</Form.Item>
<Form.Item
label="中文名称"
name="cnName"
rules={[{ required: true, message: '请输入分区中文名称' }]}
>
<Input />
</Form.Item>
<Form.Item
label="分区方式"
name="partitionMethod"
rules={[{ required: true, message: '请输入分区方式' }]}
>
<Input />
</Form.Item>
<Form.Item
label="定义"
name="definition"
>
<Input.TextArea row={4} />
</Form.Item>
<Form.Item
label="描述"
name="remark"
label="停用原因"
name="desc"
// rules={[{ required: true, message: '请填写停用原因' }]}
>
<Input.TextArea row={4} />
<Input.TextArea rows={6} />
</Form.Item>
</Form>
</Modal>
);
}
export default UpdatePartitionModal;
\ No newline at end of file
export default FC;
\ No newline at end of file
......@@ -17,17 +17,17 @@ const RecatalogModal = (props) => {
const onOk = () => {
if ((catalogId||'') === '') {
showMessage('warn', '请先选择模型目录');
showMessage('warn', '请先选择服务目录');
return;
}
setConfirmLoading(true);
dispatch({
type: 'datamodel.recatalogDataModel',
type: 'pds.recatalogService',
payload: {
params: {
easyDataModelCatalogId: catalogId,
easyDataModelerDataModelIds: ids.join(',')
pdsDataServiceCatalogId: catalogId,
pdsDataServiceIds: ids.join(',')
},
},
callback: message => {
......
import React, { useEffect, useState } from 'react';
import { Modal, Button, Form, Input, Table, Tooltip, Typography } from 'antd';
import { dispatch } from '../../../../model';
const FC = (props) => {
const {visible, service, onCancel} = props;
const [loading, setLoading] = useState(false);
const [data, setData] = useState(undefined);
const [cols, setCols] = useState([]);
useEffect(() => {
if (visible) {
getSample();
}
}, [visible])
const getSample = () => {
setLoading(true)
dispatch({
type: 'pds.getSample',
payload: {
params: {
pdsDataServiceId: service?.id,
}
},
callback: data => {
setLoading(false);
setData(data?.content||[]);
const newCols = [];
data?.headers?.forEach(item => {
if (item) {
newCols.push({
title: item,
dataIndex: item,
width: 150,
ellipsis: true,
render: (value, record) => <Tooltip title={value}>
<Typography.Text ellipsis={true}>{value}</Typography.Text>
</Tooltip>
});
}
});
setCols(newCols);
},
error: () => {
setLoading(false);
}
});
}
const cancel = () => {
setLoading(false);
setData(undefined);
onCancel?.();
}
const footer = [
<Button
key="0"
onClick={() => {cancel()}}
>
取消
</Button>,
];
return (
<Modal
forceRender
visible={visible}
title={`${service?.name}的样本数据`}
width={650}
onCancel={() => {cancel()}}
footer={footer}
>
<Table
loading={loading}
columns={cols}
dataSource={data||[]}
size='small'
scroll={{ x: 600, y: 300 }}
pagination={false}
/>
</Modal>
)
}
export default FC;
\ No newline at end of file
import React, { useState, useMemo, useEffect } from "react"
import {Select} from "antd"
import debounce from 'lodash/debounce';
const {Option} = Select
const FC = ({ value, onChange, data, ...restProps }) => {
const [searchValue, setSearchValue] = useState(undefined)
const debounceFetcher = useMemo(() => {
return debounce((value) => {
setSearchValue(value);
}, 800);
}, []);
const filterData = useMemo(() => {
if (searchValue) {
return data?.filter(item => item.includes(searchValue));
}
return data||[];
}, [data, searchValue])
const change = (value) => {
onChange?.(value)
}
return (
<Select
style={{width:'100%'}}
showSearch
value={value}
onChange={change}
allowClear
filterOption={false}
onSearch={debounceFetcher}
{...restProps}
>
{
filterData?.map((item, index)=>{
return(
<Option value={item} key={index}>{item}</Option>
)
})
}
</Select>
)
}
export default FC
\ No newline at end of file
import React, { useState, useMemo, useEffect } from "react"
import {Select, Typography} from "antd"
import debounce from 'lodash/debounce';
import { highlightSearchContentByTerms } from '../../../../util';
const {Option} = Select
const SelectUser:React.FC=(props)=>{
const {value,onChange,users,type,loading=false, terms,publishedValue} = props
const [searchValue, setSearchValue] = useState(undefined)
const debounceFetcher = useMemo(() => {
return debounce((value) => {
setSearchValue(value);
}, 800);
}, []);
const filterUsers = useMemo(() => {
if (searchValue) {
return users?.filter(item => item.nachn?.includes(searchValue) || item.pernr?.includes(searchValue));
}
return users||[];
}, [users, searchValue])
const change=(value)=>{
onChange&&onChange(value)
}
if(type==='edit'){
return(
<Select
style={{width:'100%'}}
showSearch
value={value}
onChange={change}
loading={loading}
allowClear
filterOption={false}
onSearch={debounceFetcher}
>
{
filterUsers?.map((item)=>{
return(
<Option value={item.pernr} key={item.pernr}>{`${item.nachn}(${item.pernr})`}</Option>
)
})
}
</Select>
)
}else if(type==='detail'){
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>
// try {
// 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 <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
}
}
export default SelectUser
\ No newline at end of file
import React, { useState, useMemo, useEffect } from 'react'
import { Button, Modal, Spin, Popover, Table, Descriptions, Tooltip } from 'antd'
import { dispatch } from '../../../../model'
import { highlightSearchContentByTerms } from '../../../../util'
const FC = (props) => {
const { id, terms } = props
const [data, setData] = useState()
const [loading, setLoading] = useState(false)
const columns = [
{
title: '序号',
dataIndex: 'key',
editable: false,
width: 60,
fixed: 'left',
render: (text, record, index) => {
return (index+1).toString();
}
},
{
title: '中文名称',
width: 200,
dataIndex: 'cnName',
editable: true,
ellipsis: true,
require: true,
fixed: 'left',
render: (text, _, __) => {
return (
<Tooltip title={text||''}>
<span>
{highlightSearchContentByTerms(text, terms)}
</span>
</Tooltip>
)
}
},
{
title: '英文名称',
width: 200,
dataIndex: 'name',
editable: true,
ellipsis: true,
require: true,
render: (text, record, index) => {
return (
<Tooltip title={text||''}>
<span style={{ fontWeight: 'bold' }} >{highlightSearchContentByTerms(text, terms)}</span>
</Tooltip>
)
}
},
{
title: '类型',
width: 150,
dataIndex: 'datatype',
editable: true,
ellipsis: true,
require: true,
render: (_, record, __) => {
if (record?.datatype) {
if ((record?.datatype?.name==='Char'||record?.datatype?.name==='Varchar') && record?.datatype?.parameterValues?.length>0) {
return `${record?.datatype?.name||''}(${(record?.datatype?.parameterValues[0]?record.datatype.parameterValues[0]:0)})`;
} else if ((record?.datatype?.name==='Decimal'||record?.datatype?.name==='Numeric') && record?.datatype?.parameterValues?.length>1) {
return `${record?.datatype?.name||''}(${(record?.datatype?.parameterValues[0]?record.datatype.parameterValues[0]:0)},${(record?.datatype?.parameterValues[1]?record.datatype.parameterValues[1]:0)})`;
}
return record.datatype.name||'';
}
return '';
}
},
]
useEffect(() => {
getService()
}, [])
const getService = () => {
setLoading(true)
dispatch({
type: 'pds.getDataService',
payload: {
id
},
callback: (data) => {
setLoading(false)
setData(data||[])
},
error: () => {
setLoading(false)
}
})
}
return (
<Spin spinning={loading}>
<h3 className='mr-3' style={{ marginBottom: 0 }}>基本信息</h3>
<Descriptions className='mt-3' column={3}>
<Descriptions.Item label={<div style={{ textAlign: 'right', width: 85 }}>中文名称</div>} >{highlightSearchContentByTerms(data?.cnName||'', terms)}</Descriptions.Item>
<Descriptions.Item label={<div style={{ textAlign: 'right', width: 85 }}>英文名称</div>}>{highlightSearchContentByTerms(data?.name||'', terms)}</Descriptions.Item>
<Descriptions.Item label={<div style={{ textAlign: 'right', width: 85 }}>数据内容</div>}>{highlightSearchContentByTerms(data?.remark||'', terms)}</Descriptions.Item>
</Descriptions>
<h3 className='mr-3' style={{ marginBottom: 0 }}>字段列表</h3>
<Table
className='mt-3'
dataSource={data?.pdsdataServiceAttributes||[]}
columns={columns}
size='small'
rowKey='iid'
pagination={false}
sticky
/>
</Spin>
)
}
export default FC
import React, { useState, useMemo, useEffect } from 'react'
import { Button, Modal, Spin, Popover, Table, Descriptions, Tooltip } from 'antd'
import { dispatch } from '../../../../model'
import { highlightSearchContentByTerms } from '../../../../util'
import ServiceDetail from './ServiceDetail'
const FC = (props) => {
const { visible, id, onClose, terms } = props
const close = () => {
onClose?.()
}
return (
<Modal
width={1200}
visible={visible}
destroyOnClose
title='服务详情'
bodyStyle={{ minHeight: 300 }}
footer={<>
<Button onClick={close}>取消</Button>
</>}
onCancel={close}
>
{ visible && <ServiceDetail id={id} terms={terms} /> }
</Modal>
)
}
export default FC
import React, { useState } from 'react';
import { Modal, Form, Input } from 'antd';
import LocalStorage from 'local-storage';
import { dispatchLatest } from '../../../../model';
import { showNotifaction, showMessage } from '../../../../util';
const FC = (props) => {
const { visible, onCancel, services } = props;
const [ form ] = Form.useForm();
const [ confirmLoading, setConfirmLoading ] = useState(false);
const formItemLayout = {
labelCol: {
xs: { span: 24 },
sm: { span: 4 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 20 },
},
};
const handleOk = async () => {
try {
const values = await form.validateFields();
setConfirmLoading(true);
dispatchLatest({
type: 'pds.authorize',
payload: {
params: {
reason: values?.desc
},
data: services
},
callback: () => {
reset();
showMessage('success', '授权成功!');
onCancel && onCancel(true);
},
error: () => {
setConfirmLoading(false);
}
})
} catch (errInfo) {
}
}
const reset = () => {
setConfirmLoading(false);
form.resetFields();
}
return (
<Modal
forceRender
visible={visible}
title='服务授权'
width={520}
confirmLoading={confirmLoading}
onCancel={() => {
reset();
onCancel && onCancel();
}}
onOk={handleOk}
>
<Form
{...formItemLayout}
form={form}
>
<Form.Item
label="授权原因"
name="desc"
rules={[{ required: true, message: '请填写授权原因' }]}
>
<Input.TextArea rows={6} />
</Form.Item>
</Form>
</Modal>
);
}
export default FC;
\ No newline at end of file
import React, { useState } from 'react';
import { Modal, Form, Input } from 'antd';
import LocalStorage from 'local-storage';
import { dispatchLatest } from '../../../../model';
import { showMessage, showNotifaction } from '../../../../util';
const FC = (props) => {
const { visible, onCancel, ids } = props;
const [ form ] = Form.useForm();
const [ confirmLoading, setConfirmLoading ] = useState(false);
const formItemLayout = {
labelCol: {
xs: { span: 24 },
sm: { span: 4 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 20 },
},
};
const handleOk = async () => {
try {
const values = await form.validateFields();
setConfirmLoading(true);
dispatchLatest({
type: 'pds.release',
payload: {
params: {
reason: values?.desc
},
data: ids
},
callback: () => {
reset();
showMessage('success', '发布成功!')
onCancel && onCancel(true);
},
error: () => {
setConfirmLoading(false);
}
})
} catch (errInfo) {
}
}
const reset = () => {
setConfirmLoading(false);
form.resetFields();
}
return (
<Modal
forceRender
visible={visible}
title='服务发布'
width={520}
confirmLoading={confirmLoading}
onCancel={() => {
reset();
onCancel && onCancel();
}}
onOk={handleOk}
>
<Form
{...formItemLayout}
form={form}
>
<Form.Item
label="发布原因"
name="desc"
rules={[{ required: true, message: '请填写发布原因' }]}
>
<Input.TextArea rows={6} />
</Form.Item>
</Form>
</Modal>
);
}
export default FC;
\ No newline at end of file
import React, { useState } from 'react';
import { Table, Tooltip, Typography } from 'antd';
import { Table, Tooltip } from 'antd';
import { Resizable } from 'react-resizable';
import ResizeObserver from 'rc-resize-observer';
......@@ -123,7 +123,7 @@ const SuggestTable = (props) => {
render: (text, _, __) => {
return (
<Tooltip title={text||''}>
<Typography.Text ellipsis={true}>{text||''}</Typography.Text>
<span>{text||''}</span>
</Tooltip>
)
}
......
......@@ -70,6 +70,12 @@ class UpdateTreeItemForm extends React.Component {
>
<Input />
</Form.Item>
<Form.Item
label="编码"
name="code"
>
<Input />
</Form.Item>
</Form>
);
}
......@@ -89,12 +95,12 @@ const UpdateTreeItemModal = (props) => {
_action = item ? 'sub' : 'root';
}
form.setFields([{ name: 'name', errors: [] }, { name: 'remark', errors: [] }]);
form.setFields([{ name: 'name', errors: [] }, { name: 'remark', errors: [] }, { name: 'code', errors: [] }]);
if (type === 'add') {
form.setFieldsValue({ action: _action, name: '', remark: '' });
form.setFieldsValue({ action: _action, name: '', remark: '', code: '' });
} else {
form.setFieldsValue({ action: '', name: item?item.name:'', remark: item?item.remark:'' });
form.setFieldsValue({ action: '', name: item?item.name:'', remark: item?item.remark:'', code: item?.code });
}
}
//eslint-disable-next-line react-hooks/exhaustive-deps
......@@ -112,12 +118,14 @@ const UpdateTreeItemModal = (props) => {
payload = {
name: values.name||'',
remark: values.remark||'',
code: values.code||'',
parentId: rootId
};
} else if (type === 'add') {
payload = {
name: values.name||'',
remark: values.remark||'',
code: values.code||'',
parentId: item.id
};
} else {
......@@ -125,11 +133,12 @@ const UpdateTreeItemModal = (props) => {
...item,
name: values.name||'',
remark: values.remark||'',
code: values.code||'',
}
}
dispatchLatest({
type: 'datamodel.saveDataModelCatalog',
type: 'pds.saveCatalog',
payload: {
data: payload
},
......
......@@ -22,7 +22,7 @@ const VersionHistory = (props) => {
const getVersions = () => {
setLoading(true);
dispatch({
type: 'datamodel.getVersions',
type: 'pds.getVersions',
payload: {
params: {
id
......@@ -39,7 +39,7 @@ const VersionHistory = (props) => {
}
const onVersionItemClick = (version) => {
window.open(`/data-govern/data-model-action?${Action}=detail-version&${ModelerId}=${version.dataModelId||''}&${VersionId}=${version.id||''}`);
// window.open(`/data-govern/data-model-action?${Action}=detail-version&${ModelerId}=${version.dataModelId||''}&${VersionId}=${version.id||''}`);
}
return (
......
import React, { useEffect, useState } from 'react';
import { Input, Table, Tooltip } from 'antd';
import { inputWidth } from '../../../../util';
import { dispatch } from '../../../../model';
const ConstraintDetail = (props) => {
const [ loading, setLoading ] = useState(false);
const [ rules, setRules ] = useState([]);
const [ keyword, setKeyword ] = useState('');
useEffect(() => {
setLoading(true);
dispatch({
type: 'datamodel.getAllConstraints',
callback: data => {
setLoading(false);
const _rules = [];
(data||[]).forEach(constraint => {
(constraint.allRules||[]).forEach(rule => {
_rules.push({...constraint, ...{ ruleName: rule.name||'', ruleDesc: rule.desc||'' }});
});
});
setRules(_rules);
},
error: () => {
setLoading(false);
}
})
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
const columns = [
{
title: '序号',
dataIndex: 'key',
editable: false,
render: (_, __, index) => {
return (index+1).toString();
},
width: 60,
},
{
title: '规范名称',
dataIndex: 'name',
width: 180,
ellipsis: true,
render: (text, _, __) => {
return (
<Tooltip title={text||''}>
<span>{text||''}</span>
</Tooltip>
)
}
},
{
title: '规范中文名称',
dataIndex: 'cnName',
width: 180,
ellipsis: true,
render: (text, _, __) => {
return (
<Tooltip title={text||''}>
<span>{text||''}</span>
</Tooltip>
)
}
},
{
title: '前置依赖',
dataIndex: 'ruleName',
width: 180,
ellipsis: true,
render: (text, _, __) => {
return (
<Tooltip title={text||''}>
<span>{text||''}</span>
</Tooltip>
)
}
},
{
title: '描述',
dataIndex: 'ruleDesc',
ellipsis: true,
render: (text, _, __) => {
return (
<Tooltip title={text||''}>
<span>{text||''}</span>
</Tooltip>
)
}
}
]
const onSearchInputChange = (e) => {
setKeyword(e.target.value||'');
}
return (
<div>
<div className='d-flex mb-3' style={{ alignItems: 'center' }}>
<Input
placeholder="请输入前置依赖名称"
allowClear
value={keyword}
onChange={onSearchInputChange}
style={{ width: inputWidth }}
/>
</div>
<Table
loading={loading}
columns={columns}
rowKey={'ruleName'}
dataSource={(rules||[]).filter(item => (item.ruleName||'').indexOf(keyword)!==-1)}
pagination={false}
sticky
/>
</div>
);
}
export default ConstraintDetail;
\ No newline at end of file
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