2026-04-03 17:35:22 +08:00
|
|
|
import { Connect } from "@cqsjjb/jjb-dva-runtime";
|
|
|
|
|
import { message } from "antd";
|
|
|
|
|
import { useEffect } from "react";
|
|
|
|
|
import FormBuilder from "zy-react-library/components/FormBuilder";
|
|
|
|
|
import Page from "zy-react-library/components/Page";
|
|
|
|
|
import DictionarySelect from "zy-react-library/components/Select/Dictionary";
|
|
|
|
|
import { FORM_ITEM_RENDER_ENUM } from "zy-react-library/enum/formItemRender";
|
|
|
|
|
import useGetUrlQuery from "zy-react-library/hooks/useGetUrlQuery";
|
|
|
|
|
import { PHONE } from "zy-react-library/regular";
|
|
|
|
|
import { NS_EMERGENCY_EQUIPMENT } from "~/enumerate/namespace";
|
|
|
|
|
|
|
|
|
|
function Add(props) {
|
|
|
|
|
const query = useGetUrlQuery();
|
|
|
|
|
const [form] = FormBuilder.useForm();
|
|
|
|
|
|
|
|
|
|
const getData = async () => {
|
|
|
|
|
if (!query.id)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const { data } = await props["emergencyEquipmentInfo"]({ id: query.id });
|
2026-04-07 15:52:33 +08:00
|
|
|
form.setFieldsValue({
|
|
|
|
|
...data,
|
|
|
|
|
validityDate: [data.validityStartDate, data.validityEndDate],
|
|
|
|
|
});
|
2026-04-03 17:35:22 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
getData();
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const onSubmit = async (values) => {
|
|
|
|
|
const { success } = await props[query.id ? "emergencyEquipmentUpdate" : "emergencyEquipmentAdd"]({
|
|
|
|
|
...values,
|
2026-04-07 15:52:33 +08:00
|
|
|
validityStartDate: values.validityDate[0],
|
|
|
|
|
validityEndDate: values.validityDate[1],
|
2026-04-03 17:35:22 +08:00
|
|
|
id: query.id,
|
|
|
|
|
});
|
|
|
|
|
if (success) {
|
|
|
|
|
message.success(query.id ? "编辑成功" : "新增成功");
|
|
|
|
|
props.history.goBack();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Page headerTitle={query.id ? "编辑" : "新增"} isShowFooter={false}>
|
|
|
|
|
<FormBuilder
|
|
|
|
|
loading={props.emergencyEquipment.emergencyEquipmentLoading}
|
|
|
|
|
options={[
|
2026-04-07 15:52:33 +08:00
|
|
|
{ name: "equipmentName", label: "装备名称" },
|
|
|
|
|
{
|
|
|
|
|
name: "equipmentCategory",
|
|
|
|
|
label: "装备类别",
|
|
|
|
|
render: (
|
|
|
|
|
<DictionarySelect
|
|
|
|
|
dictValue="emergencyEquipmentCategory"
|
|
|
|
|
onGetLabel={(label) => {
|
|
|
|
|
form.setFieldValue("equipmentCategoryName", label);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
{ name: "equipmentCategoryName", label: "装备类别名称", onlyForLabel: true },
|
|
|
|
|
{ name: "specModel", label: "规格型号" },
|
|
|
|
|
{ name: "technicalPerformance", label: "技术性能指标" },
|
|
|
|
|
{ name: "maintenanceCycle", label: "保养周期" },
|
|
|
|
|
{ name: "validityDate", label: "有效期", render: FORM_ITEM_RENDER_ENUM.DATE_RANGE },
|
|
|
|
|
{ name: "usageDescription", label: "用途说明", render: FORM_ITEM_RENDER_ENUM.TEXTAREA, span: 24 },
|
|
|
|
|
{ name: "storageLocation", label: "存放场所", span: 24 },
|
|
|
|
|
{ name: "custodianName", label: "负责保管人姓名" },
|
|
|
|
|
{ name: "custodianPhone", label: "负责保管人电话", rules: [{ pattern: PHONE, message: "请输入正确的电话号码" }] },
|
2026-04-03 17:35:22 +08:00
|
|
|
]}
|
|
|
|
|
form={form}
|
|
|
|
|
onFinish={onSubmit}
|
|
|
|
|
/>
|
|
|
|
|
</Page>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Connect([NS_EMERGENCY_EQUIPMENT], true)(Add);
|