中航光电热表web
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

863 lines
34 KiB

<template>
<el-dialog
title="批量填报"
append-to-body
:modelValue="openShow"
width="100%"
fullscreen
@close="closeDialog(false)"
>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
v-model:page="page"
v-model="form"
ref="crud"
@row-update="rowUpdate"
@row-save="rowSave"
@row-del="rowDel"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
>
<template #normValueLimit="scope">
<span>{{scope.row.liquidTank.normValueMin}} ~ {{scope.row.liquidTank.normValueMax}}</span>
</template>
<template #targetValueLimit="scope">
<span>{{scope.row.liquidTank.targetValueMin}} ~ {{scope.row.liquidTank.targetValueMax}}</span>
</template>
<template #temperatureType="scope">
<span v-show="scope.row.liquidTank.temperatureType == 2">{{scope.row.liquidTank.temperatureInRoom}}</span>
<span v-show="scope.row.liquidTank.temperatureType == 3">{{scope.row.liquidTank.temperatureEnv}}</span>
<span v-show="scope.row.liquidTank.temperatureType == 4">{{scope.row.liquidTank.temperatureRangeLeft}} ~ {{scope.row.liquidTank.temperatureRangeRight}}</span>
</template>
<template #phType="scope">
<span v-show="scope.row.phType == 2">{{scope.row.liquidTank.phRangeLeft}} ~ {{scope.row.liquidTank.phRangeRight}}</span>
</template>
<!-- 测量值 -->
<template #firstTestValue="scope">
<div class="inpu-text" >
<el-input style="margin-top:9px;" @blur="() => testBlur(scope.row,scope.$index)" @input="val => scope.row.firstTestValue = formatDecimal(val, 5)" :disabled="scope.row.status == 8" v-model="scope.row.firstTestValue" />
<i>({{scope.row.liquidTank.testUnit}})</i>
</div>
</template>
<template #conductivityFirstTestValue="scope">
<div class="inpu-text"><el-input @input="val => scope.row.conductivityFirstTestValue = formatDecimal(val, 5)" :disabled="scope.row.status == 8" v-model="scope.row.conductivityFirstTestValue" /></div>
</template>
<template #temperatureActual="scope">
<div class="inpu-text"><el-input @input="val => scope.row.temperatureActual = formatDecimal(val, 5)" :disabled="scope.row.status == 8" v-model="scope.row.temperatureActual" /></div>
</template>
<template #afterAddTheoryValue="scope">
<div class="inpu-text"><el-input @input="val => scope.row.afterAddTheoryValue = formatDecimal(val, 5)" :disabled="scope.row.status == 8" v-model="scope.row.afterAddTheoryValue" /></div>
</template>
<template #phActual="scope">
<div class="inpu-text"><el-input @input="val => scope.row.phActual = formatDecimal(val, 5)" :disabled="scope.row.status == 8" v-model="scope.row.phActual" /></div>
</template>
<!-- 是否合格 -->
<template #qualified="scope">
{{scope.row.qualified == 1 ? '合格' : scope.row.qualified == 2 ? '不合格' : ''}}
</template>
<!-- 复测电导率 -->
<!-- <template #conductivityRepeatTestValue="scope">
<div class="inpu-text">
<el-input @input="val => scope.row.conductivityRepeatTestValue = formatDecimal(val, 5)" :disabled="scope.row.status == 2 || scope.row.status == 4" v-model="scope.row.conductivityRepeatTestValue" /></div>
</template> -->
<template #firstTestDate="scope">
<div class="inpu-text">
<el-date-picker
v-model="scope.row.firstTestDate"
type="datetime"
format="YYYY-MM-DD HH:mm:ss"
value-format="YYYY-MM-DD HH:mm:ss"
:disabled="scope.row.status == 8"
placeholder=""
style="height: 32px;"
>
</el-date-picker>
</div>
</template>
<template #needAddValue="scope">
<div class="inpu-text">
<el-input style="margin-top:9px;" @input="val => scope.row.needAddValue = formatDecimal(val, 5)" :disabled="scope.row.status == 8 || scope.row.status == 2 || scope.row.status == 4" v-model="scope.row.needAddValue" />
<i>({{scope.row.liquidTank.addUnit}})</i>
</div>
</template>
<template #actualAddValue="scope">
<div class="inpu-text">
<el-input style="margin-top:9px;" @blur="() => changeActualValue(scope.row,scope.$index)" @input="val => scope.row.actualAddValue = formatDecimal(val, 5)" :disabled="scope.row.status == 8" v-model="scope.row.actualAddValue" />
<i>({{scope.row.liquidTank.addUnit}})</i>
</div>
</template>
<!-- 复测测量值 -->
<template #repeatTestValue="scope">
<div class="inpu-text">
<el-input style="margin-top:9px;" @input="val => scope.row.repeatTestValue = formatDecimal(val, 5)" :disabled="scope.row.status == 2 || scope.row.status == 4" v-model="scope.row.repeatTestValue" />
<i>({{scope.row.liquidTank.testUnit}})</i>
</div>
</template>
</avue-crud>
<template #footer>
<span class="dialog-footer">
<el-button @click="closeDialog(false)">取 消</el-button>
<el-button type="primary" v-if="data[0].status == 2 || data[0].status == 12" @click="handleSave">暂 存</el-button>
<el-button type="primary" @click="submit"> </el-button>
</span>
</template>
</el-dialog>
</template>
<script>
import {calcTank,safeEval} from "@/utils/tankclac"
import {firstBat,fillBat,editDrugBat,saveDrugBat} from "@/api/tankSolutionSystem/tankSolutionTaskAssignment"
export default {
props: {
showDialog: {
type: Boolean,
default: false
},
list:{
type:Object,
default:[]
}
},
data() {
return {
openShow: false,
data:[],
loading:false,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
option: {
page: false, // 关闭分页
height: 'auto',
addRowBtn: true,
tip: false,
calcHeight: 50,
searchShow: true,
searchMenuSpan: 6,
searchIcon: true,
searchIndex: 3,
columnSort: true,
tree: false,
border: true,
index: true,
selection: false,
viewBtn: false,
delBtn: false,
addBtn: false,
editBtn: false,
editBtnText: '修改',
viewBtnText: '详情',
addBtnIcon: ' ',
viewBtnIcon: ' ',
delBtnIcon: ' ',
editBtnIcon: ' ',
labelWidth: 120,
// menuWidth: 330,
dialogWidth: 600,
dialogClickModal: false,
searchEnter: true,
filterBtn: true,
searchShowBtn: false,
excelBtn: true,
showOverflowTooltip: true,
align: 'center',
menu: false,
header: false,
searchLabelPosition: 'left',
searchLabelPosition: 'left',
searchGutter: 24,
searchSpan: 6,
menuAlign: 'left',
gridBtn: false,
searchMenuPosition: 'right',
column: [
{
label: '任务号',
prop: 'code',
sortable: true,
filter: true,
span: 24,
search: false,
width: 110,
fixed:true,
},
{
label: '作业中心',
prop: 'wcName',
sortable: true,
filter: true,
span: 24,
search: false,
width: 110,
fixed:true,
},
{
label: '作业槽',
prop: 'workTankName',
search: false,
sortable: true,
filter: true,
span: 24,
width: 120,
fixed:true,
},
{
label: '分析项目',
prop: 'testElement',
type: 'textarea',
search: false,
sortable: true,
filter: true,
span: 24,
width: 110,
fixed:true,
},
{
label: '药品名称',
prop: 'drugName',
sortable: true,
filter: true,
span: 24,
search: false,
width: 110
},
{
label: '药品物料号',
prop: 'drugMaterialCode',
sortable: true,
filter: true,
span: 24,
search: false,
width: 120
},
{
label: '药品物料名称',
prop: 'drugMaterialName',
sortable: true,
filter: true,
span: 24,
search: false,
width: 140
},
{
label: '规范上下限',
prop: 'normValueLimit',
sortable: true,
filter: true,
span: 24,
search: false,
width: 140
},
{
label: '目标上下限',
prop: 'targetValueLimit',
sortable: true,
filter: true,
span: 24,
search: false,
width: 140
},
{
label: '温度',
prop: 'temperatureType',
sortable: true,
filter: true,
span: 24,
search: false,
width: 110
},
{
label: 'PH值',
prop: 'proContent',
sortable: true,
filter: true,
span: 24,
search: false,
width: 110
},
{
label: '目标值',
prop: 'targetValue',
sortable: true,
filter: true,
span: 24,
search: false,
width: 110
},
{
label: '添加点',
prop: 'fillingLocation',
sortable: true,
filter: true,
span: 24,
search: false,
width: 110
},
{
label: '测量值',
prop: 'firstTestValue',
sortable: true,
filter: true,
span: 24,
search: false,
width: 170,
// cell: true,
},
{
label: '是否合格',
prop: 'qualified',
sortable: true,
filter: true,
span: 24,
search: false,
width: 110
},
{
label: '电导率测量值',
prop: 'conductivityFirstTestValue',
sortable: true,
filter: true,
span: 24,
search: false,
width: 140,
cell: true,
},
{
label: '实测温度',
prop: 'temperatureActual',
sortable: true,
filter: true,
span: 24,
search: false,
width: 110,
cell: true,
},
{
label: '实测PH值',
prop: 'phActual',
sortable: true,
filter: true,
span: 24,
search: false,
width: 110,
cell: true,
},
{
label: '体积',
prop: 'volume',
sortable: true,
filter: true,
span: 24,
search: false,
},
{
label: '需添加量',
prop: 'needAddValue',
sortable: true,
filter: true,
span: 24,
search: false,
width: 200,
},
{
label: '实际添加量',
prop: 'actualAddValue',
sortable: true,
filter: true,
span: 24,
search: false,
width: 170,
// cell: true,
},
{
label: '加药后理论值',
prop: 'afterAddTheoryValue',
sortable: true,
filter: true,
span: 24,
search: false,
width: 150,
cell: true,
},
{
label: '化验时间',
prop: 'firstTestDate',
sortable: true,
filter: true,
span: 24,
search: false,
width: 200,
cell: true,
type: 'datetime',
},
{
label: '复测测量值',
prop: 'repeatTestValue',
sortable: true,
filter: true,
span: 24,
search: false,
width: 200,
},
// {
// label: '复测电导率测量值',
// prop: 'conductivityRepeatTestValue',
// sortable: true,
// filter: true,
// span: 24,
// search: false,
// width: 220,
// cell: true
// },
]
},
}
},
watch: {
// 监听父组件传入的 list 变化,同步到本地(深拷贝)
list: {
handler(newVal) {
// 使用 lodash 深拷贝,断开引用
this.data = JSON.parse(JSON.stringify(newVal));
// 或者用 JSON 方式(仅适用于纯对象):
// this.localData = JSON.parse(JSON.stringify(newVal));
},
immediate: true,
deep: false // 不需要 deep,因为 newVal 是新数组引用
}
},
mounted() {
this.openShow = this.showDialog
// this.$nextTick(() =>{
// this.data = this.list
// })
},
methods: {
closeDialog(val) {
this.openShow = false
this.$emit('closeDialog',val);
},
formatDecimal(rawValue, digits = 5) {
if (rawValue == null) return '';
// 步骤1:移除所有非数字和非小数点的字符
let filterVal = rawValue.replace(/[^\d.]/g, '');
// 步骤2:处理多个小数点的情况(只保留第一个小数点)
filterVal = filterVal.replace(/(\.\d*)\./g, '$1');
// 步骤3:处理小数点后最多5位
filterVal = filterVal.replace(/(\.\d{5})\d+/g, '$1');
// 步骤4:处理首位为0的情况
// 情况1:纯数字且长度>1,首位为0(如0123)→ 保留第一个0,后面的数字正常显示(但禁止多个0开头)
// 情况2:0后面跟小数点(如0.123)→ 允许
if (filterVal.startsWith('0') && filterVal.length > 1 && !filterVal.startsWith('0.')) {
// 移除开头多余的0(只保留一个0,后面的数字正常显示)
filterVal = filterVal.replace(/^0+/, '0');
// 若处理后是0且后面有数字(如0123→0123,再处理为0123→改为0)
if (filterVal === '0' && val.length > 1) {
filterVal = '0';
} else {
// 如0123→改为0,01234→改为0,0.123→不变
filterVal = filterVal.replace(/^0(?!\.)/, '');
// 若过滤后为空(如01→过滤后为空),则设为0
if (!filterVal) {
filterVal = '0';
}
}
}
return filterVal;
},
testBlur(row,index){
// console.log('row-----------',row)
// console.log('formula-----------',formula)
// console.log('theoryFormula-----------',theoryFormula)
// 合格判断逻辑
const testValue = parseFloat(row.firstTestValue);
const min = parseFloat(row.targetValueMin);
const max = parseFloat(row.targetValueMax);
const fillingLocation = parseFloat(row.fillingLocation) //添加点
if (testValue > min && testValue < max) {
row.qualified = 1; // 合格
} else {
row.qualified = 2; // 不合格
}
// 如果测量值>添加点,需添加量/实际添加量=0;加药后理论值=测量值
if(testValue > fillingLocation){
row.needAddValue = 0
row.actualAddValue = 0
row.afterAddTheoryValue = testValue
}
this.data.map(item =>{
let formula = calcTank(this.data,item,item.addFormulaContent)
let theoryFormula = calcTank(this.data,item,item.afterFormulaContent)
item.needAddValue = parseFloat(safeEval(formula).toFixed(5))
item.afterAddTheoryValue = parseFloat(safeEval(theoryFormula).toFixed(5))
})
console.log('data------------',this.data)
},
changeActualValue(row,index){
let formula = calcTank(this.data,row,row.addFormulaContent)
let theoryFormula = calcTank(this.data,row,row.afterFormulaContent)
console.log('row',row)
console.log('formula',formula)
console.log('theoryFormula',theoryFormula)
row.needAddValue = parseFloat(safeEval(formula).toFixed(5))
row.afterAddTheoryValue = parseFloat(safeEval(theoryFormula).toFixed(5))
},
// 暂存
handleSave(){
saveDrugBat(this.data).then(res =>{
if(res.data.code == 200){
this.$message.success('暂存成功')
this.closeDialog(true)
}
})
},
submit(){
if(this.data[0].status == 2 || this.data[0].status == 12){
const requiredFields = [
{ key: 'firstTestValue', label: '测量值' },
{ key: 'conductivityFirstTestValue', label: '电导率测量值' },
// { key: 'needAddValue', label: '需添加量' },
{ key: 'actualAddValue', label: '实际添加量' },
{ key: 'afterAddTheoryValue', label: '加药后理论值' },
{ key: 'firstTestDate', label: '化验时间' }
];
// 遍历所有行进行校验和计算
for (let i = 0; i < this.data.length; i++) {
const row = this.data[i];
// 必填校验 + 数值格式校验(除时间外)
for (const field of requiredFields) {
const value = row[field.key];
if (field.key === 'firstTestDate') {
if (!value) {
this.$message.error(`${i + 1} 行:${field.label} 不能为空`);
return;
}
} else {
// 检查是否为空或非数字
if (value === '' || value == null || isNaN(Number(value))) {
this.$message.error(`${i + 1} 行:${field.label} 必须为有效数字`);
return;
}
// 转换为数字并保留5位小数(四舍五入)
const numValue = Number(parseFloat(value).toFixed(5));
row[field.key] = numValue; // 更新回 data,确保精度统一
}
}
}
console.log('data--------------',this.data)
firstBat(this.data).then(res =>{
if(res.data.code == 200){
this.$message.success('填报成功')
this.closeDialog(true)
}
})
}else if(this.data[0].status == 8){
const requiredFields = [
// { key: 'conductivityRepeatTestValue', label: '复测电导率测量值' },
{ key: 'repeatTestValue', label: '复测测量值' },
];
// 遍历所有行进行校验和计算
for (let i = 0; i < this.data.length; i++) {
const row = this.data[i];
// 必填校验 + 数值格式校验(除时间外)
for (const field of requiredFields) {
const value = row[field.key];
if (field.key === 'firstTestDate') {
if (!value) {
this.$message.error(`${i + 1} 行:${field.label} 不能为空`);
return;
}
} else {
// 检查是否为空或非数字
if (value === '' || value == null || isNaN(Number(value))) {
this.$message.error(`${i + 1} 行:${field.label} 必须为有效数字`);
return;
}
// 转换为数字并保留5位小数(四舍五入)
const numValue = Number(parseFloat(value).toFixed(5));
row[field.key] = numValue; // 更新回 data,确保精度统一
}
}
}
fillBat(this.data).then(res =>{
if(res.data.code == 200){
this.$message.success('复测成功')
this.closeDialog(true)
}
})
}else{
editDrugBat(this.data).then(res =>{
if(res.data.code == 200){
this.$message.success('修改加药量成功')
this.closeDialog(true)
}
})
}
},
onLoad() {
// this.loading = true
// this.data = [...this.list]
// this.loading = false
// }
// console.log('list---------------',this.list)
// this.loading = true
// // setTimeout(() =>{
// this.data = this.list
console.log('data------------',this.data)
// this.loading = false
// // },200)
// this.data = this.list
// this.data = [
// {
// $cellEdit: true,
// id: '6',
// taskCode: 'CYSYXXXXXXXXX',
// slotNo: '#25', wcName: '化学镀镍作业中心', testEle: '氰化钠',
// proContent: 32,
// targetValue: 40,
// targetLowerLimit: 4,
// drugMatterCode: 'XXXX',
// drugName: 'XXXX',
// addPoints: 45,
// drugMatterName: "XXXX",
// targetUpperLimit: 45,
// testMan: {
// userId: '',
// userName: '张三',
// testEle: '张三'
// }, taskMethod: 1, taskMethodName: '需求生成',
// status: 0,
// statusName: '待接收',
// taskTime: '2025-01-22 12:23:35',
// testTime: '2025-01-22',
// needAdd: 444,
// actualAdd: 444,
// initialInspectionTime: '2025-01-23 11:12:23',
// finishTime: '',
// finishReason: '',
// meterNum: 32,
// condNum: 181,
// auditResult: 1,
// auditResultName: '审核通过',
// auditOpinion: '审核通过',
// auditUser: '张三',
// auditTime: '2025-01-25 15:33:26',
// drugBatch: '1002',
// drugRecipient: '',
// drugRecipientName: '张三',
// drugTime: '2025-01-25 11:23:56',
// meterNumTwo: 32,
// condNumTwo: 32,
// recheckUser: '李四',
// recheckTime: '2025-01-26 11:23:23',
// recheckSubmit: '2025-01-26 11:23:23'
// },
// {
// $cellEdit: true,
// id: '1',
// taskCode: 'CYSYXXXXXXXXX',
// slotNo: '#21', wcName: '化学镀镍作业中心', testEle: '氰化钠',
// proContent: 32,
// targetValue: 40,
// targetLowerLimit: 4,
// drugMatterCode: 'XXXX',
// drugName: 'XXXX',
// addPoints: 45,
// drugMatterName: "XXXX",
// targetUpperLimit: 45,
// testMan: {
// userId: '',
// userName: '张三',
// testEle: '张三'
// }, taskMethod: 1, taskMethodName: '周期生成',
// status: 1,
// statusName: '待检测',
// taskTime: '2025-01-22 12:23:35',
// testTime: '2025-01-22',
// needAdd: 444,
// actualAdd: 444,
// initialInspectionTime: '2025-01-23 11:12:23',
// finishTime: '',
// finishReason: '',
// meterNum: 32,
// condNum: 181,
// auditResult: 1,
// auditResultName: '审核通过',
// auditOpinion: '审核通过',
// auditUser: '张三',
// auditTime: '2025-01-25 15:33:26',
// drugBatch: '1002',
// drugRecipient: '',
// drugRecipientName: '张三',
// drugTime: '2025-01-25 11:23:56',
// meterNumTwo: 32,
// condNumTwo: 32,
// recheckUser: '李四',
// recheckTime: '2025-01-26 11:23:23',
// recheckSubmit: '2025-01-26 11:23:23'
// },
// {
// $cellEdit: true,
// id: '2',
// taskCode: 'CYSYXXXXXXXXX',
// slotNo: '#22', wcName: '化学镀镍作业中心', testEle: '氰化钠',
// proContent: 32,
// targetValue: 40,
// targetLowerLimit: 4,
// drugMatterCode: 'XXXX',
// drugName: 'XXXX',
// addPoints: 45,
// drugMatterName: "XXXX",
// targetUpperLimit: 45,
// testMan: {
// userId: '',
// userName: '张三',
// testEle: '张三'
// }, taskMethod: 1, taskMethodName: '周期生成',
// status: 4,
// statusName: '待复检',
// taskTime: '2025-01-22 12:23:35',
// testTime: '2025-01-22',
// needAdd: 444,
// actualAdd: 444,
// initialInspectionTime: '2025-01-23 11:12:23',
// finishTime: '',
// finishReason: '',
// meterNum: 32,
// condNum: 181,
// auditResult: 1,
// auditResultName: '审核通过',
// auditOpinion: '审核通过',
// auditUser: '张三',
// auditTime: '2025-01-25 15:33:26',
// drugBatch: '1002',
// drugRecipient: '',
// drugRecipientName: '张三',
// drugTime: '2025-01-25 11:23:56',
// meterNumTwo: 32,
// condNumTwo: 32,
// recheckUser: '李四',
// recheckTime: '2025-01-26 11:23:23',
// recheckSubmit: '2025-01-26 11:23:23'
// },
// {
// $cellEdit: true,
// id: '3',
// taskCode: 'CYSYXXXXXXXXX',
// slotNo: '#23', wcName: '化学镀镍作业中心', testEle: '氰化钠',
// proContent: 32,
// targetValue: 40,
// targetLowerLimit: 4,
// drugMatterCode: 'XXXX',
// drugName: 'XXXX',
// addPoints: 45,
// drugMatterName: "XXXX",
// targetUpperLimit: 45,
// testMan: {
// userId: '',
// userName: '张三',
// testEle: '张三'
// }, taskMethod: 1, taskMethodName: '周期生成',
// status: 5,
// statusName: '已完成',
// taskTime: '2025-01-22 12:23:35',
// testTime: '2025-01-22',
// needAdd: 444,
// actualAdd: 444,
// initialInspectionTime: '2025-01-23 11:12:23',
// finishTime: '',
// finishReason: '',
// meterNum: 32,
// condNum: 181,
// auditResult: 1,
// auditResultName: '审核通过',
// auditOpinion: '审核通过',
// auditUser: '张三',
// auditTime: '2025-01-25 15:33:26',
// drugBatch: '1002',
// drugRecipient: '',
// drugRecipientName: '张三',
// drugTime: '2025-01-25 11:23:56',
// meterNumTwo: 32,
// condNumTwo: 32,
// recheckUser: '李四',
// recheckTime: '2025-01-26 11:23:23',
// recheckSubmit: '2025-01-26 11:23:23'
// },
// ]
// this.page.total = this.data.length
// this.loading = false
// setTimeout(() => {
// this.selectionClear();
// }, 500)
}
}
}
</script>
<style lang="scss" scoped>
.inpu-text {
display: flex;
.el-input {
height: 32px;
// margin-top: 9px;
}
.el-date-editor.el-input, .el-date-editor.el-input__wrapper .el-input__inner {
height: var(--el-input-height,var(--el-component-size)) !important;
}
i {
font-style: normal;
line-height: 50px;
padding-left: 5px;
}
}
</style>