feat(component): 实现组件列表页面及新增组件弹窗
parent
9ce152a85c
commit
4a9390a211
@ -0,0 +1,9 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
|
// 公共路径
|
||||||
|
const urlPrefix = '/api/v1/bpms-workbench';
|
||||||
|
|
||||||
|
// 我的组件
|
||||||
|
export function getMyComponentList(params) {
|
||||||
|
return axios.get(`${urlPrefix}/componentBase/list`, { params });
|
||||||
|
}
|
||||||
@ -0,0 +1,146 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
import { Modal, Form, Input, Grid, Space, Divider, Button, Table, TableColumnProps } from '@arco-design/web-react';
|
||||||
|
import styles from './style/addComponentModal.module.less';
|
||||||
|
import Cover from '@/pages/scene/cover';
|
||||||
|
|
||||||
|
const FormItem = Form.Item;
|
||||||
|
|
||||||
|
const columns: TableColumnProps[] = [
|
||||||
|
{
|
||||||
|
title: '接口名称',
|
||||||
|
dataIndex: 'name'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '输入参数',
|
||||||
|
dataIndex: 'salary'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '输出参数',
|
||||||
|
dataIndex: 'address'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
dataIndex: 'email'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
const data = [
|
||||||
|
{
|
||||||
|
key: '1',
|
||||||
|
name: 'Jane Doe',
|
||||||
|
salary: 23000,
|
||||||
|
address: '32 Park Road, London',
|
||||||
|
email: 'jane.doe@example.com'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
const AddComponentModal = ({ visible, setVisible }) => {
|
||||||
|
const [selectedImage, setSelectedImage] = useState('');
|
||||||
|
const [form] = Form.useForm();
|
||||||
|
|
||||||
|
const transformImageUrl = (image: string) => {
|
||||||
|
if (!image) return;
|
||||||
|
if (image.includes('/')) setSelectedImage(image.split('/')[image.split('/').length - 1]);
|
||||||
|
else setSelectedImage(image);
|
||||||
|
};
|
||||||
|
|
||||||
|
const modalFooter = () => {
|
||||||
|
return (
|
||||||
|
<Space size={30}>
|
||||||
|
<Button size="small" type="secondary" style={{ borderRadius: 5 }}>代码初始化</Button>
|
||||||
|
<Button size="small" type="outline" style={{ borderRadius: 5 }}>取消</Button>
|
||||||
|
<Button size="small" type="primary" style={{ borderRadius: 5 }}>保存</Button>
|
||||||
|
</Space>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
className={styles['add-component-modal']}
|
||||||
|
title="新增组件"
|
||||||
|
visible={visible}
|
||||||
|
onOk={() => setVisible(false)}
|
||||||
|
onCancel={() => setVisible(false)}
|
||||||
|
autoFocus={false}
|
||||||
|
focusLock={true}
|
||||||
|
style={{ width: '60%' }}
|
||||||
|
footer={modalFooter}
|
||||||
|
>
|
||||||
|
<Form form={form} className={styles['add-component-container']}>
|
||||||
|
<div className={styles['first-half']}>
|
||||||
|
<div className={styles['component-preview']}>
|
||||||
|
<FormItem label="图标:">
|
||||||
|
<Cover
|
||||||
|
defaultImage={selectedImage}
|
||||||
|
imgWidth={100}
|
||||||
|
onImageChange={(selectedImage) => transformImageUrl(selectedImage)}
|
||||||
|
/>
|
||||||
|
</FormItem>
|
||||||
|
<FormItem label="组件预览:">
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
width: '80%',
|
||||||
|
height: 200,
|
||||||
|
border: '1px solid #dcdfe6',
|
||||||
|
borderRadius: 5
|
||||||
|
}}
|
||||||
|
|
||||||
|
>组件外壳
|
||||||
|
</div>
|
||||||
|
</FormItem>
|
||||||
|
</div>
|
||||||
|
<div className={styles['component-info']}>
|
||||||
|
<Grid.Row gutter={8}>
|
||||||
|
<Grid.Col span={12}>
|
||||||
|
<FormItem label="名称:">
|
||||||
|
<Input style={{ width: '90%' }} allowClear placeholder="请输入名称" />
|
||||||
|
</FormItem>
|
||||||
|
</Grid.Col>
|
||||||
|
<Grid.Col span={12}>
|
||||||
|
<FormItem label="名称:">
|
||||||
|
<Input style={{ width: '90%' }} allowClear placeholder="请输入名称" />
|
||||||
|
</FormItem>
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid.Row>
|
||||||
|
<Grid.Row gutter={8}>
|
||||||
|
<Grid.Col span={12}>
|
||||||
|
<FormItem label="名称:">
|
||||||
|
<Input style={{ width: '90%' }} allowClear placeholder="请输入名称" />
|
||||||
|
</FormItem>
|
||||||
|
</Grid.Col>
|
||||||
|
<Grid.Col span={12}>
|
||||||
|
<FormItem label="名称:">
|
||||||
|
<Input style={{ width: '90%' }} allowClear placeholder="请输入名称" />
|
||||||
|
</FormItem>
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid.Row>
|
||||||
|
<Grid.Row gutter={8}>
|
||||||
|
<Grid.Col span={12}>
|
||||||
|
<FormItem label="名称:">
|
||||||
|
<Input style={{ width: '90%' }} allowClear placeholder="请输入名称" />
|
||||||
|
</FormItem>
|
||||||
|
</Grid.Col>
|
||||||
|
<Grid.Col span={12}>
|
||||||
|
<FormItem label="名称:">
|
||||||
|
<Input style={{ width: '90%' }} allowClear placeholder="请输入名称" />
|
||||||
|
</FormItem>
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid.Row>
|
||||||
|
<FormItem label="名称:">
|
||||||
|
富文本编辑器
|
||||||
|
</FormItem>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={styles['last-half']}>
|
||||||
|
<div className={styles['last-half-header']}>
|
||||||
|
<p> 组件接口</p>
|
||||||
|
<Button size="mini" type="primary" style={{ borderRadius: 5 }}>+ 新增接口</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Table columns={columns} data={data} pagination={false} />
|
||||||
|
</div>
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AddComponentModal;
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
.add-component-modal {
|
||||||
|
:global(.arco-modal-content) {
|
||||||
|
padding-left: 0;
|
||||||
|
padding-right: 0;
|
||||||
|
background-color: #f7f8fa
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.add-component-container {
|
||||||
|
|
||||||
|
.first-half {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
|
||||||
|
.component-preview {
|
||||||
|
overflow: hidden;
|
||||||
|
width: 30%;
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 15px 5px;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
border-top-right-radius: 5px;
|
||||||
|
border-bottom-right-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.component-info {
|
||||||
|
width: 67%;
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 15px 5px;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
border-top-left-radius: 5px;
|
||||||
|
border-bottom-left-radius: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.last-half {
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 100%;
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 15px 20px;
|
||||||
|
|
||||||
|
.last-half-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue