<template>
  <div>
    <el-container>

      <!-- <el-scrollbar height="550px">
        <el-aside>
          <div class="JKWTree-tree">
            <h3>工序大废品奖惩记录</h3>
            <el-tree
              :data="treeData"
              :props="defaultProps"
              @node-click="handleNodeClick"
            />
          </div>
        </el-aside>
      </el-scrollbar> -->
	  
	  <layout-sider
	    :resize-directions="['right']"
	    :width="220"
	    style="margin-right: 10px;"
	  >
	    <div
	      class="JKWTree-tree"
	      style="height: 70vh;"
	    >
	      <h3>工序大废品奖惩记录</h3>
	      <el-tree
	        :data="treeData"
	        highlight-current
	        @node-click="handleNodeClick"
	      />
	    </div>
	  </layout-sider>

      <el-container>
        <!--        <el-header>dd</el-header>-->
        <el-main>

          <div class="gva-search-box">
            <el-form
              ref="elSearchFormRef"
              :inline="true"
              :model="searchInfo"
              class="demo-form-inline"
              :rules="searchRule"
              @keyup.enter="onSubmit"
            >
              <el-form-item>
                <el-input
                  v-model="detailData.image"
                  :clearable="true"
                  placeholder="输入工单编号或产品名称"
                />
              </el-form-item>
              <el-form-item>
                <el-button
                  type="primary"
                  icon="search"
                  @click="onSubmit"
                >查询</el-button>
				<el-button
				  type="primary"
				  icon="search"
				  @click="onAdd"
				>新增</el-button>
				<el-button
				  type="primary"
				  icon="search"
				  @click="onDel"
				>删除</el-button>
                <el-button
                  icon="refresh"
                  @click="onReset"
                >切换显示方式</el-button>
              </el-form-item>
            </el-form>
          </div>
          <div class="gva-table-box">
            <el-table
              ref="multipleTable"
              style="width: 100%"
              border
              tooltip-effect="dark"
              :data="tableData"
              row-key="ID"
              :show-overflow-tooltip="true"
              highlight-current-row
              :row-style="{ height: '20px' }"
              :cell-style="{ padding: '0px' }"
              :header-row-style="{ height: '20px' }"
              :header-cell-style="{ padding: '0px' }"
              @selection-change="handleSelectionChange"
              @row-dblclick="handleDoubleClick"
			  @row-click="Click"
            >
              <el-table-column
                type="selection"
                width="55"
              />
              <el-table-column
                align="left"
                label="工单编号"
                prop="sczl_gdbh"
                width="90" sortable
              />
              <el-table-column
                align="left"
                label="印件名称"
                prop="yj_yjmc"
                width="210" sortable
              />
              <el-table-column
                align="left"
                label="日期"
                prop="sczl_rq"
                width="100" sortable
              />
              <el-table-column
                align="left"
                label="流程单备注"
                prop="sczl_numDesc"
                width="100" sortable
              />
              <el-table-column
                align="left"
                label="联数"
                prop="sczl_ls"
                width="70" sortable
              />
              <el-table-column
                align="left"
                label="责任部门"
                prop="责任部门"
                width="90" sortable
              />
              <el-table-column
                align="left"
                label="大废品数"
                prop="sczl_cl"
                width="90" sortable
              />
              <el-table-column
                align="left"
                label="废品类型"
                prop="sczl_fplxA"
                width="100" sortable
              />
              <el-table-column
                align="left"
                label="废品来源"
                prop="sczl_fplxB"
                width="90" sortable
              />
              <el-table-column
                align="left"
                label="奖励班组"
                prop="Jl_bzdh"
                width="90" sortable
              />
              <el-table-column
                align="left"
                label="检验员工"
                prop="JL_bh1"
                width="90" sortable
              />
              <el-table-column
                align="left"
                label="责任班组"
                prop="sczl_bzdh"
                width="90" sortable
              />
              <el-table-column
                align="left"
                label="责任员工1"
                prop="sczl_bh1"
                width="90" sortable
              />
              <el-table-column
                align="left"
                label="责任员工2"
                prop="sczl_bh2"
                width="90" sortable
              />
              <el-table-column
                align="left"
                label="创建用户"
                prop="sys_id"
                width="120" sortable
              />
              <el-table-column
                align="left"
                label="创建时间"
                prop="sys_rq"
                width="160" sortable
              />
              <el-table-column
                align="left"
                label="UNIQID"
                prop="UniqId"
                width="80" sortable
              />
            </el-table>
            <div class="gva-pagination">
              <el-pagination
                layout="total, sizes, prev, pager, next, jumper"
                :current-page="page"
                :page-size="pageSize"
                :page-sizes="[10, 30, 50, 100]"
                :total="total"
                @current-change="handleCurrentChange"
                @size-change="handleSizeChange"
              />
            </div>
          </div>
          <el-dialog
            v-model="dialogFormVisible"
            :before-close="closeDialog"
            :title="type === 'create' ? '新增' : '修改'"
            destroy-on-close
            style="width: 1020px;position: fixed; top: 35%; left: 50%; transform: translate(-50%, -50%);"
          >
            <el-scrollbar height="70vh">
              <el-form
                ref="elFormRef"
                :model="detailData"
                :inline="true"
                style="margin-bottom: 0px;"
                label-position="right"
                :rules="rule"
                label-width="80px"
                aria-="true"
              >
                <el-form-item
                  label="工单编号:"
                  prop="address"
                  style="margin-right: 120px;"
                >
                  <el-input
                    v-model="detailData.sczl_gdbh"
                    @keydown="ent1($event)"
					@blur="getCPMCsubmit()"
                    style="width: 120px;"
                  />
                </el-form-item>
                <el-form-item
                  label="产品名称:"
                  prop="image"
                >
                  <el-input
                    v-model="detailData.Gd_cpmc"
                    @keydown="ent1($event)"
                    placeholder="请输入产品名称"
                    style="width: 450px;"
                  />
                </el-form-item>
              </el-form>
              <el-form
                ref="elFormRef"
                :model="detailData"
                :inline="true"
                label-position="right"
                :rules="rule"
                label-width="80px"
              >
                <el-form-item
                  label="印件号:"
                  prop="address"
                  style="margin-right: 120px;"
                >
                  <el-input
                    v-model="detailData.sczl_yjno"
                    @keydown="ent1($event)"
					@blur="getYJMCsubmit()"
                    style="width: 120px;"
                  />
                </el-form-item>
                <el-form-item
                  label="印件名称:"
                  prop="image"
                >
                  <el-input
                    v-model="detailData.yj_yjmc"
                    @keydown="ent1($event)"
                    style="width: 450px;"
                  />
                </el-form-item>
              </el-form>
              <el-form
                ref="elFormRef"
                :model="detailData"
                :inline="true"
                label-position="right"
                :rules="rule"
                label-width="90px"
              >
                <el-form-item
                  label="工序名称:"
                  prop="address"
                >
                  <el-input
                    v-model="detailData.sczl_gxmc"
                    @blur="getGXsubmit()"
					 @keydown="ent1($event)"
                    style="width: 300px;"
                  />
                </el-form-item>
                <el-form-item prop="image">
                  <el-input
                    v-model="detailData.sczl_gxh"
                     @keydown="ent1($event)"
                    style="width: 50px;"
                  />
                </el-form-item>
                <el-form-item
                  label="流程单备注:"
                  prop="image"
                >
                  <el-input
                    v-model="detailData.sczl_numDesc"
                     @keydown="ent1($event)"
                  />
                </el-form-item>
              </el-form>
              <el-form
                ref="elFormRef"
                :model="detailData"
                :inline="true"
                label-position="right"
                :rules="rule"
                label-width="80px"
              >
                <el-form-item
                  label="日期:"
                  prop="address"
                  style="margin-right: 120px;"
                >
                  <el-input
                    v-model="detailData.sczl_rq"
                     @keydown="ent1($event)"
                    style="width: 120px;"
                  />
                </el-form-item>
                <el-form-item
                  label="废品数量:"
                  prop="image"
                >
                  <el-input
                    v-model="detailData.sczl_cl"
                     @keydown="ent1($event)"
                    style="width: 120px;"
                  />
                </el-form-item>
                <el-form-item
                  label="联数:"
                  prop="image"
                >
                  <el-input
                    v-model="detailData.sczl_ls"
                     @keydown="ent1($event)"
                    style="width: 120px;"
                  />
                </el-form-item>
              </el-form>
              <el-form
                ref="elFormRef"
                :model="detailData"
                :inline="true"
                label-position="right"
                :rules="rule"
                label-width="90px"
              >
                <el-form-item
                  label="废品备注:"
                  prop="address"
                >
                  <el-input
                    v-model="detailData.sczl_fplxA"
                     @keydown="ent1($event)"
                    style="width: 300px;"
                  />
                </el-form-item>
                <el-form-item>
                  <el-checkbox
                    v-model="detailData"
                    style="width: 30px;"
					 @keydown="ent1($event)"
                  >制程废</el-checkbox>
                </el-form-item>
                <el-form-item
                  label="责任部门:"
                  prop="image"
                >
                  <el-input
                    v-model="detailData.责任部门"
                     @keydown="ent1($event)"
                    style="width: 250px;"
                  />
                </el-form-item>
              </el-form>
              <el-form
                ref="elFormRef"
                :model="detailData"
                :inline="true"
                label-position="right"
                :rules="rule"
              >
                <el-form-item>
                  <div
                    class="sub-title"
                    style="width: 193px; height: 10px;"
                  />
                  <div
                    class="sub-title"
                    style="width: 83.5px; height: 10px;"
                  >组员1</div>
                  <div
                    class="sub-title"
                    style="width: 83.5px; height: 10px;"
                  >组员2</div>
                  <div
                    class="sub-title"
                    style="width: 83.5px; height: 10px;"
                  >组员3</div>
                  <div
                    class="sub-title"
                    style="width: 83.5px; height: 10px;"
                  >组员4</div>
                  <div
                    class="sub-title"
                    style="width: 83.5px; height: 10px;"
                  >组员5</div>
                  <div
                    class="sub-title"
                    style="width: 83.5px; height: 10px;"
                  >组员6</div>
                  <div
                    class="sub-title"
                    style="width: 83.5px; height: 10px;"
                  >组员7</div>
                  <div
                    class="sub-title"
                    style="width: 83.5px; height: 10px;"
                  >组员8</div>
                  <div
                    class="sub-title"
                    style="width: 83.5px; height: 10px;"
                  >组员9</div>
                </el-form-item>
              </el-form>
              <el-form
                ref="elFormRef"
                :model="detailData"
                :inline="true"
                label-position="right"
                :rules="rule"
              >
                <el-form-item>
                  <div class="sub-title">奖励班组：</div>
                  <el-input
                    v-model="detailData.Jl_bzdh"
                     @keydown="ent1($event)"
                    style="width: 45px;"
                  />
                  <el-input
                    v-model="detailData.jl_jtbh"
                     @blur="getJtbhsubmit('1')"
					 @keydown="ent1($event)"
					id="jt"
                    style="width: 65px;"
                  />
                  <el-input
                    v-model="detailData.JL_bh1"
                    id="bh1"  @keydown="ent($event, 'jt', 'bh1', 'bh2')" @keyup.enter.native="GetYg($event, '1')"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.JL_bh2"
                    id="bh2"  @keydown="ent($event, 'bh1', 'bh2', 'bh3')" @keyup.enter.native="GetYg($event, '2')"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.JL_bh3"
                    id="bh3"  @keydown="ent($event, 'bh2', 'bh3', 'bh4')" @keyup.enter.native="GetYg($event, '3')"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.JL_bh4"
                    id="bh4"  @keydown="ent($event, 'bh3', 'bh4', 'bh5')" @keyup.enter.native="GetYg($event, '4')"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.JL_bh5"
                    id="bh5"  @keydown="ent($event, 'bh4', 'bh5', 'bh6')" @keyup.enter.native="GetYg($event, '5')"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.JL_bh6"
                    id="bh6"  @keydown="ent($event, 'bh5', 'bh6', 'bh7')" @keyup.enter.native="GetYg($event, '6')"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.JL_bh7"
                    id="bh7"  @keydown="ent($event, 'bh6', 'bh7', 'bh8')" @keyup.enter.native="GetYg($event, '7')"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.JL_bh8"
                    id="bh8"  @keydown="ent($event, 'bh7', 'bh8', 'bh9')" @keyup.enter.native="GetYg($event, '8')"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.JL_bh9"
                    id="bh9"  @keydown="ent($event, 'bh8', 'bh9', 'name1')" @keyup.enter.native="GetYg($event, '9')"
                    style="width: 85px;"
                  />
                </el-form-item>
              </el-form>
              <el-form
                ref="elFormRef"
                :model="detailData"
                :inline="true"
                label-position="right"
                :rules="rule"
              >
                <el-form-item>
                  <div
                    class="sub-title"
                    style="width: 182px;"
                  />
                  <el-input
                    v-model="detailData.jlname1"
                    id="name1"
					 @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.jlname2"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.jlname3"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.jlname4"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.jlname5"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.jlname6"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.jlname7"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.jlname8"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.jlname9"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                </el-form-item>
              </el-form>
              <el-form
                ref="elFormRef"
                :model="detailData"
                :inline="true"
                label-position="right"
                :rules="rule"
              >
                <el-form-item>
                  <div
                    class="sub-title"
                    style="width: 182px;"
                  >奖励金额：</div>
                  <el-input
                    v-model="detailData.JL_Je1"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.JL_Je2"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.JL_Je3"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.JL_Je4"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.JL_Je5"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.JL_Je6"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.JL_Je7"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.JL_Je8"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.JL_Je9"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                </el-form-item>
              </el-form>
              <el-form
                ref="elFormRef"
                :model="detailData"
                :inline="true"
                label-position="right"
                :rules="rule"
              >
                <el-form-item>
                  <div
                    class="sub-title"
                    style="width: 193px; height: 10px;"
                  />
                  <div
                    class="sub-title"
                    style="width: 83.5px; height: 10px;"
                  >组员1</div>
                  <div
                    class="sub-title"
                    style="width: 83.5px; height: 10px;"
                  >组员2</div>
                  <div
                    class="sub-title"
                    style="width: 83.5px; height: 10px;"
                  >组员3</div>
                  <div
                    class="sub-title"
                    style="width: 83.5px; height: 10px;"
                  >组员4</div>
                  <div
                    class="sub-title"
                    style="width: 83.5px; height: 10px;"
                  >组员5</div>
                  <div
                    class="sub-title"
                    style="width: 83.5px; height: 10px;"
                  >组员6</div>
                  <div
                    class="sub-title"
                    style="width: 83.5px; height: 10px;"
                  >组员7</div>
                  <div
                    class="sub-title"
                    style="width: 83.5px; height: 10px;"
                  >组员8</div>
                  <div
                    class="sub-title"
                    style="width: 83.5px; height: 10px;"
                  >组员9</div>
                </el-form-item>
              </el-form>
              <el-form
                ref="elFormRef"
                :model="detailData"
                :inline="true"
                label-position="right"
                :rules="rule"
              >
                <el-form-item>
                  <div class="sub-title">责任班组：</div>
                  <el-input
                    v-model="detailData.sczl_bzdh"
                     @keydown="ent1($event)"
                    style="width: 45px;"
                  />
                  <el-input
                    v-model="detailData.sczl_jtbh"
                    id="jt2"
					 @blur="getJtbhsubmit('2')"
					 @keydown="ent1($event)"
                    style="width: 65px;"
                  />
                  <el-input
                    v-model="detailData.sczl_bh1"
                    id="dh1"  @keydown="ent($event, 'jt2', 'dh1', 'dh2')" @keyup.enter.native="GetYg($event, '10')"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.sczl_bh2"
                    id="dh2"  @keydown="ent($event, 'dh1', 'dh2', 'dh3')" @keyup.enter.native="GetYg($event, '11')"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.sczl_bh3"
                   id="dh3"  @keydown="ent($event, 'dh2', 'dh3', 'dh4')" @keyup.enter.native="GetYg($event, '12')"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.sczl_bh4"
                   id="dh4"  @keydown="ent($event, 'dh3', 'dh4', 'dh5')" @keyup.enter.native="GetYg($event, '13')"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.sczl_bh5"
                    id="dh5"  @keydown="ent($event, 'dh4', 'dh5', 'dh6')" @keyup.enter.native="GetYg($event, '14')"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.sczl_bh6"
                    id="dh6"  @keydown="ent($event, 'dh5', 'dh6', 'dh7')" @keyup.enter.native="GetYg($event, '15')"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.sczl_bh7"
                    id="dh7"  @keydown="ent($event, 'dh6', 'dh7', 'dh8')" @keyup.enter.native="GetYg($event, '16')"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.sczl_bh8"
                   id="dh8"  @keydown="ent($event, 'dh7', 'dh8', 'dh9')" @keyup.enter.native="GetYg($event, '17')"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.sczl_bh9"
                    id="dh9"  @keydown="ent($event, 'dh8', 'dh9', 'name2')" @keyup.enter.native="GetYg($event, '18')"
                    style="width: 85px;"
                  />
                </el-form-item>
              </el-form>
              <el-form
                ref="elFormRef"
                :model="detailData"
                :inline="true"
                label-position="right"
                :rules="rule"
              >
                <el-form-item>
                  <div
                    class="sub-title"
                    style="width: 182px;"
                  />
                  <el-input
                    v-model="detailData.zrname1"
                    id="name2"
					 @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.zrname2"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.zrname3"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.zrname4"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.zrname5"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.zrname6"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.zrname7"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.zrname8"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.zrname9"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                </el-form-item>
              </el-form>
              <el-form
                ref="elFormRef"
                :model="detailData"
                :inline="true"
                label-position="right"
                :rules="rule"
              >
                <el-form-item>
                  <div
                    class="sub-title"
                    style="width: 182px;"
                  >处罚金额：</div>
                  <el-input
                    v-model="detailData.sczl_je1"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.sczl_je2"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.sczl_je3"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.sczl_je4"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.sczl_je5"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.sczl_je6"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.sczl_je7"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.sczl_je8"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                  <el-input
                    v-model="detailData.sczl_je9"
                     @keydown="ent1($event)"
                    style="width: 85px;"
                  />
                </el-form-item>
              </el-form>
            </el-scrollbar>
            <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="dialogSelectVisible" title="选择" destroy-on-close width="800px" @keydown="selectGX($event)">
		    <el-table tooltip-effect="dark" :data="selectData" row-key="ID" 
			highlight-current-row="true" border style="width:100%" @row-dblclick="handleSelectClick" ref="table2">
		      <el-table-column label="工序名称" width="225">
		        <template v-slot="{ row }">
		          {{ row }}
		        </template>
		      </el-table-column>
		    </el-table>
		  </el-dialog>
		  
		  
		  <el-dialog v-model="JtbhVisible" title="选择" destroy-on-close width="800px" >
		    <el-table tooltip-effect="dark" :data="selectDataJtbh" row-key="ID"
		      highlight-current-row="true" border style="width:100%"
		      @row-dblclick="SelectClickJtbh"
		    >
		      <el-table-column prop="设备编号" label="设备编号" width="150" />			        	 			        	 
		    </el-table>
		  </el-dialog>


		  

          <el-dialog
            v-model="detailShow"
            style="width: 800px"
            lock-scroll
            :before-close="closeDetailShow"
            title="查看详情"
            destroy-on-close
          >
            <el-scrollbar height="550px">
              <el-descriptions
                column="1"
                border
              >
                <el-descriptions-item label="address字段">
                  {{ detailData.address }}
                </el-descriptions-item>
                <el-descriptions-item label="image字段">
                  {{ detailData.image }}
                </el-descriptions-item>
                <el-descriptions-item label="name字段">
                  {{ detailData.name }}
                </el-descriptions-item>
              </el-descriptions>
            </el-scrollbar>
          </el-dialog>

        </el-main>

      </el-container>
    </el-container>

  </div>
</template>

<script setup>
import { getRewardDetail, getRewardList, getRewardTab, getRewardTabByGd,JunkWorkOrderList,PrintCodeList,
ProcessList,MachineClassList,MachineList,JunkDetailDel,JunkDetailEdit,JunkDetailAdd} from '@/api/mes/job'
import {getYg} from '@/api/jixiaoguanli/jitairibaobiao'
import { createCompany, deleteCompany, deleteCompanyByIds, findCompany, updateCompany } from '@/api/company'
import { Layout, LayoutContent, LayoutHeader, LayoutSider } from '@arco-design/web-vue'
// 全量引入格式化工具 请按需保留
import { ElMessage, ElMessageBox } from 'element-plus'
import { ref, reactive, nextTick, onMounted, onBeforeMount } from 'vue'
import { useUserStore } from '@/pinia/modules/user'
const userStore = useUserStore() 
const sys_id='['+userStore.userInfo.userName+'/'+userStore.userInfo.nickName+']'
defineOptions({
  name: 'Company'
})

const treeData = ref([])
const displayMod = ref('')
// 侧边栏
const RewardTab = async() => {
  const getRewardTabs = await getRewardTab()
  if (getRewardTabs.code === 0) {
    treeData.value = getRewardTabs.data.map((item) => ({
      label: `${item.date.replace(/-/g, '.')}【单据数: ${item.counts}张】`,
      params: {
        date: item.date.replace(/\./g, '-'),
      }
    }))
    displayMod.value = 'date'
  }
}
RewardTab()

const RewardTabByGd = async() => {
  const getRewardTabs = await getRewardTabByGd()
  if (getRewardTabs.code === 0) {
    treeData.value = getRewardTabs.data.map((item) => ({
      label: item.label,
      params: {
        date: item.sczl_gdbh
      }
    }))
    displayMod.value = 'gd'
  }
}

const handleNodeClick = (node, check) => {
  // 存放当前节点的nodeId
  // console.log(node, check)
  if (node.params) {
    params.date = node.params.date
    getTableData()
  }
}

// 切换显示方式
const onReset = () => {
  if (displayMod.value === 'date') {
    RewardTabByGd()
  } else {
    RewardTab()
  }
}

// 验证规则
const rule = reactive({
})

const searchRule = reactive({
  createdAt: [
    { validator: (rule, value, callback) => {
      if (searchInfo.value.startCreatedAt && !searchInfo.value.endCreatedAt) {
        callback(new Error('请填写结束日期'))
      } else if (!searchInfo.value.startCreatedAt && searchInfo.value.endCreatedAt) {
        callback(new Error('请填写开始日期'))
      } else if (searchInfo.value.startCreatedAt && searchInfo.value.endCreatedAt && (searchInfo.value.startCreatedAt.getTime() === searchInfo.value.endCreatedAt.getTime() || searchInfo.value.startCreatedAt.getTime() > searchInfo.value.endCreatedAt.getTime())) {
        callback(new Error('开始日期应当早于结束日期'))
      } else {
        callback()
      }
    }, trigger: 'change' }
  ],
})

const elFormRef = ref()
const elSearchFormRef = ref()

// =========== 表格控制部分 ===========
const page = ref(1)
const total = ref(0)
const pageSize = ref(10)
const tableData = ref([])
const searchInfo = ref({})
const params = {
  date: '',
  page: page.value.toString(),
  limit: pageSize.value.toString(),
}

// 搜索
const onSubmit = () => {
  elSearchFormRef.value?.validate(async(valid) => {
    if (!valid) return
    page.value = 1
    pageSize.value = 10
    getTableData()
  })
}

// 分页
const handleSizeChange = (val) => {
  pageSize.value = val
  params.limit = val.toString()
  getTableData()
}

// 修改页面容量
const handleCurrentChange = (val) => {
  page.value = val
  params.page = val.toString()
  getTableData()
}

// 查看详情
const detailData = reactive({})
const handleDoubleClick = async(row) => {
  type.value = 'update';
  const { UniqId } = row
  console.log(UniqId)
  const res = await getRewardDetail({ UniqId })
  console.log(res)
  if (res.code === 0) {
    console.log(res)
    Object.assign(detailData, res.data[0])
    dialogFormVisible.value = true
  }
}
let lastCellValue=ref()
// 单击表格操作
function Click(row, column, event) {
    lastCellValue= row['UniqId'];
	console.log(lastCellValue)
}
// 查询
const getTableData = async() => {
  const table = await getRewardList(params)
  if (table.code === 0) {
    tableData.value = table.data.rows
    total.value = table.data.total
  }
}
const ADD=ref('0')
//新增
function onAdd() {
	ADD.value='新增'
	type.value = 'create'
	GetInfo(lastCellValue)
	// Productionadd()
}
// getTableData()
//获取详细信息
const GetInfo = async (value) => {
  const res = await getRewardDetail({ UniqId:value })
  if (res.code === 0) {
	 console.log(res)
	 Object.assign(detailData, res.data[0])
	 dialogFormVisible.value = true
  }
}
//工单编号回车事件
const getCPMCsubmit = () => {
	if(detailData.sczl_gdbh!=''){
		JunkWorkOrderList({search:detailData.sczl_gdbh}).then(response=>{
		  if (response.code === 0) {
			  detailData.Gd_cpmc = response.data[0].产品名称			  
			}else{
				detailData.Gd_cpmch = '';
			}
		});
		PrintCodeList({workorder:detailData.sczl_gdbh}).then(response=>{
		  if (response.code === 0) {
			  detailData.sczl_yjno = response.data[0].印件号	
			  detailData.yj_yjmc = response.data[0].印件名称	
			}else{
				detailData.sczl_yjno = ''
				detailData.yj_yjmc = ''
			}
		});
	}else{
		ElMessage({
		  type: 'error',
		  message: '请注意, 工单编号输入空置, 除非有特殊需要！'
		})
	}
}
//印件号失去焦点事件
// const getYJMCsubmit = () => {
//  if(detailData.sczl_gdbh!='' && formData.value.sczl_yjno!=''){
//  	//获取印件名称
// 	productionYjmc({gdbh:formData.value.sczl_gdbh,yjno:formData.value.sczl_yjno}).then(response=>{
//  	  if (response.code === 0) {
//  		  formData.value.yj_yjmc = response.data.yj_yjmc
//  		  gxmc.value = response.data.gxmc
// 		  formData.value.sczl_gxmc = gxmc.value.sczl_gxmc;
// 		  setColorReadonly('印件名称')
		  
//  		}else{
//  			ElMessage({
//  			  type: 'error',
//  			  message: '印件编号不存在, 将恢复默认值, 请仔细确认数据准确性！'
//  			})
//  			formData.value.sczl_yjno = yjnoArr.value[0];
//  			formData.value.yj_yjmc = '';
// 			gxmc.value = '';
//  		}
//  	});
//  }else{
//  	ElMessage({
//  	  type: 'error',
//  	  message: '印件编号不存在, 将恢复默认值, 请仔细确认数据准确性！'
//  	})
// 	formData.value.sczl_yjno = yjnoArr.value[0];
// 	formData.value.yj_yjmc = '';
// 	gxmc.value = '';
//  }
// }
const dialogSelectVisible=ref(false)
const selectData=reactive([])
//工序失去焦点事件
const getGXsubmit = () => {
	//弹出选择
	ProcessList({workorder:detailData.sczl_gdbh,yjno: detailData.sczl_yjno}).then(response=>{
		if (response.code === 0) {
			  selectData.splice(0, selectData.length, ...response.data)
			  console.log(selectData)
			  dialogSelectVisible.value=true			
		  }
	})		
}
// 工单选择框
const handleSelectClick = (row, column, event) => {
  console.log(row)
  detailData.sczl_gxmc=row
  dialogSelectVisible.value=false
}
//机台选择
const selectDataJtbh = reactive([])
const JtbhVisible = ref(false)
const SelectClickJtbh = (row, column, event) => {
  const {设备编号 } = row
 if(jtbh.value==='JL'){
 	detailData.jl_jtbh=row.设备编号
 }else if(jtbh.value==='ZR'){
 	detailData.sczl_jtbh=row.设备编号
 }
  JtbhVisible.value = false
}
const jtbh=ref()
//机台失去焦点事件
const getJtbhsubmit = (value) => {
	if(value==='1'){
		jtbh.value='JL'
	}else if(value==='2'){
		jtbh.value='ZR'
	}
	console.log(jtbh.value)
	MachineList().then(response=>{
		if (response.code === 0) {			
		selectDataJtbh.splice(0, selectDataJtbh.length, ...response.data)
		JtbhVisible.value=true				  
		}
	})
}
//获取员工信息
const GetYg = (event, inputName) => {
    if (event.target.value !== '') {
        getYg({ sczl_bh: event.target.value }).then(response => {
            if (response.code === 0) {
                // 设置值
                if (inputName >= 1 && inputName <= 9) {
                    detailData['jlname' + inputName] = response.data.ygxm;
                } else if (inputName >= 10 && inputName <= 18) {
                    detailData['zrname' + (inputName - 9)] = response.data.ygxm;
                }
            }
        });
    }
}
// ============== 表格控制部分结束 ===============

// 获取需要的字典 可能为空 按需保留
const setOptions = async() => {
}

// 获取需要的字典 可能为空 按需保留
setOptions()

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

// 删除行
const deleteRow = (row) => {
  ElMessageBox.confirm('确定要删除吗?', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(() => {
    deleteCompanyFunc(row)
  })
}

// 批量删除控制标记
const deleteVisible = ref(false)

// 多选删除
const onDelete = async() => {
  const ids = []
  if (multipleSelection.value.length === 0) {
    ElMessage({
      type: 'warning',
      message: '请选择要删除的数据'
    })
    return
  }
  multipleSelection.value &&
        multipleSelection.value.map(item => {
          ids.push(item.ID)
        })
  const res = await deleteCompanyByIds({ ids })
  if (res.code === 0) {
    ElMessage({
      type: 'success',
      message: '删除成功'
    })
    if (tableData.value.length === ids.length && page.value > 1) {
      page.value--
    }
    deleteVisible.value = false
    getTableData()
  }
}

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

// 删除行
const deleteCompanyFunc = async(row) => {
  const res = await deleteCompany({ ID: row.ID })
  if (res.code === 0) {
    ElMessage({
      type: 'success',
      message: '删除成功'
    })
    if (tableData.value.length === 1 && page.value > 1) {
      page.value--
    }
    getTableData()
  }
}

// 弹窗控制标记
const dialogFormVisible = ref(false)

// 查看详情控制标记
const detailShow = ref(false)

// 打开详情弹窗
const openDetailShow = () => {
  detailShow.value = true
}

// 打开详情
const getDetails = async(row) => {
  // 打开弹窗
  const res = await findCompany({ ID: row.ID })
  if (res.code === 0) {
    detailData.value = res.data.recompany
    openDetailShow()
  }
}

// 关闭详情弹窗
const closeDetailShow = () => {
  detailShow.value = false
  detailData.value = {
    address: '',
    image: '',
    name: '',
  }
}
//删除
function onDel() {
	Del()
}
// 删除
const Del = async() => {
	
    const res = await JunkDetailDel({ UniqId:lastCellValue})
    if (res.code === 0) {
    ElMessage({
      type: 'success',
      message: '成功'
    })
	getTableData()
    }else{
	ElMessage({
	  type: 'error',
	  message: '失败'
	})
	}
}
// 打开弹窗
const openDialog = () => {
  type.value = 'create'
  dialogFormVisible.value = true
}

// 关闭弹窗
const closeDialog = () => {
  dialogFormVisible.value = false
  detailData.value = {
    address: '',
    image: '',
    name: '',
  }
}
// 弹窗确定
const enterDialog = async() => {
	if (type.value === 'update') {
		  SubmitDailyProduction()
	} else if (type.value === 'create') {
		  add()   
	}
	// SubmitDailyProduction()
  // elFormRef.value?.validate(async(valid) => {
  //   if (!valid) return
  //   let res
  //   switch (type.value) {
  //     case 'create':
  //       res = await createCompany(detailData.value)
  //       break
  //     case 'update':
  //       res = await updateCompany(detailData.value)
  //       break
  //     default:
  //       res = await createCompany(detailData.value)
  //       break
  //   }
  //   if (res.code === 0) {
  //     ElMessage({
  //       type: 'success',
  //       message: '创建/更改成功'
  //     })
  //     closeDialog()
  //     getTableData()
  //   }
  // })
}
 //日报表上传
 const SubmitDailyProduction = async () => {
 
   
   const restoredData = {
	   
     sczl_gdbh:detailData.sczl_gdbh,
     sczl_yjno:detailData.sczl_yjno,
     sczl_gxh:detailData.sczl_gxh,
     sczl_gxmc: detailData.sczl_gxmc,
    sczl_numDesc: detailData.sczl_numDesc,
    sczl_bh1: detailData.sczl_bh1,
    sczl_bh2: detailData.sczl_bh2,
    sczl_bh3: detailData.sczl_bh3,
    sczl_bh4: detailData.sczl_bh4,
    sczl_bh5: detailData.sczl_bh5,
    sczl_bh6: detailData.sczl_bh6,
    sczl_bh7: detailData.sczl_bh7,
    sczl_bh8: detailData.sczl_bh8,
    sczl_bh9: detailData.sczl_bh9,
    sczl_bh10: '',
	
	sczl_je1: detailData.sczl_je1,
	sczl_je2: detailData.sczl_je2,
	sczl_je3: detailData.sczl_je3,
	sczl_je4: detailData.sczl_je4,
	sczl_je5: detailData.sczl_je5,
	sczl_je6: detailData.sczl_je6,
	sczl_je7: detailData.sczl_je7,
	sczl_je8: detailData.sczl_je8,
	sczl_je9: detailData.sczl_je9,
	sczl_je10: '',
	
	JL_bh1: detailData.JL_bh1,
	JL_bh2: detailData.JL_bh2,
	JL_bh3: detailData.JL_bh3,
	JL_bh4: detailData.JL_bh4,
	JL_bh5: detailData.JL_bh5,
	JL_bh6: detailData.JL_bh6,
	JL_bh7: detailData.JL_bh7,
	JL_bh8: detailData.JL_bh8,
	JL_bh9: detailData.JL_bh9,
	JL_bh10:'',
	
	JL_Je1: detailData.JL_Je1,
	JL_Je2: detailData.JL_Je2,
	JL_Je3: detailData.JL_Je3,
	JL_Je4: detailData.JL_Je4,
	JL_Je5: detailData.JL_Je5,
	JL_Je6: detailData.JL_Je6,
	JL_Je7: detailData.JL_Je7,
	JL_Je8: detailData.JL_Je8,
	JL_Je9: detailData.JL_Je9,
	JL_Je10: '',

    sczl_rq: detailData.sczl_rq,
	sczl_ls: detailData.sczl_ls,
	sczl_fplxA: detailData.sczl_fplxA,
	sczl_fplxB: '0',
	责任部门: detailData.责任部门,
	sczl_cl: detailData.sczl_cl,
	jl_jtbh: detailData.jl_jtbh,
	Jl_bzdh: detailData.Jl_bzdh,
	sczl_jtbh: detailData.sczl_jtbh,
	sczl_bzdh: detailData.sczl_bzdh,
	sys_id: sys_id,  
	UniqId:lastCellValue
   }
   console.log(restoredData)
   // console.log(formData3.value.formattedArray)
   const response = await JunkDetailEdit(restoredData);
   console.log(response)
   if (response.code === 0) {
 	  ElMessage({
 	    type: 'success',
 	    message: '成功'
 	  })
   }
   detailShow.value = false
   getTableData()
 }
 const add = async () => {
 	const restoredData = {
 		   
 	  sczl_gdbh:detailData.sczl_gdbh,
 	  sczl_yjno:detailData.sczl_yjno,
 	  sczl_gxh:detailData.sczl_gxh,
 	  sczl_gxmc: detailData.sczl_gxmc,
 	 sczl_numDesc: detailData.sczl_numDesc,
 	 sczl_bh1: detailData.sczl_bh1,
 	 sczl_bh2: detailData.sczl_bh2,
 	 sczl_bh3: detailData.sczl_bh3,
 	 sczl_bh4: detailData.sczl_bh4,
 	 sczl_bh5: detailData.sczl_bh5,
 	 sczl_bh6: detailData.sczl_bh6,
 	 sczl_bh7: detailData.sczl_bh7,
 	 sczl_bh8: detailData.sczl_bh8,
 	 sczl_bh9: detailData.sczl_bh9,
 	 sczl_bh10: '',
 		
 		sczl_je1: detailData.sczl_je1,
 		sczl_je2: detailData.sczl_je2,
 		sczl_je3: detailData.sczl_je3,
 		sczl_je4: detailData.sczl_je4,
 		sczl_je5: detailData.sczl_je5,
 		sczl_je6: detailData.sczl_je6,
 		sczl_je7: detailData.sczl_je7,
 		sczl_je8: detailData.sczl_je8,
 		sczl_je9: detailData.sczl_je9,
 		sczl_je10: '',
 		
 		JL_bh1: detailData.JL_bh1,
 		JL_bh2: detailData.JL_bh2,
 		JL_bh3: detailData.JL_bh3,
 		JL_bh4: detailData.JL_bh4,
 		JL_bh5: detailData.JL_bh5,
 		JL_bh6: detailData.JL_bh6,
 		JL_bh7: detailData.JL_bh7,
 		JL_bh8: detailData.JL_bh8,
 		JL_bh9: detailData.JL_bh9,
 		JL_bh10:'',
 		
 		JL_Je1: detailData.JL_Je1,
 		JL_Je2: detailData.JL_Je2,
 		JL_Je3: detailData.JL_Je3,
 		JL_Je4: detailData.JL_Je4,
 		JL_Je5: detailData.JL_Je5,
 		JL_Je6: detailData.JL_Je6,
 		JL_Je7: detailData.JL_Je7,
 		JL_Je8: detailData.JL_Je8,
 		JL_Je9: detailData.JL_Je9,
 		JL_Je10: '',
 	
 	 sczl_rq: detailData.sczl_rq,
 		sczl_ls: detailData.sczl_ls,
 		sczl_fplxA: detailData.sczl_fplxA,
 		sczl_fplxB: '0',
 		责任部门: detailData.责任部门,
 		sczl_cl: detailData.sczl_cl,
 		jl_jtbh: detailData.jl_jtbh,
 		Jl_bzdh: detailData.Jl_bzdh,
 		sczl_jtbh: detailData.sczl_jtbh,
 		sczl_bzdh: detailData.sczl_bzdh,
 		sys_id: sys_id,  
 	}
 	console.log(restoredData)
 	// console.log(formData3.value.formattedArray)
 	const response = await JunkDetailAdd(restoredData);
 	console.log(response)
 	if (response.code === 0) {
 	 	  ElMessage({
 	 	    type: 'success',
 	 	    message: '成功'
 	 	  })
 	}
 	detailShow.value = false
 	getTableData()
 }
//键盘 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()
    }
  }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 ent1 = (event) => {
  const inputs = document.getElementsByTagName('input');
  const currentIndex = Array.from(inputs).indexOf(event.target);
  
  if (event.keyCode === 13 || event.keyCode === 40) { // Enter 或向下箭头
    for (let i = currentIndex + 1; i < inputs.length; i++) {
      if (!inputs[i].readOnly) {
        nextTick(()=>{
          inputs[i].focus();
          inputs[i].select();
        })
        break;
      }
    }
  } else if (event.keyCode === 38) { // 向上箭头
    for (let i = currentIndex - 1; i >= 0; i--) {
      if (!inputs[i].readOnly) {
        nextTick(()=>{
          inputs[i].focus();
          inputs[i].select();
        })
        break;
      }
    }
  } else if (event.keyCode === 8) { // 删除箭头
    if (event.target.selectionStart === 0) {
      for (let i = currentIndex - 1; i >= 0; i--) {
        if (!inputs[i].readOnly) {
          nextTick(()=>{
            inputs[i].focus();
            inputs[i].setSelectionRange(0, 0);
            inputs[i].select(); // 全选输入框内容
          })
          break;
        }
      }
    }
  } else if (event.keyCode === 37) { // 向左箭头
    if (event.target.selectionStart === 0) {
      for (let i = currentIndex - 1; i >= 0; i--) {
        if (!inputs[i].readOnly) {
          nextTick(()=>{
            inputs[i].focus();
            inputs[i].select();
          })
          break;
        }
      }
    }
  } else if (event.keyCode === 39) { // 向右箭头
    if (event.target.selectionStart === event.target.value.length) {
      for (let i = currentIndex + 1; i < inputs.length; i++) {
        if (!inputs[i].readOnly) {
          nextTick(()=>{
            inputs[i].focus();
            inputs[i].select();
          })
          break;
        }
      }
    }
  }
}
</script>

<style scoped>

:deep(.el-table td .cell) {
  line-height: 30px !important;
}

.JKWTree-container {
  display: flex;
}

/* 选中某行时的背景色 */
:deep(.el-table__body tr.current-row) > td {
  background: #ff80ff !important;
}

.JKWTree-tree {
  width: 300px;
  background-color: #fff;
  padding: 10px;
  margin-right: 20px;
}

.JKWTree-tree h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 10px 0;
}

.JKWTree-content {
  flex: 1;
}

</style>
