<template>
  <div>
    <layout>
      <layout-header >
        <div class="">
          <!--按钮部分-->
          <el-form ref="elSearchFormRef" :inline="true"  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" class="search"></el-button>
              <el-button type="primary" icon="edit" @click="onStatusClick" class="bt"><i class="el-icon-edit"></i>状态设置</el-button>
              <el-button type="primary" class="bt" icon="edit"  @click="cpgyfzclick">产品工艺复制</el-button>
              <el-button type="primary" class="bt" icon="edit"  @click="gygmClick" >工艺方案更名</el-button>
              <el-button type="primary" class="bt" icon="edit"  @click="fjClick" >工艺方案附加</el-button>
              <el-button type="primary" class="bt" icon="edit"  @click="jsssxzClick" >计损色数修正</el-button>
              <el-button type="primary" class="bt" icon="edit"  @click="fjfpxsClick" >质检废品系数</el-button>
              <el-button type="primary" class="bt" icon="edit"  @click="pccstzClick" >排产参数调整</el-button>
              <el-button type="primary" class="bt" icon="edit"  @click="hscstzClick" >核算参数调整</el-button>
              <el-button type="primary" class="bt" icon="edit"  @click="addcpyj_onclick" >新增印件资料</el-button>
              <el-button type="primary" class="bt" icon="edit"  @click="addcpgy_onclick" >新增工艺资料</el-button>
              <el-button type="primary" class="bt" icon="edit"  @click="addyb_onclick" >新增印版资料</el-button>
<!--              <el-button type="primary" class="bt" icon="Download" @click="cpexportToExcel" disabled>导出产品资料</el-button>-->
<!--              <el-button type="primary" class="bt" icon="Download" @click="gyexportToExcel" disabled>导出工艺流程</el-button>-->
            </el-form-item>
          </el-form>

          <!--按钮弹窗部分-->

          <!--状态设置-->
          <el-dialog v-model="onstatuslist" title="状态设置" style="width: 300px; top: 20%">
            <div>
              <el-radio-group v-model="status">
                <el-radio label="在产">在产</el-radio>
                <el-radio label="停产">停产</el-radio>
              </el-radio-group>
            </div>
            <div slot="footer" class="dialog-footer" style="text-align: right;">
              <el-button @click="handleCancel">取消</el-button>
              <el-button type="primary" @click="handleConfirm">确定</el-button>
            </div>
          </el-dialog>

          <!-- 产品工艺复制-->
          <el-dialog v-model="cpgyfzlist" title="产品工艺复制"  style="width: 35%;top: 15%;">
              <el-form-item label="参照产品代号:" prop="process" class="mab">
                <el-input disabled v-model="cpgyfzformData['process']" id="process" @keydown="add_cpgyfzent($event, 'fzybzl', 'process', 'processName')"  placeholder="" style="width: 160px;"/>
                <el-input disabled v-model="cpgyfzformData['processName']" id="processName" @keydown="add_cpgyfzent($event, 'process', 'processName', 'gongyifa')" placeholder="" style="width: 360px;"/>
              </el-form-item>

            <el-form-item label="参照工艺方案:" prop="originalName" class="mab">
              <el-select v-model="cpgyfzformData.gongyifa" placeholder="请选择" id="gongyifa" @keydown="add_cpgyfzent($event, 'processName', 'gongyifa', 'mubprocess')" style="width: 160px;">
                <el-option v-for="option in cpgyfzformData.gongyifaNameOptions" :key="option" :label="option" style="width: 160px;" :value="option" />
              </el-select>
            </el-form-item>

            <el-form-item label="目标产品代号:" prop="process" class="mab">
              <el-input v-model="cpgyfzformData['mubprocess']" id="mubprocess" @keydown="add_cpgyfzent($event, 'gongyifa', 'mubprocess', 'mubprocessName')"  placeholder="" style="width: 160px;"/>
              <el-input disabled v-model="cpgyfzformData['mubprocessName']" id="mubprocessName" @keydown="add_cpgyfzent($event, 'mubprocess', 'mubprocessName', 'fzgyzl')" placeholder="" style="width: 360px;"/>
            </el-form-item>
<!--            cpgyfzformData.fzgyzl === true-->
            <el-form-item label="" class="mab" >
              <el-checkbox  v-model="cpgyfzformData['fzgyzl']" id="fzgyzl" @keydown="add_cpgyfzent($event, 'mubprocessName', 'fzgyzl', 'fzybzl')"  >复制工艺资料</el-checkbox>
              <el-input v-model="cpgyfzformData['to_pro']" id="to_pro" v-if="cpgyfzformData['fzgyzl'] !== false" placeholder="目标工艺方案" style="width: 160px;margin-left: 20px"/>
            </el-form-item>
            <el-form-item label="" class="mab" >
              <el-checkbox  v-model="cpgyfzformData['fzybzl']"  id="fzybzl" @keydown="add_cpgyfzent($event, 'fzgyzl', 'fzybzl', 'process')" >复制印版资料</el-checkbox>
            </el-form-item>
              <div class="dialog-footer" style="text-align: right ">
                <el-button @click="cpgyfzhandleCancel">取消</el-button>
                <el-button type="primary" @click="cpgyfzhandleConfirm">确定</el-button>
              </div>
          </el-dialog>

          <!-- 产品工艺复制 目标产品代号弹窗-->
          <el-dialog v-model="cpgyfzdisplay" :before-close="() => cpgyfzdisplay = false">
            <el-form>
              <div>
                <el-form-item label="关键字:"  class="mab" prop="keyOrder">
                  <el-space>
                    <el-input v-model="cpgyfz_keyword" @keyup.enter="cpgyfz_ProductValue" style="width: 100%;"/>
                    <el-button @click="cpgyfzSearchHandle(cpgyfz_keyword, '产品代号')">刷新</el-button>
                  </el-space>
                </el-form-item>
                <div style="border:1px solid #eee; width:100%; height: 400px; overflow-y: auto">
                  <el-tree :data="cpgyfzLists" :props="{children: 'children',label: 'name', value: '产品编号'}" @node-click="cpgyfzselectGongDanNode($event, '产品代号')" />
                </div>
              </div>
            </el-form>
          </el-dialog>

          <!--工艺方案更名-->
          <el-dialog v-model="gygmlist" title="工艺方案更名"  style="width: 35%;top: 15%;">
              <el-form-item label="产品代号:" prop="process" class="mab">
                <el-input v-model="gyformData['process']" disabled :clearable="true" placeholder="" style="width: 160px;"/>
              </el-form-item>
              <br>
              <el-form-item label="产品名称" prop="processName" class="mab">
                <el-input v-model="gyformData['processName']" disabled :clearable="true" placeholder="" style="width: 90%;" />
              </el-form-item>
              <br>
              <el-form-item label="工艺方案原名:" prop="originalName" class="mab">
                <el-select v-model="gyformData.originalName" placeholder="请选择" style="width: 160px;">
                  <el-option v-for="option in gyformData.originalNameOptions" :key="option" :label="option" :value="option" />
                </el-select>
              </el-form-item>
              <br>
              <el-form-item label="工艺方案新名:" prop="newName"  class="mab">
                <el-input v-model="gyformData['newName']" :clearable="true" placeholder="" style="width: 160px;"/>
              </el-form-item>

              <div class="dialog-footer" style="text-align: right ">
                <el-button @click="gygmhandleCancel">取消</el-button>
                <el-button type="primary" @click="gygmhandleConfirm">确定</el-button>
              </div>
          </el-dialog>

          <!--工艺方案附加 -->
          <el-dialog v-model="fjlist" title="工艺方案附加" style="width: 100%;height: 100%;margin: 0px">
              <el-button type="primary" @click="fjbzgx">附加标准工序</el-button>
              <el-button type="primary" @click="gxdqcpgx">更新当前产品工序</el-button>
              <!--                      :disabled="!fjformData['dqoriginalName']"  替换 disabled -->
              <el-button type="primary"  disabled @click="fjhandleConfirm">建立工艺方案</el-button>
              <el-button type="primary" @click="fjhandleCancel">放弃操作</el-button>
            <div>
              <br>
              <div style="height: 38px; display: flex; align-items: center;">
                <el-form-item label="当前产品:" prop="currentProcess" style="margin-right: 20px;padding: 0px">
                  <el-input v-model="fjformData['process']" disabled :clearable="true" placeholder="" style="width: 160px;"/>
                  <el-input v-model="fjformData['processName']" disabled :clearable="true" placeholder="" style="width: 500px;flex: 1;"/>
                </el-form-item>
                <el-form-item label="工艺方案:" prop="originalName"  style="margin-left: 20px;">
                  <el-select v-model="fjformData.originalName" placeholder="请选择" style="width: 160px;">
                    <el-option v-for="option in fjformData.originalNameOptions" @click="onoriginalNameclick" :key="option" :label="option" :value="option" />
                  </el-select>
                </el-form-item>
              </div>
              <div style="height: 38px;display: flex; align-items: center;">
                <el-form-item label="新 产 品 :" prop="currentProcess" style="margin-right: 20px;">
                  <el-input v-model="fjformData['dqprocess']"
                            @keyup.enter="getProductValue"  placeholder="输入新产品" style="width: 160px;"/>
                  <el-input v-model="fjformData['dqprocessName']"
                            :disabled="!!fjformData['dqprocessName']"
                            placeholder="点击输框获取产品名称" @click="ondqprocessNameclick"   style="width: 500px;flex: 1;"/>
                </el-form-item>

                <el-form-item label="工艺方案:" prop="originalName" style="margin-left: 20px;">
                  <el-input v-model="fjformData['dqoriginalName']"
                            :disabled="!fjformData['dqprocessName']"
                            :clearable="true" placeholder="" style="width: 160px;"/>
                </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: 70vh;" border tooltip-effect="dark"
                        :data="fjtableData" row-key="ID" @selection-change="handleSelectionChange">
                <el-table-column v-slot="scope" align="left" label=方案 width="100" >
                  <el-input disabled v-model="scope.row.programme" :clearable="false"/>
                </el-table-column>
                <el-table-column v-slot="scope" align="left" label="印件号" width="100">
                  <el-input v-model="scope.row.Gy0_yjno" :clearable="false"/>
                </el-table-column>
                <el-table-column v-slot="scope" align="left" label="工序号" width="100" >
                  <el-input v-model="scope.row.Gy0_gxh" :clearable="false"/>
                </el-table-column>
                <el-table-column v-slot="scope" align="left" label="工序名称" width="600" >
                  <el-input disabled v-model="scope.row.Add_gxmc" :clearable="false"/>
                </el-table-column>
                <el-table-column v-slot="scope" align="left" label="工价系列" width="100" >
                  <el-input disabled v-model="scope.row.difficulty_coe" :clearable="false"/>
                </el-table-column>
                <el-table-column v-slot="scope" align="left" label="损耗系数" width="100" >
                  <el-input disabled v-model="scope.row.loss_coe" :clearable="false"/>
                </el-table-column>
                <el-table-column v-slot="scope" align="left" label="开数" width="100" >
                  <el-input  v-model="scope.row.Gy0_Ks" :clearable="false"/>
                </el-table-column>
                <el-table-column v-slot="scope" align="left" label="联数" width="100" >
                  <el-input  v-model="scope.row.Gy0_ls" :clearable="false"/>
                </el-table-column>
                <el-table-column v-slot="scope" align="left" label="备注" width="340" >
                  <el-input disabled v-model="scope.row.remark" :clearable="false"/>
                </el-table-column>
                <el-table-column v-slot="scope" align="left" label="车间" width="130" >
                  <el-input disabled v-model="scope.row.Gy0_site" :clearable="false"/>
                </el-table-column>
                <el-table-column v-slot="scope" align="left" label="设备编号" width="110" >
                  <el-input disabled v-model="scope.row.Gy0_sbbh" :clearable="false"/>
                </el-table-column>
              </el-table>
<!--              <div class="dialog-footer" style="text-align: right;margin: 0;">-->
<!--                <el-button type="primary" @click="fjbzgx">附加标准工序</el-button>-->
<!--                <el-button type="primary" @click="gxdqcpgx">更新当前产品工序</el-button>-->
<!--                &lt;!&ndash;                      :disabled="!fjformData['dqoriginalName']"  替换 disabled &ndash;&gt;-->
<!--                <el-button type="primary"  disabled @click="fjhandleConfirm">建立工艺方案</el-button>-->
<!--                <el-button type="primary" @click="fjhandleCancel">放弃操作</el-button>-->
<!--              </div>-->

            </div>
          </el-dialog>

          <!--工艺方案附加中 附加标准工序-->
          <el-dialog v-model="cpgylcfjxx" title="产品工艺流程附加选择" width="1400px" style="height: 740px;bottom: 6%;">
            <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" style="margin-right: 20px; padding: 0px">
                  <el-input v-model="cpgyformData['cpgydh']"
                            @keyup.enter="cpgygetProductValue"  placeholder="输入新产品" style="width: 160px;"/>
                  <el-input v-model="cpgyformData['cpgymc']"
                            disabled
                            placeholder="" @click="oncpgymcclick"   style="width: 500px;flex: 1;"/>
                </el-form-item>

                <el-form-item label="工艺方案:" prop="originalName"  style="margin-left: 20px;">
                  <el-select v-model="cpgyformData.cpgyfan" placeholder="请选择" style="width: 160px;">
                    <el-option v-for="option in cpgyformData.cpgyfans" @click="oncpgyfanclick" :key="option" :label="option" :value="option" />
                  </el-select>
                </el-form-item>
              </div>

              <el-table ref="multipleTable"
                        v-if="cpgyformData['cpgydh'] && cpgyformData['cpgydh'].length > 0"
                        :show-overflow-tooltip="true"
                        :row-style="{ height: '20px' }"
                        :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
                        :header-cell-style="{ padding: '0px' }"
                        :hidden="!cpgyformData['cpgymc']"
                        style="width: 100%;height: 450px" border tooltip-effect="dark"
                        :data="cpgytableData" row-key="ID" @selection-change="handleSelectionChange">
                <el-table-column v-slot="scope" align="left" label=方案 width="100" >
                  <el-input disabled v-model="scope.row.programme" :clearable="false"/>
                </el-table-column>
                <el-table-column v-slot="scope" align="left" label="印件号" width="100">
                  <el-input disabled v-model="scope.row.Gy0_yjno" :clearable="false"/>
                </el-table-column>
                <el-table-column v-slot="scope" align="left" label="工序号" width="100" >
                  <el-input disabled v-model="scope.row.Gy0_gxh" :clearable="false"/>
                </el-table-column>
                <el-table-column v-slot="scope" align="left" label="工序名称" width="340" >
                  <el-input disabled v-model="scope.row.Add_gxmc" :clearable="false"/>
                </el-table-column>
                <el-table-column v-slot="scope" align="left" label="工价系列" width="100" >
                  <el-input disabled v-model="scope.row.difficulty_coe" :clearable="false"/>
                </el-table-column>
                <el-table-column v-slot="scope" align="left" label="损耗系数" width="100" >
                  <el-input disabled v-model="scope.row.loss_coe" :clearable="false"/>
                </el-table-column>
                <el-table-column v-slot="scope" align="left" label="开数" width="100" >
                  <el-input disabled v-model="scope.row.Gy0_Ks" :clearable="false"/>
                </el-table-column>
                <el-table-column v-slot="scope" align="left" label="联数" width="100" >
                  <el-input disabled   v-model="scope.row.Gy0_ls" :clearable="false"/>
                </el-table-column>
                <el-table-column v-slot="scope" align="left" label="备注" width="200" >
                  <el-input disabled v-model="scope.row.remark" :clearable="false"/>
                </el-table-column>
                <el-table-column v-slot="scope" align="left" label="车间" width="120" >
                  <el-input disabled v-model="scope.row.Gy0_site" :clearable="false"/>
                </el-table-column>
                <el-table-column v-slot="scope" align="left" label="设备编号" width="100" >
                  <el-input disabled v-model="scope.row.Gy0_sbbh" :clearable="false"/>
                </el-table-column>
              </el-table>
              <!--                    <div class="dialog-footer" style="margin-top: 80px; margin-left: 45%;">-->
              <!--                      <el-button type="primary" @click="onfjbzgxexecute">执 行</el-button>-->
              <!--                      <el-button type="primary" @click="onfjbzgxcancellation">放 弃</el-button>-->
              <!--                    </div>-->
            </div>
          </el-dialog>

          <!--计损色数修正-->
          <el-dialog v-model="jsssxzlist" title="计损色数修正" style="width: 100%;height: 100%;margin: 0;">
            <el-button type="" @click="jsssxzCancel">取消</el-button>
            <el-button type="primary"  @click="jsssxzConfirm">确定</el-button>
            <div style="width: 100%; height: 60px; padding: 0px; margin: 0px 0px 6px 0px; display: flex; align-items: center;">
              <el-form-item label="关键字 :" prop="currentProcess" style="margin-right: 20px; padding: 0px">
                <el-input v-model="jsssxzformData['cpdh']"
                          @keyup.enter="jsssxzgetProductValue"  placeholder="输入产品编号" style="width: 500px;"/>
              </el-form-item>
            </div>
            <el-table ref="multipleTable"
                      :show-overflow-tooltip="true"
                      :row-style="{ height: '20px' }"
                      :header-row-style="{ height: '20px' }"
                      :header-cell-style="{ padding: '0px' }"
                      style="width: 100%;height: 70vh" border tooltip-effect="dark"
                      :data="jsssxztableData" row-key="ID" @selection-change="handleSelectionChange">
              <el-table-column v-slot="scope" align="left" label=产品名称 width="320" >
                <el-input disabled v-model="scope.row.product_name" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=方案 width="70" >
                <el-input disabled v-model="scope.row.programme" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=印件 width="70" >
                <el-input disabled v-model="scope.row.Gy0_yjno" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=工序 width="70" >
                <el-input disabled v-model="scope.row.Gy0_gxh" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=工艺 width="120" >
                <el-input disabled v-model="scope.row.gy0_gxmc" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label="原计损色数" width="100">
                <el-input :value="scope.row.old_ms_coe" disabled :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" prop="ms_coe" label=新计损色数 width="100" >
                <el-input  v-model="scope.row.ms_coe" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" prop="Gy0_Ks" label=新开数 width="90" >
                <el-input  v-model="scope.row.Gy0_Ks" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" prop="Gy0_ls" label=新联数 width="90" >
                <el-input  v-model="scope.row.Gy0_ls" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" prop="Add_gxmc" label=工序名称 width="210" >
                <el-input  v-model="scope.row.Add_gxmc" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" prop="remark" label=工序备注说明 width="340" >
                <el-input  v-model="scope.row.remark" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=设备编号 width="100" >
                <el-input disabled v-model="scope.row.Gy0_sbbh" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=客户名称 width="200" >
                <el-input disabled v-model="scope.row.custom_name" :clearable="false"/>
              </el-table-column>
            </el-table>
<!--            <div class="dialog-footer"  style="text-align: right; margin-top: 1%;">-->
<!--              <el-button type="" @click="jsssxzCancel">取消</el-button>-->
<!--              <el-button type="primary"  @click="jsssxzConfirm">确定</el-button>-->
<!--            </div>-->
          </el-dialog>

          <!--质检废品系数-->
          <el-dialog v-model="fjfpxslist" title="质检废品系数" style="width: 100%;height: 100%;margin: 0;">
            <el-button type="" @click="fjfpxsCancel">取消</el-button>
            <el-button type="primary"  @click="fjfpxsConfirm">确认</el-button>
            <div style="width: 100%; height: 60px; padding: 0px; margin: 0px 0px 6px 0px; display: flex; align-items: center;">
              <el-form-item label="关键字 :" prop="currentProcess" style="margin-right: 20px; padding: 0px">
                <el-input v-model="fjfpxsformData['cpdh']"
                          @keyup.enter="fjfpxsgetProductValue" placeholder="输入产品编号" style="width: 500px;"/>
              </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' }"
                      style="width: 100%;height: 70vh" border tooltip-effect="dark"
                      :data="fjfpxstableData" row-key="ID" @selection-change="handleSelectionChange">
              <el-table-column v-slot="scope" align="left" label=产品名称 width="300" >
                <el-input disabled  v-model="scope.row.product_name" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=印件 width="70" >
                <el-input disabled v-model="scope.row.Gy0_yjno" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=工序 width="70" >
                <el-input disabled v-model="scope.row.Gy0_gxh" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=工艺 width="120" >
                <el-input disabled v-model="scope.row.gy0_gxmc" :clearable="false"/>
              </el-table-column>

              <el-table-column v-slot="scope" align="left" label=原人工正品版 width="110" >
                <el-input disabled v-model="scope.row.old_artificial_zp" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=原人工次品板 width="110" >
                <el-input disabled v-model="scope.row.old_artificial_cp" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=原人工废检 width="100" >
                <el-input disabled v-model="scope.row.old_artificial_fj" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=原机检正品版 width="110" >
                <el-input disabled v-model="scope.row.old_machine_zp" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=原机检次品版 width="110" >
                <el-input disabled v-model="scope.row.old_machine_cp" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=原机检废检 width="100" >
                <el-input disabled v-model="scope.row.old_machine_fj" :clearable="false"/>
              </el-table-column>

              <el-table-column v-slot="scope" align="left" label=新人工正品版 width="110" >
                <el-input  v-model="scope.row.artificial_zp" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=新人工次品板 width="110" >
                <el-input  v-model="scope.row.artificial_cp" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=新人工废检 width="100" >
                <el-input  v-model="scope.row.artificial_fj" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=新机检正品版 width="110" >
                <el-input  v-model="scope.row.machine_zp" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=新机检次品版 width="110" >
                <el-input  v-model="scope.row.machine_cp" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=新机检废检 width="100" >
                <el-input  v-model="scope.row.machine_fj" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=设备编号 width="100" >
                <el-input disabled v-model="scope.row.Gy0_sbbh" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=客户名称 width="200" >
                <el-input disabled v-model="scope.row.custom_name" :clearable="false"/>
              </el-table-column>
            </el-table>
          </el-dialog>

          <!--排产参数调整-->
          <el-dialog v-model="pccstzlist" title="排产参数调整"  style="width: 100%;height: 100%;margin: 0;">
            <el-button type="" @click="pccstzCancel">取消</el-button>
            <el-button type="primary"  @click="pccstzConfirm">确认</el-button>
            <div style="width: 100%; height: 60px; padding: 0px; margin: 0px 0px 6px 0px; display: flex; align-items: center;">
              <el-form-item label="关键是字 :" prop="currentProcess" style="margin-right: 20px; padding: 0px">
                <el-input v-model="pccstzformData['cpdh']"
                          @keyup.enter="pccstzProductValue"  placeholder="输入产品编号" style="width: 500px;"/>
              </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' }"
                      style="width: 100%;height: 70vh;" border tooltip-effect="dark"
                      :data="pccstztableData" row-key="ID" @selection-change="handleSelectionChange">
              <el-table-column v-slot="scope" align="left" label=产品名称 width="230" >
                <el-input disabled  v-model="scope.row.product_name" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=方案 width="70" >
                <el-input disabled  v-model="scope.row.programme" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=印件 width="70" >
                <el-input disabled  v-model="scope.row.Gy0_yjno" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=工序 width="70" >
                <el-input disabled  v-model="scope.row.Gy0_gxh" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=工序名称 width="150" >
                <el-input disabled  v-model="scope.row.gy0_gxmc" :clearable="false"/>
              </el-table-column>

              <el-table-column v-slot="scope" align="left" label=原A类产能 width="100" >
                <el-input disabled  v-model="scope.row.old_A_power" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=原损耗代号 width="170" >
                <el-input disabled  v-model="scope.row.old_Gy0_shdh" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=原机组编号 width="100" >
                <el-input disabled  v-model="scope.row.old_Gy0_sbbh" :clearable="false"/>
              </el-table-column>

              <el-table-column v-slot="scope"  align="left" label=新A类产能 width="115" >
                <el-input   v-model="scope.row.A_power" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope"  align="left" label=新损耗代号 width="170" >
                <el-input   v-model="scope.row.Gy0_shdh" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope"   align="left" label=新机组编号 width="115" >
                <el-input   v-model="scope.row.Gy0_sbbh" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope"  align="left" label=新装版开工时 width="115" >
                <el-input   v-model="scope.row.Gy0_辅助工时" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=开数 width="70" >
                <el-input disabled  v-model="scope.row.Gy0_Ks" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=联数 width="70" >
                <el-input disabled  v-model="scope.row.Gy0_ls" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=车间 width="110" >
                <el-input disabled  v-model="scope.row.Gy0_site" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=设备编号 width="100" >
                <el-input disabled  v-model="scope.row.olds_Gy0_sbbh" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=客户名称 width="300" >
                <el-input disabled  v-model="scope.row.custom_name" :clearable="false"/>
              </el-table-column>
            </el-table>
<!--            <div class="dialog-footer" style="text-align: right; margin-top: 1%;">-->
<!--              <el-button type="" @click="pccstzCancel">取消</el-button>-->
<!--              <el-button type="primary"  @click="pccstzConfirm">确认</el-button>-->
<!--            </div>-->
          </el-dialog>

          <!--核算参数调整-->
          <el-dialog v-model="hscstzlist" title="核算参数调整"  style="width: 100%;height: 100%;margin:  0;">
            <el-button type="" @click="hscstzCancel">取消</el-button>
            <el-button type="primary"   @click="hscstzConfirm">确认</el-button>
            <div style="width: 100%; height: 60px; padding: 0px; margin: 0px 0px 6px 0px; display: flex; align-items: center;">
              <el-form-item label="关键是字 :" prop="currentProcess" style="margin-right: 20px; padding: 0px">
                <el-input v-model="hscstzformData['cpdh']"
                          @keyup.enter="hscstzProductValue"  placeholder="输入产品编号" style="width: 500px;"/>
              </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' }"
                      style="width: 100%;height: 70vh;" border tooltip-effect="dark"
                      :data="hscstztableData" row-key="ID" @selection-change="handleSelectionChange">
              <el-table-column v-slot="scope" align="left" label=产品名称 width="260" >
                <el-input disabled  v-model="scope.row.product_name" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=方案 width="70" >
                <el-input disabled  v-model="scope.row.programme" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=印件 width="70" >
                <el-input disabled  v-model="scope.row.Gy0_yjno" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=工序 width="70" >
                <el-input disabled  v-model="scope.row.Gy0_gxh" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=工序名称 width="150" >
                <el-input disabled  v-model="scope.row.gy0_gxmc" :clearable="false"/>
              </el-table-column>
              <!-- 原难度系数、原损耗系数、原计损色数-->
              <el-table-column v-slot="scope" align="left" label=原难度系数 width="115" >
                <el-input disabled  v-model="scope.row.hscstzold_difficulty_coe" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=原损耗系数 width="115" >
                <el-input disabled  v-model="scope.row.hscstzold_loss_coe" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=原计损色数 width="115" >
                <el-input disabled  v-model="scope.row.hscstzold_ms_coe" :clearable="false"/>
              </el-table-column>
              <!-- 新难度系数、新损耗系数、新计损色数-->
              <el-table-column v-slot="scope"  align="left" label=新难度系数 width="115" >
                <el-input   v-model="scope.row.difficulty_coe" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope"  align="left" label=新损耗系数 width="115" >
                <el-input   v-model="scope.row.loss_coe" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope"   align="left" label=新计损色数 width="115" >
                <el-input   v-model="scope.row.ms_coe" :clearable="false"/>
              </el-table-column>

              <el-table-column v-slot="scope" align="left" label=开数 width="70" >
                <el-input disabled  v-model="scope.row.Gy0_Ks" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=联数 width="70" >
                <el-input disabled  v-model="scope.row.Gy0_ls" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=车间 width="110" >
                <el-input disabled  v-model="scope.row.Gy0_site" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=设备编号 width="100" >
                <el-input disabled  v-model="scope.row.Gy0_sbbh" :clearable="false"/>
              </el-table-column>
              <el-table-column v-slot="scope" align="left" label=客户名称 width="300" >
                <el-input disabled  v-model="scope.row.custom_name" :clearable="false"/>
              </el-table-column>
            </el-table>
<!--            <div class="dialog-footer" style="text-align: right; margin-top: 1%;">-->
<!--              <el-button type="" @click="hscstzCancel">取消</el-button>-->
<!--              <el-button type="primary"   @click="hscstzConfirm">确认</el-button>-->
<!--            </div>-->
          </el-dialog>

          <!--导出产品资料-->
          <el-dialog v-model="cpdialogexportToExcel" title="导出产品资料" width="50%">
          </el-dialog>

          <!--导出工艺流程-->
          <el-dialog v-model="gydialogexportToExcel" title="导出工艺流程" width="50%">
          </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" @node-click="handleNodeClick" @node-expand="handleNodeExpand">
              <template #default="{node,data}">{{data['客户编号']}}【{{data['客户名称']}}】</template>
            </el-tree>
          </div>
        </layout-sider>

        <!--  右侧内容区域 -->
        <layout-content >


          <!--   产品表格列表 -->
          <div class="gva-table-box">
            <el-table ref="multipleTable"
                      style="width: 100%;height: 25vh;"
                      :row-style="{ height: '15px' }"
                      :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
                      :header-cell-style="{ padding: '0px' }"
                      border tooltip-effect="dark" :data="tableData" row-key="ID"
                      :row-class-name="tableRowClass" highlight-current-row="true"
                      size="small"
                      :cell-class-name="tableDataCellClass"
                      @selection-change="handleSelectionChange"
                      @row-dblclick="updateCompanyFunc"
                      @row-click="tableRowClick"
                      :show-overflow-tooltip="true">
              <el-table-column type="selection" width="30" />
              <el-table-column   align="left" label="产品编号" prop="产品编号" width="115" />
              <el-table-column   align="left" label="产品名称" prop="产品名称" width="340" />
              <el-table-column   align="left" label="版本号" prop="版本号" width="100"/>
              <el-table-column   align="left" label="成品规格" prop="成品规格" width="100" />
              <el-table-column   align="left" label="单位" prop="计量单位" width="100"/>
              <el-table-column   align="left" label="产品分类" prop="产品类别" width="100" />
              <el-table-column   align="left" label="最近接单时间" prop="receiveDate" width="160" />
              <el-table-column   align="left" label="印件数" prop="yjData" width="100" />
              <el-table-column   align="left" label="工艺" prop="gyData" width="100"/>
              <el-table-column   align="left" label="当前状态" prop="状态"  width="100"/>
              <el-table-column   align="left" label="最后修改" prop="Sys_id" width="160" />
              <el-table-column   align="left" label="建档日期" prop="Sys_rq" width="160" />
              <el-table-column    align="left" label="更新日期" prop="Mod_rq" 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]"
                  :page-size="30"
                  layout="total, sizes, prev, pager, next, jumper"
                  :total="total">
              </el-pagination>
            </div>
          </div>

          <!--   印件资料、工艺资料、印版资料、技术资料附件表格 -->
          <el-tabs v-model="activeName" @tab-click="handleClick" class="ta">

            <el-tab-pane label="印件资料"  @click="showTable('印件资料')"  name="first">
              <el-table ref="multipleTable"
                        :show-overflow-tooltip="true"
                        highlight-current-row="true"
                        :row-style="{ height: '20px' }"
                        :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
                        :header-cell-style="{ padding: '0px' }"
                        @row-dblclick="yjupdateCompanyFunc"
                        style="width: 100%;height: 40vh" border tooltip-effect="dark" :data="yjtableData" row-key="ID" @selection-change="handleSelectionChange">
                <el-table-column  type="selection" width="30" />
                <el-table-column  align="left" label="印件号" prop="yj_yjno"  width="80"/>
                <el-table-column  align="left" label="印件代号" prop="yj_yjdh" width="100" />
                <el-table-column  align="left" label="印件名称" prop="yj_yjmc" width="540" />
                <el-table-column  align="left" label="纸张单号" prop="yj_zzdh" width="100"/>
                <el-table-column  align="left" label="纸张名称" prop="yj_zzmc" width="340"/>
                <el-table-column  align="left" label="投料规格" prop="yj_tlgg" width="240"/>
                <el-table-column  align="left" label="开料规格" prop="yj_klgg" width="100"/>
                <el-table-column  align="left" label="开数" prop="yj_ks" width="80" />
                <el-table-column  align="left" label="联数" prop="yj_ls" width="80" />
                <el-table-column  align="left" label="备注" prop="yj_desc" width="200" />
                <el-table-column  align="left" label="建档用户" prop="sys_id" width="130" />
                <el-table-column  align="left" label="建档日期" prop="sys_rq" width="160" />
                <el-table-column  align="left" label="更新日期" prop="mod_rq" width="160"/>
              </el-table>
            </el-tab-pane>

            <el-tab-pane label="工艺资料" @click="showTable('工艺资料')" name="second">
              <el-table ref="multipleTable"
                        highlight-current-row="true"
                        :show-overflow-tooltip="true"
                        :row-style="{ height: '20px' }"
                        :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
                        :header-cell-style="{ padding: '0px' }"
                        @row-dblclick="gyupdateCompanyFunc"
                        :row-class-name="rowClassStyle"
                        style="width: 100%;height: 40vh" border tooltip-effect="dark" :data="gytableData" row-key="ID" @selection-change="handleSelectionChange"
                        @row-click="clickybupdate">
                <el-table-column type="selection" width="30" />
                <el-table-column align="left"   label="方案" prop="方案"  width="70"/>
                <el-table-column align="left"   label="印件" prop="Gy0_yjno" width="80" />
                <el-table-column align="left"   label="工序" prop="Gy0_gxh" width="70" />
                <el-table-column align="left"   label="工序名称" prop="gy0_gxmc" width="120" />
                <el-table-column align="left"   label="工序名称" prop="add_gxmc" width="340" />
                <el-table-column align="left"   label="开数" prop="Gy0_Ks" width="70" />
                <el-table-column align="left"   label="联数" prop="Gy0_ls" width="70" />
                <el-table-column align="left"   label="备注" prop="备注" width="150" />
                <el-table-column align="left"   label="工价系数" prop="工价系数" width="100" />
                <el-table-column align="left"   label="损耗系数" prop="损耗系数" width="100" />
                <el-table-column align="left"   label="计损色数" prop="Gy0_Ms" width="100" />
                <el-table-column align="left"   label="人工检_正品版" prop="人工检_正品版" width="120" />
                <el-table-column align="left"   label="人工检_次品版" prop="人工检_正品版" width="120" />
                <el-table-column align="left"   label="人工检_废检" prop="人工检_废检" width="120"/>
                <el-table-column align="left"   label="机检_正品版" prop="机检_正品版" width="120"/>
                <el-table-column align="left"   label="机检_次品检" prop="机检_次品检" width="120"/>
                <el-table-column align="left"   label="机检_废检" prop="机检_废检" width="120"/>
                <el-table-column align="left"   label="设备编号" prop="Gy0_sbmc" width="100"/>
                <el-table-column align="left"   label="最后修改" prop="最后修改" width="160"/>
                <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="third">
              <el-table ref="multipleTable"
                        highlight-current-row="true"
                        :show-overflow-tooltip="true"
                        :row-style="{ height: '20px' }"
                        :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
                        :header-cell-style="{ padding: '0px' }"
                        @row-dblclick="ybupdateCompanyFunc"
                        style="width: 100%;height: 40vh" border tooltip-effect="dark" :data="ybtableData" row-key="ID" @selection-change="handleSelectionChange"
              >
                <el-table-column type="selection" width="30" />
                <el-table-column align="left"  label="方案" prop="YB_方案"  width="70"/>
                <el-table-column align="left"  label="印件号" prop="YB_Yjno" width="80" />
                <el-table-column align="left"  label="印版类别" prop="印版类别" width="100" />
                <el-table-column align="left"  label="存货编码" prop="存货编码" width="100"/>
                <el-table-column align="left"  label="印版名称" prop="印版名称"  width="440"/>
                <el-table-column align="left"  label="考核印数" prop="考核印数" width="100"/>
                <el-table-column align="left"  label="建档用户" prop="Sys_id" 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-tab-pane label="技术资料附件" @click="showTable('技术资料附件')" name="fourth">
              <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"
                        style="width: 100%;height: 40vh" border tooltip-effect="dark" :data="jstableData" row-key="ID" @selection-change="handleSelectionChange">
                <!--              <el-table-column type="selection" width="55" />-->
                <el-table-column align="left"  label="序号" prop="序号"  width="120"/>
                <el-table-column align="left"  label="适用工序" prop="适用工序" width="120" />
                <el-table-column align="left"  label="备注" prop="备注" width="120" />
                <el-table-column align="left"  label="文件类型" prop="文件类型" width="120"/>
                <el-table-column align="left"  label="关联产品" prop="关联产品"  width="360"/>
                <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" :title="'修改产品基本资料'" height="80%" width="60%" destroy-on-close>
            <el-row>
              <el-scrollbar>
                <el-form :model="formDataTest" label-position="right" ref="elFormRef" :rules="rule" label-width="80px">
                  <el-row>
                    <el-col :span="24">
                      <el-form-item label="客户编号:" prop="address" class="mab">
                        <el-input v-model="formDataTest['客户编号']" :clearable="true" id="id1" placeholder="" @keydown="ent($event, '', 'id1', 'id2')" style="width: 150px;" />
                      </el-form-item>
                    </el-col>
                    <el-col :span="24">
                      <el-form-item label="客户名称:" prop="gender" class="mab">
                        <el-input v-model="formDataTest['客户名称']" :clearable="true" id="id2" placeholder="" @keydown="ent($event, 'id1', 'id2', 'id3')"  />
                      </el-form-item>
                    </el-col>
                    <el-col :span="9">
                      <el-form-item label="印品代号:" prop="address" class="mab">
                        <el-input v-model="formDataTest['产品编号']" :clearable="true" id="id3" placeholder="" @keydown="ent($event, 'id2', 'id3', '版本号')" style="width: 150px;" />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="版本号:" prop="gender" label-width="60px" class="mab">
                        <el-input v-model="formDataTest['版本号']" :clearable="true" placeholder="" id="版本号"  @keydown="ent($event, 'id3', '版本号', '客户料号')" style="width: 120px;" />
                      </el-form-item>
                    </el-col>
                    <el-col :span="9">
                      <el-form-item label="客户料号:" prop="idCard" label-width="110px" class="mab">
                        <el-input v-model="formDataTest['客户料号']" :clearable="true" placeholder=""  id="客户料号"  @keydown="ent($event, '版本号', '客户料号', '产品名称')"  style="width: 150px;" />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row>
                    <el-col :span="24">
                      <el-form-item label="产品名称:" prop="department" class="mab">
                        <el-input v-model="formDataTest['产品名称']" :clearable="true" placeholder="" id="产品名称"  @keydown="ent($event, '客户料号', '产品名称', '产品类别')"  />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row>
                    <el-col :span="9">
                      <el-form-item label="产品类别:" prop="department" class="mab">
                        <el-input v-model="formDataTest['产品类别']" :clearable="true" placeholder="" id="产品类别"  @keydown="ent($event, '产品名称', '产品类别', '计量单位')" style="width: 150px;" />
                      </el-form-item>
                    </el-col>
                    <el-col :span="15">
                      <el-form-item label="单位:" prop="department" label-width="60px" class="mab">
                        <el-input v-model="formDataTest['计量单位']" :clearable="true" placeholder="" id="计量单位"  @keydown="ent($event, '产品类别', '计量单位', '成品规格')" style="width: 120px;"  />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-col :span="24">
                    <el-form-item label="成品规格:" prop="department" class="mab">
                      <el-input v-model="formDataTest['成品规格']" :clearable="true" placeholder="" id="成品规格"  @keydown="ent($event, '计量单位', '成品规格', '产品备注')"  />
                    </el-form-item>
                  </el-col>
                  <el-col :span="24">
                    <el-form-item label="产品备注:" prop="remark" class="mab">
                      <el-input type="textarea" v-model="formDataTest['产品备注']" :rows="4" :clearable="true" placeholder="" id="产品备注"  @keydown="ent($event, '成品规格', '产品备注', 'id1')"   />
                    </el-form-item>
                  </el-col>
                </el-form>
              </el-scrollbar>
            </el-row>
            <template #footer>
              <div class="dialog-footer">
                <el-button @click="closeDialog">取 消</el-button>
                <el-button type="primary" @click="enterDialog">确 定</el-button>
              </div>
            </template>
          </el-dialog>

          <!-- 修改印件资料-->
          <el-dialog v-model="yjdialogFormVisible" :before-close="yjcloseDialog" :title="'修改印件资料'" height="500px" width="800px" destroy-on-close>
            <el-row>
              <el-scrollbar >
                <el-form :model="yjformDataTest" label-position="right" ref="elFormRef" :rules="rule">
                  <el-row>
                    <el-form-item label="印件号:" prop="address" class="mab"  label-width="105px">
                      <el-input v-model="yjformDataTest['yj_yjno']"  placeholder="" style="width: 140px;"  id="印件号"  @keydown="yj_ent($event, '', '印件号', '印件代号')" />
                    </el-form-item>
                  </el-row>
                  <el-row>
                    <el-form-item label="印件代号:" prop="address" class="mab" label-width="105px">
                      <el-input v-model="yjformDataTest['yj_yjdh']"  placeholder="" style="width: 140px;"  id="印件代号"  @keydown="yj_ent($event, '印件号', '印件代号', 'yj_zzdh')" />
                    </el-form-item>
                  </el-row>
                  <el-row>
                    <el-col :span="22">
                      <el-form-item label="印件名称:" prop="address" class="mab" label-width="105px">
                        <el-input v-model="yjformDataTest['yj_yjmc']" disabled placeholder="" id="印件名称"  @keydown="yj_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="105px">
                        <el-row>
                          <el-input v-model="yjformDataTest['yj_zzdh']"  placeholder="" style="width: 140px;"  id="yj_zzdh"  @keydown="yj_ent($event, '印件代号', 'yj_zzdh', 'yj_zzmc')" />
                          <el-input v-model="yjformDataTest['yj_zzmc']"  placeholder=""  style="width: 460px;" id="yj_zzmc"  @keydown="yj_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="105px">
                        <el-row>
                          <el-input v-model="yjformDataTest['yj_zzdh1']"  placeholder="" style="width: 140px;"  id="yj_zzdh1"  @keydown="yj_ent($event, 'yj_zzmc', 'yj_zzdh1', 'yj_zzmc1')" />
                          <el-input v-model="yjformDataTest['yj_zzmc1']"  placeholder=""  style="width: 460px;" id="yj_zzmc1"  @keydown="yj_ent($event, 'yj_zzdh1', 'yj_zzmc1', 'yj_zzdh2')"  />
                        </el-row>
                      </el-form-item>
                    </el-col>
                    <el-col :span="24">
                      <el-form-item label="备用纸张2:" prop="address" class="mab"  label-width="105px">
                        <el-row>
                          <el-input v-model="yjformDataTest['yj_zzdh2']"  placeholder="" style="width: 140px;"  id="yj_zzdh2"  @keydown="yj_ent($event, 'yj_zzdh2', 'yj_zzdh2', 'yj_zzmc2')" />
                          <el-input v-model="yjformDataTest['yj_zzmc2']"  placeholder=""  style="width: 460px;" id="yj_zzmc2"  @keydown="yj_ent($event, 'yj_zzdh2', 'yj_zzmc2', 'yj_zzdh3')"  />
                        </el-row>
                      </el-form-item>
                    </el-col>
                    <el-col :span="24">
                      <el-form-item label="备用纸张3:" prop="address" class="mab"  label-width="105px">
                        <el-row>
                          <el-input v-model="yjformDataTest['yj_zzdh3']"  placeholder="" style="width: 140px;"  id="yj_zzdh3"  @keydown="yj_ent($event, 'yj_zzmc2', 'yj_zzdh3', 'yj_zzmc3')" />
                          <el-input v-model="yjformDataTest['yj_zzmc3']"  placeholder=""  style="width: 460px;" id="yj_zzmc3"  @keydown="yj_ent($event, 'yj_zzdh3', 'yj_zzmc3', 'yj_zzdh4')"  />
                        </el-row>
                      </el-form-item>
                    </el-col>
                    <el-col :span="24">
                      <el-form-item label="备用纸张4:" prop="address" class="mab"  label-width="105px">
                        <el-row>
                          <el-input v-model="yjformDataTest['yj_zzdh4']"  placeholder="" style="width: 140px;"  id="yj_zzdh4"  @keydown="yj_ent($event, 'yj_zzmc3', 'yj_zzdh4', 'yj_zzmc4')" />
                          <el-input v-model="yjformDataTest['yj_zzmc4']"  placeholder=""  style="width: 460px;" id="yj_zzmc4"  @keydown="yj_ent($event, 'yj_zzdh', 'yj_zzmc4', 'yj_tlgg')"  />
                        </el-row>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row>
                    <el-col :span="12">
                      <el-form-item label="投料(mm*mm):" prop="address" class="mab">
                        <el-input v-model="yjformDataTest['yj_tlgg']"  placeholder=""  style="width: 140px;"  id="yj_tlgg"  @keydown="yj_ent($event, 'yj_zzmc4', 'yj_tlgg', 'yj_klgg')"/>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="开料(mm*mm):" prop="address" class="mab">
                        <el-input v-model="yjformDataTest['yj_klgg']"  placeholder="" style="width: 140px;"  id="yj_klgg"  @keydown="yj_ent($event, 'yj_tlgg', 'yj_klgg', 'yj_ks')"/>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row>
                    <el-col :span="6">
                      <el-form-item label="开数:" prop="address" class="mab"  label-width="105px">
                        <el-input v-model="yjformDataTest['yj_ks']"  placeholder="" style="width: 100px;" id="yj_ks"  @keydown="yj_ent($event, 'yj_tlgg', 'yj_ks', 'yj_ls')"/>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="联数:" prop="address" class="mab"  >
                        <el-input v-model="yjformDataTest['yj_ls']"  placeholder=""  style="width: 100px;" id="yj_ls"  @keydown="yj_ent($event, 'yj_ks', 'yj_ls', '换算系数')"/>
                      </el-form-item>
                    </el-col>
                    <el-col :span="10">
                      <el-form-item label="换算系数（公斤到万张）:" prop="address" class="mab">
                        <el-input v-model="yjformDataTest['KgToPages']"  placeholder=""  style="width: 170px;" id="换算系数"  @keydown="yj_ent($event, '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" label-width="105px">
                        <el-input type="textarea" v-model="yjformDataTest['yj_desc']" rows="3"  placeholder="" resize="none" id="yj_desc"  @keydown="yj_ent($event, '换算系数', 'yj_desc', '印件号')"/>
                      </el-form-item>
                    </el-col>
                  </el-row>
                </el-form>
              </el-scrollbar>
            </el-row>
            <template #footer>
              <div class="dialog-footer">
                <el-button @click="yjcloseDialog">取 消</el-button>
                <el-button type="primary"  @click="yjenterDialog">确 定</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 v-model="add_yjzlformdata.yjdh" 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 v-model="add_yjzlformdata.yjmc" 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 v-model="add_yjzlformdata.zzdh"  placeholder="" style="width: 140px;"  id="yj_zzdh" @keydown="openSearchZhiModal($event, 0)"   />
                                    <el-input v-model="add_yjzlformdata.zzmc" placeholder=""  style="width: 460px;" id="yj_zzmc"    />
                                  </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 v-model="add_yjzlformdata.zzdh1"  placeholder="" style="width: 140px;"  id="yj_zzdh1"  @keydown="openSearchZhiModal($event, 1)"  />
                                    <el-input v-model="add_yjzlformdata.zzmc1" 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 v-model="add_yjzlformdata.zzdh2" placeholder="" style="width: 140px;"  id="yj_zzdh2"  @keydown="openSearchZhiModal($event, 2)"  />
                                    <el-input v-model="add_yjzlformdata.zzmc2" 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  v-model="add_yjzlformdata.zzdh3" placeholder="" style="width: 140px;"  id="yj_zzdh3"  @keydown="openSearchZhiModal($event, 3)"  />
                                    <el-input v-model="add_yjzlformdata.zzmc3" 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 v-model="add_yjzlformdata.zzdh4"  placeholder="" style="width: 140px;"  id="yj_zzdh4"  @keydown="openSearchZhiModal($event, 4)"  />
                                    <el-input v-model="add_yjzlformdata.zzmc4" 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 v-model="add_yjzlformdata.tl" 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 v-model="add_yjzlformdata.kl" 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 v-model="add_yjzlformdata.ks" 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 v-model="add_yjzlformdata.ls" placeholder=""  style="width: 140px;" id="yj_ls"  @keydown="ent($event, 'yj_ks', 'yj_ls', 'yj_desc')"/>
                                </el-form-item>
                              </el-col>
                              <el-col :span="10">
                                <el-form-item label="换算系数(公斤到万张):" prop="address" class="mab">
                                  <el-input v-model="add_yjzlformdata.KgToPages" 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 v-model="add_yjzlformdata['备注说明']" type="textarea" rows="3" 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_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: '物料名称', 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: '物料名称', value: '物料代码'}" @node-click="selectZhiNode" />
		        </div>
		      </div>
		    </el-form>
		  </el-dialog>

      <!-- 修改工艺资料 弹窗 -->
      <el-dialog v-model="gydialogFormVisible" :before-close="gycloseDialog" :title="'修改工艺资料'" height="300px" width="900px" destroy-on-close>
            <el-row>
              <el-scrollbar>
                <el-form :model="gyformDataTest" label-position="right" ref="elFormRef" :rules="rule"  >
                  <el-row>
                      <el-form-item label="工序方案:" prop="address" class="mab" >
                        <el-input v-model="gyformDataTest['Gy0_方案']"  placeholder="" style="width: 90px;" id="方案"  @keydown="ent($event, '备注', '方案', '加工开数')"/>
                      </el-form-item>
                      <el-form-item label="印件编号:" prop="address" class="mab"  label-width="90">
                        <el-input v-model="gyformDataTest['Gy0_yjno']" disabled  placeholder="" style="width: 90px;" id="Gy0_yjno"/>
                      </el-form-item>
                      <el-form-item label="工序编号:" prop="address" class="mab" >
                        <el-input v-model="gyformDataTest['Gy0_gxh']" disabled  placeholder="" style="width: 90px;" id="Gy0_gxh" />
                      </el-form-item>
                      <el-form-item label="加工开数" prop="address" class="mab">
                        <el-input v-model="gyformDataTest['Gy0_Ks']"  placeholder="" style="width: 90px;" id="加工开数"  @keydown="ent($event, 'Gy0_gxh', '加工开数', 'Gy0_ls')"/>
                      </el-form-item>
                      <el-form-item label="加工联数:" prop="address" class="mab" >
                        <el-input v-model="gyformDataTest['Gy0_ls']"  placeholder="" style="width: 90px;" id="Gy0_ls"  @keydown="ent($event, '加工开数', 'Gy0_ls', 'gy0_site')"/>
                      </el-form-item>
                  </el-row>

                  <el-row>
                    <el-col :span="6">
                      <el-form-item label="车间名称:" prop="address" class="mab">
                        <el-input v-model="gyformDataTest['Gy0_site']"  placeholder="" style="width: 140px;" id="gy0_site"  @keydown="ent($event, 'Gy0_ls', 'gy0_site', 'gy0_gxmc')"/>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="工艺名称:" prop="address" class="mab"  label-width="100">
                        <el-input v-model="gyformDataTest['gy0_gxmc']"  placeholder="" style="width: 140px;" id="gy0_gxmc"  @keydown="ent($event, 'gy0_site', 'gy0_gxmc', 'add_gxmc')"/>
                      </el-form-item>
                    </el-col>
                  </el-row>

                  <el-row>
                    <el-col :span="24">
                      <el-form-item label="工序名称:" prop="address" class="mab">
                        <el-input v-model="gyformDataTest['Add_gxmc']"  placeholder="" style="width: 100%;" id="add_gxmc"  @keydown="ent($event, 'gy0_gxmc', 'add_gxmc', 'Gy0_sbbh')"/>
                      </el-form-item>
                    </el-col>
                  </el-row>

                  <el-row>
                      <el-form-item label="计损色数:" prop="address" class="mab">
                        <el-input v-model="gyformDataTest['Gy0_Ms']"  placeholder="" style="width: 140px;" id="Gy0_sbbh"  @keydown="ent($event, 'add_gxmc', 'Gy0_sbbh', 'sys_mc')"/>
                      </el-form-item>
                    <el-form-item label="可用设备:" prop="address" class="mab"  label-width="100">
                        <el-input v-model="gyformDataTest['Gy0_sbbh']" disabled  placeholder="" style="" id="可用设备" />
                      </el-form-item>
                    <el-form-item label="难度系数:" prop="address" class="mab" label-width="237">
                        <el-input v-model="gyformDataTest['工价系数']" disabled  placeholder="" style="width: 90px;" id="工价系数" />
                      </el-form-item>
                  </el-row>

                  <el-row>
                      <el-form-item label="标准损耗:" prop="address" class="mab">
                        <el-input v-model="gyformDataTest['Gy0_shdh']" disabled  placeholder="" style="width: 150px;" id="Gy0_shdh" />
                        <el-input v-model="gyformDataTest['sys_mc']"  placeholder="" style="width: 160px;" id="sys_mc"  @keydown="ent($event, 'Gy0_sbbh', 'sys_mc', '基础损耗')"/>
                      </el-form-item>
                      <el-form-item label="基础损耗:" prop="address" class="mab">
                        <el-input v-model="gyformDataTest['sys_rate0']"  placeholder="" style="width: 70px;" id="基础损耗"  @keydown="ent($event, 'sys_mc', '基础损耗', '损耗率')"/>
                      </el-form-item>
                      <el-form-item label="损耗率" prop="address" class="mab" >
                        <el-input v-model="gyformDataTest['sys_rate1']"  placeholder="" style="width: 90px;" id="损耗率"  @keydown="ent($event, '基础损耗', '损耗率', '工序备注')"/>
                      </el-form-item>
                      <el-form-item label="损耗系数:" prop="address" class="mab" >
                        <el-input v-model="gyformDataTest['损耗系数']"  disabled placeholder="" style="width: 90px;" id="损耗系数"/>
                      </el-form-item>
                  </el-row>

                  <el-row>
                    <el-col :span="24">
                      <el-form-item label="工序备注:" prop="remark" class="mab">
                        <el-input type="textarea" v-model="gyformDataTest['工序备注']" rows="2" resize="none" placeholder=""  id="工序备注"  @keydown="ent($event, '损耗率', '工序备注', '质量要求')" />
                      </el-form-item>
                    </el-col>
                    <el-col :span="24">
                      <el-form-item label="质量要求:" prop="remark" class="mab">
                        <el-input type="textarea" v-model="gyformDataTest['质量要求']" rows="2" resize="none" placeholder=""  id="质量要求"  @keydown="ent($event, '工序备注', '质量要求', '质量隐患')" />
                      </el-form-item>
                    </el-col>
                    <el-col :span="24">
                      <el-form-item label="质量隐患:" prop="remark" class="mab">
                        <el-input type="textarea" v-model="gyformDataTest['质量隐患']" rows="2" resize="none" placeholder=""  id="质量隐患"  @keydown="ent($event, '质量要求', '质量隐患', '方案')" />
                      </el-form-item>
                    </el-col>
                  </el-row>
                </el-form>
              </el-scrollbar>
            </el-row>
            <template #footer>
              <div class="dialog-footer">
                <el-button @click="gycloseDialog">取 消</el-button>
                <el-button type="primary" disabled  @click="gyenterDialog">确 定</el-button>
              </div>
            </template>
          </el-dialog>

		  <!-- 新增工艺资料 弹窗 -->
		  <el-dialog v-model="addgydialogFormVisible" :before-close="addgycloseDialog" :title="'新增工艺资料'" height="300px" width="900px" destroy-on-close>
		    <el-row>
		      <el-scrollbar>
		        <el-form :model="gyformDataTest" label-position="right" ref="elFormRef" :rules="rule"  >
		          <el-row>
		              <el-form-item label="工序方案:" prop="address" class="mab" >
		                <el-input v-model="add_gyformData.Gy0_方案"  placeholder="" style="width: 90px;" id="方案"  @keydown="ent($event, '备注', '方案', '加工开数')"/>
		              </el-form-item>
		              <el-form-item label="印件编号:" prop="address" class="mab"  label-width="90">
		                <el-input v-model="add_gyformData.Gy0_cpdh"   placeholder="" style="width: 90px;" id="Gy0_yjno"/>
		              </el-form-item>
		              <el-form-item label="工序编号:" prop="address" class="mab" >
		                <el-input v-model="add_gyformData.Gy0_gxh"   placeholder="" style="width: 90px;" id="Gy0_gxh" />
		              </el-form-item>
		              <el-form-item label="加工开数" prop="address" class="mab">
		                <el-input v-model="add_gyformData.Gy0_Ks"  placeholder="" style="width: 90px;" id="加工开数"  @keydown="ent($event, 'Gy0_gxh', '加工开数', 'Gy0_ls')"/>
		              </el-form-item>
		              <el-form-item label="加工联数:" prop="address" class="mab" >
		                <el-input v-model="add_gyformData.Gy0_ls"  placeholder="" style="width: 90px;" id="Gy0_ls"  @keydown="ent($event, '加工开数', 'Gy0_ls', 'gy0_site')"/>
		              </el-form-item>
		          </el-row>

		          <el-row>
		            <el-col :span="6">
		              <el-form-item label="车间名称:" prop="address" class="mab">
		                <el-input v-model="add_gyformData.Gy0_site" @keyup.enter="getcjmc()" placeholder="" style="width: 140px;" id="gy0_site"  />
		              </el-form-item>
		            </el-col>
		            <el-col :span="6">
		              <el-form-item label="工艺名称:" prop="address" class="mab"  label-width="100">
		                <el-input v-model="add_gyformData.Add_gxmc"  placeholder="" style="width: 140px;" id="gy0_gxmc"  @keydown="ent($event, 'gy0_site', 'gy0_gxmc', 'add_gxmc')"/>
		              </el-form-item>
		            </el-col>
		          </el-row>

		          <el-row>
		            <el-col :span="24">
		              <el-form-item label="工序名称:" prop="address" class="mab">
		                <el-input v-model="add_gyformData.gy0_gxmc"  placeholder="" style="width: 100%;" id="add_gxmc"  @keydown="ent($event, 'gy0_gxmc', 'add_gxmc', 'Gy0_sbbh')"/>
		              </el-form-item>
		            </el-col>
		          </el-row>

		          <el-row>
		              <el-form-item label="计损色数:" prop="address" class="mab">
		                <el-input v-model="add_gyformData.Gy0_Ms"  placeholder="" style="width: 140px;" id="Gy0_sbbh"  @keydown="ent($event, 'add_gxmc', 'Gy0_sbbh', 'sys_mc')"/>
		              </el-form-item>
		            <el-form-item label="可用设备:" prop="address" class="mab"  label-width="100">
		                <el-input v-model="add_gyformData.Gy0_sbbh"   placeholder="" style="" id="可用设备" />
		              </el-form-item>
		            <el-form-item label="难度系数:" prop="address" class="mab" label-width="237">
		                <el-input v-model="add_gyformData.难度系数"   placeholder="" style="width: 90px;" id="工价系数" />
		              </el-form-item>
		          </el-row>

		          <el-row>
		              <el-form-item label="标准损耗:" prop="address" class="mab">
		                <el-input v-model="add_gyformData.标准损耗"  @keyup.enter="getSH()"  placeholder="" style="width: 150px;" id="Gy0_shdh" />
		                <el-input v-model="add_gyformData.标准损耗2"  placeholder="" style="width: 160px;" id="sys_mc"  @keydown="ent($event, 'Gy0_sbbh', 'sys_mc', '基础损耗')"/>
		              </el-form-item>
		              <el-form-item label="基础损耗:" prop="address" class="mab">
		                <el-input v-model="add_gyformData.Gy0_shdh"  placeholder="" style="width: 70px;" id="基础损耗"  @keydown="ent($event, 'sys_mc', '基础损耗', '损耗率')"/>
		              </el-form-item>
		              <el-form-item label="损耗率" prop="address" class="mab" >
		                <el-input v-model="add_gyformData.损耗率"  placeholder="" style="width: 90px;" id="损耗率"  @keydown="ent($event, '基础损耗', '损耗率', '工序备注')"/>
		              </el-form-item>
		              <el-form-item label="损耗系数:" prop="address" class="mab" >
		                <el-input v-model="add_gyformData.损耗系数"   placeholder="" style="width: 90px;" id="损耗系数"/>
		              </el-form-item>
		          </el-row>

		          <el-row>
		            <el-col :span="24">
		              <el-form-item label="工序备注:" prop="remark" class="mab">
		                <el-input type="textarea" v-model="add_gyformData.工序备注" rows="2" resize="none" placeholder=""  id="工序备注"  @keydown="ent($event, '损耗率', '工序备注', '质量要求')" />
		              </el-form-item>
		            </el-col>
		            <el-col :span="24">
		              <el-form-item label="质量要求:" prop="remark" class="mab">
		                <el-input type="textarea" v-model="add_gyformData.质量要求" rows="2" resize="none" placeholder=""  id="质量要求"  @keydown="ent($event, '工序备注', '质量要求', '质量隐患')" />
		              </el-form-item>
		            </el-col>
		            <el-col :span="24">
		              <el-form-item label="质量隐患:" prop="remark" class="mab">
		                <el-input type="textarea" v-model="add_gyformData.质量隐患" rows="2" resize="none" placeholder=""  id="质量隐患"  @keydown="ent($event, '质量要求', '质量隐患', '方案')" />
		              </el-form-item>
		            </el-col>
		          </el-row>
		        </el-form>
		      </el-scrollbar>
		    </el-row>
		    <template #footer>
		      <div class="dialog-footer">
		        <el-button @click="addgycloseDialog">取 消</el-button>
		        <el-button type="primary"   @click="addgyenterDialog">确 定</el-button>
		      </div>
		    </template>
		  </el-dialog>

		  <!-- 新增查询车间名称 -->
		  <el-dialog v-model="searchCJModel" :before-close="() => searchCJModel = false">
		    <el-form>
		      <div>
		        <!-- <el-form-item label="关键字:"  class="mab" prop="keyOrder">
		          <el-space>
		            <el-input v-model="gymc_keyword" style="width: 100%;"/>
		            <el-button @click="searchHandle(gymc_keyword)">刷新</el-button>
		          </el-space>
		        </el-form-item> -->
		        <div style="border:1px solid #eee; width:100%; height: 400px; overflow-y: auto">
		          <el-tree :data="getCJListdata" :props="defaultProps" @node-click="selectCJNode" />
		        </div>

		      </div>
		    </el-form>
		  </el-dialog>

		  <!-- 新增查询标准损耗 -->
		  <el-dialog v-model="searchSHModel" :before-close="() => searchSHModel = false">
		    <el-form>
		      <div>
		        <!-- <el-form-item label="关键字:"  class="mab" prop="keyOrder">
		          <el-space>
		            <el-input v-model="gymc_keyword" style="width: 100%;"/>
		            <el-button @click="searchHandle(gymc_keyword)">刷新</el-button>
		          </el-space>
		        </el-form-item> -->
		        <div style="border:1px solid #eee; width:100%; height: 400px; overflow-y: auto">
		          <el-tree :data="getSHListdata" :props="defaultProps" @node-click="selectSHNode" />
		        </div>
		      </div>
		    </el-form>
		  </el-dialog>

      <!-- 修改印版资料 弹窗 -->
      <el-dialog v-model="ybdialogFormVisible" :before-close="ybcloseDialog" :title="'修改印版资料'" destroy-on-close>
        <el-row>
          <el-scrollbar >
            <el-form :model="ybformDataTest" label-position="right" ref="elFormRef" :rules="rule" label-width="100px" >
              <el-row>
                <el-col :span="8">
                  <el-form-item label="工序方案:" prop="address"  class="mab">
                    <el-input v-model="ybformDataTest['YB_方案']" clearable placeholder="" style="width: 100px;" id="YB_方案"  @keydown="ent($event, 'gy0_site', 'YB_方案', 'YB_Yjno')"/>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="印件号:" prop="address"  class="mab">
                    <el-input v-model="ybformDataTest['YB_Yjno']" clearable placeholder="" style="width: 100px;"  id="YB_Yjno"  @keydown="ent($event, 'YB_方案', 'YB_Yjno', '工序编号')"/>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="工序编号:" prop="address"  class="mab">
                    <el-input v-model="ybformDataTest['']" clearable placeholder="" style="width: 100px;"  id="工序编号"  @keydown="ent($event, 'YB_Yjno', '工序编号', '工艺名称')"/>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row>
                <el-col :span="24">
                  <el-form-item label="工艺名称:" prop="address"  class="mab">
                    <el-input v-model="ybformDataTest['gy0_site']" clearable placeholder="" style="width: 100%;"  id="工艺名称"  @keydown="ent($event, '工序编号', '工艺名称', '工序名称')"/>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <el-form-item label="工序名称:" prop="address"  class="mab">
                    <el-input v-model="ybformDataTest['gy0_site']" clearable placeholder="" style="width: 100%;"  id="工序名称"  @keydown="ent($event, '工艺名称', '工序名称', '存货编码')"/>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="10 ">
                  <el-form-item label="存货编码:" prop="address"  class="mab">
                    <el-input v-model="ybformDataTest['存货编码']" clearable placeholder="" style="width: 140px;"  id="存货编码"  @keydown="ent($event, '工序名称', '存货编码', '印版名称')"/>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <el-form-item label="存货名称:" prop="address"  class="mab">
                    <el-input v-model="ybformDataTest['印版名称']" clearable placeholder="" style="width: 100%;"  id="印版名称"  @keydown="ent($event, '存货编码', '印版名称', 'gy0_site')"/>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <el-form-item label="印版备注:" prop="address"  class="mab">
                    <el-input v-model="ybformDataTest['gy0_site']" clearable placeholder="" style="width: 100%;"  id="gy0_site"  @keydown="ent($event, '印版名称', 'gy0_site', 'YB_方案')"/>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </el-scrollbar>
        </el-row>
        <template #footer>
          <div class="dialog-footer">
            <el-button @click="ybcloseDialog">取 消</el-button>
            <el-button type="primary" disabled @click="ybenterDialog">确 定</el-button>
          </div>
        </template>
      </el-dialog>

      <!-- 新增印版资料 弹窗 -->
      <el-dialog v-model="addybdialogFormVisible" :before-close="addybcloseDialog" :title="'新增印版资料'" height="300px" width="600px" destroy-on-close>
            <el-row>
              <el-scrollbar>
                <el-form :model="add_ybformDataTest" label-position="right" ref="elFormRef" :rules="rule"  >
                  <input type="hidden" v-model="add_ybformDataTest.gxmc1">
                  <el-form-item label="" prop="gongxu" class="mab" label-width="50">
                    <el-select v-model="add_ybformDataTest.gongxu" placeholder="请选择"  id="chbm" style="width: 400px;">
                      <el-option v-for="option in addybdisplaydata.gongxuNameOptions" @click="ongongxufanclick" :key="option" :label="option"  :value="option" />
                    </el-select>
                  </el-form-item>

                    <el-form-item label="工序方案:" prop="address" class="mab" >
                      <el-input disabled v-model="add_ybformDataTest.YB_方案"  placeholder="" style="width: 90px;" id="YB_方案"/>
                      <el-form-item label="印件编号:" prop="address" class="mab" label-width="100">
                        <el-input disabled v-model="add_ybformDataTest.YB_Yjno"  placeholder="" style="width: 90px;" id="YB_Yjno"/>
                      </el-form-item>
                      <el-form-item label="工序编号:" prop="address" class="mab" label-width="100">
                        <el-input disabled v-model="add_ybformDataTest.YB_gxh"  placeholder="" style="width: 90px;" id="YB_gxh"/>
                      </el-form-item>
                    </el-form-item>

                  <el-form-item label="工艺名称:" prop="address" class="mab" >
                    <el-input disabled v-model="add_ybformDataTest.YB_gymc"  placeholder="" style="width: 500px;" id="YB_gymc"/>
                  </el-form-item>
                  <el-form-item label="工序名称:" prop="address" class="mab" >
                    <el-input disabled v-model="add_ybformDataTest.YB_gxmc"  placeholder="" style="width: 500px;" id="YB_gxmc"/>
                  </el-form-item>

                  <br>
                  <el-form-item label="存货编码:" prop="address" class="mab" >
                    <el-input  v-model="add_ybformDataTest.物料代码"  placeholder="" style="width: 200px;" id="YB_gxmc"  @keydown="add_ybzlent($event, '', 'YB_gxmc', '')"/>
                  </el-form-item>
                  <el-form-item label="存货名称:" prop="address" class="mab" >
                    <el-input disabled  v-model="add_ybformDataTest.物料名称"  placeholder="" style="width: 500px;" id="YB_gxmc"/>
                  </el-form-item>
                  <el-form-item label="印版备注:" prop="address" class="mab" >
                    <el-input  type="textarea" resize="none" v-model="add_ybformDataTest.ybbz" rows="1" clearable   style="flex: 1;resize: none" />
                  </el-form-item>

                </el-form>
              </el-scrollbar>
            </el-row>
            <template #footer>
              <div class="dialog-footer">
                <el-button @click="addtbcloseDialog">取 消</el-button>
                <el-button type="primary"   @click="addtbenterDialog">确 定</el-button>
              </div>
            </template>
          </el-dialog>

          <!-- 新增印版资料查询存货编码 -->
          <el-dialog v-model="addybdisplay" :before-close="() => addybdisplay = false">
            <el-form>
              <div>
                <el-form-item label="" prop="originalName" class="mab">
                  <el-select v-model="addybdisplaydata.chbm" placeholder="请选择"  id="chbm" style="width: 200px;">
                    <el-option v-for="option in addybdisplaydata.chbmNameOptions" @click="onybzlfanclick" :key="option" :label="option"  :value="option" />
                  </el-select>
<!--                </el-form-item>-->

<!--                <el-form-item label=""  class="mab" prop="keyOrder">-->
                  <el-space>
                    <el-input v-model="addyb_keyword" style="width: 100%;margin-left: 20px"/>
                    <el-button @click="addyb_searchHandle(addyb_keyword)"  style="width: 10%;">刷新</el-button>
                  </el-space>
                </el-form-item>
                <div style="border:1px solid #eee; width:100%; height: 400px; overflow-y: auto">
                  <el-tree :data="getYBListdata" :props="defaultProps" @node-click="addyb_selectSHNode" />
                </div>
              </div>
            </el-form>
          </el-dialog>


        </layout-content>

      </layout>
    </layout>
  </div>
</template>
<script>
//点击按钮显示下方表格
export default {
  data() {
    return {
      currentTable: '',
      activeName: 'first',
      currentGy0_yjno: null
    };
  },
  methods: {
    tableRowClass({row,rowIndex}){
      if(row.状态==="停产"){
        return "warning-row"
      }
    },
    rowClassStyle({row,rowIndex}){
      // debugger
      // console.log(row.Gy0_yjno, this.currentGy0_yjno)
      if(row.Gy0_yjno==this.currentGy0_yjno){
        return "warning-row"
      }
    },
    clickybupdate(row,column,event){
      this.currentGy0_yjno = row.Gy0_yjno
    },
    showTable(tableName) {
      // console.log(tableName)
      // 根据点击的按钮设置当前展示的表格
      // this.currentTable = tableName;
    },
    showTableChange() {
      // 处理表格选中事件
    },
    // 其他方法...
  }
};
</script>
<script setup>
// 全量引入格式化工具 请按需保留
import { ElMessage, ElMessageBox } from 'element-plus'
//拖拽 import { Layout, LayoutSider, LayoutContent } from '@arco-design/web-vue';
import { Layout, LayoutSider, LayoutContent } from '@arco-design/web-vue';
import { ref, reactive } from 'vue'
import {
  DataList,
  editGyName,
  editGyNo,
  editProduct,
  getProductYbMaterialDetail,
  editProductYjInfo,
  getProductGyInfo,
  getCustom,
  getDepartment,
  getProduct,
  editGy,
  getProductData,
  getProductYjInfo,
  getGyTotal,
  ProductCodeList,
  getProductGy,
  editGyWaste,
  editGyMs,
  getStaffList,
  setProductStatus,
  getProductYjList,
  getProductZzList,
  addProductYjInfo,
  getDepartName,
  getProcess,
  getProcessLoss,
  addProductGyInfo,
  copyProductGy,
  getProductYbMaterialList,
  getProductYbInfo,
  addProductYbInfo,
} from '@/api/yunyin/yunying'
defineOptions({   name: 'Company'})

// =========== 导出Excel表格 ===========
// //导出产品
// const cpdialogexportToExcel = ref(false)
// const cpexportToExcel = () => {
//   console.log('点击了导出产品按钮')
//   cpdialogexportToExcel.value = true;
// }
//
// //导出工艺
// const gydialogexportToExcel = ref(false)
// const gyexportToExcel = () => {
//   console.log('点击了导出工艺流程按钮')
//   gydialogexportToExcel.value = true;
// }

// =========== 状态设置 ===========
const onstatuslist = ref(false);
const status = ref('在产'); // 默认选择在产
const _stacode = ref(null);
//点击【状态设置】按钮
const onStatusClick = () => {
  if(_product_code.value == null){
    onstatuslist.value = false;
    ElMessage({
      type: 'warning',
      message: '请选择树形后，再操作此功能'
    })
  }else{
    _stacode.value = _product_code.value;
    onstatuslist.value = true;
  }
};
// 状态设置放弃按钮
const handleCancel = () => {
  onstatuslist.value = false;
};
// 状态设置执行按钮
const handleConfirm = async () => {
  onstatuslist.value = false;
  let statusCode;
  let code = _stacode.value;
  if (status.value === '在产') {
    statusCode = 1;
  } else if (status.value === '停产') {
    statusCode = 2;
  }
  const data = await setProductStatus({ code: code, status: statusCode });
  if (data.code === 0) {
    ElMessage({
      type: 'success',
      message: '更新成功'
    })
  } else {
    ElMessage({
      type: 'error',
      message: '更新成功'
    })
  }
};
handleCancel(_stacode);

// =========== 工艺方案附加 ===========
const fjlist = ref(false);
const fjformData = reactive({
  //当前产品
  process: '',
  //产品名称
  processName: '',
  //工艺方案
  processfa: [],
  // 工艺方案默认选择的值
  originalName: '',
  //↓新产品数据
  dqprocess: '',
  dqprocessName: '',
  dqoriginalName: ''
});
const fjtableData = ref([]);
const _originalNamev = ref(null);

//1.点击【工艺方案附加】按钮
const fjClick = () => {
  if(_product_code.value == null){
    fjlist.value = false;
    ElMessage({
      type: 'warning',
      message: '请选择分类项目，再操作此功能'
    })
  }else{
    fjlist.value = true;
    if (gytableData.length === 0) {
      fjlist.value = false;
      ElMessage({
        type: 'warning',
        message: '没有工艺资料'
      })
    } else {
      //将值赋值给当前产品
      fjformData.process = _product_code.value;
      fjformData.processName = _kehu_code.value;
      //默认新产品为空
      fjformData.dqprocess = ''
      fjformData.dqprocessName = ''
      fjformData.dqoriginalName = ''
      //获取方案
      const uniqueSchemeSet = new Set();
      gytableData.forEach(item => {
        uniqueSchemeSet.add(item['方案']);
      });
      const uniqueSchemeArray = Array.from(uniqueSchemeSet);
      fjformData.originalNameOptions = [];// 清空原有数据
      fjformData.originalNameOptions = fjformData.originalNameOptions.concat(uniqueSchemeArray);
      // 设置默认选择第一个选项
      if (fjformData.originalNameOptions.length > 0) {
        fjformData.originalName = fjformData.originalNameOptions[0];
      }
    }
    const product_code = fjformData.process
    const plan = fjformData.originalName
    getProductGys(product_code,plan)
  }
};

//2.输入新产品点击后面input获取新产品的值
const ondqprocessNameclick = () => {
  _originalNamev.value = fjformData['dqprocess'];
  _ongetProductclick();
}

//2.新产品输入框回车事件
const getProductValue = () => {
  if(fjformData['dqprocessName'] === ''){
    fjformData['dqprocessName'] = '';
  }
  _originalNamev.value = fjformData['dqprocess'];
  _ongetProductclick();
}

//封装获取单个产品基础数据方法[用来获取新产品名称]
const _ongetProductclick = async ()=>{
  let params = {}
  params.search = _originalNamev.value;
  params.limit = 999;
  params.page = 1;
  try {
    const WorkListdata = await getProduct(params);
    fjformData['dqprocessName'] = WorkListdata.data.data[0]['产品名称'];
  } catch (error) {
    console.error(error);
  }
}

//3.获取选择下拉框当前方案的值
const onoriginalNameclick = () => {
  //获取方案
  const uniqueSchemeSet = new Set();
  gytableData.forEach(item => {
    uniqueSchemeSet.add(item['方案']);
  });
  const uniqueSchemeArray = Array.from(uniqueSchemeSet);
  fjformData.originalNameOptions = [];// 清空原有数据
  fjformData.originalNameOptions = fjformData.originalNameOptions.concat(uniqueSchemeArray);
  const product_code = fjformData.process
  const plan = fjformData.originalName
  getProductGys(product_code,plan)
}

//当前产品号通过接口查询工艺数据,用来展示表格
const getProductGys = async (product_code,plan) => {
  const getProductGydata = await getProductGy({product_code:product_code,plan:plan});
  fjtableData.value = getProductGydata.data;
};

//==========点击【附加标准工序】按钮=====弹出新页面==========
const cpgylcfjxx = ref(false);
//产品代号
const _cpgyoriginalNamev = ref(null);
const cpgyformData = reactive({
  //当前产品代号
  cpgydh: '',
  //当前产品名称
  cpgymc: '',
  //当前产品工艺方案
  cpgyfan: [],
  // 当前工艺方案默认选择的值
  cpgyfans: '',
});

//点击【附加标准工序按钮】打开页面清空输入框数据
const fjbzgx = async () => {
  cpgyformData['cpgydh'] = '';
  cpgyformData['cpgymc'] = '';
  cpgyformData['cpgyfan'] = '';
  cpgylcfjxx.value = true;
}
//输入新产品点击后面input获取新产品的值
const oncpgymcclick = () => {
  _cpgyoriginalNamev.value = cpgyformData['cpgydh'];
  _cpgyongetProductclick();
  _ongetProductclicks();
}
//新产品输入框回车事件
const cpgygetProductValue = () => {
  if(cpgyformData['cpgydh'] == ''){
    cpgyformData['cpgymc'] = '';
  }
  _cpgyoriginalNamev.value = cpgyformData['cpgydh'];
  _cpgyongetProductclick();
  _ongetProductclicks();
}

//3.点击工艺方案下拉框获取输入框的值
const oncpgyfanclick = () => {
  // 产品代号
  const product_code = cpgyformData.cpgydh;
  // 选中的工艺方案
  const plan = cpgyformData.cpgyfan;
  getProductGyss(product_code,plan)
}

const yincangtableData = ref([]);
const _cpgyongetProductclick = async ()=>{
  const product_code = _cpgyoriginalNamev.value;//产品号
  const getProductDatadata = await getProductData({product_code:product_code});
  // 从数据中提取方案
  const schemes = getProductDatadata.data.gyData.map(item => item.方案);
  // 使用 Set 进行去重
  const uniqueSchemes = Array.from(new Set(schemes));
  // 更新工艺方案数组
  cpgyformData.cpgyfans = uniqueSchemes;
  // 设置默认选择第一个选项
  if (cpgyformData.cpgyfans.length > 0) {
    cpgyformData.cpgyfan = [cpgyformData.cpgyfans[0]];
  }
  const plan = cpgyformData.cpgyfan[0]
  getProductGyss(product_code,plan)
}
//当前产品号通过接口查询工艺数据,用来展示表格
const cpgytableData = ref([]);
const getProductGyss = async (product_code,plan) => {
  const getProductGydata = await getProductGy({product_code:product_code,plan:plan});
  cpgytableData.value = getProductGydata.data;
};
const _ongetProductclicks = async ()=>{
  let params = {}
  params.search = _cpgyoriginalNamev.value;
  params.limit = 999;
  params.page = 1;
  try {
    const getProductdata = await getProduct(params);
    cpgyformData['cpgymc'] = getProductdata.data.data[0]['产品名称'];
  } catch (error) {
    console.error(error);
  }
}

//点击【附加标准工序执行】按钮
const onfjbzgxexecute = async () => {
  cpgylcfjxx.value = false;
}

//点击【附加标准工序放弃】按钮
const onfjbzgxcancellation = async () => {cpgylcfjxx.value = false;}

//点击【更新当前产品工序】按钮，更新的是表格数据
const gxdqcpgx = async () => {
  const rawValueArray = fjtableData._rawValue;
  const formattedData = rawValueArray.map(item => {
    return {
      UniqID: item.UniqID,
      Gy0_yjno: item.Gy0_yjno,
      Gy0_gxh: item.Gy0_gxh,
      Gy0_Ks: item.Gy0_Ks,
      Gy0_ls: item.Gy0_ls
    };
  });
  const editGyNamedata = await editGyNo(formattedData);
  if (editGyNamedata.code === 0) {
    ElMessage({
      type: 'success',
      message: '更新成功'
    })
  } else {
    ElMessage({
      type: 'error',
      message: '更新失败'
    })
  }
  fjlist.value = false;
};

//点击【建立工艺方案】按钮，当前的方案建立到新产品方案中
const fjhandleConfirm = async () => {
  fjlist.value = false;
};

//点击【工艺方案附加放弃操作】按钮
const fjhandleCancel = () => {
  fjlist.value = false;
};

// =========== 产品工艺复制 ===========
const cpgyfzlist = ref(false);
const cpgyfzformData = reactive({
  process: '',
  processName: '',
  gongyifa:'',
  gongyifaNameOptions: [],
  mubprocess: '',
  mubprocessName: '',
  to_pro:'',
  fzgyzl: false,
  fzybzl: true,
});
const cpgyfzclick = async () => {
  if(_product_code.value == null){
    gygmlist.value = false;
    ElMessage({
      type: 'warning',
      message: '请选择分类项目，再操作此功能'
    })
  }else{
    cpgyfzlist.value = true;
    cpgyfzformData.process = _product_code.value;
    await _getGyTotal();
  }
};
//取消
const cpgyfzhandleCancel = async () => {
    cpgyfzlist.value = false;
};
//确定
const is_copy_gy = ref(0);
const is_copy_yb = ref(0);
const toProUpperCase = ref('');
const cpgyfzhandleConfirm = async () => {
  // console.log(cpgyfzformData)
  if(cpgyfzformData['process'] === ''){
    ElMessage({type: 'warning',message: '参照产品代号不能为空' })
    return false;
  }
  if(cpgyfzformData['mubprocess'] === ''){
    ElMessage({type: 'warning',message: '目标产品编号不能为空' })
    return false;
  }
  if(cpgyfzformData['gongyifa'] === '' ||  cpgyfzformData['gongyifa'] === undefined){
    ElMessage({type: 'warning',message: '该产品未查询到工艺方案' })
    return false;
  }
  if(cpgyfzformData['mubprocess'] === ''){
    ElMessage({type: 'warning',message: '目标产品代号不能为空' })
    return false;
  }
  //选择复制工艺资料
  if (cpgyfzformData['fzgyzl'] === true) {
    is_copy_gy.value = 1;
  }
  //选择复制印版资料
  if (cpgyfzformData['fzybzl'] === true) {
    is_copy_yb.value = 1;
  }
  //选择复制工艺资料、不选择复制印版资料
  if (cpgyfzformData['fzgyzl'] === true && cpgyfzformData['fzybzl'] === false) {
    if(cpgyfzformData['to_pro'] === ''){
      ElMessage({type: 'warning',message: '目标工艺方案不能为空' })
      return false;
    }
    is_copy_gy.value = 1;
    is_copy_yb.value = 0;
  }
  //选择复制印版资料、不选择复制工艺资料
  if (cpgyfzformData['fzgyzl'] === false && cpgyfzformData['fzybzl'] === true) {
    is_copy_gy.value = 0;
    is_copy_yb.value = 1;
    cpgyfzformData['to_pro'] = '';
  }
  //都不选择提示信息
  if (cpgyfzformData['fzgyzl'] === false && cpgyfzformData['fzybzl'] === false) {
    ElMessage({type: 'warning',message: '请选择复制工艺资料 或 复制印版资料' })
    return false;
  }
  // 判断是否为大写字母
  if (cpgyfzformData['to_pro'] === cpgyfzformData['to_pro'].toUpperCase()) {
    toProUpperCase.value = cpgyfzformData['to_pro'];
  } else {
    // 如果不是大写字母，则将其转换为大写
    toProUpperCase.value  = cpgyfzformData['to_pro'].toUpperCase();
  }
  const formattedData = {
    from_code: cpgyfzformData['process'],
    from_pro: cpgyfzformData['gongyifa'],
    to_code: cpgyfzformData['mubprocess'],
    is_copy_gy: is_copy_gy.value,
    to_pro: toProUpperCase.value,
    is_copy_yb: is_copy_yb.value,
  };
  console.log(formattedData);
  const copyProductGy_add = await copyProductGy(formattedData);
  if (copyProductGy_add.code === 0) {
    xzhscslist.value = false;
    ElMessage({ type: 'success', message: '更新成功' });
    cpgyfzlist.value = false;
  } else {
    ElMessage({ type: 'error', message: '更新失败' });
  }
};




cpgyfzhandleConfirm
//101201052
const _getGyTotal = async () => {
  console.log(_product_code.value)
  const getGyTotaldata = await getGyTotal({code:_product_code.value});
  cpgyfzformData.processName = getGyTotaldata.data.name
  cpgyfzformData.gongyifa = getGyTotaldata.data.gy[0]
  cpgyfzformData.gongyifaNameOptions = getGyTotaldata.data.gy
};

const cpgyfzdisplay = ref(false)
const cpgyfzLists = ref(false);
const cpgyfz_keyword = ref('')
//点击客户代号
const cpgyfzselectGongDanNode = (node, type) => {
  if (type === '产品代号') {
    cpgyfzformData['mubprocess'] = node.产品编号
    cpgyfzformData['mubprocessName'] = node.产品名称
    cpgyfzdisplay.value = false
  }
}
const cpgyfzSearchHandle = async (v, type) => {
  if (type === '产品代号') {
    await _ProductCodeList(v)
  }
}
//【回车】
const cpgyfz_ProductValue = async (v) => {
  await _ProductCodeList(cpgyfz_keyword.value)
};
//产品代号列表
const _ProductCodeList = async (v = '')=>{
  try {
    const ProductCodeListdata = await ProductCodeList({cilent: v});
    cpgyfzLists.value = ProductCodeListdata.data
  } catch (error) {
    console.error(error);
  }
}
const add_cpgyfzent = async (event,id1,id2,id3) => {
  if (id2 === 'mubprocess' &&  event.key==='Tab' || id2 === 'mubprocess' && event.key=== 'Enter') {
    // cpgyfz_keyword.value = '';
    await _ProductCodeList(cpgyfzformData['mubprocess'])
    if (cpgyfzLists.value != null) {
      const row = cpgyfzLists.value.find(item => item.产品编号 === cpgyfzformData['mubprocess'])
      if (row) {
        cpgyfzformData['mubprocess'] = row.产品编号
        cpgyfzformData['mubprocessName'] = row.产品名称
      } else {
        cpgyfzdisplay.value = true
      }
    } else {
      cpgyfzdisplay.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()
    }
  }
}

// =========== 工艺方案更名 ===========
const gygmlist = ref(false);
const _gygmstacode = ref(null);
const gyformData = reactive({
  process: '',
  processName: '',
  originalNameOptions: [],
  newName: '',
  originalName: '', // 工艺方案默认选择的值
});
//点击【工艺方案更名】按钮
const gygmClick = () => {
  if(_product_code.value == null){
    gygmlist.value = false;
    ElMessage({
      type: 'warning',
      message: '请选择分类项目，再操作此功能'
    })
  }else{
    gygmlist.value = true;
    gyformData.process = _product_code.value;
    gyformData.processName = _kehu_code.value;
    if (gytableData.length === 0) {
      gygmlist.value = false;
      ElMessage({
        type: 'warning',
        message: '没有工艺资料'
      })
    } else {
      const uniqueSchemeSet = new Set();
      gytableData.forEach(item => {
        uniqueSchemeSet.add(item['方案']);
      });
      const uniqueSchemeArray = Array.from(uniqueSchemeSet);
      gyformData.originalNameOptions = []; // 清空原有数据
      gyformData.originalNameOptions = gyformData.originalNameOptions.concat(uniqueSchemeArray);
      // 设置默认选择第一个选项
      if (gyformData.originalNameOptions.length > 0) {
        gyformData.originalName = gyformData.originalNameOptions[0];
      }
    }
  }
};
// 工艺方案更名放弃按钮
const gygmhandleCancel = () => {gygmlist.value = false;};

// 点击工艺方案更名【执行】按钮
const gygmhandleConfirm = async () => {
  if(gyformData.originalName === '' ||  gyformData.originalName === undefined){
    ElMessage({type: 'warning',message: '该产品未查询到工艺方案原名' })
    return false;
  }
  if(gyformData.newName === ''){
    ElMessage({
      type: 'warning',
      message: '工艺方案新名不能为空'
    })
    return;
  }
  gygmlist.value = false;
  let params = {}
  params.code = gyformData.process;
  params.old_name = gyformData.originalName;
  params.new_name = gyformData.newName;
  //确定后清空 工艺方案原名 输入框
  gyformData.originalName = ''
  //确定后清空 工艺方案新名 输入框
  gyformData.newName = ''
  try {
    const WorkListdata = await editGyName(params);
    if (WorkListdata.code === 0) {
      ElMessage({type: 'success',message: '更新成功'})
    } else {
      ElMessage({type: 'error',message: '更新失败'})
    }
  } catch (error) {
    console.error(error);
  }
};

gygmhandleCancel(_gygmstacode);

// =========== 计损色数修正 ===========
const jsssxzlist = ref(false);
const jsssxztableData = ref([]);
const jsssxzformData = reactive({cpdh: '',});
//点击【计损色数修正】按钮
const jsssxzClick = () => {
  if(_product_code.value == null){
    jsssxzlist.value = false;
    ElMessage({
      type: 'warning',
      message: '请选择分类项目，再操作此功能'
    })
  }else{
    _jsssxzgetProductGy();
    jsssxzformData['cpdh'] = _product_code.value;
    jsssxzlist.value = true;
  }
}
//计损色数修正【回车】
const jsssxzgetProductValue = async () => {
  _product_code.value = '';
  _jsssxzgetProductGy();
};
//计损色数修正获取工艺表格数据
const _jsssxzgetProductGy = async ()=>{
  let product_code = _product_code.value || jsssxzformData['cpdh'];
  try {
    const getProductGydata = await getProductGy({product_code:product_code});
    jsssxztableData.value = getProductGydata.data;
    const formattedData = getProductGydata.data.map(item=>{
      item.old_ms_coe = item.ms_coe
      return item
    });
  } catch (error) {
    console.error(error);
  }
}
//计损色数修正更新按钮
const jsssxzConfirm = async () => {
  const rawValueArray = jsssxztableData._rawValue;
  const formattedData = rawValueArray.map(item => {
    return {
      UniqID: item.UniqID,
      Gy0_Ms: item.ms_coe,
      Gy0_gxh: item.Gy0_gxh,
      Gy0_Ks: item.Gy0_Ks,
      Add_gxmc: item.Add_gxmc,
      remark: item.remark
    };
  });
  const editeditGyMs = await editGyMs(formattedData);
  if (editeditGyMs.code === 0) {
    ElMessage({type: 'success',message: '更新成功'})
  } else {
    ElMessage({type: 'error',message: '更新失败'})
  }
  jsssxzlist.value = false;

};
//计损色数修正放弃按钮
const jsssxzCancel = () => {jsssxzlist.value = false;};

// =========== 质检废品系数 ===========
const fjfpxslist = ref(false);
const fjfpxstableData = ref([]);
const fjfpxsformData = reactive({cpdh: '',});
//点击【质检废品系数】按钮
const fjfpxsClick = () => {
  if(_product_code.value == null){
    gygmlist.value = false;
    ElMessage({type: 'warning',message: '请选择分类项目，再操作此功能'})
  }else{
    fjfpxsformData['cpdh'] = _product_code.value;
    _fjfpxsgetProductGy();
    fjfpxslist.value = true;
  }
}
//质检废品系数回车
const fjfpxsgetProductValue = async () => {
  _product_code.value = '';
  _fjfpxsgetProductGy();
};
//质检废品系数获取工艺表格数据
const _fjfpxsgetProductGy = async ()=>{
  let product_code = _product_code.value || fjfpxsformData['cpdh'];
  try {
    const getProductGydata = await getProductGy({product_code:product_code});
    fjfpxstableData.value = getProductGydata.data;
    const formattedData = getProductGydata.data.map(item=>{
      item.old_artificial_zp = item.artificial_zp;
      item.old_artificial_cp = item.artificial_cp;
      item.old_artificial_fj = item.artificial_fj;
      item.old_machine_zp = item.machine_zp;
      item.old_machine_cp = item.machine_cp;
      item.old_machine_fj = item.machine_fj;
      return item
    });
  } catch (error) {
    console.error(error);
  }
}
//质检废品系数更新按钮
const fjfpxsConfirm = async () => {
  const rawValueArray = fjfpxstableData._rawValue;
  const formattedData = rawValueArray.map(item => {
    return {
      UniqID: item.UniqID,
      artificial_zp: parseFloat(item.artificial_zp) || item.artificial_zp === 0 ? parseFloat(item.artificial_zp).toFixed(3) : "0.000",
      artificial_cp: parseFloat(item.artificial_cp) || item.artificial_cp === 0 ? parseFloat(item.artificial_cp).toFixed(3) : "0.000",
      artificial_fj: parseFloat(item.artificial_fj) || item.artificial_fj === 0 ? parseFloat(item.artificial_fj).toFixed(3) : "0.000",
      machine_zp: parseFloat(item.machine_zp) || item.machine_zp === 0 ? parseFloat(item.machine_zp).toFixed(3) : "0.000",
      machine_cp: parseFloat(item.machine_cp) || item.machine_cp === 0 ? parseFloat(item.machine_cp).toFixed(3) : "0.000",
      machine_fj: parseFloat(item.machine_fj) || item.machine_fj === 0 ? parseFloat(item.machine_fj).toFixed(3) : "0.000"
    };
  });
  const editGyWastes = await editGyWaste(formattedData);
  if (editGyWastes.code === 0) {
    ElMessage({type: 'success',message: '更新成功'})
  } else {
    ElMessage({type: 'error',message: '更新失败'})
  }
  fjfpxslist.value = false;
};
//质检废品系数放弃按钮
const fjfpxsCancel = () => {fjfpxslist.value = false;};

// =========== 排产参数调整 ===========
const pccstzlist = ref(false);
const pccstztableData = ref([]);
const pccstzformData = reactive({cpdh: '',});
//点击【排产参数调整】按钮
const pccstzClick = () => {
  if(_product_code.value == null){
    pccstzlist.value = false;
    ElMessage({type: 'warning',message: '请选择分类项目，再操作此功能'})
  }else{
    pccstzformData['cpdh'] = _product_code.value;
    _pccstzgetProductGy();
    pccstzlist.value = true;
  }
}
//排产参数调整 回车
const pccstzProductValue = async () => {
  _product_code.value = '';
  _pccstzgetProductGy();
};
//排产参数调整 获取单个工艺数据（排产参数调整）
const _pccstzgetProductGy = async ()=>{
  let product_code = _product_code.value || pccstzformData['cpdh'];
  try {
    const getProductGydata = await getProductGy({product_code:product_code});
    pccstztableData.value = getProductGydata.data;
    const formattedData = getProductGydata.data.map(item=>{
      //原A类产能
      item.old_A_power = item.A_power;
      //原损耗代号
      item.old_Gy0_shdh = item.Gy0_shdh;
      // 原机组编号
      item.old_Gy0_sbbh = item.Gy0_sbbh;
      //设备编号
      item.olds_Gy0_sbbh = item.Gy0_sbbh;
      return item
    });
  } catch (error) {
    console.error(error);
  }
}
//排产参数调整 【执行更新按钮】
const pccstzConfirm = async () => {
  const rawValueArray = pccstztableData._rawValue;
  const formattedData = rawValueArray.map(item => {
    return {
      UniqID: item.UniqID,
      A_power: item.A_power,
      shdh: item.Gy0_shdh,
      machine: item.Gy0_sbbh,
      time: item.Gy0_辅助工时,
    };
  });
  const editGy_edit = await editGy(formattedData);
  if (editGy_edit.code === 0) {
    ElMessage({type: 'success',message: '更新成功'})
  } else {
    ElMessage({type: 'error',message: '更新失败'})
  }
  pccstzlist.value = false;
};
//排产参数调整 放弃
const pccstzCancel = () => {pccstzlist.value = false;};

// =========== 核算参数调整 ===========
const hscstzlist = ref(false);
const hscstztableData = ref([]);
const hscstzformData = reactive({cpdh: '',});
//点击【核算参数调整】按钮
const hscstzClick = () => {
  if(_product_code.value == null){
    hscstzlist.value = false;
    ElMessage({type: 'warning',message: '请选择分类项目，再操作此功能'})
  }else{
    hscstzformData['cpdh'] = _product_code.value;
    _hscstzgetProductGy();
    hscstzlist.value = true;
  }
}
//排产参数调整 回车
const hscstzProductValue = async () => {
  _product_code.value = '';
  _hscstzgetProductGy();
};
//核算参数调整 获取单个工艺数据（排产参数调整）
const _hscstzgetProductGy = async ()=>{
  let product_code = _product_code.value || hscstzformData['cpdh'];
  try {
    const hscstz_getProductGy = await getProductGy({product_code:product_code});
    hscstztableData.value = hscstz_getProductGy.data;
    const formattedData = hscstz_getProductGy.data.map(item=>{
      //原难度系数
      item.hscstzold_difficulty_coe = item.difficulty_coe;
      //原损耗系数
      item.hscstzold_loss_coe = item.loss_coe;
      //原计损色数
      item.hscstzold_ms_coe = item.ms_coe;
      return item
    });
  } catch (error) {
    console.error(error);
  }
}
//核算参数调整 【执行按钮】
const hscstzConfirm = async () => {
  const rawValueArray = hscstztableData._rawValue;
  const formattedData = rawValueArray.map(item => {
    return {
      UniqID: item.UniqID,
      difficulty_coe: item.difficulty_coe,
      loss_coe: item.loss_coe,
      ms_coe: item.ms_coe,
    };
  });
  const hscstz_edit = await editGy(formattedData);
  if (hscstz_edit.code === 0) {
    ElMessage({type: 'success',message: '更新成功'})
  } else {
    ElMessage({type: 'error',message: '更新失败'})
  }
  hscstzlist.value = false;
};
//核算参数调整 放弃
const hscstzCancel = () => {hscstzlist.value = false;};


// =========== 左侧树侧形结构 ===========
const treeData = ref({})
const getCustomdata = async () => {
  try {
    const data  = await getCustom()
    treeData.value = data.data;
  } catch (error) {
    console.error('Error fetching custom data:', error);
  }
}
getCustomdata()

//点击左侧树形获取列表
const tableData = reactive([])
const _custom_code = ref(null)
const handleNodeClick = async (node) => {
  _custom_code.value = node.客户编号;
  //清空搜索框
  searchInfo.value = '';
  _getProduct()
};
//印件资料
const yjtableData = reactive([])
//工艺资料
const gytableData = reactive([])
//印版资料
const ybtableData = reactive([])
//技术资料附件【暂时为空】
const jstableData = reactive([])
//全局调用产品编号
const _product_code = ref(null)
//全局调用产品名称
const _kehu_code = ref(null)
const _UniqID = ref(null)
//点击表格行 下方表格获取数据
const tableRowClick = async (row) => {
  _UniqID.value = row.UniqID;
	_Gd_gdbh.value = row.产品编号;
  _product_code.value = row.产品编号;
  _kehu_code.value = row.产品名称;
  const res = await getProductData({product_code:_product_code.value});
  console.log(ybtableData.length, ...res.data.ybData)
  yjtableData.splice(0, yjtableData.length, ...res.data.yjData);
  gytableData.splice(0, gytableData.length, ...res.data.gyData);
  ybtableData.splice(0, ybtableData.length, ...res.data.ybData);
  if(yjtableData.length==0){
	   yjzuidahaoma.value = 1
  }else{
	  let tmp = yjtableData.map(item => item.yj_yjno)
	  tmp = tmp.sort((a,b)=>b-a)
	  yjzuidahaoma.value = Number(tmp[0]) + 1
  }
  // console.log(yjzuidahaoma.value)
  // yjzuidahaoma.value = yjtableData.length+1
};

//搜索查询
const searchInfo = ref('')
//点击【查询】按钮
const onSubmit = () => {
  _custom_code.value = '';
  _getProduct();
};

//封装获取单个产品基础数据方法
const _getProduct = async ()=>{
  let params = {}
  params.search = searchInfo.value;
  params.custom_code = _custom_code.value;
  params.limit = pageSize.value;
  params.page = page.value;
  try {
    const WorkListdata = await getProduct(params);
    console.log(WorkListdata.data.data)
    if(WorkListdata.data.data === []){
      ElMessage({type: 'warning',message: '未查询到搜索条件'})
    }else{
      tableData.splice(0, tableData.length, ...WorkListdata.data.data);//表格
      console.log(WorkListdata)
      total.value = WorkListdata.data.total;//共多少条
    }
  } catch (error) {
    console.error(error);
  }
}

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

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

//=========修改产品基本资料产品表格弹窗========
let formDataTest = reactive({})
//弹窗
const dialogFormVisible = ref(false)
//双击修改弹窗
const dbclickId = ref()
const updateCompanyFunc = async (row, cols) => {
  dbclickId.value = row.UniqID
  formDataTest = Object.assign(formDataTest,row);
  dialogFormVisible.value = true;
};
//关闭修改弹窗
const closeDialog = () => {
  dialogFormVisible.value = false
}
//点击确定修改表格
const enterDialog = async () => {
  const formattedData = {
    '客户编号': formDataTest['客户编号'],
    '客户名称': formDataTest['客户名称'],
    '印品代号': formDataTest['产品编号'],
    '版本号': formDataTest['版本号'],
    '客户料号': formDataTest['客户料号'],
    '产品名称': formDataTest['产品名称'],
    '产品类别': formDataTest['产品类别'],
    '计量单位': formDataTest['计量单位'],
    '成品规格': formDataTest['成品规格'],
    '产品备注': formDataTest['产品备注'],
  };
  const editProductedit = await editProduct(formattedData);
  if (editProductedit.code === 0) {
    const row = tableData.find(item => item.UniqID === dbclickId.value)
    Object.keys(formDataTest).map( key => {
      row[key] = formDataTest[key]
    })
    ElMessage({type: 'success',message: '更新成功'})
  } else {
    ElMessage({ type: 'error',message: '更新失败'})
  }
  dialogFormVisible.value = false;
}

//=========修改印件资料========
let yjformDataTest = reactive({})
//双击修改
const yjupdateCompanyFunc = async (row) => {
  //3.1获取产品印件资料
  const getProductYjInfo_edit = await getProductYjInfo({UniqId:row.UniqId})
  Object.assign(yjformDataTest,getProductYjInfo_edit.data[0]);
  yjdialogFormVisible.value = true;
};
// 弹窗
const yjdialogFormVisible = ref(false)
//关闭修改弹窗
const yjcloseDialog = () => {
  yjdialogFormVisible.value = false
}
//点击确定修改表格
const yjenterDialog = async () => {
  console.log(yjformDataTest)
  const formattedData = {
    UniqId: yjformDataTest['UniqId'],
    yj_yjno: yjformDataTest['yj_yjno'],
    yj_yjdh: yjformDataTest['yj_yjdh'],
    yj_yjmc: yjformDataTest['yj_yjmc'],
    yj_zzdh: yjformDataTest['yj_zzdh'],
    yj_zzdh1: yjformDataTest['yj_zzdh1'],
    yj_zzdh2: yjformDataTest['yj_zzdh2'],
    yj_zzdh3: yjformDataTest['yj_zzdh3'],
    yj_zzdh4: yjformDataTest['yj_zzdh4'],
    yj_zzmc: yjformDataTest['yj_zzmc'],
    yj_zzmc1: yjformDataTest['yj_zzmc1'],
    yj_zzmc2: yjformDataTest['yj_zzmc2'],
    yj_zzmc3: yjformDataTest['yj_zzmc3'],
    yj_zzmc4: yjformDataTest['yj_zzmc4'],
    yj_tlgg: yjformDataTest['yj_tlgg'],
    yj_klgg: yjformDataTest['yj_klgg'],
    yj_ks: yjformDataTest['yj_ks'],
    yj_ls: yjformDataTest['yj_ls'],
    KgToPages: yjformDataTest['KgToPages'],
    yj_desc: yjformDataTest['yj_desc'],
  };
  //3.2修改产品印件资料
  const editProductYjInfo_edit = await editProductYjInfo(formattedData);
  if (editProductYjInfo_edit.code === 0) {
    ElMessage({type: 'success',message: '更新成功'})
  } else {
    ElMessage({ type: 'error',message: '更新失败'})
  }
  yjdialogFormVisible.value = false;
}

//=========新增印件资料========
//默认弹窗关闭
const add_gdyjdialogFormVisible = ref(false)
//新增弹窗
//全局调用工单编号
const _Gd_gdbh = ref(null)
const cgugdlist = ref(false);
const addcpyj_onclick = () => {
	if(_Gd_gdbh.value == null){
	  cgugdlist.value = false;
	  ElMessage({
	    type: 'warning',
	    message: '请选择具体的工单后，再操作此功能'
	  })
	}else{
	  gdyj_clearFormData();
	  // console.log(yjzuidahaoma.value)
	  add_gdyjdialogFormVisible.value = true
	}
  // add_yjdialogFormVisible.value = true
  // console.log(yjtableData.length)
}
const searchModel = ref(false)
const getProductYjListdata = ref()
const openSearchModal = (code) => {
  if (code.key==='Tab') {
    setTimeout(() =>document.querySelector('#yjdhId').focus(), 50)
    _getProductYjList();
    searchModel.value = true
  }
}
const selectNode = (v) => {
  if (v.children.length === 0) {
    add_yjzlformdata['yjdh'] = v.物料代码
    add_yjzlformdata['yjmc'] = v.物料名称
    searchModel.value= false
  }
}
const getProductZhiListdata = ref()
const searchZhiModel = ref(false)
const zzdhIndex = ref(null)
const openSearchZhiModal = (code, idx) => {
  if (code.key==='Tab') {
    setTimeout(() => document.querySelector('.zhi').focus(), 50)
    _getProductZzList()
    searchZhiModel.value = true
    zzdhIndex.value = idx

  }
}
const _getProductZzList = async ()=>{
  try {
    const response = await getProductZzList({search:''});
    getProductZhiListdata.value = handleTreeData(response.data)
  } catch (error) {
    console.error(error);
  }
}
const _getProductYjList = async ()=>{
  try {
    const response = await getProductYjList({search:''});
    getProductYjListdata.value = handleTreeData(response.data)
  } catch (error) {
    console.error(error);
  }
}
const handleTreeData = (treeData) => {
  let data = []
  Object.keys(treeData).map((key, index) => {
    data.push({
      物料代码:key.match(/\d+/)[0],
      物料名称:key,
      children: []
    })
    if (typeof treeData[key] === 'object') {
      Object.keys(treeData[key]).map((c_key) => {
        data[index].children.push({
          物料代码: c_key.match(/\d+/)[0],
          物料名称: c_key,
          children: []
        })
      })
    } else if (typeof treeData[key] === 'array') {
      treeData[key].map(item => data[index].children.push(item))
    }
  })

  return data
}
const selectZhiNode = (v) => {
  if (v.children.length === 0) {
    if (zzdhIndex.value == 0) {
      add_yjzlformdata['zzdh'] = v.物料代码
      add_yjzlformdata['zzmc'] = v.物料名称
	  console.log(v.物料代码)
	  console.log(v.物料名称)

    } else {
      add_yjzlformdata['zzdh' + zzdhIndex.value] = v.物料代码
      add_yjzlformdata['zzmc' + zzdhIndex.value] = v.物料名称
    }
    searchZhiModel.value = false
  }
}
const yjzuidahaoma = ref(0)
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: '',
  万小张: '',
  KgToPages:'',
});
//清空对象的属性值
const gdyj_clearFormData = () => {
  Object.keys(add_yjzlformdata).forEach(key => {
    add_yjzlformdata[key] = '';
  });
  add_yjzlformdata.yjno = yjzuidahaoma.value;
  add_yjzlformdata['pztl'] = 0;
  add_yjzlformdata['ks'] = 0;
  add_yjzlformdata['ls'] = 0;
  add_yjzlformdata['万小张'] = 0;
};
//印件新增确定
const add_gdyjenterDialog = () => {
  console.log(add_yjzlformdata)
  const formattedData = {
    yj_cpdh: _Gd_gdbh.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'],
    KgToPages:add_yjzlformdata['KgToPages'],
    yj_tlgg: add_yjzlformdata['tl'],
    yj_klgg: add_yjzlformdata['kl'],
    yj_ks: add_yjzlformdata['ks'],
    yj_ls: add_yjzlformdata['ls'],
    yj_desc: add_yjzlformdata['desc'],
    sys_id  : "[1020/邢醉育]",
    // 万小张: add_yjzlformdata['万小张'],
  };
  console.log(formattedData)
  const res=addProductYjInfo(formattedData)
  console.log(res)
  // if(res.code==0){

  // }else{

  // }
  // add_gdyjdialogFormVisible.value = false
}
//印件新增取消
const add_dyjcloseDialog = () => {
  add_gdyjdialogFormVisible.value = false
}
// //印件新增确定
// const add_yjcloseDialog = () => {
//   add_gdyjdialogFormVisible.value = true
// }
// //印件新增取消
// const add_yjenterDialog = () => {
//   add_gdyjdialogFormVisible.value = true
// }
//新增工艺资料
const addgydialogFormVisible = ref(false)
const searchCJModel = ref(false)
const searchSHModel = ref(false)

const addcpgy_onclick = () => {
	addgydialogFormVisible.value=true
  // add_yjdialogFormVisible.value = true
  // console.log(yjtableData.length)
}
const add_gyformData = reactive({
  Gy0_方案: '',
  Gy0_cpdh: '',
  Gy0_yjno: '',
  Gy0_gxh: '',
  Gy0_Ks: '',
  Gy0_ls: '',
  Gy0_site: '',
  gy0_gxmc: '',
  Add_gxmc: '',
  Gy0_Ms: '',
  Gy0_sbbh: '',
  Gy0_shdh: '',
  工价系数: '',
  难度系数:'1.000',
  损耗率:'0.00140',
  损耗系数: '1.000',
  工序备注: '',
  质量要求: '',
  质量隐患: '',
  Sys_id: '',
  标准损耗2:'',
});
const getcjmc = (code) => {
  // if (code.key==='Tab') {
  //   setTimeout(() =>document.querySelector('#yjdhId').focus(), 50)
  //   _getCJList();

  // }
  _getCJList()
}

const getCJListdata = ref([]);
const _getCJList = async () => {
  try {
    const response = await getDepartName({ search: '' });
    getCJListdata.value = Object.keys(response.data).map(process => {
      return {
        label: process,
        level: 1,
        children: Object.keys(response.data[process]).map(department => {
          return {
            label: department,
            level: 2,
            children: response.data[process][department].map(subDepartment => {
              return {
                label: subDepartment,
                level: 3
              };
            })
          };
        })
      };
    });
    searchCJModel.value = true;
  } catch (error) {
    console.error(error);
  }
};
const selectCJNode = (nodeData) => {
  console.log(nodeData.level)

  if(nodeData.level==2){
	console.log(nodeData.label)
	add_gyformData.Gy0_site=nodeData.label
  }
  if(nodeData.level==3){
	console.log(nodeData.label)
	add_gyformData.Add_gxmc=nodeData.label
	searchCJModel.value = false
  }
}
const getSHListdata = ref([]);
const getSH = (code) => {
  _getSH()
}
const _getSH = async () => {
  const response = await getProcessLoss({code:add_gyformData.标准损耗});
  // getSHListdata.value = processData(response.data);
  // searchSHModel.value = true
  console.log(response.data[0].sys_mc)
  add_gyformData.标准损耗2=response.data[0].sys_mc
  console.log(getSHListdata.value);
};
// const processData = (data) => {
//   const map = {};
//   const tree = [];
//   console.log(data)
//   data.forEach(item => {
//     map[item.sys_bh] = { label: `${item.sys_bh} ${item.sys_mc}`, level: 1, children: [] };

//   });


//   data.forEach(item => {
//     if (item.Parent !== "0_") {
//       map[item.Parent].children.push(map[item.sys_bh]);	 console.log(item) }
//    //  } else {
//    //    tree.push(map[item.sys_bh]);
// 	  // console.log(item)
//    //  }
//   });

//   tree.forEach(item => {
// 	  // console.log(item)
//     // if (item.children.length === 0) {
//       // item.children.push({ label: `${item.sys_bh} ${item.sys_mc}`, level: 2 });
//     // }
//   });

//   return tree;
// };
//工艺新增确定
const addgyenterDialog = () => {
  console.log(add_yjzlformdata)
  const formattedData = {
    Gy0_cpdh: _Gd_gdbh.value,
    Gy0_方案: add_gyformData['Gy0_方案'],
    Gy0_yjno: add_gyformData['Gy0_yjno'],
    Gy0_gxh: add_gyformData['Gy0_gxh'],
    Gy0_Ks: add_gyformData['Gy0_Ks'],
    Gy0_ls: add_gyformData['Gy0_ls'],
    Gy0_site: add_gyformData['Gy0_site'],
    gy0_gxmc: add_gyformData['gy0_gxmc'],
    Add_gxmc: add_gyformData['Add_gxmc'],
    Gy0_Ms: add_gyformData['Gy0_Ms'],
    Gy0_sbbh: add_gyformData['Gy0_sbbh'],
    Gy0_shdh: add_gyformData['Gy0_shdh'],
    工价系数: add_gyformData['工价系数'],
    损耗系数: add_gyformData['损耗系数'],
    工序备注:add_gyformData['工序备注'],
    质量要求: add_gyformData['质量要求'],
    质量隐患: add_gyformData['质量隐患'],
    Sys_id  : "[1020/邢醉育]",
    // 万小张: add_yjzlformdata['万小张'],
  };
  console.log(formattedData)
  const res=addProductGyInfo(formattedData)
  console.log(res)
  if(res.code==0){

  }else{

  }
  addgydialogFormVisible.value = false
}
//工艺新增取消
const addgycloseDialog = () => {
  addgydialogFormVisible.value = false
}
//=========新增印版资料========
const addybdialogFormVisible = ref(false)
const addybdisplay = ref(false)
const addyb_keyword = ref('')
const getYBListdata = ref([])
const addybdisplaydata = reactive({
  chbm:'',
  chbmNameOptions:[],
})
const add_ybformDataTest = reactive({
  gongxu:'',
  gongxuNameOptions:[],
})
//点击新增印版资料
const addyb_onclick = async () => {
  console.log(_UniqID)
  if(_UniqID.value === '' || _UniqID.value === undefined || _UniqID.value === null){
    ElMessage({type: 'warning',message: '请选择具体的工单后，再操作此功能'})
    return false;
  }else{
    const getProductYbInfo_list = await getProductYbInfo({UniqID:_UniqID.value});
    console.log(getProductYbInfo_list.data.gy_data)
    //默认取第一个数据
    // add_ybformDataTest.gongxu = getProductYbInfo_list.data.gy_data[0]['gy'];
    add_ybformDataTest.gxmc1 = getProductYbInfo_list.data['印版名称'];
    addybdisplaydata.gongxuNameOptions = getProductYbInfo_list.data.gy_data.map(item=>{
      return item.gy
    });
    addybdialogFormVisible.value = true;
  }

};
//点击下拉框获取数据方案、印件、编号、工艺名称、工序名称
const ongongxufanclick = async (v) => {
  add_ybformDataTest.YB_方案 = add_ybformDataTest.gongxu.split('-->')[0];
  add_ybformDataTest.YB_Yjno = add_ybformDataTest.gongxu.split('-->')[1].split('-')[0];
  add_ybformDataTest.YB_gxh = add_ybformDataTest.gongxu.split('-->')[1].split('-')[1].split('-')[0].split(' ')[0];
  add_ybformDataTest.YB_gymc = add_ybformDataTest.gongxu.split('-->')[1].split('-')[1].split('-')[0].split(' ')[1];
  add_ybformDataTest.YB_gxmc = add_ybformDataTest.gxmc1;
  // addybdialogFormVisible.value = false;
};

//新增印版资料确定
const addtbenterDialog = async () => {
  // console.log(add_ybformDataTest)
  if(add_ybformDataTest.YB_方案 === '' || add_ybformDataTest.YB_方案 === undefined){
    ElMessage({type: 'warning',message: '工艺方案不能为空'})
    return false;
  }
  if(add_ybformDataTest.物料代码 === '' || add_ybformDataTest.物料代码 === undefined){
    ElMessage({type: 'warning',message: '存货编码不能为空'})
    return false;
  }
  const formattedData = {
    YB_Cpdh: _Gd_gdbh.value,
    YB_方案: add_ybformDataTest.YB_方案 ,
    YB_Yjno: add_ybformDataTest.YB_Yjno,
    YB_gxh: add_ybformDataTest.YB_gxh,
    存货编码: add_ybformDataTest.物料代码,
    印版名称: add_ybformDataTest.物料名称,
    Sys_id: '[1016/邹训敏]',
    // 印版备注: add_ybformDataTest.ybbz,
  };
  // console.log(formattedData)
  const addProductYbInfo_add = await addProductYbInfo(formattedData);
  console.log(addProductYbInfo_add)
  if(addProductYbInfo_add.code === 0) {
    ElMessage({type: 'success',message: '更新成功'})
    addybdialogFormVisible.value = false;
  } else {
    ElMessage({type: 'error',message: '更新失败' })
  }
};
//新增印版资料取消
const addtbcloseDialog = async () => {
  addybdialogFormVisible.value = false;
};

//新增印版资料弹窗 键盘 input框跳转
const add_ybzlent = async (event,id1,id2,id3) => {
  if (id2==='YB_gxmc' && event.key==='Tab' || id2 === 'YB_gxmc' && event.key=== 'Enter') {
    addybdisplay.value = true
    addyb_keyword.value = '';
    await _getProductYbMaterialList();
  }
  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()
    }
  }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 addyb_searchHandle = async () => {
  await _getProductYbMaterialDetail();
};
//3.11印版资料-获取存货名称列表
const _getProductYbMaterialList = async () => {
  const getProductYbMaterialList_list = await getProductYbMaterialList();
  //默认取第一个数据
  addybdisplaydata.chbm = getProductYbMaterialList_list.data[0]['编号'] + "【" + getProductYbMaterialList_list.data[0]['名称'] + "】";
  addybdisplaydata.chbmNameOptions = getProductYbMaterialList_list.data.map(item=>{
    return `${item.编号}【${item.名称}】`
  });
};

//点击下拉框获取输入框的值
const onybzlfanclick = async () => {
  await _getProductYbMaterialDetail();
}

const addyb_selectSHNode = async (v) => {
  console.log(v.物料代码)
  if(v.物料名称){
    add_ybformDataTest.物料代码 = v.物料代码
    add_ybformDataTest.物料名称 = v.物料名称
    addybdisplay.value = false
  }
}

//点击下拉框获取输入框的值
const _getProductYbMaterialDetail = async () => {
  const code = addybdisplaydata.chbm.split('【')[0];
  console.log(code)
  console.log(addyb_keyword.value)
  const getProductYbMaterialDetail_list = await getProductYbMaterialDetail({code:code,search:addyb_keyword.value});
  getYBListdata.value = Object.keys(getProductYbMaterialDetail_list.data).map((key)=>({
    label:key,
    children: Object.keys(getProductYbMaterialDetail_list.data[key]).map((keys)=>({
      label:keys,
      children:Object.keys(getProductYbMaterialDetail_list.data[key][keys]).map((keyss)=>({
        label:keyss,
        children:getProductYbMaterialDetail_list.data[key][keys][keyss].map(item=>({
          label:`${item.物料代码}/${item.物料名称}/${item.规格}`,
          物料代码:item.物料代码,
          物料名称:item.物料名称,
        }))
      }))
    }))
  }))
}


//=========修改工艺资料========
let gyformDataTest = reactive({})
//双击修改
const gyupdateCompanyFunc = async (row) => {
  //3.6工艺资料-获取产品工艺资料
  const getProductGyInfo_edit = await getProductGyInfo({UniqID:row.UniqID})
  console.log(getProductGyInfo_edit)
  Object.assign(gyformDataTest,getProductGyInfo_edit.data);
  gydialogFormVisible.value = true;
};
//默认关闭弹窗
const gydialogFormVisible = ref(false)
//工艺修改确定
const gyenterDialog = () => {
  // console.log(gyformDataTest)
  const formattedData = {
    Gy0_方案: gyformDataTest['Gy0_方案'],
    Gy0_yjno: gyformDataTest['Gy0_yjno'],
    Gy0_gxh: gyformDataTest['Gy0_gxh'],
    Gy0_Ks: gyformDataTest['Gy0_Ks'],
    Gy0_ls: gyformDataTest['Gy0_ls'],
    Gy0_site: gyformDataTest['Gy0_site'],
    gy0_gxmc: gyformDataTest['gy0_gxmc'],
    Add_gxmc: gyformDataTest['Add_gxmc'],
    Gy0_Ms: gyformDataTest['Gy0_Ms'],
    Gy0_sbbh: gyformDataTest['Gy0_sbbh'],
    工价系数: gyformDataTest['工价系数'],
    Gy0_shdh: gyformDataTest['Gy0_shdh'],
    sys_mc: gyformDataTest['sys_mc'],
    sys_rate0: gyformDataTest['sys_rate0'],
    sys_rate1: gyformDataTest['sys_rate1'],
    损耗系数: gyformDataTest['损耗系数'],
    工序备注: gyformDataTest['工序备注'],
    质量要求: gyformDataTest['质量要求'],
    质量隐患: gyformDataTest['质量隐患'],

  };
  console.log(formattedData)
  // const editdata = await 修改工艺接口函数(formattedData);

  // if (editdata.code === 0) {
  //   ElMessage({type: 'success',message: '更新成功'})
  // } else {
  //   ElMessage({ type: 'error',message: '更新失败'})
  // }
  // gydialogFormVisible.value = true
}
//关闭修改弹窗
const gycloseDialog = () => {
  gydialogFormVisible.value = false
}

//=========印版修改========
let ybformDataTest = reactive({})
//双击修改
const ybupdateCompanyFunc = async (row) => {
  console.log(ybformDataTest)
  console.log(row)
  Object.assign(ybformDataTest,row);
  // ybformDataTest = row;
  ybdialogFormVisible.value = true;
};
// 弹窗
const ybdialogFormVisible = ref(false)
// 打开修改弹窗
const ybenterDialog = () => {
  console.log(ybformDataTest)
  const formattedData = {
    '工序方案': ybformDataTest['YB_方案'],
    '印件号': ybformDataTest['YB_Yjno'],
    '存货编码': ybformDataTest['存货编码'],
    '印版名称': ybformDataTest['印版名称'],
  };
  console.log(formattedData)
  // const editdata = await 修改印版接口函数(formattedData);
  // if (editdata.code === 0) {
  //   ElMessage({type: 'success',message: '更新成功'})
  // } else {
  //   ElMessage({ type: 'error',message: '更新失败'})
  // }
  // ybdialogFormVisible.value = true
}
// 关闭弹窗
const ybcloseDialog = () => {
  ybdialogFormVisible.value = false
}

//===========改变按钮中表格修改背景颜色=========
//计损色数修正表格修改颜色  :cell-style="setInputCellStyle"
const setInputCellStyle = (data) => {
  const jiSun = ['ms_coe', 'Gy0_Ks', 'Gy0_ls', 'Add_gxmc', 'remark']
  let style = { padding: 0 }
  if (data.column?.property && jiSun.includes(data.column?.property)) {
    Object.assign(style, { backgroundColor: '#42b983'})
  }
  return style
}

//键盘 input框跳转
const ent = (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  _yjdh = ref(null);
const yj_ent = (event,id1,id2,id3) => {
  // if(event.keyCode == 13){
  //   if(yjformDataTest['yj_yjdh']){
  //     _getProductDatat()
  //   }
  // }
  if ( 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 tableDataCellClass = ({row, column, rowIndex, columnIndex}) =>{
  if (column.property === 'gyData' || column.property === 'yjData') {
    return 'plan-usage-low';
  }
}
</script>
<style scoped>
:deep(.plan-usage-low div) {
  color: red !important;
}
.JKWTree-container {
  display: flex;
}
.JKWTree-tree {
  width: 300px;
  background-color: #fff;
  /*background-color: rgba(241, 224, 224, 0.99);*/
  padding: 10px;
  margin-right: 20px;
}
.JKWTree-tree h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 10px 0;
}
.JKWTree-content {
  flex: 1;
}
:deep(.el-table__body .warning-row) {
  background: #FFFF80 !important;
}
/* 选中某行时的背景色 */
:deep(.el-table__body tr.current-row) > td {
  background: #ff80ff !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;
}
.mab{
  margin-bottom: 5px;
}
</style>
