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

This commit is contained in:
caoqianming 2021-12-13 13:50:21 +08:00
commit 53428f022b
9 changed files with 3696 additions and 62 deletions

View File

@ -53,6 +53,10 @@ export default {
.adopt input.el-input__inner{
border: 1px solid #46ce7a!important;
}
.fail .originBlock input.el-input__inner,
.adopt .originBlock input.el-input__inner{
border: none!important;
}
#customerForm .el-form-item{
margin-bottom: 30px!important;
}

View File

@ -123,7 +123,7 @@
<el-row v-show="hasPicture">
<el-form-item label="图表">
<div>
<img id="canvasImg" src="./../../assets/glass.png" style="width:500px;height: 300px;display: none">
<img id="canvasImg" :src="img" style="width:500px;height: 300px;display: none">
<div style="position: relative;display: flex;flex-direction: column;
border: 1px solid #DCDFE6;">
<canvas id="canvas" width="500" height="300">
@ -174,10 +174,6 @@
default: () => {
return []
}} ,
step: {
type:String,
default:''
},
formID: {
type:Number,
default:0
@ -195,7 +191,6 @@
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();
@ -219,6 +214,12 @@
obj = item;
that.judgeList.push(obj)
});
let imag= this.formData.filter(item => {
return item.field_type === 'draw';
});
that.img = new Image();
that.img.crossOrigin = '';
that.img = 'http://47.95.0.242:2222'+imag[0].draw_template;
setTimeout(function(){
that.canvasInit();
},500);
@ -239,6 +240,7 @@
myCanvas_rect:null,
Txt:null,
word:null,
img:null,
widths:0,
heights:0,
lineW:3,
@ -246,7 +248,6 @@
imgUrl:'',
imgData:'',
canvasImg:'',
checkType:'',
formData:[],//表单数组
judgeList:[],//判定数组
is_testok:true,
@ -399,6 +400,7 @@
//画布添加背景模板图
draw(){
let canvasImg = document.getElementById("canvasImg");
canvasImg.setAttribute("crossOrigin",'anonymous');
canvasImg.style.width = '500px';
canvasImg.style.height = '300px';
this.ctx.drawImage(canvasImg,0,0,500,300);
@ -629,10 +631,10 @@
});
if(real.length>0){
that.is_testok = false;
alert("检验不合格!")
// alert("检验不合格!")
}else{
that.is_testok = true;
alert("检验合格!")
// alert("检验合格!")
}
},
//提交检查项目

View File

@ -0,0 +1,878 @@
<template>
<div>
<el-form
id="customerForm"
ref="checkForm"
label-width="100px"
:model="checkForm"
>
<el-row>
<el-col
v-for="(item, $index) in formData"
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'"
:label="item.field_name"
>
<el-input
disabled
class="halfWidth originBlock"
v-model="originForm[item.field_key]"
placeholder="请输入"
@input="keyChange($index,item.field_key)"
/>
<el-input
class="halfWidth"
v-model="checkForm[item.field_key]"
placeholder="请输入"
@input="keyChange($index,item.field_key)"
/>
</el-form-item>
<el-form-item
v-else-if="item.field_type === 'int'"
:label="item.field_name"
>
<el-input
disabled
class="halfWidth originBlock"
v-model="originForm[item.field_key]"
type="number"
placeholder="请输入"
@input="keyChange($index,item.field_key)"
/>
<el-input
class="halfWidth"
v-model="checkForm[item.field_key]"
type="number"
placeholder="请输入"
@input="keyChange($index,item.field_key)"
/>
</el-form-item>
<el-form-item
v-else-if="item.field_type === 'float'"
:label="item.field_name"
>
<el-input
disabled
class="halfWidth originBlock"
v-model="originForm[item.field_key]"
type="number"
placeholder="请输入"
@input="keyChange($index,item.field_key)"
/>
<el-input
class="halfWidth"
v-model="checkForm[item.field_key]"
type="number"
placeholder="请输入"
@input="keyChange($index,item.field_key)"
/>
</el-form-item>
<el-form-item
v-else-if="item.field_type === 'date'"
:label="item.field_name"
>
<el-date-picker
disabled
v-model="originForm[item.field_key]"
class="halfWidth originBlock"
type="date"
placeholder="选择日期"
value-format="yyyy-MM-dd"
@change="keyChange($index,item.field_key)"
/>
<el-date-picker
v-model="checkForm[item.field_key]"
class="halfWidth"
type="date"
placeholder="选择日期"
value-format="yyyy-MM-dd"
@change="keyChange($index,item.field_key)"
/>
</el-form-item>
<el-form-item
v-else-if="item.field_type === 'datetime'"
:label="item.field_name"
>
<el-date-picker
disabled
v-model="originForm[item.field_key]"
class="halfWidth originBlock"
type="datetime"
placeholder="选择日期"
value-format="yyyy-MM-dd HH:mm:ss"
@change="keyChange($index,item.field_key)"
/>
<el-date-picker
v-model="checkForm[item.field_key]"
class="halfWidth"
type="datetime"
placeholder="选择日期"
value-format="yyyy-MM-dd HH:mm:ss"
@change="keyChange($index,item.field_key)"
/>
</el-form-item>
<el-form-item
v-else-if="item.field_type === 'select'"
:label="item.field_name"
>
<el-select
disabled
v-model="originForm[item.field_key]"
class="halfWidth originBlock"
placeholder="请选择"
@change="keyChange($index,item.field_key)"
>
<el-option
v-for="item1 in item.field_choice"
:key="item1"
:label="item1"
:value="item1"
/>
</el-select>
<el-select
v-model="checkForm[item.field_key]"
class="halfWidth"
placeholder="请选择"
@change="keyChange($index,item.field_key)"
>
<el-option
v-for="item1 in item.field_choice"
:key="item1"
:label="item1"
:value="item1"
/>
</el-select>
</el-form-item>
<el-form-item
v-else-if="item.field_type === 'selects'"
:label="item.field_name"
>
<el-select
disabled
v-model="originForm[item.field_key]"
class="halfWidth originBlock"
multiple
placeholder="请选择"
@change="keyChange($index,item.field_key)"
>
<el-option
v-for="item1 in item.field_choice"
:key="item1"
:label="item1"
:value="item1"
@change="keyChange($index,item.field_key)"
>
</el-option>
</el-select>
<el-select
v-model="checkForm[item.field_key]"
class="halfWidth"
multiple
placeholder="请选择"
@change="keyChange($index,item.field_key)"
>
<el-option
v-for="item1 in item.field_choice"
:key="item1"
:label="item1"
:value="item1"
@change="keyChange($index,item.field_key)"
>
</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">
<el-form-item label="图表">
<div class="halfWidth">
<img :src="originImg">
</div>
<div class="halfWidth">
<img id="canvasImg" :src="img" style="width:500px;height: 300px;display: none">
<div style="position: relative;display: flex;flex-direction: column;
border: 1px solid #DCDFE6;">
<canvas id="canvas" width="500" height="300">
您的浏览器不支持绘图请升级或更换浏览器
</canvas>
<input type="text" value="" class="hide" id="txt" placeholder="请输入文字">
<textarea class="hide" id="word" cols="15" rows="5" placeholder="请输入文字" autofocus></textarea>
<input id="inputV" type="hidden" value="1">
<div class="canvasBtnWrap">
<div class="canvasBtn" @click="error1">标记</div>
<div class="canvasBtn" @click="word1()">文字</div>
<div class="canvasBtn" @click="back()">回退</div>
</div>
<div id="res"></div>
</div>
</div>
</el-form-item>
</el-row>
<el-row>
<el-form-item label="是否合格">
<el-radio v-model="is_testok" :label="testokTrue">检查合格</el-radio>
<el-radio v-model="is_testok" :label="testokFalse">检查不合格</el-radio>
</el-form-item>
<div class="dialog-footer" style="text-align: right">
<el-button @click="innerVisible = false"> </el-button>
<el-button type="primary" @click="submitfield">提交检查项目</el-button>
</div>
</el-row>
</el-form>
</div>
</template>
<script>
import { upFile } from "@/api/file";
let preDrawAry = [];
export default {
name: "review",
props: {
results:{
type:Array,
default: () => {
return []
}} ,
originList:{
type:Array,
default: () => {
return []
}} ,
formID: {
type:Number,
default:0
},
wproduct: {
type:Number,
default:0
},
origintest: {
type:Number,
default:0
},
hasPicture:{
type:Boolean,
default:false
}
},
mounted() {
let that = this;
this.form = this.formID;
let formData=this.results;
this.origins=this.originList;
that.wproductId=this.wproduct;
that.origin_test=this.origintest;
formData.forEach(item => {
let obj = new Object();
obj = item;
obj.is_testok = null;//是否合格
that.formData.push(obj)
});
that.formData=[...that.formData];
//当前表的数据存储
for(let i=0;i<this.results.length;i++){
let key = this.results[i].field_key;
//checkForm接收表单数据的对象
that.checkForm[key]='';
that.$set(that.checkForm,key,'')
}
//判定项
let listJudge = this.formData.filter(item => {
return item.need_judge === true;
});
listJudge.forEach(item => {
let obj = new Object();
obj = item;
that.judgeList.push(obj)
});
//原始表的数据
for(let i=0;i<this.origins.length;i++){
let key = this.origins[i].field_key;
that.originForm[key]=this.origins[i].field_key;
that.$set(that.originForm,key,this.origins[i].field_value)
}
//图片地址
let imag= this.formData.filter(item => {
return item.field_type === 'draw';
});
that.img = 'http://47.95.0.242:2222'+imag[0].draw_template;
let originImag= this.origins.filter(item => {
return item.field_type === 'draw';
});
that.originImg = new Image();
that.originImg.crossOrigin = '';
that.originImg = originImag[0].field_value;
listJudge.forEach(item => {
let obj = new Object();
obj = item;
that.judgeList.push(obj)
});
setTimeout(function(){
that.canvasInit();
},500);
},
data(){
return{
field:[],
origins:[],
checkForm:{},
originForm:{},
testrecord:{
form:this.formID,
record_data:[],
is_testok:true,
wproduct:null,
},
origin_test:null,
canvas:null,
wproductId:null,
ctx:null,
myCanvas_rect:null,
Txt:null,
word:null,
img:null,
originImg:null,
widths:0,
heights:0,
lineW:3,
colorF:"#e42343",
imgUrl:'',
imgData:'',
canvasImg:'',
checkType:'',
formData:[],//表单数组
judgeList:[],//判定数组
is_testok:true,
testokTrue:true,
testokFalse:false,
}
},
methods:{
filterBlock(parent,rule){
// debugger;
let that = this;
if(parent!==''&&parent!==null&&parent!==undefined){
if(rule!==''&&rule!==null&&rule!==undefined){
let reg = /\{(.+?)\}/g;
if(rule.indexOf('||')>-1||rule.indexOf('&&')>-1){
let tam = '', arr = [];
if(rule.indexOf('||')>-1){
arr = rule.split('||');
}else{
arr = rule.split('&&');
}
for (let i = 0;i<arr.length;i++){
//获取判断依据
let a = '';
a = arr[i].replace(/`/g,'');
a = '`'+ a+'`';
let tem =a.match(reg)[0];
let ky = tem.replace(/\{|\}/g, '');//qipao
if(that.checkForm[ky]){
//替换变量
a = a.replace(ky, 'yyy');
let yyy = "'"+that.checkForm[ky]+"'";
if(eval(eval( a))){
tam += 'true';
}else{
tam += 'false';
}
}else{
tam += 'false';
}
}
let rea = true;
if(rule.indexOf('||')>-1){
if( tam.indexOf('true')>-1){
rea = true;
}else{
rea = false;
}
}else{
if( tam.indexOf('false')>-1){
rea = false;
}else{
rea = true;
}
}
return rea;
}else{
let temp =rule.match(reg)[0];
let key = temp.replace(/\{|\}/g, '');//qipao
let a = rule.replace(key, 'yy');
a = a.replace(key, 'yy');
let yy = "'"+that.checkForm[key]+"'";
return eval(eval(a));
// return eval("'"+y+"'"+str);
}
}else{
return false;
}
}else{
return true;
}
},
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<arr.length;i++){
//获取判断依据
let a = '`'+ arr[i]+'`';
let tem =a.match(reg)[0];
let ky = tem.replace(/\{|\}/g, '');//qipao
//有值时进行判断
if(that.checkForm[ky]!==''&&that.checkForm[ky]!==null&&that.checkForm[ky]!==undefined){
//替换变量
a = a.replace(ky, 'yyy');
let yyy = "'"+that.checkForm[ky]+"'";
if(eval(eval( a))){
str += 'true';
}else{
str += 'false';
}
}
}
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)
}
}
that.$forceUpdate();
}
that.$forceUpdate();
that.judgeList = that.formData.filter(item => {
return item.need_judge === true;
});
that.judgeForm();
})
},
/* 图片保存 */
//初始化canvas
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);
},
//画布添加背景模板图
draw(){
let canvasImg = document.getElementById("canvasImg");
canvasImg.setAttribute("crossOrigin",'anonymous');
canvasImg.style.width = '500px';
canvasImg.style.height = '300px';
this.ctx.drawImage(canvasImg,0,0,500,300);
},
// 叉号
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);
}
}
},
// 撤销
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 that = this;
this.word.style.display="none";
this.Txt.style.display="none";
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);
that.imgUrl=res.data.field;
// console.log(res);
})
},
//base64ToFile
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;
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);
}
//对每个条件进行判定如果符合
for (let i = 0;i<arr.length;i++){
//获取判断依据
let a = '`'+ arr[i]+'`';
let tem =a.match(reg)[0];
let ky = tem.replace(/\{|\}/g, '');//qipao
//有值时进行判断
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';
}
}
}
if(item.indexOf('&&')>-1){
if(str.indexOf('false')>-1){
that.judgeList[i].is_testok = true;
}else{
that.judgeList[i].is_testok = false;
}
}else{
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.is_testok===false;
});
if(real.length>0){
that.is_testok = false;
// alert("检验不合格!")
}else{
that.is_testok = true;
// alert("检验合格!")
}
},
//提交检查项目
submitfield() {
let that = this;
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) => {
that.field.push({
form_field: item.id,
field_value: that.checkForm[item.field_key],
is_testok: item.is_testok//单项检查结果
});
});
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);
},
}
}
</script>
<style scoped>
canvas {
width:500px!important;
/*border: 1px solid #000000;*/
cursor: crosshair;
margin: auto;
}
.canvasBtnWrap {
display: flex;
/*flex-direction: column;*/
/*width: 80px;*/
/*padding-left: 20px;*/
justify-content: flex-end;
}
.canvasBtn {
width: 70px;
height: 35px;
line-height: 35px;
border: 1px solid #aaaaaa;
text-align: center;
border-radius: 15px;
margin-right: 10px;
margin-bottom: 10px;
}
.hide {
display: none;
}
#txt {
position: absolute;
top: 1%;
left: 1%;
width: 150px;
height: 30px;
border: 1px solid #e42343;
}
#word {
position: absolute;
width: 200px;
height: 70px;
padding: 0 2px;
background: none;
color: #e42343;
border: 1px dashed #b9b9b9;
}
#word::-webkit-input-placeholder {
color: #e42343;
}
#word::-moz-placeholder {
color: #e42343;
}
#word::placeholder {
color: #e42343;
}
#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;
}
.halfWidth{
width: 49%!important;
display: inline-block!important;
}
</style>

View File

@ -4,6 +4,8 @@ import 'normalize.css/normalize.css' // A modern alternative to CSS resets
import Element from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import "element-ui/lib/theme-chalk/base.css";
import CollapseTransition from "element-ui/lib/transitions/collapse-transition";
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n
import '@/styles/index.scss' // global css
@ -11,11 +13,13 @@ import '@/styles/index.scss' // global css
import App from './App'
import store from './store'
import router from './router'
import { plugin } from "vue-function-api";
import '@/icons' // icon
import '@/permission' // permission control
import tableHeight from '@/directive/el-table/index'
Vue.use(tableHeight)
Vue.component(CollapseTransition.name, CollapseTransition);
Vue.use(tableHeight).use(plugin);
/**
* If you don't want to use mock-server
* you want to use MockJs for mock api

View File

@ -178,6 +178,14 @@ export const asyncRoutes = [
component: () => import('@/views/pm/resources'),
meta: { title: '生产资源配置', icon: 'example', perms: ['pm_resources'] }
}
,
{
path: 'gantt',
name: 'gantt',
component: () => import('@/views/pm/gantt'),
meta: { title: '甘特图', perms: ['vendor_manage'] },
hidden: true
},
]
}
,

View File

@ -0,0 +1,396 @@
<template>
<div class="tableMneu">
<div
class="mask"
v-if="isShowHeaderBox || menuOpen"
@click="maskClick"
></div>
<el-table
ref="tableMenu"
:data="tableData"
border
fit
style="width: 100%"
row-key="id"
height="100%"
default-expand-all
highlight-current-row
@row-click="handlerRowClick"
@expand-change="handlerExpand"
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
>
<el-table-column
v-for="col in columns"
:prop="col.prop"
:key="col.prop"
:label="col.label"
:align="col.align"
:resizable="col.resizable"
>
<template slot-scope="scope">
<span v-if="col.prop == 'type'">{{
projectType[scope.row.type]
}}</span>
<span v-else>{{ scope.row[col.prop] }}</span>
</template>
</el-table-column>
</el-table>
<el-collapse-transition>
</el-collapse-transition>
<transition name="el-zoom-in-top">
<div class="menulist" v-show="menuOpen" ref="menulist">
<div
class="item"
v-for="(item, index) in menuLists"
@click="handleMenuClick(index, item)"
:key="item + index"
>
{{ item }}
</div>
</div>
</transition>
</div>
</template>
<script>
export default {
props: {
list: Array,
BGScrollTop: Number
},
computed: {
tableData() {
return this.list;
}
},
watch: {
BGScrollTop: {
handler: function(newValue) {
let table = this.$refs.tableMenu.bodyWrapper;
// console.log(newValue, table);
table.scrollTo(0, newValue);
// table.scrollTo({
// top: newValue,
// left: 0,
// behavior: "smooth"
// });
}
}
},
data() {
return {
// tableData: [],
checkList: [],
isShowHeaderBox: false,
menuOpen: false,
headerList: {
name: true,
ower: true,
per: true,
type: true
},
projectType: {
1: "计划项目",
2: "里程碑",
3: "分组"
},
menuLists: ["编辑", "里程碑", "分组", "删除"],
columns: [
{
prop: "name",
label: "名称",
width: "200px",
resizable: false
},
{
prop: "ower",
label: "负责人",
align: "center",
resizable: false
},
{
prop: "per",
label: "进度",
align: "center",
resizable: false
},
{
prop: "type",
label: "项目类型",
align: "center",
resizable: false
}
],
columnsCopy: [
{
prop: "name",
label: "名称",
width: "200px",
resizable: false
},
{
prop: "ower",
label: "负责人",
align: "center",
resizable: false
},
{
prop: "per",
label: "进度",
align: "center",
resizable: false
},
{
prop: "type",
label: "项目类型",
align: "center",
resizable: false
}
],
//当前点击的row
currentRow: {}
};
},
methods: {
handlerWatchScroll() {
let table = this.$refs.tableMenu.bodyWrapper;
table.addEventListener("scroll", e => {
// console.log(e.srcElement.scrollTop);
this.$emit("TableScrollTop", e.srcElement.scrollTop);
});
},
handlerSelect(row) {
this.$refs.tableMenu.setCurrentRow(row);
},
handlerExpand(row, expand) {
// console.log(row, expanded);
this.$emit("handlerExpand", row, expand);
},
handlerSave() {
this.isShowHeaderBox = false;
let arr = [];
this.columnsCopy.forEach(item => {
if (this.headerList[item.prop] == true) {
arr.push(item);
}
});
this.columns = arr;
},
maskClick() {
this.isShowHeaderBox = false;
this.menuOpen = false;
this.currentRow = {};
},
handlerRowClick(row, column) {
// console.log(column);
if (row.type != 3) {
this.$emit("handlerRowClick", row);
}
},
handleRowMore(row, e) {
this.menuLists = ["编辑", "里程碑", "分组", "删除"];
if (row.parentId) {
this.menuLists = ["编辑", "里程碑", "删除"];
}
if (row.type == "1") {
this.menuLists[1] = "里程碑";
} else if (row.type == "2") {
this.menuLists[1] = "计划项目";
} else if (row.type == "3") {
this.menuLists = ["编辑", "添加任务", "删除分组"];
}
this.menuOpen = true;
this.currentRow = row;
let s = this.$refs.menulist.style;
s.top = e.y - 10 - 40 + "px";
s.left = e.x + 20 + "px";
},
handleShowHeaderCheckBox() {
this.isShowHeaderBox = !this.isShowHeaderBox;
},
handleMenuClick(index, name) {
this.menuOpen = false;
if (index == 3) {
this.$confirm("此操作将永久删除该项目, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
center: true
})
.then(() => {
this.$emit("handlerDel", this.currentRow);
})
.catch(() => {});
} else if (index == 1) {
if (this.currentRow.type == 3) {
console.log("添加任务");
this.$emit("handleGroupAdd", this.currentRow);
return;
}
this.$confirm(`确定转为${this.menuLists[1]}`, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "info",
center: true
})
.then(() => {
if (this.currentRow.type == "1") {
this.$emit("milestone", this.currentRow);
} else if (this.currentRow.type == "2") {
this.$emit("planProject", this.currentRow);
}
})
.catch(() => {});
} else if (index == 0) {
this.$emit("handlerEdit", this.currentRow);
} else if (index == 2) {
console.log(name);
if (this.currentRow.type == 3 && name == "删除分组") {
this.$confirm("此操作将永久删除该分组及其子项目, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
center: true
})
.then(() => {
this.$emit("handlerDel", this.currentRow);
})
.catch(() => {});
return;
}
if (name == "删除") {
this.$confirm("此操作将永久删除该项目, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
center: true
})
.then(() => {
this.$emit("handlerDel", this.currentRow);
})
.catch(() => {});
return;
}
this.$confirm(`确定转为分组`, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "info",
center: true
})
.then(() => {
this.$emit("handlerGroup", this.currentRow);
})
.catch(() => {});
}
}
},
mounted() {
this.handlerWatchScroll();
}
};
</script>
<style lang="scss" scoped>
.tableMneu {
width: 100%;
position: relative;
height: 100%;
.mask {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
background-color: transparent;
z-index: 9999;
}
.icons {
cursor: pointer;
&:hover {
color: #409eff;
}
}
.menulist {
width: 100px;
position: absolute;
background-color: rgb(255, 255, 255);
border-radius: 5px;
border: 1px solid #ebeef5;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
transition: 0.3s;
width: 70px;
z-index: 9999;
.item {
background-color: rgb(255, 255, 255);
line-height: 30px;
text-align: center;
font-size: 12px;
color: rgb(102, 102, 102);
cursor: pointer;
height: 30px;
}
.item:hover {
color: #409eff;
}
}
.headerBox {
z-index: 9999;
position: absolute;
right: -128px;
top: 50px;
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);
width: 170px;
background-color: #fff;
&::after {
content: " ";
position: absolute;
top: -5px;
left: 16px;
width: 0;
height: 0;
border-right: 7px solid transparent;
border-left: 7px solid transparent;
border-bottom: 7px solid #fff;
}
.title {
margin: 0;
padding: 8px 16px;
min-height: 32px;
border-bottom: 1px solid #e9e9e9;
color: #303030;
font-weight: 500;
}
.main {
.line {
padding: 8px 10px;
display: flex;
flex-direction: row;
align-items: center;
width: 150px;
.pre {
flex: 1 1 auto;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
}
}
</style>
<style lang="scss" >
.tableMneu {
.el-table th.gutter {
display: table-cell !important;
}
.el-table td,
.el-table th {
padding: 8px 0;
}
.el-table--border td {
border-right: none;
}
}
</style>

View File

@ -0,0 +1,173 @@
<template>
<div class="slider" ref="slider" :style="{ width: '100%' }">
<div class="process" :style="{ width }" style="font-size: 12px;color: #ffffff;text-align: right">
{{ per }}
</div>
<div class="process1" :style="{width:process1Width}" style="font-size: 12px;color: #ffffff;text-align: right"> {{ per1 }}</div>
</div>
</template>
<script>
export default {
props: ["min", "max", "value", "widths", "per1", "id", "parentId"],
data() {
return {
//滚动条DOM元素
slider: null,
//拖拽DOM元素
thunk: null,
//当前值
per: this.value,
perOk: this.per1,
//当前是否拖拽tip
isMove: false,
// process1Width:'10px',
};
},
watch: {
value(newValue, oldValue) {
this.per = newValue;
}
},
methods: {
thunkMousedown(e) {
let width = parseInt(this.width);
let disX = e.clientX;
this.$emit("thunkMousedown");
this.isMove = true;
console.log(this.isMove);
document.onmousemove = e => {
let newWidth = e.clientX - disX + width;
let scale = newWidth / this.slider.offsetWidth;
this.per = Math.ceil((this.max - this.min) * scale + this.min);
this.per = Math.max(this.per, this.min);
this.per = Math.min(this.per, this.max);
this.$emit("thunkMousemove", e, this.index);
};
document.onmouseup = event => {
this.isMove = false;
this.$emit(
"thunkMouseup",
parseInt(this.scale * 100),
event,
this.id,
this.parentId
);
document.onmousemove = document.onmouseup = null;
};
return false;
}
},
//渲染到页面的时候
mounted() {
this.slider = this.$refs.slider;
this.thunk = this.$refs.trunk;
},
computed: {
scale() {
return (this.per - this.min) / (this.max - this.min);
},
width() {
if (this.slider) {
return this.widths * this.scale + "px";
} else {
return 0 + "px";
}
},
process1Width() {
if (this.slider) {
let scale1 = (this.perOk - this.min) / (this.max - this.min);
return this.widths * scale1 + "px";
} else {
return 0 + "px";
}
},
left() {
if (this.slider) {
return this.widths * this.scale - this.thunk.offsetWidth / 2 + "px";
} else {
return 0 + "px";
}
}
}
};
</script>
<style>
.box {
margin: 100px auto 0;
width: 80%;
}
.clear:after {
content: "";
display: block;
clear: both;
}
.slider {
position: relative;
height: 20px;
background: #e4e7ed;
border-radius: 3px;
cursor: move;
user-select: none;
}
.slider .process {
position: absolute;
left: 0;
top: 0;
width: 112px;
height: 20px;
border-radius: 3px;
background: #409eff;
}
.slider .process1 {
position: absolute;
left: 0;
top: 0;
width: 10px;
height: 20px;
border-radius: 3px;
background: #11c750;
}
.slider .thunk {
position: absolute;
left: 100px;
top: -7px;
width: 20px;
height: 20px;
}
.slider .block {
transition: 0.2s all;
}
.slider .block i {
font-size: 25px;
position: relative;
left: -3px;
top: 15px;
cursor: pointer;
}
.slider .tips {
position: absolute;
left: -3px;
bottom: 0px;
font-size: 12px;
line-height: 24px;
min-width: 15px;
text-align: center;
padding: 1px 5px;
background: #000;
border-radius: 5px;
height: 24px;
color: #fff;
}
.slider .tips i {
position: absolute;
margin-left: -5px;
left: 50%;
bottom: -9px;
font-size: 16px;
color: #000;
}
.slider .block:hover {
transform: scale(1.1);
opacity: 0.6;
}
</style>

File diff suppressed because it is too large Load Diff

View File

@ -34,10 +34,9 @@
<template slot-scope="scope">
<el-link
v-if="checkPermission(['warehouse_update'])"
@click="handleInspection(scope,'view')"
@click="handleInspection(scope)"
>检验
</el-link
>
</el-link>
</template>
</el-table-column>
</el-table>
@ -74,7 +73,6 @@
{{ actstate_[scope.row.act_state] }}
</template>
</el-table-column>
<el-table-column label="所在子工序">
<template slot-scope="scope">{{ scope.row.step_.name }}</template>
</el-table-column>
@ -82,8 +80,8 @@
<template slot-scope="scope">
<el-link
v-if="checkPermission(['warehouse_update'])"
@click="handleInspection(scope,'review')"
>
@click="handleReview(scope)"
>
检验
</el-link>
</template>
@ -226,7 +224,6 @@
:results="fieldList"
:hasPicture="hasPicture"
:formID="recordform"
:step="step"
:wproduct="wproduct"
@formFunc="formFunc"
/>
@ -238,6 +235,21 @@
<el-button type="primary" @click="submitrecordform">填写检查项目</el-button>
</div>
</el-dialog>
<el-dialog
width="60%"
:title="formName"
:visible.sync="limitedReview"
>
<reviewForm
:results="fieldList"
:originList="originList"
:formID="recordform"
:hasPicture="hasPicture"
:wproduct="wproduct"
:origintest="origintest"
@formFunc="formFunc"
/>
</el-dialog>
<el-dialog title="半成品入库" :close-on-click-modal="false" :visible.sync="dialogFormVisible">
<el-form :model="form">
<el-form-item label="仓库" :label-width="formLabelWidth">
@ -296,6 +308,7 @@
</template>
<script>
import customForm from '@/components/customForm/index';
import reviewForm from '@/components/customForm/review';
import {getwproductList, wproductTest, wproductPutin, createputins,wproductReview} from "@/api/wpm";
import checkPermission from "@/utils/permission";
import {getWarehouseList} from "@/api/inm";
@ -304,7 +317,7 @@
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
const defaultetestitem = {};
export default {
components: {Pagination, customForm},
components: {Pagination, customForm,reviewForm},
data() {
return {
testitem: defaultetestitem,
@ -362,6 +375,7 @@
options: [],
listLoading: true,
fieldList: [],
originList: [],
is_testok: "true",
field: [],
recordformList: [],
@ -370,12 +384,13 @@
listQueryrecordform: {
page: 0,
},
step:'view',
origintest:null,
mutipID: [],
wproduct: null,
hasPicture: false,
outerVisible: false,
innerVisible: false,
limitedReview: false,
dialogFormVisible: false,
dialogFormVisibles: false,
testrecord: {},
@ -476,9 +491,9 @@
}
});
},
handleInspection(scope,step) {
handleInspection(scope) {
//调该物料对应的检查表
this.step = step;
// this.step = step;
this.outerVisible = true;
this.wproduct = scope.row.id;//半成品ID
this.wproductactstate = scope.row.act_state;//半成品状态
@ -491,6 +506,30 @@
}
});
},
//半产品复检
handleReview(scope) {
let that = this;
this.wproduct = scope.row.id;//半成品ID
wproductReview({ wproduct: this.wproduct}).then((response) => {
if (response.data) {
that.hasPicture = false;
that.formName = response.data.name;
let fieldList = response.data.form_fields;
that.fieldList = [...fieldList];
that.origintest = response.data.origin_test.id;
that.recordform = response.data.origin_test.form;
let originList = response.data.origin_test.record_data_;
that.originList = [...originList];
let arr = fieldList.filter(item => {
return item.field_type === 'draw'
});
if (arr.length > 0) {
that.hasPicture = true;
}
this.limitedReview = true;
}
});
},
recordformChange() {
let that = this;
let arr = this.recordformList.filter(item => {
@ -502,61 +541,37 @@
submitrecordform() {
let that = this;
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;
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;
}
});
}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;
}
});
}
that.innerVisible = true;
}
});
} else this.$message.error("请选择检查表!");
},
//提交检查项目
submitfield() {
/* submitfield() {
let _this = this;
_this.field = []; //检查项目
this.fieldList.forEach((item) => {
_this.field.push({
form_field: item.id,
field_value: item.sort,
is_testok: item.is_testok//单项检查结果
});
});
console.log(this.recordform);
this.testrecord.form = this.recordform;//检查表
this.testrecord.record_data = _this.field;//检查项列表
this.testrecord.is_testok = this.is_testok;//检查表检查结果
this.testrecord.wproduct = this.wproduct;//半成品ID
wproductTest(this.testrecord).then((res) => {
if (res.code >= 200) {
this.innerVisible = false;
@ -569,7 +584,7 @@
});
},
},*/
//半成品入库
handlePutin(scope) {
this.dialogFormVisible = true;
@ -585,6 +600,7 @@
}
});
},
//提交检查项目
formFunc(value) {
wproductTest(value).then((res) => {
if (res.code >= 200) {