fistTestAndFaceLoginChange

This commit is contained in:
shijing 2022-02-22 16:31:39 +08:00
parent 6b73a12840
commit ba3f2cd7b9
10 changed files with 752 additions and 24 deletions

View File

@ -105,6 +105,23 @@ export function createConvert(data) {
data
})
}
//首件检查表初始化
export function firstTestInit(id,data) {
return request({
url: `/pm/subproduction_plan/${id}/first_test_init/`,
method: 'post',
data
})
}
//首件检查责任人审核
export function firstAudit(id,data) {
return request({
url: `/pm/subproduction_plan/${id}/first_audit/`,
method: 'post',
data
})
}
//任务终止
export function planstop(id) {
return request({
@ -120,4 +137,4 @@ export function plantoggle(id) {
method: 'put',
})
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 813 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 KiB

View File

@ -239,13 +239,15 @@
let imag= this.formData.filter(item => {
return item.field_type === 'draw';
});
that.img = new Image();
that.img.crossOrigin = 'anonymous';
let value = imag[0].field_value?imag[0].field_value:imag[0].draw_template;
that.img = 'http://47.95.0.242:2222'+value;
setTimeout(function(){
that.canvasInit();
},500);
if(imag.length>0){
that.img = new Image();
that.img.crossOrigin = 'anonymous';
let value = imag[0].field_value?imag[0].field_value:imag[0].draw_template;
that.img = 'http://47.95.0.242:2222'+value;
setTimeout(function(){
that.canvasInit();
},500);
}
},
data(){
return{
@ -695,7 +697,7 @@
that.field = []; //检查项目
let submit = isSubmit=='1'?false:true;
that.formData.forEach((item) => {
let field_value = null;
let field_value;
if(item.field_type==='int'){
field_value = parseInt(that.checkForm[item.field_key])
}else if(item.field_type==='float'){

View File

@ -0,0 +1,173 @@
<template>
<div style="width: 600px;height: 500px;background: #000000;margin:50px auto 0 auto;">
<div style="margin-left: 100px;">
<div class="video-box">
<video id="video" width="400" height="500" preload autoplay loop muted></video>
<canvas id="canvas" width="400" height="500"></canvas>
</div>
<canvas id="screenshotCanvas" width="400" height="500"></canvas>
</div>
</div>
</template>
<script>
import tracking from '@/assets/tracking/build/tracking-min.js';
import {faceLogin} from "@/api/testModel";
import '@/assets/tracking/build/data/face-min.js';
import {createrecordform,updaterecordform} from "@/api/mtm";
export default {
props: {
dialogType: {
type:String,
default:"new"
},
recordform: {
type:Object,
default:null
}
},
data() {
return {
video: null,
screenshotCanvas: null,
uploadLock: false // 上传锁
}
},
mounted() {
this.openTheCamera();
},
methods: {
openTheCamera () {
this.$nextTick(function () {
let _this = this;
this.video = document.getElementById('video');
// 旧版本浏览器可能根本不支持mediaDevices我们首先设置一个空对象
if (navigator.mediaDevices === undefined) {
navigator.mediaDevices = {}
}
// 一些浏览器实现了部分mediaDevices我们不能只分配一个对象
// 使用getUserMedia因为它会覆盖现有的属性
// 这里如果缺少getUserMedia属性就添加它
if (navigator.mediaDevices.getUserMedia === undefined) {
navigator.mediaDevices.getUserMedia = function (constraints) {
// 首先获取现存的getUserMedia(如果存在)
let getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.getUserMedia;
// 有些浏览器不支持会返回错误信息
// 保持接口一致
if (!getUserMedia) {
return Promise.reject(new Error('getUserMedia is not implemented in this browser'))
}
// 否则使用Promise将调用包装到旧的navigator.getUserMedia
return new Promise(function (resolve, reject) {
getUserMedia.call(navigator, constraints, resolve, reject)
})
}
}
let constraints = { audio: false, video: { width: this.videoWidth, height: this.videoHeight, transform: 'scaleX(-1)' } };
navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {
// 旧的浏览器可能没有srcObject
if ('srcObject' in _this.video) {
_this.video.srcObject = stream
} else {
// 避免在新的浏览器中使用它因为它正在被弃用
_this.video.src = window.URL.createObjectURL(stream)
}
_this.video.onloadedmetadata = function (e) {
_this.video.play();
};
_this.init();
}).catch(err => {
console.log(err)
})
});
},
// 初始化设置
init() {
// this.video = document.getElementById('video');
this.screenshotCanvas = document.getElementById('screenshotCanvas');
let canvas = document.getElementById('canvas');
let context = canvas.getContext('2d');
// 实例化tracker对象
let tracker = new window.tracking.ObjectTracker('face');
tracker.setInitialScale(4);
tracker.setStepSize(2);
tracker.setEdgesDensity(0.1);
//tracker对象和标签关联
window.tracking.track('#video', tracker, {
camera: true
});
let _this = this;
//添加事件
tracker.on('track', function (event) {
// 检测出人脸 绘画人脸位置
context.clearRect(0, 0, canvas.width, canvas.height);
// 给每个人脸绘制对应的框
event.data.forEach(function (rect) {
context.strokeStyle = '#0764B7';
context.strokeRect(rect.x, rect.y, rect.width, rect.height);
// 避免重复发送请求
if(!_this.uploadLock){
_this.uploadLock = true;
// 上传图片
_this.screenshotAndUpload();
}
});
});
},
// 上传图片
screenshotAndUpload() {
let that = this;
// 绘制当前帧图片转换为base64格式
let canvas = this.screenshotCanvas;
let video = this.video;
let ctx = canvas.getContext('2d');
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
let base64Img = canvas.toDataURL('image/jpeg');
let img = base64Img.split(',')[1];
let imgData = {base64:img};
faceLogin(imgData).then((res) => {
if (res.code >= 200) {
that.$emit('func',res.data.access);
that.$message.success("身份认证成功!");
}else{
// 打开锁
that.uploadLock = false;
this.$message.error(res.msg);
}
}).catch(()=>{
// 打开锁
that.uploadLock = false;
// this.$message.error('面部识别失败请重新验证');
});
},
closeCamera () {
this.video.srcObject.getTracks()[0].stop();
},
}
}
</script>
<style scoped>
#screenshotCanvas {
display: none;
}
.video-box {
margin: auto;
position: relative;
width: 500px;
height: 500px;
background: #000000;
text-align: center;
}
video, canvas {
position: absolute;
top: 0;
left: 0;
}
</style>

View File

@ -1,11 +1,11 @@
<template>
<div style="width: 100%;height: 620px;">
<div>
<div style="width: 600px;height: 500px;background: #000000;margin:50px auto 0 auto;">
<div style="margin-left: 100px;">
<div class="video-box">
<video id="video" width="749" height="620" preload autoplay loop muted></video>
<canvas id="canvas" width="749" height="620"></canvas>
<video id="video" width="400" height="500" preload autoplay loop muted></video>
<canvas id="canvas" width="400" height="500"></canvas>
</div>
<canvas id="screenshotCanvas" width="749" height="620"></canvas>
<canvas id="screenshotCanvas" width="400" height="500"></canvas>
</div>
</div>
</template>

View File

@ -226,8 +226,7 @@ export const asyncRoutes = [
name: 'operation',
component: () => import('@/views/wpm/operation'),
meta: { title: '车间操作', icon: 'workshopOperation', perms: ['index_manage'] }
}
,
},
{
path: 'operationdo/:id',
name: 'operationdo',
@ -240,13 +239,18 @@ export const asyncRoutes = [
name: 'need',
component: () => import('@/views/wpm/need'),
meta: { title: '过程检验', icon: 'processTest', perms: ['index_manage'] }
}
,
},
{
path: 'productjy',
name: 'productjy',
component: () => import('@/views/wpm/productjy'),
meta: { title: '成品检验', icon: 'finishedCheck', perms: ['index_manage'] }
},
{
path: 'firstCheck',
name: 'firstCheck',
component: () => import('@/views/wpm/firstCheck'),
meta: { title: '首件确认', icon: 'finishedCheck', perms: ['index_manage'] }
}
]

View File

@ -20,7 +20,7 @@ service.interceptors.request.use(
// please modify it according to the actual situation
config.headers['Authorization'] = 'Bearer ' + getToken()
}
let data = config.params;
let data = config.data;
/*debugger;
console.log(data)*/
if(data){

View File

@ -1,8 +1,8 @@
<template>
<div class="login">
<div class="login-form" style="display: flex;justify-content: space-between">
<div style="width: 250px;border-right: 1px dashed #409EFF;">
<img src="./../../assets/face.png" style="margin-top: 65px;" @click="takePhoto()">
<div class="login-form">
<div class="faceLoginBtnWrap">
<img class="faceLoginBtn" src="./../../assets/face.png" @click="takePhoto()">
</div>
<div style="width: 360px;">
<h3 class="title">航玻生产管理系统</h3>
@ -245,7 +245,7 @@
justify-content: center;
align-items: center;
height: 100%;
background-image: url("../../assets/beijing.jpg");
background-image: url("../../assets/bg-login.png");
background-size: cover;
}
.title {
@ -263,6 +263,10 @@
background: #ffffff;
width: 700px;
padding: 25px;
display: flex;
justify-content: space-between;
box-shadow: 0 0 10px 5px #eeeeee;
.el-input {
height: 45px;
input {
@ -275,6 +279,15 @@
margin-left: 2px;
}
}
.faceLoginBtnWrap{
width: 250px;
border-right: 1px dashed #409EFF;
text-align: center;
}
.faceLoginBtn{
width: 150px;
margin-top: 90px;
}
#passwordInput{
padding-right: 35px;
}
@ -309,6 +322,6 @@
}
.testTracking{
width:100%;
height: 620px;
height: 500px;
}
</style>

View File

@ -0,0 +1,519 @@
<template>
<div class="app-container">
<el-card>
<div class="tabButtonWrap">
<div
v-for="(item,$index) in processOption"
:key="item.id"
class="tabButton"
:class="{activeTab:activeIndex===$index}"
@click="changeIndex(item,$index)"
>
{{item.name}}
</div>
</div>
<el-table
:data="subPlanList"
fit
style="width: 100%"
height="100"
stripe
border
v-el-height-adaptive-table="{bottomOffset: 50}"
>
<el-table-column type="index" width="50"/>
<el-table-column label="子计划编号" min-width="70px" show-overflow-tooltip>
<template slot-scope="scope">{{scope.row.number}}</template>
</el-table-column>
<el-table-column label="产品名称" min-width="120px" show-overflow-tooltip>
<template slot-scope="scope">{{ scope.row.product_.name }}</template>
</el-table-column>
<el-table-column label="产品型号">
<template slot-scope="scope">{{ scope.row.product_.specification }}</template>
</el-table-column>
<el-table-column label="子工序" min-width="120px" show-overflow-tooltip>
<template slot-scope="scope" v-if="scope.row.steps">
<el-tag v-for="item in scope.row.steps"
:key="item.number"
:label="item.name"
:value="item.number">{{item.name}}
</el-tag>
</template>
</el-table-column>
<el-table-column label="生产车间">
<template slot-scope="scope">{{ scope.row.workshop_.name }}</template>
</el-table-column>
<el-table-column label="生产数量" prop="count">
</el-table-column>
<el-table-column label="开工时间" prop="start_date">
</el-table-column>
<el-table-column label="完工时间" prop="end_date">
</el-table-column>
<el-table-column label="检验状态">
<template slot-scope="scope">
<span v-if="scope.row.leader_1!==null&&scope.row.leader_2!==null&&scope.row.leader_3!==null">已完成</span>
<span v-else>未完成</span>
</template>
</el-table-column>
<el-table-column
align="center"
label="操作"
width="120px"
fixed="right"
>
<template slot-scope="scope">
<el-link
v-if="scope.row.first_test===null"
type="primary"
@click="handleTest(scope)"
>
首件检验
</el-link>
<el-link
v-else-if="scope.row.first_test!==null&&!scope.row.first_test_.is_submited"
type="primary"
@click="handleTestContinue(scope)"
>
检验
</el-link>
<el-link
v-else-if="scope.row.first_test_.is_submited&&(scope.row.leader_1===null||scope.row.leader_2===null||scope.row.leader_3===null)"
type="primary"
@click="handleSelectclick(scope,'0')"
>
首件审批
</el-link>
<el-link
v-else-if="scope.row.leader_1!==null&&scope.row.leader_2!==null&&scope.row.leader_3!==null"
type="primary"
@click="handleSelectclick(scope,'1')"
>
查看
</el-link>
</template>
</el-table-column>
</el-table>
<pagination
:total="count"
:page.sync="listQuery.page"
:limit.sync="listQuery.page_size"
@pagination="getsList"
/>
</el-card>
<!--物料检查表&&-->
<el-dialog title="首件确认检查表" :close-on-click-modal="false" :visible.sync="listVisible">
<el-select style="width: 100%" v-model="recordForm" placeholder="请选择" @change="recordFormChange">
<el-option
v-for="item in recordFormList"
:key="item.name"
:label="item.name"
:value="item.id"
>
</el-option>
</el-select>
<div slot="footer" class="dialog-footer">
<el-button @click="listVisible = false">
</el-button>
<el-button type="primary" @click="selectedRecordForm()">填写检查项目</el-button>
</div>
</el-dialog>
<!--检查表显示-->
<el-dialog
width="60%"
:title="formName"
:visible.sync="recordVisible"
:close-on-click-modal="false"
@close="recordCancel"
>
<customForm
v-if="recordVisible"
:results="fieldList"
:hasPicture="hasPicture"
:formID="recordForm"
:wproduct="recordFormQuery.material"
:recordId="recordId"
:isDisabled="isDisabled"
:isMidTesting="is_midtesting"
@recordSubmit="recordSubmit"
@recordSave="recordSave"
@recordCancel="recordCancel"
/>
</el-dialog>
<!--已完成检查表查后的审核-->
<el-dialog
title="首件确认审核"
:visible.sync="reviewVisible"
:close-on-click-modal="false"
>
<el-row>
<el-col v-for="item in fieldList" :key="item.id+item.id" :span="12">
<div class="items" v-if="item.field_type!=='draw'&&item.field_value!==null&&item.field_value!==''">
<span class="itemLabel">{{item.field_name}}</span>
<span>{{item.field_value}}</span>
</div>
</el-col>
<el-col v-for="item in fieldList" :key="item.id" :span="24">
<div class="items" v-if="item.field_type==='draw'" style="height: 400px">
<span class="itemLabel">{{item.field_name}}</span>
<img style="width: 45%;vertical-align: text-top;" :src="'http://47.95.0.242:2222'+item.field_value"/>
</div>
</el-col>
</el-row>
<el-row class="reviewWrap" v-if="!achieve">
<div class="reviewBlock">
<span>工序负责人:</span>
<div class="directorName">{{leader_1}}</div>
<span class="reviewBtn" @click="directorConfirm('leader_1')">人脸验证</span>
</div>
<div class="reviewBlock">
<span>技术负责人:</span>
<div class="directorName">{{leader_2}}</div>
<span class="reviewBtn" @click="directorConfirm('leader_2')">人脸验证</span>
</div>
<div class="reviewBlock">
<span>总检:</span>
<div class="directorName">{{leader_3}}</div>
<span class="reviewBtn" @click="directorConfirm('leader_3')">人脸验证</span>
</div>
</el-row>
</el-dialog>
<el-dialog :visible.sync="limitedPhoto" @close="closeCamera" id="loginFaceWrap">
<div style="font-size: 28px;color: #333333;text-align: center;font-weight: bold;">审核人员确认</div>
<div class="testTracking">
<faceLogin v-if="limitedPhoto" ref="faceTracking" name="faceLogin" @func="getMsgFormSon"></faceLogin>
</div>
</el-dialog>
</div>
</template>
<script>
import checkPermission from "@/utils/permission";
import Pagination from "@/components/Pagination";
import customForm from '@/components/customForm/index';
import faceLogin from '@/components/faceLogin/review.vue';
import {getProcessList,getrecordformList} from "@/api/mtm";
import {getsubproductionplanList,firstTestInit,firstAudit} from "@/api/pm";
import {getTestRecordItem,putTestRecordItem,subTestRecordItem} from "@/api/qm";
export default {
name: "firstCheck",
components: {Pagination,faceLogin,customForm},
data() {
return {
count: 0,
activeIndex: 0,
fieldList: [],
subPlanList: [],
processOption: [],
recordFormList: [],
listQuery:{
page:1,
page_size:20,
process: null,
},
recordFormQuery:{
type:50,
enabled:true,
material:null
},
planId:null,
leader:null,
recordId: null,
leader_1: null,
leader_2: null,
leader_3: null,
recordForm:null,
achieve:false,
hasPicture:false,
isDisabled: false,
listLoading:false,
listVisible:false,
limitedPhoto:false,
reviewVisible:false,
recordVisible:false,
is_midtesting:false,
formName:'首件确认检查表',
}
},
methods: {
checkPermission,
//工序渲染
getProcessList() {
let that = this;
getProcessList({page: 0}).then((response) => {
if (response.data) {
that.processOption = response.data;
that.listQuery.process = response.data[0].id;
that.getTableData();
}
});
},
//工序转换
changeIndex(item,index) {
this.activeIndex = index;
this.listQuery.process = item.id;
this.getTableData();
},
//获取table数据
getTableData() {
this.listLoading = true;
this.listQuery.production_plan = this.id;
getsubproductionplanList(this.listQuery).then((response) => {
if (response.data) {
this.subPlanList = response.data.results;
this.count = response.data.count;
}
this.listLoading = false;
});
},
//分页
getsList(){},
//第一次点击首件检验
handleTest(scope){
let that = this;
that.planId = scope.row.id;//子生产计划ID
that.recordFormQuery.material = scope.row.product;
that.recordForm = null;
getrecordformList(that.recordFormQuery).then((response) => {
if (response.data) {
that.recordformList = response.data.results;
if (that.recordformList.length === 1) {
that.recordForm = that.recordformList[0].id;
that.formName = that.recordformList[0].name;
that.selectedRecordForm();
} else {
//弹出列表选择框
that.listVisible = true;
}
}
});
},
//首件审批
handleSelectclick(scope,index){
let that = this;
this.reviewVisible = true;
that.planId = scope.row.id;
that.leader_1 = scope.row.leader_1_?scope.row.leader_1_.name:null;
that.leader_2 = scope.row.leader_2_?scope.row.leader_2_.name:null;
that.leader_3 = scope.row.leader_3_?scope.row.leader_3_.name:null;
getTestRecordItem(scope.row.first_test).then((res) => {
that.formName = res.data.form_.name;
let fieldList = res.data.record_data;
that.fieldList = [...fieldList];
let arr = fieldList.filter(item => {
return item.field_type === 'draw'
});
if (arr.length > 0) {
that.hasPicture = true;
}
that.$nextTick(() => {
if(index==='1'){
this.achieve = true;
}else{
this.achieve = false;
}
that.reviewVisible = true;
});
})
},
//选择物料检查表
recordFormChange() {
let that = this;
let arr = this.recordFormList.filter(item => {
return item.id === that.recordForm;
});
that.formName = arr[0].name;
},
//根据选择的表渲染检查项目
selectedRecordForm() {
let that = this;
this.listVisible = false;
that.fieldList = [];
if (that.recordForm != "") {
firstTestInit(that.planId,{ form: that.recordForm}).then((response) => {
if (response.code===200) {
that.hasPicture = false;
that.recordId = response.data.id;//记录id
that.formName = response.data.form_.name;//引用的检查表id
let fieldList = response.data.record_data;
that.fieldList = [...fieldList];
let arr = fieldList.filter(item => {
return item.field_type === 'draw'
});
if (arr.length > 0) {
that.hasPicture = true;
}
that.$nextTick(() => {
that.recordVisible = true;
});
}
});
} else this.$message.error("请选择检查表!");
},
//第一次保存提交检查项目
recordCancel() {
this.recordVisible = false;
this.listVisible = false;
this.getTableData();
},
/*关闭相机*/
closeCamera () {
this.$refs.faceTracking.closeCamera();
// this.thisVideo.srcObject.getTracks()[0].stop();
},
//保存首件检查
recordSave(value) {
let that = this;
let id = value.id;
let params = {};
params.record_data = value.record_data;
params.is_testok = value.is_testok;
putTestRecordItem(id, params).then((res) => {
if (res.code >= 200) {
that.recordVisible = false;
that.getTableData();
} else {
this.$message.error(res.msg)
}
}).catch((err) => {
console.error(err);
});
},
//提交首件检查
recordSubmit(value) {
let that = this;
let id = value.id;
let params = {};
params.record_data = value.record_data;
params.is_testok = value.is_testok;
putTestRecordItem(id, params).then((res) => {
if (res.code >= 200) {
subTestRecordItem(id, params).then((res) => {
if (res.code >= 200) {
that.recordVisible = false;
that.getTableData();
}
});
} else {
this.$message.error(res.msg)
}
}).catch((err) => {
console.error(err);
});
},
//再次点击首件检验
handleTestContinue(scope) {
let that = this;
that.fieldList = [];
that.recordVisible = false;
that.planId = scope.row.id;
that.recordId = scope.row.first_test;
that.recordForm = scope.row.first_test_.form;
getTestRecordItem(scope.row.first_test).then((res) => {
that.formName = res.data.form_.name;
let fieldList = res.data.record_data;
that.fieldList = [...fieldList];
let arr = fieldList.filter(item => {
return item.field_type === 'draw'
});
if (arr.length > 0) {
that.hasPicture = true;
}
that.$nextTick(() => {
that.recordVisible = true;
});
})
/*getrffieldList({form: this.recordform,enabled:true, page: 1, page_size: 100}).then((response) => {
if (response.data) {
that.hasPicture = false;
let fieldList = response.data.results;
that.fieldList = [...fieldList];
let arr = fieldList.filter(item => {
return item.field_type === 'draw'
});
if (arr.length > 0) {
that.hasPicture = true;
}
}
});*/
},
//点击人脸验证
directorConfirm(index){
this.leader = index;
this.limitedPhoto = true;
},
//获取人脸数据
getMsgFormSon(data){
let that =this;
firstAudit(that.planId,{leader:that.leader ,token : data}).then(res=>{
if(res.code===200){
this.limitedPhoto = false;
}
})
},
},
mounted() {
this.getProcessList();
}
}
</script>
<style scoped>
.tabButtonWrap{
display: flex;
margin-bottom: 2px;
border-bottom: 1px solid #EBEEF5;
}
.tabButton{
height: 40px;
width: 100px;
color: #555555;
line-height: 40px;
text-align: center;
border: 1px solid #EBEEF5;
border-radius: 10px 10px 0 0;
}
.activeTab {
color: #FFFFFF;
font-weight: bold;
background: #409EFF;
}
.reviewWrap{
display: flex;
font-size: 16px;
justify-content: flex-end;
}
.reviewBlock{
display: flex;
flex-direction: column;
margin-right: 40px
}
.directorName{
height: 30px;
}
.reviewBtn{
width: 80px;
height: 35px;
font-size: 15px;
line-height: 33px;
text-align: center;
border: 1px solid #409eff;
border-radius: 5px;
/*background: #409eff;*/
color: #409eff;
}
.items {
height: 35px;
line-height: 35px;
padding-left: 20px;
}
.itemLabel {
font-size: 14px;
color: #606266;
font-weight: 600;
}
</style>