|
|
|
@ -1,17 +1,10 @@
|
|
|
|
|
/*
|
|
|
|
|
* @Author: zhoux zhouxia@supervision.ltd
|
|
|
|
|
* @Date: 2023-11-01 13:56:33
|
|
|
|
|
* @LastEditors: zhoux zhouxia@supervision.ltd
|
|
|
|
|
* @LastEditTime: 2023-12-26 15:01:08
|
|
|
|
|
* @FilePath: \general-ai-platform-web\src\pages\Device\DeviceCategoryList\components\UpdateForm.tsx
|
|
|
|
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
|
|
|
*/
|
|
|
|
|
import { putDeviceCategoryUpdateDeviceCategory } from '@/services/device/DeviceCategory';
|
|
|
|
|
import { postDeviceGroupGetDeviceGroupFkSelect } from '@/services/device/DeviceGroup';
|
|
|
|
|
import { postAlarmRules } from '@/services/alarm/AlarmRules';
|
|
|
|
|
import { ModalForm, ProForm, ProFormFieldSet, ProFormSelect, ProFormSwitch, ProFormText } from '@ant-design/pro-components';
|
|
|
|
|
import { FormattedMessage, useIntl } from '@umijs/max';
|
|
|
|
|
import { Form, message } from 'antd';
|
|
|
|
|
import React from 'react';
|
|
|
|
|
import React, { useState } from 'react';
|
|
|
|
|
import {
|
|
|
|
|
proFormSmallItemStyleProps,
|
|
|
|
|
proFormSmallModelWidth,
|
|
|
|
@ -23,24 +16,24 @@ export type FormValueType = {
|
|
|
|
|
type?: string;
|
|
|
|
|
time?: string;
|
|
|
|
|
frequency?: string;
|
|
|
|
|
} & Partial<API.DeviceCategory>;
|
|
|
|
|
} & Partial<API.UpdateAlarmRulesForm>;
|
|
|
|
|
|
|
|
|
|
export type UpdateFormProps = {
|
|
|
|
|
updateModalOpen: boolean;
|
|
|
|
|
handleModal: () => void;
|
|
|
|
|
values: Partial<API.DeviceCategory>;
|
|
|
|
|
values: Partial<API.UpdateAlarmRulesForm>;
|
|
|
|
|
reload: any;
|
|
|
|
|
};
|
|
|
|
|
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
const intl = useIntl();
|
|
|
|
|
const [form] = Form.useForm<API.DeviceCategory>();
|
|
|
|
|
const [form] = Form.useForm<API.UpdateAlarmRulesForm>();
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<ModalForm<any>
|
|
|
|
|
width={proFormSmallModelWidth}
|
|
|
|
|
title={intl.formatMessage({
|
|
|
|
|
id: 'alarm_rules.page.form.title',
|
|
|
|
|
defaultMessage: `编辑${props.values.name}`,
|
|
|
|
|
id: 'alarm_rules.page.form.title1',
|
|
|
|
|
defaultMessage: `编辑${props.values.warning_name}`,
|
|
|
|
|
})}
|
|
|
|
|
open={props.updateModalOpen}
|
|
|
|
|
form={form}
|
|
|
|
@ -50,19 +43,26 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
onCancel: () => props.handleModal(),
|
|
|
|
|
}}
|
|
|
|
|
submitTimeout={2000}
|
|
|
|
|
initialValues={{
|
|
|
|
|
list: [props.values.time_period,
|
|
|
|
|
props.values.time_interval,
|
|
|
|
|
props.values.appear_number],
|
|
|
|
|
}}
|
|
|
|
|
onFinish={async (values) => {
|
|
|
|
|
console.log(values);
|
|
|
|
|
// putDeviceCategoryUpdateDeviceCategory(values)
|
|
|
|
|
// .then(() => {
|
|
|
|
|
// message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' }));
|
|
|
|
|
// props.reload();
|
|
|
|
|
// })
|
|
|
|
|
// .catch(() => {
|
|
|
|
|
// message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' }));
|
|
|
|
|
// });
|
|
|
|
|
values.id = props.values.id
|
|
|
|
|
values.is_use = values.is_use ? 1 : 0
|
|
|
|
|
// console.log(values);
|
|
|
|
|
await postAlarmRules(values)
|
|
|
|
|
.then(() => {
|
|
|
|
|
message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' }));
|
|
|
|
|
props.reload();
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' }));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// props.handleModal();
|
|
|
|
|
// return true;
|
|
|
|
|
props.handleModal();
|
|
|
|
|
return true;
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<ProForm.Group>
|
|
|
|
@ -83,7 +83,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
/> */}
|
|
|
|
|
<ProFormSwitch
|
|
|
|
|
width={proFormSmallItemStyleProps.column2Width}
|
|
|
|
|
name="isEnable"
|
|
|
|
|
name="is_use"
|
|
|
|
|
label={
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
id="alarm_rules.page.form.isEnabled"
|
|
|
|
@ -92,12 +92,12 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
}
|
|
|
|
|
checkedChildren="启用"
|
|
|
|
|
unCheckedChildren="关闭"
|
|
|
|
|
initialValue={props.values.isEnabled}
|
|
|
|
|
initialValue={props.values.is_use}
|
|
|
|
|
disabled={false}
|
|
|
|
|
/>
|
|
|
|
|
<ProFormText
|
|
|
|
|
width={proFormSmallItemStyleProps.width}
|
|
|
|
|
name="name"
|
|
|
|
|
name="warning_name"
|
|
|
|
|
label={<FormattedMessage id="alarm_rules.page.form.name" defaultMessage="$$$" />}
|
|
|
|
|
placeholder={`${intl.formatMessage({
|
|
|
|
|
id: 'common.please_input',
|
|
|
|
@ -107,7 +107,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}`}
|
|
|
|
|
required={true}
|
|
|
|
|
initialValue={props.values.name}
|
|
|
|
|
initialValue={props.values.warning_name}
|
|
|
|
|
disabled={false}
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
@ -121,106 +121,159 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
/>
|
|
|
|
|
{/* <ProFormSelect
|
|
|
|
|
width={proFormSmallItemStyleProps.width}
|
|
|
|
|
name="level"
|
|
|
|
|
label={<FormattedMessage id="alarm.setting.table.list.level" defaultMessage="$$$" />}
|
|
|
|
|
placeholder={`${intl.formatMessage({
|
|
|
|
|
id: 'common.please_select',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}${intl.formatMessage({
|
|
|
|
|
id: 'alarm.setting.table.list.level',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}`}
|
|
|
|
|
required={false}
|
|
|
|
|
// TODO 在types中增加类型注释
|
|
|
|
|
initialValue={props.values?.level}
|
|
|
|
|
debounceTime={1000}
|
|
|
|
|
request={async () => {
|
|
|
|
|
// TODO 此处需要使用告警级别接口联调
|
|
|
|
|
const resp = await postDeviceGroupGetDeviceGroupFkSelect({});
|
|
|
|
|
return resp.data.list.map((v: any) => {
|
|
|
|
|
return {
|
|
|
|
|
label: v.name,
|
|
|
|
|
value: v.id,
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
/> */}
|
|
|
|
|
{/* <ProFormText
|
|
|
|
|
width={proFormSmallItemStyleProps.width}
|
|
|
|
|
name="triggerConditions"
|
|
|
|
|
label={<FormattedMessage id="alarm_rules.page.form.triggerConditions" defaultMessage="$$$" />}
|
|
|
|
|
placeholder={`${intl.formatMessage({
|
|
|
|
|
id: 'common.please_input',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}${intl.formatMessage({
|
|
|
|
|
id: 'alarm_rules.page.form.triggerConditions',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}`}
|
|
|
|
|
required={false}
|
|
|
|
|
initialValue={props.values.triggerConditions}
|
|
|
|
|
disabled={false}
|
|
|
|
|
/> */}
|
|
|
|
|
<ProFormFieldSet
|
|
|
|
|
name="list"
|
|
|
|
|
label="触发条件"
|
|
|
|
|
type='space'
|
|
|
|
|
transform={(value: any) => ({
|
|
|
|
|
list: value,
|
|
|
|
|
startTime: value[0],
|
|
|
|
|
endTime: value[1],
|
|
|
|
|
})}
|
|
|
|
|
className={styles}
|
|
|
|
|
>
|
|
|
|
|
当检测到风险人员单人,于<ProFormText
|
|
|
|
|
width={100}
|
|
|
|
|
name="triggerConditions"
|
|
|
|
|
label={<FormattedMessage id="alarm_rules.page.form.triggerConditions" defaultMessage="$$$" />}
|
|
|
|
|
placeholder={`${intl.formatMessage({
|
|
|
|
|
id: 'common.please_input',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}${intl.formatMessage({
|
|
|
|
|
id: 'alarm_rules.page.form.triggerConditions',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}`}
|
|
|
|
|
required={false}
|
|
|
|
|
initialValue={props.values.time1}
|
|
|
|
|
disabled={false}
|
|
|
|
|
/>小时内,间隔
|
|
|
|
|
<ProFormText
|
|
|
|
|
width={100}
|
|
|
|
|
name="triggerConditions"
|
|
|
|
|
label={<FormattedMessage id="alarm_rules.page.form.triggerConditions" defaultMessage="$$$" />}
|
|
|
|
|
placeholder={`${intl.formatMessage({
|
|
|
|
|
id: 'common.please_input',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}${intl.formatMessage({
|
|
|
|
|
id: 'alarm_rules.page.form.triggerConditions',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}`}
|
|
|
|
|
required={false}
|
|
|
|
|
initialValue={props.values.time2}
|
|
|
|
|
disabled={false}
|
|
|
|
|
/>小时,重复出现
|
|
|
|
|
<ProFormText
|
|
|
|
|
width={100}
|
|
|
|
|
name="triggerConditions"
|
|
|
|
|
label={<FormattedMessage id="alarm_rules.page.form.triggerConditions" defaultMessage="$$$" />}
|
|
|
|
|
placeholder={`${intl.formatMessage({
|
|
|
|
|
id: 'common.please_input',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}${intl.formatMessage({
|
|
|
|
|
id: 'alarm_rules.page.form.triggerConditions',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}`}
|
|
|
|
|
required={false}
|
|
|
|
|
initialValue={props.values.time3}
|
|
|
|
|
disabled={false}
|
|
|
|
|
/>
|
|
|
|
|
次,则触发警告。
|
|
|
|
|
</ProFormFieldSet>
|
|
|
|
|
|
|
|
|
|
<ProFormFieldSet
|
|
|
|
|
name="list"
|
|
|
|
|
label="触发条件"
|
|
|
|
|
type='space'
|
|
|
|
|
transform={(value: any) => ({
|
|
|
|
|
// list: value,
|
|
|
|
|
// startTime: value[0],
|
|
|
|
|
// endTime: value[1],
|
|
|
|
|
time_period: value[0],
|
|
|
|
|
time_interval: value[1],
|
|
|
|
|
appear_number: value[2],
|
|
|
|
|
})}
|
|
|
|
|
className={styles}
|
|
|
|
|
>
|
|
|
|
|
当检测到风险人员单人,于<ProFormText
|
|
|
|
|
width={100}
|
|
|
|
|
name="time_period"
|
|
|
|
|
label={<FormattedMessage id="alarm_rules.page.form.triggerConditions" defaultMessage="$$$" />}
|
|
|
|
|
placeholder={`${intl.formatMessage({
|
|
|
|
|
id: 'common.please_input',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}${intl.formatMessage({
|
|
|
|
|
id: 'alarm_rules.page.form.triggerConditions',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}`}
|
|
|
|
|
required={false}
|
|
|
|
|
initialValue={props.values.time_period}
|
|
|
|
|
disabled={false}
|
|
|
|
|
/>小时内,间隔
|
|
|
|
|
<ProFormText
|
|
|
|
|
width={100}
|
|
|
|
|
name="time_interval"
|
|
|
|
|
label={<FormattedMessage id="alarm_rules.page.form.triggerConditions" defaultMessage="$$$" />}
|
|
|
|
|
placeholder={`${intl.formatMessage({
|
|
|
|
|
id: 'common.please_input',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}${intl.formatMessage({
|
|
|
|
|
id: 'alarm_rules.page.form.triggerConditions',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}`}
|
|
|
|
|
required={false}
|
|
|
|
|
initialValue={props.values.time_interval}
|
|
|
|
|
disabled={false}
|
|
|
|
|
/>小时,重复出现
|
|
|
|
|
<ProFormText
|
|
|
|
|
width={100}
|
|
|
|
|
name="appear_number"
|
|
|
|
|
label={<FormattedMessage id="alarm_rules.page.form.triggerConditions" defaultMessage="$$$" />}
|
|
|
|
|
placeholder={`${intl.formatMessage({
|
|
|
|
|
id: 'common.please_input',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}${intl.formatMessage({
|
|
|
|
|
id: 'alarm_rules.page.form.triggerConditions',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}`}
|
|
|
|
|
required={false}
|
|
|
|
|
initialValue={props.values.appear_number}
|
|
|
|
|
disabled={false}
|
|
|
|
|
/>
|
|
|
|
|
次,则触发警告。
|
|
|
|
|
</ProFormFieldSet>
|
|
|
|
|
{/* { multipleStatus &&
|
|
|
|
|
<ProFormFieldSet
|
|
|
|
|
name="list"
|
|
|
|
|
label="触发条件"
|
|
|
|
|
type='space'
|
|
|
|
|
transform={(value: any) => ({
|
|
|
|
|
// list: value,
|
|
|
|
|
// startTime: value[0],
|
|
|
|
|
// endTime: value[1],
|
|
|
|
|
time_period: value[0],
|
|
|
|
|
time_interval: value[1],
|
|
|
|
|
appear_number: value[2],
|
|
|
|
|
})}
|
|
|
|
|
className={styles}
|
|
|
|
|
>
|
|
|
|
|
当检测到风险人员人数大于<ProFormText
|
|
|
|
|
width={100}
|
|
|
|
|
name="person_number"
|
|
|
|
|
label={<FormattedMessage id="alarm_rules.page.form.triggerConditions" defaultMessage="$$$" />}
|
|
|
|
|
placeholder={`${intl.formatMessage({
|
|
|
|
|
id: 'common.please_input',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}${intl.formatMessage({
|
|
|
|
|
id: 'alarm_rules.page.form.triggerConditions',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}`}
|
|
|
|
|
required={false}
|
|
|
|
|
initialValue={props.values.person_number}
|
|
|
|
|
disabled={false}
|
|
|
|
|
/>人时,则触发告警,触发间隔
|
|
|
|
|
<ProFormText
|
|
|
|
|
width={100}
|
|
|
|
|
name="time_interval"
|
|
|
|
|
label={<FormattedMessage id="alarm_rules.page.form.triggerConditions" defaultMessage="$$$" />}
|
|
|
|
|
placeholder={`${intl.formatMessage({
|
|
|
|
|
id: 'common.please_input',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}${intl.formatMessage({
|
|
|
|
|
id: 'alarm_rules.page.form.triggerConditions',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}`}
|
|
|
|
|
required={false}
|
|
|
|
|
initialValue={props.values.time_interval}
|
|
|
|
|
disabled={false}
|
|
|
|
|
/>分钟。
|
|
|
|
|
</ProFormFieldSet>}
|
|
|
|
|
{ timeStatus &&
|
|
|
|
|
<ProFormFieldSet
|
|
|
|
|
name="list"
|
|
|
|
|
label="触发条件"
|
|
|
|
|
type='space'
|
|
|
|
|
transform={(value: any) => ({
|
|
|
|
|
// list: value,
|
|
|
|
|
// startTime: value[0],
|
|
|
|
|
// endTime: value[1],
|
|
|
|
|
time_period: value[0],
|
|
|
|
|
time_interval: value[1],
|
|
|
|
|
appear_number: value[2],
|
|
|
|
|
})}
|
|
|
|
|
className={styles}
|
|
|
|
|
>
|
|
|
|
|
当处于<ProFormText
|
|
|
|
|
width={100}
|
|
|
|
|
name="trigger_start_time"
|
|
|
|
|
label={<FormattedMessage id="alarm_rules.page.form.triggerConditions" defaultMessage="$$$" />}
|
|
|
|
|
placeholder={`${intl.formatMessage({
|
|
|
|
|
id: 'common.please_input',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}${intl.formatMessage({
|
|
|
|
|
id: 'alarm_rules.page.form.triggerConditions',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}`}
|
|
|
|
|
required={false}
|
|
|
|
|
initialValue={props.values.trigger_start_time}
|
|
|
|
|
disabled={false}
|
|
|
|
|
/>至
|
|
|
|
|
<ProFormText
|
|
|
|
|
width={100}
|
|
|
|
|
name="trigger_end_time"
|
|
|
|
|
label={<FormattedMessage id="alarm_rules.page.form.triggerConditions" defaultMessage="$$$" />}
|
|
|
|
|
placeholder={`${intl.formatMessage({
|
|
|
|
|
id: 'common.please_input',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}${intl.formatMessage({
|
|
|
|
|
id: 'alarm_rules.page.form.triggerConditions',
|
|
|
|
|
defaultMessage: '$$$',
|
|
|
|
|
})}`}
|
|
|
|
|
required={false}
|
|
|
|
|
initialValue={props.values.trigger_end_time}
|
|
|
|
|
disabled={false}
|
|
|
|
|
/>时间内,发现风险人员立即告警。
|
|
|
|
|
</ProFormFieldSet>} */}
|
|
|
|
|
</ProForm.Group>
|
|
|
|
|
</ModalForm>
|
|
|
|
|
);
|
|
|
|
|