Commit bf990ba7ddb6fb666c2a5447a6d0c770cd4bee39
1 parent
76ee774c
人脸采集
Showing
1 changed file
with
42 additions
and
30 deletions
src/components/FaceDetect/index.js
| ... | ... | @@ -75,12 +75,12 @@ class FaceDetect extends Component { |
| 75 | 75 | } |
| 76 | 76 | //登录认证 |
| 77 | 77 | getMedia = () => { |
| 78 | - this.setState({thumbImg: ''}); | |
| 79 | - this.checkParams=[]; | |
| 78 | + this.setState({ thumbImg: '' }); | |
| 79 | + this.checkParams = []; | |
| 80 | 80 | const _this = this; |
| 81 | 81 | return new Promise((resolve, reject) => { |
| 82 | 82 | _this.video = document.getElementById("video"); |
| 83 | - let constraints = {video: true}; | |
| 83 | + let constraints = { video: true }; | |
| 84 | 84 | navigator.mediaDevices.getUserMedia(constraints) |
| 85 | 85 | .then((stream) => { |
| 86 | 86 | if ("srcObject" in this.video) { |
| ... | ... | @@ -121,9 +121,9 @@ class FaceDetect extends Component { |
| 121 | 121 | _this.stopMedia(); |
| 122 | 122 | return; |
| 123 | 123 | } |
| 124 | - if (dataReturn.data.code < 0 ) { | |
| 124 | + if (dataReturn.data.code < 0) { | |
| 125 | 125 | _this.changePercentStatus('exception'); |
| 126 | - _this.changeStatusContent('人脸验证失败,请重新识别:'+dataReturn.data.msg); | |
| 126 | + _this.changeStatusContent('人脸验证失败,请重新识别:' + dataReturn.data.msg); | |
| 127 | 127 | //message.error('人脸验证失败!请重新识别'+dataReturn.data.msg); |
| 128 | 128 | _this.stopMedia(); |
| 129 | 129 | reject(); |
| ... | ... | @@ -133,7 +133,7 @@ class FaceDetect extends Component { |
| 133 | 133 | _this.changeCurrentPercent(100); |
| 134 | 134 | resolve(); |
| 135 | 135 | } |
| 136 | - _this.checkParams= []; | |
| 136 | + _this.checkParams = []; | |
| 137 | 137 | } |
| 138 | 138 | }, 200); |
| 139 | 139 | }) |
| ... | ... | @@ -148,12 +148,12 @@ class FaceDetect extends Component { |
| 148 | 148 | |
| 149 | 149 | //人脸采集 |
| 150 | 150 | getMediaAddFace = () => { |
| 151 | - this.setState({thumbImg: ''}); | |
| 152 | - this.checkParams=[]; | |
| 151 | + this.setState({ thumbImg: '' }); | |
| 152 | + this.checkParams = []; | |
| 153 | 153 | const _this = this; |
| 154 | 154 | return new Promise((resolve, reject) => { |
| 155 | 155 | _this.video = document.getElementById("video"); |
| 156 | - let constraints = {video: true}; | |
| 156 | + let constraints = { video: true }; | |
| 157 | 157 | navigator.mediaDevices.getUserMedia(constraints) |
| 158 | 158 | .then((stream) => { |
| 159 | 159 | if ("srcObject" in this.video) { |
| ... | ... | @@ -195,9 +195,9 @@ class FaceDetect extends Component { |
| 195 | 195 | _this.stopMedia(); |
| 196 | 196 | return; |
| 197 | 197 | } |
| 198 | - if (dataReturn.data.code < 0 ) { | |
| 198 | + if (dataReturn.data.code < 0) { | |
| 199 | 199 | _this.changePercentStatus('exception'); |
| 200 | - _this.changeStatusContent('人脸采集失败:'+dataReturn.data.msg); | |
| 200 | + _this.changeStatusContent('人脸采集失败:' + dataReturn.data.msg); | |
| 201 | 201 | // message.error('人脸采集失败!请重新采集'+dataReturn.data.msg); |
| 202 | 202 | _this.stopMedia(); |
| 203 | 203 | reject(); |
| ... | ... | @@ -207,17 +207,29 @@ class FaceDetect extends Component { |
| 207 | 207 | let userinfo = this.props.app.userinfo; |
| 208 | 208 | const sBrandId = userinfo?.sBrandsId; |
| 209 | 209 | const sSubsidiaryId = userinfo?.sSubsidiaryId; |
| 210 | - if(this.props.bClickSource?.includes('BtnAddFace') ){ | |
| 210 | + if (this.props.bClickSource?.includes('BtnAddFace')) { | |
| 211 | 211 | userinfo = { |
| 212 | 212 | sUserName: this.props.masterData?.sEmployeeName, |
| 213 | 213 | sEmployeeNo: this.props.masterData?.sEmployeeNo, |
| 214 | - sEmployeeId : this.props.masterData?.sEmployeeId, | |
| 215 | - sDepartName: this.props.masterData?.sDepartName, | |
| 216 | - sId :this.props.masterData?.sId | |
| 214 | + sEmployeeId: this.props.masterData?.sEmployeeId, | |
| 215 | + sDepartName: this.props.masterData?.sDepartName, | |
| 216 | + sId: this.props.masterData?.sId | |
| 217 | + } | |
| 218 | + } | |
| 219 | + if (this.props?.app?.currentPane?.route?.includes('/indexPage/commonClassify')) { | |
| 220 | + if (!this.props?.slaveSelectedRowKeys?.length) { | |
| 221 | + message.warning('请先选择人员!'); | |
| 222 | + return | |
| 223 | + } | |
| 224 | + const rowData = this.props?.slaveData?.find(x => x.sId === this.props.slaveSelectedRowKeys[0]) | |
| 225 | + userinfo = { | |
| 226 | + sUserName: rowData?.sEmployeeName, | |
| 227 | + sEmployeeNo:rowData?.sEmployeeNo, | |
| 228 | + sEmployeeId: rowData?.sEmployeeId, | |
| 229 | + sDepartName: rowData?.sDepartName, | |
| 230 | + sId: rowData?.sId | |
| 217 | 231 | } |
| 218 | - console.log('userinfo', userinfo); | |
| 219 | 232 | } |
| 220 | - | |
| 221 | 233 | let item = { |
| 222 | 234 | "image": img.split(',')[1], |
| 223 | 235 | "image_type": "BASE64", |
| ... | ... | @@ -237,16 +249,16 @@ class FaceDetect extends Component { |
| 237 | 249 | const url = this.urlpre + `/face/faceAdd`; |
| 238 | 250 | _this.changeStatusContent('人脸数据处理中,请稍等'); |
| 239 | 251 | const dataReturn = await commonServices.postValueService(null, item, url); |
| 240 | - if (dataReturn.data.code > 0 ) { | |
| 252 | + if (dataReturn.data.code > 0) { | |
| 241 | 253 | _this.changeStatusContent('人脸数据处理成功'); |
| 242 | 254 | _this.props.onSaveFaceSuccess && _this.props.onSaveFaceSuccess(dataReturn); |
| 243 | - }else{ | |
| 244 | - _this.changeStatusContent('人脸数据处理失败,'+dataReturn.data.msg+'请重新采集'); | |
| 255 | + } else { | |
| 256 | + _this.changeStatusContent('人脸数据处理失败,' + dataReturn.data.msg + '请重新采集'); | |
| 245 | 257 | } |
| 246 | 258 | _this.changeCurrentPercent(100); |
| 247 | 259 | resolve(); |
| 248 | 260 | } |
| 249 | - _this.checkParams= []; | |
| 261 | + _this.checkParams = []; | |
| 250 | 262 | } |
| 251 | 263 | }, 200); |
| 252 | 264 | }) |
| ... | ... | @@ -261,7 +273,7 @@ class FaceDetect extends Component { |
| 261 | 273 | saveFace = () => { |
| 262 | 274 | const _this = this; |
| 263 | 275 | const userinfo = this.props.app.userinfo; |
| 264 | - if(undefined === userinfo.sEmployeeId || userinfo.sEmployeeId === '' ){ | |
| 276 | + if (undefined === userinfo.sEmployeeId || userinfo.sEmployeeId === '') { | |
| 265 | 277 | _this.changeStatusContent('您没有采集权限,请联系管理员,将您绑定成员工。'); |
| 266 | 278 | message.error('您没有采集权限,请联系管理员,将您绑定成员工。'); |
| 267 | 279 | return; |
| ... | ... | @@ -313,18 +325,18 @@ class FaceDetect extends Component { |
| 313 | 325 | let limit = 5; |
| 314 | 326 | let check = 0; |
| 315 | 327 | async function handleDetectFace() { |
| 316 | - for (let i = 0; i < limit; i ++) { | |
| 317 | - check ++; | |
| 328 | + for (let i = 0; i < limit; i++) { | |
| 329 | + check++; | |
| 318 | 330 | let img = _this.getFace(); |
| 319 | 331 | let item = { |
| 320 | 332 | "image": img.split(',')[1], |
| 321 | 333 | "image_type": "BASE64", |
| 322 | 334 | "face_field": "faceshape,facetype,feature" |
| 323 | 335 | } |
| 324 | - const url = this.urlpre +`/face/faceSearch`; | |
| 336 | + const url = this.urlpre + `/face/faceSearch`; | |
| 325 | 337 | const dataReturn = await commonServices.postValueService(null, item, url); |
| 326 | 338 | if (dataReturn.data.code === 1) { |
| 327 | - _this.setState({thumbImg: _this.getFace()}) | |
| 339 | + _this.setState({ thumbImg: _this.getFace() }) | |
| 328 | 340 | _this.changeStatusContent('人脸验证成功'); |
| 329 | 341 | _this.stopMedia(); |
| 330 | 342 | _this.props.onDetectSuccess && _this.props.onDetectSuccess(dataReturn.data); |
| ... | ... | @@ -343,7 +355,7 @@ class FaceDetect extends Component { |
| 343 | 355 | const stream = this.video.srcObject; |
| 344 | 356 | if (stream) { |
| 345 | 357 | const tracks = stream.getTracks(); |
| 346 | - tracks.forEach(function(track) { | |
| 358 | + tracks.forEach(function (track) { | |
| 347 | 359 | track.stop(); |
| 348 | 360 | }); |
| 349 | 361 | this.video.srcObject = null; |
| ... | ... | @@ -369,10 +381,10 @@ class FaceDetect extends Component { |
| 369 | 381 | "quality_control": "NORMAL", |
| 370 | 382 | "liveness_control": "NORMAL" |
| 371 | 383 | } |
| 372 | - const url = this.urlpre +`/face/faceSearch`; | |
| 384 | + const url = this.urlpre + `/face/faceSearch`; | |
| 373 | 385 | const dataReturn = await commonServices.postValueService(null, item, url); |
| 374 | 386 | if (dataReturn && dataReturn.data && dataReturn.data.code === 1) { |
| 375 | - _this.setState({thumbImg: _this.getFace()}) | |
| 387 | + _this.setState({ thumbImg: _this.getFace() }) | |
| 376 | 388 | _this.changeStatusContent('人脸验证成功'); |
| 377 | 389 | _this.stopMedia(); |
| 378 | 390 | _this.props.onIdentifySuccess && _this.props.onIdentifySuccess(dataReturn.data); |
| ... | ... | @@ -424,7 +436,7 @@ class FaceDetect extends Component { |
| 424 | 436 | } |
| 425 | 437 | |
| 426 | 438 | render() { |
| 427 | - const enable = ((this.props.enabled && this.user_id !== '' )|| this.props.actionType === 'identifyFace'); | |
| 439 | + const enable = ((this.props.enabled && this.user_id !== '') || this.props.actionType === 'identifyFace'); | |
| 428 | 440 | const faceCollection = commonFunc.showLocalMessage(this.props, 'faceCollection', '人脸采集'); |
| 429 | 441 | return ( |
| 430 | 442 | <> | ... | ... |