<!-- BatchCalibrationTable.vue -->
<template>
  <div>
    <div v-for="(rowData, rowIdx) in tableData" :key="rowIdx" class="form-block">
      <el-form :model="tableData" label-width="120px" ref="tablePllr" style="width:100%;">
        <table class="common-table-style4" border style="width:100%; border-collapse:collapse; table-layout: fixed;">
          <tr>
            <td colspan="2" style="text-align:center; vertical-align:middle; border:1px solid #e6e6e6 !important; padding: 8px;">
              <el-form-item prop="index" style="margin: 0;">
                <span style="display:block; margin:5px 0; text-align:center;">标定{{ rowIdx + 1 }}</span>
              </el-form-item>
            </td>
          </tr>
          <tr v-if="cols.length > 0">
            <td style="width: 50% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[0].ANLY_ITEM_NAME || '字段1'" :prop="cols[0].ANLY_ITEM_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[0].ANLY_ITEM_NO]" 
                  @keydown.native="keyDown($event, rowIdx, 0)" 
                  :data-row="rowIdx"
                  :data-col="0"
                  :id="`input-${rowIdx}-0`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
            <td style="width: 50% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[1].ANLY_ITEM_NAME || '字段2'" :prop="cols[1].ANLY_ITEM_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[1].ANLY_ITEM_NO]"
                  @keydown.native="keyDown($event, rowIdx, 1)" 
                  :data-row="rowIdx"
                  :data-col="1"
                  :id="`input-${rowIdx}-1`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
          </tr>
          <tr v-if="cols.length >= 2">
            <td style="width: 50% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[2].ANLY_ITEM_NAME || '字段1'" :prop="cols[2].ANLY_ITEM_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[2].ANLY_ITEM_NO]"
                  @keydown.native="keyDown($event, rowIdx, 2)" 
                  :data-row="rowIdx"
                  :data-col="2"
                  :id="`input-${rowIdx}-2`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
            <td style="width: 50% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[3].ANLY_ITEM_NAME || '字段2'" :prop="cols[3].ANLY_ITEM_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[3].ANLY_ITEM_NO]"
                  @keydown.native="keyDown($event, rowIdx, 3)" 
                  :data-row="rowIdx"
                  :data-col="3"
                  :id="`input-${rowIdx}-3`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
          </tr>
          <tr v-if="cols.length >= 4">
            <td style="width: 50% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[4].ANLY_ITEM_NAME || '字段1'" :prop="cols[4].ANLY_ITEM_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[4].ANLY_ITEM_NO]"
                  @keydown.native="keyDown($event, rowIdx, 4)" 
                  :data-row="rowIdx"
                  :data-col="4"
                  :id="`input-${rowIdx}-4`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
            <td style="width: 50% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[5].ANLY_ITEM_NAME || '字段2'" :prop="cols[5].ANLY_ITEM_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[5].ANLY_ITEM_NO]"
                  @keydown.native="keyDown($event, rowIdx, 5)" 
                  :data-row="rowIdx"
                  :data-col="5"
                  :id="`input-${rowIdx}-5`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
          </tr>
          <tr v-if="cols.length >= 6">
            <td style="width: 50% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[6].ANLY_ITEM_NAME || '字段1'" :prop="cols[6].ANLY_ITEM_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[6].ANLY_ITEM_NO]"
                  @keydown.native="keyDown($event, rowIdx, 6)" 
                  :data-row="rowIdx"
                  :data-col="6"
                  :id="`input-${rowIdx}-6`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
            <td style="width: 50% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[7].ANLY_ITEM_NAME" :prop="cols[7].ANLY_ITEM_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[7].ANLY_ITEM_NO]"
                  @keydown.native="keyDown($event, rowIdx, 7)" 
                  :data-row="rowIdx"
                  :data-col="7"
                  :id="`input-${rowIdx}-7`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
          </tr>
          <tr v-if="cols.length >= 8">
            <td style="width: 50% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[8].ANLY_ITEM_NAME || '字段1'" :prop="cols[8].STUFF_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[8].STUFF_NO]"
                  @keydown.native="keyDown($event, rowIdx, 8)" 
                  :data-row="rowIdx"
                  :data-col="8"
                  :id="`input-${rowIdx}-8`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
            <td style="width: 50% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[9].ANLY_ITEM_NAME || '字段2'" :prop="cols[9].ANLY_ITEM_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[9].ANLY_ITEM_NO]"
                  @keydown.native="keyDown($event, rowIdx, 9)" 
                  :data-row="rowIdx"
                  :data-col="9"
                  :id="`input-${rowIdx}-9`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
          </tr>
        </table>
        <table class="common-table-style4" border style="width:100%; border-collapse:collapse; table-layout: fixed;">
          <tr v-if="cols.length >= 10">
            <td colspan="5" style="width: 100% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item label="干燥/灼烧恒重(g)" style="margin: 0;">
                <div style="display:flex; gap: 8px; width: 100%; box-sizing: border-box;">
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[10].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 10)" 
                    :data-row="rowIdx"
                    :data-col="10"
                    :id="`input-${rowIdx}-10`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[11].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 11)" 
                    :data-row="rowIdx"
                    :data-col="11"
                    :id="`input-${rowIdx}-11`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[12].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 12)" 
                    :data-row="rowIdx"
                    :data-col="12"
                    :id="`input-${rowIdx}-12`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[13].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 13)" 
                    :data-row="rowIdx"
                    :data-col="13"
                    :id="`input-${rowIdx}-13`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                </div>
              </el-form-item>
            </td>
          </tr>
        </table>
        <table class="common-table-style4" border style="width:100%; border-collapse:collapse; table-layout: fixed;">
          <tr v-if="cols.length >= 15">
            <td style="width: 33.33% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[14].ANLY_ITEM_NAME || '字段1'" :prop="cols[14].STUFF_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[14].STUFF_NO]"
                  @keydown.native="keyDown($event, rowIdx, 14)" 
                  :data-row="rowIdx"
                  :data-col="14"
                  :id="`input-${rowIdx}-14`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
            <td style="width: 33.33% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[15].ANLY_ITEM_NAME || '字段2'" :prop="cols[15].ANLY_ITEM_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[15].ANLY_ITEM_NO]"
                  @keydown.native="keyDown($event, rowIdx, 15)" 
                  :data-row="rowIdx"
                  :data-col="15"
                  :id="`input-${rowIdx}-15`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
            <td style="width: 33.33% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[16].ANLY_ITEM_NAME || '字段2'" :prop="cols[16].ANLY_ITEM_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[16].ANLY_ITEM_NO]"
                  @keydown.native="keyDown($event, rowIdx, 16)" 
                  :data-row="rowIdx"
                  :data-col="16"
                  :id="`input-${rowIdx}-16`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
          </tr>
          <tr v-if="cols.length >= 18">
            <td style="width: 33.33% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[17].ANLY_ITEM_NAME || '字段1'" :prop="cols[17].ANLY_ITEM_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[17].ANLY_ITEM_NO]"
                  @keydown.native="keyDown($event, rowIdx, 17)" 
                  :data-row="rowIdx"
                  :data-col="17"
                  :id="`input-${rowIdx}-17`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
            <td style="width: 33.33% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[18].ANLY_ITEM_NAME || '字段2'" :prop="cols[18].ANLY_ITEM_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[18].ANLY_ITEM_NO]"
                  @keydown.native="keyDown($event, rowIdx, 18)" 
                  :data-row="rowIdx"
                  :data-col="18"
                  :id="`input-${rowIdx}-18`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
            <td style="width: 33.33% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[22].ANLY_ITEM_NAME || '字段2'" :prop="cols[22].ANLY_ITEM_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[22].ANLY_ITEM_NO]"
                  @keydown.native="keyDown($event, rowIdx, 19)" 
                  :data-row="rowIdx"
                  :data-col="19"
                  :id="`input-${rowIdx}-19`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
          </tr>
        </table>
        <table class="common-table-style4" border style="width:100%; border-collapse:collapse; table-layout: fixed;">
          <tr>
            <td colspan="5" style="width: 100% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item label="标定序号" style="margin: 0;">
                <div style="display:flex; gap: 8px; width: 100%; box-sizing: border-box;">
                  <span style="flex: 1; min-width: 80px; width: 100%;text-align: center; box-sizing: border-box;">1</span>
                  <span style="flex: 1; min-width: 80px; width: 100%;text-align: center; box-sizing: border-box;">2</span>
                  <span style="flex: 1; min-width: 80px; width: 100%; text-align: center;box-sizing: border-box;">3</span>
                  <span style="flex: 1; min-width: 80px; width: 100%;text-align: center; box-sizing: border-box;">4</span>
                </div>
              </el-form-item>
            </td>
          </tr>
          <tr v-if="cols.length >= 26">
            <td colspan="5" style="width: 100% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item label="标定物用量" style="margin: 0;">
                <div style="display:flex; gap: 8px; width: 100%; box-sizing: border-box;">
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[21].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 20)" 
                    :data-row="rowIdx"
                    :data-col="20"
                    :id="`input-${rowIdx}-20`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[23].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 21)" 
                    :data-row="rowIdx"
                    :data-col="21"
                    :id="`input-${rowIdx}-21`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[24].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 22)" 
                    :data-row="rowIdx"
                    :data-col="22"
                    :id="`input-${rowIdx}-22`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[25].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 23)" 
                    :data-row="rowIdx"
                    :data-col="23"
                    :id="`input-${rowIdx}-23`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                </div>
              </el-form-item>
            </td>
          </tr>
          <tr v-if="cols.length >= 38">
            <td colspan="5" style="width: 100% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item label="滴定体积" style="margin: 0;">
                <div style="display:flex; gap: 8px; width: 100%; box-sizing: border-box;">
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[34].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 24)" 
                    :data-row="rowIdx"
                    :data-col="24"
                    :id="`input-${rowIdx}-24`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[35].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 25)" 
                    :data-row="rowIdx"
                    :data-col="25"
                    :id="`input-${rowIdx}-25`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[36].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 26)" 
                    :data-row="rowIdx"
                    :data-col="26"
                    :id="`input-${rowIdx}-26`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[37].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 27)" 
                    :data-row="rowIdx"
                    :data-col="27"
                    :id="`input-${rowIdx}-27`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                </div>
              </el-form-item>
            </td>
          </tr>
          <tr v-if="cols.length >= 34">
            <td colspan="5" style="width: 100% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item label="温度校正后的值" style="margin: 0;">
                <div style="display:flex; gap: 8px; width: 100%; box-sizing: border-box;">
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[30].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 28)" 
                    :data-row="rowIdx"
                    :data-col="28"
                    :id="`input-${rowIdx}-28`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[31].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 29)" 
                    :data-row="rowIdx"
                    :data-col="29"
                    :id="`input-${rowIdx}-29`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[32].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 30)" 
                    :data-row="rowIdx"
                    :data-col="30"
                    :id="`input-${rowIdx}-30`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[33].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 31)" 
                    :data-row="rowIdx"
                    :data-col="31"
                    :id="`input-${rowIdx}-31`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                </div>
              </el-form-item>
            </td>
          </tr>
          <tr v-if="cols.length >= 38">
            <td colspan="5" style="width: 100% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item label="滴定管校正后值" style="margin: 0;">
                <div style="display:flex; gap: 8px; width: 100%; box-sizing: border-box;">
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[34].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 32)" 
                    :data-row="rowIdx"
                    :data-col="32"
                    :id="`input-${rowIdx}-32`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[35].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 33)" 
                    :data-row="rowIdx"
                    :data-col="33"
                    :id="`input-${rowIdx}-33`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[36].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 34)" 
                    :data-row="rowIdx"
                    :data-col="34"
                    :id="`input-${rowIdx}-34`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[37].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 35)" 
                    :data-row="rowIdx"
                    :data-col="35"
                    :id="`input-${rowIdx}-35`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                </div>
              </el-form-item>
            </td>
          </tr>
          <tr v-if="cols.length >= 43">
            <td colspan="5" style="width: 100% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item label="实际消耗体积" style="margin: 0;">
                <div style="display:flex; gap: 8px; width: 100%; box-sizing: border-box;">
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[39].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 36)" 
                    :data-row="rowIdx"
                    :data-col="36"
                    :id="`input-${rowIdx}-36`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[40].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 37)" 
                    :data-row="rowIdx"
                    :data-col="37"
                    :id="`input-${rowIdx}-37`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[41].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 38)" 
                    :data-row="rowIdx"
                    :data-col="38"
                    :id="`input-${rowIdx}-38`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[42].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 39)" 
                    :data-row="rowIdx"
                    :data-col="39"
                    :id="`input-${rowIdx}-39`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                </div>
              </el-form-item>
            </td>
          </tr>
          <tr v-if="cols.length >= 49">
            <td colspan="5" style="width: 100% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item label="计算结果值" prop="correctedV2">
                <div style="display:flex; gap: 8px; width: 100%; box-sizing: border-box;">
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[45].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 40)" 
                    :data-row="rowIdx"
                    :data-col="40"
                    :id="`input-${rowIdx}-40`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[46].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 41)" 
                    :data-row="rowIdx"
                    :data-col="41"
                    :id="`input-${rowIdx}-41`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[47].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 42)" 
                    :data-row="rowIdx"
                    :data-col="42"
                    :id="`input-${rowIdx}-42`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[48].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 43)" 
                    :data-row="rowIdx"
                    :data-col="43"
                    :id="`input-${rowIdx}-43`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                </div>
              </el-form-item>
            </td>
          </tr>
          <tr>
            <td colspan="5" style="width: 100% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[38].ANLY_ITEM_NAME" style="margin: 0;">
                <div style="display:flex; gap: 8px; width: 100%; box-sizing: border-box;">
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[38].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 44)" 
                    :data-row="rowIdx"
                    :data-col="44"
                    :id="`input-${rowIdx}-44`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                </div>
              </el-form-item>
            </td>
          </tr>
          <tr>
            <td colspan="5" style="width: 100% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[43].ANLY_ITEM_NAME" style="margin: 0;">
                <div style="display:flex; gap: 8px; width: 100%; box-sizing: border-box;">
                  <el-input 
                    size="mini" 
                    v-model="rowData[cols[43].ANLY_ITEM_NO || '']"
                    @keydown.native="keyDown($event, rowIdx, 45)" 
                    :data-row="rowIdx"
                    :data-col="45"
                    :id="`input-${rowIdx}-45`"
                    placeholder="请输入值"
                    style="flex: 1; min-width: 80px; width: 100%; box-sizing: border-box;">
                  </el-input>
                </div>
              </el-form-item>
            </td>
          </tr>
        </table>

        <table class="common-table-style4" border style="width:100%; border-collapse:collapse; table-layout: fixed;">
          <tr v-if="cols.length > 51">
            <td style="width: 50% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[49].ANLY_ITEM_NAME || '字段1'" :prop="cols[49].ANLY_ITEM_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[49].ANLY_ITEM_NO]"
                  @keydown.native="keyDown($event, rowIdx, 46)" 
                  :data-row="rowIdx"
                  :data-col="46"
                  :id="`input-${rowIdx}-46`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
            <td style="width: 50% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[50].ANLY_ITEM_NAME || '字段2'" :prop="cols[50].ANLY_ITEM_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[50].ANLY_ITEM_NO]"
                  @keydown.native="keyDown($event, rowIdx, 47)" 
                  :data-row="rowIdx"
                  :data-col="47"
                  :id="`input-${rowIdx}-47`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
          </tr>
          <tr v-if="cols.length > 53">
            <td style="width: 50% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[51].ANLY_ITEM_NAME || '字段1'" :prop="cols[51].ANLY_ITEM_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[51].ANLY_ITEM_NO]"
                  @keydown.native="keyDown($event, rowIdx, 48)" 
                  :data-row="rowIdx"
                  :data-col="48"
                  :id="`input-${rowIdx}-48`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
            <td style="width: 50% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[52].ANLY_ITEM_NAME || '字段2'" :prop="cols[52].ANLY_ITEM_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[52].ANLY_ITEM_NO]"
                  @keydown.native="keyDown($event, rowIdx, 49)" 
                  :data-row="rowIdx"
                  :data-col="49"
                  :id="`input-${rowIdx}-49`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
          </tr>
          <tr v-if="cols.length > 55">
            <td style="width: 50% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[53].ANLY_ITEM_NAME || '字段1'" :prop="cols[53].ANLY_ITEM_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[53].ANLY_ITEM_NO]"
                  @keydown.native="keyDown($event, rowIdx, 50)" 
                  :data-row="rowIdx"
                  :data-col="50"
                  :id="`input-${rowIdx}-50`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
            <td style="width: 50% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[54].ANLY_ITEM_NAME || '字段2'" :prop="cols[54].ANLY_ITEM_NO">
                <el-input 
                  size="mini" 
                  v-model="rowData[cols[54].ANLY_ITEM_NO]"
                  @keydown.native="keyDown($event, rowIdx, 51)" 
                  :data-row="rowIdx"
                  :data-col="51"
                  :id="`input-${rowIdx}-51`"
                  placeholder="请输入值">
                </el-input>
              </el-form-item>
            </td>
          </tr>
          <tr>
            <td colspan="2" style="width: 100% !important; padding: 8px; box-sizing: border-box;">
              <el-form-item :label="cols[55].ANLY_ITEM_NAME" :prop="cols[55].ANLY_ITEM_NO">
                <el-input 
                  type="textarea" 
                  :rows="4" 
                  size="small"
                  v-model="rowData[cols[55].ANLY_ITEM_NO]"  
                  @keydown.native="keyDown($event, rowIdx, 52)" 
                  :data-row="rowIdx"
                  :data-col="52"
                  :id="`input-${rowIdx}-52`"
                  placeholder="请输入备注">
                </el-input>
              </el-form-item>
            </td>
          </tr>
        </table>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  name: 'alertComponents2',
  props: {
    tableData: {
      type: Array,
      required: true,
      default: () => []
    },
    // selectRowList: { // 新增：接收父组件的选中数据
    //   type: Array,
    //   required: true,
    //   default: () => []
    // },
    cols: { // 列配置
      type: Array,
      required: true,
      default: () => []
    },
    theight4: {
      type: [Number, String],
      default: 400
    }
  },
  // watch: {
  //   selectRowList: {
  //     immediate: true, // 初始化时执行一次
  //     deep: true,
  //     handler(newVal) {
  //       if (newVal.length && this.cols.length) {
  //         this.tableData = this.formatTableData(newVal, this.cols);
  //       } else {
  //         this.tableData = []; // 无数据时清空
  //       }
  //     }
  //   },
  //   cols: {
  //     immediate: true,
  //     deep: true,
  //     handler() {
  //       if (this.selectRowList.length) {
  //         this.tableData = this.formatTableData(this.selectRowList, this.cols);
  //       }
  //     }
  //   }
  // },
  mounted() {
    console.log('子组件接收的tableData：', this.tableData);
    console.log('子组件接收的selectRowList：', this.selectRowList);
    console.log('子组件接收的cols：', this.cols);

    if (this.tableData.length > 0) {
      const firstRowKeys = Object.keys(this.tableData[0]);
      const colKeys = this.cols.map(col => col.ANLY_ITEM_NO || col.STUFF_NO).filter(Boolean);
      const unmatch = colKeys.filter(key => !firstRowKeys.includes(key));
      if (unmatch.length > 0) {
        console.warn('字段不匹配（需确保tableData包含这些字段）：', unmatch);
      }
    }
  },
  methods: {
    // formatTableData(selectRowList, cols) {
    //   return selectRowList.map(row => {
    //     const newRow = {};
    //     // 遍历cols，映射selectRowList的字段到tableData所需字段
    //     cols.forEach(col => {
    //       const key = col.ANLY_ITEM_NO || col.STUFF_NO; // tableData的目标字段名
    //       // 关键：映射规则（根据你的业务调整，以下是通用方案）
    //       // 方案1：selectRowList字段名与key一致 → 直接赋值
    //       newRow[key] = row[key] || ""; 
    //       // 方案2：selectRowList字段名与key不一致 → 手动映射（示例）
    //       // newRow[key] = row.原始字段名 || ""; 
    //     });
    //     return newRow;
    //   });
    // },
    keyDown(event, rowIdx, colIdx) {
      const isTextarea = event.target.tagName === 'TEXTAREA';
      if (event.key !== 'Enter' || isTextarea) return;

      event.preventDefault();
      event.stopPropagation();

      const getValidInputs = (targetRowIdx) => {
        const rowInputWrappers = Array.from(document.querySelectorAll(`[data-row="${targetRowIdx}"]`));
        const nativeInputs = rowInputWrappers.map(wrapper => {
          return wrapper.querySelector('input, textarea') || wrapper;
        }).filter(input => {
          return !input.disabled && 
                 !input.readOnly && 
                 input.style.display !== 'none' && 
                 input.offsetParent !== null;
        }).sort((a, b) => {
          const aCol = parseInt(a.dataset.col || 0);
          const bCol = parseInt(b.dataset.col || 0);
          return aCol - bCol;
        });

        return nativeInputs;
      };
      const currentRowInputs = getValidInputs(rowIdx);
      if (currentRowInputs.length === 0) return;

      const currentInput = event.target;
      const currentIndex = currentRowInputs.findIndex(input => input === currentInput);

      if (currentIndex === -1) return;

      this.$nextTick(() => {
        if (currentIndex < currentRowInputs.length - 1) {
          currentRowInputs[currentIndex + 1].focus();
          if (currentRowInputs[currentIndex + 1].tagName === 'INPUT') {
            currentRowInputs[currentIndex + 1].select();
          }
        } else {
          const nextRowIdx = rowIdx + 1;
          const nextRowInputs = getValidInputs(nextRowIdx);
          if (nextRowInputs.length > 0) {
            nextRowInputs[0].focus();
            if (nextRowInputs[0].tagName === 'INPUT') {
              nextRowInputs[0].select();
            }
          } else {
            currentRowInputs[0].focus();
            if (currentRowInputs[0].tagName === 'INPUT') {
              currentRowInputs[0].select();
            }
          }
        }
      });
    },
    handleInputChange(row, field, index) {
      this.$emit('data-change', row, field, index);
    }
  }
}
</script>

<style scoped>
.common-table-style4 {
  font-size: 14px;
  color: #666;
}

.common-table-style4 td {
  border: 1px solid #e6e6e6;
  padding: 8px;
}

/* 聚焦输入框高亮样式（可选） */
:deep(input:focus), :deep(textarea:focus) {
  border-color: #409eff;
  box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2);
  outline: none;
}
</style>