Commit 945c34ea authored by 陈前坚's avatar 陈前坚

feat: dictionary

parent 7b67f75d
import React from 'react';
import { Table, Row, Col } from 'antd';
const appDic = () => {
console.log('123');
return (
<Row>
<Col span={12}>
<Table
size="small"
bordered
// columns={columns}
// dataSource={data0}
scroll={{ x: 'max-content' }}
pagination={{
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`,
pageSizeOptions: [10, 20, 50, 100],
defaultPageSize: 10,
showQuickJumper: true,
showSizeChanger: true,
}}
/>
</Col>
<Col span={12}>
<Table
size="small"
bordered
// columns={columns}
// dataSource={data0}
scroll={{ x: 'max-content' }}
pagination={{
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`,
pageSizeOptions: [10, 20, 50, 100],
defaultPageSize: 10,
showQuickJumper: true,
showSizeChanger: true,
}}
/>
</Col>
</Row>
);
};
export default appDic;
import React, { useState, useEffect } from 'react';
import {
Table,
Modal,
Form,
Input,
Space,
Button,
Popconfirm,
notification,
message,
} from 'antd';
import { get } from '@/services/index';
import styles from './WebDic.less';
const WebDic = () => {
const [loading, setLoading] = useState(false);
const [editVisible, setEditVisible] = useState(false);
// const [editValue, setEditValue] = useState('');
// const [description, setDescription] = useState('');
const [data, setData] = useState([]);
const [subData, setSubData] = useState([]);
const [select, setSelect] = useState({});
const [editForm] = Form.useForm();
const columns = [
{
title: '名称',
dataIndex: 'nodeName',
key: 'nodeName',
width: 300,
},
{
title: '值',
dataIndex: 'nodeValue',
key: 'nodeValue',
},
{
title: '操作',
key: 'action',
width: 200,
render: record => (
<Space>
<Button
type="primary"
size="small"
onClick={e => {
e.stopPropagation();
setSelect(record);
setEditVisible(true);
console.log(record);
editForm.setFieldsValue({
nodeName: record.nodeName,
nodeValue: record.nodeValue,
});
}}
>
修改
</Button>
<Popconfirm
title="是否删除该数据?"
okText="确认"
cancelText="取消"
// onConfirm={submitDelete}
>
<Button
size="small"
danger
onClick={e => {
e.stopPropagation();
setSelect(record);
}}
>
删除
</Button>
</Popconfirm>
</Space>
),
},
];
useEffect(() => {
getData('-1');
}, []);
const getData = value => {
setLoading(true);
get(`/Cityinterface/rest/services/OMS.svc/D_GetDataDictionaryList`, {
_version: 9999,
_dc: new Date().getTime(),
nodeID: value,
key: '',
})
.then(res => {
if (res.length > 0) {
res.map(item => {
item.key = item.nodeID;
return item;
});
if (value === '-1') {
setData(res); // 设置一级条目
} else if (value) {
setSubData(res); // 设置二级条目
}
// 获取二级条目
if (res && res[0] && res[0].parentID === '-1') {
getData(res[0].nodeID);
}
} else {
notification.error({
message: '获取失败',
description: res.message,
});
}
setLoading(false);
})
.catch(err => {
setLoading(false);
message.error(err);
});
};
const setRowClassName = record =>
record.nodeID === select.nodeID ? styles.clickRowStyle : '';
const submitEdit = () => {
const nodeName = editForm.getFieldValue('nodeName');
const nodeValue = editForm.getFieldValue('nodeValue');
};
return (
<div className={styles.WebDic}>
<Table
size="small"
bordered
columns={columns}
dataSource={data}
scroll={{ x: 'max-content' }}
rowClassName={setRowClassName}
onRow={record => ({
onClick: () => {
getData(record.nodeID);
setSelect(record);
},
})}
pagination={{
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`,
pageSizeOptions: [10, 20, 50, 100],
showQuickJumper: true,
showSizeChanger: true,
}}
/>
<Table
size="small"
bordered
columns={columns}
dataSource={subData}
scroll={{ x: 'max-content' }}
pagination={{
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`,
pageSizeOptions: [10, 20, 50, 100],
showQuickJumper: true,
showSizeChanger: true,
}}
/>
{/* 修改 */}
<Modal
title={select.parentID === '-1' ? '修改一级条目' : '修改二级条目'}
visible={editVisible}
onOk={submitEdit}
onCancel={() => {
setEditVisible(false);
}}
okText="确认"
cancelText="取消"
>
<Form form={editForm} labelCol={{ span: 3 }}>
<Form.Item
name="nodeName"
label="名称"
rules={[{ required: true, message: '不能为空' }]}
>
<Input placeholder="请输入名称" />
</Form.Item>
{select.nodeID !== '-1' && (
<Form.Item
name="nodeValue"
label="值"
rules={[{ required: true, message: '不能为空' }]}
>
<Input placeholder="请输入值" />
</Form.Item>
)}
</Form>
</Modal>
</div>
);
};
export default WebDic;
.WebDic{
overflow: auto;
height:calc(100vh-200px);
.ant-table-thead tr th{
font-weight: 600;
color:rgba(0,0,0,0.85);
}
.ant-pagination{
z-index: 999;
background: white;
margin: 2px 0px;
padding:6px 10px;
}
.ant-table-tbody{
.clickRowStyle{
background: #74bafc;
}
.clickRowStyle:hover>td{
background: #aed8fa;
}
}
}
\ No newline at end of file
import React from 'react';
import { Tabs, Card } from 'antd';
import PageContainer from '@/components/BasePageContainer';
import WebDic from './WebDic';
import AppDic from './AppDic';
// import VersionPublish from './VersionPublish';
const dictionary = () => {
const { TabPane } = Tabs;
return (
<PageContainer>
<Card>
<Tabs defaultActiveKey="1" type="card">
<TabPane tab="web数据字典" key="1">
<WebDic />
</TabPane>
<TabPane tab="app数据字典" key="2" type="card">
<AppDic />
</TabPane>
</Tabs>
</Card>
</PageContainer>
);
};
export default dictionary;
......@@ -39,6 +39,11 @@
.ant-dropdown-menu-item > .anticon:first-child {
vertical-align: 0.15em !important;
}
.ant-table-tbody{
.ant-table-row:hover>td{
background: #aed8fa !important;
}
}
}
.redText{
color: red;
......
......@@ -22,6 +22,7 @@ import CurrentSolution from '@/pages/database/CurrentSolution';
import UserManage from '../pages/userCenter/UserManage';
import RoleManage from '@/pages/userCenter/roleManage/RoleManage';
import SiteManage from '../pages/userCenter/siteManage/SiteManage';
import Dictionary from '../pages/platformCenter/dictionary';
import ServiceLog from '../pages/log/serviceLog';
import LoginLog from '../pages/log/loginLog';
import OmsLog from '../pages/log/omsLog';
......@@ -194,7 +195,7 @@ export default {
{
path: '/platformCenter/dictionary',
name: '数据字典',
component: Welcome,
component: Dictionary,
},
],
},
......
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