system-copyright-react/src/route/proj/edit/ProjConfigModShow.tsx

158 lines
7.0 KiB
TypeScript
Raw Normal View History

2024-03-24 12:15:40 +08:00
import './proj-config-list-mod.css';
import {
Alert,
2024-05-28 18:00:42 +08:00
Button, Col, Form, Input,
2024-03-24 12:15:40 +08:00
message, Row,
} from "antd";
2024-05-28 18:00:42 +08:00
// import { useNavigate, useParams } from "react-router-dom";
2024-05-22 16:18:38 +08:00
import { useEffect, useState } from "react";
import ModField, { IModField } from "../../../components/modfield/ModField.tsx";
import { get } from "../../../util/AjaxUtils.ts";
import { MAX_MOD_SIZE, MAX_MOD_SIZE_FREE, MIN_MOD_SIZE, MIN_MOD_SIZE_FREE } from "./ProjConfigModList.tsx";
2024-03-24 12:15:40 +08:00
type FormFieldType = {
projId: string;
modName: string;
modDesc: string;
modIcon: string;
fields: IModField[];
}
2024-04-12 18:18:14 +08:00
type PropsType = {
isFree?: boolean;
2024-05-28 18:00:42 +08:00
projModId?:string
2024-04-12 18:18:14 +08:00
}
export default function ProjConfigModShow(props: PropsType) {
2024-05-28 18:00:42 +08:00
// const nav = useNavigate();
// const pathParams = useParams();
2024-03-24 12:15:40 +08:00
const [messageApi, contextHolder] = message.useMessage();
const [form] = Form.useForm<FormFieldType>();
const [selectedModIcon, setSelectedModIcon] = useState<string>('fa fa-list');
const [fields, setFields] = useState<IModField[]>([]);
2024-04-12 18:18:14 +08:00
const minSize = props.isFree ? MIN_MOD_SIZE_FREE : MIN_MOD_SIZE;
const maxSize = props.isFree ? MAX_MOD_SIZE_FREE : MAX_MOD_SIZE;
2024-03-24 12:15:40 +08:00
2024-05-28 18:00:42 +08:00
const height = window.innerHeight - 215;
2024-03-24 12:15:40 +08:00
useEffect(() => {
2024-04-01 20:39:22 +08:00
get<any>({
2024-03-24 12:15:40 +08:00
messageApi,
2024-05-28 18:00:42 +08:00
url: `api/proj-mod/get/${props.projModId}`,
2024-05-22 16:18:38 +08:00
onSuccess({ data }) {
2024-03-24 12:15:40 +08:00
form.setFieldsValue({
projId: data.projId,
modName: data.modName,
modDesc: data.modDesc,
modIcon: data.modIcon,
fields: data.fields,
});
setSelectedModIcon(data.modIcon);
setFields(data.fields)
}
})
}, [])
return (
<>
{contextHolder}
2024-05-22 16:18:38 +08:00
{/* <Breadcrumb
2024-03-24 12:15:40 +08:00
items={[
{title: <Link to={'/'}></Link>},
{title: <Link to={'/proj-create'}></Link>},
2024-04-12 18:18:14 +08:00
{
title: <a onClick={() => {
if(props.isFree) {
nav(`/proj-efree/${pathParams.projId}`)
} else {
`/proj-edit/${pathParams.projId}`
}
}}></a>
},
{
title: <a onClick={() => {
nav(-1);
}}></a>
},
2024-03-24 12:15:40 +08:00
{title: '查看菜单'},
]}
2024-05-22 16:18:38 +08:00
/> */}
2024-05-28 18:00:42 +08:00
<div className="mod-edit-container" style={{ height: `${height}px`}}>
2024-05-22 16:18:38 +08:00
<div style={{ height: `${height}px`, overflow: 'auto' }}>
<Alert message={`菜单指的是系统的功能,最少${minSize}个菜单,最多${maxSize}个菜单`} type="info" />
<div className="mod-content" >
<Form
name="basic"
form={form}
layout="vertical"
labelCol={{ span: 8 }}
wrapperCol={{ span: 24 }}
style={{ width: '100%' }}
autoComplete="off"
>
<Row gutter={15}>
<Col span={10}>
<Form.Item<FormFieldType>
label="菜单名称"
name="modName"
extra="此内容会作为菜单名生成菜单最多8个字"
rules={[{ required: true, message: '请输入菜单名称' }]}
>
<Input placeholder="请输入菜单名称" maxLength={8} readOnly />
</Form.Item>
<Form.Item<FormFieldType>
label="菜单说明"
name="modDesc"
extra="此内容会作为功能描述生成到操作手册中请详细描述最多600字"
rules={[{ required: true, message: '请输入菜单说明' }]}
>
<Input.TextArea placeholder="请输入菜单说明" rows={6} maxLength={600} readOnly />
</Form.Item>
<Form.Item<FormFieldType>
label="菜单图标"
name="modIcon"
extra="菜单图标会显示在菜单栏中"
rules={[{ required: true, message: '请输入菜单图标' }]}
>
<Button size="large"><i className={selectedModIcon}></i></Button>
</Form.Item>
</Col>
<Col span={14}>
<Form.Item<FormFieldType>
name="fields"
rules={[{ required: true, message: '请添加菜单属性' }]}
>
<ModField modFiledArray={fields}
isEdit={false}
scrollHeight={height - 380}
handleChange={(dataArray) => {
if (!dataArray) {
return;
}
form.setFieldValue('fields', dataArray);
}} />
</Form.Item>
</Col>
</Row>
2024-03-24 12:15:40 +08:00
2024-05-22 16:18:38 +08:00
<Form.Item wrapperCol={{ span: 24 }}>
<div style={{ paddingTop: '15px' }}>
2024-05-28 18:00:42 +08:00
{/* <Flex align="center" justify="center" gap="large">
2024-05-22 16:18:38 +08:00
<Button type="default" size='large' htmlType="button" onClick={() => {
nav(-1);
}}>
</Button>
2024-05-28 18:00:42 +08:00
</Flex> */}
2024-05-22 16:18:38 +08:00
</div>
</Form.Item>
</Form>
2024-03-24 12:15:40 +08:00
2024-05-22 16:18:38 +08:00
</div>
2024-03-24 12:15:40 +08:00
</div>
</div>
</>
)
}