diff --git a/src/api/rescueTeam/index.js b/src/api/rescueTeam/index.js index 97ffc4b..c12ccce 100644 --- a/src/api/rescueTeam/index.js +++ b/src/api/rescueTeam/index.js @@ -24,3 +24,8 @@ export const rescueTeamDelete = declareRequest( "rescueTeamLoading", `Delete >@/fireResource/rescueTeam/{id}`, ); + +export const rescueTeamCheckName = declareRequest( + "rescueTeamLoading", + `Post >@/fireResource/rescueTeam/checkName`, +); diff --git a/src/pages/Container/BranchCompany/ControlRoom/Add/index.js b/src/pages/Container/BranchCompany/ControlRoom/Add/index.js index e0e027d..88e1562 100644 --- a/src/pages/Container/BranchCompany/ControlRoom/Add/index.js +++ b/src/pages/Container/BranchCompany/ControlRoom/Add/index.js @@ -35,6 +35,7 @@ function Add(props) { const [mapOpen, setMapOpen] = useState(false); const [mapLng, setMapLng] = useState(""); const [mapLat, setMapLat] = useState(""); + const pageTitle = query.id ? "编辑" : "新增"; // 设备列表 const createEmptyDevice = () => ({ @@ -131,6 +132,7 @@ function Add(props) { const handleMapConfirm = (lng, lat) => { form.setFieldsValue({ lng, lat }); + form.validateFields(["lng", "lat"]).catch(() => {}); setMapOpen(false); }; @@ -144,6 +146,10 @@ function Add(props) { }; const removeDevice = (key) => { + if (devices.length <= 1) { + message.warning("设备信息至少保留一条"); + return; + } const index = devices.findIndex(item => item.key === key); const newDevices = devices.filter(item => item.key !== key); setDevices(newDevices); @@ -172,8 +178,8 @@ function Add(props) { }; const removePerson = (key) => { - if (persons.length === 1) { - message.warning("至少保留一条人员数据"); + if (persons.length <= 1) { + message.warning("人员信息至少保留一条"); return; } const index = persons.findIndex(item => item.key === key); @@ -222,6 +228,19 @@ function Add(props) { const validDevices = devices.filter( device => device.deviceName || device.deviceModel || device.deviceQty || device.deviceLocation, ); + const validPersons = persons.filter( + person => person.personName || person.personPhone || person.dutyDesc, + ); + + if (validDevices.length === 0) { + message.warning("设备信息至少保留一条"); + return; + } + + if (validPersons.length === 0) { + message.warning("人员信息至少保留一条"); + return; + } const params = { ...values, @@ -233,7 +252,7 @@ function Add(props) { deviceLocation: device.deviceLocation, ...(device.id && { id: device.id }), })), - persons: persons.map(({ key, ...person }) => ({ + persons: validPersons.map(({ key, ...person }) => ({ personName: person.personName, personPhone: person.personPhone, dutyDesc: person.dutyDesc, @@ -262,7 +281,7 @@ function Add(props) {
- - + + {() => ( - +
+
+ + + +
+ +
- -
+ )}
@@ -378,6 +405,7 @@ function Add(props) { name="roomImages" labelCol={{ span: 3 }} wrapperCol={{ span: 21 }} + rules={[{ required: true, message: "请上传消防控制室图片" }]} > - - - updateDevice(device.key, "deviceLocation", e.target.value)} - /> - - - +
+
+ + updateDevice(device.key, "deviceLocation", e.target.value)} + /> + +
+ {devices.length > 1 && ( + + )} +
@@ -551,8 +583,8 @@ function Add(props) {
- {index > 0 && ( - )} diff --git a/src/pages/Container/BranchCompany/ControlRoom/List/index.js b/src/pages/Container/BranchCompany/ControlRoom/List/index.js index 529b194..48c9f22 100644 --- a/src/pages/Container/BranchCompany/ControlRoom/List/index.js +++ b/src/pages/Container/BranchCompany/ControlRoom/List/index.js @@ -139,6 +139,7 @@ function List(props) { isShowAllAction={isFromSupervision} isShowFooter={false} history={pageHistory} + headerTitle="消防控制室" > ( - + {props.permission("xfkzs-add") && ( + + )} )} columns={[ @@ -224,34 +227,40 @@ function List(props) { align: "center", render: (_, record) => ( - - - + {props.permission("xfkzs-info") && ( + + )} + {props.permission("xfkzs-update") && ( + + )} + {props.permission("xfkzs-remove") && ( + + )} ), }, diff --git a/src/pages/Container/BranchCompany/ControlRoom/View/index.js b/src/pages/Container/BranchCompany/ControlRoom/View/index.js index 3976380..042423a 100644 --- a/src/pages/Container/BranchCompany/ControlRoom/View/index.js +++ b/src/pages/Container/BranchCompany/ControlRoom/View/index.js @@ -16,6 +16,7 @@ function View(props) { const [loading, setLoading] = useState(false); const [detail, setDetail] = useState(null); const [statusDict, setStatusDict] = useState([]); + const pageTitle = "查看"; const { loading: dictLoading, getDictionary } = useDictionary(); const { loading: getFileLoading, getFile } = useGetFile(); @@ -163,7 +164,7 @@ function View(props) { {detail && (
diff --git a/src/pages/Container/BranchCompany/PumpRoom/Add/index.js b/src/pages/Container/BranchCompany/PumpRoom/Add/index.js index a72cbf4..a074d3f 100644 --- a/src/pages/Container/BranchCompany/PumpRoom/Add/index.js +++ b/src/pages/Container/BranchCompany/PumpRoom/Add/index.js @@ -35,6 +35,7 @@ function Add(props) { const [mapOpen, setMapOpen] = useState(false); const [mapLng, setMapLng] = useState(""); const [mapLat, setMapLat] = useState(""); + const pageTitle = query.id ? "编辑" : "新增"; // 设备信息列表 const createEmptyDevice = () => ({ @@ -105,6 +106,7 @@ function Add(props) { const handleMapConfirm = (lng, lat) => { form.setFieldsValue({ lng, lat }); + form.validateFields(["lng", "lat"]).catch(() => {}); setMapOpen(false); }; @@ -136,6 +138,11 @@ function Add(props) { device.chargeUnit || device.deviceLocation || device.paramsSpec, ); + if (validDevices.length === 0) { + message.warning("设备信息至少保留一条"); + return; + } + const params = { ...values, pumpRoomId, @@ -182,6 +189,10 @@ function Add(props) { }; const removeDevice = (key) => { + if (devices.length <= 1) { + message.warning("设备信息至少保留一条"); + return; + } const index = devices.findIndex(item => item.key === key); const newDevices = devices.filter(item => item.key !== key); setDeviceList(newDevices); @@ -204,7 +215,7 @@ function Add(props) { - - + + {() => ( - +
+
+ + + +
+ +
- -
+ )}
@@ -319,6 +338,7 @@ function Add(props) { name="roomImages" labelCol={{ span: 3 }} wrapperCol={{ span: 21 }} + rules={[{ required: true, message: "请上传消防泵房图片" }]} > - - - updateDevice(device.key, "paramsSpec", e.target.value)} - /> - - - +
+
+ + updateDevice(device.key, "paramsSpec", e.target.value)} + /> + +
+ {devices.length > 1 && ( + + )} +
diff --git a/src/pages/Container/BranchCompany/PumpRoom/List/index.js b/src/pages/Container/BranchCompany/PumpRoom/List/index.js index 4d746f1..441c666 100644 --- a/src/pages/Container/BranchCompany/PumpRoom/List/index.js +++ b/src/pages/Container/BranchCompany/PumpRoom/List/index.js @@ -127,7 +127,12 @@ function List(props) { }; return ( - + ( - + {props.permission("xfbf-add") && ( + + )} )} columns={[ @@ -159,9 +166,15 @@ function List(props) { align: "center", render: (_, record) => ( - - - + {props.permission("xfbf-info") && ( + + )} + {props.permission("xfbf-update") && ( + + )} + {props.permission("xfbf-remove") && ( + + )} ), }, diff --git a/src/pages/Container/BranchCompany/PumpRoom/View/index.js b/src/pages/Container/BranchCompany/PumpRoom/View/index.js index 1760fdd..c60e2a5 100644 --- a/src/pages/Container/BranchCompany/PumpRoom/View/index.js +++ b/src/pages/Container/BranchCompany/PumpRoom/View/index.js @@ -16,6 +16,7 @@ function View(props) { const [loading, setLoading] = useState(false); const [detail, setDetail] = useState(null); const [statusDict, setStatusDict] = useState([]); + const pageTitle = "查看"; const { getDictionary } = useDictionary(); const { loading: getFileLoading, getFile } = useGetFile(); @@ -148,7 +149,7 @@ function View(props) { {detail && (
diff --git a/src/pages/Container/BranchCompany/RescueTeam/Add/index.js b/src/pages/Container/BranchCompany/RescueTeam/Add/index.js index 57fc3d7..5eb1bde 100644 --- a/src/pages/Container/BranchCompany/RescueTeam/Add/index.js +++ b/src/pages/Container/BranchCompany/RescueTeam/Add/index.js @@ -29,6 +29,32 @@ function Add(props) { const [form] = Form.useForm(); const [loading, setLoading] = useState(false); const [submitting, setSubmitting] = useState(false); + const pageTitle = query.id ? "编辑" : "新增"; + + const validateTeamNameUnique = async (_, value) => { + const teamName = value?.trim(); + if (!teamName) { + return Promise.resolve(); + } + + if (!props["rescueTeamCheckName"]) { + return Promise.resolve(); + } + + try { + const response = await props["rescueTeamCheckName"]({ + teamName, + id: query.id, + }); + if (response?.data) { + return Promise.reject(new Error("救援队名称已存在")); + } + return Promise.resolve(); + } + catch (error) { + return Promise.reject(new Error("救援队名称校验失败")); + } + }; // 消防队员列表 const createEmptyMember = () => ({ @@ -99,6 +125,7 @@ function Add(props) { setSubmitting(true); try { + await form.validateFields(["teamName"]); const apiMethod = query.id ? props["rescueTeamUpdate"] : props["rescueTeamAdd"]; // 处理日期格式和提交参数 @@ -133,6 +160,9 @@ function Add(props) { props.history.goBack(); } catch (error) { + if (error?.errorFields) { + return; + } message.error(query.id ? "修改失败" : "新增失败"); } finally { @@ -170,7 +200,7 @@ function Add(props) { - + { + form.setFieldValue("teamName", e.target.value?.trim()); + }} + /> @@ -258,10 +295,10 @@ function Add(props) { > { // 只允许输入数字和连字符 - const value = e.target.value.replace(/[^\d-]/g, ''); + const value = e.target.value.replace(/[^\d-]/g, '').slice(0, 11); form.setFieldValue('captainPhone', value); }} /> @@ -362,34 +399,37 @@ function Add(props) { label={`队员${index + 1}电话`} required > - - - { - const value = e.target.value.replace(/[^\d-]/g, ''); - updateMember(member.key, "personPhone", value); - form.setFieldValue(['rescueMembersForm', index, 'personPhone'], value); - }} - /> - +
+
+ + { + const value = e.target.value.replace(/[^\d-]/g, '').slice(0, 11); + updateMember(member.key, "personPhone", value); + form.setFieldValue(['rescueMembersForm', index, 'personPhone'], value); + }} + /> + +
{index !== 0 && ( )} - +
diff --git a/src/pages/Container/BranchCompany/RescueTeam/List/index.js b/src/pages/Container/BranchCompany/RescueTeam/List/index.js index 9a7dfd8..8469807 100644 --- a/src/pages/Container/BranchCompany/RescueTeam/List/index.js +++ b/src/pages/Container/BranchCompany/RescueTeam/List/index.js @@ -106,7 +106,12 @@ function List(props) { }; return ( - + ( - + {props.permission("xfjyd-add") && ( + + )} )} columns={[ @@ -143,9 +150,15 @@ function List(props) { align: "center", render: (_, record) => ( - - - + {props.permission("xfjyd-info") && ( + + )} + {props.permission("xfjyd-update") && ( + + )} + {props.permission("xfjyd-remove") && ( + + )} ), }, diff --git a/src/pages/Container/BranchCompany/RescueTeam/View/index.js b/src/pages/Container/BranchCompany/RescueTeam/View/index.js index 26803fc..f035d3c 100644 --- a/src/pages/Container/BranchCompany/RescueTeam/View/index.js +++ b/src/pages/Container/BranchCompany/RescueTeam/View/index.js @@ -10,6 +10,7 @@ function View(props) { const query = useGetUrlQuery(); const [loading, setLoading] = useState(false); const [detail, setDetail] = useState(null); + const pageTitle = "查看"; const getData = async () => { setLoading(true); @@ -57,7 +58,7 @@ function View(props) { {detail && (
diff --git a/src/pages/Container/BranchCompany/WaterSource/Add/index.js b/src/pages/Container/BranchCompany/WaterSource/Add/index.js index 00d505c..7badd48 100644 --- a/src/pages/Container/BranchCompany/WaterSource/Add/index.js +++ b/src/pages/Container/BranchCompany/WaterSource/Add/index.js @@ -16,6 +16,7 @@ function Add(props) { const [mapOpen, setMapOpen] = useState(false); const [mapLng, setMapLng] = useState(""); const [mapLat, setMapLat] = useState(""); + const pageTitle = query.id ? "编辑" : "新增"; const getData = async () => { setLoading(true); @@ -43,6 +44,7 @@ function Add(props) { const handleMapConfirm = (lng, lat) => { form.setFieldsValue({ lng, lat }); + form.validateFields(["lng", "lat"]).catch(() => {}); setMapOpen(false); }; @@ -68,7 +70,7 @@ function Add(props) { - - + + {() => ( - +
+
+ + + +
+ +
- -
+ )}
diff --git a/src/pages/Container/BranchCompany/WaterSource/List/index.js b/src/pages/Container/BranchCompany/WaterSource/List/index.js index fe3c14d..d019000 100644 --- a/src/pages/Container/BranchCompany/WaterSource/List/index.js +++ b/src/pages/Container/BranchCompany/WaterSource/List/index.js @@ -147,6 +147,7 @@ function List(props) { isShowAllAction={isFromSupervision} isShowFooter={false} history={pageHistory} + headerTitle="消防水源" > ( - + {props.permission("xfsy-add") && ( + + )} )} columns={[ @@ -204,32 +207,38 @@ function List(props) { align: "center", render: (_, record) => ( - - - + {props.permission("xfsy-info") && ( + + )} + {props.permission("xfsy-update") && ( + + )} + {props.permission("xfsy-remove") && ( + + )} ), }, diff --git a/src/pages/Container/BranchCompany/WaterSource/View/index.js b/src/pages/Container/BranchCompany/WaterSource/View/index.js index 87fa0ea..161bbfd 100644 --- a/src/pages/Container/BranchCompany/WaterSource/View/index.js +++ b/src/pages/Container/BranchCompany/WaterSource/View/index.js @@ -12,6 +12,7 @@ function View(props) { const [loading, setLoading] = useState(false); const [detail, setDetail] = useState(null); const [statusDict, setStatusDict] = useState([]); + const pageTitle = "查看"; const { getDictionary } = useDictionary(); @@ -57,7 +58,7 @@ function View(props) { {detail && (