|
|
@ -1,6 +1,6 @@ |
|
|
|
import React, { useState, useRef, useEffect } from "react"; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
import { Modal, Form, Notification } from "@douyinfe/semi-ui"; |
|
|
|
import { Modal, Form, Notification, Tooltip } from "@douyinfe/semi-ui"; |
|
|
|
import { IconAlertCircle } from '@douyinfe/semi-icons'; |
|
|
|
import './pushModal.less' |
|
|
|
|
|
|
@ -34,7 +34,7 @@ function pushModal (props) { |
|
|
|
const [interval3, setInterval3] = useState(undefined); // |
|
|
|
const [deviceProportion, setDeviceProportion] = useState(undefined); // |
|
|
|
const [subType, setSubType] = useState([]); //监听模块中的子类 |
|
|
|
const [factor, setFactor] = useState([]); //结构物对应监测项 |
|
|
|
const [factorShow, setFactorShow] = useState([]); //结构物对应监测项 |
|
|
|
|
|
|
|
|
|
|
|
//初始化 |
|
|
@ -43,7 +43,7 @@ function pushModal (props) { |
|
|
|
getOrganizationUsersList()//获取全部未删除用户 |
|
|
|
getProjectPomsList()//获取已绑定项目 |
|
|
|
if (editObj.id) { |
|
|
|
getProjectStructureList(editObj.pomsProjectId) |
|
|
|
getProjectStructureList(editObj.pomsProjectId, editObj) |
|
|
|
let division = editObj?.pomsProject?.map(v => (v.pepProject?.id || 'POMS')) |
|
|
|
if (division.length == 1 && division?.includes('POMS')) { |
|
|
|
setProjectStatus([{ construction_status: 'POMS', id: 'POMS' }]) |
|
|
@ -75,11 +75,12 @@ function pushModal (props) { |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
function getProjectStructureList (value) {//获取绑定项目下结构物 |
|
|
|
function getProjectStructureList (value, alter) {//获取绑定项目下结构物 |
|
|
|
dispatch(service.getProjectStructure({ pomsProjectId: value.join(',') })).then((res) => { |
|
|
|
if (res.success) { |
|
|
|
let data = [] |
|
|
|
let ProjectId = [] |
|
|
|
let factorId = [] |
|
|
|
res.payload?.data.map(v => { |
|
|
|
if (ProjectId.includes(v.id)) { |
|
|
|
} else { |
|
|
@ -87,14 +88,15 @@ function pushModal (props) { |
|
|
|
data.push(v) |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
let mylist = [] |
|
|
|
for (let i = 0; i < data.length; i++) { |
|
|
|
mylist.push(data[i].id) |
|
|
|
} |
|
|
|
setProjectStructure(data) |
|
|
|
// setFactor() |
|
|
|
form.current.setValue('strucId', mylist) |
|
|
|
let FactorId = [] |
|
|
|
for (let key in alter?.pomsStrucFactorId) { |
|
|
|
FactorId.push(key) |
|
|
|
} |
|
|
|
setFactorShow(FactorId?.map(Number)) |
|
|
|
if (!editObj.id) { |
|
|
|
form.current.setValue('strucId', ProjectId) |
|
|
|
} |
|
|
|
form.current.validate(['strucId', 'timeType']) |
|
|
|
setStructure(false) |
|
|
|
setTimeTypeDis(false) |
|
|
@ -122,7 +124,6 @@ function pushModal (props) { |
|
|
|
let regu = /^[0-9]*[1-9][0-9]*$/; |
|
|
|
let title = tactics == 'immediately' ? '即时' : tactics == 'continue' ? '持续时长' : '异常率' |
|
|
|
if (!regu.test(interval) || (tactics == 'abnormal_rate' && interval > 720) || interval > 1440) { |
|
|
|
console.log(interval); |
|
|
|
Notification.error({ |
|
|
|
content: title + (interval ? `推送时间不能大于${tactics == 'abnormal_rate' ? 720 : 1440}分钟` : '推送时间应为正整数'), |
|
|
|
duration: 2, |
|
|
@ -157,11 +158,14 @@ function pushModal (props) { |
|
|
|
timeType: v.timeType[0] == 'POMS' ? [] : v.timeType, |
|
|
|
receiverPepUserId: v.receiverPepUserId || [], |
|
|
|
disable: v.disable, |
|
|
|
alarmSubType: {} |
|
|
|
alarmSubType: {}, |
|
|
|
pomsStrucFactorId: {} |
|
|
|
} |
|
|
|
for (let key in v) { |
|
|
|
if (['app_exception', 'data_exception', 'data_outages', 'device_exception', 'video_exception', 'strategy_hit'].includes(key)) { |
|
|
|
data.alarmSubType = { ...data.alarmSubType, [key]: v[key] } |
|
|
|
} else if (key.indexOf('factor') == 0) { |
|
|
|
data.pomsStrucFactorId = { ...data.pomsStrucFactorId, [key.slice(6)]: v[key] } |
|
|
|
} |
|
|
|
} |
|
|
|
if (caution(data.tactics, data.tacticsParams.interval, data.tacticsParams.deviceProportion)) { |
|
|
@ -190,10 +194,9 @@ function pushModal (props) { |
|
|
|
> |
|
|
|
<div> |
|
|
|
<Form |
|
|
|
allowEmpty |
|
|
|
labelPosition="left" |
|
|
|
labelAlign="right" |
|
|
|
labelWidth="120px" |
|
|
|
labelWidth="130px" |
|
|
|
onValueChange={(values, field) => { |
|
|
|
for (var key in field) { |
|
|
|
if (key == 'tactics') { |
|
|
@ -203,8 +206,7 @@ function pushModal (props) { |
|
|
|
} else { |
|
|
|
setAbnormal(false) |
|
|
|
} |
|
|
|
} |
|
|
|
if (key == 'pomsProjectId') { |
|
|
|
} else if (key == 'pomsProjectId') { |
|
|
|
if (values.pomsProjectId.length > 0) { |
|
|
|
getProjectStructureList(values.pomsProjectId)//获取绑定项目下结构物 |
|
|
|
let pepProjectId = [] |
|
|
@ -228,8 +230,9 @@ function pushModal (props) { |
|
|
|
form.current.setValue('timeType', []) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if (key == 'alarmType') { |
|
|
|
} else if (key == 'strucId') { |
|
|
|
setFactorShow(values.strucId) |
|
|
|
} else if (key == 'alarmType') { |
|
|
|
setSubType(field['alarmType']) |
|
|
|
} |
|
|
|
} |
|
|
@ -245,7 +248,7 @@ function pushModal (props) { |
|
|
|
label='策略名称:' |
|
|
|
maxLength={15} |
|
|
|
disabled={pushEdit} |
|
|
|
style={{ width: 695 }} |
|
|
|
style={{ width: 678 }} |
|
|
|
initValue={editObj?.name || ""} |
|
|
|
placeholder="请输入策略名称" |
|
|
|
showClear |
|
|
@ -256,7 +259,7 @@ function pushModal (props) { |
|
|
|
label="请选择项目:" |
|
|
|
field="pomsProjectId" |
|
|
|
placeholder="请选择项目" |
|
|
|
style={{ width: 695 }} |
|
|
|
style={{ width: 678 }} |
|
|
|
rules={[{ required: true, message: "请选择项目" }]} |
|
|
|
initValue={editObj?.pomsProjectId || ""} |
|
|
|
multiple |
|
|
@ -275,10 +278,13 @@ function pushModal (props) { |
|
|
|
</div> |
|
|
|
<div> |
|
|
|
<Form.Select |
|
|
|
label="请选择结构物:" |
|
|
|
label={<>请选择结构物 |
|
|
|
<Tooltip content={'选择结构物,若该结构物下没有监测项则下方不展示,反之展示结构物对应的监测项'} style={{ lineHeight: 2 }}> |
|
|
|
<img src="/assets/images/install/table_question.png" alt="" style={{ height: 14, width: 14 }} /> |
|
|
|
</Tooltip>:</>} |
|
|
|
field="strucId" |
|
|
|
placeholder="请选择结构物" |
|
|
|
style={{ width: 695 }} |
|
|
|
style={{ width: 678 }} |
|
|
|
rules={[{ required: true, message: "请选择结构物" }]} |
|
|
|
initValue={editObj?.strucId || []} |
|
|
|
disabled={structure} |
|
|
@ -297,6 +303,23 @@ function pushModal (props) { |
|
|
|
}) |
|
|
|
} |
|
|
|
</Form.Select> |
|
|
|
{projectStructure?.filter(v => (factorShow?.includes(v.id) && v.factor?.length > 0))?.map((u, index) => { |
|
|
|
return <Form.CheckboxGroup |
|
|
|
label={u.name + ':'} |
|
|
|
key={u.name + index} |
|
|
|
field={'factor' + u.id} |
|
|
|
style={{ width: 695 }} |
|
|
|
initValue={editObj?.id ? editObj?.pomsStrucFactorId[u.id] : []} |
|
|
|
direction='horizontal' |
|
|
|
showClear |
|
|
|
> |
|
|
|
{ |
|
|
|
u.factor?.map((v, index) => |
|
|
|
<Form.Checkbox value={v.id} key={v.id} style={{ width: 150 }}>{v.name}</Form.Checkbox>) |
|
|
|
} |
|
|
|
</Form.CheckboxGroup> |
|
|
|
}) |
|
|
|
} |
|
|
|
</div> |
|
|
|
<div className='pushInput'> |
|
|
|
<Form.RadioGroup |
|
|
|