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

This commit is contained in:
曹前明 2022-06-06 13:16:40 +08:00
commit f7a48ecfa7
11 changed files with 531 additions and 398 deletions

View File

@ -133,7 +133,7 @@
<el-row v-show="hasPicture"> <el-row v-show="hasPicture">
<el-form-item label="图表"> <el-form-item label="图表">
<div> <div>
<img id="canvasImg" :src="img" style="width:500px;height: 300px;position: absolute;top: -1000px;"> <img id="canvasImg" :src="img" alt="tupian">
<div style="position: relative;display: flex;flex-direction: column; <div style="position: relative;display: flex;flex-direction: column;
border: 1px solid #DCDFE6;"> border: 1px solid #DCDFE6;">
<canvas id="canvas" width="500" height="300"> <canvas id="canvas" width="500" height="300">
@ -169,65 +169,67 @@
</template> </template>
<script> <script>
import { upFile } from "@/api/file"; import {upFile} from "@/api/file";
let preDrawAry = []; let preDrawAry = [];
export default { export default {
name: "index", name: "index",
props: { props: {
results:{ results: {
type:Array, type: Array,
default: () => { default: () => {
return [] return []
}} , }
},
formID: { formID: {
type:Number, type: Number,
default:0 default: 0
}, },
wproduct: { wproduct: {
type:Number, type: Number,
default:0 default: 0
}, },
recordId: { recordId: {
type:Number, type: Number,
default:null default: null
}, },
hasPicture:{ hasPicture: {
type:Boolean, type: Boolean,
default:false default: false
}, },
isDisabled:{ isDisabled: {
type:Boolean, type: Boolean,
default:false default: false
} }
}, },
mounted() { mounted() {
let that = this; let that = this;
that.checkForm = {}; that.checkForm = {};
this.form = this.formID; this.form = this.formID;
let formData=this.results; let formData = this.results;
that.wproductId=this.wproduct; that.wproductId = this.wproduct;
formData.forEach(item => { formData.forEach(item => {
let obj = new Object(); let obj = new Object();
obj = item; obj = item;
if(item.field_type === 'draw'){ if (item.field_type === 'draw') {
obj.is_testok = true; obj.is_testok = true;
}else{ } else {
obj.is_testok = null; obj.is_testok = null;
} }
that.formData.push(obj) that.formData.push(obj)
}); });
that.formData=[...formData]; that.formData = [...formData];
for(let i=0;i<this.results.length;i++){ for (let i = 0; i < this.results.length; i++) {
let key = this.results[i].field_key; let key = this.results[i].field_key;
//checkForm接收表单数据的对象 //checkForm接收表单数据的对象
let valu = this.results[i].field_value; let valu = this.results[i].field_value;
if(valu!==null&&valu!==''&&valu!==undefined){ if (valu !== null && valu !== '' && valu !== undefined) {
that.checkForm[key]=valu; that.checkForm[key] = valu;
that.$set(that.checkForm,key,valu); that.$set(that.checkForm, key, valu);
that.is_save = true; that.is_save = true;
}else{ } else {
that.checkForm[key]=''; that.checkForm[key] = '';
that.$set(that.checkForm,key,null) that.$set(that.checkForm, key, null)
} }
} }
let listJudge = this.formData.filter(item => { let listJudge = this.formData.filter(item => {
@ -238,173 +240,173 @@
obj = item; obj = item;
that.judgeList.push(obj) that.judgeList.push(obj)
}); });
let imag= this.formData.filter(item => { let imag = this.formData.filter(item => {
return item.field_type === 'draw'; return item.field_type === 'draw';
}); });
if(imag.length>0){ if (imag.length > 0) {
that.img = new Image(); that.img = new Image();
that.img.crossOrigin = 'anonymous'; that.img.crossOrigin = 'anonymous';
let value = imag[0].field_value?imag[0].field_value:imag[0].draw_template; let value = imag[0].field_value!==null&&imag[0].field_value!==undefined&&imag[0].field_value!=='' ? imag[0].field_value : imag[0].draw_template;
that.img = value; that.img =process.env.VUE_APP_BASE_API.replace('/api','')+ value;
setTimeout(function(){ setTimeout(function () {
that.canvasInit(); that.canvasInit();
},500); }, 1000);
} }
}, },
data(){ data() {
return{ return {
field:[], field: [],
checkForm:{}, checkForm: {},
testrecord:{ testrecord: {
form:this.formID, form: this.formID,
record_data:[], record_data: [],
is_testok:true, is_testok: true,
wproduct:null, wproduct: null,
}, },
canvas:null, canvas: null,
wproductId:null, wproductId: null,
ctx:null, ctx: null,
myCanvas_rect:null, myCanvas_rect: null,
Txt:null, Txt: null,
word:null, word: null,
img:null, img: null,
widths:0, widths: 0,
heights:0, heights: 0,
lineW:3, lineW: 3,
colorF:"#e42343", colorF: "#e42343",
imgUrl:'', imgUrl: '',
imgData:'', imgData: '',
canvasImg:'', canvasImg: '',
formData:[],//表单数组 formData: [],//表单数组
judgeList:[],//判定数组 judgeList: [],//判定数组
is_testok:true, is_testok: true,
testokTrue:true, testokTrue: true,
is_save:false, is_save: false,
require:false, require: false,
testokFalse:false, testokFalse: false,
index:'1', index: '1',
} }
}, },
methods:{ methods: {
filterBlock(rule,index,field_key){ filterBlock(rule, index, field_key) {
let that = this; let that = this;
if(rule!==''&&rule!==null&&rule!==undefined){ if (rule !== '' && rule !== null && rule !== undefined) {
let reg = /\{(.+?)\}/g; let reg = /\{(.+?)\}/g;
if(rule.indexOf('||')>-1||rule.indexOf('&&')>-1){ if (rule.indexOf('||') > -1 || rule.indexOf('&&') > -1) {
let tam = '', arr = []; let tam = '', arr = [];
if(rule.indexOf('||')>-1){ if (rule.indexOf('||') > -1) {
arr = rule.split('||'); arr = rule.split('||');
}else{ } else {
arr = rule.split('&&'); arr = rule.split('&&');
} }
for (let i = 0;i<arr.length;i++){ for (let i = 0; i < arr.length; i++) {
//获取判断依据 //获取判断依据
let a = ''; let a = '';
a = arr[i].replace(/`/g,''); a = arr[i].replace(/`/g, '');
a = '`'+ a+'`'; a = '`' + a + '`';
let tem =a.match(reg)[0]; let tem = a.match(reg)[0];
let ky = tem.replace(/\{|\}/g, '');//qipao let ky = tem.replace(/\{|\}/g, '');//qipao
if(that.checkForm[ky]){ if (that.checkForm[ky]) {
//替换变量 //替换变量
a = a.replace(ky, 'yyy'); a = a.replace(ky, 'yyy');
let yyy = "'"+that.checkForm[ky]+"'"; let yyy = "'" + that.checkForm[ky] + "'";
if(eval(eval( a))){ if (eval(eval(a))) {
tam += 'true'; tam += 'true';
}else{ } else {
tam += 'false'; tam += 'false';
} }
}else{ } else {
tam += 'false'; tam += 'false';
} }
} }
let rea = true; let rea = true;
if(rule.indexOf('||')>-1){ if (rule.indexOf('||') > -1) {
if( tam.indexOf('true')>-1){ if (tam.indexOf('true') > -1) {
rea = true; rea = true;
}else{ } else {
rea = false; rea = false;
} }
}else{ } else {
if( tam.indexOf('false')>-1){ if (tam.indexOf('false') > -1) {
rea = false; rea = false;
}else{ } else {
rea = true; rea = true;
} }
} }
if(rea){ if (rea) {
that.formData[index].is_hidden = false; that.formData[index].is_hidden = false;
}else{ } else {
that.formData[index].is_hidden = true; that.formData[index].is_hidden = true;
that.checkForm[field_key] = null; that.checkForm[field_key] = null;
} }
return rea; return rea;
}else{ } else {
let temp =rule.match(reg)[0]; let temp = rule.match(reg)[0];
let key = temp.replace(/\{|\}/g, '');//qipao let key = temp.replace(/\{|\}/g, '');//qipao
let a = rule.replace(key, 'yy'); let a = rule.replace(key, 'yy');
a = a.replace(key, 'yy'); a = a.replace(key, 'yy');
let yy = "'"+that.checkForm[key]+"'"; let yy = "'" + that.checkForm[key] + "'";
if(eval(eval(a))){ if (eval(eval(a))) {
that.formData[index].is_hidden = false; that.formData[index].is_hidden = false;
}else{ } else {
that.formData[index].is_hidden = true; that.formData[index].is_hidden = true;
that.checkForm[field_key] = null; that.checkForm[field_key] = null;
} }
return eval(eval(a)); return eval(eval(a));
} }
}else{ } else {
that.formData[index].is_hidden = false; that.formData[index].is_hidden = false;
return true; return true;
} }
}, },
keyChange(index,key){ keyChange(index, key) {
let that = this; let that = this;
let reg = /\{(.+?)\}/g; let reg = /\{(.+?)\}/g;
that.$forceUpdate(); that.$forceUpdate();
that.$nextTick(()=>{ that.$nextTick(() => {
if(that.formData[index].need_judge===true){ if (that.formData[index].need_judge === true) {
let arr = [],str = ''; let arr = [], str = '';
let item = that.formData[index].rule_expression.replace(/`/g,''); let item = that.formData[index].rule_expression.replace(/`/g, '');
if(item.indexOf('||')>-1){ if (item.indexOf('||') > -1) {
arr = item.split('||'); arr = item.split('||');
}else if(item.indexOf('&&')>-1){ } else if (item.indexOf('&&') > -1) {
arr = item.split('&&'); arr = item.split('&&');
}else{ } else {
arr.push(item); arr.push(item);
} }
//对每个条件进行判定如果符合 //对每个条件进行判定如果符合
for (let i = 0;i<arr.length;i++){ for (let i = 0; i < arr.length; i++) {
//获取判断依据 //获取判断依据
let a = '`'+ arr[i]+'`'; let a = '`' + arr[i] + '`';
let tem =a.match(reg)[0]; let tem = a.match(reg)[0];
let ky = tem.replace(/\{|\}/g, '');//qipao let ky = tem.replace(/\{|\}/g, '');//qipao
//有值时进行判断 //有值时进行判断
if(that.checkForm[ky]!==''&&that.checkForm[ky]!==null&&that.checkForm[ky]!==undefined){ if (that.checkForm[ky] !== '' && that.checkForm[ky] !== null && that.checkForm[ky] !== undefined) {
//替换变量 //替换变量
a = a.replace(ky, 'yyy'); a = a.replace(ky, 'yyy');
let yyy = "'"+that.checkForm[ky]+"'"; let yyy = "'" + that.checkForm[ky] + "'";
if(eval(eval( a))){ if (eval(eval(a))) {
str += 'true'; str += 'true';
}else{ } else {
str += 'false'; str += 'false';
} }
} }
} }
if(item.indexOf('&&')>-1){ if (item.indexOf('&&') > -1) {
if(str.indexOf('false')>-1){ if (str.indexOf('false') > -1) {
that.formData[index].is_testok = true; that.formData[index].is_testok = true;
that.$set(that.formData[index],'is_testok',true) that.$set(that.formData[index], 'is_testok', true)
}else{ } else {
that.formData[index].is_testok = false; that.formData[index].is_testok = false;
that.$set(that.formData[index],'is_testok',false) that.$set(that.formData[index], 'is_testok', false)
} }
}else{ } else {
if(str.indexOf('true')>-1){ if (str.indexOf('true') > -1) {
that.formData[index].is_testok = false; that.formData[index].is_testok = false;
that.$set(that.formData[index],'is_testok',false) that.$set(that.formData[index], 'is_testok', false)
}else{ } else {
that.formData[index].is_testok = true; that.formData[index].is_testok = true;
that.$set(that.formData[index],'is_testok',true) that.$set(that.formData[index], 'is_testok', true)
} }
} }
that.$forceUpdate(); that.$forceUpdate();
@ -418,7 +420,7 @@
}, },
/* 图片保存 */ /* 图片保存 */
//初始化canvas //初始化canvas
canvasInit(){ canvasInit() {
let that = this; let that = this;
preDrawAry = []; preDrawAry = [];
that.canvas = document.getElementById('canvas'); that.canvas = document.getElementById('canvas');
@ -428,55 +430,54 @@
that.word = document.getElementById('word'); that.word = document.getElementById('word');
that.widths = that.myCanvas_rect.width; that.widths = that.myCanvas_rect.width;
that.heights = that.myCanvas_rect.height; that.heights = that.myCanvas_rect.height;
setTimeout(function(){ setTimeout(function () {
that.draw(); that.draw();
},500); }, 500);
}, },
//画布添加背景模板图 //画布添加背景模板图
draw(){ draw() {
this.ctx = document.getElementById('canvas').getContext('2d');
let canvasImg = document.getElementById("canvasImg"); let canvasImg = document.getElementById("canvasImg");
canvasImg.setAttribute("crossOrigin",'anonymous'); // canvasImg.setAttribute("crossOrigin", 'anonymous');
// canvasImg.style.width = '500px'; this.ctx.drawImage(canvasImg, 0, 0, 500, 300);
// canvasImg.style.height = '300px';
this.ctx.drawImage(canvasImg,0,0,500,300);
}, },
// 叉号 // 叉号
error1(){ error1() {
let canvas1 = document.getElementById('canvas'); let canvas1 = document.getElementById('canvas');
let ctx1 = canvas1.getContext('2d'); let ctx1 = canvas1.getContext('2d');
this.Txt.style.display="none"; this.Txt.style.display = "none";
document.getElementById('word').style.display="none"; document.getElementById('word').style.display = "none";
ctx1.closePath(); ctx1.closePath();
canvas1.onmousedown=function () { canvas1.onmousedown = function () {
this.imgData= ctx1.getImageData(0,0,canvas1.width,canvas1.height); this.imgData = ctx1.getImageData(0, 0, canvas1.width, canvas1.height);
preDrawAry.push(this.imgData); preDrawAry.push(this.imgData);
ctx1.beginPath(); ctx1.beginPath();
ctx1.strokeStyle = "#e42343"; ctx1.strokeStyle = "#e42343";
ctx1.lineWidth = "3"; ctx1.lineWidth = "3";
ctx1.lineJoin="round"; ctx1.lineJoin = "round";
}; };
//鼠标按下的位置 //鼠标按下的位置
canvas1.onmouseup=function (ev) { canvas1.onmouseup = function (ev) {
let oldX = ev.offsetX; let oldX = ev.offsetX;
let oldY = ev.offsetY; let oldY = ev.offsetY;
ctx1.moveTo(oldX,oldY); ctx1.moveTo(oldX, oldY);
ctx1.lineTo(ev.offsetX+10,ev.offsetY+10); ctx1.lineTo(ev.offsetX + 10, ev.offsetY + 10);
ctx1.moveTo(ev.offsetX+10,ev.offsetY); ctx1.moveTo(ev.offsetX + 10, ev.offsetY);
ctx1.lineTo(ev.offsetX,ev.offsetY+10); ctx1.lineTo(ev.offsetX, ev.offsetY + 10);
ctx1.stroke(); ctx1.stroke();
}; };
this.ctx.closePath(); this.ctx.closePath();
}, },
// 文字先写字 // 文字先写字
text(){ text() {
let canvas2 = document.getElementById('canvas'); let canvas2 = document.getElementById('canvas');
let ctx2 = canvas2.getContext('2d'); let ctx2 = canvas2.getContext('2d');
let Txt2 = document.getElementById('txt'); let Txt2 = document.getElementById('txt');
Txt2.style.display="block"; Txt2.style.display = "block";
document.getElementById('word').style.display="none"; document.getElementById('word').style.display = "none";
ctx2.font="16px Microsoft Yahei"; ctx2.font = "16px Microsoft Yahei";
canvas2.onmousedown=function (ev) { canvas2.onmousedown = function (ev) {
this.imgData=ctx2.getImageData(0,0,canvas2.width,canvas2.height); this.imgData = ctx2.getImageData(0, 0, canvas2.width, canvas2.height);
preDrawAry.push(this.imgData); preDrawAry.push(this.imgData);
var v = Txt2.value; var v = Txt2.value;
// console.log(v); // console.log(v);
@ -484,63 +485,63 @@
var oldX = ev.offsetX; var oldX = ev.offsetX;
var oldY = ev.offsetY; var oldY = ev.offsetY;
// console.log(oldX,oldY); // console.log(oldX,oldY);
ctx2.moveTo(oldX,oldY); ctx2.moveTo(oldX, oldY);
canvas2.onmouseup=function () { canvas2.onmouseup = function () {
ctx2.fillStyle=this.colorF; ctx2.fillStyle = this.colorF;
ctx2.fillText(v,oldX,oldY); ctx2.fillText(v, oldX, oldY);
canvas2.TextAutoLine(v,canvas2,oldX,oldY,20); canvas2.TextAutoLine(v, canvas2, oldX, oldY, 20);
// Txt.value = ""; // Txt.value = "";
Txt2.style.display="none"; Txt2.style.display = "none";
} }
} }
} }
}, },
// 文字 // 文字
word1(){ word1() {
let canvas3 = document.getElementById('canvas'); let canvas3 = document.getElementById('canvas');
let ctx3 = canvas3.getContext('2d'); let ctx3 = canvas3.getContext('2d');
let Txt3 = document.getElementById('txt'); let Txt3 = document.getElementById('txt');
let word3 = document.getElementById('word'); let word3 = document.getElementById('word');
Txt3.style.display="none"; Txt3.style.display = "none";
ctx3.font="16px Microsoft Yahei"; ctx3.font = "16px Microsoft Yahei";
canvas3.onmousedown=function () { canvas3.onmousedown = function () {
ctx3.closePath(); ctx3.closePath();
} }
canvas3.onmouseup=function (ev) { canvas3.onmouseup = function (ev) {
var inputV= document.getElementById('inputV').value; var inputV = document.getElementById('inputV').value;
if(inputV == 1){ if (inputV == 1) {
document.getElementById('word').focus(); document.getElementById('word').focus();
// console.log(ev.offsetX,ev.offsetY); // console.log(ev.offsetX,ev.offsetY);
var oldX = ev.offsetX; var oldX = ev.offsetX;
var oldY = ev.offsetY; var oldY = ev.offsetY;
word3.style.display="block"; word3.style.display = "block";
word3.style.left=oldX+'px'; word3.style.left = oldX + 'px';
word3.style.top =oldY+'px'; word3.style.top = oldY + 'px';
word3.onblur=function () { word3.onblur = function () {
let v = word3.value; let v = word3.value;
if(v != '' && v != ' '){ if (v != '' && v != ' ') {
this.imgData=ctx3.getImageData(0,0,canvas3.width,canvas3.height); this.imgData = ctx3.getImageData(0, 0, canvas3.width, canvas3.height);
let img = ctx3.getImageData(0,0,canvas3.width,canvas3.height); let img = ctx3.getImageData(0, 0, canvas3.width, canvas3.height);
preDrawAry.push(img); preDrawAry.push(img);
ctx3.moveTo(oldX,oldY); ctx3.moveTo(oldX, oldY);
ctx3.fillStyle="#e42343"; ctx3.fillStyle = "#e42343";
let lineWidth = 0; let lineWidth = 0;
let canvasWidth = canvas3.width; let canvasWidth = canvas3.width;
let lastSubStrIndex= 0; let lastSubStrIndex = 0;
for(let i=0;i<v.length;i++){ for (let i = 0; i < v.length; i++) {
lineWidth+=ctx3.measureText(v[i]).width; lineWidth += ctx3.measureText(v[i]).width;
if(lineWidth>canvasWidth-oldX){ if (lineWidth > canvasWidth - oldX) {
ctx3.fillText(v.substring(lastSubStrIndex,i),oldX,(oldY+10)); ctx3.fillText(v.substring(lastSubStrIndex, i), oldX, (oldY + 10));
oldY+=20; oldY += 20;
lineWidth=0; lineWidth = 0;
lastSubStrIndex=i; lastSubStrIndex = i;
} }
if(i==v.length-1){ if (i == v.length - 1) {
ctx3.fillText(v.substring(lastSubStrIndex,i+1),oldX,(oldY+10)); ctx3.fillText(v.substring(lastSubStrIndex, i + 1), oldX, (oldY + 10));
} }
} }
inputV ="2"; inputV = "2";
word3.value = ""; word3.value = "";
} }
} }
@ -548,42 +549,42 @@
} }
}, },
// 文字过长超出换行toDataURL() // 文字过长超出换行toDataURL()
canvasTextAutoLine(str,canvas,initX,initY,lineHeight){ canvasTextAutoLine(str, canvas, initX, initY, lineHeight) {
let ctx = canvas.getContext("2d"); let ctx = canvas.getContext("2d");
let lineWidth = 0; let lineWidth = 0;
let canvasWidth = canvas.width; let canvasWidth = canvas.width;
let lastSubStrIndex= 0; let lastSubStrIndex = 0;
for(let i=0;i<str.length;i++){ for (let i = 0; i < str.length; i++) {
lineWidth+=ctx.measureText(str[i]).width; lineWidth += ctx.measureText(str[i]).width;
if(lineWidth>canvasWidth-initX){ if (lineWidth > canvasWidth - initX) {
ctx.fillText(str.substring(lastSubStrIndex,i),initX,initY); ctx.fillText(str.substring(lastSubStrIndex, i), initX, initY);
initY+=lineHeight; initY += lineHeight;
lineWidth=0; lineWidth = 0;
lastSubStrIndex=i; lastSubStrIndex = i;
} }
if(i==str.length-1){ if (i == str.length - 1) {
ctx.fillText(str.substring(lastSubStrIndex,i+1),initX,initY); ctx.fillText(str.substring(lastSubStrIndex, i + 1), initX, initY);
} }
} }
}, },
// 撤销 // 撤销
back(){ back() {
this.word.style.display="none"; this.word.style.display = "none";
this.Txt.style.display="none"; this.Txt.style.display = "none";
if(preDrawAry.length>0) { if (preDrawAry.length > 0) {
var popData = preDrawAry.pop(); var popData = preDrawAry.pop();
this.ctx.putImageData(popData, 0, 0); this.ctx.putImageData(popData, 0, 0);
} }
}, },
// 回退一次 // 回退一次
put(){ put() {
this.ctx.putImageData(this.imgData,0,0); this.ctx.putImageData(this.imgData, 0, 0);
}, },
//保存 //保存
saveTu(){ saveTu() {
let that = this; let that = this;
this.word.style.display="none"; this.word.style.display = "none";
this.Txt.style.display="none"; this.Txt.style.display = "none";
let canvas = document.getElementById('canvas'); let canvas = document.getElementById('canvas');
let image = new Image(); let image = new Image();
image = canvas.toDataURL('image/png'); image = canvas.toDataURL('image/png');
@ -592,7 +593,7 @@
let formData = new FormData(); let formData = new FormData();
formData.append('file', file); formData.append('file', file);
upFile(formData).then((res) => { upFile(formData).then((res) => {
that.imgUrl=res.data.path; that.imgUrl = res.data.path;
}) })
}, },
//base64ToFile //base64ToFile
@ -600,69 +601,69 @@
let arr = baseUrl.split(','); let arr = baseUrl.split(',');
// let type = arr[0].match(/:(.*?);/)[1]; // 解锁图片类型 // let type = arr[0].match(/:(.*?);/)[1]; // 解锁图片类型
let bytes = atob(arr[1]); // 解码base64 let bytes = atob(arr[1]); // 解码base64
let n = bytes .length; let n = bytes.length;
let bufferArray = new Uint8Array(n); let bufferArray = new Uint8Array(n);
while (n--) { while (n--) {
bufferArray[n] = bytes.charCodeAt(n); bufferArray[n] = bytes.charCodeAt(n);
} }
// let fileOfBlob = new File([bufferArray], new Date()+'.jpg'); // let fileOfBlob = new File([bufferArray], new Date()+'.jpg');
return new File([bufferArray ],'draw.jpg'); return new File([bufferArray], 'draw.jpg');
}, },
/* 图片保存 */ /* 图片保存 */
//最终表格判定 //最终表格判定
judgeForm(){ judgeForm() {
let that = this , let that = this,
reg = /\{(.+?)\}/g, reg = /\{(.+?)\}/g,
judgeList = this.judgeList; judgeList = this.judgeList;
for(let i=0;i<judgeList.length;i++){ for (let i = 0; i < judgeList.length; i++) {
let arr = [],str = ''; let arr = [], str = '';
let item = judgeList[i].rule_expression.replace(/`/g,''); let item = judgeList[i].rule_expression.replace(/`/g, '');
if(item.indexOf('||')>-1){ if (item.indexOf('||') > -1) {
arr = item.split('||'); arr = item.split('||');
}else if(item.indexOf('&&')>-1){ } else if (item.indexOf('&&') > -1) {
arr = item.split('&&'); arr = item.split('&&');
}else{ } else {
arr.push(item); arr.push(item);
} }
//对每个条件进行判定如果符合 //对每个条件进行判定如果符合
for (let i = 0;i<arr.length;i++){ for (let i = 0; i < arr.length; i++) {
//获取判断依据 //获取判断依据
let a = '`'+ arr[i]+'`'; let a = '`' + arr[i] + '`';
let tem =a.match(reg)[0]; let tem = a.match(reg)[0];
let ky = tem.replace(/\{|\}/g, '');//qipao let ky = tem.replace(/\{|\}/g, '');//qipao
//有值时进行判断 //有值时进行判断
if(that.checkForm[ky]!==''&&that.checkForm[ky]!==null&&that.checkForm[ky]!==undefined){ if (that.checkForm[ky] !== '' && that.checkForm[ky] !== null && that.checkForm[ky] !== undefined) {
//替换变量 //替换变量
a = a.replace(ky, 'yyy'); a = a.replace(ky, 'yyy');
let yyy = "'"+that.checkForm[ky]+"'"; let yyy = "'" + that.checkForm[ky] + "'";
if(eval(eval( a))){ if (eval(eval(a))) {
str += 'true'; str += 'true';
}else{ } else {
str += 'false'; str += 'false';
} }
} }
} }
if(item.indexOf('&&')>-1){ if (item.indexOf('&&') > -1) {
if(str.indexOf('false')>-1){ if (str.indexOf('false') > -1) {
that.judgeList[i].is_testok = true; that.judgeList[i].is_testok = true;
}else{ } else {
that.judgeList[i].is_testok = false; that.judgeList[i].is_testok = false;
} }
}else{ } else {
if(str.indexOf('true')>-1){ if (str.indexOf('true') > -1) {
that.judgeList[i].is_testok = false; that.judgeList[i].is_testok = false;
}else{ } else {
that.judgeList[i].is_testok = true; that.judgeList[i].is_testok = true;
} }
} }
} }
let real = that.judgeList.filter(item=>{ let real = that.judgeList.filter(item => {
return item.is_testok===false; return item.is_testok === false;
}); });
if(real.length>0){ if (real.length > 0) {
that.is_testok = false; that.is_testok = false;
// alert("检验不合格!") // alert("检验不合格!")
}else{ } else {
that.is_testok = true; that.is_testok = true;
// alert("检验合格!") // alert("检验合格!")
} }
@ -671,12 +672,12 @@
submitfield(isSubmit) { submitfield(isSubmit) {
let that = this; let that = this;
that.index = isSubmit; that.index = isSubmit;
let drawArr = that.formData.filter(item=>{ let drawArr = that.formData.filter(item => {
return item.field_type==='draw'; return item.field_type === 'draw';
}); });
if(drawArr.length>0){ if (drawArr.length > 0) {
that.word.style.display="none"; that.word.style.display = "none";
that.Txt.style.display="none"; that.Txt.style.display = "none";
let canvas = document.getElementById('canvas'); let canvas = document.getElementById('canvas');
let image = new Image(); let image = new Image();
image = canvas.toDataURL('image/png'); image = canvas.toDataURL('image/png');
@ -685,27 +686,27 @@
let formData = new FormData(); let formData = new FormData();
formData.append('file', file); formData.append('file', file);
upFile(formData).then((res) => { upFile(formData).then((res) => {
if(res){ if (res) {
let key = drawArr[0].field_key; let key = drawArr[0].field_key;
that.imgUrl=res.data.path; that.imgUrl = res.data.path;
that.checkForm[key] = res.data.path; that.checkForm[key] = res.data.path;
that.fieldData(); that.fieldData();
} }
}); });
}else{ } else {
that.fieldData(); that.fieldData();
} }
}, },
fieldData(){ fieldData() {
let that = this; let that = this;
that.field = []; //检查项目 that.field = []; //检查项目
that.formData.forEach((item) => { that.formData.forEach((item) => {
let field_value; let field_value;
if(item.field_type==='int'){ if (item.field_type === 'int') {
field_value = parseInt(that.checkForm[item.field_key]) field_value = parseInt(that.checkForm[item.field_key])
}else if(item.field_type==='float'){ } else if (item.field_type === 'float') {
field_value = parseFloat(that.checkForm[item.field_key]) field_value = parseFloat(that.checkForm[item.field_key])
}else{ } else {
field_value = that.checkForm[item.field_key]; field_value = that.checkForm[item.field_key];
} }
that.field.push({ that.field.push({
@ -718,14 +719,14 @@
that.testrecord.record_data = that.field;//检查项列表 that.testrecord.record_data = that.field;//检查项列表
that.testrecord.is_testok = that.is_testok;//检查表检查结果 that.testrecord.is_testok = that.is_testok;//检查表检查结果
that.testrecord.id = that.recordId;//记录id that.testrecord.id = that.recordId;//记录id
if(that.index==='2'){//提交 if (that.index === '2') {//提交
this.$emit('recordSubmit',that.testrecord); this.$emit('recordSubmit', that.testrecord);
}else {//保存 } else {//保存
this.$emit('recordSave',that.testrecord); this.$emit('recordSave', that.testrecord);
} }
}, },
recordCancel(){ recordCancel() {
this.$emit('recordCancel','') this.$emit('recordCancel', '')
}, },
} }
} }
@ -733,7 +734,7 @@
<style scoped> <style scoped>
canvas { canvas {
width:500px!important; width: 500px !important;
/*border: 1px solid #000000;*/ /*border: 1px solid #000000;*/
cursor: crosshair; cursor: crosshair;
margin: auto; margin: auto;
@ -757,6 +758,7 @@
margin-right: 10px; margin-right: 10px;
margin-bottom: 10px; margin-bottom: 10px;
} }
.hide { .hide {
display: none; display: none;
} }
@ -795,23 +797,33 @@
#res { #res {
display: inline-block; display: inline-block;
} }
.helpText{
.helpText {
position: absolute; position: absolute;
top: 40px; top: 40px;
left: 100px; left: 100px;
} }
.adoptTip{
.adoptTip {
position: absolute; position: absolute;
top: 38px; top: 38px;
right: 0; right: 0;
font-size: 12px; font-size: 12px;
color: #46ce7a; color: #46ce7a;
} }
.failTip{
.failTip {
position: absolute; position: absolute;
top: 38px; top: 38px;
right: 0; right: 0;
font-size: 12px; font-size: 12px;
color: #ff0000; color: #ff0000;
} }
#canvasImg{
width:500px;
height: 300px;
position: absolute;
left: 50%;
transform: translateX(-50%)
}
</style> </style>

View File

@ -329,8 +329,8 @@
}); });
that.img = new Image(); that.img = new Image();
that.img.crossOrigin = ''; that.img.crossOrigin = '';
that.img = imag[0].field_value; that.img = process.env.VUE_APP_BASE_API.replace('/api','')+imag[0].field_value;
that.originImg = imag[0].origin_value; that.originImg = process.env.VUE_APP_BASE_API.replace('/api','')+ imag[0].origin_value;
listJudge.forEach(item => { listJudge.forEach(item => {
let obj = new Object(); let obj = new Object();
obj = item; obj = item;
@ -383,7 +383,7 @@
let that = this; let that = this;
if(rule!==''&&rule!==null&&rule!==undefined){ if(rule!==''&&rule!==null&&rule!==undefined){
let reg = /\{(.+?)\}/g; let reg = /\{(.+?)\}/g;
debugger; // debugger;
if(rule.indexOf('||')>-1||rule.indexOf('&&')>-1){ if(rule.indexOf('||')>-1||rule.indexOf('&&')>-1){
let tam = '', arr = []; let tam = '', arr = [];
if(rule.indexOf('||')>-1){ if(rule.indexOf('||')>-1){

View File

@ -123,6 +123,19 @@ export const asyncRoutes = [
component: () => import('@/views/mtm/materialDetail.vue'), component: () => import('@/views/mtm/materialDetail.vue'),
meta: { title: '物料详情' }, meta: { title: '物料详情' },
hidden: true hidden: true
}
,{
path: 'wproductList',
name: 'wproductList',
component: () => import('@/views/mtm/wproductList'),
meta: { title: '半成品列表', icon: 'material', perms: ['mtm_wproduct'] }
},
{
path: 'productList',
name: 'productList',
component: () => import('@/views/mtm/productList'),
meta: { title: '成品列表', icon: 'material', perms: ['mtm_product'] }
}, },
{ {
path: 'process', path: 'process',
@ -151,18 +164,7 @@ export const asyncRoutes = [
component: () => import('@/views/mtm/productprocess'), component: () => import('@/views/mtm/productprocess'),
meta: { title: '产品管理', icon: 'product', perms: ['mtm_productprocess'] } meta: { title: '产品管理', icon: 'product', perms: ['mtm_productprocess'] }
} }
,{
path: 'productList',
name: 'productList',
component: () => import('@/views/mtm/productList'),
meta: { title: '成品列表', icon: 'material', perms: ['mtm_product'] }
}
,{
path: 'wproductList',
name: 'wproductList',
component: () => import('@/views/mtm/wproductList'),
meta: { title: '半成品列表', icon: 'material', perms: ['mtm_wproduct'] }
}
] ]
}, },
{ {

View File

@ -53,8 +53,9 @@
v-if="this.$route.params.pu_order != null" v-if="this.$route.params.pu_order != null"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag v-if="scope.row.is_testok == false">不合格</el-tag> <el-tag v-if="scope.row.is_testok">合格</el-tag>
<el-tag v-else>合格</el-tag> <el-tag v-else-if="scope.row.is_testok===null">未复验</el-tag>
<el-tag v-else>不合格</el-tag>
</template> </template>
</el-table-column> </el-table-column>
@ -86,7 +87,7 @@
复验记录 复验记录
</el-link> </el-link>
<el-link <el-link
v-else-if="scope.row.need_test&&scope.row.test==[]" v-if="scope.row.need_test&&scope.row.test.length===0"
type="primary" type="primary"
@click="handleMaterial(scope)" @click="handleMaterial(scope)"
> >

View File

@ -154,7 +154,8 @@
:title="tableForm.name" :title="tableForm.name"
> >
<customForm <customForm
:results="fieldList.results" v-if="dialogVisibleForm"
:results="dialogFieldList"
:hasPicture="hasPicture" :hasPicture="hasPicture"
:formID="formID" :formID="formID"
:isDisabled="isDisabled" :isDisabled="isDisabled"
@ -549,12 +550,13 @@
}; };
const defaultrecordform = {enabled: false}; const defaultrecordform = {enabled: false};
export default { export default {
components: {Pagination, vueJsonEditor, Treeselect, customForm, faceLogin}, components: {Pagination,customForm, faceLogin},
data() { data() {
return { return {
item:{}, item:{},
step: defaultstep, step: defaultstep,
stepList: [], stepList: [],
dialogFieldList: [],
upHeaders: upHeaders(), upHeaders: upHeaders(),
upUrl: upUrl(), upUrl: upUrl(),
fileList: [], fileList: [],
@ -835,7 +837,7 @@
} }
}, },
checkValue() { checkValue() {
this.field.field_key = this.field.field_key.replace(/[^a-zA-Z]/g, ''); this.field.field_key = this.field.field_key.replace(/[^0-9a-zA-Z]/g, '');
}, },
//添加字段选项 //添加字段选项
addDomain() { addDomain() {
@ -845,16 +847,23 @@
removeDomain(index) { removeDomain(index) {
this.field_choice.splice(index, 1); this.field_choice.splice(index, 1);
}, },
handleLook(scope) { async handleLook(scope) {
debugger;
let that = this; let that = this;
this.dialogFieldList=[];
that.tableForm = Object.assign({}, scope.row); // copy obj that.tableForm = Object.assign({}, scope.row); // copy obj
that.formID = that.tableForm.id; that.formID = that.tableForm.id;
that.listQueryfield.form = that.formID; that.listQueryfield.form = that.formID;
getrffieldList(that.listQueryfield).then((response) => { getrffieldList(that.listQueryfield).then((response) => {
if (response.data) { if (response.data) {
this.hasPicture = false;
that.fieldList = response.data; that.fieldList = response.data;
let list = response.data.results; }
});
await getrffieldList({page:0,form:that.formID}).then((response) => {
if (response.data) {
this.hasPicture = false;
let list = response.data;
this.dialogFieldList= response.data;
let arr = list.filter(item => { let arr = list.filter(item => {
return item.field_type === 'draw' return item.field_type === 'draw'
}); });
@ -877,12 +886,8 @@
that.$set(that.checkForm, key, '') that.$set(that.checkForm, key, '')
} }
that.dialogVisibleForm = true; that.dialogVisibleForm = true;
/* setTimeout(function () {
that.canvasInit();
}, 500);*/
} }
}); });
that.fieldLists();
}, },
checkPermission, checkPermission,
handleCurrentChange(row) { handleCurrentChange(row) {

View File

@ -268,7 +268,14 @@
}, },
//检查表 //检查表
handlebind(scope) { handlebind(scope) {
this.$router.push({name: "MaterialDO", params: {id: scope.row.id},}) let materialItem = sessionStorage.getItem('materialItem');
if(materialItem){
sessionStorage.removeItem('materialItem');
sessionStorage.setItem('materialItem',JSON.stringify(scope.row));
}else{
sessionStorage.setItem('materialItem',JSON.stringify(scope.row));
}
this.$router.push({name: "MaterialDO", params: {id: scope.row.id}})
}, },
handleFilter() { handleFilter() {
this.listQuery.page = 1; this.listQuery.page = 1;

View File

@ -121,8 +121,12 @@
font-weight: 700; font-weight: 700;
">过程记录表</span> ">过程记录表</span>
</div> </div>
<el-button type="primary" icon="el-icon-plus" @click="handleCreate" <el-button
>新增 type="primary"
icon="el-icon-plus"
@click="handleCreate"
>
新增
</el-button> </el-button>
<el-table <el-table
:data="recordformList.results" :data="recordformList.results"
@ -135,8 +139,9 @@
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
> >
<el-table-column type="index" width="50"/> <el-table-column type="index" width="50"/>
<el-table-column label="名称"> <el-table-column label="名称" prop="name"></el-table-column>
<template slot-scope="scope">{{ scope.row.name }}</template> <el-table-column label="关联产品">
<template slot-scope="scope" v-if="scope.row.material_">{{ scope.row.material_.name }}</template>
</el-table-column> </el-table-column>
<el-table-column label="状态"> <el-table-column label="状态">
<template slot-scope="scope"> <template slot-scope="scope">
@ -153,19 +158,16 @@
> >
<template slot-scope="scope"> <template slot-scope="scope">
<el-link <el-link
v-if="checkPermission(['material_update'])"
type="primary" type="primary"
@click="handleLook(scope)" @click="handleLook(scope)"
>查看 >查看
</el-link> </el-link>
<el-link <el-link
v-if="checkPermission(['material_update'])"
type="primary" type="primary"
@click="handleEdit(scope)" @click="handleEdit(scope)"
>编辑 >编辑
</el-link> </el-link>
<el-link <el-link
v-if="checkPermission(['material_delete'])"
type="danger" type="danger"
@click="handleDelete(scope)" @click="handleDelete(scope)"
>删除 >删除
@ -184,30 +186,54 @@
label-width="80px" label-width="80px"
label-position="right" label-position="right"
> >
<el-form-item label="表格名称" prop="name"> <el-form-item label="表格名称" prop="name">
<el-input v-model="recordform.name" placeholder="表格名称"/> <el-input v-model="recordform.name" placeholder="表格名称"/>
</el-form-item> </el-form-item>
<el-form-item label="文件号" prop="number"> <el-form-item label="文件号" prop="number">
<el-input v-model="recordform.number" placeholder="文件号"/> <el-input v-model="recordform.number" placeholder="文件号"/>
</el-form-item> </el-form-item>
<el-form-item label="状态"> <el-form-item label="状态">
<el-switch v-model="recordform.enabled"></el-switch> <el-switch v-model="recordform.enabled"></el-switch>
</el-form-item> </el-form-item>
<el-form-item label="表格类型" prop="type"> <el-form-item label="表格类型" prop="type">
<el-select style="width: 100%" v-model="recordform.type" placeholder="请选择"> <el-select style="width: 100%" v-model="recordform.type" placeholder="请选择">
<el-option <el-option
v-for="item in typeoptions" v-for="item in typeoptions"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
:value="item.value"> :value="item.value"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="引用表单" v-if="dialogType === 'new'">
<el-select
v-model="recordform.form"
style="width: 100%"
clearable
filterable
placeholder="请选择"
>
<el-option
v-for="item in formList"
:key="item.id"
:label="item.name"
:value="item.id"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="关联产品">
<el-select style="width: 100%" v-model="recordform.material" clearable placeholder="请选择">
<el-option
v-for="item in productOptions"
:key="item.id"
:label="item.name"
:value="item.id"
>
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div style="text-align: right"> <div style="text-align: right">
<el-button type="danger" @click="dialogVisible = false">取消</el-button> <el-button type="danger" @click="dialogVisible = false">取消</el-button>
@ -220,22 +246,22 @@
:visible.sync="dialogVisibleForm" :visible.sync="dialogVisibleForm"
:title="tableForm.name"> :title="tableForm.name">
<el-form <el-form
label-width="80px" label-width="180px"
label-position="right" label-position="right"
> >
<el-row v-for="(item,$index) in fieldList.results" :key="$index"> <el-row v-for="(item,$index) in dialogFieldList" :key="$index">
<el-form-item v-if="item.field_type==='string'" :label="item.field_name"> <el-form-item v-if="item.field_type==='string'" :label="item.field_name">
<el-input placeholder="请输入" v-model="item.sort"/> <el-input placeholder="请输入" v-model="item.low_limit"/>
</el-form-item> </el-form-item>
<el-form-item v-else-if="item.field_type==='int'" :label="item.field_name"> <el-form-item v-else-if="item.field_type==='int'" :label="item.field_name">
<el-input type="number" placeholder="请输入" v-model="item.sort"/> <el-input type="number" placeholder="请输入" v-model="item.low_limit"/>
</el-form-item> </el-form-item>
<el-form-item v-else-if="item.field_type==='float'" :label="item.field_name"> <el-form-item v-else-if="item.field_type==='float'" :label="item.field_name">
<el-input type="number" placeholder="请输入" v-model="item.sort"/> <el-input type="number" placeholder="请输入" v-model="item.low_limit"/>
</el-form-item> </el-form-item>
<el-form-item v-else-if="item.field_type==='date'" :label="item.field_name"> <el-form-item v-else-if="item.field_type==='date'" :label="item.field_name">
<el-date-picker <el-date-picker
v-model="item.create_time" v-model="item.low_limit"
type="date" type="date"
placeholder="选择日期" placeholder="选择日期"
value-format="yyyy-MM-dd" value-format="yyyy-MM-dd"
@ -245,7 +271,7 @@
</el-form-item> </el-form-item>
<el-form-item v-else-if="item.field_type==='datetime'" :label="item.field_name"> <el-form-item v-else-if="item.field_type==='datetime'" :label="item.field_name">
<el-date-picker <el-date-picker
v-model="item.create_time" v-model="item.low_limit"
type="datetime" type="datetime"
placeholder="选择日期" placeholder="选择日期"
value-format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss"
@ -254,8 +280,9 @@
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
<el-form-item v-else-if="item.field_type==='select'" :label="item.field_name"> <el-form-item v-else-if="item.field_type==='select'" :label="item.field_name">
<el-select style="width: 100%" v-model="item.sort" placeholder="请选择"> <el-select style="width: 100%" placeholder="请选择">
<el-option <el-option
v-model="item.low_limit"
v-for="item1 in item.field_choice" v-for="item1 in item.field_choice"
:key="item1" :key="item1"
:label="item1" :label="item1"
@ -264,8 +291,9 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item v-else-if="item.field_type==='selects'" :label="item.field_name"> <el-form-item v-else-if="item.field_type==='selects'" :label="item.field_name">
<el-select style="width: 100%" v-model="optio" multiple placeholder="请选择"> <el-select style="width: 100%" multiple placeholder="请选择">
<el-option <el-option
v-model="item.low_limit"
v-for="item1 in item.field_choice" v-for="item1 in item.field_choice"
:key="item1" :key="item1"
:label="item1" :label="item1"
@ -275,10 +303,6 @@
</el-form-item> </el-form-item>
</el-row> </el-row>
</el-form> </el-form>
<!--<div style="text-align: right">-->
<!--<el-button type="danger">取消</el-button>-->
<!--<el-button type="primary">确认</el-button>-->
<!--</div>-->
</el-dialog> </el-dialog>
</el-card> </el-card>
</el-col> </el-col>
@ -289,11 +313,14 @@
font-weight: 700; font-weight: 700;
">记录字段</span> ">记录字段</span>
</div> </div>
<el-button type="primary" icon="el-icon-plus" @click="handlefieldCreate" <el-button
>新增 type="primary"
icon="el-icon-plus"
@click="handlefieldCreate"
>
新增
</el-button> </el-button>
<el-table <el-table
:data="fieldList.results" :data="fieldList.results"
border border
fit fit
@ -301,51 +328,41 @@
highlight-current-row highlight-current-row
height="100" height="100"
v-el-height-adaptive-table="{bottomOffset: 50}" v-el-height-adaptive-table="{bottomOffset: 50}"
> >
<el-table-column type="index" width="50"/> <el-table-column type="index" width="50"/>
<el-table-column label="字段类型"> <el-table-column label="字段类型">
<template slot-scope="scope">{{ options_[scope.row.field_type] }}</template> <template slot-scope="scope">{{ options_[scope.row.field_type] }}</template>
</el-table-column> </el-table-column>
<el-table-column label="字段名称"> <el-table-column label="字段名称">
<template slot-scope="scope">{{ scope.row.field_name }}</template> <template slot-scope="scope">{{ scope.row.field_name }}</template>
</el-table-column> </el-table-column>
<el-table-column label="字段标识"> <el-table-column label="字段标识">
<template slot-scope="scope">{{ scope.row.field_key }}</template> <template slot-scope="scope">{{ scope.row.field_key }}</template>
</el-table-column> </el-table-column>
<el-table-column label="选项显示名"> <el-table-column label="选项显示名">
<template slot-scope="scope">{{ scope.row.field_choice }}</template> <template slot-scope="scope">{{ scope.row.field_choice }}</template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
align="center" align="center"
label="操作" label="操作"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<el-link <el-link
v-if="checkPermission(['material_update'])" v-if="checkPermission(['material_update'])"
type="primary" type="primary"
@click="handlefieldEdit(scope)" @click="handlefieldEdit(scope)"
>编辑
</el-link
> >
编辑
</el-link>
<el-link <el-link
v-if="checkPermission(['material_delete'])" v-if="checkPermission(['material_delete'])"
type="danger" type="danger"
@click="handlefieldDelete(scope)" @click="handlefieldDelete(scope)"
>删除
</el-link
> >
删除
</el-link>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination <pagination
v-show="fieldList.count > 0" v-show="fieldList.count > 0"
@ -368,14 +385,21 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="字段标识" prop="field_key"> <el-form-item label="字段标识" prop="field_key">
<el-input v-model="field.field_key" placeholder="字段标识" <el-input
onkeyup="value=value.replace(/[^A-Za-z_\/]/ig,'')"/> v-model="field.field_key"
placeholder="字段标识"
onkeyup="value=value.replace(/[^0-9A-Za-z]/g,'')"
/>
</el-form-item> </el-form-item>
<el-form-item label="字段名称" prop="field_name"> <el-form-item label="字段名称" prop="field_name">
<el-input v-model="field.field_name" placeholder="字段名称"/> <el-input v-model="field.field_name" placeholder="字段名称"/>
</el-form-item> </el-form-item>
<el-form-item label="选项" <el-form-item label="字段说明">
v-show="field.field_type=='radio'||field.field_type=='checkbox'||field.field_type=='select'||field.field_type=='selects'" <el-input v-model="field.help_text" placeholder="字段说明"/>
</el-form-item>
<el-form-item
v-show="field.field_type==='radio'||field.field_type==='checkbox'||field.field_type==='select'||field.field_type==='selects'"
label="选项"
> >
<el-button @click.prevent="addDomain" style="border: none;"> <el-button @click.prevent="addDomain" style="border: none;">
<i class="el-icon-circle-plus-outline"></i> <i class="el-icon-circle-plus-outline"></i>
@ -408,12 +432,11 @@
</template> </template>
<script> <script>
import {getStepLists, createStep, updateStep, deleteStep} from "@/api/mtm"; import {getStepLists, createStep, updateStep, deleteStep,getMaterialList} from "@/api/mtm";
import checkPermission from "@/utils/permission"; import checkPermission from "@/utils/permission";
import {getEquipmentAll} from "@/api/equipment"; import {getEquipmentAll} from "@/api/equipment";
import {upUrl, upHeaders} from "@/api/file"; import {upUrl, upHeaders} from "@/api/file";
import { import {
getStep,
getrecordformList, getrecordformList,
createrecordform, createrecordform,
updaterecordform, updaterecordform,
@ -442,6 +465,8 @@
return { return {
step: defaultstep, step: defaultstep,
stepList: [], stepList: [],
dialogFieldList: [],
productOptions: [],
upHeaders: upHeaders(), upHeaders: upHeaders(),
upUrl: upUrl(), upUrl: upUrl(),
fileList: { fileList: {
@ -501,6 +526,7 @@
'datetime': '日期时间', 'datetime': '日期时间',
'select': '单选', 'select': '单选',
'selects': '多选', 'selects': '多选',
'draw': '绘图模板',
}, },
typeoption: [{ typeoption: [{
value: 1, value: 1,
@ -547,6 +573,7 @@
label: '多选' label: '多选'
} }
], ],
formList:[],
typeoptions: [{ typeoptions: [{
value: 10, value: 10,
label: '生产记录' label: '生产记录'
@ -559,11 +586,22 @@
this.step.process = this.$route.params.id; this.step.process = this.$route.params.id;
this.getList(); this.getList();
this.getequipments() this.getequipments()
},
mounted(){
this.step.process = this.$route.params.id;
this.getProductList();
this.getFormList();
}, },
methods: { methods: {
getProductList(){
getMaterialList({page:0,type:1}).then((response) => {
if (response.data) {
this.productOptions = response.data;
}
})
},
//添加字段选项 //添加字段选项
addDomain() { addDomain(){
this.field_choice.push('') this.field_choice.push('')
}, },
//删除字段选项 //删除字段选项
@ -571,12 +609,15 @@
this.field_choice.splice(index, 1) this.field_choice.splice(index, 1)
}, },
handleLook(scope) { handleLook(scope) {
debugger;
console.log(scope);
this.dialogVisibleForm = true; this.dialogVisibleForm = true;
this.tableForm = Object.assign({}, scope.row); // copy obj this.dialogFieldList = [];
this.tableForm = Object.assign({}, scope.row);
this.formID = this.tableForm.id; this.formID = this.tableForm.id;
this.fieldLists(); getrffieldList({page:0,form:this.formID}).then((response) => {
if (response.data) {
this.dialogFieldList = response.data;
}
});
}, },
checkPermission, checkPermission,
//子工序列表 //子工序列表
@ -611,7 +652,6 @@
this.step.instruction = null; this.step.instruction = null;
}, },
handleFilter() { handleFilter() {
this.listQuery.page = 1; this.listQuery.page = 1;
this.getList(); this.getList();
@ -632,8 +672,8 @@
this.$refs["Form"].clearValidate(); this.$refs["Form"].clearValidate();
}); });
}, },
rowClick(row) {
rowClick(row) {
this.stepid = row.id; this.stepid = row.id;
this.recordformLists(); this.recordformLists();
}, },
@ -647,6 +687,7 @@
this.$refs["Form"].clearValidate(); this.$refs["Form"].clearValidate();
}); });
}, },
handleDeleteStep(scope) { handleDeleteStep(scope) {
this.$confirm("确认删除?", "警告", { this.$confirm("确认删除?", "警告", {
confirmButtonText: "确认", confirmButtonText: "确认",
@ -677,7 +718,6 @@
} }
}); });
} else { } else {
console.log(this.step)
createStep(this.step).then((res) => { createStep(this.step).then((res) => {
if (res.code >= 200) { if (res.code >= 200) {
this.getList(); this.getList();
@ -691,11 +731,12 @@
} }
}); });
}, },
handleCurrentChange(row) { handleCurrentChange(row) {
this.formID = row.id; this.formID = row.id;
this.fieldLists(); this.fieldLists();
}, },
recordformLists() { recordformLists() {
this.listQueryrecordform.step = this.stepid; this.listQueryrecordform.step = this.stepid;
this.listQueryrecordform.type = 10; this.listQueryrecordform.type = 10;
@ -703,32 +744,45 @@
if (response.data) { if (response.data) {
this.recordformList = response.data; this.recordformList = response.data;
} }
});
},
getFormList(){
getrecordformList({page:0,type:10}).then((response) => {
if (response.data) {
this.formList = response.data;
}
}); });
}, },
fieldLists() { fieldLists() {
this.listQueryfield.form = this.formID this.listQueryfield.form = this.formID;
getrffieldList(this.listQueryfield).then((response) => { getrffieldList(this.listQueryfield).then((response) => {
if (response.data) { if (response.data) {
this.fieldList = response.data; this.fieldList = response.data;
debugger;
console.log(this.fieldList)
} }
}); });
}, },
//新增记录表 //新增记录表
handleCreate() { handleCreate() {
if(this.stepid!==''&&this.stepid!==null&&this.stepid!==undefined){
this.recordform = Object.assign({}, defaultrecordform); this.recordform = Object.assign({}, defaultrecordform);
this.dialogType = "new"; this.dialogType = "new";
this.dialogVisible = true; this.dialogVisible = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs["Forms"].clearValidate(); this.$refs["Forms"].clearValidate();
}); });
}else{
this.$confirm("请选择子工序", "警告", {
confirmButtonText: "确认",
type: "error",
}) .then(async () => {
})
.catch(() => {
});
}
}, },
//新增字段 //新增字段
handlefieldCreate() { handlefieldCreate() {
this.field_choice = ['']; this.field_choice = [''];
this.field = Object.assign({}, defaultfield); this.field = Object.assign({}, defaultfield);
this.dialogType1 = "new"; this.dialogType1 = "new";
@ -762,7 +816,7 @@
}) })
.then(async () => { .then(async () => {
await deleterecordform(scope.row.id); await deleterecordform(scope.row.id);
this.recordformLists() this.recordformLists();
this.$message.success("成功"); this.$message.success("成功");
}) })
.catch((err) => { .catch((err) => {
@ -777,7 +831,7 @@
}) })
.then(async () => { .then(async () => {
await deleterffield(scope.row.id); await deleterffield(scope.row.id);
this.fieldLists() this.fieldLists();
this.$message.success("成功"); this.$message.success("成功");
}) })
.catch((err) => { .catch((err) => {
@ -789,21 +843,19 @@
if (valid) { if (valid) {
const isEdit = this.dialogType === "edit"; const isEdit = this.dialogType === "edit";
if (isEdit) { if (isEdit) {
this.recordform.step = this.stepid this.recordform.step = this.stepid;
updaterecordform(this.recordform.id, this.recordform).then((res) => { updaterecordform(this.recordform.id, this.recordform).then((res) => {
if (res.code >= 200) { if (res.code >= 200) {
this.recordformLists() this.recordformLists();
this.dialogVisible = false; this.dialogVisible = false;
this.$message.success("成功"); this.$message.success("成功");
} }
}); });
} else { } else {
this.recordform.step = this.stepid this.recordform.step = this.stepid;
createrecordform(this.recordform).then((res) => { createrecordform(this.recordform).then((res) => {
if (res.code >= 200) { if (res.code >= 200) {
this.recordformLists() this.recordformLists();
this.dialogVisible = false; this.dialogVisible = false;
this.$message.success("成功"); this.$message.success("成功");
} }
@ -823,7 +875,7 @@
this.field.field_choice = this.field_choice; this.field.field_choice = this.field_choice;
updaterffield(this.field.id, this.field).then((res) => { updaterffield(this.field.id, this.field).then((res) => {
if (res.code >= 200) { if (res.code >= 200) {
this.fieldLists() this.fieldLists();
this.dialogVisible1 = false; this.dialogVisible1 = false;
this.$message.success("成功"); this.$message.success("成功");
} }
@ -833,7 +885,7 @@
this.field.field_choice = this.field_choice; this.field.field_choice = this.field_choice;
createrffield(this.field).then((res) => { createrffield(this.field).then((res) => {
if (res.code >= 200) { if (res.code >= 200) {
this.fieldLists() this.fieldLists();
this.dialogVisible1 = false; this.dialogVisible1 = false;
this.$message.success("成功"); this.$message.success("成功");
} }

View File

@ -241,7 +241,14 @@
}, },
//检查表 //检查表
handlebind(scope) { handlebind(scope) {
this.$router.push({name: "MaterialDO", params: {id: scope.row.id},}) let materialItem = sessionStorage.getItem('materialItem');
if(materialItem){
sessionStorage.removeItem('materialItem');
sessionStorage.setItem('materialItem',JSON.stringify(scope.row));
}else{
sessionStorage.setItem('materialItem',JSON.stringify(scope.row));
}
this.$router.push({name: "MaterialDO", params: {id: scope.row.id}})
}, },
handleFilter() { handleFilter() {
this.listQuery.page = 1; this.listQuery.page = 1;

View File

@ -30,6 +30,9 @@
<el-table-column label="物料型号"> <el-table-column label="物料型号">
<template slot-scope="scope">{{ scope.row.material_.specification }}</template> <template slot-scope="scope">{{ scope.row.material_.specification }}</template>
</el-table-column> </el-table-column>
<!--<el-table-column label="物料品牌">
<template slot-scope="scope">{{ scope.row.brand }}</template>
</el-table-column>-->
<el-table-column label="采购数量"> <el-table-column label="采购数量">
<template slot-scope="scope">{{ scope.row.count }}</template> <template slot-scope="scope">{{ scope.row.count }}</template>
</el-table-column> </el-table-column>
@ -90,6 +93,9 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<!--<el-form-item label="物料品牌">
<el-input v-model="puorderTtem.brand" placeholder="规格型号"/>
</el-form-item>-->
</el-form> </el-form>
<div style="text-align: right"> <div style="text-align: right">
<el-button type="danger" @click="dialogVisible = false">取消</el-button> <el-button type="danger" @click="dialogVisible = false">取消</el-button>

View File

@ -24,8 +24,15 @@
v-el-height-adaptive-table="{bottomOffset: 50}" v-el-height-adaptive-table="{bottomOffset: 50}"
> >
<el-table-column type="index" width="50"/> <el-table-column type="index" width="50"/>
<el-table-column label="任务编号">
<template slot-scope="scope">
<div v-for="(item,index) in scope.row.out_detail" :key="index">
{{item.plan.number}}
</div>
</template>
</el-table-column>
<el-table-column label="子工序工序"> <el-table-column label="子工序工序">
<template slot-scope="scope">{{ scope.row.step_.name }}</template> <template slot-scope="scope">{{scope.row.step_.name }}</template>
</el-table-column> </el-table-column>
<el-table-column label="是否提交"> <el-table-column label="是否提交">
<template slot-scope="scope"> <template slot-scope="scope">
@ -39,30 +46,25 @@
<span v-else>{{scope.row.create_by_.username}}</span> <span v-else>{{scope.row.create_by_.username}}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="过程记录表"> <el-table-column label="产品名称">
<template v-if="scope.row.record_" slot-scope="scope"> <template slot-scope="scope">
<el-tag <div v-for="(item,index) in scope.row.out_detail" :key="index">
v-for="item in scope.row.record_" {{item.product.name}}
:key="item.id" </div>
:label="item.name" </template>
:value="item.id" </el-table-column>
> <el-table-column label="规格型号">
{{item.name}} <template slot-scope="scope">
</el-tag> <div v-for="(item,index) in scope.row.out_detail" :key="index">
{{item.product.specification}}
</div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="产品数量"> <el-table-column label="产品数量">
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.count_work }} <div v-for="(item,index) in scope.row.out_detail" :key="index">
</template> {{item.count}}
</el-table-column> </div>
<el-table-column label="生产设备">
<template slot-scope="scope" v-if="scope.row.equip_">
<el-tag v-for="item in scope.row.equip_"
:key="item.id"
:label="item.number"
:value="item.id">{{item.number}}
</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="创建时间"> <el-table-column label="创建时间">

View File

@ -10,7 +10,23 @@
>查看作业指导书 >查看作业指导书
</el-button> </el-button>
</div> </div>
<el-form <el-descriptions :column="3" border style="margin-bottom: 20px">
<el-descriptions-item label="任务编号" v-if="operationData.number">{{operationData.number}}</el-descriptions-item>
<el-descriptions-item label="产品名称" v-if="operationData.name">{{operationData.name}}</el-descriptions-item>
<el-descriptions-item label="规格型号" v-if="operationData.specification">{{operationData.specification}}</el-descriptions-item>
<el-descriptions-item label="子工序">{{operationData.step_.name}}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{operationData.create_time}}</el-descriptions-item>
<el-descriptions-item label="操作人">{{operationData.user}}</el-descriptions-item>
</el-descriptions>
<el-button
v-if="operationData.is_submited == false"
type="primary"
style="float: right"
@click="handlesubmit()"
>
提交本次操作
</el-button>
<!-- <el-form
ref="form" ref="form"
inline="true" inline="true"
:model="operationData" :model="operationData"
@ -22,6 +38,24 @@
disabled="disabled" disabled="disabled"
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="任务编号" v-show="operationData.number">
<el-input
v-model="operationData.number"
disabled="disabled"
></el-input>
</el-form-item>
<el-form-item label="产品名称" v-show="operationData.name">
<el-input
v-model="operationData.name"
disabled="disabled"
></el-input>
</el-form-item>
<el-form-item label="规格型号" v-show="operationData.specification">
<el-input
v-model="operationData.specification"
disabled="disabled"
></el-input>
</el-form-item>
<el-form-item label="操作人"> <el-form-item label="操作人">
<el-input <el-input
v-model="operationData.user" v-model="operationData.user"
@ -35,16 +69,9 @@
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button
v-if="operationData.is_submited == false"
type="primary"
style="float: right"
@click="handlesubmit()"
>
提交本次操作
</el-button>
</el-form-item> </el-form-item>
<!-- &lt;!&ndash;
<el-form-item label="边角料"> <el-form-item label="边角料">
<el-radio-group v-model="operationData.use_scrap"> <el-radio-group v-model="operationData.use_scrap">
<el-radio border <el-radio border
@ -58,7 +85,7 @@
<el-form-item label="备注" v-if="operationData.use_scrap"> <el-form-item label="备注" v-if="operationData.use_scrap">
<el-input type="textarea" v-model="operationData.remark"></el-input> <el-input type="textarea" v-model="operationData.remark"></el-input>
</el-form-item> </el-form-item>
!--> !&ndash;&gt;
<el-form-item v-if="operationData.use_scrap"> <el-form-item v-if="operationData.use_scrap">
<el-button <el-button
type="primary" type="primary"
@ -68,7 +95,7 @@
</el-button> </el-button>
<el-button>取消</el-button> <el-button>取消</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>-->
<el-drawer <el-drawer
title="作业指导书查看!" title="作业指导书查看!"
:visible.sync="drawer" :visible.sync="drawer"
@ -814,7 +841,7 @@
}; };
}, },
created() { mounted() {
this.id = this.$route.params.id; //操作ID this.id = this.$route.params.id; //操作ID
this.readbook(); this.readbook();
this.getList(); //边角料 this.getList(); //边角料
@ -892,6 +919,18 @@
getoperation(this.id).then((response) => { getoperation(this.id).then((response) => {
if (response.data) { if (response.data) {
this.operationData = response.data; this.operationData = response.data;
let names = '';
let numbers = '';
let specification = '';
response.data.out_detail.forEach(item=>{
names +=item.product.name;
numbers +=item.plan.number;
specification +=item.product.specification;
});
this.operationData.number = numbers;
this.operationData.name = names;
this.operationData.specification = specification;
if (response.data.is_submited) { if (response.data.is_submited) {
this.operationData.user = response.data.create_by_.name; this.operationData.user = response.data.create_by_.name;
} else { } else {