Browse Source

Merge branch 'dev_trial' of https://gitea.free-sun.vip/free-sun/FS-IOT into dev_trial

release_0.0.2
yuan_yi 3 years ago
parent
commit
0956159fc8
  1. 4
      code/VideoAccess-VCMP/web/client/src/components/index.js
  2. 45
      code/VideoAccess-VCMP/web/client/src/components/reminderBox.jsx
  3. 14
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/actions/nvr.js
  4. 373
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/nvrModal.jsx
  5. 16
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/sideSheet.jsx
  6. 15
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/containers/nvr.jsx
  7. 1
      code/VideoAccess-VCMP/web/client/src/utils/webapi.js

4
code/VideoAccess-VCMP/web/client/src/components/index.js

@ -1,8 +1,10 @@
'use strict';
import SimpleFileDownButton from './simpleFileDownButton'
import Coming from './coming'
import ReminderBox from './reminderBox'
export {
SimpleFileDownButton,
Coming
Coming,
ReminderBox
};

45
code/VideoAccess-VCMP/web/client/src/components/reminderBox.jsx

@ -0,0 +1,45 @@
import { Button, Checkbox, Modal } from "@douyinfe/semi-ui";
import React from "react";
const ReminderBox = ({title, wait, toadd,visible,onOk}) => {
return (
<Modal
title={
<div style={{ fontSize: 14, lineHeight: "35px", marginLeft: 16 }}>
{title}
</div>
}
icon={
<img
src="../../assets/images/logo/figure.png"
style={{ width: 50, height: 50 }}
/>
}
footer={
<div
style={{
width: "100%",
display: "flex",
justifyContent: "space-between",
}}
>
<Checkbox
onChange={(checked) => console.log(checked)}
aria-label="Checkbox 示例"
style={{ width: 100 }}
>
不在提醒
</Checkbox>
<div>
<Button>{wait}</Button>
<Button theme="solid" onClick={onOk()}>{toadd}</Button>
</div>
</div>
}
// visible={false}
visible={visible}
></Modal>
);
};
export default ReminderBox;

14
code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/actions/nvr.js

@ -89,3 +89,17 @@ export function getExport() {
reducer: { name: "" },
});
}
export function getCheck(data) {
return (dispatch) =>
basicAction({
type: "post",
dispatch: dispatch,
data,
actionType: "GET_CHECK",
url: `${ApiTable.getCheck}`,
msg: { option: "" }, //校验nvr信息
reducer: { name: "" },
});
}

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

@ -1,177 +1,284 @@
import React, { useState ,useRef} from 'react'
import React, { useState, useRef, useEffect } from "react";
import { connect } from "react-redux";
import { Modal,Form,Row,Col,Spin } from '@douyinfe/semi-ui';
import { IconTickCircle } from '@douyinfe/semi-icons';
function nvrModal(props){
const {modalName}=props
const { dispatch, actions,vender,close } = props;
const nvrData = props.nvrData||{}//
import { Modal, Form, Row, Col, Spin } from "@douyinfe/semi-ui";
import { IconTickCircle } from "@douyinfe/semi-icons";
import moment from "moment";
function nvrModal(props) {
const { modalName } = props;
const { dispatch, actions, vender, close } = props;
const nvrData = props.nvrData || {}; //
const form = useRef();
const [visible, setVisible] = useState(false);//
const [isloading,setloading] = useState(false);//loading
const [loadingTip,setloadingTip] = useState('获取中...请稍后...');//loading tip
const [step,setstep] = useState(0)//
const [okText,setokText] = useState('测试校验')//oktext
const [cancelText,setcancelText] = useState('取消')//text
const [formObj,setformObj] = useState()//
function showDialog() {//
const [visible, setVisible] = useState(false); //
const [isloading, setloading] = useState(false); //loading
const [loadingTip, setloadingTip] = useState("获取中...请稍后..."); //loading tip
const [step, setstep] = useState("none"); //
const [okText, setokText] = useState("测试校验"); //oktext
const [cancelText, setcancelText] = useState("取消"); //text
const [formObj, setformObj] = useState(); //
useEffect(() => {
console.log(props.user.id);
}, []);
function showDialog() {
//
setVisible(true);
}
function positionForm(val){
let zz = /^(-?\d+)(\.\d+)?$/
if(!val){
return '请输入或拾取高德经纬度坐标'
}
else if(val.split(',').length!=2){
return '请输入格式为116.354169,39.835452的经纬度坐标'
}
else if(!zz.test(val.split(',')[0])){
return '只能填写数字'
}
else if(!zz.test(val.split(',')[1])){
return '只能填写数字'
}
else{
return ''
function positionForm(val) {
let zz = /^(-?\d+)(\.\d+)?$/;
if (!val) {
return "请输入或拾取高德经纬度坐标";
} else if (val.split(",").length != 2) {
return "请输入格式为116.354169,39.835452的经纬度坐标";
} else if (!zz.test(val.split(",")[0])) {
return "只能填写数字";
} else if (!zz.test(val.split(",")[1])) {
return "只能填写数字";
} else {
return "";
}
}
function handleOk() {//
if(step==0){
form.current.validate()
.then(values=>{//
let valuesObj=JSON.parse(JSON.stringify(values))
valuesObj.longitude=values.position.split(',')[0]
valuesObj.latitude=values.position.split(',')[1]
delete valuesObj.position
if(nvrData.id){
valuesObj.id=nvrData.id
}
setformObj(valuesObj)
setloading(true);
setTimeout(() => {
setloadingTip('...接受成功')
setTimeout(()=>{
setloadingTip('已完成')
setTimeout(() => {
setstep(1);
setokText('确认');
setcancelText('上一步');
setloading(false);
}, 1000);
}, 1000)
}, 1000);
})
.catch(errors=>{//
console.log('errors',errors);
})
}
else{
dispatch(actions.equipmentWarehouse.addchangeNvr(formObj)).then(res => {
function handleOk() {
//
if (step == "none") {
form.current
.validate()
.then((values) => {
//
console.log(values);
let valuesObj = JSON.parse(JSON.stringify(values));
valuesObj.longitude = values.position.split(",")[0];
valuesObj.latitude = values.position.split(",")[1];
delete valuesObj.position;
if (nvrData.id) {
valuesObj.id = nvrData.id;
}
var x = new moment();
setloading(true);
dispatch(
actions.equipmentWarehouse.getCheck({
serialNo: valuesObj.serialNo,
})
).then((res) => {
console.log(res);
var y = new moment();
var duration = moment.duration(y.diff(x))._data.milliseconds;
if (res.success) {
setTimeout(
() => {
setloadingTip("已完成");
setTimeout(() => {
setstep("block");
setloading(false);
setokText("确认");
setcancelText("上一步");
setloadingTip("获取中...请稍后...");
}, 1000);
},
duration > 2000 ? 0 : 2000 - duration
);
} else {
setTimeout(
() => {
setloadingTip("校验失败");
setTimeout(() => {
setstep("none");
setloading(false);
setokText("测试校验");
setcancelText("取消");
setloadingTip("获取中...请稍后...");
}, 1000);
},
duration > 2000 ? 0 : 2000 - duration
);
}
});
setformObj(valuesObj);
})
.catch((errors) => {
//
console.log("errors", errors);
});
} else {
dispatch(actions.equipmentWarehouse.addchangeNvr(formObj)).then((res) => {
setVisible(false);
close();
})
});
}
}
function handleAfterClose(){//
setstep(0);
setokText('测试校验');
setcancelText('取消');
function handleAfterClose() {
//
setstep("none");
setokText("测试校验");
setcancelText("取消");
}
function handleCancel() {//
if(step==0){
function handleCancel() {
//
if (step == "none") {
setVisible(false);
}
else{
setstep(0);
setokText('测试校验');
setcancelText('取消');
} else {
setstep("none");
setokText("测试校验");
setcancelText("取消");
}
}
function handleLocation(){//
window.open('https://lbs.amap.com/tools/picker','_blank')
function handleLocation() {
//
window.open("https://lbs.amap.com/tools/picker", "_blank");
}
return (
<>
<div onClick={showDialog}>{modalName=='add'?'添加NVR':'修改'}</div>
<div onClick={showDialog}>{modalName == "add" ? "添加NVR" : "修改"}</div>
<Modal
title={modalName=='add'?'添加NVR':'修改NVR'}
okText={okText}
cancelText={cancelText} //
visible={visible}
onOk={handleOk}
width={607}
afterClose={handleAfterClose}
onCancel={handleCancel}
title={modalName == "add" ? "添加NVR" : "修改NVR"}
okText={okText}
cancelText={cancelText} //
visible={visible}
onOk={handleOk}
width={607}
afterClose={handleAfterClose}
onCancel={handleCancel}
>
<Spin tip={loadingTip} spinning={isloading}>
{step==0?<div style={{paddingLeft:16}}>
<div
style={{
paddingLeft: 16,
display: step == "none" ? "block" : "none",
}}
>
<Form
allowEmpty
labelPosition='left'
labelAlign='left'
labelWidth= '90px'
onValueChange={values=>console.log(values)}
getFormApi={formApi => form.current = formApi}>
labelPosition="left"
labelAlign="left"
labelWidth="90px"
onValueChange={(values) => console.log(values)}
getFormApi={(formApi) => (form.current = formApi)}
>
<Row>
<Col span={12}>
<Form.Input maxLength='39' field='serialNo' label='设备编号:' initValue={nvrData.serialNo||''} placeholder='请输入设备编号' style={{ width:149 }}
rules={[
{ required: true, message: '请输入设备编号' }
]}/>
<Form.Input
maxLength="39"
field="serialNo"
label="设备编号:"
initValue={nvrData.serialNo || ""}
placeholder="请输入设备编号"
style={{ width: 149 }}
rules={[{ required: true, message: "请输入设备编号" }]}
/>
</Col>
<Col span={12}>
<Form.InputNumber formatter={value => `${value}`.replace(/\D/g, '')} hideButtons={true} maxLength='15' field='regionCode' label='行政区区码:' initValue={nvrData.regionCode||''} placeholder='请输入行政区区码' style={{ width:149 }}/>
<Form.InputNumber
formatter={(value) => `${value}`.replace(/\D/g, "")}
hideButtons={true}
maxLength="15"
field="regionCode"
label="行政区区码:"
initValue={nvrData.regionCode || ""}
placeholder="请输入行政区区码"
style={{ width: 149 }}
/>
</Col>
<Col span={24}>
<Form.Input maxLength='36' field='name' label='设备名称:' initValue={nvrData.name||''} placeholder='请输入设备名称、常用项目或位置定义' style={{ width:421 }}
rules={[
{ required: true, message: '请输入设备名称、常用项目或位置定义' }
]}/>
<Form.Input
maxLength="36"
field="name"
label="设备名称:"
initValue={nvrData.name || ""}
placeholder="请输入设备名称、常用项目或位置定义"
style={{ width: 421 }}
rules={[
{
required: true,
message: "请输入设备名称、常用项目或位置定义",
},
]}
/>
</Col>
<Col span={24}>
<Form.Select label="设备厂家:" field='venderId' initValue={nvrData.venderId||null} placeholder='请选择设备厂家' style={{ width: 421 }}
rules={[
{ required: true, message: '请选择设备厂家' }
]}>
{vender.map((item,index)=>(
<Form.Select.Option key={index} value={item.id}>{item.name}</Form.Select.Option>
<Form.Select
label="设备厂家:"
field="venderId"
initValue={nvrData.venderId || null}
placeholder="请选择设备厂家"
style={{ width: 421 }}
rules={[{ required: true, message: "请选择设备厂家" }]}
>
{vender.map((item, index) => (
<Form.Select.Option key={index} value={item.id}>
{item.name}
</Form.Select.Option>
))}
</Form.Select>
</Col>
<Col span={24} style={{display:'flex'}}>
<Form.Input maxLength='39' field='position' label='安装位置:' initValue={nvrData.longitude&&nvrData.latitude?nvrData.longitude+','+nvrData.latitude:''} placeholder='请输入或拾取高德经纬度坐标' style={{ width:386 }}
validate={positionForm}
<Col span={24} style={{ display: "flex" }}>
<Form.Input
maxLength="39"
field="position"
label="安装位置:"
initValue={
nvrData.longitude && nvrData.latitude
? nvrData.longitude + "," + nvrData.latitude
: ""
}
placeholder="请输入或拾取高德经纬度坐标"
style={{ width: 386 }}
validate={positionForm}
rules={[
{ required: true, message: '请输入或拾取高德经纬度坐标' }
]}/>
<div style={{
width:32,
height:32,
background:"#1859C1",
marginLeft:4,
display:'flex',
justifyContent: 'center',
alignItems: 'center',
cursor: "pointer",
marginTop:12,
borderRadius: 3+'px'}}
onClick={handleLocation}>
<img src="../../../assets/images/background/location.png" width={16} height={20}/>
{
required: true,
message: "请输入或拾取高德经纬度坐标",
},
]}
/>
<div
style={{
width: 32,
height: 32,
background: "#1859C1",
marginLeft: 4,
display: "flex",
justifyContent: "center",
alignItems: "center",
cursor: "pointer",
marginTop: 12,
borderRadius: 3 + "px",
}}
onClick={handleLocation}
>
<img
src="../../../assets/images/background/location.png"
width={16}
height={20}
/>
</div>
</Col>
</Row>
</Form>
</div>
://
<div style={{height:224}}>
<div style={{paddingTop:50,display: 'flex', justifyContent: 'center'}}>
<IconTickCircle style={{color:'#04B234',fontSize:60}}/>
<div style={{ height: 224, display: step }}>
<div
style={{
paddingTop: 50,
display: "flex",
justifyContent: "center",
}}
>
<IconTickCircle style={{ color: "#04B234", fontSize: 60 }} />
</div>
<div style={{marginTop:20,display: 'flex', justifyContent: 'center'}}>
<div
style={{
marginTop: 20,
display: "flex",
justifyContent: "center",
}}
>
已完成NVR设备测试和校验是否确认添加
</div>
</div>
}
</Spin>
</Modal>
</>
@ -179,13 +286,13 @@ function nvrModal(props){
}
function mapStateToProps(state) {
const { auth, global, members,vender } = state;
const { auth, global, members, vender } = state;
return {
loading: members.isRequesting,
user: auth.user,
actions: global.actions,
members: members.data,
vender:vender.data||[],//
vender: vender.data || [], //
};
}

16
code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/sideSheet.jsx

@ -260,7 +260,7 @@ function SideSheets(props) {
<div
key={"name" + index}
style={{
fontWeight: "600",
fontWeight: "400",
color: "#1859C1",
margin: "15px 0 12px 40px",
}}
@ -302,14 +302,14 @@ function SideSheets(props) {
width: 150,
display: "inline-block",
textAlign: "right",
fontWeight: "600",
fontWeight: "400",
color: "rgba(0, 0, 0, 0.45)",
}}
>
{item.name}
</span>
<span
style={{ fontWeight: "600", color: " #34383E" }}
style={{ fontWeight: "400", color: " #34383E" }}
>
{nvrDetails[item.key]}
</span>
@ -330,14 +330,14 @@ function SideSheets(props) {
width: 150,
display: "inline-block",
textAlign: "right",
fontWeight: "600",
fontWeight: "400",
color: "rgba(0, 0, 0, 0.45)",
}}
>
{item.name}
</span>
<span
style={{ fontWeight: "600", color: " #34383E" }}
style={{ fontWeight: "400", color: " #34383E" }}
>
{item.key == "type"
? accessType.find(
@ -430,7 +430,7 @@ function SideSheets(props) {
width: 150,
display: "inline-block",
textAlign: "right",
fontWeight: "600",
fontWeight: "400",
color: "rgba(0, 0, 0, 0.45)",
}}
>
@ -438,7 +438,7 @@ function SideSheets(props) {
</span>
<span
style={{
fontWeight: "600",
fontWeight: "400",
color: " #34383E",
}}
>
@ -514,7 +514,7 @@ function SideSheets(props) {
border: "1px solid rgba(151, 151, 151, 0.2)",
margin: "16px 0 0 36px",
color: "rgba(0, 0, 0, 0.85)",
fontWeight: "600",
fontWeight: "400",
}}
>
<div

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

@ -1,5 +1,6 @@
import React, { useState, useEffect, useRef } from "react";
import { connect } from "react-redux";
import { push } from 'react-router-redux';
import moment from "moment";
import {
Button,
@ -19,6 +20,7 @@ import NvrModal from "../components/nvrModal";
import Setup from "../components/setup";
import SideSheets from "../components/sideSheet";
import { skeletonScreen } from "../components/skeletonScreen";
import { ReminderBox } from "../../../components/index";
export const accessType = [
{ name: "萤石云平台摄像头", key: "yingshi" },
@ -39,6 +41,8 @@ const NvrHeader = (props) => {
const [search, setearch] = useState({}); //
const [rowId, setRowId] = useState(); //id
const [load, setLoad] = useState(); //
const [reminder, setReminder] = useState(true); //
const api = useRef();
const SETUPS = "setups";
@ -379,6 +383,7 @@ const NvrHeader = (props) => {
<Form.Input
label="设备搜索:"
field="keyword"
maxLength="36"
placeholder="请输入设备名称"
labelPosition="left"
style={screen}
@ -596,6 +601,16 @@ const NvrHeader = (props) => {
) : (
[]
)}
<ReminderBox
title="是否继续添加NVR摄像头?"
wait="再等等"
toadd="去添加"
visible={reminder}
onOk={()=>{
// dispatch(push('/equipmentWarehouse/camera'));
setReminder(false)
}}
/>
</div>
</>
);

1
code/VideoAccess-VCMP/web/client/src/utils/webapi.js

@ -15,6 +15,7 @@ export const ApiTable = {
delNvr: "nvr/{nvrId}",
getNvrDetails: "nvr/detail/{nvrId}", //获取nvr详情
getExport: "camera/export", //nvr表格数据导出
getCheck:"nvr/verify", //校验nvr信息
getCamera: "camera/project", // 获取摄像头列表
putForbidden: "camera/banned", //禁用摄像头

Loading…
Cancel
Save