Merge branch 'develop' of https://e.coding.net/ctcdevteam/hberp/hberp into develop

This commit is contained in:
caoqianming 2021-12-10 13:43:17 +08:00
commit b76b32665a
5 changed files with 160 additions and 321 deletions

View File

@ -47,4 +47,13 @@ export default {
.bigDialog .el-dialog{
width: 70%!important;
}
.fail input.el-input__inner{
border: 1px solid #ff0000!important;
}
.adopt input.el-input__inner{
border: 1px solid #46ce7a!important;
}
#customerForm .el-form-item{
margin-bottom: 30px!important;
}
</style>

View File

@ -288,5 +288,14 @@ export function recordInit(id) {
})
}
//半产品复检
export function wproductReview(data) {
return request({
url: '/wpm/wproduct/test_init/',
method: 'post',
data
})
}

View File

@ -1,8 +1,9 @@
<template>
<div>
<el-form
<el-form
id="customerForm"
ref="checkForm"
label-width="100px"
label-width="100px"
:model="checkForm"
>
<el-row>
@ -11,6 +12,8 @@
v-show="filterBlock(item.parent,item.display_expression)"
:key="$index"
:span="12"
style="position: relative"
:class="item.need_judge&&item.is_testok===true?'adopt':item.need_judge&&item.is_testok===false?'fail':''"
>
<el-form-item
v-if="item.field_type === 'string'"
@ -112,6 +115,9 @@
</el-option>
</el-select>
</el-form-item>
<span v-show="item.help_text" class="helpText">说明{{item.help_text}}</span>
<span v-if="item.need_judge&&item.is_testok===true" class="adoptTip">合格</span>
<span v-if="item.need_judge&&item.is_testok===false" class="failTip">不合格</span>
</el-col>
</el-row>
<el-row v-show="hasPicture">
@ -130,7 +136,7 @@
<div class="canvasBtn" @click="error1">标记</div>
<div class="canvasBtn" @click="word1()">文字</div>
<div class="canvasBtn" @click="back()">回退</div>
<div class="canvasBtn" @click="saveTu()">保存</div>
<!--<div class="canvasBtn" @click="saveTu()">保存</div>-->
</div>
<div id="res"></div>
</div>
@ -168,6 +174,10 @@
default: () => {
return []
}} ,
step: {
type:String,
default:''
},
formID: {
type:Number,
default:0
@ -185,11 +195,12 @@
let that = this;
this.form = this.formID;
let formData=this.results;
this.checkType=this.step;
that.wproductId=this.wproduct;
formData.forEach(item => {
let obj = new Object();
obj = item;
obj.is_testok = true;//是否合格
obj.is_testok = null;//是否合格
that.formData.push(obj)
});
that.formData=[...that.formData];
@ -232,8 +243,10 @@
heights:0,
lineW:3,
colorF:"#e42343",
imgUrl:'',
imgData:'',
canvasImg:'',
checkType:'',
formData:[],//表单数组
judgeList:[],//判定数组
is_testok:true,
@ -344,19 +357,23 @@
if(item.indexOf('&&')>-1){
if(str.indexOf('false')>-1){
that.formData[index].is_testok = true;
that.$set(that.formData[index],'is_testok',true)
}else{
that.formData[index].is_testok = false;
that.$set(that.formData[index],'is_testok',false)
}
}else{
if(str.indexOf('true')>-1){
that.formData[index].is_testok = false;
that.$set(that.formData[index],'is_testok',false)
}else{
that.formData[index].is_testok = true;
that.$set(that.formData[index],'is_testok',true)
}
}
}else{
that.formData[index].is_testok = true;
that.$forceUpdate();
}
that.$forceUpdate();
that.judgeList = that.formData.filter(item => {
return item.need_judge === true;
});
@ -528,6 +545,7 @@
},
//保存
saveTu(){
let that = this;
this.word.style.display="none";
this.Txt.style.display="none";
let canvas = document.getElementById('canvas');
@ -538,7 +556,9 @@
let formData = new FormData();
formData.append('file', file);
upFile(formData).then((res) => {
res;
debugger;
console.log(res);
that.imgUrl=res.data.field;
// console.log(res);
})
},
@ -618,22 +638,41 @@
//提交检查项目
submitfield() {
let that = this;
debugger;
console.log(that.checkForm);
debugger;
let drawArr = that.formData.filter(item=>{
return item.field_type==='draw';
});
if(drawArr.length>0){
that.word.style.display="none";
that.Txt.style.display="none";
let canvas = document.getElementById('canvas');
let image = new Image();
image = canvas.toDataURL('image/png');
that.canvasImg = image;
let file = that.base64ToFile(image);
let formData = new FormData();
formData.append('file', file);
upFile(formData).then((res) => {
if(res){
let key = drawArr[0].field_key;
that.imgUrl=res.data.file;
that.checkForm[key] = that.imgUrl;
that.fieldData();
}
});
}else{
that.fieldData();
}
},
fieldData(){
let that = this;
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;//检查表检查结果
@ -708,4 +747,23 @@
#res {
display: inline-block;
}
.helpText{
position: absolute;
top: 40px;
left: 100px;
}
.adoptTip{
position: absolute;
top: 38px;
right: 0;
font-size: 12px;
color: #46ce7a;
}
.failTip{
position: absolute;
top: 38px;
right: 0;
font-size: 12px;
color: #ff0000;
}
</style>

View File

@ -405,6 +405,9 @@
<el-form-item label="字段父级">
<treeselect v-model="field.parent" :multiple="false" :options="treeDate" placeholder="字段父级"/>
</el-form-item>
<el-form-item label="字段说明">
<el-input v-model="field.help_text" placeholder="字段名称"/>
</el-form-item>
<el-form-item label="是否需要判定" prop="need_judge">
<el-switch v-model="field.need_judge"></el-switch>
</el-form-item>
@ -500,14 +503,12 @@
</el-form-item>
</el-form>
<div style="text-align: right">
<el-button type="danger" @click="dialogVisible1 = false"
>取消
</el-button
>
<el-button type="primary" @click="fieldconfirm('Form')"
>确认
</el-button
>
<el-button type="danger" @click="dialogVisible1 = false">
取消
</el-button>
<el-button type="primary" @click="fieldconfirm('Form')">
确认
</el-button>
</div>
</el-dialog>
</el-card>
@ -568,6 +569,7 @@
field_name: "",
sort: "",
parent: "",
help_text: "",
draw_template: "",//图片模板
field_choice: [""],
},
@ -829,22 +831,7 @@
});
that.fieldLists();
},
/*canvasInit() {
let that = this;
preDrawAry = [];
that.canvas = document.getElementById('canvas');
that.ctx = that.canvas.getContext('2d');
that.myCanvas_rect = that.canvas.getBoundingClientRect();
that.Txt = document.getElementById('txt');
that.word = document.getElementById('word');
that.widths = that.myCanvas_rect.width;
that.heights = that.myCanvas_rect.height;
setTimeout(function () {
that.draw();
}, 500);
},*/
checkPermission,
handleCurrentChange(row) {
this.formID = row.id;
this.fieldLists();
@ -884,252 +871,6 @@
}
});
},
/*draw() {
let canvasImg = document.getElementById("canvasImg");
canvasImg.style.width = '300px';
canvasImg.style.height = '200px';
this.ctx.drawImage(canvasImg, 0, 0, 300, 200);
},
// 叉号
error1() {
let canvas1 = document.getElementById('canvas');
let ctx1 = canvas1.getContext('2d');
this.Txt.style.display = "none";
document.getElementById('word').style.display = "none";
ctx1.closePath();
canvas1.onmousedown = function () {
this.imgData = ctx1.getImageData(0, 0, canvas1.width, canvas1.height);
preDrawAry.push(this.imgData);
ctx1.beginPath();
ctx1.strokeStyle = "#e42343";
ctx1.lineWidth = "3";
ctx1.lineJoin = "round";
};
//鼠标按下的位置
canvas1.onmouseup = function (ev) {
let oldX = ev.offsetX;
let oldY = ev.offsetY;
ctx1.moveTo(oldX, oldY);
ctx1.lineTo(ev.offsetX + 10, ev.offsetY + 10);
ctx1.moveTo(ev.offsetX + 10, ev.offsetY);
ctx1.lineTo(ev.offsetX, ev.offsetY + 10);
ctx1.stroke();
};
this.ctx.closePath();
},
// 文字先写字
text() {
let canvas2 = document.getElementById('canvas');
let ctx2 = canvas2.getContext('2d');
let Txt2 = document.getElementById('txt');
Txt2.style.display = "block";
document.getElementById('word').style.display = "none";
ctx2.font = "16px Microsoft Yahei";
canvas2.onmousedown = function (ev) {
this.imgData = ctx2.getImageData(0, 0, canvas2.width, canvas2.height);
preDrawAry.push(this.imgData);
var v = Txt2.value;
// console.log(v);
if (v != '') {
var oldX = ev.offsetX;
var oldY = ev.offsetY;
// console.log(oldX,oldY);
ctx2.moveTo(oldX, oldY);
canvas2.onmouseup = function () {
ctx2.fillStyle = this.colorF;
ctx2.fillText(v, oldX, oldY);
canvas2.TextAutoLine(v, canvas2, oldX, oldY, 20);
// Txt.value = "";
Txt2.style.display = "none";
}
}
}
},
// 文字
word1() {
let canvas3 = document.getElementById('canvas');
let ctx3 = canvas3.getContext('2d');
let Txt3 = document.getElementById('txt');
let word3 = document.getElementById('word');
Txt3.style.display = "none";
ctx3.font = "16px Microsoft Yahei";
canvas3.onmousedown = function () {
ctx3.closePath();
}
canvas3.onmouseup = function (ev) {
var inputV = document.getElementById('inputV').value;
if (inputV == 1) {
document.getElementById('word').focus();
// console.log(ev.offsetX,ev.offsetY);
var oldX = ev.offsetX;
var oldY = ev.offsetY;
word3.style.display = "block";
word3.style.left = oldX + 'px';
word3.style.top = oldY + 'px';
word3.onblur = function () {
let v = word3.value;
if (v != '' && v != ' ') {
this.imgData = ctx3.getImageData(0, 0, canvas3.width, canvas3.height);
let img = ctx3.getImageData(0, 0, canvas3.width, canvas3.height);
debugger;
preDrawAry.push(img);
ctx3.moveTo(oldX, oldY);
ctx3.fillStyle = "#e42343";
let lineWidth = 0;
let canvasWidth = canvas3.width;
let lastSubStrIndex = 0;
for (let i = 0; i < v.length; i++) {
lineWidth += ctx3.measureText(v[i]).width;
if (lineWidth > canvasWidth - oldX) {
ctx3.fillText(v.substring(lastSubStrIndex, i), oldX, (oldY + 10));
oldY += 20;
lineWidth = 0;
lastSubStrIndex = i;
}
if (i == v.length - 1) {
ctx3.fillText(v.substring(lastSubStrIndex, i + 1), oldX, (oldY + 10));
}
}
inputV = "2";
word3.value = "";
}
}
}
}
},
// 文字过长超出换行toDataURL()
canvasTextAutoLine(str, canvas, initX, initY, lineHeight) {
let ctx = canvas.getContext("2d");
let lineWidth = 0;
let canvasWidth = canvas.width;
let lastSubStrIndex = 0;
for (let i = 0; i < str.length; i++) {
lineWidth += ctx.measureText(str[i]).width;
if (lineWidth > canvasWidth - initX) {
ctx.fillText(str.substring(lastSubStrIndex, i), initX, initY);
initY += lineHeight;
lineWidth = 0;
lastSubStrIndex = i;
}
if (i == str.length - 1) {
ctx.fillText(str.substring(lastSubStrIndex, i + 1), initX, initY);
}
}
},
/!* // 删除批注
restuya(){
this.word.style.display="none";
this.Txt.style.display="none";
this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);
window.location.reload();
},*!/
// 撤销
back() {
this.word.style.display = "none";
this.Txt.style.display = "none";
if (preDrawAry.length > 0) {
var popData = preDrawAry.pop();
this.ctx.putImageData(popData, 0, 0);
}
},
// 回退一次
put() {
this.ctx.putImageData(this.imgData, 0, 0);
},
//保存
saveTu() {
let canvas = document.getElementById('canvas');
let image = new Image();
image = canvas.toDataURL('image/png');
this.canvasImg = image;
let file = this.base64ToFile(image);
let formData = new FormData();
formData.append('file', file);
upFile(formData).then((res) => {
debugger;
console.log(res);
debugger;
})
},
base64ToFile(baseUrl) {
let arr = baseUrl.split(',');
// let type = arr[0].match(/:(.*?);/)[1]; // 解锁图片类型
let bytes = atob(arr[1]); // 解码base64
let n = bytes.length;
let bufferArray = new Uint8Array(n);
while (n--) {
bufferArray[n] = bytes.charCodeAt(n);
}
// let fileOfBlob = new File([bufferArray], new Date()+'.jpg');
return new File([bufferArray], 'draw.jpg');
},
judgeForm() {
let that = this,
reg = /\{(.+?)\}/g,
judgeList = this.judgeList;
debugger;
console.log(judgeList);
for (let i = 0; i < judgeList.length; i++) {
let arr = [], str = '';
let item = judgeList[i].rule_expression.replace(/`/g, '');
if (item.indexOf('||') > -1) {
arr = item.split('||');
} else if (item.indexOf('&&') > -1) {
arr = item.split('&&');
} else {
arr.push(item);
}
debugger;
console.log(arr);
//对每个条件进行判定如果符合
for (let i = 0; i < arr.length; i++) {
//获取判断依据
let a = '`' + arr[i] + '`';
let tem = a.match(reg)[0];
let ky = tem.replace(/\{|\}/g, '');//qipao
debugger;
console.log(that.checkForm[ky]);
//有值时进行判断
if (that.checkForm[ky] !== '' && that.checkForm[ky] !== null && that.checkForm[ky] !== undefined) {
//替换变量
a = a.replace(ky, 'yyy');
let yyy = "'" + that.checkForm[ky] + "'";
debugger;
if (eval(eval(a))) {
str += 'true';
} else {
str += 'false';
}
}
}
debugger;
console.log(str);
if (str.indexOf('true') > -1) {
that.judgeList[i].judge = true;
} else {
that.judgeList[i].judge = false;
}
}
let real = that.judgeList.filter(item => {
return item.judge == true;
});
debugger;
console.log(that.judgeList);
console.log(real);
if (real.length > 0) {
alert("检验不合格!")
} else {
alert("检验合格!")
}
},*/
//新增记录表
handleCreate() {
this.recordform = Object.assign({}, defaultrecordform);

View File

@ -34,7 +34,7 @@
<template slot-scope="scope">
<el-link
v-if="checkPermission(['warehouse_update'])"
@click="handleInspection(scope)"
@click="handleInspection(scope,'view')"
>检验
</el-link
>
@ -82,10 +82,10 @@
<template slot-scope="scope">
<el-link
v-if="checkPermission(['warehouse_update'])"
@click="handleInspection(scope)"
>检验
</el-link
@click="handleInspection(scope,'review')"
>
检验
</el-link>
</template>
</el-table-column>
</el-table>
@ -100,10 +100,9 @@
</el-tab-pane>
<el-tab-pane label="已合格半成品">
<el-card style="margin-top: 2px">
<el-button type="primary" icon="el-icon-plus" @click="handleCreate"
>批量入库
</el-button
>
<el-button type="primary" icon="el-icon-plus" @click="handleCreate">
批量入库
</el-button>
<el-table
v-loading="listLoading"
:data="wproductList1.results"
@ -211,15 +210,14 @@
<el-select style="width: 100%" v-model="recordform" placeholder="请选择" @change="recordformChange">
<el-option
v-for="item in recordformList"
:key="item.id"
:key="item.name"
:label="item.name"
:value="item.id"
>
>
</el-option>
</el-select>
<el-dialog
width="50%"
width="60%"
:title="formName"
:visible.sync="innerVisible"
append-to-body
@ -228,12 +226,15 @@
:results="fieldList"
:hasPicture="hasPicture"
:formID="recordform"
:step="step"
:wproduct="wproduct"
@formFunc="formFunc"
/>
</el-dialog>
<div slot="footer" class="dialog-footer">
<el-button @click="outerVisible = false"> </el-button>
<el-button @click="outerVisible = false">
</el-button>
<el-button type="primary" @click="submitrecordform">填写检查项目</el-button>
</div>
</el-dialog>
@ -295,7 +296,7 @@
</template>
<script>
import customForm from '@/components/customForm/index';
import {getwproductList, wproductTest, wproductPutin, createputins} from "@/api/wpm";
import {getwproductList, wproductTest, wproductPutin, createputins,wproductReview} from "@/api/wpm";
import checkPermission from "@/utils/permission";
import {getWarehouseList} from "@/api/inm";
import {getMaterialList, getrecordformList, getrffieldList} from "@/api/mtm";
@ -360,17 +361,18 @@
],
options: [],
listLoading: true,
fieldList: "",
fieldList: [],
is_testok: "true",
field: [],
recordformList: [],
recordform: "",
recordform: null,
fifo_detail: "",
listQueryrecordform: {
page: 0,
},
step:'view',
mutipID: [],
wproduct:null,
wproduct: null,
hasPicture: false,
outerVisible: false,
innerVisible: false,
@ -378,7 +380,7 @@
dialogFormVisibles: false,
testrecord: {},
WarehouseData: "",
formName:'项目检查表',
formName: '项目检查表',
};
},
computed: {},
@ -474,8 +476,9 @@
}
});
},
handleInspection(scope) {
handleInspection(scope,step) {
//调该物料对应的检查表
this.step = step;
this.outerVisible = true;
this.wproduct = scope.row.id;//半成品ID
this.wproductactstate = scope.row.act_state;//半成品状态
@ -488,31 +491,50 @@
}
});
},
recordformChange(){
recordformChange() {
let that = this;
let arr = this.recordformList.filter(item=>{
return item.id=that.recordform;
})
let arr = this.recordformList.filter(item => {
return item.id === that.recordform;
});
that.formName = arr[0].name;
},
//根据选择的表渲染检查项目
submitrecordform() {
let that = this;
if (this.recordform != "") {
getrffieldList({form: this.recordform, 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;
if (that.recordform != "") {
if(that.step==='view'){
getrffieldList({form: this.recordform, 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;
}
that.innerVisible = true;
}
that.innerVisible = true;
}
});
});
}else{
wproductReview({form: this.recordform, wproduct: this.wproduct}).then((response) => {
if (response.data) {
debugger;
console.log(response);
that.hasPicture = false;
let fieldList = response.data.form_fields;
that.fieldList = [...fieldList];
let arr = fieldList.filter(item => {
return item.field_type === 'draw'
});
if (arr.length > 0) {
that.hasPicture = true;
}
that.innerVisible = true;
}
});
}
} else this.$message.error("请选择检查表!");
},
//提交检查项目