﻿<template>
	<div class="mesMaterialTestTaskHead-container">
		<el-dialog v-model="state.isShowDialog" v-if="state.isShowDialog" :width="1400" draggable="" :close-on-click-modal="false">
			<template #header>
				<div style="color: #fff">
					<!--<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit /> </el-icon>-->
					<span>{{ props.title }}</span>
				</div>
			</template>
			<el-form :model="state.ruleForm" ref="ruleFormRef" label-width="auto" :rules="rules">
				<el-row :gutter="35">
					<el-form-item v-show="false">
						<el-input v-model="state.ruleForm.id" />
					</el-form-item>
					<!-- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="报检单号" prop="inspJobNo">
							<el-input v-model="state.ruleForm.inspJobNo" placeholder="请输入报检单号" maxlength="50" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col> -->
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="MES编码" prop="productCode">
                           <el-input v-model="state.ruleForm.productCode"  placeholder="请选择MES编码" :readonly="isEditable"  clearable @keyup.enter="scanCode"  >
                               <template #append v-if="props.title=='编辑原材料检验任务'==false">
								  <el-icon  @click="scanCode"></el-icon><!--<ele-FullScreen />-->
								  <el-button @click="openChoose">选择</el-button>
                               </template>
                            </el-input>
						</el-form-item>
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="MES名称/所属类别" prop="productName">
							<el-input v-model="state.ruleForm.productName" readonly="true" placeholder="请输入MES名称/所属类别" maxlength="100" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="MES规格" prop="productModel">
							<el-input v-model="state.ruleForm.productModel" readonly="true" placeholder="请输入MES规格" maxlength="150" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20" v-if="props.title=='添加原材料检验任务'">
						<el-form-item label="检验类型" prop="inspType">
							<el-select clearable v-model="state.ruleForm.inspType" placeholder="请选择检验类型" :readonly="isEditable"  >
								<el-option v-for="(item,index) in checktype"  :key="index" :value="item.code"  :label="`${item.name} [${item.value}]`" ></el-option>

							</el-select>

						</el-form-item>

					</el-col>

					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="材料名称" prop="materialType">
							<el-select  filterable v-model="state.ruleForm.materialType" placeholder="请选择材料名称" readonly="isEditable"  @change="onChooseMaterialFinishApplyType">
								<el-option v-for="(item,index) in mesQiItemQiItemCodeDropdownList" :key="index" :value="item.code" :label="item.name" />

							</el-select>
						</el-form-item>
						
					</el-col>
					<!-- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="检验状态" prop="inspJobStatus">
							<el-switch v-model="state.ruleForm.inspJobStatus" active-text="是" inactive-text="否" />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="审核状态" prop="inspStatus">
							<el-switch v-model="state.ruleForm.inspStatus" active-text="是" inactive-text="否" />
							
						</el-form-item>
						
					</el-col> -->
					
					<!-- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="结论" prop="inspResult">
							<el-input v-model="state.ruleForm.inspResult" placeholder="请输入结论" maxlength="32" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col> -->
					<!-- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20" v-if="state.ruleForm.id">
						<el-form-item label="不合格处置" prop="inPassHandle">
							<el-input v-model="state.ruleForm.inPassHandle" placeholder="请输入不合格处置" maxlength="255" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col> -->
					<!-- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="送检人账号" prop="sendPersonAccount">
							<el-input v-model="state.ruleForm.sendPersonAccount" placeholder="请输入送检人账号" maxlength="32" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="送检人名称" prop="sendPersonName">
							<el-input v-model="state.ruleForm.sendPersonName" placeholder="请输入送检人名称" maxlength="32" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="送检时间" prop="sendDate">
							<el-date-picker v-model="state.ruleForm.sendDate" type="date" placeholder="送检时间" />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="检验人账号" prop="inspPersonAccount">
							<el-input v-model="state.ruleForm.inspPersonAccount" placeholder="请输入检验人账号" maxlength="32" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="检验人名称" prop="inspPersonName">
							<el-input v-model="state.ruleForm.inspPersonName" placeholder="请输入检验人名称" maxlength="32" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="检验时间" prop="inspDate">
							<el-date-picker v-model="state.ruleForm.inspDate" type="date" placeholder="检验时间" />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="审核人账号" prop="examinePersonAccount">
							<el-input v-model="state.ruleForm.examinePersonAccount" placeholder="请输入审核人账号" maxlength="32" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="审核人名称" prop="examinePersonName">
							<el-input v-model="state.ruleForm.examinePersonName" placeholder="请输入审核人名称" maxlength="32" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="审核时间" prop="examineDate">
							<el-date-picker v-model="state.ruleForm.examineDate" type="date" placeholder="审核时间" />
							
						</el-form-item>
						
					</el-col> -->
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20" v-if="props.title=='添加原材料检验任务'">
						<el-form-item label="供应商编码" prop="supplierCode">
                           <el-input v-model="state.ruleForm.supplierCode"  placeholder="请选择供应商" readonly="true" maxlength="100" show-word-limit clearable >
                               <template #append >
                                  <el-button @click="openSupper">选择</el-button>
                               </template>
                            </el-input>
						</el-form-item>
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20" v-if="props.title=='添加原材料检验任务'">
						<el-form-item label="供应商名称" prop="supplierName">
							<el-input v-model="state.ruleForm.supplierName" placeholder="请输入供应商名称" readonly="true" maxlength="100" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20" v-if="props.title=='添加原材料检验任务'">
						<el-form-item label="产品名称规格" prop="partSpec">
							<el-input v-model="state.ruleForm.partSpec" placeholder="请输入产品名称规格" :readonly="isEditable"  maxlength="150" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<!-- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="材料进厂批次" prop="materialSpec">
							<el-input v-model="state.ruleForm.materialSpec" placeholder="请输入材料进厂批次" maxlength="64" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col> -->
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20" >
						<el-form-item label="材料进厂批次" prop="materialSpec">
							<el-date-picker v-model="state.ruleForm.materialSpec" format="YYYYMMDD" value-farmat="YYYYMMDD" placeholder="请输入材料进厂批次"  :readonly="isEditable"   show-word-limit clearable />
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="检验批次" prop="testSpec">
							<el-input v-model="state.ruleForm.testSpec" placeholder="请输入检验批次" readonly="true" maxlength="100" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20" v-if="props.title=='添加原材料检验任务'">
						<el-form-item label="钢厂炉号" prop="heatNumber">
							<el-input v-model="state.ruleForm.heatNumber" placeholder="请输入钢厂炉号" :readonly="isEditable"  maxlength="100" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20" v-if="props.title=='添加原材料检验任务'">
						<el-form-item label="冷轧厂卡号" prop="cartNumber">
							<el-input v-model="state.ruleForm.cartNumber" placeholder="请输入冷轧厂卡号" :readonly="isEditable"  maxlength="255" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="进货数量" prop="purchaseNumber">
							<el-input-number v-model="state.ruleForm.purchaseNumber" placeholder="请输入进货数量" :readonly="isEditable"   min="1" maxlength="18" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20" >
						<el-form-item label="单位名称" prop="unitName">
							<el-input v-model="state.ruleForm.unitName" placeholder="单位名称"   maxlength="255" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="进货件数" prop="purchaseQuantity">
							<el-input-number v-model="state.ruleForm.purchaseQuantity" placeholder="请输入进货件数" :readonly="isEditable"   :precision="0" min="1" maxlength="18" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<!-- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="排序" prop="sortCode">
							<el-input-number v-model="state.ruleForm.sortCode" placeholder="请输入排序" clearable />
							
						</el-form-item>
						
					</el-col> -->
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20" v-if="props.title=='添加原材料检验任务'">
						<el-form-item label="描述" prop="remark">
							<el-input v-model="state.ruleForm.remark"  show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
				</el-row>
			</el-form>
			<template #footer>
				<span class="dialog-footer">
					<el-button @click="cancel">取 消</el-button>
					<el-button type="primary" @click="submit">确 定</el-button>
				</span>
			</template>
			<!-- <template v-if="state.ruleForm.id">
                <el-tabs v-model="tabActive">
                <el-tab-pane label="检验项目及标准" name="item"></el-tab-pane>
                </el-tabs>
                <MesQiInspTempItem :qiInspJobIds="state.ruleForm.id+'-'+state.ruleForm.samplingNumMax+'-修改'" v-if="tabActive == 'item'"></MesQiInspTempItem>
            </template> -->
			<template v-if="props.title=='添加原材料检验任务'">
                <el-tabs v-model="tabActive">
                <el-tab-pane label="检验项目及标准" name="item"></el-tab-pane>
                </el-tabs>
                <el-table :data="detailList">
				<el-table-column type="index" label="序号" width="55" align="center" />
                <el-table-column prop="qiItemName" label="检验项名称" align="center" width="120"  show-overflow-tooltip="" />
                <el-table-column prop="testRequire" label="检验要求" align="center" width="100"  show-overflow-tooltip="" />
				<el-table-column prop="samplingNum" label="取样数" align="center" width="100"  show-overflow-tooltip="" />
				<el-table-column prop="standVal" label="标准值" align="center" width="100"  show-overflow-tooltip="" />
				<el-table-column prop="maxVal" label="上限值" align="center" width="100"  show-overflow-tooltip="" />
				<el-table-column prop="minVal" label="下限值" align="center" width="100"  show-overflow-tooltip="" />
            </el-table>
            </template>
			<template v-if="props.title=='编辑原材料检验任务'">
                <el-tabs v-model="tabActive">
                <el-tab-pane label="检验项目及标准" name="item"></el-tab-pane>
                </el-tabs>
                <el-table :data="detailList" :span-method="mergeRowMethod">
				<el-table-column type="index" label="序号" width="55" align="center" />
                <el-table-column prop="qiItemName" label="检验项名称" width="120" align="center" show-overflow-tooltip="" />
                <el-table-column prop="testRequire" label="检验要求" width="180" align="center" show-overflow-tooltip="" />
				<el-table-column prop="standVal" label="标准值" width="100" align="center"  show-overflow-tooltip="" />
				<el-table-column prop="maxVal" label="上限值" width="100" align="center"  show-overflow-tooltip="" />
				<el-table-column prop="minVal" label="下限值" width="100" align="center" show-overflow-tooltip="" />
				<el-table-column prop="samplingNum" label="取样数" width="100" align="center"  show-overflow-tooltip="" />
				<el-table-column prop="resultVal1" label="检验结果值1" v-if="state.ruleForm.samplingNumMax>=1==true" align="center" show-overflow-tooltip="" >
                  <template  #default="scope">
                    <el-input  v-model="scope.row.resultVal1"  @input="handleInput1(scope.row)" ></el-input>
                  </template>
                </el-table-column>
				<el-table-column prop="resultVal2" label="检验结果值2" v-if="state.ruleForm.samplingNumMax>=2==true" align="center" show-overflow-tooltip="" >
                  <template  #default="scope">
                    <el-input  v-model="scope.row.resultVal2" @input="handleInput2(scope.row)"></el-input>
                  </template>
                </el-table-column>
				<el-table-column prop="resultVal3" label="检验结果值3" v-if="state.ruleForm.samplingNumMax>=3==true" align="center" show-overflow-tooltip="" >
                  <template  #default="scope">
                    <el-input  v-model="scope.row.resultVal3" @input="handleInput3(scope.row)"></el-input>
                  </template>
                </el-table-column>
				<el-table-column prop="resultVal4" label="检验结果值4" v-if="state.ruleForm.samplingNumMax>=4==true" align="center" show-overflow-tooltip="" >
                  <template  #default="scope">
                    <el-input  v-model="scope.row.resultVal4" @input="handleInput4(scope.row)"></el-input>
                  </template>
                </el-table-column>
				<el-table-column prop="resultVal5" label="检验结果值5" v-if="state.ruleForm.samplingNumMax>=5==true" align="center" show-overflow-tooltip="" >
                  <template  #default="scope">
                    <el-input v-model="scope.row.resultVal5" @input="handleInput5(scope.row)"></el-input>
                  </template>
                </el-table-column>
				<el-table-column prop="inspResult" label="结论" align="center"  show-overflow-tooltip="" >
                </el-table-column>
				<el-table-column prop="remark" label="描述" align="center" show-overflow-tooltip="" >
                  <template  #default="scope">
                    <el-input type="text" v-model="scope.row.remark" ></el-input>
                  </template>
                </el-table-column>
            </el-table>
            </template>
		</el-dialog>
		<!--  选择原材料  -->
		<choose-material title="选择原材料" ref="chooseMaterialRef"  :is-any="false" @finish="onChooseMaterialFinish"></choose-material>
		<!--  选择供应商  -->
		<choose-supper title="选择原材料" ref="chooseSupperRef"  :is-any="false" @finish="onChooseSupperFinish"></choose-supper>
	</div>
</template>
<style lang="scss" scoped>
:deep(.el-select),
:deep(.el-input-number) {
	width: 100%;
}
</style>
<script lang="ts" setup>
    import { ref,onMounted, reactive } from "vue";
	import {ElMessageBox, ElMessage } from "element-plus";
	import type { FormRules } from "element-plus";
	import { addMesMaterialTestTaskHead, updateMesMaterialTestTaskHead, detailMesMaterialTestTaskHead,getMesQiItemQiItemCodeDropdown ,ScanMaintel,ScanSupper,sendProducePlanTemplate,getMesQiItemQiItemCodeDropdowns,getMesQiItemQiItemCode,getMesQiItemQiItemList} from "/@/api/simple/mesMaterialTestTaskHead";
	import { pageMesMaterialTestTaskHead, deleteMesMaterialTestTaskHead } from '/@/api/simple/mesMaterialTestTaskHead';
	import { getDictDataItem as di, getDictDataList as dl } from '/@/utils/dict-utils';
  	import { formatDate } from '/@/utils/formatTime';
	//import ChooseMaterial from "/@/businessComponents/chooseMaterial.vue";
	import ChooseMaterial from "/@/views/simple/mesmaterialtesttemplatehead/component/chooseMaterial.vue";
	import ChooseSupper from "/@/views/simple/mesMaterialTestTaskHead/component/chooseSupper.vue";
	import MesQiInspTempItem from "/@/views/simple/mesMaterialTestTaskDetial/index.vue";
    import { disable } from "ol/rotationconstraint";
	import { nextTick } from "vue";
	//父级传递来的参数
	var props = defineProps({
		title: {
		type: String,
		default: "",
	},
	});
	//父级传递来的函数，用于回调
	const emit = defineEmits(["reloadTable"]);
	const ruleFormRef = ref();
    const state = reactive({
    isShowDialog: false,
    ruleForm: {} as any,
});

 // 子表
 const detailList = ref([]);

const checktype=ref([]);//检验的表
	//自行添加其他规则
	const rules = ref<FormRules>({
	});

	// 页面加载时
	onMounted(() => {

	});
const isEditable=ref(false);
	// 打开弹窗
	const openDialog = async (row: any) => {
		// state.ruleForm = JSON.parse(JSON.stringify(row));
		// 改用detail获取最新数据来编辑
		detailList.value = [];
		checktype.value=[];
		let list: any[] = (dl('materialchecktype') || []).map((item: any) => ({
        ...item,
		code:item.code,
        name: item.name,
        value: item.value,
      }));
	
	  for(let index=0;index<list.length;index++)
	  {
		if(list[index]["name"]=="原材料检验")
		{
			checktype.value.push(list[index]);
		}
	  }
	  
		let rowData = JSON.parse(JSON.stringify(row));
		if (rowData.id)
	    {
			state.ruleForm = (await detailMesMaterialTestTaskHead(rowData.id)).data.result;
			console.log(`${rowData.materialCode}`);
			getMesQiItemQiItemCodeDropdownList(`${rowData.materialCode}`);
			state.ruleForm.inspType=`${rowData.inspType}`;
			state.ruleForm.materialSpec=`${rowData.materialSpec}`;
			state.ruleForm.materialType=`${rowData.materialType}`;
			if(props.title=="编辑原材料检验任务")
		    {
				isEditable.value=true;
				getMesQiItemQiItemCodeDropdownList(rowData.productCode);
		    }
			let list = await getMesQiItemQiItemList({
          id:rowData.id,
         });
		 let datas = list.data.result ?? [];
		 detailList.value.push(...datas);
	    }
		else
		{
			state.ruleForm = rowData;
			state.ruleForm.inspType="1";
			isEditable.value=false;
			//state.ruleForm.materialType="Standard";
		}
		if(props.title=="添加原材料检验任务")
		{
			isEditable.value=false;
		}
		state.isShowDialog = true;
	};

	// 关闭弹窗
	const closeDialog = () => {
		emit("reloadTable");
		state.isShowDialog = false;
	};

	// 取消
	const cancel = () => {
		emit("reloadTable");
		state.isShowDialog = false;
	};

	// 提交
	const submit = async () => {
		ruleFormRef.value.validate(async (isValid: boolean, fields?: any) => {
			if (isValid) {
				let values = state.ruleForm;
				if(state.ruleForm.productCode==undefined)
			    {
			    	return ElMessage({
                     message: `请输入ERP编码！`,
                     type: "error",
                    });
			    }
				if(state.ruleForm.materialSpec==undefined)
			    {
			    	return ElMessage({
                     message: `请输入材料进厂批次！`,
                     type: "error",
                    });
			    }
				if(state.ruleForm.partSpec==undefined)
			    {
			    	return ElMessage({
                     message: `请输入产品名称规格！`,
                     type: "error",
                    });
			    }
				if(state.ruleForm.purchaseNumber==undefined)
			    {
			    	return ElMessage({
                     message: `请输入进货数量！`,
                     type: "error",
                    });
			    }
				if(state.ruleForm.purchaseQuantity==undefined)
			    {
			    	return ElMessage({
                     message: `请输入进货件量！`,
                     type: "error",
                    });
			    }
				
				var numReg = /^[0-9]+$/
				if (!numReg.test(state.ruleForm.materialSpec))
				{
					state.ruleForm.materialSpec=new Date(state.ruleForm.materialSpec);
					state.ruleForm.materialSpec=state.ruleForm.materialSpec.getFullYear()+('0' + (state.ruleForm.materialSpec.getMonth() + 1)).slice(-2)+state.ruleForm.materialSpec.getDate().toString().padStart(2, '0');
				}
				if (state.ruleForm.id == undefined || state.ruleForm.id == null || state.ruleForm.id == "" || state.ruleForm.id == 0) {
					//await addMesMaterialTestTaskHead(values);
					
					var result=(await addMesMaterialTestTaskHead(values)).data.result;
					if(result=="添加成功")
					 closeDialog();
					else
					{
					  ElMessage({
					    message: `${result}`,
					    type: "error",
				       });
					}
				} else {
					values.data=detailList.value;
					//debugger
					const result=ref(true);
					for(let index=0;index<values.data.length;index++) {
					
				    if(values.data[index].qiItemCode=="QT003")
					{

					}
					else if(values.data[index].qiItemCode=="QT001")
					{
                        if(values.data[index].inspResult ==undefined  && values.data[index].inspResult==null)
					    {
					    	if(values.data[index].resultVal1 ==undefined  && values.data[index].resultVal1==null){
                             return ElMessage({
                             message: `当前检验原材料中第${index+1}行中存在未输入的检验项`,
                             type: "error",
                            });
                         }
					    }
						if(values.data[index].inspResult=="不合格")
				        {
					       result.value=false;
				        }
					}
					else{
						if(state.ruleForm.samplingNumMax==1)
					  {
						if(values.data[index].resultVal1 ==undefined && values.data[index].resultVal1==null){
                        return ElMessage({
                        message: `当前检验原材料中第${index+1}行中存在未输入的检验项`,
                        type: "error",
                        });
                        }
	                  }
					  else if(state.ruleForm.samplingNumMax==2)
					  {
						if(values.data[index].resultVal1 ==undefined  && values.data[index].resultVal1==null){
                        return ElMessage({
                        message: `当前检验原材料中第${index+1}行中存在未输入的检验项`,
                        type: "error",
                        });
                        }
						if(values.data[index].resultVal2 ==undefined  && values.data[index].resultVal2==null){
                        return ElMessage({
                        message: `当前检验原材料中第${index+1}行中存在未输入的检验项`,
                        type: "error",
                        });
                        }
					  }
					  else if(state.ruleForm.samplingNumMax==4)
					  {
						if(values.data[index].resultVal1 ==undefined && values.data[index].resultVal1==null){
                        return ElMessage({
                        message: `当前检验原材料中第${index+1}行中存在未输入的检验项`,
                        type: "error",
                        });
                        }
						if(values.data[index].resultVal2 ==undefined && values.data[index].resultVal2==null){
                        return ElMessage({
                        message: `当前检验原材料中第${index+1}行中存在未输入的检验项`,
                        type: "error",
                        });
                        }
						if(values.data[index].resultVal3 ==undefined  && values.data[index].resultVal3==null){
                        return ElMessage({
                        message: `当前检验原材料中第${index+1}行中存在未输入的检验项`,
                        type: "error",
                        });
                        }
						if(values.data[index].resultVal4 ==undefined  && values.data[index].resultVal4==null){
                        return ElMessage({
                        message: `当前检验原材料中第${index+1}行中存在未输入的检验项`,
                        type: "error",
                        });
                        }
					  }
					  else if(state.ruleForm.samplingNumMax==3)
					  {
						console.log(values.data[index].resultVal1);
						if(values.data[index].resultVal1 ==undefined  && values.data[index].resultVal1==null){
                        return ElMessage({
                        message: `当前检验原材料中第${index+1}行中存在未输入的检验项`,
                        type: "error",
                        });
                        }
						if(values.data[index].resultVal2 ==undefined  && values.data[index].resultVal2==null){
                        return ElMessage({
                        message: `当前检验原材料中第${index+1}行中存在未输入的检验项`,
                        type: "error",
                        });
                        }
						if(values.data[index].resultVal3 ==undefined  && values.data[index].resultVal3==null){
                        return ElMessage({
                        message: `当前检验原材料中第${index+1}行中存在未输入的检验项`,
                        type: "error",
                        });
                        }
					  }
					  else if(state.ruleForm.samplingNumMax==5)
					  {
						if(values.data[index].resultVal1 ==undefined  && values.data[index].resultVal1==null){
                        return ElMessage({
                        message: `当前检验原材料中第${index+1}行中存在未输入的检验项`,
                        type: "error",
                        });
                        }
						if(values.data[index].resultVal2 ==undefined  && values.data[index].resultVal2==null){
                        return ElMessage({
                        message: `当前检验原材料中第${index+1}行中存在未输入的检验项`,
                        type: "error",
                        });
                        }
						if(values.data[index].resultVal3 ==undefined  && values.data[index].resultVal3==null){
                        return ElMessage({
                        message: `当前检验原材料中第${index+1}行中存在未输入的检验项`,
                        type: "error",
                        });
                        }
						if(values.data[index].resultVal4 ==undefined && values.data[index].resultVal4==null){
                        return ElMessage({
                        message: `当前检验原材料中第${index+1}行中存在未输入的检验项`,
                        type: "error",
                        });
                        }
						if(values.data[index].resultVal5 ==undefined  && values.data[index].resultVal5==null){
                        return ElMessage({
                        message: `当前检验原材料中第${index+1}行中存在未输入的检验项`,
                        type: "error",
                        });
                        }
					  }
					  if(values.data[index].inspResult=="不合格")
				        {
					       result.value=false;
				        }
					}
					 
					}
		             
					//await updateMesMaterialTestTaskHead(values);
					//closeDialog();
				if(result.value==false)
				{
					ElMessageBox.confirm(`当前检验信息存在不合格是否确认提交?`, '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning',
					})
					.then(async () => {
						await updateMesMaterialTestTaskHead(values);
						closeDialog();
					})
					.catch(() => {});
					
				}
				else{
					await updateMesMaterialTestTaskHead(values);
					closeDialog();
				}
				}
				
			} else {
				ElMessage({
					message: `表单有${Object.keys(fields).length}处验证失败，请修改后再提交`,
					type: "error",
				});
			}
		});
	};

	const tabActive = ref('item');
	const chooseMaterialRef = ref();
    const openChoose = ()=>{
      chooseMaterialRef.value.openDialog({})
    }
    const onChooseMaterialFinish = async(row)=>{
      state.ruleForm.productName = row?.materialName;
      state.ruleForm.productCode = row?.materialCode;
      state.ruleForm.productModel = row?.specs;

	  //判断当前先择的原材料是否存在检验模板
	  let listtemplate = await sendProducePlanTemplate({packCode:state.ruleForm.productCode,});
	  let datatemplate = listtemplate.data.result ?? [];
	  if(datatemplate.length==0)
	  {
		state.ruleForm.productName = "";
        state.ruleForm.productCode = "";
        state.ruleForm.productModel = "";
		return ElMessage({
        message: `当前${ row?.materialCode}产品没有原材料检验模板，请先维护原材料检验模板`,
        type: "error",
      });
	  }

	  //生成进厂检验规则
      let list = await getMesQiItemQiItemCodeDropdown({packCode:state.ruleForm.productCode,});
      let data = list.data.result ?? [];
	  if(data.length==0)
	  {
		  const datenow=new Date();
		  const datanow=datenow.getFullYear()+('0' + (datenow.getMonth() + 1)).slice(-2)+datenow.getDate().toString().padStart(2, '0');
		  state.ruleForm.testSpec=datanow+row?.materialCode+"0001";
	  }
	  else{
		const datenow=data[0].testSpec;
		let num=datenow.substring(datenow.length-4);
		let number=parseFloat(num)+1;
		state.ruleForm.testSpec=datenow.substring(0,datenow.length-4)+number.toString().padStart(4,'0');
	  }
	  //getMesQiItemQiItemCodeDropdownList(row?.materialCode);
	  let lists = await getMesQiItemQiItemCodeDropdowns({
        packCode:row?.materialCode,
         });
		mesQiItemQiItemCodeDropdownList.value = lists.data.result ?? [];
	  state.ruleForm.materialType=mesQiItemQiItemCodeDropdownList.value[0].code;
	  onChooseMaterialFinishApplyType("");
	  
    }

	const chooseSupperRef = ref();
    const openSupper = ()=>{
      chooseSupperRef.value.openDialog({})
    }
    const onChooseSupperFinish = (row)=>{
      state.ruleForm.supplierName = row?.supplierName;
      state.ruleForm.supplierCode = row?.supplierCode;
    }

	// 扫码载具转移前条码
	const scanCode = async ()=>{
		
	  console.log(state.ruleForm.productCode);
	  const matial=state.ruleForm.productCode.split('*');
	  if(matial.length!=5)
	  {
		return ElMessage({
        message: `二维码信息不正确`,
        type: "error",
      });
	  }

	  //判断当前先择的原材料是否存在检验模板
	  let listtemplate = await sendProducePlanTemplate({packCode:matial[0],});
	  let datatemplate = listtemplate.data.result ?? [];
	  if(datatemplate.length==0)
	  {
		state.ruleForm.productCode="";
		return ElMessage({
        message: `当前${ matial[0]}产品没有原材料检验模板，请先维护原材料检验模板`,
        type: "error",
      });
	  }

      //查询原材料编码
      let  res = await ScanMaintel({
        packCode:matial[0],
      })
      let datas = res.data.result || {};
	  if(datas.materialCode==undefined)
	  {
		state.ruleForm.productCode="";
        state.ruleForm.productName="";
	    state.ruleForm.productModel="";
        state.ruleForm.heatNumber="";

	    state.ruleForm.purchaseNumber="";
	    state.ruleForm.purchaseQuantity="";
		return ElMessage({
        message: `系统中不存在当前原材料信息`,
        type: "error",
      });
	  }
	  else
	  {
		state.ruleForm.productName = datas.materialName;
        state.ruleForm.productCode = datas.materialCode;
        state.ruleForm.productModel = datas.specs;
		state.ruleForm.heatNumber=matial[2];
		state.ruleForm.purchaseNumber=matial[3];
	    state.ruleForm.purchaseQuantity=matial[4];
	    //生成进厂检验规则
        let list = await getMesQiItemQiItemCodeDropdown({packCode:state.ruleForm.productCode,});
        let data = list.data.result ?? [];
	    if(data.length==0)
	    {
		  const datenow=new Date();
		  const datanow=datenow.getFullYear()+('0' + (datenow.getMonth() + 1)).slice(-2)+datenow.getDate().toString().padStart(2, '0');
		  state.ruleForm.testSpec=datanow+datas.materialCode+"0001";
	    }
	    else{
		const datenow=data[0].testSpec;
		let num=datenow.substring(datenow.length-4);
		let number=parseFloat(num)+1;
		state.ruleForm.testSpec=datenow.substring(0,datenow.length-4)+number.toString().padStart(4,'0');
	    }
	  }
	  //getMesQiItemQiItemCodeDropdownList(datas?.materialCode);
	  let lists = await getMesQiItemQiItemCodeDropdowns({
        packCode:datas?.materialCode,
         });
		mesQiItemQiItemCodeDropdownList.value = lists.data.result ?? [];
	  state.ruleForm.materialType=mesQiItemQiItemCodeDropdownList.value[0].code;
	  onChooseMaterialFinishApplyType("");
	  //查询供应商信息
	  let  res1 = await ScanSupper({
        packCode:matial[1],
      })
      let data1 = res1.data.result || {};
	  if(data1.supplierCode==undefined)
	  {
		state.ruleForm.supplierCode="";
        state.ruleForm.supplierName="";
		return ElMessage({
        message: `系统中不存在当前供应商信息`,
        type: "error",
      });
	  }
	  else{
		state.ruleForm.supplierCode = data1.supplierCode;
        state.ruleForm.supplierName = data1.supplierName;
	  }
    }

	//查询原材料检验类型
	const mesQiItemQiItemCodeDropdownList = ref<any>([]);
	const getMesQiItemQiItemCodeDropdownList = async (maintial:any) => {
		let list = await getMesQiItemQiItemCodeDropdowns({
        packCode:maintial,
         });
		mesQiItemQiItemCodeDropdownList.value = list.data.result ?? [];
	};


		//原材料有值后进行选择值
	  const onChooseMaterialFinishApplyType = async(data: any) => {
		detailList.value = [];
		let list = await getMesQiItemQiItemCode({
          packCode:state.ruleForm.productCode,packType:state.ruleForm.materialType,
         });
		 let datas = list.data.result ?? [];
		 detailList.value.push(...datas);
    };

	//值1
	const handleInput1=(value:any) =>{
      // 允许输入的字符串
	  const allowedValues = ['o','O','k','K','N','G','n','g','ｏ','Ｏ','ｋ','Ｋ','Ｎ','Ｇ','ｎ','ｇ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9','.','-','－','．', '０', '１', '２', '３', '４', '５', '６', '７', '８', '９'];
      // 当前输入的字符
      const currentChar = value.resultVal1.slice(-1);
      // 判断当前字符是否在允许的字符串内
      if (allowedValues.includes(currentChar)) {
        // 允许输入
        value.resultVal1 = ToCDB(value.resultVal1.toUpperCase());
		handleInput(value,value.resultVal1);
      } else {
        // 不允许输入，将输入值回退到上一个合法状态
        nextTick(() => {
			value.resultVal1 = value.resultVal1.slice(0, -1);
        });
      }
	  
    }

//值2
const handleInput2=(value:any) =>{
      // 允许输入的字符串
	  const allowedValues = ['o','O','k','K','N','G','n','g','ｏ','Ｏ','ｋ','Ｋ','Ｎ','Ｇ','ｎ','ｇ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9','.','-','－','．', '０', '１', '２', '３', '４', '５', '６', '７', '８', '９'];
      // 当前输入的字符
      const currentChar = value.resultVal2.slice(-1);
      // 判断当前字符是否在允许的字符串内
      if (allowedValues.includes(currentChar)) {
        // 允许输入
        value.resultVal2 = ToCDB(value.resultVal2.toUpperCase());
		handleInput(value,value.resultVal2);
      } else {
        // 不允许输入，将输入值回退到上一个合法状态
        nextTick(() => {
			value.resultVal2 = value.resultVal2.slice(0, -1);
        });
      }
    }

	//值3
	const handleInput3=(value:any) =>{
      // 允许输入的字符串
	  const allowedValues = ['o','O','k','K','N','G','n','g','ｏ','Ｏ','ｋ','Ｋ','Ｎ','Ｇ','ｎ','ｇ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9','.','-','－','．', '０', '１', '２', '３', '４', '５', '６', '７', '８', '９'];   
	   // 当前输入的字符
	   const currentChar = value.resultVal3.slice(-1);
      // 判断当前字符是否在允许的字符串内
      if (allowedValues.includes(currentChar)) {
        // 允许输入
        value.resultVal3 = ToCDB(value.resultVal3.toUpperCase());
		handleInput(value,value.resultVal3);
      } else {
        // 不允许输入，将输入值回退到上一个合法状态
        nextTick(() => {
			value.resultVal3 = value.resultVal3.slice(0, -1);
        });
      }
    }

	//值4
	const handleInput4=(value:any) =>{
      // 允许输入的字符串
	  const allowedValues = ['o','O','k','K','N','G','n','g','ｏ','Ｏ','ｋ','Ｋ','Ｎ','Ｇ','ｎ','ｇ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9','.','-','－','．', '０', '１', '２', '３', '４', '５', '６', '７', '８', '９'];
       // 当前输入的字符
	   const currentChar = value.resultVal4.slice(-1);
      // 判断当前字符是否在允许的字符串内
      if (allowedValues.includes(currentChar)) {
        // 允许输入
        value.resultVal4 = ToCDB(value.resultVal4.toUpperCase());
		handleInput(value,value.resultVal4);
      } else {
        // 不允许输入，将输入值回退到上一个合法状态
        nextTick(() => {
			value.resultVal4 = value.resultVal4.slice(0, -1);
        });
      }
    }

	//值5
	const handleInput5=(value:any) =>{
      // 允许输入的字符串
	  const allowedValues = ['o','O','k','K','N','G','n','g','ｏ','Ｏ','ｋ','Ｋ','Ｎ','Ｇ','ｎ','ｇ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9','.','-','－','．', '０', '１', '２', '３', '４', '５', '６', '７', '８', '９'];
       // 当前输入的字符
	   const currentChar = value.resultVal5.slice(-1);
      // 判断当前字符是否在允许的字符串内
      if (allowedValues.includes(currentChar)) {
        // 允许输入
        value.resultVal5 = ToCDB(value.resultVal5.toUpperCase());
		handleInput(value,value.resultVal5);
      } else {
        // 不允许输入，将输入值回退到上一个合法状态
        nextTick(() => {
			value.resultVal5 = value.resultVal5.slice(0, -1);
        });
      }
    }

	//全角转半角
	const ToCDB=(str:any) =>{
        // 全角转半角
        var tmp = void 0;
        if (str) {
            tmp = '';
            for (var i = 0; i < str.length; i++) {
                if (str.charCodeAt(i) == 12288) {
                    tmp += String.fromCharCode(32);
                } else if (str.charCodeAt(i) == 160) {
                    tmp += String.fromCharCode(32); // 处理下Unicode为160的特殊空格
                } else if (str.charCodeAt(i) > 65248 && str.charCodeAt(i) < 65375) {
                    tmp += String.fromCharCode(str.charCodeAt(i) - 65248);
                } else {
                    tmp += str[i];
                }
            }
        } else {
            tmp = str;
        }
        return tmp;
      }

//统一判断方法
const handleInput=(value:any,number:any) =>{
	const hege=ref();//值1是否合格判断
	const Nohege=ref();//值2是否合格判断
	const hegeN=ref();//值3是否合格判断
	const NohegeNo=ref();//值4是否合格判断
	const Nhege=ref();//值5是否合格判断
	//所有前提都是不为外观检验和芯板
    if(value.qiItemCode=="QT001")//外观检验
    {
    	 value.resultVal1=number;
		 value.resultVal2=number;
		 value.resultVal3=number;
		 value.resultVal4=number;
		 value.resultVal5=number;
		 if(number=="OK")
		    value.inspResult="合格";
		else
		    value.inspResult="不合格";
    }
	else if(value.qiItemCode=="QT003")//芯板
	{
         value.resultVal1=undefined;
		 value.resultVal2=undefined;
		 value.resultVal3=undefined;
		 value.resultVal4=undefined;
		 value.resultVal5=undefined;
		 value.inspResult=undefined;
	}
	else{
    //判断值1不为空的情况下
	if(value.resultVal1!=undefined && value.resultVal1 !="")
	{
		if(/[A-Za-z]/.test(value.resultVal1))
		{
             if(value.resultVal1=="OK")
			   hege.value="合格";
			else
			   hege.value="不合格";
		}
		else{
        //判断是否存在标准值，标准值不为0的
	   if(value.standVal!=undefined)
	   {
		  if(value.maxVal==undefined)
		  {
			value.maxVal=0;
		  }
		  if(value.minVal==undefined)
		  {
			value.minVal=0;
		  }
		  if(parseFloat(value.standVal)+parseFloat(value.maxVal)>=parseFloat(value.resultVal1) && parseFloat(value.standVal)-parseFloat(value.minVal)<=parseFloat(value.resultVal1))
		  {
			hege.value="合格";
		  }else
	        hege.value="不合格";
	   }
	   //判断只存在最小值的
         else if(value.minVal!=undefined && value.standVal==undefined &&  value.maxVal==undefined)
	   {
		if(parseFloat(value.minVal)>parseFloat(value.resultVal1) )
		  {
			hege.value="不合格";
		  }else
	        hege.value="合格";
	   }
	   //判断最大值最小值都不为0的
	   else if(value.minVal!=undefined && value.standVal==undefined &&  value.maxVal!=undefined)
	   {
		if(parseFloat(value.minVal)<=parseFloat(value.resultVal1) &&  parseFloat(value.maxVal)>=parseFloat(value.resultVal1))
		  {
			hege.value="合格";
		  }else
	        hege.value="不合格";
	   }
	}
	}
	  //判断值2不为空的情况下
	if(value.resultVal2!=undefined && value.resultVal2 !="")
	{
		//判断值2否是字符类型的
		if(/[A-Za-z]/.test(value.resultVal2))
		{
             if(value.resultVal2=="OK")
			 Nohege.value="合格";
			else
			Nohege.value="不合格";
		}
		else{
        //判断是否存在标准值，标准值不为0的
	   if(value.standVal!=undefined)
	   {
		  if(value.maxVal==undefined)
		  {
			value.maxVal=0;
		  }
		  if(value.minVal==undefined)
		  {
			value.minVal=0;
		  }
		  if(parseFloat(value.standVal)+parseFloat(value.maxVal)>=parseFloat(value.resultVal2) && parseFloat(value.standVal)-parseFloat(value.minVal)<=parseFloat(value.resultVal2))
		  {
			Nohege.value="合格";
		  }else
		  Nohege.value="不合格";
	   }
	   //判断只存在最小值的
         else if(value.minVal!=undefined && value.standVal==undefined &&  value.maxVal==undefined)
	   {
		if(parseFloat(value.minVal)>parseFloat(value.resultVal2) )
		  {
			Nohege.value="不合格";
		  }else
		  Nohege.value="合格";
	   }
	   //判断最大值最小值都不为0的
	   else if(value.minVal!=undefined && value.standVal==undefined &&  value.maxVal!=undefined)
	   {
		if(parseFloat(value.minVal)<=parseFloat(value.resultVal2) &&  parseFloat(value.maxVal)>=parseFloat(value.resultVal2))
		  {
			Nohege.value="合格";
		  }else
		  Nohege.value="不合格";
	   }
	}
	}
	  //判断值3不为空的情况下
	  if(value.resultVal3!=undefined && value.resultVal3 !="")
	{
		//判断值3否是字符类型的
		if(/[A-Za-z]/.test(value.resultVal3))
		{
             if(value.resultVal3=="OK")
			 hegeN.value="合格";
			else
			hegeN.value="不合格";
		}
		else{
        //判断是否存在标准值，标准值不为0的
	   if(value.standVal!=undefined)
	   {
		  if(value.maxVal==undefined)
		  {
			value.maxVal=0;
		  }
		  if(value.minVal==undefined)
		  {
			value.minVal=0;
		  }
		  if(parseFloat(value.standVal)+parseFloat(value.maxVal)>=parseFloat(value.resultVal3) && parseFloat(value.standVal)-parseFloat(value.minVal)<=parseFloat(value.resultVal3))
		  {
			hegeN.value="合格";
		  }else
		  hegeN.value="不合格";
	   }
	   //判断只存在最小值的
         else if(value.minVal!=undefined && value.standVal==undefined &&  value.maxVal==undefined)
	   {
		if(parseFloat(value.minVal)>parseFloat(value.resultVal3) )
		  {
			hegeN.value="不合格";
		  }else
		  hegeN.value="合格";
	   }
	   //判断最大值最小值都不为0的
	   else if(value.minVal!=undefined && value.standVal==undefined &&  value.maxVal!=undefined)
	   {
		if(parseFloat(value.minVal)<=parseFloat(value.resultVal3) &&  parseFloat(value.maxVal)>=parseFloat(value.resultVal3))
		  {
			hegeN.value="合格";
		  }else
		  hegeN.value="不合格";
	   }
	}
	}
	  //判断值4不为空的情况下
	  if(value.resultVal4!=undefined && value.resultVal4 !="")
	{
		//判断值4否是字符类型的
		if(/[A-Za-z]/.test(value.resultVal4))
		{
             if(value.resultVal4=="OK")
			 NohegeNo.value="合格";
			else
			NohegeNo.value="不合格";
		}
		else{
        //判断是否存在标准值，标准值不为0的
	   if(value.standVal!=undefined)
	   {
		  if(value.maxVal==undefined)
		  {
			value.maxVal=0;
		  }
		  if(value.minVal==undefined)
		  {
			value.minVal=0;
		  }
		  if(parseFloat(value.standVal)+parseFloat(value.maxVal)>=parseFloat(value.resultVal4) && parseFloat(value.standVal)-parseFloat(value.minVal)<=parseFloat(value.resultVal4))
		  {
			NohegeNo.value="合格";
		  }else
		  NohegeNo.value="不合格";
	   }
	   //判断只存在最小值的
         else if(value.minVal!=undefined && value.standVal==undefined &&  value.maxVal==undefined)
	   {
		if(parseFloat(value.minVal)>parseFloat(value.resultVal4) )
		  {
			NohegeNo.value="不合格";
		  }else
		  NohegeNo.value="合格";
	   }
	   //判断最大值最小值都不为0的
	   else if(value.minVal!=undefined && value.standVal==undefined &&  value.maxVal!=undefined)
	   {
		if(parseFloat(value.minVal)<=parseFloat(value.resultVal4) &&  parseFloat(value.maxVal)>=parseFloat(value.resultVal4))
		  {
			NohegeNo.value="合格";
		  }else
		  NohegeNo.value="不合格";
	   }
	}
	}
	  //判断值5不为空的情况下
	  if(value.resultVal5!=undefined && value.resultVal5 !="")
	{
		//判断值5否是字符类型的
		if(/[A-Za-z]/.test(value.resultVal5))
		{
             if(value.resultVal5=="OK")
			 Nhege.value="合格";
			else
			Nhege.value="不合格";
		}
		else{
        //判断是否存在标准值，标准值不为0的
	   if(value.standVal!=undefined)
	   {
		  if(value.maxVal==undefined)
		  {
			value.maxVal=0;
		  }
		  if(value.minVal==undefined)
		  {
			value.minVal=0;
		  }
		  if(parseFloat(value.standVal)+parseFloat(value.maxVal)>=parseFloat(value.resultVal5) && parseFloat(value.standVal)-parseFloat(value.minVal)<=parseFloat(value.resultVal5))
		  {
			Nhege.value="合格";
		  }else
		  Nhege.value="不合格";
	   }
	   //判断只存在最小值的
         else if(value.minVal!=undefined && value.standVal==undefined &&  value.maxVal==undefined)
	   {
		if(parseFloat(value.minVal)>parseFloat(value.resultVal5) )
		  {
			Nhege.value="不合格";
		  }else
		  Nhege.value="合格";
	   }
	   //判断最大值最小值都不为0的
	   else if(value.minVal!=undefined && value.standVal==undefined &&  value.maxVal!=undefined)
	   {
		if(parseFloat(value.minVal)<=parseFloat(value.resultVal5) &&  parseFloat(value.maxVal)>=parseFloat(value.resultVal5))
		  {
			Nhege.value="合格";
		  }else
		  Nhege.value="不合格";
	   }
	}
	}
	//1：取样数为1
	if(state.ruleForm.samplingNumMax==1)
	{
		if(hege.value!=undefined)
	    {
	    	if(hege.value=="合格")
		  value.inspResult="合格"
		else 
		 value.inspResult="不合格"
	    }
	}
	//2：取样数为2
	else if(state.ruleForm.samplingNumMax==2)
	{
		if(hege.value=="合格" && Nohege.value=="合格")
		  value.inspResult="合格"
		else 
		 value.inspResult="不合格"
	}
	//3：取样数为3
	else if(state.ruleForm.samplingNumMax==3)
	{
		if(hege.value!=undefined && Nohege.value!=undefined && hegeN.value!=undefined)
	    {
			if(hege.value=="合格" && Nohege.value=="合格" && hegeN.value=="合格")
		     value.inspResult="合格"
		    else 
		     value.inspResult="不合格"
		}
	}
	//4：取样数为4
	else if(state.ruleForm.samplingNumMax==4)
	{
		if(hege.value=="合格" && Nohege.value=="合格" && hegeN.value=="合格" && NohegeNo.value=="合格")
		  value.inspResult="合格"
		else 
		 value.inspResult="不合格"
	}
	//5：取样数为5
	else if(state.ruleForm.samplingNumMax==5)
	{
		if(hege.value=="合格" && Nohege.value=="合格" && hegeN.value=="合格" && NohegeNo.value=="合格" && Nhege.value=="合格")
		  value.inspResult="合格"
		else 
		 value.inspResult="不合格"
	}
	else{
		value.inspResult=undefined;
	}
  }

	
}
	  const mergeRowMethod = ({ row , _rowIndex, column, visibleData }:any) => {
//     const fields = ['qiItemName']; // 需要合并的字段
//    const cellValue = row[column.property];
//    if (cellValue && fields.includes(column.property)) {
// 	visibleData=0;
// 	_rowIndex=0;
//      const prevRow = visibleData[_rowIndex - 1];
//      let nextRow = visibleData[_rowIndex + 1];
// 	 console.log(row);
// 	 console.log(_rowIndex);
// 	 console.log(column);
// 	 console.log(visibleData);
// 	  if(column.property=="qiItemName")
// 	  {
// 		if (prevRow && prevRow[column.property] === cellValue)
// 	    {
// 			return { rowspan: 0, colspan: 0 }; // 隐藏当前单元格
// 	    }
// 		else{
// 			let countRowspan = 1;
// 			while (nextRow && nextRow[column.property] === cellValue) {
// 				nextRow = visibleData[++countRowspan + _rowIndex];
// 			}
// 			if (countRowspan > 1) {
// 				return { rowspan: countRowspan, colspan: 1 }; // 合并单元格
// 			}
// 		}
// 	  }
   //}
	
    //return { rowspan: 1, colspan: 1 }; // 默认不合并
  };
	//将属性或者函数暴露给父组件
	defineExpose({ openDialog });
</script>




