Browse Source

NVR跳转传参功能完成,NVR摄像头获取视频流时交互样式

release_0.0.2
wenlele 3 years ago
parent
commit
2d9f850a9f
  1. 21
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/cameraModal.jsx
  2. 729
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/nvrCamera.jsx
  3. 15
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/nvrModal.jsx
  4. 36
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/camera.jsx
  5. 12
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/nvr.jsx

21
code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/cameraModal.jsx

@ -20,7 +20,9 @@ function cameraModal (props) {
CameraAbility, CameraAbility,
cameraData, // cameraData, //
modify, modify,
parentCamera parentCamera,
addNvr,
nvrNumber
} = props; } = props;
const { equipmentWarehouse } = actions; const { equipmentWarehouse } = actions;
const fluoriteRef = useRef(); const fluoriteRef = useRef();
@ -31,13 +33,13 @@ function cameraModal (props) {
const [loadingTip, setloadingTip] = useState("获取中...请稍后..."); //loading tip const [loadingTip, setloadingTip] = useState("获取中...请稍后..."); //loading tip
const [okText, setokText] = useState("确定"); //oktext const [okText, setokText] = useState("确定"); //oktext
const [cancelText, setcancelText] = useState("取消"); //text const [cancelText, setcancelText] = useState("取消"); //text
const [clickNum, setclickNum] = useState( const [clickNum, setclickNum] = useState(
cameraData.type == "yingshi" cameraData.type == "yingshi"
? 1 ? 1
: cameraData.type == "ipc" : cameraData.type == "ipc"
? 3 ? 3
: cameraData.type == "nvr" : cameraData.type == "nvr" || addNvr
? 2 ? 2
: cameraData.type == "cascade" : cameraData.type == "cascade"
? 4 ? 4
@ -47,7 +49,7 @@ function cameraModal (props) {
useEffect(() => { useEffect(() => {
dispatch(equipmentWarehouse.getCameraKind()); dispatch(equipmentWarehouse.getCameraKind());
dispatch(equipmentWarehouse.getAbility()); dispatch(equipmentWarehouse.getAbility());
cameraData.type == "nvr" ? setcameraList(cameraList.slice(1, 4)) : ""; cameraData.type == "nvr" || addNvr ? setcameraList(cameraList.slice(1, 4)) : "";
}, []); }, []);
const cameraList = [ const cameraList = [
// //
@ -149,20 +151,19 @@ function cameraModal (props) {
} }
function handleChoose (id) { function handleChoose (id) {
// //
if (!modify) { if (!addNvr && !modify) {
setclickNum(id); setclickNum(id);
} }
} }
function turnLift () { function turnLift () {
// //
if (!modify) { if (!addNvr && !modify) {
setcameraList(cameraList.slice(0, 3)); setcameraList(cameraList.slice(0, 3));
} }
} }
function turnRight () { function turnRight () {
// //
if (!modify) { if (!addNvr && !modify) {
setcameraList(cameraList.slice(1, 4)); setcameraList(cameraList.slice(1, 4));
} }
} }
@ -337,7 +338,7 @@ function cameraModal (props) {
}} }}
onClick={() => handleChoose(item.id)} onClick={() => handleChoose(item.id)}
> >
{modify ? item.id == clickNum ? "" : <div style={{ {modify || addNvr ? item.id == clickNum ? "" : <div style={{
width: 266, width: 266,
height: 146, height: 146,
borderRadius: 3, borderRadius: 3,
@ -490,7 +491,7 @@ function cameraModal (props) {
cameraData={cameraData} cameraData={cameraData}
/> />
) : clickNum == 2 ? ( ) : clickNum == 2 ? (
<NvrCamera nvrRef={nvrRef} cameraData={cameraData} /> <NvrCamera nvrRef={nvrRef} cameraData={cameraData} addNvr={addNvr} nvrNumber={nvrNumber} />
) : clickNum == 3 ? ( ) : clickNum == 3 ? (
<IpcCamera <IpcCamera
aRef={ipcRef} aRef={ipcRef}

729
code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/nvrCamera.jsx

@ -1,358 +1,417 @@
import React, { useState, useRef, useEffect, useImperativeHandle } from "react"; import React, { useState, useRef, useEffect, useImperativeHandle } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { import {
Form, Form,
Row, Row,
Col, Col,
Button, Button,
CheckboxGroup, CheckboxGroup,
Checkbox, Checkbox,
Radio, Radio,
Input, Input,
Spin,
} from "@douyinfe/semi-ui"; } from "@douyinfe/semi-ui";
import { IconEdit, IconPlayCircle } from "@douyinfe/semi-icons"; import { IconEdit, IconPlayCircle, IconTickCircle } from "@douyinfe/semi-icons";
import "./cameraModal.less"; import "./cameraModal.less";
import PerfectScrollbar from "perfect-scrollbar"; import PerfectScrollbar from "perfect-scrollbar";
import { isIndexed } from "immutable"; import { isIndexed } from "immutable";
let equipmentScrollbar; let equipmentScrollbar;
function nvrCamera({ dispatch, actions, nvrRef, cameraData }) { function nvrCamera ({ dispatch, actions, nvrRef, cameraData, addNvr, nvrNumber }) {
const { equipmentWarehouse } = actions; const { equipmentWarehouse } = actions;
const cameraDataNvr = cameraData.nvr || ""; const cameraDataNvr = cameraData.nvr || "";
const form = useRef(); const form = useRef();
const [nvrCheckList, setNvrCheckList] = useState([]); //nvr const [nvrCheckList, setNvrCheckList] = useState([]); //nvr
const [NVRcameraList, setNVRcameraList] = useState([]); //nvr const [NVRcameraList, setNVRcameraList] = useState([]); //nvr
const [isAllChoose, setIsAllChoose] = useState(false); // const [isAllChoose, setIsAllChoose] = useState(false); //
const [equipmentNum, setEquipmentNum] = useState(""); //nvr const [equipmentNum, setEquipmentNum] = useState(""); //nvr
const [isloading, setloading] = useState(false); //loading
const [loadingTip, setloadingTip] = useState("正在接入视频流..."); //loading tip
const [step, setstep] = useState("none");
const [stepp, setstepp] = useState("none");
useEffect(() => { useEffect(() => {
NVRcameraList NVRcameraList
? (equipmentScrollbar = new PerfectScrollbar("#video_streaming", { ? (equipmentScrollbar = new PerfectScrollbar("#video_streaming", {
suppressScrollX: true, suppressScrollX: true,
})) }))
: ""; : "";
}, [NVRcameraList]); }, [NVRcameraList]);
useEffect(() => { useEffect(() => {
const videoStreaming = document.getElementById("video_streaming"); const videoStreaming = document.getElementById("video_streaming");
if (videoStreaming && equipmentScrollbar) { if (videoStreaming && equipmentScrollbar) {
equipmentScrollbar.update(); equipmentScrollbar.update();
} }
}); });
useEffect(() => { useEffect(() => {
cameraDataNvr if (cameraDataNvr) {
? dispatch( setloading(true);
equipmentWarehouse.getVideoStreaming({ setstep("block");
streamId: cameraDataNvr.serialNo, dispatch(
}) equipmentWarehouse.getVideoStreaming({
).then((res) => { streamId: cameraDataNvr.serialNo,
let oneData = res.payload.data[0]; })
).then((res) => {
let modifyData = res.payload.data.find( console.log(res)
(item) => item.camera.name == cameraData.name let oneData = res.payload.data[0];
); let modifyData = res.payload.data.find(
console.log(oneData); (item) => item.camera == null ? false : item.camera.name == cameraData.name
console.log(modifyData); );
let data = res.payload.data.map((item, index) => { let data = res.payload.data.map((item, index) => {
if (index == 0) { if (index == 0) {
item = modifyData; item = modifyData;
} }
if ( if (
item.camera item.camera
? item.camera.name == cameraData.name && index > 0 ? item.camera.name == cameraData.name && index > 0
: index < 0 : index < 0
) { ) {
item = oneData; item = oneData;
} }
item.change = false; item.change = false;
item.support = false; item.support = false;
if (item.camera) { if (item.camera) {
item.name = item.camera.name; item.name = item.camera.name;
} }
return item;
});
setNVRcameraList(data);
setNvrCheckList([data[0].id]);
if (res.success) {
setTimeout(() => {
setloadingTip("接入完成");
setTimeout(() => {
setstep("none");
setloading(false);
setstepp("block");
setloadingTip("正在接入视频流...");
}, 800);
}, 800)
}
})
}
return item; //NVRnvr
}); if (addNvr) {
console.log(data); setloading(true);
setNVRcameraList(data); setstep("block");
dispatch(equipmentWarehouse.getVideoStreaming({ streamId: nvrNumber })).then((res) => {
let chooseList = [];
let data = res.payload.data.map((item) => {
item.change = false;
item.support = false;
return item;
});
setNVRcameraList(data);
for (let index = 0; index < data.length; index++) {
chooseList.push(data[index].id);
}
setNvrCheckList(chooseList);
setIsAllChoose(true);
if (res.success) {
setTimeout(() => {
setloadingTip("接入完成");
setTimeout(() => {
setstep("none");
setloading(false);
setstepp("block");
setloadingTip("正在接入视频流...");
}, 800);
}, 800)
}
})
}
setNvrCheckList([data[0].id]); }, []);
}) function NvrChangeName (e, index, name) {
: ""; //nvr
}, []); let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList));
function NvrChangeName(e, index, name) { if (!cameraDataNvr || cameraData.name == name) {
//nvr NvrchangeList[index].change = true;
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList)); setNVRcameraList(NvrchangeList);
if (!cameraDataNvr || cameraData.name == name) { e.stopPropagation();
NvrchangeList[index].change = true; }
setNVRcameraList(NvrchangeList); }
e.stopPropagation(); function nvronBlur (index) {
//nvr
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList));
NvrchangeList[index].change = false;
setNVRcameraList(NvrchangeList);
}
function inputchange (e, index) {
//nvr
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList));
NvrchangeList[index].name = e;
setNVRcameraList(NvrchangeList);
}
function toggle (e, index) {
//nvr
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList));
NvrchangeList[index].support = e.target.checked;
setNVRcameraList(NvrchangeList);
e.stopPropagation();
}
function getVideoList () {
form.current
.validate()
.then((values) => {
//
let chooseList = [];
let valuess = JSON.parse(JSON.stringify(values));
valuess.streamId = values.serialNo;
delete valuess.serialNo;
setloading(true);
setstep("block");
dispatch(equipmentWarehouse.getVideoStreaming(valuess)).then((res) => {
let data = res.payload.data.map((item) => {
item.change = false;
item.support = false;
return item;
});
setNVRcameraList(data);
for (let index = 0; index < data.length; index++) {
chooseList.push(data[index].id);
}
setNvrCheckList(chooseList);
setIsAllChoose(true);
if (res.success) {
setTimeout(() => {
setloadingTip("接入完成");
setTimeout(() => {
setstep("none");
setloading(false);
setstepp("block");
setloadingTip("正在接入视频流...");
}, 800);
}, 800)
}
});
})
.catch((errors) => {
//
console.log("errors", errors);
});
} }
} function allChoose (e) {
function nvronBlur(index) { ///
//nvr
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList));
NvrchangeList[index].change = false;
setNVRcameraList(NvrchangeList);
}
function inputchange(e, index) {
//nvr
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList));
console.log(e);
NvrchangeList[index].name = e;
setNVRcameraList(NvrchangeList);
}
function toggle(e, index) {
//nvr
console.log(e)
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList));
console.log(NvrchangeList)
NvrchangeList[index].support = e.target.checked;
setNVRcameraList(NvrchangeList);
e.stopPropagation();
}
function getVideoList() {
form.current
.validate()
.then((values) => {
//
let chooseList = []; let chooseList = [];
let valuess = JSON.parse(JSON.stringify(values)); if (NVRcameraList.length == nvrCheckList.length) {
valuess.streamId = values.serialNo; setNvrCheckList([]);
delete valuess.serialNo; setIsAllChoose(false);
dispatch(equipmentWarehouse.getVideoStreaming(valuess)).then((res) => { } else {
let data = res.payload.data.map((item) => { for (let index = 0; index < NVRcameraList.length; index++) {
item.change = false; chooseList.push(NVRcameraList[index].id);
item.support = false; }
return item; setNvrCheckList(chooseList);
}); setIsAllChoose(true);
console.log(data); }
setNVRcameraList(data);
for (let index = 0; index < data.length; index++) {
chooseList.push(data[index].id);
}
console.log(chooseList);
setNvrCheckList(chooseList);
setIsAllChoose(true);
});
})
.catch((errors) => {
//
console.log("errors", errors);
});
}
function allChoose(e) {
///
let chooseList = [];
if (NVRcameraList.length == nvrCheckList.length) {
setNvrCheckList([]);
setIsAllChoose(false);
} else {
for (let index = 0; index < NVRcameraList.length; index++) {
chooseList.push(NVRcameraList[index].id);
}
setNvrCheckList(chooseList);
setIsAllChoose(true);
} }
} function playVideo (e) {
function playVideo(e) { //nvr
//nvr console.log("22222222222222222");
console.log("22222222222222222"); e.stopPropagation();
e.stopPropagation();
}
function onDisabled(name) {
if ((cameraDataNvr && cameraData.name == name) || !cameraDataNvr) {
return false;
} else {
return true;
} }
} function onDisabled (name) {
useImperativeHandle(nvrRef, () => ({ if ((cameraDataNvr && cameraData.name == name) || !cameraDataNvr) {
// return false;
//aa } else {
resetFluoriteCamera: form.current.reset, return true;
equipmentNum: cameraDataNvr ? cameraDataNvr.serialNo : equipmentNum, }
NVRcameraList: NVRcameraList.filter((v) => }
nvrCheckList.some((e) => e == v.id) useImperativeHandle(nvrRef, () => ({
), //
})); //aa
return ( resetFluoriteCamera: form.current.reset,
<> equipmentNum: cameraDataNvr ? cameraDataNvr.serialNo : addNvr ? nvrNumber : equipmentNum,
<Form NVRcameraList: NVRcameraList.filter((v) =>
allowEmpty nvrCheckList.some((e) => e == v.id)
labelPosition="left" ),
labelAlign="left" }));
labelWidth="115px" return (
onValueChange={(values) => { <>
setEquipmentNum(values.serialNo); <Form
}} allowEmpty
getFormApi={(formApi) => (form.current = formApi)} labelPosition="left"
> labelAlign="left"
<div style={{ display: "flex" }}> labelWidth="115px"
<Form.Input onValueChange={(values) => {
field="serialNo" setEquipmentNum(values.serialNo);
maxLength="39" }}
label="设备编号:" getFormApi={(formApi) => (form.current = formApi)}
disabled={cameraDataNvr ? true : false}
initValue={cameraDataNvr ? cameraDataNvr.serialNo : ""}
placeholder="请输入设备编号"
style={{ width: 307 }}
rules={[
{ required: true, message: "请输入设备编号" },
{ pattern: "^[A-Za-z0-9]+$", message: "只能输入数字或者字母" },
]}
/>
<Button
disabled={!equipmentNum.length > 0}
theme="solid"
type="primary"
onClick={() => {
getVideoList();
}}
style={{ marginLeft: 8, marginTop: 12 }}
>
视频流获取
</Button>
{NVRcameraList.length > 0 ? (
<div
style={{ display: "flex", alignItems: "center", marginLeft: 211 }}
>
<Radio
checked={isAllChoose}
mode="advanced"
disabled={cameraDataNvr ? true : false}
onChange={(e) => allChoose(e)}
aria-label="全选"
>
全选
</Radio>
</div>
) : (
""
)}
</div>
<Row>
<CheckboxGroup
type="pureCard"
direction="vertical"
aria-label="视频流获取"
value={nvrCheckList}
onChange={(nvrCheck) => {
setNvrCheckList(nvrCheck);
if (NVRcameraList.length == nvrCheck.length) {
setIsAllChoose(true);
} else {
setIsAllChoose(false);
}
}}
>
<div
id="video_streaming"
style={{ maxHeight: 300, position: "relative" }}
> >
{NVRcameraList.length > 0 <div style={{ display: "flex" }}>
? NVRcameraList.map((item, index) => ( <Form.Input
<Col field="serialNo"
key={index} maxLength="39"
span={12} label="设备编号:"
style={{ disabled={cameraDataNvr ? true : addNvr ? true : false}
display: "flex", initValue={cameraDataNvr ? cameraDataNvr.serialNo : addNvr ? nvrNumber : ""}
justifyContent: "center", placeholder="请输入设备编号"
marginTop: 12, style={{ width: 307 }}
}} rules={[
{ required: true, message: "请输入设备编号" },
{ pattern: "^[A-Za-z0-9]+$", message: "只能输入数字或者字母" },
]}
/>
<Button
disabled={!equipmentNum.length > 0}
theme="solid"
type="primary"
onClick={() => {
getVideoList();
}}
style={{ marginLeft: 8, marginTop: 12 }}
> >
<Checkbox 视频流获取
value={item.id} </Button>
disabled={onDisabled(item.name)} {NVRcameraList.length > 0 ? (
extra={ <div
<div> style={{ display: "flex", alignItems: "center", marginLeft: 211 }}
<div >
style={{ <Radio
display: "flex", checked={isAllChoose}
alignItems: "center",
justifyContent: "space-between",
height: 30,
}}
>
<div>
通道名称
{item.change ? (
<Input
autofocus
style={{ width: 100 }}
value={item.name}
onChange={(e) => inputchange(e, index)}
onBlur={() => nvronBlur(index)}
></Input>
) : (
item.name
)}
</div>
<div
style={{
display: "flex",
alignItems: "center",
}}
>
<IconEdit
style={{
fontSize: 16,
marginLeft: 18,
cursor: "pointer",
color: "#1859C1",
}}
onClick={(e) =>
NvrChangeName(e, index, item.name)
}
/>
</div>
</div>
<div style={{ marginTop: 8, width: 246 }}>
设备编号{item.streamid}
</div>
<div
style={{
marginTop: 12,
display: "flex",
justifyContent: "space-between",
alignItems: "center",
}}
>
<IconPlayCircle
size="extra-large"
style={{ color: "#1859C1" }}
onClick={(e) => playVideo(e)}
/>
<Radio
checked={item.support}
mode="advanced" mode="advanced"
disabled={onDisabled(item.name)} disabled={cameraDataNvr ? true : false}
onChange={(e) => toggle(e, index)} onChange={(e) => allChoose(e)}
aria-label="单选" aria-label="全选"
> >
云台支持 全选
</Radio> </Radio>
</div> </div>
</div> ) : (
} ""
style={{ width: 280, border: "1px solid #F9F9F9" }} )}
></Checkbox> </div>
</Col> <Row>
)) <CheckboxGroup
: ""} type="pureCard"
</div> direction="vertical"
</CheckboxGroup> aria-label="视频流获取"
</Row> value={nvrCheckList}
</Form> onChange={(nvrCheck) => {
</> setNvrCheckList(nvrCheck);
); if (NVRcameraList.length == nvrCheck.length) {
setIsAllChoose(true);
} else {
setIsAllChoose(false);
}
}}
>
<div
id="video_streaming"
style={{ maxHeight: 300, position: "relative" }}
>
<Spin tip={loadingTip} spinning={isloading}>
<div style={{ display: stepp }}>
{NVRcameraList.length > 0
? NVRcameraList.map((item, index) => (
<Col
key={index}
span={12}
style={{
display: "flex",
justifyContent: "center",
marginTop: 12,
}}
>
<Checkbox
value={item.id}
disabled={onDisabled(item.name)}
extra={
<div>
<div
style={{
display: "flex",
alignItems: "center",
justifyContent: "space-between",
height: 30,
}}
>
<div>
通道名称
{item.change ? (
<Input
autofocus
style={{ width: 100 }}
value={item.name}
onChange={(e) => inputchange(e, index)}
onBlur={() => nvronBlur(index)}
></Input>
) : (
item.name
)}
</div>
<div
style={{
display: "flex",
alignItems: "center",
}}
>
<IconEdit
style={{
fontSize: 16,
marginLeft: 18,
cursor: "pointer",
color: "#1859C1",
}}
onClick={(e) =>
NvrChangeName(e, index, item.name)
}
/>
</div>
</div>
<div style={{ marginTop: 8, width: 246 }}>
设备编号{item.streamid}
</div>
<div
style={{
marginTop: 12,
display: "flex",
justifyContent: "space-between",
alignItems: "center",
}}
>
<IconPlayCircle
size="extra-large"
style={{ color: "#1859C1" }}
onClick={(e) => playVideo(e)}
/>
<Radio
checked={item.support}
mode="advanced"
disabled={onDisabled(item.name)}
onChange={(e) => toggle(e, index)}
aria-label="单选"
>
云台支持
</Radio>
</div>
</div>
}
style={{ width: 280, border: "1px solid #F9F9F9" }}
></Checkbox>
</Col>
))
: ""}
</div>
<div style={{ height: 50, width: "100%", display: step }}></div>
</Spin>
</div>
</CheckboxGroup>
</Row>
</Form>
</>
);
} }
function mapStateToProps(state) { function mapStateToProps (state) {
const { auth, global, members } = state; const { auth, global, members } = state;
return { return {
loading: members.isRequesting, loading: members.isRequesting,
user: auth.user, user: auth.user,
actions: global.actions, actions: global.actions,
members: members.data, members: members.data,
}; };
} }
export default connect(mapStateToProps)(nvrCamera); export default connect(mapStateToProps)(nvrCamera);

15
code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/nvrModal.jsx

@ -1,4 +1,4 @@
import React, { useState, useRef, useEffect } from "react"; import React, { useState, useRef, useEffect,useImperativeHandle } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { Modal, Form, Row, Col, Spin } from "@douyinfe/semi-ui"; import { Modal, Form, Row, Col, Spin } from "@douyinfe/semi-ui";
import { IconTickCircle } from "@douyinfe/semi-icons"; import { IconTickCircle } from "@douyinfe/semi-icons";
@ -6,7 +6,7 @@ import { IconTickCircle } from "@douyinfe/semi-icons";
import moment from "moment"; import moment from "moment";
function nvrModal(props) { function nvrModal(props) {
const { modalName } = props; const { modalName ,nvrRef} = props;
const { dispatch, actions, vender, close } = props; const { dispatch, actions, vender, close } = props;
const nvrData = props.nvrData || {}; // const nvrData = props.nvrData || {}; //
const form = useRef(); const form = useRef();
@ -18,10 +18,6 @@ function nvrModal(props) {
const [cancelText, setcancelText] = useState("取消"); //text const [cancelText, setcancelText] = useState("取消"); //text
const [formObj, setformObj] = useState(); // const [formObj, setformObj] = useState(); //
useEffect(() => {
console.log(props.user.id);
}, []);
function showDialog() { function showDialog() {
// //
setVisible(true); setVisible(true);
@ -47,6 +43,7 @@ function nvrModal(props) {
.validate() .validate()
.then((values) => { .then((values) => {
// //
console.log(values)
let valuesObj = JSON.parse(JSON.stringify(values)); let valuesObj = JSON.parse(JSON.stringify(values));
valuesObj.longitude = values.position.split(",")[0]; valuesObj.longitude = values.position.split(",")[0];
valuesObj.latitude = values.position.split(",")[1]; valuesObj.latitude = values.position.split(",")[1];
@ -61,7 +58,6 @@ function nvrModal(props) {
serialNo: valuesObj.serialNo, serialNo: valuesObj.serialNo,
}) })
).then((res) => { ).then((res) => {
console.log(res);
var after = new moment(); // var after = new moment(); //
var duration = moment.duration(after.diff(front))._data.milliseconds; var duration = moment.duration(after.diff(front))._data.milliseconds;
if (res.success) { if (res.success) {
@ -127,6 +123,11 @@ function nvrModal(props) {
// //
window.open("https://lbs.amap.com/tools/picker", "_blank"); window.open("https://lbs.amap.com/tools/picker", "_blank");
} }
useImperativeHandle(nvrRef, () => ({
//
//aa
nvrNumber: ()=>formObj.serialNo
}));
return ( return (
<> <>
<div onClick={showDialog}>{modalName == "add" ? "添加NVR" : "修改"}</div> <div onClick={showDialog}>{modalName == "add" ? "添加NVR" : "修改"}</div>

36
code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/camera.jsx

@ -37,6 +37,8 @@ const CameraHeader = (props) => {
const [cameraData, setCameraData] = useState({}); // const [cameraData, setCameraData] = useState({}); //
const [modify, setModify] = useState(false); // const [modify, setModify] = useState(false); //
const [parentCamera, setParentCamera] = useState(""); // const [parentCamera, setParentCamera] = useState(""); //
const [addNvr, setAddNvr] = useState(false); //nvrNVR
const [nvrNumber, setNvrNumber] = useState();
const { equipmentWarehouse } = actions; const { equipmentWarehouse } = actions;
const api = useRef(); const api = useRef();
const searchb = useRef(search) const searchb = useRef(search)
@ -44,8 +46,14 @@ const CameraHeader = (props) => {
const CAMERAS = "cameras"; const CAMERAS = "cameras";
useEffect(() => { useEffect(() => {
console.log(props) console.log(props)
if (props.location.query) {
setAddNvr(props.location.query.addNvr)
setNvrNumber(props.location.query.serialNo)
setCameraModal(true);
}
dispatch(actions.equipmentWarehouse.getVender()).then((res) => { dispatch(actions.equipmentWarehouse.getVender()).then((res) => {
setvenderList(res.payload.data); setvenderList(res.payload.data);
attribute(res.payload.data); attribute(res.payload.data);
@ -115,7 +123,6 @@ const CameraHeader = (props) => {
width: "20%", width: "20%",
dataIndex: "", dataIndex: "",
render: (_, row) => { render: (_, row) => {
console.log(row);
return ( return (
<div style={{ display: "flex" }}> <div style={{ display: "flex" }}>
<Button <Button
@ -220,26 +227,6 @@ const CameraHeader = (props) => {
}, },
]; ];
const device_ = (r) => {
console.log(searchb)
if (deviceClick) {
// if (r.type == "nvr") {
// console.log(search)
// setearch({ ...search, nvrId: r.nvr.id })
// } else {
// setearch({ ...search, externalDomain: r.externalDomain })
// }
setDeviceClick(false)
} else {
// if (r.type == "nvr") {
// setearch({ ...search, nvrId: null })
// } else {
// setearch({ ...search, externalDomain: null })
// }
setDeviceClick(true)
}
}
// //
function attribute (data) { function attribute (data) {
const arr = localStorage.getItem(CAMERAS) const arr = localStorage.getItem(CAMERAS)
@ -706,14 +693,17 @@ const CameraHeader = (props) => {
venderList={venderList} venderList={venderList}
cameraData={cameraData} cameraData={cameraData}
modify={modify} modify={modify}
addNvr={addNvr}
nvrNumber={nvrNumber}
parentCamera={parentCamera} parentCamera={parentCamera}
close={() => { close={() => {
setCameraModal(false); setCameraModal(false);
setCameraData({}); setCameraData({});
setModify(false) setModify(false)
setParentCamera("") setParentCamera("")
setAddNvr(false)
setNvrNumber("")
equipmentGetCamera(); equipmentGetCamera();
}} }}
modalName={modalName} modalName={modalName}
/> />

12
code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/nvr.jsx

@ -1,6 +1,6 @@
import React, { useState, useEffect, useRef } from "react"; import React, { useState, useEffect, useRef } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { push } from "react-router-redux"; // import { push } from "react-router-redux";
import moment from "moment"; import moment from "moment";
import { import {
Button, Button,
@ -30,7 +30,7 @@ export const accessType = [
]; ];
const NvrHeader = (props) => { const NvrHeader = (props) => {
const { dispatch, actions, user, loading, equipmentWarehouseNvr } = props; const { history,dispatch, actions, user, loading, equipmentWarehouseNvr } = props;
const { equipmentWarehouse } = actions; const { equipmentWarehouse } = actions;
const [setup, setSetup] = useState(false); const [setup, setSetup] = useState(false);
const [sideSheet, setSideSheet] = useState(false); const [sideSheet, setSideSheet] = useState(false);
@ -39,12 +39,13 @@ const NvrHeader = (props) => {
const [query, setQuery] = useState({ limit: 10, page: 0 }); // const [query, setQuery] = useState({ limit: 10, page: 0 }); //
const [search, setearch] = useState({}); // const [search, setearch] = useState({}); //
const [rowId, setRowId] = useState(); //id const [rowId, setRowId] = useState(); //id
const [reminder, setReminder] = useState(false); // const [reminder, setReminder] = useState(false); //
const api = useRef(); const api = useRef();
const SETUPS = "setups"; const SETUPS = "setups";
const nvrRef = useRef(); //
useEffect(() => { useEffect(() => {
console.log(props)
dispatch(actions.equipmentWarehouse.getVender()).then((res) => { dispatch(actions.equipmentWarehouse.getVender()).then((res) => {
setvenderList(res.payload.data); setvenderList(res.payload.data);
attribute(res.payload.data); attribute(res.payload.data);
@ -157,7 +158,6 @@ const NvrHeader = (props) => {
dataIndex: "venderId", dataIndex: "venderId",
key: "manufactor", key: "manufactor",
render: (_, r, index) => { render: (_, r, index) => {
console.log(r);
let manufactorName = data.find((item) => item.id == r.venderId); let manufactorName = data.find((item) => item.id == r.venderId);
return manufactorName ? manufactorName.name : ""; return manufactorName ? manufactorName.name : "";
}, },
@ -327,7 +327,9 @@ const NvrHeader = (props) => {
<NvrModal <NvrModal
modalName="add" modalName="add"
venderList={venderList} venderList={venderList}
nvrRef={nvrRef}
close={() => { close={() => {
setReminder(true)
equipmentGetNvr(); equipmentGetNvr();
}} }}
/> />
@ -592,7 +594,7 @@ const NvrHeader = (props) => {
toadd="去添加" toadd="去添加"
visible={reminder} visible={reminder}
onOk={() => { onOk={() => {
dispatch(push('/equipmentWarehouse/camera/:addNvr=true')); history.push({pathname:'/equipmentWarehouse/camera',query:{addNvr:true,serialNo:nvrRef.current.nvrNumber()}});
setReminder(false) setReminder(false)
}} }}
/> />

Loading…
Cancel
Save