From 7555ef9dba69f025476be0062ce8d55b61fd821d Mon Sep 17 00:00:00 2001 From: shijing Date: Mon, 6 Dec 2021 13:18:20 +0800 Subject: [PATCH] needCheckForm --- hb_client/src/components/customForm/index.vue | 181 +++- hb_client/src/views/wpm/need.vue | 866 ++++++++---------- 2 files changed, 530 insertions(+), 517 deletions(-) diff --git a/hb_client/src/components/customForm/index.vue b/hb_client/src/components/customForm/index.vue index 7fcfd50..416696f 100644 --- a/hb_client/src/components/customForm/index.vue +++ b/hb_client/src/components/customForm/index.vue @@ -19,7 +19,7 @@ @@ -68,7 +68,7 @@ placeholder="选择日期" value-format="yyyy-MM-dd HH:mm:ss" style="width: 100%" - @change="keyChange(item.field_key)" + @change="keyChange($index,item.field_key)" /> @@ -80,7 +80,7 @@ v-model="checkForm[item.field_key]" style="width: 100%" placeholder="请选择" - @change="keyChange(item.field_key)" + @change="keyChange($index,item.field_key)" > @@ -135,11 +137,22 @@ -
- - 合格验证 - -
+ + + + + 检查合格 + 检查不合格 + + + + @@ -159,6 +172,10 @@ type:Number, default:0 }, + wproduct: { + type:Number, + default:0 + }, hasPicture:{ type:Boolean, default:false @@ -167,24 +184,28 @@ mounted() { let that = this; this.form = this.formID; - // debugger; - // console.log(this.results); - this.formData=this.results; - this.formData=[...this.formData]; + let formData=this.results; + that.wproductId=this.wproduct; + formData.forEach(item => { + let obj = new Object(); + obj = item; + obj.is_testok = true;//是否合格 + that.formData.push(obj) + }); + that.formData=[...that.formData]; + for(let i=0;i { return item.need_judge === true; }); listJudge.forEach(item => { let obj = new Object(); obj = item; - obj.judge = false; that.judgeList.push(obj) }); setTimeout(function(){ @@ -193,8 +214,16 @@ }, data(){ return{ + field:[], checkForm:{}, + testrecord:{ + form:this.formID, + record_data:[], + is_testok:true, + wproduct:null, + }, canvas:null, + wproductId:null, ctx:null, myCanvas_rect:null, Txt:null, @@ -207,6 +236,9 @@ canvasImg:'', formData:[],//表单数组 judgeList:[],//判定数组 + is_testok:true, + testokTrue:true, + testokFalse:false, } }, methods:{ @@ -276,15 +308,63 @@ return true; } }, - keyChange(key){ - key; - this.$forceUpdate(); - /* debugger; - let y = this.checkForm[key]; - this.$set(this.checkForm,key,y);*/ - // this.filterBlock(); + keyChange(index,key){ + let that = this; + let reg = /\{(.+?)\}/g; + that.$forceUpdate(); + that.$nextTick(()=>{ + if(that.formData[index].need_judge===true){ + let arr = [],str = ''; + let item = that.formData[index].rule_expression.replace(/`/g,''); + if(item.indexOf('||')>-1){ + arr = item.split('||'); + }else if(item.indexOf('&&')>-1){ + arr = item.split('&&'); + }else{ + arr.push(item); + } + //对每个条件进行判定,如果符合, + for (let i = 0;i-1){ + if(str.indexOf('false')>-1){ + that.formData[index].is_testok = true; + }else{ + that.formData[index].is_testok = false; + } + }else{ + if(str.indexOf('true')>-1){ + that.formData[index].is_testok = false; + }else{ + that.formData[index].is_testok = true; + } + } + }else{ + that.formData[index].is_testok = true; + } + that.judgeList = that.formData.filter(item => { + return item.need_judge === true; + }); + that.judgeForm(); + }) }, - /* base64ToFile */ + /* 图片保存 */ + //初始化canvas canvasInit(){ let that = this; preDrawAry = []; @@ -299,6 +379,7 @@ that.draw(); },500); }, + //画布添加背景模板图 draw(){ let canvasImg = document.getElementById("canvasImg"); canvasImg.style.width = '500px'; @@ -360,7 +441,6 @@ } } }, - // 文字 word1(){ let canvas3 = document.getElementById('canvas'); @@ -462,6 +542,7 @@ // console.log(res); }) }, + //base64ToFile base64ToFile(baseUrl) { let arr = baseUrl.split(','); // let type = arr[0].match(/:(.*?);/)[1]; // 解锁图片类型 @@ -474,7 +555,8 @@ // let fileOfBlob = new File([bufferArray], new Date()+'.jpg'); return new File([bufferArray ],'draw.jpg'); }, - /* base64ToFile */ + /* 图片保存 */ + //最终表格判定 judgeForm(){ let that = this , reg = /\{(.+?)\}/g, @@ -508,21 +590,56 @@ } } } - if(str.indexOf('true')>-1){ - that.judgeList[i].judge = true; + if(item.indexOf('&&')>-1){ + if(str.indexOf('false')>-1){ + that.judgeList[i].is_testok = true; + }else{ + that.judgeList[i].is_testok = false; + } }else{ - that.judgeList[i].judge = false; + if(str.indexOf('true')>-1){ + that.judgeList[i].is_testok = false; + }else{ + that.judgeList[i].is_testok = true; + } } } let real = that.judgeList.filter(item=>{ - return item.judge==true; + return item.is_testok===false; }); if(real.length>0){ + that.is_testok = false; alert("检验不合格!") }else{ + that.is_testok = true; alert("检验合格!") } }, + //提交检查项目 + submitfield() { + let that = this; + debugger; + console.log(that.checkForm); + debugger; + that.field = []; //检查项目 + that.formData.forEach((item) => { + debugger; + console.log(that.checkForm[item.field_key]); + debugger; + that.field.push({ + form_field: item.id, + field_value: that.checkForm[item.field_key], + is_testok: item.is_testok//单项检查结果 + }); + }); + console.log(that.field); + debugger; + that.testrecord.form = that.formID;//检查表 + that.testrecord.record_data = that.field;//检查项列表 + that.testrecord.is_testok = that.is_testok;//检查表检查结果 + that.testrecord.wproduct = that.wproductId;//半成品ID + this.$emit('formFunc',that.testrecord); + }, } } diff --git a/hb_client/src/views/wpm/need.vue b/hb_client/src/views/wpm/need.vue index 37be5ee..c0764b2 100644 --- a/hb_client/src/views/wpm/need.vue +++ b/hb_client/src/views/wpm/need.vue @@ -1,152 +1,155 @@