企业预案管理

master
LiuJiaNan 2026-04-10 14:21:06 +08:00
parent 3af4efd132
commit d1b1eee4dd
7 changed files with 74 additions and 53 deletions

View File

@ -16,34 +16,23 @@ function BasicInfo(props) {
const [enterprisePlanEventType, setEnterprisePlanEventType] = useState([]);
const getData = async () => {
if (!props.planId)
return;
const { data } = await props["enterprisePlanBasicInfoInfo"]({ id: props.planId });
form.setFieldsValue({
...data,
eventType: data.eventType ? data.eventType.split(",") : [],
eventTypeName: data.eventTypeName ? data.eventTypeName.split(",") : [],
});
};
const getEnterprisePlanEventType = async () => {
const dictionaryItems = await getDictionary({ dictValue: "enterprisePlanEventType" });
setEnterprisePlanEventType(dictionaryItems);
};
useEffect(() => {
getData();
}, [props.planId]);
useEffect(() => {
getEnterprisePlanEventType();
}, []);
useEffect(() => {
form.setFieldsValue(props.basicInfo);
}, [props.basicInfo]);
const onSubmit = async (values) => {
const { success, data } = await props[!props.planId ? "enterprisePlanBasicInfoAdd" : "enterprisePlanBasicInfoUpdate"]({
...values,
id: props.planId,
eventType: values.eventType.join(","),
eventTypeName: values.eventTypeName.join(","),
});
@ -51,9 +40,9 @@ function BasicInfo(props) {
message.success("保存成功");
props.setUrlState({
planId: data?.id || props.planId,
planName: values.planName,
currentStep: "gradeResponse",
});
props.getBasicInfo();
}
};

View File

@ -1,5 +1,6 @@
import { Connect } from "@cqsjjb/jjb-dva-runtime";
import { message } from "antd";
import { Button, message, Space } from "antd";
import { useEffect } from "react";
import FormBuilder from "zy-react-library/components/FormBuilder";
import { FORM_ITEM_RENDER_ENUM } from "zy-react-library/enum/formItemRender";
import { NS_ENTERPRISE_PLAN } from "~/enumerate/namespace";
@ -7,6 +8,10 @@ import { NS_ENTERPRISE_PLAN } from "~/enumerate/namespace";
function PlanText(props) {
const [form] = FormBuilder.useForm();
useEffect(() => {
form.setFieldsValue(props.basicInfo);
}, [props.basicInfo]);
const onSubmit = async (values) => {
const { success } = await props["enterprisePlanBasicInfoUpdate"]({
...values,
@ -15,17 +20,25 @@ function PlanText(props) {
if (success) {
message.success("保存成功");
props.setUrlState({ currentStep: "planAttachments" });
props.getBasicInfo();
}
};
return (
<FormBuilder
loading={props.enterprisePlan.enterprisePlanBasicInfoLoading}
values={{
planName: props.planName,
}}
span={24}
submitButtonText="保存并下一步"
customActionButtons={(
<Space>
<Button onClick={() => {
props.setUrlState({ currentStep: "planInstructions" });
}}
>
上一步
</Button>
<Button type="primary" onClick={form.submit}>保存并下一步</Button>
</Space>
)}
options={[
{ name: "planName", label: "预案名称", componentProps: { disabled: true } },
{ name: "planText", label: "预案文本", render: FORM_ITEM_RENDER_ENUM.TEXTAREA, required: false },

View File

@ -22,7 +22,6 @@ function Add(props) {
{
currentStep: "basicInfo",
planId: query.id,
planName: query.planName,
},
{ navigateMode: "replace" },
);
@ -30,6 +29,23 @@ function Add(props) {
const [responseLevelRefresh, setResponseLevelRefresh] = useState(true);
const [executingAgencyRefresh, setExecutingAgencyRefresh] = useState(true);
const [reviewPersonModalVisible, setReviewPersonModalVisible] = useState(false);
const [basicInfo, setBasicInfo] = useState({});
const getBasicInfo = async () => {
if (!urlState.planId)
return;
const { data } = await props["enterprisePlanBasicInfoInfo"]({ id: urlState.planId });
setBasicInfo({
...data,
eventType: data.eventType ? data.eventType.split(",") : [],
eventTypeName: data.eventTypeName ? data.eventTypeName.split(",") : [],
});
};
useEffect(() => {
getBasicInfo();
}, [urlState.planId]);
const subordinateTabDisabled = !urlState.planId;
const isShowFooter = ["basicInfo", "planText"].includes(urlState.currentStep);
@ -92,6 +108,8 @@ function Add(props) {
<BasicInfo
planId={urlState.planId}
setUrlState={setUrlState}
basicInfo={basicInfo}
getBasicInfo={getBasicInfo}
/>
),
},
@ -143,8 +161,9 @@ function Add(props) {
children: (
<PlanText
planId={urlState.planId}
planName={urlState.planName}
setUrlState={setUrlState}
basicInfo={basicInfo}
getBasicInfo={getBasicInfo}
/>
),
disabled: subordinateTabDisabled,
@ -238,4 +257,4 @@ const ReviewPersonModalComponent = (props) => {
};
const ReviewPersonModal = Connect([NS_ENTERPRISE_PLAN], true)(ReviewPersonModalComponent);
export default Add;
export default Connect([NS_ENTERPRISE_PLAN], true)(Add);

View File

@ -72,7 +72,7 @@ function List(props) {
<Button
type="link"
onClick={() => {
props.history.push(`./view?id=${record.id}&planName=${record.planName}`);
props.history.push(`./view?id=${record.id}`);
}}
>
查看
@ -81,7 +81,7 @@ function List(props) {
<Button
type="link"
onClick={() => {
props.history.push(`./add?id=${record.id}&planName=${record.planName}`);
props.history.push(`./add?id=${record.id}`);
}}
>
编辑

View File

@ -1,19 +1,7 @@
import { Connect } from "@cqsjjb/jjb-dva-runtime";
import { Descriptions } from "antd";
import { useEffect, useState } from "react";
import { NS_ENTERPRISE_PLAN } from "~/enumerate/namespace";
function BasicInfo(props) {
const [info, setInfo] = useState({});
const getData = async () => {
const { data } = await props["enterprisePlanBasicInfoInfo"]({ id: props.planId });
setInfo(data);
};
useEffect(() => {
getData();
}, [props.planId]);
const info = props.info;
return (
<div>
@ -37,4 +25,4 @@ function BasicInfo(props) {
);
}
export default Connect([NS_ENTERPRISE_PLAN], true)(BasicInfo);
export default BasicInfo;

View File

@ -1,8 +1,8 @@
import { Connect } from "@cqsjjb/jjb-dva-runtime";
import { Descriptions } from "antd";
import { NS_ENTERPRISE_PLAN } from "~/enumerate/namespace";
function BasicInfo(props) {
function PlanText(props) {
const info = props.info;
return (
<div>
<Descriptions
@ -10,12 +10,12 @@ function BasicInfo(props) {
column={1}
styles={{ label: { width: 200 } }}
items={[
{ label: "预案名称", children: props.planName },
{ label: "预案文本", children: props.planText },
{ label: "预案名称", children: info.planName },
{ label: "预案文本", children: info.planText },
]}
/>
</div>
);
}
export default Connect([NS_ENTERPRISE_PLAN], true)(BasicInfo);
export default PlanText;

View File

@ -1,7 +1,10 @@
import useUrlState from "@ahooksjs/use-url-state";
import { Connect } from "@cqsjjb/jjb-dva-runtime";
import { Tabs } from "antd";
import { useEffect, useState } from "react";
import Page from "zy-react-library/components/Page";
import useGetUrlQuery from "zy-react-library/hooks/useGetUrlQuery";
import { NS_ENTERPRISE_PLAN } from "~/enumerate/namespace";
import BasicInfo from "./components/BasicInfo";
import GradeResponse from "./components/GradeResponse";
import OrganizationStructure from "./components/OrganizationStructure";
@ -10,17 +13,26 @@ import PlanInstructions from "./components/PlanInstructions";
import PlanResources from "./components/PlanResources";
import PlanText from "./components/PlanText";
function View() {
function View(props) {
const query = useGetUrlQuery();
const [urlState, setUrlState] = useUrlState(
{
currentStep: "basicInfo",
planId: query.id,
planName: query.planName,
},
{ navigateMode: "replace" },
);
const [basicInfo, setBasicInfo] = useState({});
const getData = async () => {
const { data } = await props["enterprisePlanBasicInfoInfo"]({ id: query.id });
setBasicInfo(data);
};
useEffect(() => {
getData();
}, []);
return (
<Page headerTitle="查看">
<Tabs
@ -30,7 +42,7 @@ function View() {
{
key: "basicInfo",
label: "基本信息",
children: (<BasicInfo planId={query.id} />),
children: (<BasicInfo info={basicInfo} />),
},
{
key: "gradeResponse",
@ -55,7 +67,7 @@ function View() {
{
key: "planText",
label: "预案文案",
children: (<PlanText planId={query.id} planName={urlState.planName} />),
children: (<PlanText info={basicInfo} />),
},
{
key: "planAttachments",
@ -68,4 +80,4 @@ function View() {
);
}
export default View;
export default Connect([NS_ENTERPRISE_PLAN], true)(View);