<template>
|
<view>
|
<page-nav title="入厂检验"></page-nav>
|
|
|
|
<view class="mainContent">
|
<view>
|
<u-gap height="10" bgColor="#eff0f1"></u-gap>
|
<view class="head" style="height: 300rpx;overflow: auto;">
|
<view class="head_block">
|
<view class="head_left">
|
<view class="head_bar"></view>
|
<view class="head_title" style="font-weight: bolder;">
|
质检方案
|
</view>
|
</view>
|
</view>
|
|
<view class="marginLeft20 marginRight20">
|
<view class="marginBottom20" style="display: flex;">
|
<view class="flex_column titleFont">
|
<view>方案名称:</view>
|
<view>抽样方式:</view>
|
<view>总数量:</view>
|
<view>样本数量:</view>
|
</view>
|
<view class="flex_column contentFont">
|
<view>{{purchorderObj.checkstandname}}</view>
|
<view>{{purchorderObj.sampmethod==='FIXED'?'固时抽检':'比例抽检'}}</view>
|
<view>{{purchorderObj.hqty}}</view>
|
<!-- <view>{{purchorderObj.sampscare}}</view> -->
|
<u-number-box inputWidth='110' v-model="purchorderObj.sampscare" min='1'
|
:max='purchorderObj.hqty' class="contentFont" @change="hqtyChange"></u-number-box>
|
</view>
|
</view>
|
</view>
|
|
</view>
|
|
<u-gap height="20" bgColor="#eff0f1"></u-gap>
|
<view class="head" style="max-height: 1020rpx;overflow: scroll;">
|
<view class="head_block">
|
<view class="head_left">
|
<view class="head_bar"></view>
|
<view class="head_title" style="font-weight: bolder;">
|
检验项目
|
</view>
|
</view>
|
</view>
|
|
|
<view class="marginBottom20 marginTop10"
|
style="display: flex;justify-content: center;align-items: center;">
|
<u-button type="primary" :disabled="checkNumber===1" @click="preTo"
|
style="width: 200rpx;margin-left: 0%; " plain text="上一件"></u-button>
|
<view style="margin-left: 5%;">{{checkNumber}}/{{purchorderObj.sampscare}}</view>
|
<u-button type="primary"
|
:disabled="checkNumber===purchorderObj.sampscare||purchorderDetailArr%purchorderDetailArr.filter(i=>i.isPlain!=='').length===0"
|
@click="nextTo" style="width: 200rpx;margin-left: 7%; " plain text="下一件"></u-button>
|
</view>
|
|
<u-gap height="6" style="width: 96%;margin-left: 2%;" bgColor="#eff0f1"></u-gap>
|
|
|
<view class="marginLeft20 marginRight20 marginTop20">
|
<view class="marginBottom20 flex_column" v-for="(item,index) in purchorderDetailArr"
|
v-if="item.checkNumber===checkNumber" :key="item.name+index+checkNumber">
|
|
<!-- {{item.name+index+checkNumber}} -->
|
<view class="flex_between marginLeft20 marginRight20">
|
<view class="contentFont">{{item.name}}({{item.unit}})</view>
|
<view class="titleFont" style="display: flex;">
|
<view>
|
{{item.standvalue}}
|
</view>
|
<view v-if="item.lowervalue&&item.uppervalue">
|
({{item.lowervalue}}~{{item.uppervalue}})
|
</view>
|
<view v-if="!item.lowervalue&&item.uppervalue">
|
(~{{item.uppervalue}})
|
</view>
|
<view v-if="item.lowervalue&&!item.uppervalue">
|
({{item.lowervalue}}~)
|
</view>
|
</view>
|
</view>
|
<view class="flex_between marginLeft20 marginTop10">
|
<view class="contentFont " style="display: flex;align-items: center;">
|
<view class="contentFont">
|
实测值:
|
</view>
|
|
<view class="inputClass " style="width: 40%;">
|
<!-- padding: 6rpx 18rpx; -->
|
|
<u--input style="" placeholder="请输入" border="surround" v-model="item.real_value"
|
@change='val=>realValueBlur(val,item)'></u--input>
|
</view>
|
|
<view style="display: flex;">
|
<u-button type="success" style="width: 130rpx;margin-left: 10%;height: 56rpx;"
|
shape="circle" @click="item.isPlain=true;$forceUpdate()"
|
:disabled="item.required==='Y'&&!item.real_value" :plain='!item.isPlain'
|
text="合格"></u-button>
|
|
|
<u-button type="warning" style="width: 130rpx;margin-left: 4%;height: 56rpx;"
|
shape="circle" :plain='item.isPlain'
|
:disabled="item.required==='Y'&&!item.real_value"
|
@click="item.isPlain=false;$forceUpdate()" text="不合格"></u-button>
|
</view>
|
</view>
|
|
</view>
|
|
<view class=" marginLeft20 marginRight20 marginTop10">
|
<view class="titleFont"> 描述:{{item.stepcheckitem_desc}}</view>
|
</view>
|
<view class=" marginLeft20 marginRight20 marginTop10 marginBottom20"
|
style="display: flex;align-items: center;">
|
<view class="contentFont"> 备注:</view>
|
<view class="inputClass " style="">
|
<u--input style="" placeholder="请输入" border="surround"
|
v-model="item.stepcheckitem_remark"></u--input>
|
</view>
|
</view>
|
|
<u-gap height="6"
|
v-if="(index+1)%purchorderDetailArr.map(i=>i.checkNumber===1).filter(i=>i).length!==0"
|
style="width: 96%;margin-left: 2%;" bgColor="#eff0f1"></u-gap>
|
|
</view>
|
</view>
|
|
</view>
|
|
</view>
|
</view>
|
|
<!-- {{purchorderDetailArr.length}} -->
|
<view class="footer" style="min-height:62rpx;">
|
<u-button type="primary" :disabled="!(purchorderDetailArr.filter(i=>i.isPlain==='').length===0)"
|
size='large' :hairline="true" @click="navigateTo" text="下一步"></u-button>
|
</view>
|
|
</view>
|
</template>
|
|
|
<script>
|
import {
|
InFactoryCheckItem
|
|
} from '../../config/api.js';
|
const App = getApp()
|
export default {
|
onLoad(option) {
|
|
console.log(option)
|
|
this.passPurchorderObj = option.purchorderObj
|
|
const t1 = JSON.parse(option.radioSelectValue)
|
|
this.passToNext = option.radioSelectValue
|
|
this.purchorderObj.checkstandname = option.checkstandname
|
this.purchorderObj.checkstandcode = option.checkstandcode
|
this.purchorderObj.sampmethod = option.sampmethod
|
this.purchorderObj.hqty = JSON.parse(option.radioSelectValue).hqty
|
|
this.purchorderObj.sampscare = option.sampmethod === 'FIXED' ? option.sampscare : Math.ceil(parseFloat(
|
JSON.parse(option.radioSelectValue).hqty) * parseFloat(option.sampscare) / 100)
|
|
this.purchorderObj.sampscare = this.purchorderObj.sampscare <= this.purchorderObj.hqty ? this.purchorderObj
|
.sampscare : this.purchorderObj.hqty
|
|
},
|
|
onPullDownRefresh() {
|
setTimeout(() => {
|
this.init(() => {
|
uni.stopPullDownRefresh();
|
})
|
}, 1000);
|
},
|
|
data() {
|
return {
|
|
passPurchorderObj: {}, //页面1传过来的对象
|
|
passToNext: {}, //传给页面3的参数
|
|
|
purchorderObj: {
|
checkstandcode: 'BZ01', //方案编码
|
checkstandname: '标准01', //方案名称
|
sampmethod: 'FIXED', //抽样方式
|
hqty: 30, //总数量
|
sampscare: 3, //样本数量
|
},
|
|
checkNumber: 1, //检验项目中的检验数量 现在处于第几个
|
|
purchorderDetailArr: [
|
// {
|
// stepcheckitem_seq: '1',
|
// name: '质检1S(KG)',
|
// code: '',
|
// standvalue: '6.5',
|
// lowervalue: '6.0',
|
// uppervalue: '7.0',
|
// real_value: '', //实测值
|
// unit: '', //单位
|
// required: '', //是否必填
|
// numberjudge: '', //数值判断
|
// stepcheckitem_desc: '检测外观内径.需用专业仪器',
|
// stepcheckitem_remark: '', //备注
|
// isPlain: false
|
// }, {
|
// stepcheckitem_seq: '2',
|
// name: '质检1S(KG)',
|
// code: '',
|
// standvalue: '6.5',
|
// lowervalue: '6.0',
|
// uppervalue: '7.0',
|
// real_value: '', //实测值
|
// unit: '',
|
// required: '', //是否必填
|
// numberjudge: '', //数值判断
|
// stepcheckitem_desc: '检测外观内径.需用专业仪器',
|
// stepcheckitem_remark: '', //备注
|
// isPlain: true
|
// },
|
// {
|
// stepcheckitem_seq: '3',
|
// name: '质检1S(KG)',
|
// code: '',
|
// standvalue: '6.5',
|
// lowervalue: '6.0',
|
// uppervalue: '7.0',
|
// real_value: '',
|
// unit: '',
|
// required: '', //是否必填
|
// numberjudge: '', //数值判断
|
// stepcheckitem_desc: '检测外观内径.需用专业仪器',
|
// stepcheckitem_remark: '',
|
// isPlain: false
|
// },
|
// {
|
// stepcheckitem_seq: '4',
|
// name: '质检1S(KG)',
|
// code: '',
|
// standvalue: '6.5',
|
// lowervalue: '6.0',
|
// uppervalue: '7.0',
|
// real_value: '',
|
// unit: '',
|
// required: '', //是否必填
|
// numberjudge: '', //数值判断
|
// stepcheckitem_desc: '检测外观内径.需用专业仪器',
|
// stepcheckitem_remark: '',
|
// isPlain: false
|
// },
|
],
|
|
}
|
},
|
created() {
|
|
},
|
mounted() {
|
this.init()
|
|
this.getInFactoryCheckItem()
|
},
|
methods: {
|
init() {
|
uni.stopPullDownRefresh();
|
},
|
async getInFactoryCheckItem() {
|
const data = {
|
checkstandcode: this.purchorderObj.checkstandcode
|
}
|
const res = await InFactoryCheckItem(this.global.formatData(data))
|
|
for (var i = 0; i < this.purchorderObj.sampscare; i++) {
|
|
res.data.forEach(j => {
|
this.purchorderDetailArr.push({
|
checkNumber: i + 1,
|
stepcheckitem_seq: j.stepcheckitem_seq,
|
name: j.name,
|
code: j.code,
|
standvalue: j.standvalue,
|
lowervalue: j.lowervalue,
|
uppervalue: j.uppervalue,
|
real_value: j.real_value,
|
unit: j.unit,
|
stepcheckitem_desc: j.stepcheckitem_desc,
|
stepcheckitem_remark: '',
|
isPlain: '',
|
required: j.required, //是否必填
|
numberjudge: j.numberjudge, //数值判断
|
})
|
})
|
}
|
|
|
console.log(JSON.parse(JSON.stringify(this.purchorderDetailArr)), 999)
|
|
},
|
|
//样本数量值改变
|
hqtyChange(val) {
|
|
console.log(val.value)
|
const t = this.purchorderDetailArr.filter(i => i.checkNumber === 1)
|
let len = this.purchorderDetailArr.length / t.length
|
|
// 件数减少时
|
if (val.value < this.purchorderDetailArr.length / t.length) {
|
this.purchorderDetailArr.reverse()
|
const a = this.purchorderDetailArr.splice(0, t.length * (len - val.value))
|
this.purchorderDetailArr.reverse()
|
if (this.checkNumber > val.value) {
|
this.checkNumber = val.value
|
}
|
}
|
|
|
// 件数变多时
|
if (val.value > this.purchorderDetailArr.length / t.length) {
|
|
for (var i = val.value; i > len; i--) {
|
t.forEach(j => {
|
this.purchorderDetailArr.push({
|
checkNumber: i,
|
stepcheckitem_seq: j.stepcheckitem_seq,
|
name: j.name,
|
code: j.code,
|
standvalue: j.standvalue,
|
lowervalue: j.lowervalue,
|
uppervalue: j.uppervalue,
|
real_value: '',
|
unit: j.unit,
|
stepcheckitem_desc: j.stepcheckitem_desc,
|
stepcheckitem_remark: '',
|
isPlain: '',
|
required: j.required, //是否必填
|
numberjudge: j.numberjudge, //数值判断
|
})
|
})
|
}
|
|
this.purchorderDetailArr.sort((a, b) => a.checkNumber - b.checkNumber)
|
|
}
|
|
// console.log(this.purchorderDetailArr, 1)
|
// console.log(this.purchorderDetailArr.length, 1)
|
this.$forceUpdate()
|
},
|
|
navigateTo() {
|
|
// console.log(this.passPurchorderObj)
|
|
// console.log(JSON.parse(JSON.stringify(this.purchorderDetailArr)))
|
|
// let t =
|
|
// 计算OK值
|
let goodqty = 0;
|
for (var i = 0; i < this.purchorderObj.sampscare; i++) {
|
let flag = this.purchorderDetailArr.filter(j => j.checkNumber === i + 1).every(j => j.isPlain)
|
if (flag) {
|
goodqty++
|
}
|
}
|
|
|
uni.navigateTo({
|
url: './rcjy3?passPurchorderObj=' + JSON.stringify(this.passPurchorderObj) +
|
'&purchorderDetailArr=' + JSON
|
.stringify(this.purchorderDetailArr) + '&passToNext=' + this.passToNext +
|
'&purchorderObj=' + JSON.stringify(this.purchorderObj) + '&sampleqty=' + this.purchorderObj
|
.sampscare + '&goodqty=' + goodqty
|
});
|
},
|
|
// 上一件
|
preTo() {
|
if (this.checkNumber > 1) {
|
this.checkNumber--
|
}
|
|
},
|
|
//下一件
|
nextTo() {
|
if (this.checkNumber < this.purchorderObj.sampscare) {
|
this.checkNumber++
|
}
|
|
this.$forceUpdate()
|
|
console.log(JSON.parse(JSON.stringify(this.purchorderDetailArr)))
|
|
// let t = JSON.parse(JSON.stringify(this.purchorderDetailArr))
|
// t.forEach(i=>{
|
// i.isPlain=''
|
// })
|
|
},
|
|
// 实测值输入时失焦状态
|
realValueBlur(val, item) {
|
console.log(val === '', item)
|
|
|
if (val.value !== '') {
|
if (item.numberjudge === 'Y') { //如果需要进行数值判断
|
|
if (item.uppervalue === '' && item.lowervalue === '') { //上限值为空,下限值为空
|
if (parseFloat(val) === parseFloat(item.standvalue)) {
|
item.isPlain = true
|
} else {
|
item.isPlain = false
|
}
|
}
|
|
|
if (item.uppervalue !== '' && item.lowervalue !== '') { //上限值不为空,下限值不为空
|
if (parseFloat(val) >= parseFloat(item.lowervalue) && parseFloat(val) <=
|
parseFloat(item.uppervalue)) {
|
item.isPlain = true
|
} else {
|
item.isPlain = false
|
}
|
}
|
|
|
if (item.uppervalue !== '' && item.lowervalue === '') { //上限值不为空,下限值为空
|
if (parseFloat(val) <= parseFloat(item.uppervalue)) {
|
item.isPlain = true
|
} else {
|
item.isPlain = false
|
}
|
}
|
|
if (item.uppervalue === '' && item.lowervalue !== '') { //上限值为空,下限值不为空
|
if (parseFloat(val) >= parseFloat(item.lowervalue)) {
|
item.isPlain = true
|
} else {
|
item.isPlain = false
|
}
|
}
|
|
}
|
}
|
|
|
if (val === '') {
|
item.isPlain = ''
|
}
|
// this.$forceUpdate()
|
}
|
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
@import url('@/style/global.css');
|
|
::v-deep .uicon-arrow-left>span {
|
display: block;
|
}
|
|
::v-deep .u-input {
|
padding: 6rpx 18rpx !important;
|
}
|
|
::v-deep .u-number-box__minus {
|
height: 50rpx !important;
|
}
|
|
::v-deep .u-number-box__input {
|
height: 50rpx !important;
|
|
}
|
|
::v-deep .u-number-box__plus {
|
height: 50rpx !important;
|
}
|
</style>
|