|
@ -1,6 +1,6 @@ |
|
|
import React, { useState, useRef, useEffect } from "react"; |
|
|
import React, { useState, useRef, useEffect } from "react"; |
|
|
import { connect } from "react-redux"; |
|
|
import { connect } from "react-redux"; |
|
|
import { Modal, Form, Tag } from "@douyinfe/semi-ui"; |
|
|
import { Modal, Form, Tag, } from "@douyinfe/semi-ui"; |
|
|
import { IconAlertCircle } from '@douyinfe/semi-icons'; |
|
|
import { IconAlertCircle } from '@douyinfe/semi-icons'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -22,46 +22,95 @@ function adminModal (props) { |
|
|
appArr,//修改时添加应用 |
|
|
appArr,//修改时添加应用 |
|
|
bindId, |
|
|
bindId, |
|
|
mapping, //修改时的映射类型 |
|
|
mapping, //修改时的映射类型 |
|
|
maintenancePeriod //维保时间段 |
|
|
maintenancePeriod, //维保时间段 |
|
|
|
|
|
editData, |
|
|
|
|
|
traitLabel |
|
|
} = props; |
|
|
} = props; |
|
|
const { install } = actions; |
|
|
const { install } = actions; |
|
|
const form = useRef();//表单 |
|
|
const form = useRef();//表单 |
|
|
const [custom, setCustom] = useState(false); //是否是自定义项目 |
|
|
const [custom, setCustom] = useState(false); //是否是自定义项目 |
|
|
const [myprojectType, setMyprojectType] = useState('pep'); //是否是自定义项目 |
|
|
const [myprojectType, setMyprojectType] = useState('pep'); //是否是自定义项目 |
|
|
|
|
|
const [structureSensor, setStructureSensor] = useState([]) |
|
|
|
|
|
const [sendorders, setSendorders] = useState([]) |
|
|
|
|
|
const [strucId, setStrucId] = useState([]) |
|
|
|
|
|
|
|
|
//初始化 |
|
|
//初始化 |
|
|
useEffect(() => { |
|
|
useEffect(async () => { |
|
|
if (pepname) { |
|
|
if (pepname) { |
|
|
setCustom(true) |
|
|
setCustom(true) |
|
|
setMyprojectType('axy') |
|
|
setMyprojectType('axy') |
|
|
} |
|
|
} |
|
|
|
|
|
if (editData?.id) { |
|
|
|
|
|
await getData({ projectId: anxincloudArr?.join(',') + ',-1' }) |
|
|
|
|
|
setSendorders(editData?.sendorders) |
|
|
|
|
|
if (editData?.sendorders?.includes('emphasis')) { |
|
|
|
|
|
form.current.setValue('strucId', editData?.strucId) |
|
|
|
|
|
editData?.strucId?.forEach(d => { |
|
|
|
|
|
form.current.setValue('strucSensor' + d, editData?.strucSensor[d]) |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
setStrucId(editData?.strucId || []) |
|
|
|
|
|
} |
|
|
|
|
|
if (editData?.sendorders?.includes('percentage')) { |
|
|
|
|
|
form.current.setValue('percentage', editData?.percentage) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
}, []); |
|
|
}, []); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getData = async (data = {}) => { |
|
|
|
|
|
await dispatch(install.getStructureStation({ ...data, traitLabel })).then((res) => { |
|
|
|
|
|
if (res.success) { |
|
|
|
|
|
setStructureSensor(res.payload.data || []) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function handleOk () { |
|
|
function handleOk () { |
|
|
//点击弹框确定 右边按钮 |
|
|
//点击弹框确定 右边按钮 |
|
|
form.current |
|
|
form.current |
|
|
.validate() |
|
|
.validate() |
|
|
.then((values) => { |
|
|
.then((values) => { |
|
|
if (systemEdit) { |
|
|
|
|
|
let appArr = [] |
|
|
let appArr = [] |
|
|
for (let i = 0; i < values.appId.length; i++) { |
|
|
for (let i = 0; i < values.appId.length; i++) { |
|
|
appArr.push(JSON.parse(values.appId[i]).id) |
|
|
appArr.push(JSON.parse(values.appId[i]).id) |
|
|
} |
|
|
} |
|
|
let bindObj = JSON.parse(JSON.stringify(values)) |
|
|
console.log(22, values); |
|
|
bindObj.appId = appArr |
|
|
|
|
|
dispatch(install.postProjectBind({ ...bindObj, bindId: bindId, msg: '修改映射关系' })).then((res) => {//获取项企(PEP)全部部门及其下用户 |
|
|
let strucSensor = {} |
|
|
|
|
|
if (values.sendorders?.includes("emphasis")) { |
|
|
|
|
|
values.strucId?.forEach(d => { |
|
|
|
|
|
strucSensor[d] = values['strucSensor' + d] || [] |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
let data = { |
|
|
|
|
|
name: values.name, |
|
|
|
|
|
pepProjectId: values.pepProjectId, |
|
|
|
|
|
anxinProjectId: values.anxinProjectId, |
|
|
|
|
|
appId: appArr, |
|
|
|
|
|
mappingClass: values.mappingClass, |
|
|
|
|
|
maintenancePeriod: values.maintenancePeriod, |
|
|
|
|
|
isanchor: values.isanchor, |
|
|
|
|
|
sendorders: values.sendorders, |
|
|
|
|
|
percentage: values.percentage, |
|
|
|
|
|
strucId: values.strucId, |
|
|
|
|
|
strucSensor: strucSensor |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (systemEdit) { |
|
|
|
|
|
dispatch(install.postProjectBind({ ...data, bindId: bindId, msg: '修改映射关系', })).then((res) => {//获取项企(PEP)全部部门及其下用户 |
|
|
if (res.success) { |
|
|
if (res.success) { |
|
|
close(); |
|
|
close(); |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
let appArr = [] |
|
|
dispatch(install.postProjectBind({ ...data, msg: '添加映射关系' })).then((res) => {//获取项企(PEP)全部部门及其下用户 |
|
|
for (let i = 0; i < values.appId.length; i++) { |
|
|
|
|
|
appArr.push(JSON.parse(values.appId[i]).id) |
|
|
|
|
|
} |
|
|
|
|
|
let bindObj = JSON.parse(JSON.stringify(values)) |
|
|
|
|
|
bindObj.appId = appArr |
|
|
|
|
|
dispatch(install.postProjectBind({ ...bindObj, msg: '添加映射关系' })).then((res) => {//获取项企(PEP)全部部门及其下用户 |
|
|
|
|
|
if (res.success) { |
|
|
if (res.success) { |
|
|
close(); |
|
|
close(); |
|
|
} |
|
|
} |
|
@ -69,6 +118,8 @@ function adminModal (props) { |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function handleCancel () { |
|
|
function handleCancel () { |
|
|
cancel(); |
|
|
cancel(); |
|
|
//点击弹框取消 左边按钮 |
|
|
//点击弹框取消 左边按钮 |
|
@ -86,6 +137,7 @@ function adminModal (props) { |
|
|
content |
|
|
content |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<> |
|
|
<> |
|
|
<Modal |
|
|
<Modal |
|
@ -106,7 +158,7 @@ function adminModal (props) { |
|
|
allowEmpty |
|
|
allowEmpty |
|
|
labelPosition="left" |
|
|
labelPosition="left" |
|
|
labelAlign="right" |
|
|
labelAlign="right" |
|
|
labelWidth="110px" |
|
|
labelWidth="132px" |
|
|
onValueChange={(values, field) => { |
|
|
onValueChange={(values, field) => { |
|
|
for (var key in field) { |
|
|
for (var key in field) { |
|
|
if (key == 'projectType') { |
|
|
if (key == 'projectType') { |
|
@ -179,6 +231,15 @@ function adminModal (props) { |
|
|
rules={[{ required: true, message: "请选择安心云项目" }]} |
|
|
rules={[{ required: true, message: "请选择安心云项目" }]} |
|
|
initValue={anxincloudArr || []} |
|
|
initValue={anxincloudArr || []} |
|
|
showClear |
|
|
showClear |
|
|
|
|
|
onChange={v => { |
|
|
|
|
|
if (v.length) { |
|
|
|
|
|
getData({ projectId: v.join(',') + ',-1' }) |
|
|
|
|
|
} else { |
|
|
|
|
|
setStructureSensor([]) |
|
|
|
|
|
} |
|
|
|
|
|
form.current.setValue('strucId', []) |
|
|
|
|
|
setStrucId([]) |
|
|
|
|
|
}} |
|
|
> |
|
|
> |
|
|
{ |
|
|
{ |
|
|
anxincloudList.map((item, index) => { |
|
|
anxincloudList.map((item, index) => { |
|
@ -261,18 +322,82 @@ function adminModal (props) { |
|
|
<Form.DatePicker |
|
|
<Form.DatePicker |
|
|
style={{ width: 425 }} |
|
|
style={{ width: 425 }} |
|
|
label='维保期限时间:' |
|
|
label='维保期限时间:' |
|
|
type={'dateRange'} |
|
|
type='dateRange' |
|
|
field='maintenancePeriod' |
|
|
field='maintenancePeriod' |
|
|
initValue={maintenancePeriod} |
|
|
initValue={maintenancePeriod} |
|
|
|
|
|
|
|
|
> |
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</Form.DatePicker> |
|
|
</Form.DatePicker> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<Form.RadioGroup field="isanchor" label='是否续签:' initValue={editData?.isanchor} > |
|
|
|
|
|
<Form.Radio value={true}>续签</Form.Radio> |
|
|
|
|
|
<Form.Radio value={false}>不续签</Form.Radio> |
|
|
|
|
|
</Form.RadioGroup> |
|
|
|
|
|
<Form.CheckboxGroup |
|
|
|
|
|
field="sendorders" |
|
|
|
|
|
label='自动派单:' |
|
|
|
|
|
direction='horizontal' |
|
|
|
|
|
initValue={editData?.sendorders || []} |
|
|
|
|
|
onChange={v => { |
|
|
|
|
|
setSendorders(v) |
|
|
|
|
|
if (!v.includes('emphasis')) { |
|
|
|
|
|
setStrucId([]) |
|
|
|
|
|
} |
|
|
|
|
|
}} |
|
|
|
|
|
> |
|
|
|
|
|
<Form.Checkbox value="percentage">项目中断比例</Form.Checkbox> |
|
|
|
|
|
<Form.Checkbox value="emphasis">重点点位监控</Form.Checkbox> |
|
|
|
|
|
</Form.CheckboxGroup> |
|
|
|
|
|
{ |
|
|
|
|
|
sendorders?.includes('percentage') && |
|
|
|
|
|
<Form.InputNumber field='percentage' label='项目中断百分比:' min={0} max={100} /> |
|
|
|
|
|
} |
|
|
|
|
|
{ |
|
|
|
|
|
sendorders?.includes('emphasis') && |
|
|
|
|
|
<> |
|
|
|
|
|
<Form.Select |
|
|
|
|
|
label="选择结构物:" |
|
|
|
|
|
field="strucId" |
|
|
|
|
|
filter |
|
|
|
|
|
multiple |
|
|
|
|
|
placeholder="请选择结构物" |
|
|
|
|
|
style={{ width: 425 }} |
|
|
|
|
|
// initValue={[]} |
|
|
|
|
|
showClear |
|
|
|
|
|
onChange={v => { |
|
|
|
|
|
setStrucId(v) |
|
|
|
|
|
}} |
|
|
|
|
|
> |
|
|
|
|
|
{ |
|
|
|
|
|
structureSensor.map(item => { |
|
|
|
|
|
return <Form.Select.Option key={item.strucId} value={item.strucId}> |
|
|
|
|
|
{item.strucName} |
|
|
|
|
|
</Form.Select.Option> |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
</Form.Select> |
|
|
|
|
|
|
|
|
|
|
|
{strucId?.length ? structureSensor?.filter(v => strucId?.includes(v.strucId))?.map((u, index) => { |
|
|
|
|
|
return <Form.CheckboxGroup |
|
|
|
|
|
label={u.strucName + ':'} |
|
|
|
|
|
key={u.strucName + index} |
|
|
|
|
|
field={'strucSensor' + u.strucId} |
|
|
|
|
|
style={{ width: 420 }} |
|
|
|
|
|
// initValue={editObj?.pomsStrucFactorId ? editObj?.pomsStrucFactorId[u.id] : (factorItem || [])} |
|
|
|
|
|
direction='horizontal' |
|
|
|
|
|
showClear |
|
|
|
|
|
> |
|
|
|
|
|
{ |
|
|
|
|
|
u.sensor?.map((v, index) => |
|
|
|
|
|
<Form.Checkbox value={v.senterId} key={v.senterId} style={{ width: 200 }}>{v.senterName}({v.factorName})</Form.Checkbox>) |
|
|
|
|
|
} |
|
|
|
|
|
</Form.CheckboxGroup> |
|
|
|
|
|
}) : "" |
|
|
|
|
|
} |
|
|
|
|
|
</> |
|
|
|
|
|
} |
|
|
</Form> |
|
|
</Form> |
|
|
</div> |
|
|
</div > |
|
|
</Modal> |
|
|
</Modal > |
|
|
</> |
|
|
</> |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
@ -282,7 +407,7 @@ function mapStateToProps (state) { |
|
|
// loading: members.isRequesting, |
|
|
// loading: members.isRequesting, |
|
|
user: auth.user, |
|
|
user: auth.user, |
|
|
actions: global.actions, |
|
|
actions: global.actions, |
|
|
// members: members.data, |
|
|
traitLabel: global.traitLabel, |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|