|
|
@ -22,6 +22,7 @@ const DeviceManagement = (props) => { |
|
|
|
const [selectedRows,setSelectedRows]=useState([])//选择的key |
|
|
|
const [selectdR,setSelectedR]=useState([])//选择行 |
|
|
|
const [vData,setVData]=useState([])//版本信息 |
|
|
|
const [id,setId]=useState()//初始化展示的结构物 |
|
|
|
const getData=(data)=>{ |
|
|
|
dispatch(firmwareUpgrade.getThingMessages(data)).then((res)=>{ |
|
|
|
if(res.success) { |
|
|
@ -51,12 +52,13 @@ const DeviceManagement = (props) => { |
|
|
|
useEffect(()=>{ |
|
|
|
if(thingIds&&thingIds.length){ |
|
|
|
const data={thingIds:thingIds.split(',')[0]||'000'}//给一个初始化的值 |
|
|
|
setId(thingIds.split(',')[0]) |
|
|
|
getData(data) |
|
|
|
} |
|
|
|
console.log('thingIds',thingIds) |
|
|
|
},[thingIds]) |
|
|
|
|
|
|
|
const structChange =value => { |
|
|
|
setId(value) |
|
|
|
clearSelectedRows() |
|
|
|
setUpdataButtonDisabled(true) |
|
|
|
const deviceTypeList= strucAndDeviceType?.find(item=>item.thingId==value)?.deviceType?.map(child=>{ |
|
|
@ -120,7 +122,7 @@ const DeviceManagement = (props) => { |
|
|
|
// console.log(`select row: ${selected}`, record); |
|
|
|
// }, |
|
|
|
onSelectAll: (selected, selectedRows) => { |
|
|
|
setUpdataButtonDisabled(!selectedRows.every(item=>selectedRows[0]?.deviceType===item.deviceType)) |
|
|
|
setUpdataButtonDisabled(!selectedRows.every(item=>selectedRows[0]?.deviceType===item.deviceType&&item.switchStatus)) |
|
|
|
}, |
|
|
|
onChange: (selectedRowKeys, selectedRows) => { |
|
|
|
setSelectedR(selectedRows) |
|
|
@ -132,7 +134,7 @@ const DeviceManagement = (props) => { |
|
|
|
} |
|
|
|
//选择很多的时候,如果有设备型号不对应的情况 |
|
|
|
if(selectedRows&&selectedRows.length>0){ |
|
|
|
setUpdataButtonDisabled(!selectedRows.every(item=>selectedRows[0].deviceType===item.deviceType)) |
|
|
|
setUpdataButtonDisabled(!selectedRows.every(item=>selectedRows[0].deviceType===item.deviceType&&item.switchStatus)) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -211,6 +213,7 @@ return <><div style={{ background: '#FFFFFF', margin: '8px 12px', padding: '20 |
|
|
|
<Select placeholder='请选择结构物' optionList={struc} filter showClear |
|
|
|
onChange={structChange} |
|
|
|
onClear={clearHandler} |
|
|
|
value={id} // 设置默认值为第一个选项的值 |
|
|
|
style={{ width:300,marginRight:10}}> |
|
|
|
</Select> |
|
|
|
<Select placeholder='请选择设备型号' value={defaultVal} optionList={deviceType} |
|
|
|