<template>
|
<view>
|
<view class="InSpect-value-content">
|
<view class="form-item">
|
<view class="left">项目序号</view>
|
<view class="right disabled">
|
<input type="text" v-model="checkData.num" disabled />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="left">检验项目</view>
|
<view class="right disabled">
|
<input type="text" v-model="checkData.HQCCheckItemName" disabled />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="left">样本量</view>
|
<view class="right disabled">
|
<input type="text" v-model="checkData.HSampleQty" disabled />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="left">检验结果</view>
|
<view class="right" :class="CheckResultClass">
|
<input type="text" v-model="checkData.HResult2" disabled />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="left">不合格数</view>
|
<view class="right">
|
<input type="number" v-model="checkData.HSampleUnRightQty" />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="left">保留小数位</view>
|
<view class="right">
|
<input type="number" v-model="checkData.HResDec" />
|
</view>
|
</view>
|
<view style="width: 100%;border-bottom: 1px solid #e3e3e3;"></view>
|
<view class="form-item" style="width: 100%;">
|
<view class="left">状态</view>
|
<view class="right none-border">
|
<view style="width: 4em; ">
|
{{ checkData.HStatus?"合格":"不合格" }}
|
</view>
|
<view>
|
<switch style="width: 2em; transform:scale(0.7);" :checked="!!checkData.HStatus"
|
@change="HStatusChange" />
|
</view>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="left">比较符</view>
|
<view class="right disabled">
|
<uni-combox :candidates="HCompareSymbolList" v-model="checkData.HCompareSymbol"></uni-combox>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="left">单位</view>
|
<view class="right disabled">
|
<uni-combox :candidates="UnitNameList" v-model="checkData.HUnitName"></uni-combox>
|
<!-- <input type="text" v-model="checkData.HTargetVal" /> -->
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="left">检验值</view>
|
<view class="right">
|
<input type="number" v-model="checkData.HInSpectVal" />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="left">目标值</view>
|
<view class="right ">
|
<input type="number" v-model="checkData.HTargetVal" @blur="CalculateLimitOffset(1)" />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="left">上限值</view>
|
<view class="right" :class="[AnalysisMethodStatus == 1?'disabled':'']">
|
<input type="number" v-model="checkData.HUpLimit" :disabled="AnalysisMethodStatus == 1" @blur="CalculateLimitOffset(2)" />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="left">下限值</view>
|
<view class="right" :class="[AnalysisMethodStatus == 1?'disabled':'']">
|
<input type="number" v-model="checkData.HDownLimit" :disabled="AnalysisMethodStatus == 1" @blur="CalculateLimitOffset(3)" />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="left">上偏差</view>
|
<view class="right" :class="[
|
(AnalysisMethodStatus == 1 || AnalysisMethodStatus == 3)?'disabled':''
|
]">
|
<input type="number" v-model="checkData.HUpOffset"
|
:disabled="AnalysisMethodStatus == 1 || AnalysisMethodStatus == 3" @blur="CalculateLimitOffset(4)" />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="left">下偏差</view>
|
<view class="right" :class="[
|
(AnalysisMethodStatus == 1 || AnalysisMethodStatus == 3)?'disabled':''
|
]">
|
<input type="number" v-model="checkData.HDownOffset"
|
:disabled="AnalysisMethodStatus == 1 || AnalysisMethodStatus == 3" @blur="CalculateLimitOffset(5)" />
|
</view>
|
</view>
|
<view style="width: 100%;border-bottom: 1px solid #e3e3e3;"></view>
|
<view class="InSpect-value-list">
|
<!-- <view style="width: 100%;text-align: right;">
|
<button type="default" size="mini" class="btn-a" @click="storeInSpectValue">缓存检验值</button>
|
</view> -->
|
<view class="item" style="border-top: 2px solid #e3e3e3 ;">
|
<view class="th1">序号</view>
|
<view class="th2" style="display: flex; flex-direction: row; align-items: center;">
|
检验结果
|
</view>
|
<view class="th3">
|
检验值({{getAnalysisMethodTitle(checkData.HAnalysisMethod)}})
|
</view>
|
</view>
|
<view class="item" v-for="(item, index) in InSpectValues">
|
<view class="th1">{{item.HSEQ}}</view>
|
<view class="th2" style="display: flex; flex-direction: row; align-items: center;">
|
<view style="width: 3em; ">
|
{{ item.HInSpectResult == 1?"合格":"不合格" }}
|
</view>
|
<view>
|
<switch style="width: 3em; transform:scale(0.7);" :checked="item.HInSpectResult == 1"
|
@change="HInSpectResultChange(index, $event)" />
|
</view>
|
</view>
|
<view class="th3">
|
<uni-combox v-if="checkData.HAnalysisMethod == 1" :candidates="InitInSpectValNameList"
|
v-model="item.HInSpectValueB_Text"
|
@update:modelValue="HInSpectValueBChange(index, $event)"></uni-combox>
|
<input v-else-if="checkData.HAnalysisMethod == 2" type="number" v-model="item.HInSpectValue"
|
@blur="InSpectValueChange(item,index)" @confirm="InSpectValueChange(item,index)" @focus="item.HInSpectValue = ''" />
|
<input v-else type="number" v-model="item.HInSpectValueT"
|
@blue="InSpectValueTChange(item, index)" @confirm="InSpectValueTChange(item, index)" @focus="item.HInSpectValueT = ''"/>
|
</view>
|
</view>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import {
|
getUserInfo
|
} from '../../utils/auth';
|
import {
|
CommonUtils
|
} from '../../utils/common';
|
// 检验值模板
|
export default {
|
name: "InSpectValueTemplate",
|
data() {
|
return {
|
mode: 0,
|
checkData: {
|
HResDec: 2,
|
HResult2: '',
|
HStatus: true,
|
HCompareSymbol: "=", // 默认为=号
|
HUnitName: '',
|
HAnalysisMethod: 0,
|
HTargetVal: 0,
|
HUpOffset: 0,
|
HDownOffset: 0,
|
HUpLimit: 0,
|
HDownLimit: 0,
|
HSampleUnRightQty: 0
|
},
|
InSpectValues: [],
|
InitInSpectValNameList: [],
|
InitInSpectValList: [],
|
UnitNameList: [],
|
UnitList: [],
|
|
CheckResultClass: 'disable',
|
|
HCompareSymbolList: ["=", ">", ">=", "<", "<=", "<>", "between"]
|
};
|
},
|
props: {
|
bindKey: {
|
type: [String, Number],
|
required: true
|
},
|
bindData: {
|
type: Object,
|
required: true
|
}
|
},
|
mounted() {
|
console.log('bingData: ', this.bindData);
|
let {
|
data,
|
list,
|
mode
|
} = this.bindData
|
Object.assign(this.checkData, data, JSON.parse(JSON.stringify(this.bindData)))
|
// 前段获取HStatus时,0和1 的状态均初始化为 true,2状态初始化为false
|
if(typeof this.checkData.HStatus == 'number'){
|
this.checkData.HStatus = this.checkData.HStatus <= 1 ? true : false
|
}
|
this.checkData.HResult2 = this.checkData.HResult == 1 ? '合格' : '不合格'
|
this.mode = mode
|
// 判断是否有缓存数据或者缓存数据是否与样本数一致
|
if (!list || list.length != this.checkData.HSampleQty) {
|
for (let index = 0; index < this.checkData.HSampleQty; index++) {
|
this.InSpectValues.push({
|
HSEQ: index + 1,
|
HInSpectResult: 1,
|
HInSpectValue: 0, // 定量检测值
|
HInSpectValueB: 0, // 定性检测ID
|
HInSpectValueB_Text: '', // 定性检测(内容)
|
HInSpectValueT: 0, // 其他检测值
|
})
|
}
|
} else {
|
this.InSpectValues = list
|
}
|
this.InitInSpectVal()
|
this.InitUnit()
|
// 实例挂载后,获取InterID 和 EntryID 对应的检验项目的检验值
|
this.getValueList()
|
|
this.$forceUpdate()
|
},
|
watch: {
|
"checkData.HResult2"(newVal, oldVal) {
|
if (newVal == '合格') {
|
this.CheckResultClass = 'pass-background'
|
} else if (newVal == '不合格') {
|
this.CheckResultClass = 'unpass-background'
|
} else {
|
this.CheckResultClass = 'disabled'
|
}
|
// 同步父组件的对应检验项目的结论
|
this.$emit("syncInspectResult", {
|
HResult2: newVal,
|
bindKey: this.bindKey
|
})
|
},
|
|
},
|
computed: {
|
AnalysisMethodStatus: {
|
get() {
|
if (this.checkData.HAnalysisMethod == 1) {
|
return 1
|
} else if (this.checkData.HAnalysisMethod == 2) {
|
return 2
|
}
|
return 3
|
}
|
},
|
currWebUrl: {
|
get(){
|
switch (this.mode){
|
case 1: return {
|
// 首检
|
setUrl: '/QC_FirstPieceCheckBill/set_SaveValue',
|
getUrl: '/QC_ValueTable/getValueList'
|
}
|
case 2: return {
|
// 巡检
|
setUrl: '/QC_PatrolProcCheckOtherBill/set_SaveValue',
|
getUrl: '/QC_PatrolProcCheckOtherBill/getValueList'
|
}
|
case 3: return {
|
// 生产入库检
|
setUrl: '/QC_LastPieceCheckBill/set_SaveValue',
|
getUrl: '/QC_LastPieceCheckBill_ValueTable/getValueList'
|
}
|
case 4:return{
|
// 出厂检
|
setUrl: '/QC_OutCompCheckBill/set_SaveValue',
|
getUrl: '/QC_OutCompCheckBill_ValueTable/getValueList'
|
}
|
case 5:return{
|
// 来料检
|
setUrl: '/QC_POStockInCheckBill/set_SaveValue',
|
getUrl: '/QC_POStockInCheckBill_ValueTable/getValueList'
|
}
|
case 6: return {
|
// 末检
|
}
|
}
|
}
|
}
|
},
|
|
beforeDestroy() {
|
// 注销前,提交数据的检验值
|
this.set_SaveValue()
|
this.$emit("syncCheckData", this.checkData)
|
},
|
methods: {
|
CalculateLimitOffset(mode) { // 重新计算上限值的偏差值
|
switch (mode) {
|
// 目标值变更
|
case 1:
|
this.checkData.HUpOffset = 0
|
this.checkData.HUpLimit = this.checkData.HTargetVal
|
this.checkData.HDownOffset = 0
|
this.checkData.HDownLimit = this.checkData.HTargetVal
|
break;
|
// 上限值变更
|
case 2:
|
this.checkData.HUpOffset = eval(`${this.checkData.HUpLimit}-${this.checkData.HTargetVal}`)
|
break;
|
// 下限值变更
|
case 3:
|
this.checkData.HDownOffset = eval(`${this.checkData.HDownLimit}-${this.checkData.HTargetVal}`)
|
break;
|
// 上偏差值变更
|
case 4:
|
this.checkData.HUpLimit = eval(`${this.checkData.HUpOffset}-${this.checkData.HTargetVal}`)
|
break;
|
// 下偏差值变更
|
case 5:
|
this.checkData.HDownLimit = eval(`${this.checkData.HDownOffset}-${this.checkData.HTargetVal}`)
|
break;
|
}
|
},
|
// 其他分析 检验值变化时判断
|
InSpectValueTChange(item, index) {
|
console.log('item,: ', item);
|
|
this.HInSpectResultChange(index, {
|
detail: {
|
value: this.checkValuePass(item.HInSpectValueT)
|
}
|
})
|
},
|
// 定量分析 检验值变化时判断
|
InSpectValueChange(item, index) {
|
console.log('item,: ', item);
|
|
this.HInSpectResultChange(index, {
|
detail: {
|
value: this.checkValuePass(item.HInSpectValue)
|
}
|
})
|
},
|
checkValuePass(val) {
|
console.log('val: ', val);
|
console.log('this.checkData.HTargetVal: ', this.checkData.HTargetVal);
|
switch (this.checkData.HCompareSymbol) {
|
case '=':
|
if (val == this.checkData.HTargetVal) {
|
return true
|
};
|
break;
|
case '>':
|
if (val > this.checkData.HTargetVal) {
|
return true
|
};
|
break;
|
case '>=':
|
if (val >= this.checkData.HTargetVal) {
|
return true
|
};
|
break;
|
case '<':
|
if (val < this.checkData.HTargetVal) {
|
return true
|
};
|
break;
|
case '<=':
|
if (val <= this.checkData.HTargetVal) {
|
return true
|
};
|
break;
|
case '<>':
|
if (val != this.checkData.HTargetVal) {
|
return true
|
};
|
break;
|
case 'between':
|
if (val >= (this.checkData.HTargetVal - this.checkData.HDownLimit || 0) &&
|
val <= (this.checkData.HTargetVal + this.checkData.HUpLimit || 0)) {
|
return true
|
};
|
break;
|
default:
|
CommonUtils.showTips({
|
message: '请选择比较符'
|
})
|
}
|
},
|
// 初始化 单位
|
async InitUnit() {
|
let res = await CommonUtils.doRequest2Async({
|
url: '/Gy_Unit/list1',
|
data: {
|
sWhere: ` and 禁用标记 = '' and 审核人 != ''`,
|
user: getUserInfo()['Czymc'],
|
Organization: uni.getStorageSync("Organization")
|
}
|
})
|
|
let {
|
data,
|
count,
|
Message
|
} = res.data
|
if (!count) {
|
CommonUtils.showTips({
|
title: '温馨提示',
|
message: `初始化单位错误: ${Message}`
|
})
|
} else {
|
this.UnitNameList = Array.from(data).map(e => e["计量单位名称"])
|
this.UnitList = data
|
}
|
},
|
// 单位 修改 监听
|
UnitChange(e) {
|
|
},
|
async set_SaveValue() {
|
await this.$nextTick();
|
console.log("InSpect Values: ", this.InSpectValues)
|
try {
|
let res = await CommonUtils.doRequest2Sync({
|
url: this.currWebUrl.setUrl,
|
data: {
|
msg: `${JSON.stringify(this.InSpectValues)};${this.checkData.HInterID};${this.checkData.num}`
|
},
|
method: "POST"
|
})
|
|
if (!res) {
|
return
|
}
|
let {
|
Message,
|
count
|
} = res.data
|
if (count != 1) {
|
CommonUtils.showTips({
|
title: '温馨提示',
|
message: `保存检验值错误: ${Message}`
|
})
|
}
|
} catch (err) {
|
CommonUtils.showTips({
|
title: '温馨提示',
|
message: `保存检验值错误: ${err}`
|
})
|
}
|
},
|
async getValueList() {
|
console.log('checkData: ', this.checkData);
|
try {
|
let res = await CommonUtils.doRequest2Async({
|
url: this.currWebUrl.getUrl,
|
data: {
|
HInterID: this.checkData.HInterID,
|
HEntryID: this.checkData.num,
|
user: getUserInfo()['Czymc']
|
}
|
})
|
|
let {
|
data,
|
count
|
} = res.data
|
if (count == 1) {
|
console.log('InspectValuesData: ', data);
|
// 当前 检验值页签中 保存的数据个数和数据库中的个数大 或者相等,取数据库中的数据,多的补空
|
if (this.InSpectValues.length >= data.length) {
|
let InSpectValuesNew = this.InSpectValues.slice(data.length, this.InSpectValues.length)
|
this.InSpectValues = [...data, ...InSpectValuesNew]
|
} else {
|
// 截取当前保存的数据
|
this.InSpectValues = data.slice(0, this.InSpectValues.length)
|
}
|
// this.InSpectValues = data
|
|
}
|
} catch (err) {
|
CommonUtils.showTips({
|
tite: '温馨提示',
|
message: `获取检测值错误: ${err}`
|
})
|
}
|
|
},
|
async InitInSpectVal() { // 初始化定性检测内容
|
try {
|
let res = await CommonUtils.doRequest2Async({
|
url: '/Gy_BadReason/Gy_InSpectValueList',
|
data: {
|
sWhere: ` and 使用组织名称 = '${uni.getStorageSync("Organization")}' and 禁用标志 = '否' and 审核人 !='' `,
|
user: getUserInfo()['Czymc']
|
}
|
})
|
|
let {
|
count,
|
Message,
|
data
|
} = res.data
|
|
if (count == 1) {
|
this.InitInSpectValNameList = Array.from(data).map(e => e["检测值名称"])
|
this.InitInSpectValList = data
|
} else {
|
CommonUtils.showTips({
|
title: "温馨提示",
|
message: `检测值初始化错误: ${Message}`
|
})
|
}
|
} catch (err) {
|
CommonUtils.showTips({
|
title: "温馨提示",
|
message: `检测值初始化错误: ${err}`
|
})
|
}
|
},
|
// 检测值修改
|
HInSpectValueBChange(index, e) {
|
let InSpectVal = this.InitInSpectValList.find(elem => elem["检测值名称"] == e)
|
if (!InSpectVal) {
|
this.InSpectValues[index].HInSpectValueB = 0
|
this.InSpectValues[index].HInSpectValueB_Text = ''
|
return
|
}
|
this.InSpectValues[index].HInSpectValueB = InSpectVal["HItemID"]
|
this.InSpectValues[index].HInSpectValueB_Text = InSpectVal["检测值名称"]
|
},
|
storeInSpectValue() {
|
this.$emit("update", {
|
data: this.checkData,
|
list: this.InSpectValues
|
})
|
},
|
getAnalysisMethodTitle(type) {
|
if (type == 1) {
|
return '定性分析'
|
} else if (type == 2) {
|
return '定量分析'
|
}
|
return '其他分析'
|
},
|
HStatusChange(e) {
|
this.checkData.HStatus = e.detail.value
|
},
|
HInSpectResultChange(index, e) {
|
console.log('e: ', e.detail.value);
|
this.InSpectValues[index].HInSpectResult = e.detail.value ? 1 : 2
|
this.CheckPassNum()
|
|
},
|
CheckPassNum() {
|
let unPassNum = this.InSpectValues.map(elem => elem.HInSpectResult).filter(elem => elem != 1).length
|
|
this.checkData.HSampleUnRightQty = unPassNum
|
let unRightQty = this.checkData.HAcceptQty
|
if (this.checkData.HStatus) { // true 为 检验合格, false为检验 不合格
|
if (unPassNum > unRightQty) {
|
this.checkData.HResult2 = '不合格'
|
|
} else {
|
this.checkData.HResult2 = '合格'
|
}
|
} else {
|
if (this.InSpectValues.length - unPassNum > unRightQty) {
|
this.checkData.HResult2 = '不合格'
|
} else {
|
this.checkData.HResult2 = '合格'
|
}
|
}
|
|
}
|
|
},
|
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
input {
|
height: inherit;
|
width: inherit;
|
font-size: 26rpx;
|
}
|
|
.InSpect-value-content {
|
box-sizing: border-box;
|
padding: 20rpx 10rpx;
|
display: flex;
|
flex-direction: row;
|
flex-wrap: wrap;
|
gap: 20rpx 0;
|
|
.form-item {
|
width: 50%;
|
display: flex;
|
align-items: center;
|
font-size: 26rpx;
|
box-sizing: border-box;
|
padding-left: 20rpx;
|
|
.left {
|
width: 5em;
|
|
text {
|
color: red;
|
font-weight: bold;
|
}
|
}
|
|
.right {
|
// width: 450rpx;
|
padding: 8rpx 20rpx;
|
font-size: 26rpx;
|
flex: 1;
|
border-radius: 22rpx;
|
border: 1px solid #acacac;
|
display: flex;
|
flex-direction: row;
|
align-items: center;
|
|
.uni-combox {
|
padding: 0;
|
height: auto;
|
|
.uni-input-placeholder,
|
.uni-input-input {
|
font-size: 26rpx;
|
}
|
}
|
|
.uni-combox::v-deep input {
|
height: inherit;
|
font-size: 26rpx;
|
}
|
}
|
|
.disabled {
|
border: 1px solid #e4e4e4;
|
background-color: #e4e4e4;
|
}
|
|
.pass-background {
|
background-color: #CEE3F2;
|
border: none;
|
}
|
|
.unpass-background {
|
background-color: #F0D6E3;
|
border: none;
|
}
|
|
.none-border {
|
border: none;
|
}
|
}
|
}
|
|
|
|
.InSpect-value-list {
|
box-sizing: border-box;
|
display: flex;
|
flex-direction: column;
|
width: 100%;
|
|
.item {
|
display: flex;
|
flex-direction: row;
|
align-items: center;
|
font-size: 30rpx;
|
}
|
|
.th1 {
|
height: 100%;
|
width: 4em;
|
border: #e4e4e4 2px solid;
|
border-top: 0;
|
display: flex;
|
align-items: center;
|
box-sizing: border-box;
|
padding: 8rpx 16rpx;
|
}
|
|
.th2 {
|
height: 100%;
|
width: 50%;
|
border: #e4e4e4 2px solid;
|
border-left: 0;
|
border-top: 0;
|
box-sizing: border-box;
|
padding: 8rpx 16rpx;
|
}
|
|
.th3 {
|
height: 100%;
|
flex: 1;
|
border: #e4e4e4 2px solid;
|
border-left: 0;
|
border-top: 0;
|
box-sizing: border-box;
|
padding: 8rpx 16rpx;
|
}
|
}
|
|
.btn-a {
|
background-color: #3A78FF;
|
color: #fff;
|
}
|
</style>
|