<template>
  <view class="page-product-receipt">
    <view class="header" :style="{ backgroundColor: `rgba(250, 53, 52, ${scrollTop / 100})` }">
      <view class="left">
        <u-icon class="icon" name="arrow-left" @click="uni.navigateBack({})" />
      </view>
      <view class="title">质量检验</view>
      <view class="right"></view>
    </view>
    <div style="display: flex; justify-content: space-between">
      <u-form class="form" ref="form" label-width="180rpx" style="display: flex; width: 48%">
        <!-- 订单 -->
        <!-- <u-form-item label="检验节点"> -->
        <jPicker sureColor="#ff0000" :moren="moren" @bindpicker="selectProductlocCode" showKey="label" valKey="value" :val="selectList.value" :options="model.selectList" />
        <!-- <u-input @blur="onblur()" @focus="onfocus" @click="onclick" :border="true" v-model="selectvalue" placeholder="请选择检验节点" style="overflow: hidden" /> -->
        <!-- </u-form-item> -->
      </u-form>
      <u-form class="form" ref="form" label-width="180rpx" style="display: flex; width: 48%">
        <!-- 订单 -->
        <!-- <u-form-item label="检验节点"> -->
        <jPicker sureColor="#ff0000" :moren="moren4" @bindpicker="selectProductlocCode3" showKey="label" valKey="value" :val="selectList1.value" :options="model.selectList1" />
        <!-- <u-input @blur="onblur()" @focus="onfocus" @click="onclick" :border="true" v-model="selectvalue" placeholder="请选择检验节点" style="overflow: hidden" /> -->
        <!-- </u-form-item> -->
      </u-form>
    </div>

    <u-form class="form" ref="form" label-width="180rpx" style="margin-top: 10px">
      <!-- 单号 -->
      <view class="single" style="display: flex; align-items: center">
        <div class="single-left">
          <!-- <div style="width: 210rpx">物料名称/编码 :</div> -->
          <u-input style="padding: 0" border height="60" placeholder="请输入物料名称/编码" class="inputshow" v-model="materialCode" />
          <!-- <jPicker sureColor="#ff0000" :moren="moren1" @bindpicker="selectDate" showKey="label" valKey="value" :val="Datelist.value" :options="model.locList1?model.locList1 : []" /> -->
        </div>
        <div class="single-right" style="margin: 0; margin-left: 10px">
          <u-button type="primary" @click="querylist">查询</u-button>
        </div>
      </view>
    </u-form>
    <view class="scroll">
      <view v-for="(item, index) in list" :key="item.id">
        <u-form :style="`margin-top: 10rpx; background-color: ${selectedFormIndexes.includes(index) ? 'rgb(192 229 218)' : '#fff'};`" class="form2">
          <view class="list">
            <view @click="toggleFormSelection(index, item)">
              <view class="righttitle">
                <view class="boder-icon-top zhuangtai" data-state="0">{{ item.checkStatus == 0 ? '待检验' : '检验完成' }}</view>
              </view>
              <view class="row-list">
                <view class="list-item" style="white-space: nowrap">批次号: </view>
                <view>
                  {{ item.incomeBatchNo }}
                </view>
              </view>
              <view class="row-list">
                <view class="list-item"> 任务号: </view>
                <view> {{ item.checkNo }} </view>
              </view>
              <view class="row-list">
                <view class="list-item"> 订单号: </view>
                <view> {{ item.workorderCodeSap }} </view>
              </view>
              <view class="row-list">
                <view class="list-item"> 物料号: </view>
                <view> {{ item.materialCode }} </view>
              </view>
              <view class="row-list">
                <view class="list-item" style="white-space: nowrap"> 物料名称: </view>
                <view> {{ item.materialName }} </view>
              </view>
              <view class="row-list">
                <view class="list-item"> 创建时间: </view>
                <view> {{ item.createTime }} </view>
              </view>
              <view class="row-list">
                <view class="row-list-item">
                  <view class="list-item"> 数量: </view>
                  <view> {{ item.quality }} </view>
                </view>
              </view>
              <view class="row-list">
                <view class="row-list-item">
                  <view class="list-item"> 检验位置: </view>
                  <view> {{ item.checkLocName }} </view>
                </view>
              </view>
              <view class="row-list">
                <view class="row-list-item">
                  <view class="list-item"> 供应商单位: </view>
                  <view> {{ item.supplierName }} </view>
                </view>
              </view>
            </view>
            <view a:if="true" class="righttitle">
              <view @click.stop="onPass(item)" class="boder-icon-rigth"> 处理 </view>
            </view>
          </view>
        </u-form>
      </view>
    </view>
    <view>
      <u-popup v-model="show" mode="center" z-index="1000" width="98%">
        <view @click="closepopup"><u-icon style="position: absolute; right: 20rpx" name="close" color="#2979ff" size="28"></u-icon></view>
        <view class="selectlist">
          <div class="item-name">
            <div class="quest">检验项目 :</div>
            <div class="details">
              <div v-if="!isshow3">批次号 : {{ clickitem.incomeBatchNo }}</div>
              <div style="display: flex; white-space: nowrap" v-if="isshow3">批次号 :<jPicker v-if="isshow3" sureColor="#ff0000" :moren="moren2" @bindpicker="selectProductlocCode1" showKey="label" valKey="value" :val="incomeBatchNo.value" :options="model.locList" /></div>
            </div>
            <div class="details">
              <div>订单号 : {{ clickitem.orderNo }}</div>
            </div>
            <div class="details">
              <div>物料号 : {{ clickitem.materialCode }}</div>
            </div>
            <div class="details">
              <div>物料名称 : {{ clickitem.materialName }}</div>
            </div>
            <div class="details">
              <div>数量 : {{ clickitem.quality }}{{ clickitem.unit }}</div>
              <div style="margin-left: 30px">检验状态 : {{ clickitem.checkStatus == 0 ? '待检验' : '检验完成' }}</div>
            </div>
            <div class="details">
              <div>检验位置 : {{ clickitem.checkLocName }}</div>
            </div>
            <div class="details">
              <div>供应商单位 : {{ clickitem.supplierName }}</div>
            </div>
            <!-- <div v-if="selectList.value === 'checkTypeCP'" class="details">
              <div style="display: flex; flex-direction: row"><view style="line-height: 70rpx">样本数量: </view><u-input border v-model="sampleQuality"></u-input></div>
            </div> -->
          </div>
          <!-- <div style="text-align: center">
            <u-button style="width: 100%; height: 35px; margin: auto" @click="onOk" size="mini" type="primary">同步信息</u-button>
          </div> -->
          <view class="item" v-for="(item, index) in detaillistceshi" :key="index">
            <div class="item1">项目名称: {{ item.ruleName }}</div>
            <div style="font-weight: 600; margin-bottom: 3px">检查标准: {{ item.checkStandard }}</div>
            <div v-if="item.propertyCode == '0'">
              <div class="item1 item2 item3">
                <div class="item1">检查结果: {{ item.itemMethod }}</div>
                <div class="select">
                  <u-radio-group v-model="item.status" @change="radioGroupChange(item, item.status, index)">
                    <u-radio @change="radioChange" v-for="(n, indexn) in listselect" :key="indexn" :name="n.type" :disabled="n.disabled">
                      {{ n.name }}
                    </u-radio>
                  </u-radio-group>
                </div>
              </div>
              <div v-if="selectList.value == 'checkTypeSC' && (item.projectNo === '2024010305' || item.projectNo === '2024010304')"><view>实际值：</view><u-input type="textarea" :maxlength="700" border v-model="item.actualValue" @confirm="confirmNumber(item, index)" @blur="confirmNumber(item, index)"></u-input></div>
              <div v-else><view>实际值：</view><u-input type="textarea" :maxlength="700" border v-model="item.actualValue"></u-input></div>
            </div>

            <div class="item1 item2" style="width: 100%" v-if="item.propertyCode == '1'">
              <div class="input-box" id="input-box1" style="display: flex; align-items: center">
                实际值:
                <input class="input" v-model="item.actualValue" @focus="focus(item, item.actualValue, index)" type="text" name="" id="" />
                单位:{{ item.unitCode }}
              </div>
              <view v-if="item.weight == '1' || item.weight == '2'" @click.stop="WeightInfo(item)" class="boder-icon-rigth1"> 自动获取 </view>
            </div>
            <div class="item1" style="color: #000; position: relative">
              <!-- <div class="item1">检查结果: {{ item.itemMethod }}</div> -->
              <div class="Overlay" @click="focustype(item, item.actualValue, index)" style="width: 100%; height: 100%; position: absolute; top: 0; left: 0; z-index: 666"></div>
              <!-- <jPicker style="border: 1px solid #ffffff; color: #000" :moren="moren3" @bindpicker="selectProductlocCode2(index, $event)" showKey="label" valKey="value" :val="item.defectCode" :options="model.locList1" /> -->
              <u-input placeholder="请输入不合格数量" :disabled="item.defectName == null ? true : true" style="background: #fafafa; border: 1px dashed #e2e2e2; margin-top: 10px" :border="true" v-model="item.defectNames" />
            </div>
            <div class="item1" style="color: #000; position: relative" v-show="!(selectList.value == 'checkTypeSC' || selectList.value == 'checkTypeSCXJ')">
              <div class="item1">抽样数量: {{ item.itemMethod }}</div>
              <!-- <input :value="item.sampleQuality" type="number" v-if="selectList.value == 'checkTypeCP'" style="border: 1px solid #ddd" @input="changeInput1($event, index)" @blur="changeInput1($event, index)" /> -->
              <input :value="item.sampleQuality" type="number" style="border: 1px solid #ddd" @blur="changeInput($event, index)" />
              <!-- <uni-easyinput type="number" :value="item.sampleQuality"  :inputBorder="true" @blur="changeInput($event,index)"/> -->
              <!-- <jPicker style="border: 1px solid #ffffff; color: #000" :moren="moren3" @bindpicker="selectProductlocCode2(index, $event)" showKey="label" valKey="value" :val="item.defectCode" :options="model.locList1" /> -->
              <!-- <u-input placeholder="请输入抽样数量" :value="item.sampleQuality"  :border="true" @input="changeInput($event,index)" /> -->
            </div>
            <div class="item1 item2 item3" v-if="item.propertyCode == '1'">
              <div>检查结果:</div>
              <div class="select">
                <u-radio-group v-model="item.status" @change="radioGroupChange(item, item.status, index)">
                  <u-radio @change="radioChange" v-for="(n, indexn) in listselect" :key="indexn" :name="n.type" :disabled="n.disabled">
                    {{ n.name }}
                  </u-radio>
                </u-radio-group>
              </div>
            </div>
            <uni-icons type="scan" size="35" @click="scanCodeOne" style="color: #0b9eff; margin: auto; padding: 22rpx"></uni-icons>
            <!-- <uni-icons type="scan" size="35" @click="scanCodeOne3" style="color: #0b9eff; margin: auto; padding: 22rpx"></uni-icons> -->
            <!-- <uni-icons type="scan" size="35" @click="scanCodeOne2" style="color: #0b9eff; margin: auto; padding: 22rpx"></uni-icons> -->
            <div class="upload-name">
              <!-- <div class="name">检查标准:{{ form.item5 }}</div> -->
              <!-- <u-upload :before-upload="beforeUpload" ref="uUpload" :fileList="fileList" @on-error='errorUpload($event)' :action="action" @on-remove="removePic($event, item)" @on-success="successUpload($event)" :deletable="true"></u-upload> -->
              <scroll-view class="scroll-view_H" scroll-x="true" :scroll-left="scrollLeft(item.files)">
                <view class="photoList">
                  <view class="itemBox photoBox" v-for="(img, index1) in item.files" :key="index1">
                    <view class="closeBtn" @click="deleteImg(index, index1)">
                      <image class="img" src="../../../static/images/iconCloseGray.svg" mode="scaleToFill"></image>
                    </view>
                    <image class="img" :src="img" mode="aspectFit" @click="showScreenImg(index1, item.files)"></image>
                  </view>
                  <view class="itemBox chooseBtn" @click="chooseImg(index, item.files)">
                    <view class="inner">
                      <image class="img" src="../../../static/images/upload-pic-icon.svg" mode="scaleToFill"></image>
                      <text class="desc">添加照片</text>
                    </view>
                  </view>
                </view>
              </scroll-view>
            </div>
            <!-- remark:不合格描述 -->
            <!--<div class="item1">不合格描述:</div>
            <u-input style="background: #fafafa; border: 1px dashed #e2e2e2; padding: 10px 5px" v-model="item.remark" placeholder="" type="textarea" />
            <view class="boder-icon-rigth2">
              <u-button @click="SaveDraft()" type="primary">暂存</u-button>
            </view>-->
          </view>
        </view>
        <!-- sampleQuality：抽样数量
		noOkQuality:不合格数量（只来料、入库有）
		aNoOkquality：A类不良（只过程有）
		bNoOkquality：B类不良（只过程有）
		cNoOkquality：C类不良（只过程有） -->
        <u-form class="Belowsform3" ref="form" label-width="230rpx" label-position="left">
          <div class="" v-show="selectList.value == 'checkTypeSC'">
            <u-form-item label="首检原因:">
              <u-input v-model="formdata.reason" placeholder="" />
            </u-form-item>
          </div>
          <u-form-item label="抽样数量:" v-show="selectList.value == 'checkTypeSC' || selectList.value == 'checkTypeSCXJ'">
            <u-input :value="formdata.sampleQuality" placeholder="" type="number" @blur="changeInputsamp($event)" />
          </u-form-item>
          <u-form-item :label="item.defectSubclass" v-for="(item, index) in detaillistdefects" :key="index">
            <u-input :disabled="item.noOkQuality == null ? true : true" v-model="item.noOkQuality" placeholder="" type="number" />
          </u-form-item>

          <div class="" v-show="selectList.value == 'checkTypeLL'">
            <u-form-item label="最终判定:">
              <!-- <u-input v-model="formdata.checkResult" placeholder="" type="text" /> -->
              <u-radio-group v-model="formdata.checkResult" @change="changeradio1(formdata.checkResult)">
                <u-radio v-for="(n, indexn) in listselectdetermine" :key="indexn" :name="n.type" :disabled="n.disabled">
                  {{ n.name }}
                </u-radio>
              </u-radio-group>
            </u-form-item>
            <u-form-item label="缺陷分类:">
              <jPicker sureColor="#ff0000" :moren="moren19" @bindpicker="selectdisqualification" showKey="label" valKey="value" :val="formdata.remarkCode" :options="SJLLdefectList" />
            </u-form-item>
            <view v-show="formdata.checkResult == 'N'">
              <u-form-item label="是否发起oa:">
                <u-radio-group v-model="formdata.startOA">
                  <u-radio v-for="(n, indexn) in listselectoa" :key="indexn" :name="n.type" :disabled="n.disabled">
                    {{ n.name }}
                  </u-radio>
                </u-radio-group>
              </u-form-item>
              <div v-show="formdata.checkResult == 'N'">
                <u-form-item label="不合格描述:">
                  <u-input style="background: #fafafa; border: 1px dashed #e2e2e2; padding: 10px 5px" :maxlength="700" v-model="formdata.remark" placeholder="" type="textarea" />
                </u-form-item>
              </div>
              <div v-show="formdata.startOA == '1'">
                <u-form-item label="来料类别:">
                  <jPicker sureColor="#ff0000" :moren="moren5" @bindpicker="selectProductlocCode4" showKey="label" valKey="value" :val="selectmaterialType.value" :options="model.locList2" />
                </u-form-item>
                <u-form-item label="物料来源:">
                  <jPicker sureColor="#ff0000" :moren="moren6" @bindpicker="selectProductlocCode5" showKey="label" valKey="value" :val="selectmaterialFromList.value" :options="model.locList3" />
                </u-form-item>
                <u-form-item label="仓储报检人:">
                  <jPicker sureColor="#ff0000" :moren="moren9" @bindpicker="selectstorageCode" showKey="label" valKey="value" :val="selectstorageList.value" :options="locList6" />
                </u-form-item>
                <u-form-item label="转出方:">
                  <jPicker sureColor="#ff0000" :moren="moren10" @bindpicker="selectTransferCode" showKey="label" valKey="value" :val="selectTransferList.value" :options="ZCFList" />
                </u-form-item>
                <u-form-item label="转出OEM厂名:">
                  <u-input v-model="formdata.oem" placeholder="" />
                </u-form-item>
                <u-form-item label="QC主管:">
                  <jPicker sureColor="#ff0000" :moren="moren11" @bindpicker="selectqcCode" showKey="label" valKey="value" :val="selectQCList.value" :options="QCZGList" />
                </u-form-item>
                <u-form-item label="厂区:">
                  <jPicker sureColor="#ff0000" :moren="moren12" @bindpicker="selectworkCode" showKey="label" valKey="value" :val="selectworkList.value" :options="CQList" />
                </u-form-item>
              </div>
            </view>
          </div>
          <!-- 过程/首见 -->
          <div class="" v-show="selectList.value == 'checkTypeSC' || selectList.value == 'checkTypeSCXJ' || selectList.value == 'checkTypeCP' || selectList.value == 'checkTypeCC'">
            <u-form-item label="最终判定:">
              <!-- <u-input v-model="formdata.checkResult" placeholder="" type="text" /> -->
              <u-radio-group v-model="formdata.checkResult" @change="changeradio1(formdata.checkResult)">
                <u-radio v-for="(n, indexn) in listselectdetermine" :key="indexn" :name="n.type" :disabled="n.disabled">
                  {{ n.name }}
                </u-radio>
              </u-radio-group>
            </u-form-item>
            <u-form-item v-show="selectList.value == 'checkTypeSC'" label="缺陷分类:">
              <jPicker sureColor="#ff0000" :moren="moren19" @bindpicker="selectdisqualification" showKey="label" valKey="value" :val="formdata.remarkCode" :options="SJLLdefectList" />
            </u-form-item>
            <view v-show="formdata.checkResult == 'N'">
              <u-form-item label="是否发起oa:">
                <u-radio-group v-model="formdata.startOA">
                  <u-radio v-for="(n, indexn) in listselectoa" :key="indexn" :name="n.type" :disabled="n.disabled">
                    {{ n.name }}
                  </u-radio>
                </u-radio-group>
              </u-form-item>
              <div v-show="formdata.checkResult == 'N'">
                <u-form-item label="不合格描述:">
                  <u-input style="background: #fafafa; border: 1px dashed #e2e2e2; padding: 10px 5px" :maxlength="700" v-model="formdata.remark" placeholder="" type="textarea" />
                </u-form-item>
              </div>
              <div v-show="formdata.startOA == '1'">
                <u-form-item label="生产数量:">
                  <u-input :value="formdata.quality" placeholder="" @blur="changeInputqual($event)" type="number" />
                </u-form-item>
                <u-form-item label="申请部门:">
                  <jPicker sureColor="#ff0000" :moren="moren13" @bindpicker="selectdept" showKey="label" valKey="value" :val="selectdeptType.value" :options="deptlist" />
                </u-form-item>
                <u-form-item label="发现地点:">
                  <u-input v-model="formdata.checkLoc" placeholder="" />
                </u-form-item>
                <u-form-item label="是否供应商问题:">
                  <jPicker sureColor="#ff0000" :moren="moren14" @bindpicker="selectsupplier" showKey="label" valKey="value" :val="selectsupplierType.value" :options="supplierlist" />
                </u-form-item>
                <u-form-item label="异常范围:">
                  <jPicker sureColor="#ff0000" :moren="moren15" @bindpicker="selectabnormal" showKey="label" valKey="value" :val="selectabnormalType.value" :options="abnormallist" />
                </u-form-item>
                <u-form-item label="所属车间:">
                  <jPicker sureColor="#ff0000" :moren="moren18" @bindpicker="selectSSCJCode" showKey="label" valKey="value" :val="selectSSCJType.value" :options="SSCJlist" />
                </u-form-item>
                <u-form-item label="是否需要主管审核:">
                  <jPicker sureColor="#ff0000" :moren="moren16" @bindpicker="selectischeck" showKey="label" valKey="value" :val="selectischeckType.value" :options="ischecklist" />
                </u-form-item>
                <u-form-item label="QC主管:" v-show="selectischeckType.value == '0'">
                  <jPicker sureColor="#ff0000" :moren="moren11" @bindpicker="selectpgzgCode" showKey="label" valKey="value" :val="selectpgzgList.value" :options="pgzgList" />
                </u-form-item>
                <u-form-item label="质量主管:">
                  <jPicker sureColor="#ff0000" :moren="moren17" @bindpicker="selectZLCode" showKey="label" valKey="value" :val="selectZLType.value" :options="pgzgList" />
                </u-form-item>
              </div>
            </view>
          </div>
          <u-form-item label="备注描述:">
            <u-input v-model="formdata.attr3" placeholder="" type="textarea" :maxlength="700" :border="border" :height="height" :auto-height="autoHeight" />
          </u-form-item>
          <u-form-item label-width="55" v-show="selectList.value == 'checkTypeSC'" label="签名:">
            <u-row class="button-barsing">
              <!-- 确定 -->
              <u-col :span="4">
                <u-button style="font-size: 24rpx" @click="singname('1')" type="primary"
                  >产线组长签名<span>({{ formdata.cxzz && formdata.cxzz != '' ? 'Y' : 'N' }})</span></u-button
                >
              </u-col>
              <!-- 返回 -->
              <u-col :span="4">
                <u-button style="font-size: 24rpx" @click="singname('2')" type="primary"
                  >机管员签名 <span>({{ formdata.jgy && formdata.jgy != '' ? 'Y' : 'N' }})</span></u-button
                >
              </u-col>
              <u-col :span="4">
                <u-button style="font-size: 24rpx" @click="singname('3')" type="primary"
                  >品管员签名 <span>({{ formdata.pgy && formdata.pgy != '' ? 'Y' : 'N' }})</span></u-button
                >
              </u-col>
            </u-row>
          </u-form-item>
          <!-- <u-form-item v-if="isshow1" label="不合格数量:">
            <u-input v-model="formdata.noOkQuality" placeholder="" type="number" />
          </u-form-item>
          <u-form-item v-if="isshow3" label="A类不良:">
            <u-input v-model="formdata.aNoOkquality" placeholder="" type="number" />
          </u-form-item>
          <u-form-item v-if="isshow3" label="B类不良:">
            <u-input v-model="formdata.bNoOkquality" placeholder="" type="number" />
          </u-form-item>
          <u-form-item v-if="isshow3" label="C类不良:">
            <u-input v-model="formdata.cNoOkquality" placeholder="" type="number" />
          </u-form-item> -->
        </u-form>
        <view class="poupbutton" style="margin-top: 10px">
          <div>
            <u-button style="width: 100px; height: 35px" @click="onOk" size="mini" type="primary">提交</u-button>
          </div>
          <div>
            <u-button style="width: 100px; height: 35px" size="mini" type="error" @click="nopoup">取消</u-button>
          </div>
        </view>
      </u-popup>
      <view v-if="show" style="z-index: 997" class="mask"></view>
    </view>
    <!-- <u-select v-model="showselect" mode="mutil-column-auto" :list="selectlist"></u-select> -->
    <u-modal v-model="isshow" class="modal" :show-cancel-button="true" :show-title="false" @cancel="cancel" @confirm="confirm">
      <div class="tagsbox">
        <u-tag v-for="(item, index) in tagslist" class="tags" :key="index" :text="item.label" type="info" closeable @close="tagClick(index)" />
      </div>
      <div class="upload-name">
        <div style="display: flex">
          <div><u-input :border="true" disabled :value="tagslist.length + 1" :focus="isfocus" style="background-color: #eee; width: 80rpx; margin-right: 10rpx" @blur="changeInputtags($event)" /></div>
          <div><u-input :border="true" :value="tagsvalue" :focus="isfocus" style="overflow: hidden" @blur="changeInputtags($event)" /></div>
        </div>
      </div>
      <div>
        <u-button style="width: 200rpx; height: 70rpx; margin-left: 38rpx" @click="ontagsadd" size="mini" type="primary">测量值增加</u-button>
      </div>
      <div class="upload-name" v-show="isgetAutoJudge">
        <jPicker style="border: 1px solid #dcdfe6; padding: 8px 18px" sureColor="#ff0000" :moren="moren7" @bindpicker="selectProductlocCode6" showKey="label" valKey="value" :val="selectList4.value" :options="model.locList4" />
      </div>
      <div class="upload-name" v-show="isgetAutoJudge">
        <jPicker style="border: 1px solid #dcdfe6; padding: 8px 18px" sureColor="#ff0000" :moren="moren8" @bindpicker="selectProductlocCode7" showKey="label" valKey="value" :val="selectList5.value" :options="model.locList5" />
      </div>
    </u-modal>
    <!-- <badtype sureColor="#ff0000" ref="babtype" :showtype="isshowtype" @bindtypelist="selectbabTypelist" showKey="label" valKey="value" :options="model.locList1" /> -->
    <badtable sureColor="#ff0000" ref="badtable" @bindtypelist="selectbabTypelist" :showtype="isshowtype" :options="model.locList1" :defectList="disqualificationlist" />
    <u-toast ref="uToast" />
    <u-popup v-model="showsing" mode="center" width="98%">
      <f-signature @getImg="getImg" @cancel="cancelsing"></f-signature>
    </u-popup>
    <view v-show="selectList.value == 'checkTypeLL'" class="bottom-bar">
      <u-row class="button-bar">
        <!-- 确定 -->
        <u-col :span="6">
          <u-button @click="hebingsubmit" type="primary">合并</u-button>
        </u-col>
        <!-- 返回 -->
        <u-col :span="6">
          <u-button type="error" @click="uni.navigateBack()">返回</u-button>
        </u-col>
      </u-row>
    </view>
    <u-mask :show="showmask" :mask-click-able="false" z-index="100090">
      <view class="warp">
        <view class="rect" @tap.stop>系统自动保存中请勿操作</view>
      </view>
    </u-mask>
    <u-picker mode="selector" @confirm="confirmindex" @cancel="cancelindex" v-model="showindex" :default-selector="[0]" :range="indexdata"></u-picker>
  </view>
</template>
<script lang="ts" module="vconsole">
import { Component } from 'vue-property-decorator';
import { BasePage } from '@/components/base/page';
import jPicker from '@/components/J-Picker/jPicker.vue';
import badtype from '@/components/bad-type/bad-type.vue';
import badtable from '@/components/bad-table/bad-table.vue';
import model from './model';
import { session } from '@/store/modules/session';
import fSignature from '@/components/f-signature/f-signature.vue';
// 以下路径需根据项目实际情况填写
//import UniTable from '@/components/uni-table/components/uni-table/uni-table.vue';
const mpaasScanModule: any = uni.requireNativePlugin('Mpaas-Scan-Module');

@Component({
  components: {
    jPicker,
    badtype,
    badtable,
    fSignature,
    //UniTable,
  },
})
export default class PurchaseWHSRM extends BasePage {
  model = model;
  border = true;
  vbase64data = '';
  height = 100;
  autoHeight = true;
  showsing = false;
  showmask = false;
  showindex = false;
  singmark = '';
  moren = '请选择检验节点';
  moren2 = '请选择批次号';
  moren3 = '请选择不良分类';
  moren4 = '请选择检验位置';
  moren5 = '请选择来料类别';
  moren6 = '请选择物料来源';
  moren7 = '请选择接受质量限';
  moren8 = '请选择检测水平';
  moren9 = '请选择仓储报检人';
  moren10 = '请选择转出方';
  moren11 = '请选择QC主管';
  moren12 = '请选择厂区';
  moren13 = '请选择申请部门';
  moren14 = '请选择是否供应商问题';
  moren15 = '请选择异常范围';
  moren16 = '请选择是否需要主管审核';
  moren17 = '请选择质量主管';
  moren18 = '请选择所属车间';
  moren19 = '请选择缺陷分类';
  list: any = [];
  locList6: any = [];
  show = false;
  showselect = false;
  isshow = false;
  form3: any = {
    barCodewl: '',
  };
  ischecklist: any = [];
  indexdata: any = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
  listselect: any = [
    {
      type: 'Y',
      name: '合格',
      radiovalue: null,
    },
    {
      type: 'N',
      name: '不合格',
      radiovalue: null,
    },
    {
      type: 'O',
      name: '不检验',
      radiovalue: null,
    },
  ];
  listselectoa: any = [
    {
      type: 1,
      name: '是',
      radiovalue: null,
    },
    {
      type: 0,
      name: '否',
      radiovalue: null,
    },
  ];
  listselectdetermine: any = [
    {
      type: 'Y',
      name: '合格',
      radiovalue: null,
    },
    {
      type: 'N',
      name: '不合格',
      radiovalue: null,
    },
  ];
  selectList: any = {};
  selectList1: any = {};
  selectList2: any = {};
  selectList4: any = {};
  selectList5: any = {};
  defectCodeList: any = {};
  selectischeckType: any = {};
  selectpgzgList: any = {};
  selectZLType: any = {};
  selectSSCJType: any = {};
  sqrlist: any = {};
  selectdisqualificationType: any = {};
  // remove: any = {};
  // async onReady() {
  //   await this.model.queryLocation();
  //   this.remove = this.model.WlList[0];
  // }
  // selectItem(e: any) {
  //   this.remove = e.pickerName;
  // }
  orderNo: any = '';
  // 自动取数
  WeightInfolist: any = [];
  detailList: any = [];
  equipmentindex: any = [];
  tagsvalue: any = '';
  serialnumber: any = '1';
  tagslist: any = [];
  detailsinfo: any = [];
  nodelist: any = '';
  nodelist1: any = '';
  detaillistceshi: any = [];
  detaillistdefects: any = [];
  pgzgList: any = [];
  ZLlist: any = [];
  ZCFList: any = [];
  QCZGList: any = [];
  CQList: any = [];
  SSCJlist: any = [];
  disqualificationlist: any = [];
  SJLLdefectList: any = [];
  clickitem: any = '';
  formdata: any = {
    sampleQuality: null,
    noOkQuality: null,
    aNoOkquality: null,
    bNoOkquality: null,
    cNoOkquality: null,
    checkResult: null,
    materialType: null,
    materialFrom: null,
    remark: null,
    startOA: null,
    reason: null,
    cxzz: null,
    jgy: null,
    pgy: null,
    attr3: null,
  };
  isvalue = false;
  isvalue2 = false;
  isvalue3 = false;
  isquality = false;
  isremark = false;
  isgetAutoJudge = false;
  isfocus = false;
  isshow1 = false;
  isshow2 = false;
  isshow3 = false;
  incomeBatchNo: any = {};
  files: any = [];
  DefectListPDAlist: any = [];
  defectCodelist: any = [];
  imgurl: any = 'http://lj08.cn/21001871815240307020600048115350';
  // 不良类型
  isshowtype = false;
  // 来料类别
  getmaterialType: any = [];
  selectmaterialType: any = {};
  // 物料来源
  getmaterialFromList: any = [];
  selectmaterialFromList: any = {};
  selectdeptType: any = {};
  selectsupplierType: any = {};
  selectabnormalType: any = {};
  selectstorageList: any = [];
  selectTransferList: any = [];
  selectQCList: any = [];
  selectworkList: any = [];
  deptlist: any = [];
  supplierlist: any = [];
  abnormallist: any = [];
  selectedFormIndexes: any = [];
  selectedForms: any = [];
  keyboardHideInterval: any = [];
  numLength: any = 0;
  materialCode: any = '';
  //sampleQuality = null; //成品检验样本数量
  // 引入原生插件
  // 调用插件的 mpaasScan 方法
  //点击合并处理选择
  toggleFormSelection(index, item) {
    if (this.selectList.value == 'checkTypeLL') {
      const isAlreadySelected = this.selectedFormIndexes.includes(index);
      if (isAlreadySelected) {
        this.selectedFormIndexes = this.selectedFormIndexes.filter((i) => i !== index);
        this.selectedForms = this.selectedForms.filter((f) => f !== item);
      } else {
        this.selectedFormIndexes.push(index);
        this.selectedForms.push(item);
      }
    }
  }

  async hebingsubmit() {
    let ids = [];
    this.selectedForms.forEach((item) => {
      ids.push(item.recordId);
    });
    const joinedIds = ids.join(','); // 将连接后的字符串赋值给 joinedId// 打印连接后的字符串
    await this.model.mergeCheckTask(joinedIds);
    if (this.model.togetherTaskcode == '200') {
      (this.$refs.uToast as any).show({
        title: model.togetherTaskmsg,
        type: 'default',
      });
      let query = {
        factoryCode: session.PoolName,
        checkManCode: session.userName,
        checkStatus: 0,
        checkType: this.detailsinfo.checkType,
        checkLoc: this.selectList1.value,
      };
      await this.model.getCheckTaskListall(query);
      this.list = this.model.CheckTaskListall;
      this.selectedFormIndexes = [];
      this.selectedForms = [];
    }
  }

  //收货按钮
  tagClick(index) {
    if (index + 1 != this.tagslist.length) {
      (this.$refs.uToast as any).show({
        title: '请按顺序删除',
        type: 'default',
      });
      return;
    }
    this.tagslist.splice(index, 1);
  }
  hasDuplicateValueIndex(arr) {
    const valueIndexes = arr.map((item) => item.valueindex);
    return valueIndexes.some((item, index) => valueIndexes.indexOf(item) !== index);
  }
  // 标准输入
  ontagsadd() {
    if (this.tagsvalue == '' || this.tagsvalue == undefined) {
      // this.customToast('请扫码设备编码');
      (this.$refs.uToast as any).show({
        title: '请输入内容',
        type: 'default',
      });
      return;
    }
    // const regex = /^[a-zA-Z0-9.]+$/; // 仅允许英文、数字和小数点
    // const inputValue = this.tagsvalue; // 获取输入值
    // if (!regex.test(inputValue)) {
    //   // 替换所有非法字符
    //   this.tagsvalue = inputValue.replace(/[^a-zA-Z0-9.]/g, '');
    // } else {
    //   this.tagsvalue = inputValue; // 输入合法，直接赋值
    // }
    console.log(this.tagslist, 'sadasdww');
    let a: any = {};
    a.value = this.tagsvalue;
    a.valueindex = this.tagslist.length + 1;
    a.label = a.valueindex + ':' + a.value;
    this.tagslist.push(a);
    this.tagsvalue = 0;
    // this.isfocus = false;
    // this.$nextTick(() => {
    //   this.isfocus = true;
    // });
    // this.isfocus = false;
    // this.$nextTick(() => {
    //   this.isfocus = true;
    // });
  }
  // 页面加载
  async onLoad(options) {
    uni.$on('scanCodeData', (data) => {
      let str = `${data.code}`;
      let recData = JSON.parse(str);
      console.log(recData, 'assdasdasdasdad cc');
      this.scanCodeOne2;
      // 现在你可以使用 recData 进行进一步的处理
    });
    this.getselectlist();
    if (options.listitem) {
      let str = decodeURIComponent(options.listitem);
      if (str) {
        this.detailsinfo = JSON.parse(str);
        this.selectList.value = this.detailsinfo.checkType;

        this.getDefectListPDA();
        let query = {
          factoryCode: session.PoolName,
          checkManCode: session.userName,
          checkStatus: 0,
          checkType: this.detailsinfo.checkType,
          checkLoc: this.selectList1.value,
        };
        await this.model.getCheckTaskListall(query);
        this.list = this.model.CheckTaskListall;
      }
    }
  }
  // 获取下拉
  async getselectlist() {
    await this.model.getCheckType();
    await this.model.getcheckLocList();
    await this.model.getsampleaqlList();
    await this.model.getsamplelevelList();
    this.nodelist = this.model.orderNoItemList;
    this.nodelist1 = this.model.orderNoItemList1;
  }
  async getDefectListPDA() {
    let query1 = {
      factoryCode: session.PoolName,
      checkType: this.selectList.value,
    };
    await this.model.getDefectListPDA(query1);
    this.defectCodelist = [];
    this.DefectListPDAlist = this.model.locList1;
    this.DefectListPDAlist.forEach((item) => {
      let a: any = {};
      a.label = item.label;
      a.defectCode = item.value;
      a.numberall = 0;
      this.defectCodelist.push(a);
    });
  }
  async getmaterialTypePDA() {
    await this.model.getmaterialTypePDA();
    this.getmaterialType = this.model.locList2;
  }
  // 自动取数
  async WeightInfo(item) {
    let query = {
      factoryCode: session.PoolName,
      recordId: item.recordId,
    };
    await this.model.getWeightInfo(query);
    // let actualValue = '["111","111"]'
    // item.actualValue = actualValue
    this.WeightInfolist = this.model.WeightInfoList;
    if (this.WeightInfolist.msg) {
      item.actualValue = this.WeightInfolist.msg;
    }
  }
  async getmaterialFromListPDA() {
    await this.model.getmaterialFromListPDA();
    this.getmaterialFromList = this.model.locList3;
  }

  async onPass(item) {
    this.clickitem = item;
    let query1 = {
      factoryCode: session.PoolName,
      workorderCode: this.clickitem.orderNo,
    };
    this.formdata.cxzz = null;
    this.formdata.jgy = null;
    this.formdata.pgy = null;
    //debugger;
    if (this.selectList.value == 'checkTypeSC' || this.selectList.value == 'checkTypeSCXJ' || this.selectList.value == 'checkTypeCP' || this.selectList.value == 'checkTypeCC') {
      await model.getdeptFromListPDA();
      this.deptlist = model.deptlist;
      await model.getabnormallistFromListPDA();
      this.abnormallist = model.abnormallist;
      await model.getischecklistFromListPDA();
      this.ischecklist = model.ischecklist;
      await this.model.getqcFromListPDA(); //qc主管
      this.pgzgList = model.locList8;
      await this.model.getsupplierlistFromListPDA();
      this.supplierlist = model.isclistsupplierlist;
      await this.model.getSSCJlistFromListPDA();
      this.SSCJlist = model.SSCJlist;
    } else {
      this.getmaterialFromListPDA();
      this.getmaterialTypePDA();
      await this.model.getstorgeFromListPDA();
      this.locList6 = model.locList6;
      await this.model.gettrensferFromListPDA();
      let requestCFlist = model.locList7;
      this.ZCFList = requestCFlist;
      this.CQList = requestCFlist;
      await this.model.getqcFromListPDA();
      this.QCZGList = model.locList8;
      await this.model.getworkFromListPDA();
      this.CQList = model.locList9;
    }
    this.getDefectListPDA();
    let disqualificationparams = {
      dictType: 'unqualified_remark',
      //dictLable:不良描述中文
      remark: this.selectList.value,
    };
    //首见，来料底部缺陷分类
    if (this.selectList.value == 'checkTypeSC' || this.selectList.value == 'checkTypeLL') {
      await this.model.getSJLLdefect(this.selectList.value);
      this.SJLLdefectList = this.model.SJLLdefectList;
    }

    await this.model.getdisqualification(disqualificationparams);
    this.disqualificationlist = this.model.disqualificationlist;

    //await this.model.getOaUserIdlist();
    //this.sqrlist = model.sqrlist;

    if (this.selectList.value == 'checkTypeLL') {
      this.formdata.startOA = 1;
    } else {
      this.formdata.startOA = 0;
    }
    await this.model.getBatchList(query1);
    let labelname = this.selectList.value;
    if (labelname == 'checkTypeSCXJ') {
      this.isshow3 = true;
      if (item.incomeBatchNo) {
        this.incomeBatchNo.value = item.incomeBatchNo;
      }
    } else {
      this.isshow3 = false;
    }

    let belongTo = item.recordId;
    let query = {
      factoryCode: session.PoolName,
      belongTo: belongTo,
      checkType: this.selectList.value,
    };
    //默认查暂存草稿
    await this.model.queryCheckTaskDetailListCG(query);
    let dataobj = this.model.returnobj;
    //console.log(dataobj, '草稿数据');
    //如果没有草稿，则查询正式数据
    if (Object.keys(dataobj).length === 0) {
      await this.model.getCheckTaskList(query);

      if (this.clickitem.sampleQuality != null) {
        this.formdata.sampleQuality = this.clickitem.sampleQuality;
      } else {
        this.formdata.sampleQuality = null;
      }
      this.detaillistceshi = this.model.CheckTaskList.qcCheckTaskDetails;
      this.detaillistdefects = this.model.CheckTaskList.defects;
      this.detaillistdefects.forEach((item) => {
        if (item.noOkQuality == null) {
          item.noOkQuality = 0;
        }
      });
      this.detaillistdefects.forEach((item) => {
        if (item.sampleQuality == null) {
          item.sampleQuality = '0';
        }
      });
      this.detaillistceshi.forEach((item) => {
        item.factoryCode = session.PoolName;
        item.checkType = this.selectList.value;
        item.orderCode = this.clickitem.orderNo;
        item.files = [];
        item.babtype = this.defectCodelist;
        item.defectlabel = null;
      });
      this.formdata.cxzz = this.model.CheckTaskList.cxzz;
      this.formdata.jgy = this.model.CheckTaskList.jgy;
      this.formdata.pgy = this.model.CheckTaskList.pgy;
      this.determine();
    } else {
      //存草稿回显
      /***一些页面，回显了但是提交表单字段不对应，导致提交没有以下字段 */
      this.formdata = dataobj;
      this.formdata.storageFrom = dataobj.czbjr; //仓储报检人
      this.formdata.transferFrom = dataobj.zcf; //转出方
      this.formdata.qcFrom = dataobj.qczg; //来料QC主管
      this.formdata.workFrom = dataobj.oaFactory; //厂区
      this.formdata.startOA = dataobj.startOA;
      this.formdata.sampleQuality = dataobj.sampleQuality;
      this.formdata.oem = dataobj.zcoemcm; //转出OEM厂名
      this.formdata.sfxvzq = dataobj.sfxyzg; //是否需要主管审核
      /***用于页面回显，主要是一些下拉选择和表单字段不对应的 */
      this.selectdeptType.value = dataobj.sqbm; //申请部门
      this.selectmaterialType.value = dataobj.materialType; //来料类别
      this.selectmaterialFromList.value = dataobj.materialFrom; //物料来源
      this.selectstorageList.value = dataobj.czbjr; //仓储报检人
      this.selectTransferList.value = dataobj.zcf; //转出方
      this.selectQCList.value = dataobj.qczg; //QC主管
      this.selectworkList.value = dataobj.oaFactory; //厂区
      this.selectsupplierType.value = dataobj.sfgyswt; //是否供应商问题
      this.selectabnormalType.value = dataobj.oaFactoryF; //异常范围
      this.selectSSCJType.value = dataobj.sccj; //所属车间
      this.selectischeckType.value = dataobj.sfxyzg; //是否需要主管审核
      this.selectpgzgList.value = dataobj.pgzg; //QC主管
      this.selectZLType.value = dataobj.pgzr; //质量主管
      this.detaillistceshi = dataobj.qcCheckTaskDetails;
      this.detaillistdefects = dataobj.defects;
      this.formdata.cxzz = dataobj.cxzz;
      this.formdata.jgy = dataobj.jgy;
      this.formdata.pgy = dataobj.pgy;

      ///this.selectdisqualificationType.value = dataobj.remarkCode; //是否不合格
      this.detaillistdefects.forEach((item) => {
        if (item.noOkQuality == null) {
          item.noOkQuality = 0;
        }
      });
      this.detaillistdefects.forEach((item) => {
        if (item.sampleQuality == null) {
          item.sampleQuality = '0';
        }
      });
      this.detaillistceshi.forEach((item) => {
        item.factoryCode = session.PoolName;
        item.checkType = this.selectList.value;
        item.orderCode = this.clickitem.orderNo;
        if (!item.files) {
          item.files = []; ///.........
        } else {
          item.files = item.files.map((item) => {
            return item.fileAddress;
          });
          // item.files.map((item) => {
          //   item.fileListStr.push(item.fileAddress);
          // });
          item.fileListStr = item.files.join(',');
        }
        let classTypeCodeslist = [];
        if (item.classTypeCodes != null && item.classTypeCodes != '') {
          classTypeCodeslist = item.classTypeCodes.split(',');
          // classTypeCodeslist = classTypeCodeslist.filter(function(code) {
          //  return code.trim() !== ''; // 使用 trim() 来处理字符串前后的空格
          // });
          //console.log('classTypeCodeslist...',classTypeCodeslist);
        }
        let defectObj = {};
        let classTypeCodesobj = {};
        if (item.defectNames != null) {
          item.defectNames.split(',').forEach((item, index) => {
            let [key, value] = item.split(':');
            defectObj[key.trim()] = parseFloat(value.trim());
            classTypeCodesobj[key.trim()] = classTypeCodeslist[index];
          });
          //  console.log(defectObj, '缺陷对象');
          //console.log('缺陷列表？？？？',this.defectCodelist);
          let olddefectCodelist = [];
          olddefectCodelist = JSON.parse(JSON.stringify(this.defectCodelist));
          //  console.log(olddefectCodelist, 'old缺陷列表');
          olddefectCodelist.forEach((item) => {
            if (Object.prototype.hasOwnProperty.call(defectObj, item.label)) {
              // console.log('什么数据。。。', defectObj[item.label]);
              item.numberall = defectObj[item.label];
            }
            if (Object.prototype.hasOwnProperty.call(classTypeCodesobj, item.label)) {
              //console.log('什么数据。。。', defectObj[item.label]);
              item.defect = classTypeCodesobj[item.label];
            }
          });
          item.babtype = olddefectCodelist;
        } else {
          item.babtype = this.defectCodelist;
        }

        //this.defectCodelist;
        item.defectlabel = null;
      });

      //this.determine();
    }

    // if (this.detaillistceshi.some((item) => item.status === 'Y')) {
    //   this.formdata.checkResult = '合格'
    // }
    // if (this.detaillistceshi.some((item) => item.status === 'N')) {
    //   this.formdata.checkResult = '不合格'
    // }
    this.show = true;
    // this.clearMessage();
  }
  // 最终判定是否合格
  determine() {
    if (this.detaillistceshi.some((item) => item.status === 'Y')) {
      this.formdata.checkResult = 'Y';
    }
    if (this.detaillistceshi.some((item) => item.status === 'N')) {
      this.formdata.checkResult = 'N';
    }
  }
  radioGroupChange(item, value, index) {
    console.log(item, value, index, '切换单选框');
    this.determine();
  }
  radioChange(e) {
    console.log(e);
  }
  // 判定选择
  changeradio1(checkResult) {
    console.log(checkResult);
  }
  async querylist() {
    let query = {
      factoryCode: session.PoolName,
      checkManCode: session.userName,
      checkStatus: 0,
      checkType: this.selectList.value,
      checkLoc: this.selectList1.value,
      materialCode: this.materialCode,
    };
    this.getDefectListPDA();
    await this.model.getCheckTaskListall(query);
    this.list = this.model.CheckTaskListall;
  }
  async selectProductlocCode(e: any) {
    this.selectList = e.pickerName;
    let query = {
      factoryCode: session.PoolName,
      checkManCode: session.userName,
      checkStatus: 0,
      checkType: this.selectList.value,
      checkLoc: this.selectList1.value,
    };
    this.getDefectListPDA();
    await this.model.getCheckTaskListall(query);
    this.list = this.model.CheckTaskListall;
    // let params = {
    //   productionState: this.productCodelocList.value.toString(),
    // };
    // await this.model.getpalletLocation(params); //参数：成型区2，烘房3
  }
  async selectbabTypelist(babtypelist, index) {
    //console.log('9990000',babtypelist, index);
    this.detaillistceshi[index].babtype = babtypelist;
    let defectCode = [];
    let defectQuality = [];
    let defectlabel = [];
    let classTypeCodes = [];
    // a.label = item.label;
    //   a.defectCode = item.value;
    //   a.numberall = 0;
    babtypelist.forEach((item) => {
      if (item.numberall != 0) {
        let a = item.label + ':' + item.numberall;
        defectCode.push(item.defectCode);
        defectQuality.push(item.numberall);
        defectlabel.push(a);
      }
      //console.log(item.defect, '缺陷0000');
      if (item.defect != undefined) {
        classTypeCodes.push(item.defect);
      }
    });
    this.detaillistceshi[index].defectCodes = defectCode.join(',');
    this.detaillistceshi[index].defectQualitys = defectQuality.join(',');
    this.detaillistceshi[index].defectNames = defectlabel.join(',');
    this.detaillistceshi[index].classTypeCodes = classTypeCodes.join(',');
    //console.log( '缺陷提交数据',this.detaillistceshi[index].classTypeCodes)
    const mergedObject = {};
    for (let index = 0; index < this.detaillistceshi.length; index++) {
      this.detaillistceshi[index].babtype.forEach((obj) => {
        const { numberall, defectCode } = obj;
        if (!mergedObject[defectCode]) {
          mergedObject[defectCode] = parseInt(numberall);
        } else {
          mergedObject[defectCode] += parseInt(numberall);
        }
      });
    }
    //console.log(mergedObject, '合并后的对象');
    const array3 = Object.keys(mergedObject).map((defectCode) => ({
      defectCode,
      value: mergedObject[defectCode],
    }));
    //console.log(array3, '合并后的数组');

    for (let index = 0; index < array3.length; index++) {
      this.detaillistdefects.forEach((item) => {
        if (item.defectCode == array3[index].defectCode) {
          if (item.noOkQuality == null) {
            item.noOkQuality = 0;
          }
          item.noOkQuality = array3[index].value;
        }
      });
    }
  }
  async selectProductlocCode1(e: any) {
    this.incomeBatchNo = e.pickerName;
  }
  async selectProductlocCode3(e: any) {
    this.selectList1 = e.pickerName;
    let query = {
      factoryCode: session.PoolName,
      checkManCode: session.userName,
      checkStatus: 0,
      checkType: this.selectList.value,
      checkLoc: this.selectList1.value,
    };
    this.getDefectListPDA();
    await this.model.getCheckTaskListall(query);
    this.list = this.model.CheckTaskListall;
  }
  async selectProductlocCode4(e: any) {
    this.selectmaterialType = e.pickerName;
    this.formdata.materialType = this.selectmaterialType.value;
  }
  async selectProductlocCode5(e: any) {
    this.selectmaterialFromList = e.pickerName;
    this.formdata.materialFrom = this.selectmaterialFromList.value;
  }

  async selectstorageCode(e: any) {
    this.selectstorageList = e.pickerName;
    this.formdata.storageFrom = this.selectstorageList.value;
  }
  async selectTransferCode(e: any) {
    this.selectTransferList = e.pickerName;
    this.formdata.transferFrom = this.selectTransferList.value;
  }
  async selectworkCode(e: any) {
    this.selectworkList = e.pickerName;
    this.formdata.workFrom = this.selectworkList.value;
  }
  async selectqcCode(e: any) {
    this.selectQCList = e.pickerName;
    this.formdata.qcFrom = this.selectQCList.value;
  }

  async selectProductlocCode6(e: any) {
    this.selectList4 = e.pickerName;
    this.detaillistceshi[this.equipmentindex[0]].sampleAql = this.selectList4.value;
  }
  async selectProductlocCode7(e: any) {
    this.selectList5 = e.pickerName;
    this.detaillistceshi[this.equipmentindex[0]].checkLevel = this.selectList5.value;
  }
  async selectdept(e: any) {
    this.selectdeptType = e.pickerName;
    this.formdata.sqbm = this.selectdeptType.value;
  }
  async selectsupplier(e: any) {
    this.selectsupplierType = e.pickerName;
    this.formdata.sfgyswt = this.selectsupplierType.value;
  }
  async selectabnormal(e: any) {
    this.selectabnormalType = e.pickerName;
    this.formdata.oaFactoryF = this.selectabnormalType.value;
  }
  async selectSSCJCode(e: any) {
    this.selectSSCJType = e.pickerName;
    this.formdata.sccj = this.selectSSCJType.value;
  }
  async selectischeck(e: any) {
    this.selectischeckType = e.pickerName;
    this.formdata.sfxvzq = this.selectischeckType.value;
    if (this.formdata.sfxvzq == '1') {
      this.selectpgzgList = {};
      //this.selectZLType = {};
      this.formdata.pgzg = null;
      // this.formdata.pgzr = null;
    }
  }
  async selectpgzgCode(e: any) {
    this.selectpgzgList = e.pickerName;
    this.formdata.pgzg = this.selectpgzgList.value;
  }
  async selectZLCode(e: any) {
    this.selectZLType = e.pickerName;
    this.formdata.pgzr = this.selectZLType.value;
  }
  async selectdisqualification(e: any) {
    this.selectdisqualificationType = e.pickerName;
    this.formdata.remarkCode = this.selectdisqualificationType.value;
  }

  focustype(item, value, index) {
    //console.log('什么呀这是。。。。',item,value,index);
    this.isfocus = false;
    this.$nextTick(() => {
      this.isfocus = true;
    });
    //openbad(item, index);
    (this.$refs.badtable as any).open(item, index);
  }
  focus(item, value, index) {
    this.serialnumber = 1;
    if (this.detaillistceshi[index].upperDiff == null && this.detaillistceshi[index].downDiff == null) {
      this.isgetAutoJudge = false;
    } else {
      if (this.selectList.value == 'checkTypeLL' || this.selectList.value == 'checkTypeCP') {
        this.isgetAutoJudge = true;
      }
    }
    if (this.detaillistceshi[index].actualValue) {
      this.tagslist = [];
      JSON.parse(this.detaillistceshi[index].actualValue).forEach((item) => {
        let a: any = {};
        a.label = item;
        this.tagslist.push(a);
      });
      this.selectList4.value = this.detaillistceshi[index].sampleAql;
      this.selectList5.value = this.detaillistceshi[index].checkLevel;
    } else {
      this.tagslist = [];
      this.detaillistceshi[index].sampleAql = null;
      this.detaillistceshi[index].checkLevel = null;
      // this.selectList4.value = this.detaillistceshi[index].sampleAql;
      // this.selectList5.value = this.detaillistceshi[index].checkLevel;
    }
    this.isfocus = false;
    this.$nextTick(() => {
      this.isfocus = true;
    });
    this.equipmentindex = [];
    this.tagsvalue = null;
    this.equipmentindex.push(index);
    this.isshow = true;
    this.tagsvalue = 0;
  }
  nopoup() {
    this.SaveDraft();
    this.show = false;
    this.form3.barCodewl = '';
    //this.sampleQuality = null;
    this.formdata.attr3 = '';
  }
  async getlist() {
    let query = {
      factoryCode: session.PoolName,
      checkManCode: session.userName,
      checkStatus: 0,
      checkType: this.selectList.value,
      checkLoc: this.selectList1.value,
    };
    await this.model.getCheckTaskListall(query);
    this.list = this.model.CheckTaskListall;
  }
  //点击收货按钮，录入批次（或系统自动生成）、数量、托盘码进行收货。
  async onOk() {
    this.isvalue = false;
    this.isvalue2 = false;
    this.isvalue3 = false;
    this.isquality = false;
    this.isremark = false;
    let typeCode = '';
    this.nodelist.forEach((item) => {
      if (this.selectList.value == item.orderCode) {
        typeCode = item.typeCode;
      }
    });
    this.detaillistceshi.forEach((item) => {
      if (item.propertyCode == 1) {
        if (item.actualValue == null || item.actualValue == '') {
          this.isvalue = true;
        }
      }
    });
    this.detaillistceshi.forEach((item) => {
      if (item.status == 'N') {
        // if (item.remark == null || item.remark == '') {
        this.isremark = true;
        // }
      }
    });
    // this.detaillistceshi.forEach((item) => {
    //   if (item.defectQuality == null || item.defectQuality == '') {
    //     this.isvalue3 = true;
    //   }
    // });
    this.detaillistdefects.forEach((item) => {
      if (item.noOkQuality === null || item.noOkQuality === '') {
        this.isquality = true;
      }
    });

    if (this.selectList.value == 'checkTypeSC') {
      if (this.isvalue) {
        (this.$refs.uToast as any).show({
          title: '实际测量值不能为空',
          type: 'default',
        });
        return;
      }
    }
    if (this.selectList.value == 'checkTypeSC') {
      if (this.formdata.reason === null || this.formdata.reason === '') {
        (this.$refs.uToast as any).show({
          title: '首检原因不能为空',
          type: 'default',
        });
        return;
      }
    }
    if (this.selectList.value != 'checkTypeLL') {
      // if (this.isremark) {
      //   (this.$refs.uToast as any).show({
      //     title: '不合格描述不能为空',
      //     type: 'default',
      //   });
      //   return;
      // }
      if (this.formdata.checkResult == 'N') {
        if (this.formdata.attr3 === null || this.formdata.attr3 === '') {
          (this.$refs.uToast as any).show({
            title: '备注描述不能为空',
            type: 'default',
          });
          return;
        }
      }
    }
    // if (this.isvalue2) {
    //   (this.$refs.uToast as any).show({
    //     title: '请选择不良分类',
    //     type: 'default',
    //   });
    //   return;
    // }
    // if (this.isvalue3) {
    //   (this.$refs.uToast as any).show({
    //     title: '不合格数量不能为空',
    //     type: 'default',
    //   });
    //   return;
    // }

    if (this.formdata.sampleQuality === null || this.formdata.sampleQuality === '') {
      (this.$refs.uToast as any).show({
        title: '抽样数量不能为空',
        type: 'default',
      });
      return;
    }
    if (this.selectList.value == 'checkTypeLL') {
      if (this.formdata.checkResult == 'N') {
        if (this.formdata.remark === null || this.formdata.remark === '') {
          (this.$refs.uToast as any).show({
            title: '不合格描述不能为空',
            type: 'default',
          });
          return;
        }
        // if (this.selectdisqualificationType.value === null || this.selectdisqualificationType.value === '') {
        //   (this.$refs.uToast as any).show({
        //     title: '不良分类不能为空',
        //     type: 'default',
        //   });
        //   return;
        // }
      }
    }
    //来料oa校验 不合格发起oa 合格不发起oa
    if (this.selectList.value == 'checkTypeLL') {
      if (this.formdata.checkResult == 'N') {
        if (this.formdata.startOA == '1') {
          if (this.formdata.materialType === null || this.formdata.materialType === '') {
            (this.$refs.uToast as any).show({
              title: '请选择来料类别',
              type: 'default',
            });
            return;
          }
          if (this.formdata.materialFrom === null || this.formdata.materialFrom === '') {
            (this.$refs.uToast as any).show({
              title: '请选择物料来源',
              type: 'default',
            });
            return;
          }
          if (this.formdata.storageFrom === null || this.formdata.storageFrom === '') {
            (this.$refs.uToast as any).show({
              title: '请选择仓储报检人',
              type: 'default',
            });
            return;
          }
        }
      }
    }
    //首见，过程oa校验 不合格发起oa 合格不发起oa
    if (this.selectList.value == 'checkTypeSC' || this.selectList.value == 'checkTypeSCXJ' || this.selectList.value == 'checkTypeCP' || this.selectList.value == 'checkTypeCC') {
      if (this.formdata.checkResult == 'N') {
        if (this.formdata.startOA == '1') {
          if (this.formdata.checkLoc === null || this.formdata.checkLoc === '') {
            (this.$refs.uToast as any).show({
              title: '请输入发现地点',
              type: 'default',
            });
            return;
          }
          if (this.formdata.oaFactoryF === null || this.formdata.oaFactoryF === '') {
            (this.$refs.uToast as any).show({
              title: '请选择异常范围',
              type: 'default',
            });
            return;
          }
          if (this.formdata.sfgyswt === null || this.formdata.sfgyswt === '') {
            (this.$refs.uToast as any).show({
              title: '请选择是否供应商问题',
              type: 'default',
            });
            return;
          }
          if (this.formdata.sfxvzq === null || this.formdata.sfxvzq === '') {
            (this.$refs.uToast as any).show({
              title: '请选择是否需要主管审核',
              type: 'default',
            });
            return;
          }
          if (this.formdata.sqbm === null || this.formdata.sqbm === '') {
            (this.$refs.uToast as any).show({
              title: '请选择申请部门',
              type: 'default',
            });
            return;
          }
          if (this.formdata.sccj === null || this.formdata.sccj === '') {
            (this.$refs.uToast as any).show({
              title: '请选择所属车间',
              type: 'default',
            });
            return;
          }
          if (this.selectischeckType.value == '0' && !this.formdata.pgzg) {
            (this.$refs.uToast as any).show({
              title: '请选择QC主管',
              type: 'default',
            });
            return;
          }
          if (this.formdata.pgzr == null || this.formdata.pgzr == '') {
            (this.$refs.uToast as any).show({
              title: '请选择质量主管',
              type: 'default',
            });
            return;
          }
        }
      }
    }
    // if (this.selectList.value == 'checkTypeCP' && !this.sampleQuality) {
    //   (this.$refs.uToast as any).show({
    //     title: '请输入样本数量',
    //     type: 'default',
    //   });
    //   return;
    // }
    // if (this.isquality) {
    //   (this.$refs.uToast as any).show({
    //     title: '数量不能为空',
    //     type: 'default',
    //   });
    //   return;
    // }
    let incomeBatchNo = '';
    if (this.isshow3) {
      if (this.incomeBatchNo.value == '' || this.incomeBatchNo.value == undefined) {
        (this.$refs.uToast as any).show({
          title: '批次号不能为空',
          type: 'default',
        });
        return;
      }
      incomeBatchNo = this.incomeBatchNo.value;
    } else {
      incomeBatchNo = this.clickitem.incomeBatchNo;
    }
    // for (let index = 0; index < this.defectCodelist.length; index++) {
    //   this.defectCodelist[index].numberall = 0;
    //   this.detaillistceshi.forEach((item) => {
    //     if (item.defectCode == this.defectCodelist[index].defectCode) {
    //       this.defectCodelist[index].numberall += parseInt(item.defectQuality);
    //     }
    //   });
    // }
    // for (let index = 0; index < this.defectCodelist.length; index++) {
    //   this.detaillistdefects.forEach((item) => {
    //     if (item.defectCode == this.defectCodelist[index].defectCode) {
    //       item.noOkQuality = this.defectCodelist[index].numberall;
    //     }
    //   });
    // }
    this.detaillistceshi.forEach((item) => {
      if (item.files.length > 0) {
        item.files = [];
      } else {
        item.files = [];
      }
      // if (this.selectList.value === 'checkTypeCP') {
      //   item.sampleQuality = this.sampleQuality;
      // }
    });
    let query: any = {};
    if (this.selectList.value == 'checkTypeSC' || this.selectList.value == 'checkTypeSCXJ' || this.selectList.value == 'checkTypeCP' || this.selectList.value == 'checkTypeCC') {
      //过程首见
      query = {
        sampleQuality: this.formdata.sampleQuality,
        updateBy: session.userName,
        factoryCode: session.PoolName,
        updateByName: session.nickName,
        typeCode: typeCode,
        checkType: this.selectList.value,
        orderCode: this.clickitem.orderNo,
        workorderCodeSap: this.clickitem.workorderCodeSap,
        qcCheckTaskDetails: this.detaillistceshi,
        defects: this.detaillistdefects,
        // 检验编码
        checkNo: this.clickitem.checkNo,
        // 批次编码
        incomeBatchNo: incomeBatchNo || null,
        //物料编号
        materialCode: this.clickitem.materialCode,
        // 物料名称
        materialName: this.clickitem.materialName,
        // 供应商编码
        supplierCode: this.clickitem.supplierCode,
        // 供应商名称
        supplierName: this.clickitem.supplierName,
        // 首见数量
        quality: this.formdata.quality,
        // 单位
        unit: this.clickitem.unit,
        //是否发起oa
        startOA: this.formdata.startOA,
        // 最终判定结果
        checkResult: this.formdata.checkResult,
        // 不良分类
        remarkCode: this.formdata.remarkCode || null,
        //不合格描述
        remark: this.formdata.remark,
        // 来料类别
        //materialType: this.formdata.materialType,
        // 物料来源
        //materialFrom: this.formdata.materialFrom,
        // 物料来源
        reason: this.formdata.reason,
        //发现地点
        checkLoc: this.formdata.checkLoc, //输入
        //异常范围选
        oaFactoryF: this.formdata.oaFactoryF,
        //是否供应商问题1非供应商问题 0是供应商问题(首检巡检)选
        sfgyswt: this.formdata.sfgyswt,
        //申请部门] 来自字典表oa sobm(首检巡检)选
        sqbm: this.formdata.sqbm,
        //是否需要审批主管
        sfxyzg: this.formdata.sfxvzq,
        // 仓储报检人
        // czbir: this.formdata.storageFrom,
        // //转出方
        // zcf: this.formdata.transferFrom,
        // //转出oem
        // zcoemcm:this.formdata.oem,
        //qc主管
        pgzg: this.formdata.pgzg,
        //质量主管
        pgzr: this.formdata.pgzr,
        sqr: session.loginName, //this.sqrlist.userId,
        sccj: this.formdata.sccj,
        attr3: this.formdata.attr3,
      };
      if (this.selectList.value == 'checkTypeSC') {
        query.cxzz = this.formdata.cxzz;
        query.jgy = this.formdata.jgy;
        query.pgy = this.formdata.pgy;
      }
    } else if (this.selectList.value == 'checkTypeLL') {
      //来料
      query = {
        sampleQuality: this.formdata.sampleQuality,
        updateBy: session.userName,
        factoryCode: session.PoolName,
        updateByName: session.nickName,
        typeCode: typeCode,
        checkType: this.selectList.value,
        orderCode: this.clickitem.orderNo,
        workorderCodeSap: this.clickitem.workorderCodeSap,
        qcCheckTaskDetails: this.detaillistceshi,
        defects: this.detaillistdefects,
        // 检验编码
        checkNo: this.clickitem.checkNo,
        // 批次编码
        incomeBatchNo: incomeBatchNo || null,
        //物料编号
        materialCode: this.clickitem.materialCode,
        // 物料名称
        materialName: this.clickitem.materialName,
        // 供应商编码
        supplierCode: this.clickitem.supplierCode,
        // 供应商名称
        supplierName: this.clickitem.supplierName,
        // 来料数量
        quality: this.clickitem.quality,
        // 单位
        unit: this.clickitem.unit,
        //是否发起oa
        startOA: this.formdata.startOA,
        // 最终判定结果
        checkResult: this.formdata.checkResult,
        // 不良分类
        remarkCode: this.formdata.remarkCode || null,
        //不合格描述
        remark: this.formdata.remark,
        // 来料类别
        materialType: this.formdata.materialType,
        // 物料来源
        materialFrom: this.formdata.materialFrom,
        // 物料来源
        //reason: this.formdata.reason,
        // 仓储报检人
        czbjr: this.formdata.storageFrom,
        //转出方
        zcf: this.formdata.transferFrom,
        //转出oem
        zcoemcm: this.formdata.oem,
        //qc主管
        qczg: this.formdata.qcFrom,
        //申请人id
        sqr: session.loginName, //this.sqrlist.userId,
        //厂区
        oaFactory: this.formdata.workFrom,
        attr3: this.formdata.attr3,
      };
    } else {
      query = {
        sampleQuality: this.formdata.sampleQuality,
        updateBy: session.userName,
        factoryCode: session.PoolName,
        updateByName: session.nickName,
        typeCode: typeCode,
        checkType: this.selectList.value,
        orderCode: this.clickitem.orderNo,
        workorderCodeSap: this.clickitem.workorderCodeSap,
        qcCheckTaskDetails: this.detaillistceshi,
        defects: this.detaillistdefects,
        // 检验编码
        checkNo: this.clickitem.checkNo,
        // 批次编码
        incomeBatchNo: incomeBatchNo || null,
        //物料编号
        materialCode: this.clickitem.materialCode,
        // 物料名称
        materialName: this.clickitem.materialName,
        // 供应商编码
        supplierCode: this.clickitem.supplierCode,
        // 供应商名称
        supplierName: this.clickitem.supplierName,
        // 来料数量
        quality: this.clickitem.quality,
        // 单位
        unit: this.clickitem.unit,
        //是否发起oa
        startOA: this.formdata.startOA,
        // 最终判定结果
        checkResult: this.formdata.checkResult,
        // 不良分类
        remarkCode: this.formdata.remarkCode || null,
        //不合格描述
        remark: this.formdata.remark,
        // 来料类别
        materialType: this.formdata.materialType,
        // 物料来源
        materialFrom: this.formdata.materialFrom,
        // 物料来源
        reason: this.formdata.reason,
        attr3: this.formdata.attr3,
        // 仓储报检人
        // czbir: this.formdata.storageFrom,
        // //转出方
        // zcf: this.formdata.transitFrom,
        // //转出oem
        // zcoemcm:this.formdata.oem,
        // //qc主管
        // qczg:this.formdata.qcfrom,
        // sqr: this.model.sqrlist[0].userId,
      };
    }
    // console.log('9999ggggg', this.detaillistceshi);
    await this.model.commitCheckTaskList(query);
    if (this.model.SubmitCode.code == '200') {
      (this.$refs.uToast as any).show({
        title: '成功',
        type: 'default',
      });

      this.show = false;
      // this.clickevent();
      this.getlist();
      this.clear();
    } else {
      (this.$refs.uToast as any).show({
        title: '失败',
        type: 'default',
      });
    }
  }
  clear() {
    this.formdata.sampleQuality = null;
    //this.sampleQuality = null;
    this.formdata.attr3 = '';
  }
  confirm() {
    if (this.tagslist.length <= 0) {
      this.detaillistceshi[this.equipmentindex[0]].actualValue = null;
    } else {
      let tagslistitem = [];
      this.tagslist.forEach((item) => {
        tagslistitem.push(item.label);
      });
      this.detaillistceshi[this.equipmentindex[0]].actualValue = JSON.stringify(tagslistitem);
      if (this.isgetAutoJudge) {
        this.getAutoJudgelist();
      }
    }
    this.tagsvalue = null;
  }
  async getAutoJudgelist() {
    let query1 = {
      factoryCode: session.PoolName,
      sampleQuality: this.clickitem.quality,
      checkLevel: this.selectList5.value,
      sampleAql: this.selectList4.value,
      actualValues: this.tagslist,
      upperDiff: this.detaillistceshi[this.equipmentindex[0]].upperDiff,
      downDiff: this.detaillistceshi[this.equipmentindex[0]].downDiff,
    };
    await this.model.getAutoJudge(query1);
    //     sampleCode:样本量编码
    // sampleQuality:样本数量
    // status:是否台格合格N不合格
    if (this.model.getAutoJudgeList.data) {
      this.detaillistceshi[this.equipmentindex[0]].status = this.model.getAutoJudgeList.data.status;
      this.detaillistceshi[this.equipmentindex[0]].sampleCode = this.model.getAutoJudgeList.data.sampleCode;
      this.detaillistceshi[this.equipmentindex[0]].sampleQuality = this.model.getAutoJudgeList.data.sampleQuality;
      this.detaillistceshi[this.equipmentindex[0]].sampleAql = this.selectList4.value;
      this.detaillistceshi[this.equipmentindex[0]].checkLevel = this.selectList5.value;
    }
  }
  // factoryCode:工厂编码sampleQuality： checkLevel:检测水平sampleaq1:接受质量限actualValue:[]实际测量值upperDiff:上限downDiff:下限
  cancel() {
    this.isshow = false;
    this.tagsvalue = null;
    this.detaillistceshi[this.equipmentindex[0]].sampleAql = null;
    this.detaillistceshi[this.equipmentindex[0]].checkLevel = null;
  }
  //查询货单关联采购单信息
  // 照片上传
  scrollLeft(files) {
    return 222 * (files.length + 1);
  }
  showScreenImg(i, files) {
    let list = files;
    // .map((item) => {
    //   return item.fileAddress;
    // });
    uni.previewImage({
      current: i,
      urls: list,
      // loop: true
    });
  }
  chooseImg(index, files) {
    uni.chooseImage({
      count: 9, //默认9
      // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album', 'camera'],
      success: (res) => {
        // uni.showLoading();
        let tempFilePaths: any = res.tempFilePaths;

        //      (this.$refs.uToast as any).show({
        //     title: '成功',
        //     type: 'success',
        //   });
        //   uni.navigateBack({});
        // } else {
        //   (this.$refs.uToast as any).show({
        //     title: '失败',
        //     type: 'error',
        //   });

        tempFilePaths.map((item) => {
          uni.uploadFile({
            url: 'http://192.168.202.34:30000/prod-api/file/upload',
            // url: '/prod-api/file/upload',
            //url: '/dev-api/file/upload',
            fileType: 'image',
            filePath: item,
            header: {
              Authorization: 'Bearer ' + session.user?.access_token,
              // 'cosmo-env-sitecode': this.$store.state.siteCode
            },
            name: 'file',
            // formData: {
            // 	materialCode: this.materialObj.materialCode,
            // },
            success: (res) => {
              uni.hideLoading();
              if (!res.data) {
                // this.$refs.toastRef.show({
                // 	type:"error",
                // 	text:res.msg
                // })
                return;
              }
              let data = JSON.parse(res.data);
              files = [...files, data.data.url];
              this.detaillistceshi[index].files = files;
              this.detaillistceshi[index].fileListStr = files.join(',');
              //this.filesName = [...this.filesName,data.fileName];
              //this.picUrls = this.files.join(",");
              //this.picNames = this.filesName.join(",");
              uni.hideLoading();
            },
            fail: () => {
              uni.hideLoading();
            },
          });
        });
      },
    });
  }
  deleteImg(index, index1) {
    this.detaillistceshi[index].files.splice(index1, 1);
    this.detaillistceshi[index].fileListStr = this.detaillistceshi[index].files.join(',');
  }
  // "resp_message":"success""res_presult":"http://li08.cn/21001871815240307020600048115350""res_pcode":1000}
  scanCodeOne() {
    // http://lj08.cn/21201501124240221021300171390045
    mpaasScanModule.mpaasScan(
      {
        // 扫码识别类型，参数可多选，qrCode、barCode，
        // 如不设置，默认识别所有扫码类型，可能有些许影响识别效率
        scanType: ['qrCode', 'barCode'],
        // 是否隐藏相册，默认false不隐藏
        hideAlbum: false,
      },
      (ret) => {
        // uni.showModal({
        //   title: '扫码结果',
        //   // 返回值中，有三个参数 resp_code、resp_message、resp_result
        //   // resp_code 表示返回结果值，10：用户取消，11：其他错误，1000：成功
        //   // resp_message 表示返回结果信息
        //   // resp_result 表示扫码结果，只有成功才会有返回
        //   content: JSON.stringify(ret),
        //   showCancel: false,
        //   confirmText: '确定',
        // });
        if (ret.resp_message == 'success') {
          uni.navigateTo({
            url: `/pages/quality/Materialinspection/web?listitem=` + encodeURIComponent(ret.resp_result),
          });
        } else {
          this.customToast(ret.resp_result);
        }
      },
    );
  }
  scanCodeOne3() {
    // http://lj08.cn/21201501124240221021300171390045
    uni.scanCode({
      scanType: ['qrCode', 'barCode'],
      success: (res) => {
        this.orderNo = res.result;
        uni.navigateTo({
          url: `/pages/quality/Materialinspection/web?listitem=` + encodeURIComponent(res.result),
        });
      },
      fail(result) {
        this.customToast(result);
      },
    });
  }
  scanCodeOne2() {
    // http://lj08.cn/21201501124240221021300171390045
    let result: any = 'https://wx.hlcode.cn/?id=NEVVLoo';
    uni.navigateTo({
      url: `/pages/quality/Materialinspection/web?listitem=` + encodeURIComponent(result),
    });
  }
  closepopup() {
    //this.show = false;
    //是否关闭弹窗
    this.SaveDraft();
    this.$nextTick(() => {
      this.show = false;
      this.clickevent();
    });
  }

  onBackPress(e) {
    if (e.from === 'backbutton') {
      if (this.show === true) {
        this.SaveDraft();
        this.$nextTick(() => {
          this.show = false;
          this.clickevent();
        });
        return true;
      } else {
        ///
      }
    }
  }
  // 暂存
  async SaveDraft() {
    this.showmask = true;
    let typeCode = '';
    this.nodelist.forEach((item) => {
      if (this.selectList.value == item.orderCode) {
        typeCode = item.typeCode;
      }
    });
    this.detaillistceshi.forEach((item) => {
      if (item.propertyCode == 1) {
        if (item.actualValue == null || item.actualValue == '') {
          this.isvalue = true;
        }
      }
    });
    this.detaillistceshi.forEach((item) => {
      if (item.status == 'N') {
        if (item.remark == null || item.remark == '') {
          this.isremark = true;
        }
      }
    });
    this.detaillistdefects.forEach((item) => {
      if (item.noOkQuality === null || item.noOkQuality === '') {
        this.isquality = true;
      }
    });
    let incomeBatchNo = '';
    if (this.isshow3) {
      // if (this.incomeBatchNo.value == '' || this.incomeBatchNo.value == undefined) {
      //   (this.$refs.uToast as any).show({
      //     title: '批次号不能为空',
      //     type: 'default',
      //   });
      //   return;
      // }
      incomeBatchNo = this.incomeBatchNo.value;
    } else {
      incomeBatchNo = this.clickitem.incomeBatchNo;
    }
    let detaillistceshidata = JSON.parse(JSON.stringify(this.detaillistceshi));
    detaillistceshidata.forEach((item) => {
      if (item.files.length > 0) {
        item.files = [];
      } else {
        item.files = [];
      }
      // if (this.selectList.value === 'checkTypeCP') {
      //   item.sampleQuality = this.sampleQuality;
      // }
    });
    let params;
    params = {
      sampleQuality: this.formdata.sampleQuality,
      updateBy: session.userName,
      factoryCode: session.PoolName,
      updateByName: session.nickName,
      typeCode: typeCode,
      checkType: this.selectList.value,
      orderCode: this.clickitem.orderNo,
      workorderCodeSap: this.clickitem.workorderCodeSap,
      qcCheckTaskDetails: detaillistceshidata,
      defects: this.detaillistdefects,
      // 检验编码
      checkNo: this.clickitem.checkNo,
      // 批次编码
      incomeBatchNo: incomeBatchNo || null,
      //物料编号
      materialCode: this.clickitem.materialCode,
      // 物料名称
      materialName: this.clickitem.materialName,
      // 供应商编码
      supplierCode: this.clickitem.supplierCode,
      // 供应商名称
      supplierName: this.clickitem.supplierName,
      // 首见数量
      quality: this.formdata.quality,
      // 单位
      unit: this.clickitem.unit,
      //是否发起oa
      startOA: this.formdata.startOA,
      // 最终判定结果
      checkResult: this.formdata.checkResult,
      // 不良分类
      remarkCode: this.formdata.remarkCode || null,
      //不合格描述
      remark: this.formdata.remark,
      // 来料类别
      materialType: this.formdata.materialType,
      // 物料来源
      materialFrom: this.formdata.materialFrom,
      // 物料来源
      reason: this.formdata.reason,
      //发现地点
      checkLoc: this.formdata.checkLoc, //输入
      //异常范围选
      oaFactoryF: this.formdata.oaFactoryF,
      //是否供应商问题1非供应商问题 0是供应商问题(首检巡检)选
      sfgyswt: this.formdata.sfgyswt,
      //申请部门] 来自字典表oa sobm(首检巡检)选
      sqbm: this.formdata.sqbm,
      //是否需要审批主管
      sfxyzg: this.formdata.sfxvzq,
      // 仓储报检人
      czbjr: this.formdata.storageFrom,
      // //转出方
      zcf: this.formdata.transferFrom,
      // //转出oem
      zcoemcm: this.formdata.oem,
      //qc主管
      pgzg: this.formdata.pgzg,
      //质量主管
      pgzr: this.formdata.pgzr,
      sqr: session.loginName, //this.sqrlist.userId,
      sccj: this.formdata.sccj,
      attr3: this.formdata.attr3,
      oaFactory: this.formdata.workFrom,
      //qc主管
      qczg: this.formdata.qcFrom,
    };
    if (this.selectList.value == 'checkTypeSC') {
      params.cxzz = this.formdata.cxzz;
      params.jgy = this.formdata.jgy;
      params.pgy = this.formdata.pgy;
    }
    try {
      await model.commitDraft(params); //99999
      if (model.commitDraftCode == 200) {
        // let query = {
        //   factoryCode: session.PoolName,
        //   belongTo: this.clickitem.recordId,
        //   checkType: this.selectList.value,
        // };
        // //默认查暂存草稿
        // await this.model.queryCheckTaskDetailListCG(query);
        (this.$refs.uToast as any).show({
          title: '保存成功',
        });
        this.showmask = false;
        // this.show = false;
      } else {
        (this.$refs.uToast as any).show({
          title: '保存失败,请网络通畅了再试',
        });
      }
    } catch (err) {
      (this.$refs.uToast as any).show({
        title: '保存失败,请网络通畅了再试',
      });
    }
  }

  async singname(singmark) {
    this.showsing = true;
    this.singmark = singmark;
  }
  cancelsing() {
    this.showsing = false;
  }
  async getImg(e) {
    uni.uploadFile({
      url: 'http://192.168.202.34:30000/prod-api/file/upload',
      filePath: e, // You may need to save the blob as a file first or use a temp path
      name: 'file',
      formData: {
        filename: '签名.png',
      },
      header: {
        Authorization: 'Bearer ' + session.user?.access_token,
        // 'cosmo-env-sitecode': this.$store.state.siteCode
      },
      success: (uploadFileRes) => {
        let dataobj = JSON.parse(uploadFileRes.data);
        if (this.singmark === '1') {
          this.formdata.cxzz = dataobj.data.url;
        } else if (this.singmark === '2') {
          this.formdata.jgy = dataobj.data.url;
        } else if (this.singmark === '3') {
          this.formdata.pgy = dataobj.data.url;
        }
      },
      fail: (error) => {
        (this.$refs.uToast as any).show({
          title: '签名失败',
          // url: '/pages/user/index'
        });
        console.error(error);
      },
    });

    this.showsing = false;
  }
  confirmNumber(changeobj, index) {
    //console.log('1239999999',changeobj);
    //console.log('1239999999',this.clickitem.incomeBatchNo);
    //console.log('1239999999',changeobj.actualValue);
    if (changeobj.actualValue === this.clickitem.incomeBatchNo) {
      this.detaillistceshi[index].status = 'Y';
    } else {
      this.detaillistceshi[index].status = 'N';
    }
    this.determine();
  }

  validateInput(value, index) {
    const isValidNumber = /^\d*$/.test(value); // 只允许输入数字
    if (!isValidNumber) {
      const cleanedValue = value.replace(/[^\d]/g, '');
      this.$set(this.detaillistceshi[index], 'sampleQuality', cleanedValue);
      //this.detaillistceshi[index].sampleQuality = cleanedValue;
    }
  }
  changeInput(event, index) {
    //this.detaillistceshi[index].newsampleQuality = event.target.value;
    this.detaillistceshi[index].sampleQuality = event.target.value;
    console.log('后面改变了吗', this.detaillistceshi[index].sampleQuality);
  }

  changeInput1(event, index) {
    this.detaillistceshi.forEach((item) => {
      item.sampleQuality = event.target.value;
    });
    this.detaillistceshi[index].sampleQuality = event.target.value;
    console.log('后面改变了吗', this.detaillistceshi[index].sampleQuality);
  }
  changeInputsamp(event) {
    this.formdata.sampleQuality = event;
  }
  changeInputqual(event) {
    this.formdata.quality = event;
  }
  changeInputtags(event) {
    this.tagsvalue = event;
    // const regex = /^[a-zA-Z0-9.]+$/; // 仅允许英文、数字和小数点
    // const inputValue = event; // 获取输入值
    // if (!regex.test(inputValue)) {
    //   // 替换所有非法字符
    //   this.tagsvalue = inputValue.replace(/[^a-zA-Z0-9.]/g, '');
    // } else {
    //   this.tagsvalue = inputValue; // 输入合法，直接赋值
    // }
  }
  //正则匹配
  validateInputtags(event) {
    console.log(event);
    const regex = /^[a-zA-Z0-9.]+$/; // 仅允许英文、数字和小数点
    const inputValue = event; // 获取输入值
    if (!regex.test(inputValue)) {
      // 替换所有非法字符
      this.tagsvalue = inputValue.replace(/[^a-zA-Z0-9.]/g, '');
    } else {
      this.tagsvalue = inputValue; // 输入合法，直接赋值
    }
  }
  // 清除定时器
  clickevent() {
    this.keyboardHideInterval.forEach((id) => clearInterval(id)); // 清除所有定时器
    this.keyboardHideInterval = []; // 清空数组
    // #ifdef APP-PLUS
    // #endif
  }
  // 启动定时器
  clearMessage() {
    this.keyboardHideInterval.forEach((id) => clearInterval(id)); // 清除所有定时器
    this.keyboardHideInterval = []; // 清空数组
    const intervalId = setInterval(() => {
      this.SaveDraft();
    }, 1000 * 60 * 1);
    if (intervalId) {
      this.keyboardHideInterval.push(intervalId);
    }
    // #ifdef APP-PLUS

    // #endif
  }
  beforeDestroy() {
    // 清除定时器
    this.keyboardHideInterval.forEach((id) => clearInterval(id)); // 清除所有定时器
    this.keyboardHideInterval = []; // 清空数组
  }
  //测量值修改
  confirmindex(e) {
    this.serialnumber = this.indexdata[e[0]];
    console.log(e);
  }
  cancelindex(e) {
    console.log(e);
  }
  clickInputtags() {
    this.showindex = true;
  }
}
</script>
<style lang="scss" scoped>
.boder-icon-rigth1 {
  border: 1rpx solid #5a9cf8;
  width: 200rpx;
  text-align: center;
  background: #5a9cf8;
  color: #ffffff;
  margin-top: 10rpx;
  padding: 10rpx;
}
// 暂存按钮
.boder-icon-rigth2 {
  text-align: center;
  color: #ffffff;
  margin-top: 20rpx;
  .u-btn {
    width: 280rpx;
  }
}
.page-product-receipt {
  background: #f2f2f2 linear-gradient(0deg, #f2f2f2 0%, #f8262c 51%, #d9001b 100%) no-repeat;
  background-size: 100% 600rpx;
  padding: 118rpx 30rpx 162rpx;
  min-height: 100%;

  .header {
    position: fixed;
    top: 0rpx;
    left: 0;
    right: 0;
    z-index: 99;
    display: flex;
    height: 120rpx;
    line-height: 88rpx;
    color: #fff;
    font-size: 34rpx;
    font-weight: 500;
    text-align: center;
    padding: 45rpx 0rpx 0rpx;

    .title {
      flex: 3;
    }

    .left,
    .right {
      flex: 1;
    }

    .icon {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 88rpx;
      height: 88rpx;
    }
  }

  .form {
    background-color: #fff;
    padding: 20rpx;
    border-radius: 10rpx;
    box-shadow: 0 0 20rpx 0 rgba(128, 128, 128, 0.2);

    .u-form-item {
      padding: 30rpx 0;
      line-height: 35rpx;

      .Transfer {
        width: 280rpx;
        height: 64rpx;
        background: rgb(242, 242, 242);
        border-radius: 110rpx;
      }
    }

    .single {
      width: 100%;
      // height: 100rpx;
      display: flex;

      .single-left {
        width: 80%;
        height: 100%;
        display: flex;

        view {
          width: 142rpx;
          height: 100%;
          line-height: 100rpx;
        }
      }

      .single-right {
        button {
          width: 140rpx;
          height: 70rpx;
          background-color: #fa3534;
        }
      }
    }

    .row {
      display: flex;
      flex-direction: row;
      justify-content: space-around;
      flex: 1;
    }
  }

  .scroll {
    // margin-top: 120rpx;
    // padding-left: 30rpx;
    // padding-right: 16rpx;
    // margin-bottom: 20rpx;
    // overflow: scroll;
    // padding-top: 20rpx;

    .form2 {
      // background-color: #fff;
      padding: 0rpx 25rpx 25rpx;
      border-radius: 10rpx;
      box-shadow: 0 0 20rpx 0 rgba(128, 128, 128, 0.2);
      color: #8d8989;
      .row-list {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        .row-list-item {
          display: flex;
          flex-direction: row;
          justify-content: space-between;
          width: 40%;
        }
        .list-item {
          display: flex;
          flex-direction: row;
          flex: 1;
        }
      }

      .righttitle {
        display: flex;
        justify-content: flex-end;

        .boder-icon-rigth {
          border: 1rpx solid #fa3534;
          width: 130rpx;
          text-align: center;
          background: #fa3534;
          color: #ffffff;
          margin-top: 20rpx;
        }

        .zhuangtai {
          background: #a7a0a04a;
          width: 224rpx;
          margin-right: -27rpx;
          border: 2rpx solid #a7a0a04a;
          border-radius: 12rpx;
          text-align: center;
          margin-bottom: 10rpx;
        }

        .zhuangtai[data-state='1'] {
          color: green;
        }

        .zhuangtai[data-state='0'] {
          color: blue;
        }
      }
    }
  }

  .bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 99;
    background: #ffffff;
    box-shadow: 0 1rpx 20rpx 0 rgba(128, 128, 128, 0.2);
    padding: 20rpx;
  }

  .button-bar {
  }
  .button-barsing {
    font-size: 20px;
  }

  .photoList {
    display: flex;
    padding-top: 12rpx;

    .chooseBtn {
      width: 202rpx;
      height: 202rpx;
      background: #fafafa;
      border-radius: 12rpx;
      border: 2rpx dashed #e2e2e2;
      display: flex;
      justify-content: center;
      align-items: center;

      .inner {
        text-align: center;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
      }

      .desc {
        font-size: 28rpx;
        font-weight: 400;
        color: #24252a;
        line-height: 40rpx;
      }

      .img {
        width: 50rpx;
        height: 50rpx;
        margin-bottom: 6rpx;
      }
    }

    .photoBox {
      width: 202rpx;
      height: 202rpx;
      background: #fafafa;
      border-radius: 12rpx;
      position: relative;

      .closeBtn {
        position: absolute;
        top: -12rpx;
        right: -12rpx;
        z-index: 2;
        width: 36rpx;
        height: 36rpx;

        .img {
          width: 36rpx;
          height: 36rpx;
        }
      }

      .img {
        width: 202rpx;
        height: 202rpx;
        border-radius: 12rpx;
      }
    }

    .itemBox {
      flex: 0 0 202rpx;
      margin-right: 20rpx;

      &:last-child {
        margin-right: 0;
      }
    }

    // /deep/ .remarksBox textarea {
    //   font-size: 24rpx;
    // }
  }
  .poupbutton {
    display: flex;
    justify-content: space-around;
  }
  .mask {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* 半透明的黑色背景 */
    z-index: 9999; /* 确保遮罩层在最上层 */
  }
  .selectlist {
    margin-top: 30rpx;
    border-radius: 10rpx;
    // border: rgba(121, 121, 121, 1) solid 1px;
    // background-color: #ffffff;
    padding: 14rpx 16rpx 14rpx 24rpx;
    box-sizing: border-box;
    .item-name {
      .quest {
        // width: 367px;
        // border-radius: 5px;
        // border: rgba(121, 121, 121, 1) solid 1px;
        // background-color: #ffffff;
        padding: 14rpx 16rpx 14rpx 24rpx;
        box-sizing: border-box;
        text-align: center;
        font-size: 36rpx;
      }
      .details {
        display: flex;
        font-size: 30rpx;
        // justify-content: space-between;
        align-items: center;
        margin-bottom: 16rpx;
      }
    }
    .single-left {
      display: flex;
      // align-items: center;
      // justify-content: space-around;
      text-align: center;
      margin-top: 24rpx;
      margin-bottom: 40rpx;
      border: 2rpx solid #eee;
    }
    .item {
      margin-top: 30rpx;
      width: 100%;
      border-radius: 10rpx;
      border: rgba(121, 121, 121, 1) solid 2rpx;
      // background-color: #ffffff;
      padding: 14rpx 16rpx 14rpx 16rpx;
      box-sizing: border-box;
      .item1 {
        margin-bottom: 6rpx;
        white-space: 2rpx;
        font-size: 30rpx;
        font-weight: 600;
      }
      .item2 {
        display: flex;
        align-items: center;
        // justify-content: space-between;
        .select {
          font-size: 30rpx;
          font-weight: 400;
          display: flex;
          // margin-left: 19px;
        }
        .input-box {
          font-size: 26rpx;
          font-weight: 400;
          display: flex;
          align-content: center;
          margin-top: 4rpx;
          .input {
            font-size: 24rpx;
            width: 56%;
            padding: 2rpx 16rpx;
            height: 54rpx;
            box-sizing: border-box;
            border: 2rpx solid #b6b6b6;
            margin-left: 12rpx;
            display: inline-block;
            margin-right: 12rpx;
            border-radius: 8rpx;
            position: relative;
          }
        }
      }
      .item3 {
        display: flex;
        align-content: center;
        justify-content: space-between;
      }
    }
  }
  .modal {
    .upload-name {
      padding: 12rpx 40rpx;
      display: flex;
      justify-content: space-between;
      .name {
        font-size: 34rpx;
        font-weight: 600;
      }
    }
    .tagsbox {
      padding: 20rpx 40rpx;
      .tags {
        margin-right: 10rpx;
      }
    }
  }
  .Belowsform3 {
    background-color: #fff;
    padding: 14rpx 16rpx 14rpx 24rpx;
    .u-form-item {
      line-height: 35rpx;
      font-size: 32rpx;
    }
    .photoList {
      display: flex;
      padding-top: 12rpx;

      .chooseBtn {
        width: 202rpx;
        height: 202rpx;
        background: #fafafa;
        border-radius: 12rpx;
        border: 2rpx dashed #e2e2e2;
        display: flex;
        justify-content: center;
        align-items: center;

        .inner {
          text-align: center;
          display: flex;
          flex-direction: column;
          justify-content: center;
          align-items: center;
        }

        .desc {
          font-size: 28rpx;
          font-weight: 400;
          color: #24252a;
          line-height: 40rpx;
        }

        .img {
          width: 50rpx;
          height: 50rpx;
          margin-bottom: 6rpx;
        }
      }

      .photoBox {
        width: 202rpx;
        height: 202rpx;
        background: #fafafa;
        border-radius: 12rpx;
        position: relative;

        .closeBtn {
          position: absolute;
          top: -12rpx;
          right: -12rpx;
          z-index: 2;
          width: 36rpx;
          height: 36rpx;

          .img {
            width: 36rpx;
            height: 36rpx;
          }
        }

        .img {
          width: 202rpx;
          height: 202rpx;
          border-radius: 12rpx;
        }
      }

      .itemBox {
        flex: 0 0 202rpx;
        margin-right: 20rpx;

        &:last-child {
          margin-right: 0;
        }
      }
    }
  }
  ::v-deep .input1 .u-input__input {
    //background: rgb(233 231 231 / 38%);
    background-color: #f0f0f0;
  }
  ::v-deep .uni-input-placeholder {
    font-weight: 500;
    left: 20rpx;
  }
  ::v-deep .uni-textarea-placeholder {
    font-weight: 500;
  }
  ::v-deep .Belowsform3 .uni-input-input {
    width: 97%;
    border: 2rpx solid #dcdfe6;
  }
  .selected-form {
    background-color: #f0f0f0; /* 示例背景色 */
  }
  .warp {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
  }

  .rect {
    // width: px;
    // height: 120px;
    background-color: #2c2c2c;
    border-radius: 5px;
    padding: 7px;
    color: #ffffff;
  }
}
::v-deep .vc-switch {
  z-index: 999999;
}
// ::v-deep .vc-mask {
//   z-index: 999999;
// }
// ::v-deep .vc-panel {
//   z-index: 999999;
// }
</style>
