<template>
  <div>
    <layout>
      <layout-header>
        <div class="">
          <!--按钮部分-->
          <el-form ref="elSearchFormRef"  class="demo-form-inline" :rules="searchRule" @keyup.enter="onSubmit">
            <el-form-item>
              <el-input v-model="searchInfo"  placeholder="搜索工单编号、产品代号" style="width: 180px;"></el-input>
              <el-button type="primary" icon="search" @click="onSubmit" title="搜索"  ></el-button>
              <el-button type="primary" icon="edit"   @click="ontlssclick"       class="bt" title="按工序投料反馈，试算某产量的投料">U8投料试算</el-button>
              <el-button type="primary" icon="edit"   @click="onyycpzlclick"     class="bt" title="重新引用 产品资料！">引用产品资料</el-button>
              <el-button type="primary" icon="edit"   @click="oneditgxclhsclick" class="bt" title="工序产量核算">工序产量核算</el-button>
              <el-button type="primary" icon="edit"   @click="oneditgylctzclick" class="bt" title="根据实际生产需要，对工艺流程做调整">工艺流程调整</el-button>
              <el-button type="primary" icon="edit"   @click="oneditugdclick"    class="bt" title="删除U8工单异常数据">查改U8工单</el-button>
              <!--            <el-button type="primary" icon="edit"   @click="oneditztfwclick"   class="bt" title="初始化中间表更新状态，便于数据重新获取" disabled>状态复位</el-button>-->
              <el-button type="primary" icon="edit"   @click="onxzhscsclick"     class="bt" title="修正核算参数">修正核算参数</el-button>
              <el-button type="primary" icon="edit"   @click="onzjfpxsclick"     class="bt" title="批量调整质检废品系数">质检废品系数</el-button>
              <el-button type="primary" icon="edit"   @click="cp_gdprintonClick" class="bt" title="打印生产工单" >工单打印</el-button>
              <el-button type="primary" icon="edit"   @click="gd_gxclhconClick"  class="bt" title="工序产量核查">工序产量核查</el-button>
              <el-button type="primary" icon="edit"   @click="gdlcdcxconlick"    class="bt" title="流程单查询">流程单查询</el-button>
              <el-button type="primary" icon="edit"   @click="addgd_onclick"   class="bt" title="新增工单资料">新增工单资料</el-button>
              <el-button type="primary" icon="edit"   @click="addgdyj_onclick"   class="bt" title="新增印件资料">新增印件资料</el-button>
              <el-button type="primary" icon="edit"   @click="addgdgy_onclick"   class="bt" title="新增工艺资料" >新增工艺资料</el-button>
              <el-button type="primary" icon="edit"   @click="delgd_delclick"  :disabled="yjSelection === '' && gySelection === ''"  class="bt" title="选择批量删除（印件资料或工艺资料）"  >删除</el-button>
            </el-form-item>
          </el-form>

          <!--按钮弹窗部分-->
          <!--U8投料试算-->
          <el-dialog v-model="tlsslist"     title="U8投料试算"   style="height: 100%;width: 100%;margin: 0;padding: 0">
            <el-button type="primary" icon="" disabled @click="ontlssclicks" class="bt">投料试算</el-button>
            <el-button type="primary" icon="" disabled @click="onbxgxclicks" class="bt">备选工序</el-button>
            <el-button type="primary" icon="" disabled @click="onsjgxclicks" class="bt">实际工序</el-button>
            <el-button type="primary" icon="" @click="oncloneclick" style="margin: 5px">退出</el-button>
            <div style="width: 100%; height: 60px; padding: 0px; margin: 10px 0px 0px 0px; display: flex; align-items: center;">
              <!-- 第一行 -->
              <el-form-item class="mab" label="产品代码 :" prop="currentProcess">
                <el-input v-model="tlssformData['cpdh']" @keyup.enter="tlssgetProductValue" placeholder="" style="width: 200px;"/>
                <el-input v-model="tlssformData['cpmc']" disabled placeholder="" style="width: 700px;"/>
              </el-form-item>
            </div>
            <div style="display: flex; align-items: center; margin: 0px; padding: 0px;">
              <!-- 第二行 -->
              <el-form-item class="mab" label="成品张数 :" prop="currentProcess" style="margin-right: 10px;">
                <el-input disabled v-model="tlssformData['cpzs']" @keyup.enter="tlsscpzsgetProductValue" />
              </el-form-item>
              <el-form-item class="mab" label="主印投料大张数 :" prop="currentProcess" style="margin-right: 10px;">
                <el-input disabled v-model="tlssformData['zytldzs']" style="width: 130px;" />
              </el-form-item>
              <el-form-item class="mab" label="目标合格率 :" prop="currentProcess" style="margin-right: 10px;">
                <el-input disabled v-model="tlssformData['mbhgl']" style="width: 130px;" />
              </el-form-item>
              <el-form-item class="mab" label="损耗数 :" prop="currentProcess" style="margin-right: 10px;">
                <el-input disabled v-model="tlssformData['shs']" style="width: 130px;" />
              </el-form-item>
            </div>
            <el-table ref="multipleTable"
                      :show-overflow-tooltip="true"
                      :row-style="{ height: '0px' }"
                      :cell-style="{ padding: '0px' }" :header-row-style="{ height: '0px' }"
                      :header-cell-style="{ padding: '0px' }"
                      style="width: 100%;height: 65vh;" border tooltip-effect="dark"
                      :data="tlsstableData" row-key="ID" @selection-change="handleSelectionChange">
              <!--                    <el-table-column type="selection" width="55" />-->
              <el-table-column v-slot="scope" align="left" label=备选工序 width="100" >
                <el-input disabled :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=印件号 width="80" >
                <el-input disabled  v-model="scope.row.印件号" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=工序号 width="80" >
                <el-input disabled  v-model="scope.row.工序号" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=工序名称 width="390" >
                <el-input disabled  v-model="scope.row.工序名称" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=墨色数 width="100" >
                <el-input disabled  v-model="scope.row.墨色数" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=损耗代号 width="120" >
                <el-input disabled  v-model="scope.row.损耗代号" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=调机损耗 width="100" >
                <el-input disabled  v-model="scope.row.调机损耗" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=运行损耗率 width="120" >
                <el-input disabled  v-model="scope.row.运行损耗率" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=损耗系数 width="100" >
                <el-input disabled  v-model="scope.row.损耗系数" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=加工联数 width="100" >
                <el-input disabled  v-model="scope.row.加工联数" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=工序接货数 width="100" >
                <el-input disabled   :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=工序损耗 width="100" >
                <el-input disabled   :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=工序成品数 width="100" >
                <el-input disabled   :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=工序损耗率 width="100" >
                <el-input disabled  :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=产品代号 width="130" >
                <el-input disabled  v-model="scope.row.产品代号" :clearable="false"/>
              </el-table-column>
            </el-table>
          </el-dialog>

          <!--引用产品资料-->
          <el-dialog v-model="onyycpzllist" title="获取产品资料">
            <div style=" padding: 0px; align-items: center;">
              <el-form-item label="工单编号" prop="processName" class="mab">
                <el-input v-model="yycpzlformData['gdbh']" @keyup.enter="yycpzlProductValue" placeholder="" style="width: 23%;" />
              </el-form-item>
              <el-form-item label="客户代号" prop="processName" class="mab">
                <el-input v-model="yycpzlformData['khdh']" disabled  placeholder="" style="width: 23%;" />
                <el-input v-model="yycpzlformData['khmc']" disabled  placeholder="" style="width: 320px;" />
              </el-form-item>
              <el-form-item label="产品代号" prop="processName" class="mab" >
                <el-input v-model="yycpzlformData['cpdh']"  disabled placeholder="" style="width: 23%;" />
              </el-form-item>
              <el-form-item label="产品名称" prop="processName" class="mab" >
                <el-input v-model="yycpzlformData['cpmc']" disabled  placeholder="" style="width: 69%; height: 70px" type="textarea" resize="none" rows="2" :resize="false" />
              </el-form-item>
              <el-form-item label="创建选择" class="mab" >
                <el-checkbox disabled v-model="yycpzlformData['yjzl']">获取印件资料</el-checkbox>
                <el-checkbox disabled v-model="yycpzlformData['gyap']">获取工艺安排</el-checkbox>
              </el-form-item>
            </div>
            <!--          <template #footer>-->
            <!--            <div class="dialog-footer">-->
            <!--              <el-button @click="yycpzlhandleCancel">放弃</el-button>-->
            <!--              <el-button type="primary" @click="yycpzlhandleConfirm">执行</el-button>-->
            <!--            </div>-->
            <!--          </template>-->
            <div slot="footer" class="dialog-footer" style="text-align: right;margin-left: 25%">
              <el-button @click="yycpzlhandleCancel">放弃</el-button>
              <el-button type="primary" @click="yycpzlhandleConfirm">执行</el-button>
            </div>
          </el-dialog>

          <!--工序产量核算-->
          <el-dialog v-model="gxclhslist"   title="印件投料核算"  style="width: 20%;position: fixed; bottom: 35%; left: 35%">
            <div style="display: flex; flex-direction: column;  height: 100%;">
              <el-form-item label="工单编号:" prop="process" class="mab">
                <el-input v-model="gxclhsformData['gdbh']"  placeholder="" style="width: 160px;"/>
              </el-form-item>
              <div class="dialog-footer" style="margin-top: 20px; text-align: right ">
                <el-button @click="gxclhshandleCancel">取消</el-button>
                <el-button type="primary" disabled  @click="gxclhshandleConfirm">确定</el-button>
              </div>
            </div>
          </el-dialog>

          <!--工艺流程调整-->
          <el-dialog v-model="gylctzlist"   title="工艺方案附加"  style="width: 100%;height: 100%;margin: 0px;padding: 0px">
            <el-button type="primary"  @click="gylctz_gxdqcpgx" style="margin: 5px;">更新当前产品工序</el-button>
            <el-button type="primary"  @click="gylctz_fjbzgx" style="margin: 5px;">附加标准工序</el-button>

            <!--工艺流程调整中 附加标准工序-->
            <el-dialog v-model="gdzlfjxx" title="工单工艺流程附加选择"  style="width: 100%;height:100%;margin: 0">
              <el-button  type="primary" @click="addGongyiAttach" :disabled="attachList.length === 0">执行</el-button>
              <el-button  type="" @click="gylcfj_fangqi" >放弃</el-button>
              <div>
                <div style="width: 100%; height: 60px; padding: 0px; margin: 10px 0px 0px 0px; display: flex; align-items: center;">
                  <el-form-item label="产品代号 :" prop="currentProcess" class="mab">
                    <el-input v-model="gdzlfjxxformData['cpdh']" disabled placeholder="" style="width: 200px;"/>
                    <el-input v-model="gdzlfjxxformData['cpmc']" disabled placeholder="" style="width: 500px;margin-left: 20px"/>
                  </el-form-item>
                  <el-form-item label="工单编号:" prop="originalName"  class="mab" style="width: 200px;margin-left: 20px">
                    <el-select v-model="gdzlfjxxformData.cpgyfan" placeholder="请选择" allow-create filterable  >
                      <el-option v-for="option in gdzlfjxxformData.cpgyfans" @click="ongdzlfanclick" :key="option" :label="option" :value="option" />
                    </el-select>
                  </el-form-item>
                </div>
                <el-table ref="paichengRef"
                          :show-overflow-tooltip="true"
                          :row-style="{ height: '0px' }"
                          :cell-style="{ padding: '0px' }" :header-row-style="{ height: '0px' }"
                          :header-cell-style="{ padding: '0px' }"
                          style="width: 100%;height: 74vh" border tooltip-effect="dark"
                          :data="gdzlfjxxtableData" row-key="ID"
                          highlight-current-row="true" @selection-change="attachChange"
                          :cell-class-name="gdzlfjxxCellClass">
                  <el-table-column align="center" type="selection" width="30"/>
                  <template v-for="(item, idx) in gdzlfjxxtableColumns">
                    <el-table-column #default="{ row, column, $index }" align="left" :label="item.label" :width="item.width" >
                      <div v-if="[''].includes(item.prop)">
                        <el-input v-model="row[item.prop]" :clearable="false"
                                  :id="`input${idx}${$index}`" @keyup="gylctz_handleKeyDown($event, idx, $index, item.prop)"/>
                      </div>
                      <div v-else>{{ row[item.prop] }}</div>
                    </el-table-column>
                  </template>
                </el-table>
              </div>
            </el-dialog>

            <el-button type="primary" @click="gylctzhandleCancel" style="margin: 5px">放弃操作</el-button>
            <div>
              <div style="align-items: center;">
                <el-form-item label="当前工单:" prop="currentProcess" class="mab">
                  <el-input v-model="gylctzformData['gdbh']"  @keyup.enter="gylctzProductValue"  placeholder="" style="width: 160px;margin: 10px"/>
                  <el-input v-model="gylctzformData['gddh']"  disabled  placeholder="" style="width: 170px;margin-left: 10px;margin: 10px"/>
                  <el-input v-model="gylctzformData['gdmc']"  disabled  placeholder="" style="width: 340px;margin-left: 10px;margin: 10px"/>
                </el-form-item>
              </div>
              <el-table ref="paichengRef"
                        :show-overflow-tooltip="true"
                        :row-style="{ height: '0px' }"
                        :cell-style="{ padding: '0px' }" :header-row-style="{ height: '0px' }"
                        :header-cell-style="{ padding: '0px' }"
                        style="width: 100%;height: 74vh" border tooltip-effect="dark"
                        :data="gylctztableData" row-key="ID"
                        :cell-class-name="gylctzCellClass">
                <template v-for="(item, idx) in gylctztableColumns">
                  <el-table-column #default="{ row, column, $index }" align="left" :label="item.label" :width="item.width" >
                    <div v-if="['工序号'].includes(item.prop)">
                      <el-input v-model="row[item.prop]" :clearable="false"
                                :id="`input${idx}${$index}`" @keyup="gylctz_handleKeyDown($event, idx, $index, item.prop)"/>
                    </div>
                    <div v-else>{{ row[item.prop] }}</div>
                  </el-table-column>
                </template>
              </el-table>
            </div>
          </el-dialog>

          <!--查改U8工单-->
          <el-dialog v-model="cgugdlist"    title="查改U8工单"   style="width: 100%;height: 100%;margin: 0;padding: 0">
            <el-button type="primary"  icon=""  @click="oncgugdclickdel" :disabled="multipleSelection.length === 0" style="margin: 0px 0px 20px 0px">删除</el-button>
            <el-button type="primary"  icon="" @click="oncgugdcloneclick" style="margin: 0px 0px 20px 10px">退出</el-button>
            <div>
              <div style="width: 100%; padding: 0px; margin: 10px 0px 0px 0px; display: flex; align-items: center;margin: 0px 0px 20px 0px">
                <el-form-item label="当前工单:" prop="currentProcess" style="margin-right: 20px;padding: 0px">
                  <el-input v-model="cgugdformData['gdbh']"  @keyup.enter="cgugdProductValue"  placeholder="" style="width: 200px;"/>
                  <el-input v-model="cgugdformData['cpdh']"  disabled  placeholder="" style="width: 120px;margin-left: 10px"/>
                  <el-input v-model="cgugdformData['gdmc']"  disabled  placeholder="" style="width: 500px;margin-left: 10px"/>
                </el-form-item>
              </div>
              <el-table ref="multipleTable"
                        :show-overflow-tooltip="true"
                        :row-style="{ height: '20px' }"
                        :cell-style="{ padding: '0px' }"
                        :header-row-style="{ height: '20px' }"
                        :header-cell-style="{ padding: '0px' }"
                        highlight-current-row="true"
                        style="width: 100%; height: 74vh; margin: 0px;"
                        border tooltip-effect="dark"
                        :data="cgugdtableData" row-key="ID" @selection-change="cguzlgd_del">
                <el-table-column type="selection" width="55"/>
                <el-table-column align="left" label="工单编号" prop="工单编号" width="120"/>
                <el-table-column align="left" label="行号" prop="行号"/>
                <el-table-column align="left" label="客户代号" prop="客户代号"/>
                <el-table-column align="left" label="客户名称" prop="客户名称"/>
                <el-table-column align="left" label="成品代号" prop="成品代号"/>
                <el-table-column align="left" label="成品名称" prop="成品名称" width="340"/>
                <el-table-column align="left" label="获取日期" prop="获取日期"/>
                <el-table-column align="left" label="序号" prop="序号"/>
              </el-table>
            </div>
          </el-dialog>

          <!--修正核算参数-->
          <el-dialog v-model="xzhscslist"   title="修正核算参数"  style="width: 100%;height: 100%;margin: 0px;padding: 0px">
            <el-button type="primary"  @click="xzhscsConfirm">更新</el-button>
            <el-button type="" @click="sxzhscsCancel">退出</el-button>
            <div style="width: 100%; height: 60px; padding: 0px; margin: 10px 0px 0px 0px; display: flex; align-items: center;">
              <el-form-item label="当前工单 :" prop="currentProcess" style="margin-right: 20px; padding: 0px">
                <el-input v-model="xzhscsformData['gdbh']"
                          @keyup.enter="xzhscsgetProductValue"  style="width: 200px;"/>
                <el-input v-model="xzhscsformData['cpdh']"   disabled   style="width: 120px;margin-left: 10px;"/>
                <el-input v-model="xzhscsformData['gdmc']"   disabled   style="width: 500px;"/>
              </el-form-item>
            </div>
            <el-table ref="paichengRef"
                      :show-overflow-tooltip="true"
                      :row-style="{ height: '0px' }"
                      :cell-style="{ padding: '0px' }" :header-row-style="{ height: '0px' }"
                      :header-cell-style="{ padding: '0px' }"
                      style="width: 100%;height: 74vh" border tooltip-effect="dark"
                      :data="sxzhscstableData" row-key="ID"
                      :cell-class-name="sxzhscsCellClass">
              <template v-for="(item, idx) in xzhstableColumns">
                <el-table-column #default="{ row, column, $index }" align="left" :label="item.label" :width="item.width" >
                  <div v-if="['难度系数', '损耗代号', '印刷方式', '版距','计损色数', '损耗系数'].includes(item.prop)">
                    <el-input v-model="row[item.prop]" :clearable="false"
                              :id="`input${idx}${$index}`" @keyup="handleKeyDown($event, idx, $index, item.prop)"/>
                  </div>
                  <div v-else>{{ row[item.prop] }}</div>
                </el-table-column>
              </template>
            </el-table>
          </el-dialog>

          <!--质检废品系数-->
          <el-dialog v-model="scfjfpxslist" title="质检废品系数"  style="width: 100%;height: 100%;margin: 0px;padding: 0px">
            <el-button type="primary"  @click="scfjfpxsConfirm">更新</el-button>
            <el-button type="" @click="scfjfpxsCancel">退出</el-button>
            <div style="width: 100%; height: 60px; padding: 0px; margin: 10px 0px 0px 0px; display: flex; align-items: center;">
              <el-form-item label="关键字 :" prop="currentProcess" style="margin-right: 20px; padding: 0px">
                <el-input v-model="scfjfpxsformData['cpdh']"
                          @keyup.enter="scfjfpxsgetProductValue" placeholder="" style="width: 200px;"/>
              </el-form-item>
            </div>
            <el-table ref="paichengRef"
                      :show-overflow-tooltip="true"
                      :row-style="{ height: '0px' }"
                      :cell-style="{ padding: '0px' }" :header-row-style="{ height: '0px' }"
                      :header-cell-style="{ padding: '0px' }"
                      style="width: 100%;height: 74vh" border tooltip-effect="dark"
                      :data="scfjfpxstableData" row-key="ID"
                      :cell-class-name="scfjfpxsCellClass">
              <template v-for="(item, idx) in zjfpxs_tableColumns">
                <el-table-column #default="{ row, column, $index }" align="left" :label="item.label" :width="item.width" >
                  <div v-if="['人工正品板', '人工次品板', '人工废检', '机检正品板','机检次品板', '机检废检'].includes(item.prop)">
                    <el-input v-model="row[item.prop]" :clearable="false"
                              :id="`input${idx}${$index}`" @keyup="zjfpxs_handleKeyDown($event, idx, $index, item.prop)"/>
                  </div>
                  <div v-else>{{ row[item.prop] }}</div>
                </el-table-column>
              </template>
            </el-table>
          </el-dialog>

          <!--工序产量核查【弹窗】-->
          <el-dialog v-model="gd_gxclhclist" title="工序产量核查" style="width: 100%;height: 100%;margin: 0px;padding: 0px">
            <el-button type="" @click="gxclhcCancel">退出</el-button>
            <div style="width: 100%; height: 60px; padding: 0px; margin: 10px 0px 0px 0px; display: flex; align-items: center;">
              <div style="width: 100%; height: 60px; padding: 0px;  display: flex; align-items: center;">
                <el-form-item label="工单编号" prop="currentProcess" style="margin-right: 20px; padding: 0px">
                  <el-input v-model="gxclhcformData['gdbh']"  @keyup.enter="gxclhcProductValue" placeholder="" />
                </el-form-item>
              </div>
            </div>
            <el-table ref="paichengRef"
                      :show-overflow-tooltip="true"
                      :row-style="{ height: '0px' }"
                      :cell-style="{ padding: '0px' }" :header-row-style="{ height: '0px' }"
                      :header-cell-style="{ padding: '0px' }"
                      style="width: 100%;height: 70vh" border tooltip-effect="dark"
                      highlight-current-row="true"
                      @row-click="gxclhc_tableRowClick"
                      :data="gxclhc_Data" row-key="ID"
                      :cell-class-name="gxclhcCellClass">
              <template v-for="(item, idx) in gxclhc_Columns">
                <el-table-column #default="{ row, column, $index }" align="left" :label="item.label" :width="item.width" >
                  {{row[item.prop]}}
                </el-table-column>
              </template>
            </el-table>
          </el-dialog>

          <!--流程单查询【弹窗】-->
          <el-dialog v-model="gd_lcdlist" title="工单工序生产进程" style="width: 100%;height: 100%;margin: 0px;padding: 0px;">
            <div style="width: 100%;height: 100%;">
              <el-button type="" @click="gd_lcdCancel">退出</el-button>
            </div>
            <div style="width: 100%; height: 100%; display: flex; align-items: center;">
              <el-form-item label="工单编号" style="margin-right: 20px; padding: 0;">
                <el-input v-model="gd_lcdformData['gdbh']" @keyup.enter="gd_lcdProductValue"/>
              </el-form-item>
              <el-form-item label="" style="margin-right: 5px; padding: 0;">
                <el-input v-model="gd_lcdformData['code']" disabled/>
              </el-form-item>
              <el-form-item label="" style="margin-right: 5px; padding: 0;">
                <el-input v-model="gd_lcdformData['name']" disabled style="width: 500px"/>
              </el-form-item>
            </div>
            <div style="width: 100%; height: 70vh; display: flex;">
              <layout>
                <layout-sider :resize-directions="['right']" :width="240" style="margin-right: 10px;height: 70vh;">
                  <div class="JKWTree-tree">
                    <el-tree :data="lcd_treeData" @node-click="lcd_handleNodeClick" default-expand-all></el-tree>
                  </div>
                </layout-sider>
                <layout-main>
                  <!-- 这里放右侧的内容 -->
                  <el-space wrap>
                    <!-- 右侧内容 -->
                    <template v-for="item in processList.total_process">
                      <el-button disabled :type="! processList.process.includes(item) ? 'danger' : 'info'" plain style="width: 50px">{{ item }}</el-button>
                    </template>
                  </el-space>
                </layout-main>
              </layout>
            </div>
          </el-dialog>

        </div>

      </layout-header>
      <layout>
        <!-- 左侧树形结构 -->
        <layout-sider :resize-directions="['right']" :width="190" style="margin-right: 10px;">
          <div class="JKWTree-tree" style="height: 200px">
            <h3>工单管理</h3>
            <el-tree :data="treeData.data"  @node-click="handleNodeClick"></el-tree>
          </div>
        </layout-sider>

        <!-- 右侧内容区域 -->
        <layout-content >
          <el-main>
            <!-- 工单表格列表 -->
            <div class="gva-table-box">
              <el-table ref="multipleTable"
                        style="width: 100%;height: 28vh"
                        :row-style="{ height: '20px' }"
                        :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
                        :header-cell-style="{ padding: '0px' }"
                        border
                        tooltip-effect="dark"
                        :data="tableData" row-key="ID"
                        @row-click="tableRowClick"
                        highlight-current-row="true"
                        :cell-class-name="tableDataCellClass"
                        @row-dblclick="updateCompanyFunc"
                        @selection-change="handleSelectionChange"
                        :show-overflow-tooltip="true">
<!--                <el-table-column align="center" type="selection" width="30"/>-->
                <el-table-column align="left" label="获取状态"   prop="status"  width="81" />
                <el-table-column align="left" label="工单编号"   prop="工单编号"  width="81" />
                <el-table-column align="left" label="生产分类"   prop="生产分类" width="81" />
                <el-table-column align="left" label="销售订单号" prop="销售订单号" width="100" />
                <el-table-column align="left" label="产品代号"   prop="产品代号"  width="99" />
                <el-table-column align="left" label="产品名称"   prop="产品名称" width="370" />
                <el-table-column align="left" label="订单数量"   prop="订单数量" width="100" />
                <el-table-column align="left" label="单位"       prop="单位"   width="54"/>
                <el-table-column align="left" label="折合大箱"   prop="折合大箱" width="81" />
                <el-table-column align="left" label="投料率"     prop="投料率" width="80" />
                <el-table-column align="left" label="平均合格率"  prop="平均合格率" width="95" />
                <el-table-column align="left" label="开单日期"    prop="开单日期" width="98" />
                <el-table-column align="left" label="交货日期"    prop="交货日期" width="98" />
                <el-table-column align="left" label="工单类型"    prop="工单类型" width="98" />
                <el-table-column align="left" label="工单状态"    prop="工单状态" width="85" />
                <el-table-column align="left" label="当前生产工序" prop="当前生产工序" width="110" />
                <el-table-column align="left" label="产量提交时间" prop="产量提交时间" width="110" />
                <el-table-column align="left" label="建档用户"    prop="建档用户" width="130" />
                <el-table-column align="left" label="建档时间"    prop="建档时间" width="115" />
                <el-table-column align="left" label="更新时间"    prop="更新时间" width="160" />
              </el-table>
              <!-- 分页 -->
              <div class="gva-pagination">
                <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="page"
                    :page-sizes="[10, 30, 50, 100]"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="total">
                </el-pagination>
              </div>
            </div>

            <!--  印件资料、工艺资料、BOM资料列表  -->
            <el-tabs v-model="activeName" @tab-click="handleClick">
              <el-tab-pane label="印件资料"  @click="showTable('印件资料')"  name="first">
                <el-table ref="multipleTable"
                          :row-style="{ height: '20px' }"
                          :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
                          :header-cell-style="{ padding: '0px' }"
                          :show-overflow-tooltip="true"
                          highlight-current-row="true"
                          @row-dblclick="gdyjupdateCompanyFunc"
                          @selection-change="selectionChange($event, '印件资料')"
                          style="width: 100%;height: 36vh" border tooltip-effect="dark" :data="yjtableData" row-key="ID">
                  <el-table-column type="selection" width="30" />
                  <el-table-column align="left" label="印件号" prop="印件号"  width="70"/>
                  <el-table-column align="left" label="印件代号" prop="印件代号"  width="98"/>
                  <el-table-column align="left" label="印件名称" prop="印件名称"  width="340"/>
                  <el-table-column align="left" label="纸张代号" prop="纸张代号"  width="98"/>
                  <el-table-column align="left" label="纸张名称" prop="纸张名称"  width="340"/>
                  <el-table-column align="left" label="投料规格" prop="投料规格"  width="90"/>
                  <el-table-column align="left" label="平张投料" prop="平张投料"  width="90"/>
                  <el-table-column align="left" label="开料规格" prop="开料规格"  width="90"/>
                  <el-table-column align="left" label="开数*联数" prop="开数*联数"  width="90"/>
                  <el-table-column align="left" label="建档用户" prop="建档用户"  width="100"/>
                  <el-table-column align="left" label="建档时间" prop="建档时间"  width="160"/>
                  <el-table-column align="left" label="更新时间" prop="更新时间"  width="160"/>
                </el-table>
              </el-tab-pane>

              <el-tab-pane label="工艺资料" @click="showTable('工艺资料')" name="second">
                <el-table ref="multipleTable"
                          :row-style="{ height: '20px' }"
                          :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
                          :header-cell-style="{ padding: '0px' }"
                          highlight-current-row="true"
                          :show-overflow-tooltip="true"
                          size="small"
                          :cell-class-name="gysatusCellClass"
                          @row-dblclick="gdgyupdateCompanyFunc"
                          @row-click="clickybupdate2"
                          :row-class-name="rowClassStyle2"
                          @selection-change="selectionChange($event, '工艺资料')"
                          style="width: 100%;height: 36vh" border tooltip-effect="dark" :data="gytableData" row-key="ID">
                  <el-table-column type="selection" width="30" />
                  <el-table-column align="left" label="完工状态" prop="status"  width="75"/>
                  <el-table-column align="left" label="重点工序" prop="重点工序"  width="80"/>
                  <el-table-column align="left" label="印件-工序" prop="印件-工序"  width="80"/>
                  <el-table-column align="left" label="备选工序" prop="备选工序"  width="80"/>
                  <el-table-column align="left" label="工序名称" prop="工序名称"  width="280"/>
                  <el-table-column align="left" label="计划产量" prop="计划产量"  width="80"/>
                  <el-table-column align="left" label="基础损耗" prop="基础损耗"  width="80"/>
                  <el-table-column align="left" label="报废定额" prop="报废定额"  width="80"/>
                  <el-table-column align="left" label="允损比例" prop="允损比例"  width="80"/>
                  <el-table-column align="left" label="难度系数" prop="难度系数"  width="80"/>
                  <el-table-column align="left" label="损耗系数" prop="损耗系数"  width="80"/>
                  <el-table-column align="left" label="人工检_次品板" prop="人工检_次品板"  width="110"/>
                  <el-table-column align="left" label="人工检_废检" prop="人工检_废检"  width="110"/>
                  <el-table-column align="left" label="机检_正品板" prop="机检_正品板"  width="110"/>
                  <el-table-column align="left" label="机检_次品板" prop="机检_次品板"  width="110"/>
                  <el-table-column align="left" label="机检_废检" prop="机检_废检"  width="90"/>
                  <!--<el-table-column align="left" label="开数*联数" prop="开数*联数"  width="100"/>-->
                  <el-table-column align="center" label="开数" prop="开数"  width="45"/>
                  <el-table-column align="center" label="联数" prop="联数"  width="45"/>
                  <el-table-column align="left" label="备注" prop="备注"  width="230"/>
                  <el-table-column align="left" label="印刷方式" prop="印刷方式"  width="80"/>
                  <el-table-column align="center" label="版距" prop="版距"  width="45"/>
                  <el-table-column align="left" label="建档用户" prop="建档用户"  width="90"/>
                  <el-table-column align="left" label="建档日期" prop="建档日期"  width="150"/>
                  <el-table-column align="left" label="更新时间" prop="更新时间"  width="150"/>
                  <el-table-column align="left" label="更新时间" prop="更新时间"  width="150"/>
                </el-table>
              </el-tab-pane>

              <el-tab-pane label="BOM资料" @click="showTable('BOM资料')" name="third">
                <el-table ref="multipleTable"
                          :row-style="{ height: '20px' }"
                          :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
                          :header-cell-style="{ padding: '0px' }"
                          :show-overflow-tooltip="true"
                          :cell-class-name="planUsageCellClass"
                          highlight-current-row="true"
                          @row-dblclick="gdbomupdateCompanyFunc"
                          style="width: 100%;height: 36vh" border tooltip-effect="dark" :data="bomtableData" row-key="ID" @selection-change="handleSelectionChange">
<!--                  <el-table-column type="selection" width="30" />-->
                  <el-table-column align="left" label="方案" prop="方案"  width="120"/>
                  <el-table-column align="left" label="物料编号" prop="物料编号"  width="100"/>
                  <el-table-column align="left" label="物料名称" prop="物料名称"  width="400"/>
                  <el-table-column align="left" label="消耗定量" prop="消耗定量"  width="210"/>
                  <el-table-column align="left" label="计划用量" prop="计划用量"  width="100" />
                  <el-table-column align="left" label="建档用户" prop="建档用户"  width="120"/>
                  <el-table-column align="left" label="建档时间" prop="建档时间"  width="160"/>
                  <el-table-column align="left" label="更新时间" prop="更新时间"  width="160"/>
                </el-table>
              </el-tab-pane>
            </el-tabs>

            <!-- 修改工单资料弹窗 -->
            <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" style="width: 55%;margin: 50px auto" :title="'修改工单资料'" destroy-on-close>
              <el-row>
                <el-form :model="scgdformData" label-position="right" ref="elFormRef" :rules="rule" >
                  <el-row :gutter="24">
                    <el-form-item label="重点工单:" prop="keyOrder" class="mab" label-width="90">
                      <el-select v-model="add_gdscgdformData['重点工单']" style="width: 110px;" id="重点工单" @keydown="add_gdzlent($event, '备注', '重点工单', '开单日期')">
                        <el-option label="" value=""></el-option>
                        <el-option label="打样工单" value="打样工单"></el-option>
                        <el-option label="来料加工" value="来料加工"></el-option>
                        <el-option label="新产品工单" value="新产品工单"></el-option>
                        <el-option label="异常工单" value="异常工单"></el-option>
                        <el-option label="客诉工单" value="客诉工单"></el-option>
                        <el-option label="中试工单" value="中试工单"></el-option>
                        <el-option label="大试工单" value="大试工单"></el-option>
                        <el-option label="补数工单" value="补数工单"></el-option>
                        <el-option label="试机工单" value="试机工单"></el-option>
                        <el-option label="打样工单" value="打样工单"></el-option>
                        <el-option label="外发加工" value="外发加工"></el-option>
                        <el-option label="新华订单" value="新华订单"></el-option>
                        <el-option label="研发打样" value="研发打样"></el-option>
                        <el-option label="废码利用" value="废码利用"></el-option>
                      </el-select>
                      <!--                      <el-input v-model="scgdformData['重点工单']"  style="width: 110px;"  id="重点工单"  @keydown="gdzlent($event, '备注', '重点工单', '开单日期')" />-->
                    </el-form-item>
                    <el-form-item label="开单日期" prop="orderDate" class="mab" label-width="70">
                      <el-date-picker v-model="scgdformData['开单日期']" type="date"  style="width: 140px;" id="开单日期"  @keydown="gdzlent($event, '重点工单', '开单日期', '工单编号')" />
                    </el-form-item>
                    <el-form-item label="工单编号:" prop="orderNumber" class="mab" label-width="90">
                      <el-input v-model="scgdformData['工单编号']"  style="width: 80px;" id="工单编号"  @keydown="gdzlent($event, '开单日期', '工单编号', '生产类型')" />
                    </el-form-item>
                    <el-form-item label="生产类型:" prop="productionType" class="mab" label-width="90">
                      <el-select v-model="add_gdscgdformData['生产类型']" style="width: 100px;" id="生产类型" @keydown="add_gdzlent($event, '工单编号', '生产类型', '客户代号')">
                        <el-option label="" value=""></el-option>
                        <el-option label="备货" value="备货"></el-option>
                        <el-option label="面彩" value="面彩"></el-option>
                      </el-select>
                      <!--                      <el-input v-model="scgdformData['生产类型']" style="width: 100px;"  id="生产类型"  @keydown="gdzlent($event, '工单编号', '生产类型', '客户代号')" />-->
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="24">
                    <el-form-item label="客户代号:" prop="customerCode" class="mab" label-width="90">
                      <el-input v-model="scgdformData['客户代号']" style="width: 110px;" id="客户代号"  @keydown="gdzlent($event, '生产类型', '客户代号', '客户名称')"/>
                    </el-form-item>
                    <el-form-item label="客户名称:" prop="customerName" class="mab" label-width="75">
                      <el-input v-model="scgdformData['客户名称']" style="width: 520px;" id="客户名称"  @keydown="gdzlent($event, '客户代号', '客户名称', '产品代号')"/>
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="24">
                    <el-form-item label="产品代码:" prop="productCode" class="mab" label-width="90">
                      <el-input v-model="scgdformData['产品代号']" style="width: 110px;" id="产品代号"  @keydown="gdzlent($event, '客户名称', '产品代号', '产品名称')"/>
                    </el-form-item>
                    <el-form-item label="产品名称:" prop="productName" class="mab" label-width="75">
                      <el-input v-model="scgdformData['产品名称']" style="width: 520px;"  id="产品名称"  @keydown="gdzlent($event, '产品代号', '产品名称', '印件代号')" />
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="24">
                    <el-form-item label="印件代码:" prop="customerCode" class="mab" label-width="90">
                      <el-input v-model="scgdformData['印件代号']"   style="width: 110px;" id="印件代号"  @keydown="gdzlent($event, '产品名称', '印件代号', '印件名称')"/>
                    </el-form-item>
                    <el-form-item label="印件名称:" prop="customerName" class="mab" label-width="75">
                      <el-input v-model="scgdformData['印件名称']"  id="印件名称" style="width: 520px;"  @keydown="gdzlent($event, '印件代号', '印件名称', '订单数量')"  />
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="24">
                    <el-form-item label="订单数量:" prop="orderQuantity" class="mab" label-width="90">
                      <el-input v-model="scgdformData['订单数量']"   style="width: 110px;" id="订单数量"  @keydown="gdzlent($event, '印件名称', '订单数量', '交货日期')" />
                    </el-form-item>
                    <el-form-item label="交货日期:" prop="deliveryDate" class="mab" label-width="75">
                      <el-date-picker v-model="scgdformData['交货日期']" type="date"  style="width: 140px;"  id="交货日期"  @keydown="gdzlent($event, '订单数量', '交货日期', '投料率')"/>
                    </el-form-item>
                    <el-form-item label="投料率:" prop="feedRate" class="mab" label-width="75">
                      <el-input v-model="scgdformData['投料率']"   style="width: 90px;"  id="投料率"  @keydown="gdzlent($event, '交货日期', '投料率', '平均合格率')"/>
                    </el-form-item>
                    <el-form-item label="平均合格率:" prop="passRate" class="mab" label-width="90">
                      <el-input v-model="scgdformData['平均合格率']"   style="width: 125px;"  id="平均合格率"  @keydown="gdzlent($event, '投料率', '平均合格率', '平张投料')"/>
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="24">
                    <el-form-item label="平张投料:" prop="flatFeed" class="mab" label-width="90">
                      <el-input v-model="scgdformData['平张投料']"  style="width: 110px;"  id="平张投料"  @keydown="gdzlent($event, '平均合格率', '平张投料', '万小张')"/>
                    </el-form-item>
                    <el-form-item label="万小张:" prop="perTenThousand" class="mab" label-width="70">
                      <el-input v-model="scgdformData['万小张']"   style="width: 95px;"  id="万小张"  @keydown="gdzlent($event, '平张投料', '万小张', '单位')"/>
                      <el-input v-model="scgdformData['单位']"   style="width: 50px;"  id="单位"  @keydown="gdzlent($event, '万小张', '单位', '投料大箱')"/>
                    </el-form-item>
                    <el-form-item label="投料大箱:" prop="feedBox" class="mab" label-width="75">
                      <el-input v-model="scgdformData['投料大箱']"  style="width: 90px;"  id="投料大箱"  @keydown="gdzlent($event, '单位', '投料大箱', '库存大箱')"/>
                    </el-form-item>
                    <el-form-item label="库存大箱:" prop="stockBox" class="mab" label-width="80">
                      <el-input v-model="scgdformData['库存大箱']"   style="width: 135px;"  id="库存大箱"  @keydown="gdzlent($event, '投料大箱', '库存大箱', '销售订单号')"/>
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="20">
                    <el-form-item label="销售订单号:" prop="salesOrder" class="mab" label-width="90">
                      <el-input v-model="scgdformData['销售订单号']"  style="width: 700px;"   id="销售订单号"  @keydown="gdzlent($event, '库存大箱', '销售订单号', '警语版面')"/>
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="20">
                    <el-form-item label="警语版面:" prop="warningLayout" class="mab" label-width="90">
                      <el-input v-model="scgdformData['警语版面']"  style="width: 700px;"    id="警语版面"  @keydown="gdzlent($event, '销售订单号', '警语版面', '版本号')"/>
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="20">
                    <el-form-item label="版本号:" prop="versionNumber" class="mab" label-width="90">
                      <el-input v-model="scgdformData['版本号']"   id="版本号" style="width: 180px;"  @keydown="gdzlent($event, '警语版面', '版本号', '客户ERP编码')" />
                    </el-form-item>
                    <el-form-item label="客户ERP编码:" prop="customerErpCode" class="mab" label-width="120">
                      <el-input v-model="scgdformData['客户ERP编码']"   style="width: 400px;"  id="客户ERP编码"  @keydown="gdzlent($event, '版本号', '客户ERP编码', '码源数量')"/>
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="20">
                    <el-form-item label="码源数量:" prop="codeSourceQuantity" class="mab" label-width="90">
                      <el-input v-model="scgdformData['码源数量']" style="width: 180px;"  id="码源数量"  @keydown="gdzlent($event, '客户ERP编码', '码源数量', '进程备注')" />
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="20">
                    <el-form-item label="进程备注:" prop="processNote" class="mab" label-width="90">
                      <el-input v-model="scgdformData['进程备注']"  style="width: 700px;"  id="进程备注"  @keydown="gdzlent($event, '码源数量', '进程备注', '备注')"/>
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="20">
                    <el-form-item label="备注说明:" prop="remark" class="mab" label-width="90">
                      <el-input type="textarea" v-model="scgdformData['备注']" :rows="2" :clearable="true" style="width: 700px;" resize="none"  id="备注"  @keydown="gdzlent($event, '进程备注', '备注', '重点工单')"/>
                    </el-form-item>
                  </el-row>
                </el-form>
              </el-row>
              <template #footer>
                <div class="dialog-footer" style="text-align: right;">
                  <el-button @click="closeDialog">取 消</el-button>
                  <el-button type="primary"  @click="enterDialog">确 定</el-button>
                </div>
              </template>

            </el-dialog>

            <!-- 新增工单资料弹窗 -->
            <el-dialog v-model="add_gddialogFormVisible" :before-close="add_gdcloseDialog"  style="width: 55%;margin: 50px auto" :title="'新增工单资料'" destroy-on-close>
              <el-row>
                <el-form :model="add_gdscgdformData" label-position="right" ref="elFormRef" :rules="rule" >
                  <!-- 第一排 -->
                  <el-row :gutter="24">
                    <el-form-item label="重点工单:" prop="keyOrder" class="mab" label-width="90">
                      <el-select v-model="add_gdscgdformData['重点工单']" style="width: 110px;" id="重点工单" @keydown="add_gdzlent($event, '备注', '重点工单', '开单日期')">
                        <el-option label="" value=""></el-option>
                        <el-option label="打样工单" value="打样工单"></el-option>
                        <el-option label="来料加工" value="来料加工"></el-option>
                        <el-option label="新产品工单" value="新产品工单"></el-option>
                        <el-option label="异常工单" value="异常工单"></el-option>
                        <el-option label="客诉工单" value="客诉工单"></el-option>
                        <el-option label="中试工单" value="中试工单"></el-option>
                        <el-option label="大试工单" value="大试工单"></el-option>
                        <el-option label="补数工单" value="补数工单"></el-option>
                        <el-option label="试机工单" value="试机工单"></el-option>
                        <el-option label="打样工单" value="打样工单"></el-option>
                        <el-option label="外发加工" value="外发加工"></el-option>
                        <el-option label="新华订单" value="新华订单"></el-option>
                        <el-option label="研发打样" value="研发打样"></el-option>
                        <el-option label="废码利用" value="废码利用"></el-option>
                      </el-select>
                      <!--                      <el-input v-model="add_gdscgdformData['重点工单']"  style="width: 110px;"  id="重点工单"  @keydown="add_gdzlent($event, '备注', '重点工单', '开单日期')" />-->
                    </el-form-item>
                    <el-form-item label="开单日期" prop="orderDate" class="mab" label-width="70">
                      <el-date-picker v-model="add_gdscgdformData['开单日期']" type="date"  style="width: 140px;"   id="开单日期"  @keydown="add_gdzlent($event, '重点工单', '开单日期', '工单编号')" />
                    </el-form-item>
                    <el-form-item label="工单编号:" prop="orderNumber" class="mab" label-width="90">
                      <el-input v-model="add_gdscgdformData['工单编号']"  style="width: 85px;" id="工单编号"  @keydown="add_gdzlent($event, '开单日期', '工单编号', '生产类型')" />
                    </el-form-item>
                    <el-form-item label="生产类型:" prop="productionType" class="mab" label-width="90">
                      <el-select v-model="add_gdscgdformData['生产类型']" style="width: 100px;" id="生产类型" @keydown="add_gdzlent($event, '工单编号', '生产类型', '客户代号')">
                        <el-option label="" value=""></el-option>
                        <el-option label="备货" value="备货"></el-option>
                        <el-option label="面彩" value="面彩"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="24">
                    <el-form-item label="客户代号:" prop="customerCode" class="mab" label-width="90">
                      <el-input v-model="add_gdscgdformData['客户代号']" style="width: 110px;" id="客户代号"  @keydown="add_gdzlent($event, '生产类型', '客户代号', '客户名称')"/>
                    </el-form-item>
                    <el-form-item label="客户名称:" prop="customerName" class="mab" label-width="75">
                      <el-input v-model="add_gdscgdformData['客户名称']" style="width: 520px;" id="客户名称"  @keydown="add_gdzlent($event, '客户代号', '客户名称', '产品代号')"/>
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="24">
                    <el-form-item label="产品代码:" prop="productCode" class="mab" label-width="90">
                      <el-input v-model="add_gdscgdformData['产品代号']" style="width: 110px;" id="产品代号"  @keydown="add_gdzlent($event, '客户名称', '产品代号', '产品名称')"/>
                    </el-form-item>
                    <el-form-item label="产品名称:" prop="productName" class="mab" label-width="75">
                      <el-input v-model="add_gdscgdformData['产品名称']" style="width: 520px;"  id="产品名称"  @keydown="add_gdzlent($event, '产品代号', '产品名称', '印件代号')" />
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="24">
                    <el-form-item label="印件代码:" prop="customerCode" class="mab" label-width="90">
                      <el-input v-model="add_gdscgdformData['印件代号']" disabled  style="width: 110px;" id="印件代号"  @keydown="add_gdzlent($event, '产品名称', '印件代号', '印件名称')"/>
                    </el-form-item>
                    <el-form-item label="印件名称:" prop="customerName" class="mab" label-width="75">
                      <el-input v-model="add_gdscgdformData['印件名称']" disabled id="印件名称" style="width: 520px;"  @keydown="add_gdzlent($event, '印件代号', '印件名称', '订单数量')"  />
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="24">
                    <el-form-item label="订单数量:" prop="orderQuantity" class="mab" label-width="90">
                      <el-input v-model="add_gdscgdformData['订单数量']"   style="width: 110px;" id="订单数量"  @keydown="add_gdzlent($event, '印件名称', '订单数量', '交货日期')" />
                    </el-form-item>
                    <el-form-item label="交货日期:" prop="deliveryDate" class="mab" label-width="75">
                      <el-date-picker v-model="add_gdscgdformData['交货日期']" type="date"  style="width: 140px;"  id="交货日期"  @keydown="add_gdzlent($event, '订单数量', '交货日期', '投料率')"/>
                    </el-form-item>
                    <el-form-item label="投料率:" prop="feedRate" class="mab" label-width="75">
                      <el-input v-model="add_gdscgdformData['投料率']"   style="width: 90px;"  id="投料率"  @keydown="add_gdzlent($event, '交货日期', '投料率', '平均合格率')"/>
                    </el-form-item>
                    <el-form-item label="平均合格率:" prop="passRate" class="mab" label-width="90">
                      <el-input v-model="add_gdscgdformData['平均合格率']"   style="width: 125px;"  id="平均合格率"  @keydown="add_gdzlent($event, '投料率', '平均合格率', '平张投料')"/>
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="24">
                    <el-form-item label="平张投料:" prop="flatFeed" class="mab" label-width="90">
                      <el-input v-model="add_gdscgdformData['平张投料']"  style="width: 110px;"  id="平张投料"  @keydown="add_gdzlent($event, '平均合格率', '平张投料', '投料大箱')"/>
                    </el-form-item>
                    <el-form-item label="万小张:" prop="perTenThousand" class="mab" label-width="70">
                      <el-input v-model="add_gdscgdformData['万小张']" disabled   style="width: 95px;"  id="万小张"  />
                      <el-input v-model="add_gdscgdformData['单位']"  disabled style="width: 50px;"  id="单位"/>
                    </el-form-item>
                    <el-form-item label="投料大箱:" prop="feedBox" class="mab" label-width="75">
                      <el-input v-model="add_gdscgdformData['投料大箱']"  style="width: 90px;"  id="投料大箱"  @keydown="add_gdzlent($event, '平张投料', '投料大箱', '库存大箱')"/>
                    </el-form-item>
                    <el-form-item label="库存大箱:" prop="stockBox" class="mab" label-width="80">
                      <el-input v-model="add_gdscgdformData['库存大箱']"   style="width: 135px;"  id="库存大箱"  @keydown="add_gdzlent($event, '投料大箱', '库存大箱', '销售订单号')"/>
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="20">
                    <el-form-item label="销售订单号:" prop="salesOrder" class="mab" label-width="90">
                      <el-input v-model="add_gdscgdformData['销售订单号']"  style="width: 700px;"   id="销售订单号"  @keydown="add_gdzlent($event, '库存大箱', '销售订单号', '警语版面')"/>
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="20">
                    <el-form-item label="警语版面:" prop="warningLayout" class="mab" label-width="90">
                      <el-input v-model="add_gdscgdformData['警语版面']"  style="width: 700px;"    id="警语版面"  @keydown="add_gdzlent($event, '销售订单号', '警语版面', '版本号')"/>
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="20">
                    <el-form-item label="版本号:" prop="versionNumber" class="mab" label-width="90">
                      <el-input v-model="add_gdscgdformData['版本号']"   id="版本号" style="width: 180px;"  @keydown="add_gdzlent($event, '警语版面', '版本号', '客户ERP编码')" />
                    </el-form-item>
                    <el-form-item label="客户ERP编码:" prop="customerErpCode" class="mab" label-width="120">
                      <el-input v-model="add_gdscgdformData['客户ERP编码']"   style="width: 400px;"  id="客户ERP编码"  @keydown="add_gdzlent($event, '版本号', '客户ERP编码', '码源数量')"/>
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="20">
                    <el-form-item label="码源数量:" prop="codeSourceQuantity" class="mab" label-width="90">
                      <el-input v-model="add_gdscgdformData['码源数量']" style="width: 180px;"  id="码源数量"  @keydown="add_gdzlent($event, '客户ERP编码', '码源数量', '进程备注')" />
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="20">
                    <el-form-item label="进程备注:" prop="processNote" class="mab" label-width="90">
                      <el-input v-model="add_gdscgdformData['进程备注']"  style="width: 700px;"  id="进程备注"  @keydown="add_gdzlent($event, '码源数量', '进程备注', '备注')"/>
                    </el-form-item>
                  </el-row>
                  <el-row :gutter="20">
                    <el-form-item label="备注说明:" prop="remark" class="mab" label-width="90">
                      <el-input type="textarea" v-model="add_gdscgdformData['备注']" :rows="2" :clearable="true" style="width: 700px;" resize="none"  id="备注"  @keydown="add_gdzlent($event, '进程备注', '备注', '重点工单')"/>
                    </el-form-item>
                  </el-row>
                </el-form>
              </el-row>
              <template #footer>
                <div class="dialog-footer" style="text-align: right;">
                  <el-button @click="add_gdcloseDialog">取 消</el-button>
                  <el-button type="primary"  @click="add_gdenterDialog">确 定</el-button>
                </div>
              </template>
            </el-dialog>

            <!-- 新增查询客户代号 -->
            <el-dialog v-model="khdhModal" :before-close="() => khdhModal = false">
              <el-form>
                <div>
                  <el-form-item label="关键字:"  class="mab" prop="keyOrder">
                    <el-space>
                      <el-input v-model="khdh_keyword" @keyup.enter="khdh_ProductValue"  style="width: 100%;"/>
                      <el-button @click="gongdanSearchHandle(khdh_keyword, '客户代号')">刷新</el-button>
                    </el-space>
                  </el-form-item>
                  <div style="border:1px solid #eee; width:100%; height: 400px; overflow-y: auto">
                    <el-tree :data="khdhDataList" :props="{children: 'children',label: 'name', value: '客户编号'}" @node-click="selectGongDanNode($event, '客户代号')" />
                  </div>
                </div>
              </el-form>
            </el-dialog>

            <!-- 新增查询 cp代号 -->
            <el-dialog v-model="cpdhModal" :before-close="() => cpdhModal = false">
              <el-form>
                <div>
                  <el-form-item label="关键字:"  class="mab" prop="keyOrder">
                    <el-space>
                      <el-input v-model="cpdh_keyword" @keyup.enter="cpdh_ProductValue" style="width: 100%;"/>
                      <el-button @click="gongdanSearchHandle(cpdh_keyword, '产品代号')">刷新</el-button>
                    </el-space>
                  </el-form-item>
                  <div style="border:1px solid #eee; width:100%; height: 400px; overflow-y: auto">
                    <el-tree :data="cpdhDataList" :props="{children: 'children',label: 'name', value: '产品编号'}" @node-click="selectGongDanNode($event, '产品代号')" />
                  </div>
                </div>
              </el-form>
            </el-dialog>

            <!-- 修改印件表格资料弹窗 -->
            <el-dialog v-model="gdyjdialogFormVisible" :before-close="gdyjcloseDialog"
                       style="width: 60%;"  :title="'修改印件资料'" destroy-on-close>
              <el-form label-width="100px">
                <el-form-item label="印件号:" class="mab" prop="keyOrder">
                  <el-input v-model="gdyjformData['印件号']" placeholder="" style="width: 140px;"  id="印件号"  @keydown="edit_gdyjent($event, '备注说明', '印件号', '印件代号')"/>
                </el-form-item>
                <el-form-item label="印件代码:" class="mab" prop="keyOrder">
                  <el-input v-model="gdyjformData['印件代号']" placeholder="" style="width: 140px;"  id="印件代号"  @keydown="edit_gdyjent($event, '印件号', '印件代号', '印件名称')"/>
                  <el-input v-model="gdyjformData['印件名称']" placeholder="" style="width: 80%; margin-left: 10px"  id="印件名称"  @keydown="edit_gdyjent($event, '印件代号', '印件名称', '纸张代号')"/>
                </el-form-item>
                <el-form-item label="纸张编号:" class="mab" prop="keyOrder">
                  <el-input v-model="gdyjformData['纸张代号']" placeholder="" style="width: 140px;" id="纸张代号"  @keydown="edit_gdyjent($event, '印件名称', '纸张代号', '纸张名称')"/>
                  <el-input v-model="gdyjformData['纸张名称']" placeholder="" style="width: 80%; margin-left: 10px" id="纸张名称"  @keydown="edit_gdyjent($event, '纸张代号', '纸张名称', '备用纸张1')"/>
                </el-form-item>
                <el-form-item label="备用纸张1:" class="mab" prop="keyOrder">
                  <el-input v-model="gdyjformData['备用纸张1']" placeholder="" style="width: 140px;" id="备用纸张1"  @keydown="edit_gdyjent($event, '纸张名称', '备用纸张1', '纸张名称11')"/>
                  <el-input v-model="gdyjformData['纸张名称11']" placeholder="" style="width: 80%; margin-left: 10px" id="纸张名称11"  @keydown="edit_gdyjent($event, '备用纸张1', '纸张名称11', '备用纸张2')"/>
                </el-form-item>
                <el-form-item label="备用纸张2:" class="mab" prop="keyOrder">
                  <el-input v-model="gdyjformData['备用纸张2']" placeholder="" style="width: 140px;" id="备用纸张2"  @keydown="edit_gdyjent($event, '纸张名称11', '备用纸张2', '纸张名称22')"/>
                  <el-input v-model="gdyjformData['纸张名称22']" placeholder="" style="width: 80%; margin-left: 10px" id="纸张名称22"  @keydown="edit_gdyjent($event, '备用纸张2', '纸张名称22', '备用纸张3')"/>
                </el-form-item>
                <el-form-item label="备用纸张3:" class="mab" prop="keyOrder">
                  <el-input v-model="gdyjformData['备用纸张3']" placeholder="" style="width: 140px;" id="备用纸张3"  @keydown="edit_gdyjent($event, '纸张名称22', '备用纸张3', '纸张名称33')"/>
                  <el-input v-model="gdyjformData['纸张名称33']" placeholder="" style="width: 80%; margin-left: 10px" id="纸张名称33"  @keydown="edit_gdyjent($event, '备用纸张3', '纸张名称33', '备用纸张4')"/>
                </el-form-item>
                <el-form-item label="备用纸张4:" class="mab" prop="keyOrder">
                  <el-input v-model="gdyjformData['备用纸张4']" placeholder="" style="width: 140px;" id="备用纸张4"  @keydown="edit_gdyjent($event, '纸张名称33', '备用纸张4', '纸张名称44')"/>
                  <el-input v-model="gdyjformData['纸张名称44']" placeholder="" style="width: 80%; margin-left: 10px" id="纸张名称44"  @keydown="edit_gdyjent($event, '备用纸张4', '纸张名称44', '订单数量')"/>
                </el-form-item>
                <div style="display: flex; gap: 0px;">
                  <el-form-item label="订单数量:" class="mab" prop="keyOrder">
                    <el-input v-model="gdyjformData['订单数量']" placeholder="" style="width: 80px;" id="订单数量"  @keydown="edit_gdyjent($event, '纸张名称44', '订单数量', '平张投料')"/>
                  </el-form-item>
                  <el-form-item label="平张投料:" class="mab" prop="keyOrder">
                    <el-input v-model="gdyjformData['平张投料']" placeholder="" style="width: 80px;" id="平张投料"  @keydown="edit_gdyjent($event, '订单数量', '平张投料', '万小张')"/>
                  </el-form-item>
                  <el-form-item label="万小张:" class="mab" prop="keyOrder">
                    <el-input v-model="gdyjformData['万小张']" placeholder="" style="width: 80px;" id="万小张"  @keydown="edit_gdyjent($event, '平张投料', '万小张', '开料规格')"/>
                  </el-form-item>
                  <el-form-item label="纸张规格:" class="mab" prop="keyOrder">
                    <el-input disabled v-model="gdyjformData['投料规格']" placeholder="" style="width: 240px;" />
                  </el-form-item>
                </div>
                <div style="display: flex; gap: 0px;">
                  <el-form-item label="投料规格:" class="mab" prop="keyOrder">
                    <el-input v-model="gdyjformData['开料规格']" placeholder="" style="width: 80px;" id="开料规格"  @keydown="edit_gdyjent($event, '万小张', '开料规格', '开数')"/>
                  </el-form-item>
                  <el-form-item label="开料开数:" class="mab" prop="keyOrder">
                    <el-input v-model="gdyjformData['开数']" placeholder="" style="width: 80px;" id="开数"  @keydown="edit_gdyjent($event, '开料规格', '开数', '联数')"/>
                  </el-form-item>
                  <el-form-item label="开料联数:" class="mab" prop="keyOrder">
                    <el-input v-model="gdyjformData['联数']" placeholder="" style="width: 80px;" id="联数"  @keydown="edit_gdyjent($event, '开数', '联数', '核算规格')"/>
                  </el-form-item>
                  <el-form-item label="核算规格:" class="mab" prop="keyOrder">
                    <el-input v-model="gdyjformData['核算规格']" placeholder="" style="width: 240px;" id="核算规格"  @keydown="edit_gdyjent($event, '联数', '核算规格', '备注说明')"/>
                  </el-form-item>
                </div>
                <el-form-item label="备注说明:" class="mab" prop="remark">
                  <el-input type="textarea" v-model="gdyjformData['备注']"  resize="none" rows="2" clearable placeholder="" id="备注说明"  @keydown="edit_gdyjent($event, '核算规格', '备注说明', '印件号')"/>
                </el-form-item>
              </el-form>

              <template #footer>
                <div class="dialog-footer" style="text-align: right;">
                  <el-button @click="gdyjcloseDialog">取消</el-button>
                  <el-button type="primary"  @click="gdyjenterDialog">确定</el-button>
                </div>
              </template>
            </el-dialog>


			<!-- 新增印件资料 -->
<!--          <el-dialog v-model="add_gdyjdialogFormVisible" :before-close="add_gdyjcloseDialog" :title="'新增印件资料'" height="500px" width="800px" destroy-on-close>-->
<!--			            <el-row>-->
<!--			              <el-scrollbar >-->
<!--			                <el-form :model="add_yjformDataTest" label-position="right" ref="elFormRef" :rules="rule">-->
<!--			                  <el-row>-->
<!--			                    <el-form-item label="印件号:" prop="address" class="mab" label-width="100px">-->
<!--			                      <el-input v-model="add_yjzlformdata.yjno" placeholder="" style="width: 140px;"  id="印件号"  @keydown="ent($event, '', '印件号', '印件代号')" />-->
<!--			                    </el-form-item>-->
<!--			                  </el-row>-->
<!--			                  <el-row>-->
<!--			                    <el-form-item label="印件代号:" prop="address" class="mab" label-width="100px">-->
<!--			                      <el-input  placeholder="" style="width: 140px;"  id="印件代号" @keydown="openSearchModal"   />-->
<!--			                    </el-form-item>-->
<!--			                  </el-row>-->
<!--			                  <el-row>-->
<!--			                    <el-col :span="18">-->
<!--			                      <el-form-item label="印件名称:" prop="address" class="mab" label-width="100px">-->
<!--			                        <el-input  placeholder="" style="width: 100%;" id="印件名称"  @keydown="ent($event, '印件代号', '印件名称', 'yj_zzdh')" />-->
<!--			                      </el-form-item>-->
<!--			                    </el-col>-->
<!--			                  </el-row>-->
<!--			                  <el-row>-->
<!--			                    <el-col :span="24">-->
<!--			                      <el-form-item label="纸张:" prop="address" class="mab" label-width="100px">-->
<!--			                        <el-row>-->
<!--			                          <el-input  placeholder="" style="width: 140px;"  id="yj_zzdh"  @keydown="ent($event, '印件名称', 'yj_zzdh', 'yj_zzmc')" />-->
<!--			                          <el-input  placeholder=""  style="width: 460px;" id="yj_zzmc"  @keydown="ent($event, 'yj_zzdh', 'yj_zzmc', 'yj_zzdh1')"  />-->
<!--			                        </el-row>-->
<!--			                      </el-form-item>-->
<!--			                    </el-col>-->
<!--			                    <el-col :span="24">-->
<!--			                      <el-form-item label="备用纸张1:" prop="address" class="mab" label-width="100px">-->
<!--			                        <el-row>-->
<!--			                          <el-input  placeholder="" style="width: 140px;"  id="yj_zzdh1"  @keydown="ent($event, 'yj_zzmc', 'yj_zzdh1', 'yj_zzmc1')" />-->
<!--			                          <el-input  placeholder=""  style="width: 460px;" id="yj_zzmc1"  @keydown="ent($event, 'yj_zzdh1', 'yj_zzmc', 'yj_zzdh2')"  />-->
<!--			                        </el-row>-->
<!--			                      </el-form-item>-->
<!--			                    </el-col>-->
<!--			                    <el-col :span="24">-->
<!--			                      <el-form-item label="备用纸张2:" prop="address" class="mab" label-width="100px">-->
<!--			                        <el-row>-->
<!--			                          <el-input  placeholder="" style="width: 140px;"  id="yj_zzdh2"  @keydown="ent($event, 'yj_zzmc1', 'yj_zzdh', 'yj_zzmc2')" />-->
<!--			                          <el-input  placeholder=""  style="width: 460px;" id="yj_zzmc2"  @keydown="ent($event, 'yj_zzdh2', 'yj_zzmc', 'yj_zzdh3')"  />-->
<!--			                        </el-row>-->
<!--			                      </el-form-item>-->
<!--			                    </el-col>-->
<!--			                    <el-col :span="24">-->
<!--			                      <el-form-item label="备用纸张3:" prop="address" class="mab" label-width="100px">-->
<!--			                        <el-row>-->
<!--			                          <el-input  placeholder="" style="width: 140px;"  id="yj_zzdh3"  @keydown="ent($event, 'yj_zzmc2', 'yj_zzdh', 'yj_zzmc3')" />-->
<!--			                          <el-input  placeholder=""  style="width: 460px;" id="yj_zzmc3"  @keydown="ent($event, 'yj_zzdh3', 'yj_zzmc', 'yj_zzdh4')"  />-->
<!--			                        </el-row>-->
<!--			                      </el-form-item>-->
<!--			                    </el-col>-->
<!--			                    <el-col :span="24">-->
<!--			                      <el-form-item label="备用纸张4:" prop="address" class="mab" label-width="100px">-->
<!--			                        <el-row>-->
<!--			                          <el-input  placeholder="" style="width: 140px;"  id="yj_zzdh4"  @keydown="ent($event, 'yj_zzmc3', 'yj_zzdh', 'yj_zzmc4')" />-->
<!--			                          <el-input  placeholder=""  style="width: 460px;" id="yj_zzmc4"  @keydown="ent($event, 'yj_zzdh4', 'yj_zzmc', 'yj_tlgg')"  />-->
<!--			                        </el-row>-->
<!--			                      </el-form-item>-->
<!--			                    </el-col>-->

<!--			                  </el-row>-->
<!--			                  <el-row>-->
<!--			                    <el-col :span="8">-->
<!--			                      <el-form-item label="投料(mm*mm):" prop="address" class="mab">-->
<!--			                        <el-input  placeholder=""  style="width: 140px;"  id="yj_tlgg"  @keydown="ent($event, 'yj_zzmc', 'yj_tlgg', 'yj_klgg')"/>-->
<!--			                      </el-form-item>-->
<!--			                    </el-col>-->
<!--			                    <el-col :span="8">-->
<!--			                      <el-form-item label="开料(mm*mm):" prop="address" class="mab">-->
<!--			                        <el-input placeholder="" style="width: 140px;"  id="yj_klgg"  @keydown="ent($event, 'yj_tlgg', 'yj_klgg', 'yj_ks')"/>-->
<!--			                      </el-form-item>-->
<!--			                    </el-col>-->
<!--			                  </el-row>-->
<!--			                  <el-row>-->
<!--			                    <el-col :span="10">-->
<!--			                      <el-form-item label="开数:" prop="address" class="mab" label-width="100px">-->
<!--			                        <el-input  placeholder="" style="width: 140px;" id="yj_ks"  @keydown="ent($event, 'yj_tlgg', 'yj_ks', 'yj_ls')"/>-->
<!--			                      </el-form-item>-->
<!--			                    </el-col>-->
<!--			                    <el-col :span="10">-->
<!--			                      <el-form-item label="联数:" prop="address" class="mab">-->
<!--			                        <el-input  placeholder=""  style="width: 140px;" id="yj_ls"  @keydown="ent($event, 'yj_ks', 'yj_ls', 'yj_desc')"/>-->
<!--			                      </el-form-item>-->
<!--			                    </el-col>-->
<!--			                  </el-row>-->
<!--			                  <el-row>-->
<!--			                    <el-col :span="24">-->
<!--			                      <el-form-item label="备注说明:" prop="remark" class="mab">-->
<!--			                        <el-input type="textarea" rows="4" clearable placeholder="请输入备注说明"  id="yj_desc"  @keydown="ent($event, 'yj_ls', 'yj_desc', '印件号')"/>-->
<!--			                      </el-form-item>-->
<!--			                    </el-col>-->
<!--			                  </el-row>-->
<!--			                </el-form>-->
<!--			              </el-scrollbar>-->
<!--			            </el-row>-->
<!--			            <template #footer>-->
<!--			              <div class="dialog-footer">-->
<!--			                <el-button @click="add_yjcloseDialog">取 消</el-button>-->
<!--			                <el-button type="primary" disabled @click="add_yjenterDialog">确 定</el-button>-->
<!--			              </div>-->
<!--			            </template>-->
<!--			          </el-dialog>-->

            <!-- 新增印件资料弹窗 -->
            <el-dialog v-model="add_gdyjdialogFormVisible" :before-close="add_gdyjcloseDialog"
                       style="width: 60%;" :title="'新增印件资料'" destroy-on-close>
              <el-form label-width="100px" :model="add_yjzlformdata">
                <el-form-item label="印件号:" class="mab" prop="yjno" >
                  <el-input v-model="add_yjzlformdata.yjno" placeholder="" style="width: 140px;" id="yjno"  @keydown="add_gdzlyjent($event, 'desc', 'yjno', 'yjdh')"/>
                </el-form-item>
                <el-form-item label="印件代码:" class="mab" prop="keyOrder">
                  <el-input v-model="add_yjzlformdata.yjdh" id="yjdh"  @keydown="add_gdzlyjent($event, 'yjno', 'yjdh', 'yjmc')" style="width: 140px;"/>
                  <el-input v-model="add_yjzlformdata.yjmc" id="yjmc" @keydown="add_gdzlyjent($event, 'yjdh', 'yjmc', 'zzdh')" style="width: 80%; margin-left: 10px"/>
                </el-form-item>
                <el-form-item label="纸张编号:" class="mab" prop="keyOrder">
                  <el-input v-model="add_yjzlformdata.zzdh"  class="zhi" id="zzdh" @keydown="add_gdzlyjent($event, 'yjmc', 'zzdh', 'zzmc',0)"  placeholder="" style="width: 140px;"/>
                  <el-input v-model="add_yjzlformdata.zzmc"  id="zzmc" @keydown="add_gdzlyjent($event, 'zzdh', 'zzmc', 'zzdh1')" style="width: 80%; margin-left: 10px"/>
                </el-form-item>
                <el-form-item label="备用纸张1:" class="mab" prop="keyOrder">
                  <el-input v-model="add_yjzlformdata.zzdh1" class="zhi" id="zzdh1" @keydown="add_gdzlyjent($event, 'zzmc', 'zzdh1', 'zzmc1',1)" style="width: 140px;"/>
                  <el-input v-model="add_yjzlformdata.zzmc1"  id="zzmc1" @keydown="add_gdzlyjent($event, 'zzdh1', 'zzmc1', 'zzdh2')"  style="width: 80%; margin-left: 10px"/>
                </el-form-item>
                <el-form-item label="备用纸张2:" class="mab" prop="keyOrder">
                  <el-input v-model="add_yjzlformdata.zzdh2" class="zhi" id="zzdh2" @keydown="add_gdzlyjent($event, 'zzmc1', 'zzdh2', 'zzmc2',2)" style="width: 140px;"/>
                  <el-input v-model="add_yjzlformdata.zzmc2"  id="zzmc2" @keydown="add_gdzlyjent($event, 'zzdh2', 'zzmc2', 'zzdh3')" style="width: 80%; margin-left: 10px"/>
                </el-form-item>
                <el-form-item label="备用纸张3:" class="mab" prop="keyOrder">
                  <el-input v-model="add_yjzlformdata.zzdh3" class="zhi" id="zzdh3" @keydown="add_gdzlyjent($event, 'zzmc2', 'zzdh3', 'zzmc3',3)" style="width: 140px;"/>
                  <el-input v-model="add_yjzlformdata.zzmc3" id="zzmc3" @keydown="add_gdzlyjent($event, 'zzdh3', 'zzmc3', 'zzdh4')" style="width: 80%; margin-left: 10px"/>
                </el-form-item>
                <el-form-item label="备用纸张4:" class="mab" prop="keyOrder">
                  <el-input v-model="add_yjzlformdata.zzdh4"  class="zhi" id="zzdh4" @keydown="add_gdzlyjent($event, 'zzmc3', 'zzdh4', 'zzmc4',4)" style="width: 140px;"/>
                  <el-input v-model="add_yjzlformdata.zzmc4" id="zzmc4" @keydown="add_gdzlyjent($event, 'zzdh4', 'zzmc4', 'cpsl')" style="width: 80%; margin-left: 10px"/>
                </el-form-item>
                <div style="display: flex; gap: 0px;">
                  <el-form-item label="订单数量:" class="mab" prop="keyOrder">
                    <el-input v-model="add_yjzlformdata.cpsl" style="width: 80px;" id="cpsl" @keydown="add_gdzlyjent($event, 'zzmc4', 'cpsl', 'pztl')"/>
                  </el-form-item>
                  <el-form-item label="平张投料:" class="mab" prop="keyOrder">
                    <el-input v-model="add_yjzlformdata.pztl" style="width: 80px;" id="pztl" @keydown="add_gdzlyjent($event, 'cpsl', 'pztl', 'klgg')"/>
                  </el-form-item>
                  <el-form-item label="万小张:" class="mab" prop="keyOrder">
                    <el-input disabled v-model="add_yjzlformdata.万小张" style="width: 80px;"/>
                  </el-form-item>
                  <el-form-item label="纸张规格:" class="mab" prop="keyOrder">
                    <el-input disabled v-model="add_yjzlformdata.tlgg" style="width: 240px;"/>
                  </el-form-item>
                </div>
                <div style="display: flex; gap: 0px;">
                  <el-form-item label="投料规格:" class="mab" prop="keyOrder">
                    <el-input v-model="add_yjzlformdata.klgg" style="width: 80px;" id="klgg"  @keydown="add_gdzlyjent($event, 'pztl', 'klgg', 'ks')"/>
                  </el-form-item>
                  <el-form-item label="开料开数:" class="mab" prop="keyOrder">
                    <el-input v-model="add_yjzlformdata.ks" style="width: 80px;" id="ks"  @keydown="add_gdzlyjent($event, 'klgg', 'yjdh', 'ls')"/>
                  </el-form-item>
                  <el-form-item label="开料联数:" class="mab" prop="keyOrder">
                    <el-input v-model="add_yjzlformdata.ls" style="width: 80px;" id="ls"  @keydown="add_gdzlyjent($event, 'ks', 'ls', 'hsgg')"/>
                  </el-form-item>
                  <el-form-item label="核算规格:" class="mab" prop="keyOrder">
                    <el-input v-model="add_yjzlformdata.hsgg" style="width: 240px;" id="hsgg"  @keydown="add_gdzlyjent($event, 'ls', 'hsgg', 'desc')"/>
                  </el-form-item>
                </div>
                <el-form-item label="备注说明:" class="mab" prop="remark">
                  <el-input v-model="add_yjzlformdata.desc" type="textarea" resize="none" rows="2" clearable id="desc" @keydown="add_gdzlyjent($event, 'hsgg', 'desc', 'yjno')" />
                </el-form-item>
              </el-form>

              <template #footer>
                <div class="dialog-footer" style="text-align: right;">
                  <el-button @click="add_dyjcloseDialog">取消</el-button>
                  <el-button type="primary"  @click="add_gdyjenterDialog">确定</el-button>
                </div>
              </template>
            </el-dialog>

            <!-- 新增查询印件代码 -->
            <el-dialog v-model="searchModel" :before-close="() => searchModel = false">
              <el-form>
                <div>
                  <el-form-item label="关键字:"  class="mab" prop="keyOrder">
                    <el-space>
                      <el-input v-model="yjdh_keyword" style="width: 100%;"/>
                      <el-button @click="searchHandle(yjdh_keyword)">刷新</el-button>
                    </el-space>
                  </el-form-item>
                  <div style="border:1px solid #eee; width:100%; height: 400px; overflow-y: auto">
                    <el-tree :data="getProductYjListdata" :props="{children: 'children',label: 'label', value: '物料代码'}" @node-click="selectNode" />
                  </div>
                </div>
              </el-form>
            </el-dialog>

            <!-- 新增查询印件纸张 -->
            <el-dialog v-model="searchZhiModel" :before-close="() => searchZhiModel = false">
              <el-form>
                <div>
                  <el-form-item label="关键字:"  class="mab" prop="keyOrder">
                    <el-space>
                      <el-input v-model="zhi_keyword" style="width: 100%;"/>
                      <el-button @click="searchZhiHandle(zhi_keyword)">刷新</el-button>
                    </el-space>
                  </el-form-item>
                  <div style="border:1px solid #eee; width:100%; height: 400px; overflow-y: auto">
                    <el-tree :data="getProductZhiListdata" :props="{children: 'children',label: 'label', value: '物料代码'}" @node-click="selectZhiNode" />
                  </div>
                </div>
              </el-form>
            </el-dialog>

            <!-- 修改工艺资料弹窗 -->
            <el-dialog v-model="gdgydialogFormVisible" :before-close="gycloseDialog" style="width: 1100px;" :title="'修改工艺资料'" destroy-on-close>
              <el-form>
                <div>
                  <div style="display: flex; gap: 0px;">
                    <el-form-item label="印件编号:"  class="mab" prop="keyOrder">
                      <el-input disabled v-model="gdgyformData['印件']"   style="width: 100px;"/>
                    </el-form-item>
                    <el-form-item label="工序编号:"  class="mab" prop="keyOrder" label-width=" 90">
                      <el-input disabled v-model="gdgyformData['工序']"  style="width: 100px;"/>
                    </el-form-item>
                    <el-form-item label="重点工序:"  class="mab" prop="keyOrder" label-width=" 90">
                      <el-input  v-model="gdgyformData['重点工序']"  id="重点工序"   @keydown="gyzlent($event, '', '重点工序', '设备编号')"  style="width: 100px;"/>
                    </el-form-item>
                    <el-form-item label="备选工序："  class="mab" prop="isBanciSelected" label-width=" 90">
                      <el-checkbox v-model="gdgyformData['备选工序']"></el-checkbox>
                    </el-form-item>
                    <el-form-item label="加工开数:"  class="mab" prop="keyOrder" label-width=" 125">
                      <el-input disabled v-model="gdgyformData['开数']"  style="width: 100px;"/>
                    </el-form-item>
                    <el-form-item label="加工联数:"  class="mab" prop="keyOrder" label-width=" 80">
                      <el-input disabled v-model="gdgyformData['联数']"  style="width: 100px;"/>
                    </el-form-item>
                  </div>
                  <div style="display: flex; gap: 0px;">
                    <el-form-item label="车间名称:"  class="mab" prop="keyOrder">
                      <el-input disabled v-model="gdgyformData['车间名称']"  style="width: 130px;"/>
                    </el-form-item>
                    <el-form-item label="工艺名称:"  class="mab" prop="keyOrder" label-width=" 90">
                      <el-input disabled v-model="gdgyformData['工艺名称']"  style="width: 140px;"/>
                    </el-form-item>
                    <el-form-item label="工序名称:"  class="mab" prop="keyOrder" label-width=" 90">
                      <el-input disabled v-model="gdgyformData['工序名称']"  style="width: 400px;"/>
                    </el-form-item>
                    <el-form-item label="计损色数"  class="mab" prop="keyOrder" label-width=" 80">
                      <el-input disabled v-model="gdgyformData['计损色数']" style="width: 90px;"/>
                    </el-form-item>
                  </div>
                  <el-form-item label="设备编号:"  class="mab" prop="remark">
                    <el-select v-model="gdgyformData['设备编号']" multiple
                               id="设备编号"  @keydown="gyzlent($event, '重点工序', '设备编号', '工序损耗')"
                               style="flex: 1; height: auto;">
                      <el-option
                          @keydown.tab.prevent="sbbhclick"
                          @click="sbbhclick"
                          v-for="(item, index) in gdzl_MachineList_address.data"
                          :key="index"
                          :label="item.split('-->')[0].trim()"
                          :value="item.split('-->')[0].trim()">
                        {{ item }}
                      </el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="工序损耗:"  class="mab" prop="keyOrder" >
                    <el-input v-model="gdgyformData['shdh']"  style="width: 10%;" id="工序损耗"  @keydown="gyzlent($event, '设备编号', '工序损耗', '损耗系数')"/>
                    <el-input disabled v-model="gdgyformData['工序名称']"  style="width: 88.7%;margin-left: 10px"/>
                  </el-form-item>
                  <div style="display: flex; gap: 0px;">
                    <el-form-item label="损耗系数:"  class="mab" prop="keyOrder">
                      <el-input v-model="gdgyformData['损耗系数']"  style="flex: 1;"  id="损耗系数"  @keydown="gyzlent($event, '工序损耗', '损耗系数', '难度系数')"/>
                    </el-form-item>
                    <el-form-item label="难度系数"  class="mab" prop="keyOrder">
                      <el-input v-model="gdgyformData['难度系数']"  style="flex: 1;" id="难度系数"  @keydown="gyzlent($event, '设备编号', '难度系数', '小时产能')"/>
                    </el-form-item>
                    <el-form-item label="装版工时:"  class="mab" prop="keyOrder">
                      <el-input disabled v-model="gdgyformData['装版工时']"  style="flex: 1;"/>
                    </el-form-item>
                    <el-form-item label="排产小时产能:"  class="mab" prop="keyOrder" label-width=" 120px">
                      <el-input  v-model="gdgyformData['小时产能']"  style="flex: 1;" id="小时产能"  @keydown="gyzlent($event, '难度系数', '小时产能', '')"/>
                    </el-form-item>
                    <el-form-item label="印刷方式"  class="mab" prop="keyOrder">
                      <el-input disabled v-model="gdgyformData['印刷方式']"  style="flex: 1;"/>
                    </el-form-item>
                    <el-form-item label="版距"  class="mab" prop="keyOrder">
                      <el-input disabled v-model="gdgyformData['版距']"  style="flex: 1;"/>
                    </el-form-item>
                  </div>
                  <el-form-item label="工序备注:"  class="mab" prop="remark">
                    <el-input disabled type="textarea" resize="none" v-model="gdgyformData['备注']" rows="3" clearable   style="flex: 1;resize: none" />
                  </el-form-item>
                  <el-form-item  label="质量要求:"  class="mab" prop="remark">
                    <el-input disabled type="textarea" resize="none" v-model="gdgyformData['质量要求']" rows="2" clearable   style="flex: 1;resize: both;"/>
                  </el-form-item>
                  <el-form-item label="质量隐患:"  class="mab" prop="remark">
                    <el-input disabled type="textarea" resize="none" v-model="gdgyformData['质量隐患']" rows="2" clearable   style="flex: 1;"/>
                  </el-form-item>
                </div>
              </el-form>
              <template #footer>
                <div class="dialog-footer" style="text-align: right;top: auto">
                  <el-button @click="gdgycloseDialog">取 消</el-button>
                  <el-button type="primary" @click="gdgyenterDialog">确 定</el-button>
                </div>
              </template>
            </el-dialog>

          </el-main>
        </layout-content>
      </layout>
    </layout>

    <PrintPage ref="printPageRef" />

    <AddGongYi ref="addGongYiRef" />
  </div>
</template>
<script>
//点击按钮显示下方表格
export default {
  data() {
    return {
      currentTable: '', // 当前展示的表格
      activeName: 'first',
    };
  },
  methods: {
    showTable(tableName) {
      this.currentTable = tableName;
    },
    showTableChange() {
      // 处理表格选中事件
    },
  }
};
</script>
<script setup>
// 全量引入格式化工具 请按需保留
import { Layout, LayoutSider, LayoutContent } from '@arco-design/web-vue';
import { ElMessage, ElMessageBox } from 'element-plus'
import { ref, reactive, computed } from 'vue'
import {
  DataList,
  WorkList, gdzl_MachineList,PrintCodeList,getProductYjList, getProductZzList,
  U8workOrder, ProcessDetailEdit, PrintedEdit, PrintJobOrder,WorkOrderAdd,PrintDetailAdd,
  WorkOrderEdit, ReferenceWorkOrder,getOrderProcessLeft,ClientList,ProductCodeList,
  editGyWaste, U8DataCorrection, AccountingParameterEdit,ProcessCopy,
  ProductInformation, TestCoefficient, capacityList,getOrderProcessRight,
  DataCorrection, U8Trial, ProcessFlow, AccountingParameter,
  setProductStatus,
  getProduct, getProductGy, ProductInformationEdit, workOrderListDetail, editProduct, getOrderProcessCount, StatusEdit,
  PrintDetailDel, ProcessDetailDel
} from "@/api/yunyin/yunying";

import PrintPage from './components/print.vue'
import AddGongYi from './components/addGongYi.vue'
defineOptions({name: 'Company'})

const printPageRef = ref()
const addGongYiRef = ref()

// =========== 修正核算参数 ===========
const xzhstableColumns = ref(
    [
      { label: '方案', prop: '方案', width: '65' },
      { label: '印件号及工序名称', prop: '印件号及工序名称', width: '300' },
      { label: '参照设备', prop: '参照设备', width: '90' },
      { label: '难度系数', prop: 'sxzhscsold_难度系数', width: '90' },
      { label: '新难度系数', prop: '难度系数', width: '100' },
      { label: '原损耗代号', prop: 'sxzhscsold_损耗代号', width: '150' },
      { label: '基础损耗', prop: '基础损耗', width: '90' },
      { label: '新损耗代号', prop: '损耗代号', width: '150' },
      { label: '原印刷方式', prop: 'sxzhscsold_印刷方式', width: '150' },
      { label: '原来版距', prop: 'sxzhscsold_版距', width: '100' },
      { label: '新印刷方式', prop: '印刷方式', width: '100' },
      { label: '新来版距', prop: '版距', width: '90' },
      { label: '原计损色数', prop: 'sxzhscsold_计损色数', width: '100' },
      { label: '新计损色数', prop: '计损色数', width: '100' },
      { label: '原损耗系数', prop: 'sxzhscsold_损耗系数', width: '100' },
      { label: '新损耗系数', prop: '损耗系数', width: '100' },
    ]
)
const handleKeyDown = (event, x, y, prop) => {
  const currentElement = document.getElementById(`input${x}${y}`);
  if (currentElement === null && currentElement === undefined) return
  let move = 0
  switch (event.keyCode) {
    case 13: // Enter
    case 40: // 向下箭头
      if (y < sxzhscstableData.value.length )
        document.getElementById(`input${x}${y + 1}`).focus();
      break;
    case 38: // 向上箭头
      if ( y > 0) {
        document.getElementById(`input${x}${y - 1}`).focus();
      }
      break;
    case 39: // 向左箭头
      if ( x === 4) {
        move = x + 3
      } else if(x === 7){
        move = x + 3
      } else if( x === 10){
        move = x + 1
      }else if( x === 11){
        move = x + 2
      }else if( x === 13){
        move = x + 2
      }
      document.getElementById(`input${move}${y}`).focus();
      break;
    case 37: // 向右箭头
      if ( x === 15) {
        move = x -  2
      } else if (x=== 13) {
        move = x - 2
      }else if (x=== 11) {
        move = x - 1
      }else if (x=== 10) {
        move = x - 3
      }else if (x=== 7) {
        move = x - 3
      }
      document.getElementById(`input${move}${y}`).focus();
      break;
    default:
      break;
  }
}
const xzhscslist = ref(false);
const xzhscsformData = reactive({
  gdbh: '',
  cpdh: '',
  gdmc: '',
});
const sxzhscstableData = ref([]);
//修正核算参数按钮
const onxzhscsclick = () => {
  if(_Gd_gdbh.value == null){
    xzhscslist.value = false;
    ElMessage({type: 'warning',message: '请选择具体的工单后，再操作此功能' })
  }else{
    xzhscsformData['gdbh'] = _Gd_gdbh.value;
    xzhscsformData['cpdh'] = _Gd_cpdh.value;
    xzhscsformData['gdmc'] = _Gd_cpmc.value;
    _AccountingParameterdata();
    xzhscslist.value = true;
  }
};
//修正核算参数回车
const xzhscsgetProductValue = () => {
  _AccountingParameterdata()
};
// 修正工单核算参数表格数据
const _AccountingParameterdata = async ()=>{
  let workOrder = xzhscsformData['gdbh'];
  try {
    const AccountingParameterdata = await AccountingParameter({workOrder:workOrder});
    sxzhscstableData.value = AccountingParameterdata.data;
    const formattedData = AccountingParameterdata.data.map(item=>{
      item.sxzhscsold_难度系数 = item.难度系数;
      item.sxzhscsold_损耗代号 = item.损耗代号;
      item.sxzhscsold_印刷方式 = item.印刷方式;
      item.sxzhscsold_版距 = item.版距;
      item.sxzhscsold_计损色数 = item.计损色数;
      item.sxzhscsold_损耗系数 = item.损耗系数;
      return item
    });
  } catch (error) {
    console.error(error);
  }
}
//修正核算参数更新
const xzhscsConfirm = async () => {
  const firstCharValid = sxzhscstableData.value.map(item => {
    const firstChar = item["损耗代号"] ? item["损耗代号"].charAt(0) : '';
    return firstChar === '0' || firstChar === '';
  });
  if(firstCharValid.includes(false)){
    ElMessage({type: 'warning',message: '损耗代号开头必须是 0' })
    return false;
  }
  if (sxzhscstableData.value) {
    const formattedData = sxzhscstableData.value.map(item => {
      return {
        Uniqid: parseInt(item.UniqId),
        chromatic: parseFloat(item.计损色数) ?? '',
        difficulty: parseFloat(item.难度系数) ?? '',
        loss: item.损耗代号 ??'',
        plate: parseInt(item.版距) ?? '',
        printMode: item.印刷方式 ?? '',
        wastage: parseFloat(item.损耗系数),
      }
    });
    // console.log(formattedData)
    const AccountingParameterEditdata = await AccountingParameterEdit(formattedData);
    if (AccountingParameterEditdata.code === 0) {
      xzhscslist.value = false;
      ElMessage({ type: 'success', message: '更新成功' });
    } else {
      ElMessage({ type: 'error', message: '更新失败' });
    }
  } else {
    console.error("数据错误");
  }
};
//修正核算参数退出
const sxzhscsCancel = () => {
  xzhscslist.value = false;
};

// =========== 质检废品系数 ===========
const zjfpxs_tableColumns = ref(
    [
      { label: '产品编号', prop: '产品编号', width: '95' },
      { label: '产品名称', prop: '产品名称', width: '200' },
      { label: '印件工序及工艺', prop: '印件工序及工艺', width: '220' },
      { label: '新人工正品板', prop: 'scfjfpxsold_人工正品板', width: '110' },
      { label: '新人工次品板', prop: 'scfjfpxsold_人工次品板', width: '110' },
      { label: '新人工废检', prop: 'scfjfpxsold_人工废检', width: '110' },
      { label: '新机检正品板', prop: 'scfjfpxsold_机检正品板', width: '110' },
      { label: '新机检次品板', prop: 'scfjfpxsold_机检次品板', width: '110' },
      { label: '新机检废检', prop: 'scfjfpxsold_机检废检', width: '110' },
      { label: '人工正品板', prop: '人工正品板', width: '110' },
      { label: '人工次品板', prop: '人工次品板', width: '110' },
      { label: '人工废检', prop: '人工废检', width: '110' },
      { label: '机检正品板', prop: '机检正品板', width: '110' },
      { label: '机检次品板', prop: '机检次品板', width: '110' },
      { label: '机检废检', prop: '机检废检', width: '110' },
      { label: '设备编号', prop: '设备编号', width: '100' },
      { label: '客户名称', prop: '客户名称', width: '200' },
    ]
)
const zjfpxs_handleKeyDown = (event, x, y, prop) => {
  const currentElement = document.getElementById(`input${x}${y}`);
  if (currentElement === null && currentElement === undefined) return
  let move = 0
  switch (event.keyCode) {
    case 13: // Enter
    case 40: // 向下箭头
      if (y < scfjfpxstableData.value.length )
        document.getElementById(`input${x}${y + 1}`).focus();
      break;
    case 38: // 向上箭头
      if ( y > 0) {
        document.getElementById(`input${x}${y - 1}`).focus();
      }
      break;
    case 39: // 向左箭头
      if (x >= 9 && x <=14) {
        move = x + 1
      }
      document.getElementById(`input${move}${y}`).focus();
      break;
    case 37: // 向右箭头
      if (x >= 9 && x <=14) {
        move = x - 1
      }
      document.getElementById(`input${move}${y}`).focus();
      break;
    default:
      break;
  }
}
const scfjfpxslist = ref(false);
const scfjfpxsformData = reactive({
  cpdh: '',
});
const scfjfpxstableData = ref([]);
//质检废品系数【按钮】
const onzjfpxsclick = () => {
  if(_Gd_gdbh.value == null){
    scfjfpxslist.value = false;
    ElMessage({type: 'warning',message: '请选择具体的工单后，再操作此功能'});
  }else{
    scfjfpxsformData['cpdh'] = _Gd_gdbh.value;
    _TestCoefficient();
    scfjfpxslist.value = true;
  }
};

const cp_gdprintonClick = () => {
  printPageRef.value.open(_Gd_gdbh.value)
}

//质检废品系数【回车】
const scfjfpxsgetProductValue = () => {
  if(scfjfpxsformData['cpdh'] === ''){
    scfjfpxstableData.value = [];
    ElMessage({type: 'warning',message: '输入框为空'});
    return false;
  }
  _TestCoefficient();
};
//修正工单核算参数->数据获取
const _TestCoefficient = async ()=>{
  let workOrder = scfjfpxsformData['cpdh'];
  try {
    const TestCoefficientdata = await TestCoefficient({workOrder:workOrder});
    scfjfpxstableData.value = TestCoefficientdata.data;
    const formattedData = TestCoefficientdata.data.map(item=>{
      item.scfjfpxsold_人工正品板 = item.人工正品板;
      item.scfjfpxsold_人工次品板 = item.人工次品板;
      item.scfjfpxsold_人工废检 = item.人工废检;
      item.scfjfpxsold_机检正品板 = item.机检正品板;
      item.scfjfpxsold_机检次品板 = item.机检次品板;
      item.scfjfpxsold_机检废检 = item.机检废检;
      return item
    });
  } catch (error) {
    console.error(error);
  }
}

//质检废品系数【更新】
const scfjfpxsConfirm = async () => {
  const rawValueArray = scfjfpxstableData._rawValue;
  const formattedData = rawValueArray.map(item => {
    return {
      UniqID: item.Uniqid,
      artificial_zp: item.人工正品板 !== null ? item.人工正品板 : "",
      artificial_cp: item.人工次品板 !== null ? item.人工次品板 : "",
      artificial_fj: item.人工废检 !== null ? item.人工废检 : "",
      machine_zp: item.机检正品板 !== null ? item.机检正品板 : "",
      machine_cp: item.机检次品板 !== null ? item.机检次品板 : "",
      machine_fj: item.机检废检 !== null ? item.机检废检 : ""
    }
  });
  const editGyWastes = await editGyWaste(formattedData);
  if (editGyWastes.code === 0) {
    scfjfpxslist.value = false;
    ElMessage({type: 'success',message: '更新成功'})
  } else {
    ElMessage({type: 'error',message: '更新失败'})
  }
};

//质检废品系数【退出】
const scfjfpxsCancel = () => {
  scfjfpxslist.value = false;
};

//=========工序产量核查===========
const gd_gxclhclist = ref(false);
const gxclhc_Data = ref([]);
const gxclhc_Columns = ref(
    [
      { label: '印件及工序名称', prop: 'concatenatedData', width: '380' },
      // { label: '印件', prop: 'Gy0_yjno', width: '130' },
      // { label: '工序', prop: 'Gy0_gxh', width: '130' },
      // { label: '名称', prop: 'Gy0_gxmc', width: '130' },
      { label: '工序计划产量', prop: 'Gy0_计划接货数', width: '120' },
      { label: '联数', prop: 'Gy0_ls', width: '70' },
      { label: '折算车头产量', prop: '折算车头产量', width: '120' },
      { label: '实际上报产量', prop: 'sczl_cl', width: '120' },
      { label: '制程废品', prop: 'sczl_zcfp', width: '120' },
      { label: '制程废品率', prop: '制程废品率', width: '120' },
      { label: '来料异常', prop: '来料异常', width: '90' },
      { label: '流程单数', prop: 'process_num', width: '90' },
      { label: '当前设备', prop: 'Gy0_sbbh', width: '120' },
      { label: '工序状态', prop: 'PD_WG', width: '90'},
      { label: '首板生产日期', prop: 'sczl_rq', width: '160' },
    ]
)
const gxclhcformData = reactive({
  gdbh: '',
  gdmc: '',
});
// 工序产量核查按钮
const gd_gxclhconClick = async () => {
  if(_Gd_gdbh.value === '' || _Gd_gdbh.value === null){
    ElMessage({type: 'warning',message: '请选择具体的工单，在进行操作'})
    return false;
  }
  gxclhcformData['gdbh'] = _Gd_gdbh.value;
  gd_gxclhclist.value = true;
  _getOrderProcessCount();
};
//工序产量核查回车
const gxclhcProductValue = async () => {
  _getOrderProcessCount();
}
//工序产量核查退出
const gxclhcCancel = async () => {
  gd_gxclhclist.value = false;
};
//工序产量核查方法接口
const _getOrderProcessCount = async () => {
  const order = gxclhcformData['gdbh'];
  const getOrderProcessCount_list = await getOrderProcessCount({order:order});
  const concatenatedData = getOrderProcessCount_list.data.map(item => {
    // 优化后的代码，使用模板字符串连接字段值并在单个数字前添加零
    const formattedYjno = item.Gy0_yjno.length === 1 ? `0${item.Gy0_yjno}` : item.Gy0_yjno;
    const formattedGxh = item.Gy0_gxh.length === 1 ? `0${item.Gy0_gxh}` : item.Gy0_gxh;
    const concatenatedValue = `${formattedYjno}-${formattedGxh} ${item.Gy0_gxmc}`;
    return {
      ...item,
      concatenatedData: concatenatedValue, // 使用新属性名
    };
  });
  gxclhc_Data.value = concatenatedData;
};

//工序产量核查
const gxclhcCellClass = ({row, column, rowIndex, columnIndex}) =>{
  if (column.label === '实际上报产量' ||column.label === '制程废品'  || column.label === '制程废品率' ||
      column.label === '来料异常' || column.label === '流程单数' || column.label === '当前设备') {
    return 'lan-plan-usage-lows';
  }
  if (column.label === '折算车头产量') {
    return 'gxclhc—color-column-red';
  }
  // 如果不是 'PD_WG' 列，返回空字符串或其他样式类
  if (column.label === '工序状态'){
    if(row['PD_WG'] === '完工'){
      return 'lan-plan-usage-lowshui';
    }else{
      return 'pczccolor-column-lan';
    }
  }
}

// =========== 流程单查询 ===========
const gd_lcdlist = ref(false);
const gd_lcdformData = reactive({
  gdbh: '',
  code: '',
  name: '',
});
// 流程单查询按钮
const processList = ref([]);
const gdlcdcxconlick = async () => {
  if(_Gd_gdbh.value === '' || _Gd_gdbh.value === null){
    ElMessage({type: 'warning',message: '请选择具体的工单，在进行操作'})
    return false;
  }else{
    gd_lcdformData['gdbh'] = _Gd_gdbh.value;
    _getOrderProcessLeft_list();
    gd_lcdlist.value = true;
    processList.value = []
  }
}
//流程单查询回车
const gd_lcdProductValue = async () => {
  _getOrderProcessLeft_list();
}
const lcd_treeData = ref([]);
const _getOrderProcessLeft_list = async () => {
  const order = gd_lcdformData['gdbh'];
  try {
    //5.1流程单查询-工单工序生产进程菜单栏
    const getOrderProcessLeft_list = await getOrderProcessLeft({ order:order});
    gd_lcdformData['code'] = getOrderProcessLeft_list.data.Gd_info['code'];
    gd_lcdformData['name'] = getOrderProcessLeft_list.data.Gd_info['name'];
    lcd_treeData.value = [{
      label: order + '-' + getOrderProcessLeft_list.data.Gd_info['name'],
      // label: getOrderProcessLeft_list.data.Gd_info['code'] + '-' + getOrderProcessLeft_list.data.Gd_info['name'],
      value: undefined,
      children: []
    }]
    const newData = [];
    for (let key in getOrderProcessLeft_list.data.Gy_info) {
      let temp = getOrderProcessLeft_list.data.Gy_info[key];
      let concatenatedValue = `${temp.Gy0_yjno}-${temp.Gy0_gxh} ---> ${temp.Gy0_gxmc}`;
      newData.push({ label: concatenatedValue,value: temp.Gy0_gxh });
    }
    lcd_treeData.value[0].children = newData;
    //5.2流程单查询-获取工单工序生产进程右侧【接口】【进入页面默认显示第一个数据】
    const getOrderProcessRight_list = await getOrderProcessRight({order: order, gxNo:newData[0].value});
    processList.value = getOrderProcessRight_list.data
  } catch (error) {
    console.error(error);
  }
};
//点击左侧获取工序显示右侧数据
const lcd_handleNodeClick = async (node) => {
  if (node.value === undefined) return
  const order = gd_lcdformData['gdbh'];
  //5.2流程单查询-获取工单工序生产进程右侧【接口】
  const getOrderProcessRight_list = await getOrderProcessRight({order:order, gxNo:node.value});
  processList.value = getOrderProcessRight_list.data
};

// 流程单查询退出
const gd_lcdCancel = async () => {
  gd_lcdlist.value = false;
}

// =========== 新增工单资料 ===========
// 获取当前日期
const today = new Date();
const year = today.getFullYear();
const month = String(today.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始，需要补零
const day = String(today.getDate()).padStart(2, '0');
const hours = String(today.getHours()).padStart(2, '0');
const minutes = String(today.getMinutes()).padStart(2, '0');
const seconds = String(today.getSeconds()).padStart(2, '0');
const currentDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;


const add_gddialogFormVisible = ref(false)
const add_gdscgdformData = reactive({
  重点工单: '',
  开单日期: '',
  工单编号: '',
  生产类型: '',
  客户代号: '',
  客户名称: '',
  产品代号: '',
  产品名称: '',
  印件代号: '',
  印件名称: '',
  订单数量: '',
  交货日期: '',
  投料率: '',
  平均合格率: '',
  平张投料: '',
  万小张: '',
  单位: '',
  投料大箱: '',
  库存大箱: '',
  销售订单号: '',
  警语版面: '',
  版本号: '',
  客户ERP编码: '',
  码源数量: '',
  进程备注: '',
  备注: '',
});
//清空对象的属性值
const gd_clearFormData = () => {
  Object.keys(add_gdscgdformData).forEach(key => {
    add_gdscgdformData[key] = '';
  });
};
//新增工单资料按钮
const addgd_onclick = () => {
  gd_clearFormData();
  add_gdscgdformData['重点工单'] = '打样工单';
  add_gdscgdformData['订单数量'] = 0;
  add_gdscgdformData['平张投料'] = 0;
  add_gdscgdformData['万小张'] = 0;
  add_gdscgdformData['单位'] = "张";
  add_gdscgdformData['投料大箱'] = 0;
  add_gdscgdformData['码源数量'] = 0;
  add_gdscgdformData['开单日期'] = currentDate;
  add_gddialogFormVisible.value = true
}
//新增工单资料确定
const add_gdenterDialog = async ()=>{
  console.log(add_gdscgdformData)
  if(add_gdscgdformData['工单编号'] === ''){
    ElMessage({type: 'warning',message: '工单编号为空'})
    return false;
  }
  if(add_gdscgdformData['交货日期'] === ''){
    ElMessage({type: 'warning',message: '交货日期为空'})
    return false;
  }
  const deliveryDate = new Date(add_gdscgdformData['交货日期']);
  const jhriqi = deliveryDate.getFullYear() + '-' +
      (deliveryDate.getMonth() + 1).toString().padStart(2, '0') + '-' +
      deliveryDate.getDate().toString().padStart(2, '0') + ' ' +
      deliveryDate.getHours().toString().padStart(2, '0') + ':' +
      deliveryDate.getMinutes().toString().padStart(2, '0') + ':' +
      deliveryDate.getSeconds().toString().padStart(2, '0');
  const formattedData = {
    zdgd: add_gdscgdformData['重点工单'],
    start: add_gdscgdformData['开单日期'],
    gdbh: add_gdscgdformData['工单编号'],
    sclx: add_gdscgdformData['生产类型'],
    khdh: add_gdscgdformData['客户代号'],
    khmc: add_gdscgdformData['客户名称'],
    cpdh: add_gdscgdformData['产品代号'],
    cpmc: add_gdscgdformData['产品名称'],
    yjno: add_gdscgdformData['印件代号'],
    yjmc: add_gdscgdformData['印件名称'],
    number: add_gdscgdformData['订单数量'],
    end: jhriqi,
    tll: add_gdscgdformData['投料率'],
    hgl: add_gdscgdformData['平均合格率'],
    pztl: add_gdscgdformData['平张投料'],
    wxz: add_gdscgdformData['万小张'],
    tldw: add_gdscgdformData['单位'],
    tldx: add_gdscgdformData['投料大箱'],
    kcdx: add_gdscgdformData['库存大箱'],
    xsddh: add_gdscgdformData['销售订单号'],
    jybm: add_gdscgdformData['警语版面'],
    bbh: add_gdscgdformData['版本号'],
    erp: add_gdscgdformData['客户ERP编码'],
    mysl: add_gdscgdformData['码源数量'],
    jcbz: add_gdscgdformData['进程备注'],
    remark: add_gdscgdformData['备注'],
  };
  // console.log(formattedData)
  const WorkOrderAdd_add = await WorkOrderAdd(formattedData);
  if (WorkOrderAdd_add.code === 0) {
    ElMessage({type: 'success',message: '添加成功'})
  } else {
    ElMessage({type: 'error',message: '添加失败'})
  }
  add_gddialogFormVisible.value = false
}
//新增工单资料取消
const add_gdcloseDialog = () => {
  add_gddialogFormVisible.value = false
}
//获取客户代号，客户名称
const khdhModal = ref(false)
const cpdhModal = ref(false)
const khdhDataList = ref([])
const cpdhDataList = ref([])
const khdh_keyword = ref('')
const cpdh_keyword = ref('')

//新增工单资料客户代号【回车】
const khdh_ProductValue = async (v) => {
  // console.log(khdh_keyword.value)
  await _gClientList(khdh_keyword.value)
};
//新增工单资料产品代号【回车】
const cpdh_ProductValue = async (v) => {
  // console.log(khdh_keyword.value)
  await _ProductCodeList(cpdh_keyword.value)
};
//新增工单->客户列表
const _gClientList = async (v = '')=>{
  try {
    // if(add_gdscgdformData['客户代号']){
    //   const ClientListdata = await ClientList({search: add_gdscgdformData['客户代号']});
    //   khdhDataList.value = ClientListdata.data
    // }else{
      const ClientListdata = await ClientList({search: v});
      khdhDataList.value = ClientListdata.data
    // }
  } catch (error) {
    console.error(error);
  }
}
//新增工单->产品代号列表
const _ProductCodeList = async (v = '')=>{
  try {
    // if(add_gdscgdformData['产品代号']){
    //   const ProductCodeListdata = await ProductCodeList({cilent: add_gdscgdformData['产品代号']});
    //   cpdhDataList.value = ProductCodeListdata.data
    // }else{
      const ProductCodeListdata = await ProductCodeList({cilent: v});
      cpdhDataList.value = ProductCodeListdata.data
    // }
  } catch (error) {
    console.error(error);
  }
}

const gongdanSearchHandle = async (v, type) => {
  if (type === '客户代号') {
      await _gClientList(v)
  }
  if (type === '产品代号') {
    await _ProductCodeList(v)
  }
}
//点击客户代号
const selectGongDanNode = (node, type) => {
  if (type === '客户代号') {
    add_gdscgdformData['客户代号'] = node.客户编号
    add_gdscgdformData['客户名称'] = node.客户名称
    scgdformData.value['客户代号'] = node.客户编号
    scgdformData.value['客户名称'] = node.客户名称
    khdhModal.value = false
  }
  if (type === '产品代号') {
    add_gdscgdformData['产品代号'] = node.产品编号
    add_gdscgdformData['产品名称'] = node.产品名称
    scgdformData.value['产品代号'] = node.产品编号
    scgdformData.value['产品名称'] = node.产品名称
    cpdhModal.value = false
  }
}

//新增工单资料弹窗 键盘 input框跳转
const add_gdzlent = async (event,id1,id2,id3) => {
  if (id2 === '客户代号' && event.key==='Tab' || id2 === '客户代号' && event.key=== 'Enter') {
    await _gClientList(add_gdscgdformData['客户代号'])
    if (khdhDataList.value != null) {
      const row = khdhDataList.value.find(item => item.客户编号 === add_gdscgdformData['客户代号'])
      if (row) {
        add_gdscgdformData['客户名称'] = row.客户名称
      } else {
        khdhModal.value = true
      }
    } else {
      khdhModal.value = true
    }
  }
  if (id2 === '产品代号' && event.key==='Tab' || id2 === '产品代号' && event.key=== 'Enter') {
    await _ProductCodeList()
    cpdhModal.value = true
  }
  if(event.keyCode === 40){
    if(id3!=''){
      document.getElementById(id3).focus()
    }
  }else if (event.keyCode === 13) { // Enter 或向下箭头
    if(id3!=''){
      document.getElementById(id3).focus()
    }
  } else if (event.keyCode === 38) { // 向上箭头
    if(id1!=''){
      document.getElementById(id1).focus()
    }
  }else if (event.keyCode === 8) { // 删除箭头
    if(id1!='' && document.getElementById(id2).value==''){
      document.getElementById(id1).focus()
    }
  }else if (event.keyCode === 37) { // 向左箭头
    if(id1!='' && document.getElementById(id2).selectionStart==0){
      document.getElementById(id1).focus()
    }
  }else if (event.keyCode === 39) { // 向右箭头
    if(id3!='' && document.getElementById(id2).selectionStart == document.getElementById(id2).value.length){
      document.getElementById(id3).focus()
    }
  }
}

// =========== 新增印件资料 ===========
//默认弹窗关闭
const yjzuidahaoma = ref(0)
const add_gdyjdialogFormVisible = ref(false)
const searchModel = ref(false)
const searchZhiModel = ref(false)
const zzdhIndex = ref(null)
const getProductYjListdata = ref()
const getProductZhiListdata = ref()
const yjdh_keyword = ref('')
const zhi_keyword = ref('')

// 新增印件资料表单
const add_yjzlformdata = reactive({
  yjno: '',
  yjdh: '',
  yjmc: '',
  zzdh: '',
  zzdh1: '',
  zzdh2: '',
  zzdh3: '',
  zzdh4: '',
  zzmc: '',
  zzmc1: '',
  zzmc2: '',
  zzmc3: '',
  zzmc4: '',
  cpsl: '',
  sjtl: '',
  pztl: '',
  tlgg: '',
  klgg: '',
  hsgg: '',
  ks: '',
  ls: '',
  desc: '',
  万小张: '',
});

//清空对象的属性值
const gdyj_clearFormData = () => {
  Object.keys(add_yjzlformdata).forEach(key => {
    add_yjzlformdata[key] = '';
  });
  if (isNaN(yjzuidahaoma.value)) {
    add_yjzlformdata.yjno = 1;
  } else {
    add_yjzlformdata.yjno = yjzuidahaoma.value;
  }
  add_yjzlformdata['pztl'] = 0;
  add_yjzlformdata['ks'] = 0;
  add_yjzlformdata['ls'] = 0;
  add_yjzlformdata['万小张'] = 0;
  console.log(add_yjzlformdata.yjno)

};

//点击新增印件资料按钮
const addgdyj_onclick = () => {
  if(_Gd_gdbh.value == null){
    cgugdlist.value = false;
    ElMessage({type: 'warning',message: '请选择具体的工单后，再操作此功能' })
  }else{
    gdyj_clearFormData();
    add_gdyjdialogFormVisible.value = true
  }
}
//印件新增确定
const add_gdyjenterDialog =  async  () => {
  if(add_yjzlformdata['yjno'] === ''){
    ElMessage({type: 'warning',message: '印件号不能为空'})
    return false;
  }
  if(add_yjzlformdata['yjdh'] === ''){
    ElMessage({type: 'warning',message: '印件代号不能为空'})
    return false;
  }
  if(add_yjzlformdata['zzdh'] === ''){
    ElMessage({type: 'warning',message: '纸张编号不能为空'})
    return false;
  }
  const formattedData = {
    Yj_Gdbh: _Gd_gdbh.value,
    yj_cpdh: _Gd_cpdh.value,
    yj_Yjno: add_yjzlformdata['yjno'],
    yj_Yjdh: add_yjzlformdata['yjdh'],
    yj_yjmc: add_yjzlformdata['yjmc'],
    yj_zzdh: add_yjzlformdata['zzdh'],
    yj_zzdh1: add_yjzlformdata['zzdh1'],
    yj_zzdh2: add_yjzlformdata['zzdh2'],
    yj_zzdh3: add_yjzlformdata['zzdh3'],
    yj_zzdh4: add_yjzlformdata['zzdh4'],
    yj_zzmc: add_yjzlformdata['zzmc'],
    yj_zzmc1: add_yjzlformdata['zzmc1'],
    yj_zzmc2: add_yjzlformdata['zzmc2'],
    yj_zzmc3: add_yjzlformdata['zzmc3'],
    yj_zzmc4: add_yjzlformdata['zzmc4'],
    yj_tlgg: add_yjzlformdata['tlgg'],
    yj_klgg: add_yjzlformdata['klgg'],
    Yj_核算规格: add_yjzlformdata['hsgg'],
    yj_成品数量: add_yjzlformdata['cpsl'],
    yj_平张投料: add_yjzlformdata['pztl'],
    yj_ks: add_yjzlformdata['ks'],
    yj_ls: add_yjzlformdata['ls'],
    yj_desc: add_yjzlformdata['desc'],
    Sys_id  : "[1031/谭鸿忠]",
  };
  const PrintDetailAdd_add = await PrintDetailAdd(formattedData);
  if(PrintDetailAdd_add.code === 0) {
    ElMessage({type: 'success',message: '添加成功'})
    add_gdyjdialogFormVisible.value = false
  } else {
    ElMessage({type: 'error',message: '添加失败' })
  }
}
//印件新增取消
const add_dyjcloseDialog = () => {add_gdyjdialogFormVisible.value = false}

//印件新增【印件代码】树状图
const handleTreeData = (treeData) => {
 const data = Object.keys(treeData).map((key)=>({
   label:key,
    children: Object.keys(treeData[key]).map((keys)=>({
      label:keys,
      children:treeData[key][keys].map(item=>({
        label:`${item.物料代码} ${item.物料名称}`,
        物料代码:item.物料代码,
        物料名称:item.物料名称
      }))
    }))
  }))
  return data
}

//印件新增【纸张】树状图
const handleTreeDatas = (treeData) => {
  const data = Object.keys(treeData).map((key)=>({
    label:key,
    children: Object.keys(treeData[key]).map((keys)=>({
      label:keys,
      children:Object.keys(treeData[key][keys]).map((keyss)=>({
        label:keyss,
        children:treeData[key][keys][keyss].map(item=>({
          label:`${item.物料代码} ${item.物料名称}`,
          规格:item.规格,
          物料代码:item.物料代码,
          物料名称:item.物料名称
        }))
      }))
    }))
  }))
  return data
}

//3.4获取印件代码及名称
const _getProductYjList = async ()=>{
  try {
    const response = await getProductYjList({search:''});
    getProductYjListdata.value = handleTreeData(response.data)
  } catch (error) {
    console.error(error);
  }
}
//3.5获取纸张代号及名称
const _getProductZzList = async ()=>{
  try {
    const response = await getProductZzList({search:''});
    getProductZhiListdata.value = handleTreeDatas(response.data)
  } catch (error) {
    console.error(error);
  }
}
//3.4获取印件代码及名称
const searchHandle = async (v) => {
  const response = await getProductYjList({search:v});
  getProductYjListdata.value = handleTreeData(response.data)
}
//3.5获取纸张代号及名称
const searchZhiHandle = async(v) => {
  const response = await getProductZzList({search:v});
  getProductZhiListdata.value = handleTreeDatas(response.data)
}
//印件代码tab 点击事件
const selectNode = (v) => {
  if(v.物料名称){
    add_yjzlformdata['yjdh'] = v.物料代码
      add_yjzlformdata['yjmc'] = v.物料名称
      searchModel.value= false
  }
}
//纸张tab 点击事件
const selectZhiNode = (v) => {
  if(v.物料名称){
    if (zzdhIndex.value == 0) {
          add_yjzlformdata['zzdh'] = v.物料代码
          add_yjzlformdata['zzmc'] = v.物料名称
          add_yjzlformdata['tlgg'] = v.规格
        } else {
          add_yjzlformdata['zzdh' + zzdhIndex.value] = v.物料代码
          add_yjzlformdata['zzmc' + zzdhIndex.value] = v.物料名称
        }
    searchZhiModel.value = false
  }
}
//新增印件资料弹窗 键盘 input框跳转
const add_gdzlyjent = async (event,id1,id2,id3,idx) => {
  if (id2 === 'yjdh' && event.key==='Tab' || id2 === 'yjdh' && event.key=== 'Enter') {
    _getProductYjList();
    searchModel.value = true
  }
  if (id2 === 'zzdh' && event.key==='Tab' || id2 === 'zzdh' && event.key=== 'Enter') {
    _getProductZzList()
    searchZhiModel.value = true
    zzdhIndex.value = idx
  }
  if (id2 === 'zzdh1' && event.key==='Tab' || id2 === 'zzdh1' && event.key=== 'Enter') {
    _getProductZzList()
    searchZhiModel.value = true
    zzdhIndex.value = idx
  }
  if (id2 === 'zzdh2' && event.key==='Tab' || id2 === 'zzdh2' && event.key=== 'Enter') {
    _getProductZzList()
    searchZhiModel.value = true
    zzdhIndex.value = idx
  }
  if (id2 === 'zzdh3' && event.key==='Tab' || id2 === 'zzdh3' && event.key=== 'Enter') {
    _getProductZzList()
    searchZhiModel.value = true
    zzdhIndex.value = idx
  }
  if (id2 === 'zzdh4' && event.key==='Tab' || id2 === 'zzdh4' && event.key=== 'Enter') {
    _getProductZzList()
    searchZhiModel.value = true
    zzdhIndex.value = idx
  }
  if(event.keyCode === 40){
    if(id3!=''){
      document.getElementById(id3).focus()
    }
  }else if (event.keyCode === 13) { // Enter 或向下箭头
    if(id3!=''){
      document.getElementById(id3).focus()
    }
  } else if (event.keyCode === 38) { // 向上箭头
    if(id1!=''){
      document.getElementById(id1).focus()
    }
  }else if (event.keyCode === 8) { // 删除箭头
    if(id1!='' && document.getElementById(id2).value==''){
      document.getElementById(id1).focus()
    }
  }else if (event.keyCode === 37) { // 向左箭头
    if(id1!='' && document.getElementById(id2).selectionStart==0){
      document.getElementById(id1).focus()
    }
  }else if (event.keyCode === 39) { // 向右箭头
    if(id3!='' && document.getElementById(id2).selectionStart == document.getElementById(id2).value.length){
      document.getElementById(id3).focus()
    }
  }
}


// =========== 新增工艺资料 ===========
//默认弹窗关闭
const add_gdgydialogFormVisible = ref(false)
const add_gdgyformData = reactive({});
//清空对象的属性值
const gdgy_clearFormData = () => {
  Object.keys(add_gdgyformData).forEach(key => {
    add_gdgyformData[key] = '';
  });
};
//新增工艺资料弹窗
const addgdgy_onclick = () => {
  if(_Gd_gdbh.value == null){
    cgugdlist.value = false;
    ElMessage({
      type: 'warning',
      message: '请选择具体的工单后，再操作此功能'
    })
  }else{
    let gongxu = gytableData.value.map(item => {
      return item['印件-工序']
    })
    addGongYiRef.value.open(_Gd_gdbh.value, gongxu)
  }
}


// =========== 查改U8工单 ===========
const cgugdlist = ref(false);
const cgugdformData = reactive({
  gdbh: '',
  cpdh: '',
  gdmc: '',
});
const cgugdtableData = ref([]);
//查改U8工单【按钮】
const oneditugdclick = () => {
  if(_Gd_gdbh.value == null){
    cgugdlist.value = false;
    ElMessage({
      type: 'warning',
      message: '请选择具体的工单后，再操作此功能'
    })
  }else{
    cgugdformData['gdbh'] = _Gd_gdbh.value;
    cgugdformData['cpdh'] = _Gd_cpdh.value;
    cgugdformData['gdmc'] = _Gd_cpmc.value;
    _U8workOrder();
    cgugdlist.value = true;
  }
};

//查改U8工单【回车】
const cgugdProductValue = () => {
  _U8workOrder();
};

//查改U8工单->工单列表
const _U8workOrder = async ()=>{
  let workOrder = cgugdformData['gdbh'];
  // console.log(workOrder)
  try {
    const U8workOrderdata = await U8workOrder({workOrder:workOrder});
    cgugdtableData.value = U8workOrderdata.data;
  } catch (error) {
    console.error(error);
  }
}

// 多选数据
const multipleSelection = ref([]);

// 多选
const cguzlgd_del = (val) => {
  if (Array.isArray(val) && val.length === 0) {
    multipleSelection.value = [];
  } else {
    multipleSelection.value = [];
    multipleSelection.value.push(...val.map(item => item.序号));
  }
}

//查改U8工单（工单删除）
const oncgugdclickdel = async ()=>{
  const Uniqid = multipleSelection.value.join(',');
  // console.log(Uniqid)
  try {
    const U8DataCorrection_del = await U8DataCorrection({Uniqid:Uniqid});
    if (U8DataCorrection_del.code === 0) {
      multipleSelection.value = [];
      ElMessage({type: 'success',message: '删除成功'})
      const U8workOrderdata = await U8workOrder({workOrder:cgugdformData['gdbh']});
      cgugdtableData.value = U8workOrderdata.data;
    } else {
      ElMessage({type: 'error',message: '删除失败'})
    }
    // 清空 multipleSelection 为空数组，只有在处理完数据后清空
  } catch (error) {
    console.error(error);
  }
}

//查改U8工单【退出】
const oncgugdcloneclick = () => {
  cgugdlist.value = false;
};

// =========== 工艺流程调整 ===========
const gylctztableColumns = ref(
    [
      { label: '方案', prop: '方案', width: '60' },
      { label: '印件号', prop: '印件号', width: '70' },
      { label: '工序号', prop: '工序号', width: '80' },
      { label: '工序名称', prop: '工序名称', width: '440' },
      { label: '工价系数', prop: '工价系数', width: '100' },
      { label: '损耗系数', prop: '损耗系数', width: '100' },
      { label: '开数', prop: 'ks', width: '60' },
      { label: '联数', prop: 'ls', width: '60' },
      { label: '备注', prop: '备注', width: '200' },
      { label: '车间', prop: '车间', width: '90' },
      { label: '设备编号', prop: '设备编号', width: '100' },
      { label: '设备名称', prop: '设备名称', width: '100' },
      { label: '建档用户', prop: '建档用户', width: '100' },
      { label: '建档时间', prop: '建档时间', width: '160' },
      { label: '更新时间', prop: '更新时间', width: '160' },
    ]
)
const gylctz_handleKeyDown = (event, x, y, prop) => {
  const currentElement = document.getElementById(`input${x}${y}`);
  if (currentElement === null && currentElement === undefined) return
  switch (event.keyCode) {
    case 13: // Enter
    case 40: // 向下箭头
      if (y < gylctztableData.value.length )
        document.getElementById(`input${x}${y + 1}`).focus();
      break;
    case 38: // 向上箭头
      if ( y > 0) {
        document.getElementById(`input${x}${y - 1}`).focus();
      }
      break;
    default:
      break;
  }
}
const gylctzlist = ref(false);
const gylctzformData = reactive({
  gdbh: '',
  gddh: '',
  gdmc: '',
});
const gylctztableData = ref([]);
//工艺流程调整【按钮】
const oneditgylctzclick = () => {
  if(_Gd_gdbh.value == null){
    gylctzlist.value = false;
    ElMessage({type: 'warning',message: '请选择具体的工单后，再操作此功能'})
  }else{
    gylctzformData['gdbh'] = _Gd_gdbh.value;
    _ProcessFlow();
    gylctzlist.value = true;
  }
};
////工艺流程调整【回车】
const gylctzProductValue = () => {
  _ProcessFlow();
};

// 工艺流程调整->获取当前工单工艺资料
const _ProcessFlow = async ()=>{
  let workOrder = gylctzformData['gdbh'];
  try {
    const ProcessFlowdata = await ProcessFlow({workOrder:workOrder});
    gylctzformData["gddh"] = ProcessFlowdata.data.成品编号;
    gylctzformData["gdmc"] = ProcessFlowdata.data.成品名称;
    gylctztableData.value = ProcessFlowdata.data.process;
  } catch (error) {
    console.error(error);
  }
}
//附加标准工序【按钮】
const gdzlfjxx = ref(false);
const gdzlfjxxformData = reactive({
  gdbh: '',
  cpmc: '',
  // 下拉框选项数据
  cpgyfans: [],
  // 设置默认值
  cpgyfan: '',
});
//点击下拉框获取输入框的值
const ongdzlfanclick = () => {
  const workOrder = gdzlfjxxformData.cpgyfan;
  _ProcessFlow_xiala(workOrder);
}
// 工艺流程调整->获取当前工单工艺资料
const gdzlfjxxtableData = ref([]);
const _ProcessFlow_xiala = async (workOrder)=>{
  try {
    const ProcessFlow_xiala = await ProcessFlow({ workOrder });
    if (ProcessFlow_xiala.data) {
      gdzlfjxxtableData.value = ProcessFlow_xiala.data.process;
    } else {
      console.log("工艺流程调整->获取当前工单工艺资料 中缺少 data 属性");
    }
  } catch (error) {
    console.error(error);
  }
}
//工艺方案附加【下拉框工单编号数据】
const attachList = ref([])
const attachChange = (val) => {
  attachList.value = val
}
//工艺方案附加【执行】
const addGongyiAttach = () => {
  attachList.value.map(row => gylctztableData.value.push(row))
  gdzlfjxx.value = false
}
const gdzlfjxxtableColumns = ref(
    [
      { label: '方案', prop: '方案', width: '60' },
      { label: '印件号', prop: '印件号', width: '70' },
      { label: '工序号', prop: '工序号', width: '70' },
      { label: '工序名称', prop: '工序名称', width: '370' },
      { label: '工价系数', prop: '工价系数', width: '87' },
      { label: '损耗系数', prop: '损耗系数', width: '87' },
      { label: '开数', prop: 'ks', width: '65' },
      { label: '联数', prop: 'ls', width: '65' },
      { label: '备注', prop: '备注', width: '240' },
      { label: '车间', prop: '车间', width: '105' },
      { label: '设备编号', prop: '设备编号', width: '100' },
      { label: '设备名称', prop: '设备名称', width: '100' },
      { label: '建档用户', prop: '建档用户', width: '100' },
      { label: '建档时间', prop: '建档时间', width: '160' },
      { label: '更新时间', prop: '更新时间', width: '160' },
    ]
)
//工艺方案附加【放弃】
const gylcfj_fangqi = () => {
  gdzlfjxx.value = false
}

//点击附加标准工序【按钮】
const gylctz_fjbzgx = async () => {
  gdzlfjxxformData['cpdh'] = gylctzformData['gddh'];
  gdzlfjxxformData['cpmc'] = gylctzformData['gdmc'];
  gdzlfjxxtableData.value = [];
  await _ReferenceWorkOrder();
  gdzlfjxx.value = true;
};
// 工艺流程调整->参照工单列表获取【展示下拉框的数据】
const _ReferenceWorkOrder = async ()=>{
  let params = {};
  params.productCode = gylctzformData['gddh'];
  params.workOrder = _Gd_gdbh.value;
  try {
    const ReferenceWorkOrder_data = await ReferenceWorkOrder(params);
    if(ReferenceWorkOrder_data.code === 0){
      // 从数据中提取方案
      const schemes = ReferenceWorkOrder_data.data || [];
      // 直接将数组作为工艺方案数组
      gdzlfjxxformData.cpgyfans = schemes;
      if (gdzlfjxxformData.cpgyfans.length > 0) {
        gdzlfjxxformData.cpgyfan = [gdzlfjxxformData.cpgyfans[0]];
      }
      //默认获取下拉框第一个值
      const workOrder = gdzlfjxxformData.cpgyfan[0]
      gdzlfjxxformData.cpgyfan = gdzlfjxxformData.cpgyfans[0]
      _ProcessFlow_xiala(workOrder)
    }else{
      console.log("该产品下没有工单")
    }
  } catch (error) {
    console.error(error);
  }
}

//更新当前产品工序【按钮】
const gylctz_gxdqcpgx = async () => {
  console.log(gylctztableData)
  const rawValueArray = gylctztableData.value;
  const formattedData = rawValueArray.map(item => {
    return {
      workOrder:gylctzformData['gdbh'],
      UniqId:item.UniqId,
      gxh:item['工序号']
    }
  });
  const ProcessCopy_edit = await ProcessCopy(formattedData);
  if(ProcessCopy_edit.code === 0) {
    ElMessage({type: 'success',message: '更新成功'})
  } else {
    ElMessage({type: 'error',message: '更新失败' })
  }
  gylctzlist.value = false;
};

//放弃操作【按钮】
const gylctzhandleCancel = () => {
  gylctzlist.value = false;
};

// =========== 工序产量核算 ===========
const gxclhslist = ref(false);
const gxclhsformData = reactive({
  gdbh: '',
});
//工序产量核算【按钮】
const oneditgxclhsclick = () => {
  if(_Gd_gdbh.value == null){
    gxclhslist.value = false;
    ElMessage({type: 'warning',message: '请选择具体的工单后，再操作此功能'})
  }else{
    gxclhsformData['gdbh'] = _Gd_gdbh.value;
    gxclhslist.value = true;
  }
};
//工序产量核算【确定】(未完成)
const gxclhshandleConfirm = async () => {
  console.log(gxclhsformData['gdbh'])
  // const  = await ({:gxclhsformData['gdbh']});
  // if (.code === 0) {
  //   ElMessage({type: 'success', message: '更新成功'})
  // } else {
  //   ElMessage({type: 'error',message: '更新失败'})
  // }
  // gxclhslist.value = false;
};
//工序产量核算【取消】
const gxclhshandleCancel = () => {gxclhslist.value = false;};
// =========== U8投料试算 ===========
const tlsslist = ref(false);
const tlsstableData = ref([]);
const tlssformData = reactive({
  cpdh: '',
  cpmc: '',
  cpzs: '',
  zytldzs: '',
  mbhgl: '',
  shs: '',
});
//点击U8投料试算【按钮】
const ontlssclick = () => {
  //工单编号
  if(_Gd_gdbh.value == null){
    tlsslist.value = false;
    ElMessage({
      type: 'warning',
      message: '请选择具体的工单后，再操作此功能'
    })
  }else{
    // //产品代号
    if( _Gd_cpdh.value === ''){
      tlsslist.value = false;
      ElMessage({
        type: 'warning',
        message: '该产品号未查询到'
      })
    }else{
      tlssformData['cpdh'] =  _Gd_cpdh.value;
      // tlssformData['cpdh'] =  '100401101';
      tlssformData['cpmc'] = _Gd_cpmc.value;
      tlsslist.value = true;
      _U8Trial();
    }
  }
};
//点击U8投料试算【回车】
const tlssgetProductValue = async () => {
  _U8Trial();
};
//点击U8投料试算【成品张数回车】
const tlsscpzsgetProductValue = async () => {
  console.log("成品张数回车")
};
//U8投料试算
const _U8Trial = async ()=>{
  let productCode = tlssformData['cpdh'];
  try {
    const U8Trialdata = await U8Trial({productCode:productCode});
    tlsstableData.value = U8Trialdata.data;
  } catch (error) {
    console.error(error);
  }
}
//U8投料试算【退出】
const oncloneclick = () => {tlsslist.value = false;};

// =========== 引用产品资料 ===========
const yycpzlformData = reactive({
  gdbh: '',
  khdh: '',
  khmc: '',
  cpdh: '',
  cpmc: '',
  yjzl:true,
  gyap: true,
  gyfa: '',
});
const onyycpzllist = ref(false);
//引用产品资料【按钮】
const onyycpzlclick = () => {
  if(_Gd_gdbh.value == null){
    onyycpzllist.value = false;
    ElMessage({type: 'warning',message: '请选择具体的工单后，再操作此功能'})
  }else{
    yycpzlformData['gdbh'] = _Gd_gdbh.value;
    _ProductInformations();
    onyycpzllist.value = true;
  }
};
//引用产品资料【回车】
const yycpzlProductValue = async () => {
  _ProductInformations();
};
//引用产品资料->获取产品资料
const _ProductInformations = async ()=>{
  let workOrder = yycpzlformData['gdbh'];
  // try {
  const ProductInformations = await ProductInformation({workOrder:workOrder});
  if(ProductInformations.msg === '未找到工单信息'){
    yycpzlformData['khdh'] = '';
    yycpzlformData['khmc'] = '';
    yycpzlformData['cpdh'] = '';
    yycpzlformData['cpmc'] =  '';
    ElMessage({type: 'warning',message: '未找到工单信息'})
    return false;
  }else{
    yycpzlformData['gdbh'] = ProductInformations.data['工单编号'];
    yycpzlformData['khdh'] = ProductInformations.data['客户代号'];
    yycpzlformData['khmc'] = ProductInformations.data['客户名称'];
    yycpzlformData['cpdh'] = ProductInformations.data['产品代号'];
    yycpzlformData['cpmc'] = ProductInformations.data['产品名称'];
  }

  // } catch (error) {
  //   console.error(error);
  // }
}
//引用产品资料【执行】
const yycpzlhandleConfirm = async () => {
  _ProductInformationEdit();
};
//引用产品资料->获取产品资料
const _ProductInformationEdit = async ()=>{
  let params = {}
  params.oldWorkOrder = _Gd_gdbh.value;
  params.newWorkOrder = yycpzlformData['gdbh'];
  try {
    const ProductInformationEditdata = await ProductInformationEdit(params);
    if (ProductInformationEditdata.code === 0) {
      ElMessage({type: 'success', message: '更新成功'})
    } else {
      ElMessage({type: 'error',message: '更新失败'})
    }
  } catch (error) {
    console.error(error);
  }
  onyycpzllist.value = false;
}
//引用产品资料【放弃】
const yycpzlhandleCancel = () => {onyycpzllist.value = false;};

// =========== 左侧树侧形结构 ===========
const treeData = reactive({data:[]});
// const treeData = ref({})
const defaultProps = {
  children: 'children',
  label: 'label'
};
//工单资料菜单列表
const DataListdata = async () => {
  try {
    const data = await DataList();
    for (let key in data.data) {
      // 忽略 "productingAll" 和 "progressAll"
      if (key !== "productingAll" && key !== "progressAll") {
        let temp = data.data[key];
        let object = {};
        object.id = temp[0];
        object.label = data.data[key];
        object.children = [];
        treeData.data.push(object);
      }
    }
  } catch (error) {
    console.error(error);
  }
};
DataListdata();

//点击左侧树形获取编号
const tableData = reactive([])
const _Gd_khdh = ref(null)
const handleNodeClick = async (node) => {
  searchInfo.value = '';
  gytableData.value = [];
  yjtableData.value = [];
  bomtableData.value = [];
  _Gd_khdh.value = node.label.substring(0, 4);
  _WorkList_page();
};
//工单资料
const _WorkList_page = async () => {
  try {
    const WorkListdata = await WorkList({Gd_khdh:_Gd_khdh.value,limit:pageSize.value,page:page.value});
    tableData.splice(0,tableData.length,...WorkListdata.data.data);//表格数据
    total.value =WorkListdata.data.total;//共多少条
  } catch (error) {
    console.error(error);
  }
};

//查询
const searchInfo = ref('')
//查询按钮
const onSubmit = () => {
  _cha_WorkList();
};
const _cha_WorkList = async (node) => {
  if(searchInfo.value === ''){
    ElMessage({type: 'warning',message: '请输入搜索的信息'})
    return false;
  }
  const search = searchInfo.value;
  try {
    const WorkListdata = await WorkList({ search:search,limit:1,page:1});//接口调用函数
    if(WorkListdata.data.total === 0){
      ElMessage({type: 'warning',message: '未搜索具体查询条件'})
    }
    tableData.splice(0,tableData.length,...WorkListdata.data.data);//表格数据
    total.value = WorkListdata.data.total;//共多少条
  } catch (error) {
    console.error(error);
  }
};

// 分页
const page = ref(1)
const total = ref(0)
const pageSize = ref(50)
const handleCurrentChange = (val) => {
  page.value = val;
  _WorkList_page();
};

// 修改页面容量 点击多少条/页
const handleSizeChange = (val) => {
  // page.value = 10;
  pageSize.value = val;
  _WorkList_page();
};

//点击表格行获取下方表格数据列表
//印件资料
const yjtableData = ref([])
//工艺资料
const gytableData = ref([])
//BOM资料
const bomtableData = ref([])
//全局调用工单编号
const _Gd_gdbh = ref(null)
//全局调用产品代号
const _Gd_cpdh = ref(null)
//全局调用产品名称
const _Gd_cpmc = ref(null)
//工单印件、工艺、BOM详情
const tableRowClick = async (row) => {
  _Gd_gdbh.value = row.工单编号;
  _Gd_cpdh.value = row.产品代号;
  _Gd_cpmc.value = row.产品名称;
  const workOrderListDetail_data = await workOrderListDetail({Gd_gdbh:_Gd_gdbh.value});
  yjtableData.value = workOrderListDetail_data.data.printList;
  gytableData.value = workOrderListDetail_data.data.processList;
  bomtableData.value = workOrderListDetail_data.data.BOM;
  let tmp = yjtableData.value.map(item => item.印件号)
  tmp = tmp.sort((a,b)=>b-a)
  yjzuidahaoma.value = Number(tmp[0]) + 1
};

// // 多选数据
// const multipleSelection = ref([])
// // 多选
// const handleSelectionChange = (val) => {
//   multipleSelection.value = val
// }

// 行为控制标记（弹窗内部需要增还是改）
const type = ref('')

//=========表格列表修改========
let scgdformData = ref({})
//双击修改
const updateCompanyFunc = async(row) => {
  console.log(row['工单编号'])
  // if(row['status'] === '*'){
  //   ElMessage({ type: 'warning', message: '未找到该工单印件资料' });
  //   return false;
  // }else{
    const DataCorrection_list = await DataCorrection({ Gd_gdbh:row['工单编号']});
    console.log(DataCorrection_list)
    scgdformData.value = DataCorrection_list.data;
    dialogFormVisible.value = true
  // }
}
// 弹窗控制标记
const dialogFormVisible = ref(false)
// 弹窗确定
const enterDialog = async () => {
  const zdgx = /^[A-Za-z0-9\u4e00-\u9fa5\s]*$/.test(scgdformData.value['重点工单']);
  if (!zdgx) {
    ElMessage({ type: 'warning', message: '重点工单数据中 只允许出现中文、数字、空格' });
    return false;
  }
  const formattedData = {
    lx: scgdformData.value['重点工单'],
    kdrq: scgdformData.value['开单日期'],
    gdbh: scgdformData.value['工单编号'],
    scfl: scgdformData.value['生产类型'],
    khdh: scgdformData.value['客户代号'],
    khmc: scgdformData.value['客户名称'],
    cpdh: scgdformData.value['产品代号'],
    cpmc: scgdformData.value['产品名称'],
    ddsl: scgdformData.value['订单数量'],
    jhrq: scgdformData.value['交货日期'],
    tll: scgdformData.value['投料率'],
    jhtl: scgdformData.value['平张投料'],
    sjtl: scgdformData.value['万小张'],
    jldw: scgdformData.value['单位'],
    tldx: scgdformData.value['投料大箱'],
    xsddh: scgdformData.value['销售订单号'],
    jymb: scgdformData.value['警语版面'],
    bbh: scgdformData.value['版本号'],
    erp: scgdformData.value['客户ERP编码'],
    ymsl: scgdformData.value['码源数量'],
    jcbz: scgdformData.value['进程备注'],
    desc: scgdformData.value['备注'],
    Uniqid: scgdformData.value['Uniqid'],
    yjdh: scgdformData.value['印件代号'],
    yjmc: scgdformData.value['印件名称'],
    kc: scgdformData.value['库存大箱'],
    avg:scgdformData.value['平均合格率'] === undefined ? '' : scgdformData.value['平均合格率'],
    printID: scgdformData.value['印件ID'],
  };
  const WorkOrderEdit_edit = await WorkOrderEdit(formattedData);
  if (WorkOrderEdit_edit.code === 0) {
    dialogFormVisible.value = false
    ElMessage({type: 'success',message: '更新成功' })
  } else {
    ElMessage({type: 'error', message: '更新失败'})
  }
}
// 关闭弹窗
const closeDialog = () => {dialogFormVisible.value = false}

//=========印件列表修改========
// 弹窗控制标记
const gdyjdialogFormVisible = ref(false)
const gdyjformData = reactive({})
//双击打开印件列表修改
const gdyjupdateCompanyFunc = async(row) => {
  gdyjformData['开数'] = row['开数'];
  gdyjformData['联数'] = row['联数'];
  Object.assign(gdyjformData,row);
  gdyjdialogFormVisible.value = true
}
//印件列表修改【确定】
const gdyjenterDialog = async () => {
  const formattedData = {
    Uniqid: gdyjformData['Uniqid'],
    yjno: gdyjformData['印件号'] ? gdyjformData['印件号'] : "",
    yjdh: gdyjformData['印件代号'] ? gdyjformData['印件代号'] : "",
    yjmc: gdyjformData['印件名称'] ? gdyjformData['印件名称'] : "",
    zzdh:gdyjformData['纸张代号'] ? gdyjformData['纸张代号'] : "",
    zzmc:gdyjformData['纸张名称'] ? gdyjformData['纸张名称'] : "",
    zzdh1:gdyjformData['zzdh1'] ? gdyjformData['zzdh1'] : "",
    zzdh2:gdyjformData['zzdh2'] ? gdyjformData['zzdh2'] : "",
    zzdh3:gdyjformData['zzdh3'] ? gdyjformData['zzdh3'] : "",
    zzdh4:gdyjformData['zzdh4'] ? gdyjformData['zzdh4'] : "",
    zzmc1:gdyjformData['zzmc1'] ? gdyjformData['zzmc1'] : "",
    zzmc2:gdyjformData['zzmc2'] ? gdyjformData['zzmc2'] : "",
    zzmc3:gdyjformData['zzmc3'] ? gdyjformData['zzmc3'] : "",
    zzmc4:gdyjformData['zzmc4'] ? gdyjformData['zzmc4'] : "",
    cpsl:gdyjformData['订单数量'] ? gdyjformData['订单数量'] : "",
    pztl:gdyjformData['平张投料'] ? gdyjformData['平张投料'] : "",
    sjtl:gdyjformData['万小张'] ? gdyjformData['万小张'] : "",
    tlgg:gdyjformData['投料规格'] ? gdyjformData['投料规格'] : "",
    klgg:gdyjformData['开料规格'] ? gdyjformData['开料规格'] : "",
    ks:gdyjformData['开数'] ? gdyjformData['开数'] : "",
    ls:gdyjformData['联数'] ? gdyjformData['联数'] : "",
    hsgg:gdyjformData['核算规格'] ? gdyjformData['核算规格'] : "",
    desc:gdyjformData['备注'] ? gdyjformData['备注'] : "",
  };
  const PrintedEdit_edit = await PrintedEdit(formattedData);
  if (PrintedEdit_edit.code === 0) {
    gdyjdialogFormVisible.value = false
    ElMessage({type: 'success',message: '更新成功' })
  } else {
    ElMessage({type: 'error', message: '更新失败'})
  }
}
// 印件列表修改【关闭弹窗】
const gdyjcloseDialog = () => {
  gdyjdialogFormVisible.value = false
}
//修改印件表格input
const edit_gdyjent = (event,id1,id2,id3) => {
  // console.log(event.keyCode)
  if(event.keyCode === 40){
    if(id3!=''){
      document.getElementById(id3).focus()
    }
  }else if (event.keyCode === 13) { // Enter 或向下箭头
    if(id3!=''){
      document.getElementById(id3).focus()
    }
  } else if (event.keyCode === 38) { // 向上箭头
    if(id1!=''){
      document.getElementById(id1).focus()
    }
  }else if (event.keyCode === 8) { // 删除箭头
    if(id1!='' && document.getElementById(id2).value==''){
      document.getElementById(id1).focus()
    }
    // console.log(document.getElementById(id2).value)
  }else if (event.keyCode === 37) { // 向左箭头
    if(id1!='' && document.getElementById(id2).selectionStart==0){
      document.getElementById(id1).focus()
    }
  }else if (event.keyCode === 39) { // 向右箭头
    if(id3!='' && document.getElementById(id2).selectionStart == document.getElementById(id2).value.length){
      document.getElementById(id3).focus()
    }
  }
}


//=========工艺修改========
const gdgydialogFormVisible = ref(false)
const gdgyformData = reactive({})
const gdzl_MachineList_address = reactive({
  data: []
});
const _cjmc = ref(null);
//双击修改
const gdgyupdateCompanyFunc = async(row) => {
  gdgyformData['设备编号'] = [];
  if(row['车间名称']){
    _cjmc.value = row['车间名称']
  }else{
    _cjmc.value = '';
  }
  //通过车间名称查询机台
  const MachineList_jitai = await gdzl_MachineList({address:_cjmc.value});
  gdzl_MachineList_address.data = MachineList_jitai.data;

  // 示例字符串
  const processName = row['工序名称'];
  // 初始化工艺名称和工序名称
  let technologyName = '';
  let operationName = '';
  // 检查字符串中是否包含【】
  const bracketIndex = processName.indexOf('【');
  if (bracketIndex !== -1) {
    // 如果包含【】，则分割字符串
    technologyName = processName.substring(0, bracketIndex).trim();
    operationName = processName.substring(bracketIndex + 1, processName.indexOf('】')).trim();
  } else {
    // 如果没有【】，则整个字符串是工艺名称，工序名称为空
    technologyName = processName.trim();
  }

  // 示例字符串
  const printProcess = row['印件-工序'];
  // 初始化印件和工序
  let yinjian = '';
  let gongxu = '';
  // 检查字符串中是否包含 "-"
  const dashIndex = printProcess.indexOf('-');
  if (dashIndex !== -1) {
    // 如果包含 "-"，则分割字符串
    yinjian = printProcess.substring(0, dashIndex).trim();
    gongxu = printProcess.substring(dashIndex + 1).trim();
  } else {
    // 如果没有 "-"，则整个字符串是印件，工序为空
    yinjian = printProcess.trim();
  }
  gdgyformData['印件'] = yinjian;
  gdgyformData['工序'] = gongxu;
  gdgyformData['工艺名称'] = technologyName;
  gdgyformData['工序名称'] = operationName;

  Object.assign(gdgyformData,row);
  gdgydialogFormVisible.value = true
}

//工艺列表修改【确定】
const gdgyenterDialog = async () => {
  if(_Gd_gdbh.value){
    const selectedValuesAsString = gdgyformData['设备编号'].join(' ');
    if(gdgyformData['shdh'] === ''){
      ElMessage({type: 'warning', message: '工序损耗不能为空'})
      return false;
    }
    if(gdgyformData['小时产能'] === '' || gdgyformData['小时产能'] === "0"){
      ElMessage({type: 'warning', message: '排产小时产能 不能为空或0'})
      return false;
    }
    if(gdgyformData['设备编号'] === '' || gdgyformData['设备编号'] === "0"){
      ElMessage({type: 'warning', message: '设备编号 不能为空'})
      return false;
    }
    const formattedData = {
      sbbh: selectedValuesAsString ? selectedValuesAsString : "",
      shdh: gdgyformData['shdh'] ? gdgyformData['shdh'] : "",
      shxs:gdgyformData['损耗系数'] ? gdgyformData['损耗系数'] : "",
      ndxs:gdgyformData['难度系数'] ? gdgyformData['难度系数'] : "",
      zdgx: gdgyformData['重点工序'] ? gdgyformData['重点工序'] : "",
      xscn: gdgyformData['小时产能'] ? gdgyformData['小时产能'] : "",
      bxgx: gdgyformData['备选工序'] ? 1 : "",
      UniqId: gdgyformData['UniqId'],
      workOrder: _Gd_gdbh.value,
    };
    const ProcessDetailEdit_edit = await ProcessDetailEdit(formattedData);
    if (ProcessDetailEdit_edit.code === 0) {
      gdgydialogFormVisible.value = false
      ElMessage({type: 'success',message: '更新成功' })
    } else {
      ElMessage({type: 'error', message: '更新失败'})
    }
  }else{
    ElMessage({type: 'error', message: '更新失败'})
  }
  gdgyformData['设备编号'] = [];
}

//工艺列表修改【关闭弹窗】
const gdgycloseDialog = () => {
  gdgyformData['设备编号'] = [];
  gdgydialogFormVisible.value = false
}

//点击设备编号
const _capacityListsbbh = ref(null)
const sbbhclick = () => {
  _capacityList();
}


const _capacityList = async () => {
  if(gdgyformData['设备编号'] === ''){
    return false;
  }else{
    _capacityListsbbh.value = gdgyformData['设备编号'].join(' ');
    const editProductedit_machine = await capacityList({machine:_capacityListsbbh.value});
    gdgyformData['小时产能'] = editProductedit_machine.data;
  }

};

//截取印件前两位
const clickybupdate2 = (row,column,event) => {
  currentGy0_yjno.value = row['印件-工序'].substr(0, 2)
}


//===============颜色==================================
//工艺资料背景颜色变黄
const currentGy0_yjno = ref(null)
const rowClassStyle2 = ({row,rowIndex}) =>{
  if(row['印件-工序'].substr(0, 2)==currentGy0_yjno.value){
    return "warning-row"
  }
  return "warning-row"
}
//表格文字颜色
const tableDataCellClass = ({row, column, rowIndex, columnIndex}) =>{
  if (column.property === '订单数量') {
    return 'plan-usage-low';
  }
}
//工艺流程调整颜色
const gylctzCellClass = ({row, column, rowIndex, columnIndex}) =>{
  if (column.label === '工序号') {
    return 'background-plan-usage-low';
  }
}
//修正核算参数颜色
const sxzhscsCellClass = ({row, column, rowIndex, columnIndex}) =>{
  if (column.label === '新难度系数' || column.label === '新损耗代号' || column.label === '新印刷方式' || column.label === '新来版距' || column.label === '新计损色数'  || column.label === '新损耗系数') {
    return 'background-plan-usage-low';
  }
}
//质检废品系数颜色
const scfjfpxsCellClass = ({row, column, rowIndex, columnIndex}) =>{
  if (column.label === '人工正品板' || column.label === '人工次品板' || column.label === '人工废检' || column.label === '机检正品板' || column.label === '机检次品板'  || column.label === '机检废检') {
    return 'background-plan-usage-low';
  }
}
//根据工艺状态文字颜色
const gysatusCellClass = ({row, column, rowIndex, columnIndex}) =>{
  if(row['status'] === '未完工'){
    return 'status-plan-usage-low';
  }
  if(row['status'] === '已完工'){
    return 'statusy-plan-usage-low';
  }
}
//bom颜色
const planUsageCellClass = ({row, column, rowIndex, columnIndex}) =>{
  if (column.property === '计划用量') {
    return 'plan-usage-low';
  }
}

//工艺文字变色
// const planUsageCellClass = ({row, column, rowIndex, columnIndex}) =>{
//   if (column.property === '计划用量') {
//     return 'plan-usage-low';
//   }
// }

//修改工单资料弹窗 键盘 input框跳转
const gdzlent =async (event,id1,id2,id3) => {
  if (id2 === '客户代号' && event.key==='Tab') {
    await _gClientList(scgdformData.value['客户代号'])
    if (khdhDataList.value != null) {
      const row = khdhDataList.value.find(item => item.客户编号 === scgdformData.value['客户代号'])
      if (row) {
        scgdformData.value['客户名称'] = row.客户名称
      } else {
        khdhModal.value = true
      }
    } else {
      khdhModal.value= true
    }
  }
  if (id2 === '产品代号' && event.key==='Tab') {
    await _ProductCodeList()
    cpdhModal.value = true
  }
  if (event.keyCode === 13 || event.keyCode === 40) { // Enter 或向下箭头
    if(id3!=''){
      document.getElementById(id3).focus()
    }
  } else if (event.keyCode === 38) { // 向上箭头
    if(id1!=''){
      document.getElementById(id1).focus()
    }
  }else if (event.keyCode === 8) { // 删除箭头
    if(id1!='' && document.getElementById(id2).value==''){
      document.getElementById(id1).focus()
    }
    // console.log(document.getElementById(id2).value)
  }else if (event.keyCode === 37) { // 向左箭头
    if(id1!='' && document.getElementById(id2).selectionStart==0){
      document.getElementById(id1).focus()
    }
  }else if (event.keyCode === 39) { // 向右箭头
    if(id3!='' && document.getElementById(id2).selectionStart == document.getElementById(id2).value.length){
      document.getElementById(id3).focus()
    }
  }
}

//修改工艺资料弹窗 键盘 input框跳转
const gyzlent = (event,id1,id2,id3) => {
  if (event.keyCode === 13 || event.keyCode === 40) { // Enter 或向下箭头
    if(id3!=''){
      document.getElementById(id3).focus()
    }
  } else if (event.keyCode === 38) { // 向上箭头
    if(id1!=''){
      document.getElementById(id1).focus()
    }
  }else if (event.keyCode === 8) { // 删除箭头
    if(id1!='' && document.getElementById(id2).value==''){
      document.getElementById(id1).focus()
    }
    // console.log(document.getElementById(id2).value)
  }else if (event.keyCode === 37) { // 向左箭头
    if(id1!='' && document.getElementById(id2).selectionStart==0){
      document.getElementById(id1).focus()
    }
  }else if (event.keyCode === 39) { // 向右箭头
    if(id3!='' && document.getElementById(id2).selectionStart == document.getElementById(id2).value.length){
      document.getElementById(id3).focus()
    }
  }
}

const yjSelection = ref('')
const gySelection = ref('')
const selectionChange = (selection, type) => {
  const ids = selection.map(item => {
    return type === '印件资料' ? item.Uniqid: item.UniqId
  })
  if (type === '印件资料') {
    yjSelection.value = ids.join(',')
  }
  if (type === '工艺资料') {
    gySelection.value = ids.join(',')
  }
}

// ===========删除印件资料、工艺资料 ===========
const delgd_delclick = async () => {
  if (yjSelection.value !== '') {
    try {
      const res1 = await PrintDetailDel({UniqId: yjSelection.value})
      res1.code === 0 && ElMessage.success('印件资料删除成功')
    } catch(err) {
      ElMessage.error(err)
    }
  }
  if (gySelection.value !== ''){
    try {
      const res2 = await ProcessDetailDel({UniqId: gySelection.value})
      res2.code === 0 && ElMessage.success('工艺资料删除成功')
    } catch(err) {
      ElMessage.error(err)
    }
  }

  const workOrderListDetail_data = await workOrderListDetail({Gd_gdbh:_Gd_gdbh.value});
  yjtableData.value = workOrderListDetail_data.data.printList;
  gytableData.value = workOrderListDetail_data.data.processList;
  bomtableData.value = workOrderListDetail_data.data.BOM;
}

</script>
<style scoped>
/* 在样式表中使用媒体查询 */
@media (max-width: 768px) {
  /* 在小屏幕下的样式设置 */
  .dialog-footer {
    text-align: center;
  }
}
/*工序产量核查*/
:deep(.gxclhc—color-column-red div) {
  color: red !important;
}
:deep(.lan-plan-usage-lows div) {
  color: blue !important;
  font-weight: bold;
}
:deep(.lan-plan-usage-lowshui div) {
  color: #8c939d !important;
}

/*背景颜色*/
/*印件背景颜色变黄*/
:deep(.el-table__body .warning-row) {
  background: #FFFF80 !important;
}
/*修正工单核算参数背景*/
:deep(.el-table__body .background-plan-usage-low div div div) {
  background: #80FA80 !important;
}
/* 选中某行时的背景色 */
:deep(.el-table__body tr.current-row) > td {
  background: #ff80ff !important;
}
/*文字颜色*/
/*bom计划用量文字变色【表格中单独文字变色】*/
:deep(.plan-usage-low div) {
  color: red !important;
}
/*根据工艺状态文字变色*/
:deep(.status-plan-usage-low div) {
  color: blue !important;
}
:deep(.statusy-plan-usage-low div) {
  color: #8c939d !important;
}
/* 在样式表中添加以下样式 */
.el-input__textarea {
  resize: none; /* 禁止调整大小 */
}
.JKWTree-container {
  display: flex;
}
.JKWTree-tree {
  width: 300px;
  background-color: #fff;
  padding: 10px;
  margin-right: 20px;
}
.JKWTree-tree h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 10px 0;
}
.JKWTree-content {
  flex: 1;
}
/*关闭拖拽功能*/
.el-textarea textarea {
  resize: none !important;
}

</style>
<style scoped>
:deep(.el-table td .cell) {
  line-height: 20px !important;
}
:deep(.el-tabs__header){
  margin-bottom: 0;
}
.search{
  margin-left: 0px !important;
  margin-right: 10px !important;
}
.bt{
  margin-left: 2px !important;
  padding: 3px !important;
  font-size: 12px;
}
.el-tabs__header{
  margin: 0px !important;
}
.gva-table-box{
  padding: 0px !important;
}
.el-pagination{
  margin-top: 0px !important;
}
.mab{
  margin-bottom: 5px;
}

</style>
