import React, { useState, useRef, useEffect, useImperativeHandle } from "react"; import { connect } from "react-redux"; import { Form, Row, Col } from "@douyinfe/semi-ui"; import "./cameraModal.less"; function ipcCamera ({ aRef, CameraKind, CameraAbility, venderList, cameraData, ashTrue, ashFalse }) { const { TextArea } = Form; const form = useRef(); const [cloud, setcloud] = useState(""); //云台支持 const [voice, setvoice] = useState(""); //语音支持 const [memoryList, setMemoryList] = useState([ { id: 1, value: "8g", }, { id: 2, value: "16g", }, { id: 3, value: "32g", }, { id: 4, value: "64g", }, { id: 5, value: "128g", }, { id: 6, value: "256g", }, { id: 7, value: ">256g", }, ]); //内存卡列表 useEffect(() => { setcloud(cameraData.cloudControl || ""); setvoice(cameraData.voice || ""); }, []); function handleLocation () { //高德经纬度 window.open("https://lbs.amap.com/tools/picker", "_blank"); } 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 ""; } } useImperativeHandle(aRef, () => ({ //传给父组件方法 //子组件暴露给父组件的方法 ipcCameraForm: form.current.validate, resetIpcCamera: form.current.reset, toempty: empty, })); function empty () { setcloud(null); setvoice(null); } return ( <>
> ); } function mapStateToProps (state) { const { auth, global, members } = state; return { loading: members.isRequesting, user: auth.user, actions: global.actions, members: members.data, }; } export default connect(mapStateToProps)(ipcCamera);