永康嘉持电器有限公司前端
小小儁爺
2025-03-13 2146654ce466348808bd11218d5a71756d03abc4
src/views/workOrder/workOrderList.vue
@@ -1,4038 +1,4731 @@
<template>
  <div>
    <div class="body" :style="{height:mainHeight+'px'}">
      <div class="bodyTopButtonGroup" style="justify-content: space-between">
        <div style="display: flex">
          <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button>
          <el-button v-waves type="success" icon="el-icon-connection" @click="send">派发</el-button>
        </div>
        <!--        <el-button v-waves icon="el-icon-switch-button" @click="orderClose">关闭工单</el-button>-->
      </div>
      <div class="bodyTopFormGroup">
        <el-form
          ref="form"
          :model="form"
          label-width="100px"
          inline
          style="display: flex;"
        >
          <div class="elForm">
            <el-form-item label="车间名称" style=" display: flex;">
              <el-select
                v-model="form.wkshopcode"
                filterable
                :popper-append-to-body="false"
                style="width: 200px"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in wkshopcodeArr"
                  :key="item.torg_code"
                  :label="item.torg_name"
                  :value="item.torg_code"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="工单状态" style=" display: flex;">
              <el-select
                v-model="form.mesorderstus"
                :popper-append-to-body="false"
                style="width: 200px"
                placeholder="请选择"
                filterable
                @change="erporderstusChange"
              >
                <el-option
                  v-for="item in erporderstusArr"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="工单编号" style=" display: flex;">
              <el-input v-model="form.mesordercode" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="源单单号" style="display: flex;">
              <el-input v-model="form.sourceorder" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <el-form-item v-show="isExpandForm" label="销售订单" style="display: flex;">
              <el-input v-model="form.saleordercode" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <el-form-item v-show="isExpandForm" label="单据类型" style=" display: flex;">
              <el-select
                v-model="form.ordertype"
                :popper-append-to-body="false"
                style="width: 200px"
                placeholder="请选择"
              >
                <!--            @change="mesordertypeChange"-->
                <el-option
                  v-for="item in ordertypeArr"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
            <el-form-item v-show="isExpandForm" label="产品编码" style=" display: flex;">
              <el-input v-model="form.partcode" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <el-form-item v-show="isExpandForm" label="产品名称" style=" display: flex;">
              <el-input v-model="form.partname" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <el-form-item v-show="isExpandForm" label="产品规格" style=" display: flex;">
              <el-input v-model="form.partspec" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <el-form-item v-show="isExpandForm" label="创建人员" style=" display: flex;">
              <el-input v-model="form.creatuser" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <DateType
              ref="DateTypeRef"
              :is-expand-form="isExpandForm"
              style="display:flex;justify-content: center;align-items: center;position: relative"
              :datatype-list="datatypeList"
              @DateTypeChange="DateTypeChange"
              @cycleTimeChange="cycleTimeChange"
            />
          </div>
          <div
            class="bodySearchReset"
            :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}"
          >
            <el-button v-waves type="primary" icon="el-icon-search" @click="search">查询</el-button>
            <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">重置</el-button>
          </div>
        </el-form>
        <div
          class="bodyTopFormExpand"
        >
          <svg-icon
            v-show="mouseHoverType==='mouseout'"
            style="cursor: pointer"
            :icon-class="!isExpandForm?'doubleDown3':'doubleUp3'"
            @mouseenter="mouseHoverType=$event.type"
          />
          <svg-icon
            v-show="mouseHoverType==='mouseenter'"
            style="cursor: pointer"
            :icon-class="!isExpandForm?'doubleDown':'doubleUp'"
            @click="isExpandForm=!isExpandForm"
            @mouseout="mouseHoverType=$event.type"
          />
        </div>
      </div>
      <div class="elTableDiv">
        <el-table
          ref="tableDataRef"
          class="tableFixed"
          :data="tableData"
          :height="isExpandForm?tableHeight:(tableHeight+80)+'px'"
          border
          :summary-method="getSummaries"
          show-summary
          :row-class-name="tableRowClassName"
          :style="{width: 100+'%',height:isExpandForm?tableHeight:(tableHeight+80)+'px'}"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
          @sort-change="sortChange"
          @row-click="rowClick"
          @selection-change="handleSelectionChange"
        >
          <el-table-column
            type="selection"
            width="50"
            :selectable="selected"
          />
          <el-table-column
            prop="rowNum"
            width="50"
            label="序号"
            fixed
          />
          <el-table-column
            prop="status"
            label="工单状态"
            sortable="custom"
            width="110"
            show-tooltip-when-overflow
          >
            <template slot-scope="{row}">
              <div v-if="row.status==='NEW'">新工单</div>
              <!--              <div v-if="row.status==='CREATING'">执行中</div>-->
              <!--              <div v-if="row.status==='CREATED'">已关闭</div>-->
              <div v-if="row.status==='ALLO'">已派发</div>
              <div v-if="row.status==='START'">开工</div>
              <div v-if="row.status==='CLOSED'">完工</div>
              <div v-if="row.status==='NOSCHED'">待排程</div>
              <div v-if="row.status==='SCHED'">已排程</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="wo_code"
            label="工单编号"
            show-tooltip-when-overflow
            sortable="custom"
            min-width="160"
          />
          <el-table-column
            prop="m_po"
            label="源单单号"
            sortable="custom"
            show-tooltip-when-overflow
            min-width="160"
          >
            <template slot-scope="{row}">
              <div v-if="row.m_po">{{ row.m_po }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="saleOrderCode"
            label="销售订单"
            sortable="custom"
            show-tooltip-when-overflow
            min-width="160"
          >
            <template slot-scope="{row}">
              <div v-if="row.saleOrderCode">{{ row.saleOrderCode }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="wotype"
            label="单据类型"
            sortable="custom"
            show-tooltip-when-overflow
            min-width="120"
          >
            <template slot-scope="{row}">
              <div v-if="row.wotype==='PO'">标准工单</div>
              <div v-else-if="row.wotype==='FO'">报废补单</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="partcode"
            label="产品编码"
            show-tooltip-when-overflow
            sortable="custom"
            min-width="120"
          />
          <el-table-column
            prop="partname"
            min-width="150"
            label="产品名称"
            show-tooltip-when-overflow
            sortable="custom"
          />
          <el-table-column
            prop="partspec"
            label="产品规格"
            sortable="custom"
            width="110"
            show-tooltip-when-overflow
          >
            <template slot-scope="{row}">
              <div v-if="row.partspec">{{ row.partspec }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            v-if="mesSetting.route"
            prop="route_name"
            label="工艺路线"
            sortable="custom"
            show-tooltip-when-overflow
            width="120"
          >
            <template slot-scope="{row}">
              <div v-if="row.route_name">{{ row.route_name }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="plan_qty"
            label="工单数"
            sortable="custom"
            show-tooltip-when-overflow
            width="100"
          />
          <el-table-column
            prop="clerkuser"
            label="销售业务员"
            sortable="custom"
            show-tooltip-when-overflow
            width="150"
          >
            <template slot-scope="{row}">
              <div v-if="row.clerkuser">{{ row.clerkuser }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="wkshp_name"
            label="生产车间"
            show-tooltip-when-overflow
            sortable="custom"
            width="120"
          >
            <template slot-scope="{row}">
              <div v-if="row.wkshp_name">{{ row.wkshp_name }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="plan_startdate"
            label="预计开工日期"
            sortable="custom"
            width="130"
          >
            <template slot-scope="{row}">
              <div v-if="row.plan_startdate">{{ row.plan_startdate.substring(0, 11) }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="plan_enddate"
            label="预计完工日期"
            sortable="custom"
            width="130"
          >
            <template slot-scope="{row}">
              <div v-if="row.plan_enddate">{{ row.plan_enddate.substring(0, 11) }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="saleOrderDeliveryDate"
            label="预计交付日期"
            sortable="custom"
            width="130"
          >
            <template slot-scope="{row}">
              <div v-if="row.saleOrderDeliveryDate">{{ row.saleOrderDeliveryDate.substring(0, 11) }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <!--          <el-table-column-->
          <!--            prop="data_sources"-->
          <!--            show-tooltip-when-overflow-->
          <!--            label="数据来源"-->
          <!--            sortable="custom"-->
          <!--            width="120"-->
          <!--          />-->
          <el-table-column
            prop="lm_user"
            show-tooltip-when-overflow
            label="创建人员"
            sortable="custom"
            width="120"
          />
          <el-table-column
            prop="lm_date"
            label="创建时间"
            show-tooltip-when-overflow
            width="160"
            sortable="custom"
          />
          <el-table-column
            label="操作"
            width="160"
            fixed="right"
          >
            <template slot-scope="{row}">
              <div class="operationClass">
                <el-tooltip v-del-tab-index class="item" effect="dark" content="SOP预览" placement="top">
                  <i
                    v-if="mesSetting.workOrder"
                    class="el-icon-files"
                    style="cursor: pointer;color:#42b983;margin-right: 15px"
                    @click="pre(row,1)"
                  />
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="修改" placement="top">
                  <i
                    class="el-icon-edit-outline"
                    :style="{color:$store.state.settings.theme}"
                    @click="edit('edit',row)"
                  />
                </el-tooltip>
                <el-tooltip v-del-tab-index class="item" effect="dark" content="删除" placement="top">
                  <i class="el-icon-delete" :style="{color:$store.state.settings.theme}" @click="del(row)" />
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="打印工单" placement="top">
                  <!--                  <i-->
                  <!--                    class="el-icon-tickets"-->
                  <!--                    style="cursor: pointer;color: #42b983;margin-right: 15px"-->
                  <!--                    @click="check(row)"-->
                  <!--                  />-->
                  <i
                    :style="{color:$store.state.settings.theme}"
                    class="el-icon-printer"
                    style="cursor: pointer;margin-right: 15px"
                    @click="handlePrint(row.wo_code,row.saleOrderCod)"
                  />
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="详情" placement="top">
                  <i
                    class="el-icon-view"
                    style="cursor: pointer;"
                    :style="{color:$store.state.settings.theme}"
                    @click="edit('view',row)"
                  />
                </el-tooltip>
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <!--分页-->
      <pagination
        :total="total"
        :page.sync="form.page"
        :limit.sync="form.rows"
        align="right"
        layout="total,prev, pager, next,sizes,jumper"
        popper-class="select_bottom"
        @pagination="getMesOrderSearch"
      />
      <div class="elTableDiv">
        <el-table
          :data="tableDataDetail"
          border
          height="210px"
          :row-class-name="tableRowClassName"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
        >
          <!--          <el-table-column-->
          <!--            width="50"-->
          <!--            type="index"-->
          <!--            prop="序号"-->
          <!--            fixed-->
          <!--          />   -->
          <el-table-column
            width="50"
            prop="seq"
            label="序号"
            fixed
          />
          <el-table-column
            prop="wo_code"
            show-tooltip-when-overflow
            label="工单编号"
            width="160"
          />
          <!--          <el-table-column-->
          <!--            prop="partcode"-->
          <!--            label="产品编码"-->
          <!--            width="150"-->
          <!--            show-tooltip-when-overflow-->
          <!--          />-->
          <!--          <el-table-column-->
          <!--            prop="partname"-->
          <!--            label="产品名称"-->
          <!--            width="200"-->
          <!--            show-tooltip-when-overflow-->
          <!--          />-->
          <el-table-column
            label="工序编码"
            prop="step_code"
            show-tooltip-when-overflow
            width="150"
          />
          <el-table-column
            label="工序名称"
            show-tooltip-when-overflow
            prop="stepname"
            width="150"
          />
          <el-table-column
            label="工序单价"
            show-tooltip-when-overflow
            prop="stepprice"
          />
          <el-table-column
            label="已生产数量"
            show-tooltip-when-overflow
            prop="produceq_qty"
          />
          <el-table-column
            label="合格数量"
            show-tooltip-when-overflow
            prop="good_qty"
          />
          <el-table-column
            label="不良数量"
            show-tooltip-when-overflow
            prop="ng_qty"
          />
          <el-table-column
            label="工废数量"
            show-tooltip-when-overflow
            prop="laborbad_qty"
          />
          <el-table-column
            label="料废数量"
            show-tooltip-when-overflow
            prop="materielbad_qty"
          />
          <el-table-column
            label="待产数量"
            show-tooltip-when-overflow
            prop="delive_qty"
          />
          <el-table-column
            label="操作"
            width="120"
            fixed="right"
          >
            <template slot-scope="{row}">
              <div class="operationClass">
                <el-tooltip v-del-tab-index class="item" effect="dark" content="SOP预览" placement="top">
                  <i
                    v-if="mesSetting.tech"
                    class="el-icon-files"
                    style="cursor: pointer;color:#42b983;margin-right: 15px"
                    @click="pre(row,2)"
                  />
                </el-tooltip>
                <!--                          <el-tooltip class="item" effect="dark" content="打印工序" placement="top">-->
                <!--                            <i-->
                <!--                              v-if="tableDataDetail.length!==row.seq"-->
                <!--                              class="el-icon-printer"-->
                <!--                              :style="{color:$store.state.settings.theme}"-->
                <!--                              style="cursor: pointer;margin-right: 15px"-->
                <!--                              @click="supplementSmallClick(row)"-->
                <!--                            />-->
                <!--                          </el-tooltip>-->
                <!--                          <el-tooltip class="item" effect="dark" content="补打生产入库条码" placement="top">-->
                <!--                            <i-->
                <!--                              v-if="tableDataDetail.length===row.seq"-->
                <!--                              class="  el-icon-camera"-->
                <!--                              :style="{color:$store.state.settings.theme}"-->
                <!--                              style="cursor: pointer;margin-right: 15px"-->
                <!--                              @click="getProductInHouseLabCode(row.wo_code)"-->
                <!--                            />-->
                <!--                          </el-tooltip>-->
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <!--新增派发对话框-->
    <el-dialog
      v-el-drag-dialog
      :title="operation==='add'?'新增':(operation==='edit'?'修改':'详情')"
      :visible.sync="dialogVisible"
      width="1200px"
      top="8vh"
      :close-on-click-modal="false"
      @closed="handleClose"
      @close="handleClose"
    >
      <el-form
        ref="dialogForm"
        inline
        :rules="dialogFormRules"
        :model="dialogForm"
        label-width="110px"
      >
        <el-divider content-position="left">基本信息</el-divider>
        <el-form-item
          label="工单状态"
          prop="mesorderstus"
        >
          <el-select
            v-model="dialogForm.mesorderstus"
            disabled
            filterable
            :popper-append-to-body="false"
            style="width: 200px"
            placeholder="请选择"
          >
            <el-option
              v-for="item in erporderstusArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="工单编号" prop="mesordercode">
          <!--          <el-input v-model="dialogForm.mesordercode" :disabled="operation!=='add'" style="width: 200px" />-->
          <el-input v-model="dialogForm.mesordercode" disabled style="width: 200px" />
        </el-form-item>
        <!--        <div style="display: flex">-->
        <el-form-item label="工单类型" prop="mesorderstus">
          <el-select
            v-model="dialogForm.ordertype"
            :popper-append-to-body="false"
            style="width: 200px"
            :disabled="operation!=='add'"
            placeholder="请选择"
            @change="mesordertypeChange"
          >
            <el-option
              v-for="item in ordertypeArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
        <!--          <div style="display: flex;flex-wrap: nowrap">-->
        <el-form-item label="源单单号">
          <el-input
            v-model="dialogForm.sourceorder"
            :disabled="dialogForm.ordertype==='PO'"
            style="width: 200px"
          >
            <el-button
              slot="append"
              icon="el-icon-search"
              :disabled="operation!=='add'||dialogForm.ordertype==='PO'"
              @click="mesordertsourcesearchclick"
            />
          </el-input>
        </el-form-item>
        <!--            <el-button-->
        <!--              v-waves-->
        <!--              type="primary"-->
        <!--              style="padding: 0 10px;margin-left: -8px;margin-top: 3px"-->
        <!--              class="el-icon-search"-->
        <!--              :disabled="operation!=='add'||dialogForm.ordertype==='PO'"-->
        <!--              @click="mesordertsourcesearchclick"-->
        <!--            />-->
        <!--          </div>-->
        <!--        </div>-->
        <el-form-item label="工单数量" prop="mesqty">
          <el-input
            v-model="dialogForm.mesqty"
            oninput="value=value.replace(/[^\d]/g,'')"
            style="width: 200px"
          />
          <!--          oninput="value=value.replace(/[^0-9*.{1}0-9*]/g,'')"-->
        </el-form-item>
        <el-form-item label="所属车间" prop="wkshopcode">
          <el-select
            v-model="dialogForm.wkshopcode"
            filterable
            :popper-append-to-body="false"
            style="width: 200px;"
            placeholder="请选择车间"
            @change="getMesOrderNewStepContent"
          >
            <!--            @change="sourceType? getMesOrderNewStepContent():routecodeChange()"-->
            <el-option
              v-for="item in wkshopArr"
              :key="item.torg_code"
              :label="item.torg_name"
              :value="item.torg_code"
            />
          </el-select>
        </el-form-item>
        <el-form-item
          label="产品名称/编码"
          prop="partcode"
        >
          <el-select
            v-model="dialogForm.partcode"
            filterable
            :disabled="operation!=='add'"
            :popper-append-to-body="false"
            style="width: 200px"
            placeholder="请选择"
            @change="partcodeChangeDialog"
          >
            <el-option
              v-for="item in partArr"
              :key="item.partcode"
              :label="item.partname+'/'+item.partcode"
              :value="item.partcode"
            />
          </el-select>
        </el-form-item>
        <!--        <el-form-item v-if="operation!=='add'" label="产品名称" prop="partname">-->
        <!--          <el-input v-model="dialogForm.partname" disabled style="width: 200px" />-->
        <!--        </el-form-item>-->
        <!--        <el-form-item v-if="operation!=='add'" label="产品编码">-->
        <!--          <el-input v-model="dialogForm.partcode" disabled style="width: 200px" />-->
        <!--        </el-form-item>-->
        <el-form-item label="产品规格" prop="partspec">
          <el-input v-model="dialogForm.partspec" disabled style="width: 200px" />
        </el-form-item>
        <!--        :disabled="dialogForm.partcode===''"-->
        <el-form-item v-if="mesSetting.route" label="工艺路线" prop="wkshopcode">
          <el-select
            v-model="dialogForm.routecode"
            filterable
            :popper-append-to-body="false"
            style="width: 200px;"
            placeholder="请选择工艺路线"
            @change="sourceType? getMesOrderNewStepContent():routecodeChange()"
          >
            <el-option
              v-for="item in routecodeArr"
              :key="item.route_code"
              :label="item.route_name"
              :value="item.route_code"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="预计交付日期" prop="deliverydate">
          <el-date-picker
            v-model="dialogForm.deliverydate"
            type="date"
            size="mini"
            :clearable="false"
            class="dateMini"
            :picker-options="pickerOptions"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            placeholder="选择日期"
          />
          <!--          :disabled="dialogForm.deliverydate"-->
        </el-form-item>
        <el-form-item label="工序来源" required>
          <el-switch
            v-model="sourceType"
            style="width: 200px;"
            inactive-text="基础设置"
            active-text="历史最新"
            :disabled="!dialogForm.wkshopcode"
            @change="sourceTypeChange"
          />
        </el-form-item>
        <el-divider content-position="left">工序信息</el-divider>
        <div style="display: flex;align-items: center">
          <div style="font-weight: bolder">工序选择:</div>
          <el-select
            v-model="stepSelectedValue"
            class="stepSelectedValueClass"
            style="width: 930px;"
            multiple
            placeholder="请选择相对应工序"
            @change="stepSelectedValueChange"
          >
            <el-option
              v-for="item in stepSelectArr"
              :key="item.stepcode"
              :label="item.stepname"
              :value="item.stepcode"
            />
          </el-select>
          <!--          <el-drag-select-->
          <!--            v-model="stepSelectedValue"-->
          <!--            style="width:930px;"-->
          <!--            multiple-->
          <!--            placeholder="请选择相对应工序"-->
          <!--            @change="stepSelectedValueChange"-->
          <!--          >-->
          <!--            <el-option-->
          <!--              v-for="item in stepSelectArr"-->
          <!--              :key="item.stepcode"-->
          <!--              :label="item.stepname"-->
          <!--              :value="item.stepcode"-->
          <!--            />-->
          <!--          </el-drag-select>-->
        </div>
        <el-table
          ref="stepTableDataRef"
          :data="stepTableData"
          border
          :row-class-name="tableRowClassName"
          height="300"
          style="width: 100%;margin-top: 15px;"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
          row-key="stepcode"
        >
          <el-table-column
            type="index"
            label="序号"
            width="50"
          />
          <el-table-column
            prop="stepcode"
            show-tooltip-when-overflow
            label="工序编码"
          />
          <el-table-column
            prop="stepname"
            label="工序名称"
            show-tooltip-when-overflow
          />
          <el-table-column
            prop="stepprice"
            label="生产单价"
            show-tooltip-when-overflow
          >
            <template slot-scope="{row}">
              <el-input
                v-model="row.stepprice"
                placeholder="请输入工序单价"
                oninput="value=value.replace(/[^0-9.]/g,'')"
                style="width: 100%"
                @click=""
              />
            </template>
          </el-table-column>
          <el-table-column
            label="操作"
            width="120"
          >
            <template slot-scope="{row}">
              <div class="operationClass">
                <!--                <el-tooltip class="item" effect="dark" content="移动" placement="top">-->
                <i
                  class="el-icon-rank"
                  :style="{color:$store.state.settings.theme}"
                  style="cursor: move"
                />
                <!--                </el-tooltip>-->
                <!--                @click="edit('edit',row)"-->
                <el-tooltip v-del-tab-index class="item" effect="dark" content="删除" placement="top">
                  <i
                    class="el-icon-delete"
                    :style="{color:$store.state.settings.theme}"
                    style="margin-left: 15px;"
                    @click="stepDel(row)"
                  />
                </el-tooltip>
              </div>
            </template>
          </el-table-column>
        </el-table>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="dialogVisibleCancel">取 消</el-button>
          <!--          <el-button v-waves v-if="operation==='add'" type="primary" @click="dialogVisibleConfirmPreview('add')">预览</el-button>-->
          <el-button
            v-if="operation!=='view'&&(dialogForm.mesorderstus==='NEW'||dialogForm.mesorderstus==='ALLO')"
            v-waves
            type="primary"
            :loading="$store.state.app.buttonIsDisabled"
            :disabled="$store.state.app.buttonIsDisabled"
            @click="dialogVisibleConfirm"
          >确 定</el-button>
        </div>
      </span>
    </el-dialog>
    <!-- 工序任务对话框-->
    <el-dialog
      v-el-drag-dialog
      title="工序任务"
      :visible.sync="dialogVisibleTask"
      width="840px"
      top="15vh"
      class="dialogVisibleSearch"
      :close-on-click-modal="false"
      @close="dialogVisibleTaskClose"
    >
      <el-button
        v-waves
        style="margin-bottom: 15px"
        type="primary"
        @click="supplementClick"
      >补打
      </el-button>
      <el-table
        :data="taskTableData"
        border
        :row-class-name="tableRowClassName"
        height="300"
        style="width: 100%;"
        highlight-current-row
        :header-cell-style="this.$headerCellStyle"
        :cell-style="this.$cellStyle"
      >
        <el-table-column
          prop="seq"
          width="50"
          label="序号"
          fixed
        />
        <el-table-column
          prop="wo_code"
          show-tooltip-when-overflow
          label="工单编号"
          width="200"
        />
        <el-table-column
          prop="stepcode"
          label="工序编码"
          show-tooltip-when-overflow
        />
        <el-table-column
          prop="stepname"
          show-tooltip-when-overflow
          label="工序名称"
        />
        <!--        <el-table-column-->
        <!--          prop="flwtype"-->
        <!--          label="工序类型"-->
        <!--        >-->
        <!--          <template slot-scope="{row}">-->
        <!--            <div v-if="row.flwtype==='W'">外协</div>-->
        <!--            <div v-if="row.flwtype==='Z'">自制</div>-->
        <!--          </template>-->
        <!--        </el-table-column>-->
        <!--        <el-table-column-->
        <!--          prop="descr"-->
        <!--          label="工序描述"-->
        <!--        />-->
        <el-table-column
          prop="plan_qty"
          show-tooltip-when-overflow
          label="任务数量"
        />
        <el-table-column
          prop="good_qty"
          show-tooltip-when-overflow
          label="合格数量"
        />
        <el-table-column
          prop="ng_qty"
          show-tooltip-when-overflow
          label="不良数量"
        />
        <el-table-column
          label="操作"
          fixed="right"
        >
          <template slot-scope="{row}">
            <el-button v-waves type="text" style="padding: 0;" @click="supplementSmallClick(row)">补打</el-button>
          </template>
        </el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="dialogVisibleBack">返 回</el-button>
          <!--          <el-button v-waves type="primary" @click="dialogVisibleConfirm">确 定</el-button>-->
        </div>
      </span>
    </el-dialog>
    <!-- 源单单号对话框-->
    <el-dialog
      v-el-drag-dialog
      title="源单单号"
      :visible.sync="dialogVisibleSource"
      width="1200px"
      top="10vh"
      class="dialogVisibleSearch"
      :close-on-click-modal="false"
      @close="dialogVisibleSourceClose"
    >
      <div class="bodyTopFormGroup">
        <el-form
          ref="sourceForm"
          :model="sourceForm"
          label-width="100px"
          inline
          style="display: flex;justify-content: space-between"
        >
          <div class="elForm" style="justify-content: flex-start">
            <!--            <el-form-item-->
            <!--              label="预计开工时间"-->
            <!--              label-width="100px"-->
            <!--              style=" display: flex;font-size: 14px;margin-top: 3px"-->
            <!--            >-->
            <!--              <el-date-picker-->
            <!--                v-model="sourceForm.paystartdate"-->
            <!--                type="daterange"-->
            <!--                range-separator="~"-->
            <!--                class="timeMini"-->
            <!--                size="mini"-->
            <!--                style="width: 200px;display: flex;line-height: 34px;height: 34px;font-size: 14px!important;"-->
            <!--                :clearable="false"-->
            <!--                start-placeholder="开始日期"-->
            <!--                end-placeholder="结束日期"-->
            <!--              />-->
            <!--              &lt;!&ndash;              :picker-options="expireTimeOption"&ndash;&gt;-->
            <!--            </el-form-item>-->
            <!--            <el-form-item-->
            <!--              label="预计完工时间"-->
            <!--              label-width="100px"-->
            <!--              style=" display: flex;font-size: 14px;margin-top: 3px"-->
            <!--            >-->
            <!--              <el-date-picker-->
            <!--                v-model="sourceForm.payenddate"-->
            <!--                type="daterange"-->
            <!--                :clearable="false"-->
            <!--                class="timeMini"-->
            <!--                range-separator="~"-->
            <!--                start-placeholder="开始日期"-->
            <!--                style="width: 200px;display: flex;line-height: 34px ;height: 34px ;font-size: 14px !important;"-->
            <!--                end-placeholder="结束日期"-->
            <!--                size="mini"-->
            <!--              />-->
            <!--            </el-form-item>-->
            <!--            <el-form-item label="工单状态" style=" display: flex;">-->
            <!--              <el-select-->
            <!--                v-model="sourceForm.mesordercode"-->
            <!--                filterable-->
            <!--                :popper-append-to-body="false"-->
            <!--                style="width: 200px"-->
            <!--                placeholder="请选择"-->
            <!--              >-->
            <!--                <el-option-->
            <!--                  v-for="item in erporderstusArr"-->
            <!--                  :key="item.code"-->
            <!--                  :label="item.name"-->
            <!--                  :value="item.code"-->
            <!--                />-->
            <!--              </el-select>-->
            <!--            </el-form-item>-->
            <el-form-item label="车间名称" style=" display: flex;">
              <el-select
                v-model="sourceForm.wkshopcode"
                filterable
                :popper-append-to-body="false"
                style="width: 200px"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in wkshopcodeArr"
                  :key="item.torg_code"
                  :label="item.torg_name"
                  :value="item.torg_code"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="工单编号" style=" display: flex;">
              <el-input v-model="sourceForm.mesordercode" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="产品编码" style=" display: flex;">
              <el-input v-model="sourceForm.partcode" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <el-form-item v-show="isExpandDialog" label="产品名称" style=" display: flex;">
              <el-input v-model="sourceForm.partname" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <!--            <el-form-item v-show="isExpandDialog" label="产品规格" style=" display: flex;">-->
            <!--              <el-input v-model="sourceForm.partspec" style="width: 200px" placeholder="请输入" />-->
            <!--            </el-form-item>-->
            <el-form-item v-show="isExpandDialog" label="创建人员" style=" display: flex;">
              <el-input v-model="sourceForm.creatuser" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <el-form-item
              v-show="isExpandDialog"
              label="创建时间"
              label-width="100px"
              style=" display: flex;font-size: 14px;margin-top: 3px"
            >
              <el-date-picker
                v-model="sourceForm.createdate"
                type="daterange"
                range-separator="~"
                class="timeMini"
                size="mini"
                style="width: 200px;display: flex;line-height: 34px;height: 34px;font-size: 14px!important;"
                :clearable="false"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              />
              <!--              :picker-options="expireTimeOption"-->
            </el-form-item>
          </div>
          <div style="display: flex;align-items: start;margin-top: 3px;z-index: 2;justify-content: end">
            <el-button v-waves type="primary" icon="el-icon-search" @click="sourceSearch">查询</el-button>
            <el-button v-waves type="info" icon="el-icon-refresh" @click="sourceReset">重置</el-button>
          </div>
        </el-form>
        <div
          class="bodyTopFormExpand"
        >
          <svg-icon
            v-show="mouseHoverTypeDialog==='mouseout'"
            style="cursor: pointer"
            :icon-class="!isExpandDialog?'doubleDown3':'doubleUp3'"
            @mouseenter="mouseHoverTypeDialog=$event.type"
          />
          <svg-icon
            v-show="mouseHoverTypeDialog==='mouseenter'"
            style="cursor: pointer"
            :icon-class="!isExpandDialog?'doubleDown':'doubleUp'"
            @click="isExpandDialog=!isExpandDialog"
            @mouseout="mouseHoverTypeDialog=$event.type"
          />
        </div>
      </div>
      <div class="elTableDiv">
        <el-table
          :data="sourceTableData"
          :height="isExpandDialog?(tableHeight+100)+'px':(tableHeight+140)+'px'"
          border
          :row-class-name="tableRowClassName"
          :style="{width: 100+'%',height:isExpandDialog?(tableHeight+100)+'px':(tableHeight+140)+'px',}"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
          @sort-change="sourceSortChange"
          @row-click="getCurrentRowSource"
        >
          <!--          <el-table-column-->
          <!--            type="selection"-->
          <!--            width="50"-->
          <!--          />-->
          <el-table-column
            width="50"
            fixed
          >
            <template slot-scope="{row}">
              <el-radio
                v-model="radioSelectedId"
                :label="row.id"
                style="color: transparent;padding-left: 10px;"
              />
              <!--              @change.native="getCurrentRowSource(row.id)"-->
            </template>
          </el-table-column>
          <el-table-column
            prop="rowNum"
            width="50"
            fixed
            label="序号"
          />
          <!--          <el-table-column-->
          <!--            prop="status"-->
          <!--            label="工单状态"-->
          <!--            show-tooltip-when-overflow-->
          <!--            sortable="custom"-->
          <!--            width="110"-->
          <!--          >-->
          <!--            <template slot-scope="{row}">-->
          <!--              <div v-if="row.status==='NEW'">新订单</div>-->
          <!--              <div v-if="row.status==='CREATING'">部分下达</div>-->
          <!--              <div v-if="row.status==='CREATED'">全部下达</div>-->
          <!--              <div v-if="row.status==='CLOSED'">已关闭</div>-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <el-table-column
            label="工单编号"
            prop="wo_code"
            show-tooltip-when-overflow
            min-width="150"
            sortable="custom"
          >
            <!--            <template slot-scope="{row}">-->
            <!--              <div v-if="row.m_po">{{ row.m_po }}</div>-->
            <!--              <div v-else>{{ row.wo_code }}</div>-->
            <!--            </template>-->
          </el-table-column>
          <el-table-column
            prop="partcode"
            label="产品编码"
            sortable="custom"
            show-tooltip-when-overflow
            min-width="150"
          />
          <el-table-column
            prop="partname"
            label="产品名称"
            sortable="custom"
            show-tooltip-when-overflow
            min-width="150"
          />
          <el-table-column
            prop="partspec"
            label="产品规格"
            show-tooltip-when-overflow
            sortable="custom"
            min-width="110"
          >
            <template slot-scope="{row}">
              <div v-if="row.partspec">{{ row.partspec }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="plan_qty"
            label="任务数量"
            width="150"
            show-tooltip-when-overflow
            sortable="custom"
          />
          <el-table-column
            prop="laborbad_qty"
            label="工废数量"
            width="150"
            show-tooltip-when-overflow
            sortable="custom"
          />
          <el-table-column
            prop="materielbad_qty"
            label="料废数量"
            width="150"
            show-tooltip-when-overflow
            sortable="custom"
          />
          <!--          <el-table-column-->
          <!--            prop="relse_qty"-->
          <!--            show-tooltip-when-overflow-->
          <!--            label="已下单数量"-->
          <!--            width="150"-->
          <!--            sortable="custom"-->
          <!--          />-->
          <el-table-column
            prop="wkshp_name"
            label="生产车间"
            show-tooltip-when-overflow
            sortable="custom"
            width="150"
          >
            <template slot-scope="{row}">
              <div v-if="row.wkshp_name">{{ row.wkshp_name }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <!--          <el-table-column-->
          <!--            prop="plan_startdate"-->
          <!--            label="预计开工时间"-->
          <!--            show-tooltip-when-overflow-->
          <!--            sortable="custom"-->
          <!--            width="130"-->
          <!--          >-->
          <!--            <template slot-scope="{row}">-->
          <!--              <div v-if="row.plan_startdate">{{ row.plan_startdate.substring(0, 11) }}</div>-->
          <!--              <div v-else>/</div>-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <!--          <el-table-column-->
          <!--            prop="plan_enddate"-->
          <!--            label="预计完工时间"-->
          <!--            show-tooltip-when-overflow-->
          <!--            sortable="custom"-->
          <!--            width="130"-->
          <!--          >-->
          <!--            <template slot-scope="{row}">-->
          <!--              <div v-if="row.plan_enddate">{{ row.plan_enddate.substring(0, 11) }}</div>-->
          <!--              <div v-else>/</div>-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <el-table-column
            prop="lm_user"
            label="创建人员"
            show-tooltip-when-overflow
            sortable="custom"
            width="150"
          >
            <template slot-scope="{row}">
              <div v-if="row.lm_user">{{ row.lm_user }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="lm_date"
            label="创建时间"
            show-tooltip-when-overflow
            width="130"
            sortable="custom"
          >
            <template slot-scope="{row}">
              <div v-if="row.lm_date">{{ row.lm_date.substring(0, 11) }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <!--          <el-table-column-->
          <!--            label="操作"-->
          <!--            fixed="right"-->
          <!--            width="80"-->
          <!--          >-->
          <!--            <template slot-scope="{row}">-->
          <!--              <div class="operationClass">-->
          <!--                <el-tooltip class="item" effect="dark" content="下达" placement="top">-->
          <!--                  &lt;!&ndash;                <el-button v-waves type="text" @click="edit('edit',row)">下达</el-button>&ndash;&gt;-->
          <!--                  <i-->
          <!--                    class="el-icon-bottom"-->
          <!--                    style="color:#42b983;cursor: pointer;margin-left: 5px"-->
          <!--                    @click="edit('edit',row)"-->
          <!--                  />-->
          <!--                </el-tooltip>-->
          <!--              </div>-->
          <!--            </template>-->
          <!--          </el-table-column>-->
        </el-table>
      </div>
      <!--分页-->
      <pagination
        :total="sourceFormTotal"
        :page.sync="sourceForm.page"
        :limit.sync="sourceForm.rows"
        align="right"
        layout="total,prev, pager, next,sizes"
        popper-class="select_bottom"
        @pagination="getMesBadOrderSearch"
      />
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="dialogVisibleSourceBack">返 回</el-button>
          <el-button v-waves type="primary" @click="dialogVisibleSourceConfirm">确 定</el-button>
        </div>
      </span>
    </el-dialog>
    <!--打印预览对话框  大标签-->
    <el-dialog
      v-el-drag-dialog
      title=""
      top="7vh"
      :visible.sync="dialogVisibleApprove"
      width="812px"
      class="dialogVisibleConfirmClass"
      append-to-body
      :close-on-click-modal="false"
      @close="dialogVisibleConfirmClose"
    >
      <!-- 要打印的区域 -->
      <div id="printMe" style="padding: 30px">
        <!--        <div v-for="(item,index) in tableDataPrint" :key="index">-->
        <div>
          <div style="font-size: 26px; text-align: center">流程单</div>
          <div style="display: flex;justify-content: space-around;margin-top: 20px; position: relative;">
            <div style="width: 78%">
              <el-form
                ref="formApprove"
                :model="formApprove"
                label-width="80px"
                inline
                style="display: flex;justify-content: space-between"
              >
                <div class="elForm">
                  <el-form-item label="销售单号:" class="formContent">
                    {{ formApprove.saleOrderCode ? formApprove.saleOrderCode : '/' }}
                  </el-form-item>
                  <el-form-item label="工单编号:" class="formContent">
                    {{ formApprove.mesordercode }}
                  </el-form-item>
                  <el-form-item label="源单单号:" class="formContent">
                    {{ formApprove.m_po }}
                  </el-form-item>
                  <el-form-item label="产品编码:" class="formContent">
                    {{ formApprove.partcode }}
                  </el-form-item>
                  <el-form-item label="产品名称:" class="formContent">
                    {{ formApprove.partname }}
                  </el-form-item>
                  <el-form-item label="产品规格:" class="formContent">
                    {{ formApprove.partspec }}
                  </el-form-item>
                  <el-form-item label="工单数量:" class="formContent">
                    {{ formApprove.plan_qty }}
                  </el-form-item>
                  <!--                <el-form-item label="工艺路线:" class="formContent">-->
                  <!--                  {{ formApprove.routename }}-->
                  <!--                </el-form-item>-->
                  <el-form-item label="打印人员:" class="formContent">
                    <!--                  {{ localStorage.getItem('username') }}-->
                    {{ formApprove.routename }}
                  </el-form-item>
                  <el-form-item label="打印时间:" class="formContent">
                    {{ formApprove.lm_date }}
                  </el-form-item>
                </div>
              </el-form>
            </div>
            <div
              id="qrCode0"
              style="width: 22%;height:90px;
                        margin-top: 20px;
                        overflow-y: scroll;display: flex;
                        justify-content: center;
                        position: relative;"
            >
              <div id="qrCode00" ref="qrCodeDiv00" />
            </div>
            <div style="background-color: #fff;width: 20px;height:120px; position: absolute;right: 0" />
            <div
              style="z-index: 10;background-color:transparent;width: 120px;height:120px; position: absolute;right: 21px"
            />
          </div>
          <el-table
            id="table"
            :data="tableDataPrint[0]"
            border
            class="tableDataPrint"
            :header-cell-style="{ background: '#c0c0c0',textAlign:'center',color:'#000',borderColor:'#000'}"
            :cell-style="{textAlign: 'center',color:'#000',borderColor:'#000'}"
            style="width: 100%;margin-top: 20px;text-align: center;border-color: #000"
          >
            <el-table-column
              id="column0"
              prop="seq"
              label="工序号"
              width="70"
              align="center"
            />
            <el-table-column
              id="column1"
              prop="stepqrcode"
              label="工序二维码"
              width="100"
              align="center"
            >
              <template slot-scope="{row}">
                <div :id="'qrCode'+row.seq" :ref="'qrCodeDiv'+row.seq" :key="'qrCodeDiv'+row.seq" class="tableColumn" />
              </template>
            </el-table-column>
            <el-table-column
              id="column2"
              prop="stepname"
              label="工序"
              width="120"
              align="center"
            />
            <el-table-column
              id="column3"
              prop="plan_qty"
              label="加工数量"
              width="100"
              align="center"
            />
            <el-table-column
              id="column4"
              prop="good_qty"
              width="100"
              align="center"
              label="合格数量"
            />
            <el-table-column
              id="column5"
              width="100"
              prop="ng_qty"
              align="center"
              label="不良数量"
            />
            <el-table-column
              id="column6"
              prop="desc"
              align="center"
              width="120"
              label="备注"
            />
          </el-table>
        </div>
        <div v-if="tableDataPrint[1]" style="margin-top: 100px;">
          <div style="font-size: 26px; text-align: center">流程单</div>
          <div style="display: flex;justify-content: space-around;margin-top: 20px; position: relative;">
            <div style="width: 78%">
              <el-form
                ref="formApprove"
                :model="formApprove"
                label-width="80px"
                inline
                style="display: flex;justify-content: space-between"
              >
                <div class="elForm">
                  <el-form-item label="销售单号:" class="formContent">
                    {{ formApprove.saleOrderCode ? formApprove.saleOrderCode : '/' }}
                  </el-form-item>
                  <el-form-item label="工单编号:" class="formContent">
                    {{ formApprove.mesordercode }}
                  </el-form-item>
                  <el-form-item label="源单单号:" class="formContent">
                    {{ formApprove.m_po }}
                  </el-form-item>
                  <el-form-item label="产品编码:" class="formContent">
                    {{ formApprove.partcode }}
                  </el-form-item>
                  <el-form-item label="产品名称:" class="formContent">
                    {{ formApprove.partname }}
                  </el-form-item>
                  <el-form-item label="产品规格:" class="formContent">
                    {{ formApprove.partspec }}
                  </el-form-item>
                  <el-form-item label="工单数量:" class="formContent">
                    {{ formApprove.plan_qty }}
                  </el-form-item>
                  <!--                <el-form-item label="工艺路线:" class="formContent">-->
                  <!--                  {{ formApprove.routename }}-->
                  <!--                </el-form-item>-->
                  <el-form-item label="打印人员:" class="formContent">
                    <!--                  {{ localStorage.getItem('username') }}-->
                    {{ formApprove.routename }}
                  </el-form-item>
                  <el-form-item label="打印时间:" class="formContent">
                    {{ formApprove.lm_date }}
                  </el-form-item>
                </div>
              </el-form>
            </div>
            <div
              id="qrCode1"
              style="width: 22%;height:90px;
                        margin-top: 20px;
                        overflow-y: scroll;display: flex;
                        justify-content: center;
                        position: relative;"
            >
              <div id="qrCode01" ref="qrCodeDiv01" />
            </div>
            <div style="background-color: #fff;width: 20px;height:120px; position: absolute;right: 0" />
            <div
              style="z-index: 10;background-color:transparent;width: 120px;height:120px; position: absolute;right: 21px"
            />
          </div>
          <el-table
            id="table"
            :data="tableDataPrint[1]"
            border
            class="tableDataPrint"
            :header-cell-style="{ background: '#c0c0c0',textAlign:'center',color:'#000',borderColor:'#000'}"
            :cell-style="{textAlign: 'center',color:'#000',borderColor:'#000'}"
            style="width: 100%;margin-top: 20px;text-align: center;border-color: #000"
          >
            <el-table-column
              id="column0"
              prop="seq"
              label="工序号"
              width="70"
              align="center"
            />
            <el-table-column
              id="column1"
              prop="stepqrcode"
              label="工序二维码"
              width="100"
              align="center"
            >
              <template slot-scope="{row}">
                <div :id="'qrCode'+row.seq" :ref="'qrCodeDiv'+row.seq" :key="'qrCodeDiv'+row.seq" class="tableColumn" />
              </template>
            </el-table-column>
            <el-table-column
              id="column2"
              prop="stepname"
              label="工序"
              width="120"
              align="center"
            />
            <el-table-column
              id="column3"
              prop="plan_qty"
              label="加工数量"
              width="100"
              align="center"
            />
            <el-table-column
              id="column4"
              prop="good_qty"
              width="100"
              align="center"
              label="合格数量"
            />
            <el-table-column
              id="column5"
              width="100"
              prop="ng_qty"
              align="center"
              label="不良数量"
            />
            <el-table-column
              id="column6"
              prop="desc"
              align="center"
              width="120"
              label="备注"
            />
          </el-table>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="dialogVisibleBackPreview">返 回</el-button>
          <!--            <el-button v-waves v-if="operation==='add'" type="primary" @click="dialogVisibleConfirm">确 定</el-button>-->
          <!--            <el-button v-waves type="primary" @click="dialogVisibleConfirm">确 定/打 印</el-button>-->
          <el-button v-waves v-print="printObj" type="primary">打 印</el-button>
        </div>
      </span>
    </el-dialog>
    <!--打印预览页面  小标签-->
    <el-dialog
      v-el-drag-dialog
      title="预览"
      :visible.sync="dialogVisible2"
      width="1000"
      top="10vh"
      :close-on-click-modal="false"
      @close="dialogVisible2Close"
    >
      <div style="height: 650px;overflow:auto;">
        <!--      下拉框选择打印尺寸-->
        <div v-if="!isLastPrint" style="display: flex;align-items: center;margin: 0 0 20px 0">
          <div>选择打印尺寸:</div>
          <el-select
            v-model="printSize"
            :popper-append-to-body="false"
            style="width: 200px"
            placeholder="请选择"
            @change="printSizeChange"
          >
            <el-option
              v-for="item in printSizeSelectArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </div>
        <!-- 要打印的区域 -->
        <!--      <div id="printMe2" :style="{paddingLeft:'10px',paddingTop: '5px'}">-->
        <div v-if="!isLastPrint" :style="printMe2StylePadding(printSize)">
          <!--      80 * 50-->
          <div
            v-if="printSize===0"
            style="display: flex;width: 280px;height: 160px;border: 1px solid #000;text-align: center;font-size: 10px;"
          >
            <div style="width: 90px;display: flex;flex-direction: column;border-right: 1px solid #000">
              <div
                style="display: flex;height: 96px;border-bottom:1px solid #000;
              justify-content: center;align-items: center;position: relative"
              >
                <div
                  id="qrCode2"
                  ref="qrCodeDiv2"
                  style="overflow-y: hidden;height:60px;position: absolute;left: 14px;"
                />
              </div>
              <div
                style="display: flex;height: 32px;justify-content: flex-start;border-bottom:1px solid #000;align-items: center"
              >
                <div style="margin-left: 5px;width: 28px">数量:</div>
                {{ qrForm.startqty }}
              </div>
              <div style="display: flex;height: 32px;justify-content: flex-start;align-items: center">
                <div style="margin-left: 5px;width: 42px">处理人:</div>
                {{ qrForm.operator }}
              </div>
            </div>
            <div style="width:190px;display: flex;flex-direction: column">
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center;text-align: left"
              >
                <div style="width: 60px;margin-left: 5px;">工单编号:</div>
                <div>{{ qrForm.wo_code }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center ;text-align: left"
              >
                <div style="width: 60px;margin-left: 5px;">产品编码:</div>
                <div>{{ qrForm.partcode }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
              >
                <div style="width:60px;margin-left: 5px;">产品名称:</div>
                <div>{{ qrForm.partname }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
              >
                <div style="width:60px;margin-left: 5px;">下道工序:</div>
                <div>{{ qrForm.nextstepname }}</div>
              </div>
              <div style="display: flex;height: 20%;justify-content: flex-start;align-items: center;text-align: left">
                <div style="width: 60px;margin-left: 5px;">处理时间:</div>
                <div>{{ qrForm.operatorTime }}</div>
              </div>
            </div>
          </div>
          <!--      78 * 60    -->
          <div
            v-if="printSize===1"
            style="display: flex;width: 280px;height: 160px;border: 1px solid #000;text-align: center;font-size: 10px;"
          >
            <div style="width: 90px;display: flex;flex-direction: column;border-right: 1px solid #000">
              <div
                style="display: flex;height: 96px;border-bottom:1px solid #000;
              justify-content: center;align-items: center;position: relative"
              >
                <div
                  id="qrCode2"
                  ref="qrCodeDiv2"
                  style="overflow-y: hidden;height:60px;position: absolute;left: 14px;"
                />
              </div>
              <div
                style="display: flex;height: 32px;justify-content: flex-start;border-bottom:1px solid #000;align-items: center"
              >
                <div style="margin-left: 5px;width: 28px">数量:</div>
                {{ qrForm.startqty }}
              </div>
              <div style="display: flex;height: 32px;justify-content: flex-start;align-items: center">
                <div style="margin-left: 5px;width: 42px">处理人:</div>
                {{ qrForm.operator }}
              </div>
            </div>
            <div style="width:190px;display: flex;flex-direction: column">
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center;text-align: left"
              >
                <div style="width: 60px;margin-left: 5px;">工单编号:</div>
                <div>{{ qrForm.wo_code }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center ;text-align: left"
              >
                <div style="width: 60px;margin-left: 5px;">产品编码:</div>
                <div>{{ qrForm.partcode }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
              >
                <div style="width:60px;margin-left: 5px;">产品名称:</div>
                <div>{{ qrForm.partname }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
              >
                <div style="width:60px;margin-left: 5px;">下道工序:</div>
                <div>{{ qrForm.nextstepname }}</div>
              </div>
              <div style="display: flex;height: 20%;justify-content: flex-start;align-items: center;text-align: left">
                <div style="width: 60px;margin-left: 5px;">处理时间:</div>
                <div>{{ qrForm.operatorTime }}</div>
              </div>
            </div>
          </div>
          <!--      60 * 40    -->
          <div
            v-if="printSize===2"
            style="display: flex;width: 220px;height: 130px;border: 1px solid #000;text-align: center;font-size: 12px"
          >
            <div style="width: 70px;display: flex;flex-direction: column;border-right: 1px solid #000">
              <div
                style="display: flex;height: 60%;border-bottom:1px solid #000;
              justify-content: center;align-items: center;position: relative"
              >
                <div
                  id="qrCode2"
                  ref="qrCodeDiv2"
                  style="overflow-y: hidden;height:71%;position: absolute;left: 7px;"
                />
              </div>
              <div
                style="display: flex;height:  20%;justify-content: flex-start;border-bottom:1px solid #000;align-items: center"
              >
                <div style="margin-left: 3px; ">数量:{{ qrForm.startqty }}</div>
              </div>
              <div style="display: flex;height:  20%;justify-content: flex-start;align-items: center;">
                <div style="margin-left: 3px; ">操作:{{ qrForm.operator }}</div>
              </div>
            </div>
            <div style="width:150px;display: flex;flex-direction: column">
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center;text-align: left"
              >
                <div style="margin-left: 3px;">编号:{{ qrForm.wo_code }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center ;text-align: left"
              >
                <div style="margin-left: 3px;">产品编码:{{ qrForm.partcode }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
              >
                <div style="margin-left: 3px;">产品名称:{{ qrForm.partname }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
              >
                <div style="margin-left: 3px;">下道工序:{{ qrForm.nextstepname }}</div>
              </div>
              <div style="display: flex;height: 20%;justify-content: flex-start;align-items: center;text-align: left">
                <div style=" margin-left: 3px;">时间: {{ qrForm.operatorTime }}</div>
                <!--                <div>{{ qrForm.operatorTime?qrForm.operatorTime.substring(5):'' }}</div>-->
                <!--                <div>{{ qrForm.operatorTime }}</div>-->
              </div>
            </div>
          </div>
          <div
            v-if="printSize===5"
            style="display: flex;width: 140px;height: 80px;border: 1px solid #000;text-align: center;font-size: 10px;"
          >
            <div v-if="false" style="width: 45px;display: flex;flex-direction: column;border-right: 1px solid #000">
              <div
                style="display: flex;height: 60px;border-bottom:1px solid #000;
              justify-content: center;align-items: center;position: relative"
              >
                <div
                  id="qrCode2"
                  ref="qrCodeDiv2"
                  style="overflow-y: hidden;height:60px;position: absolute;left: 14px;"
                />
              </div>
              <div
                style="display: flex;height: 20px;justify-content: flex-start;border-bottom:1px solid #000;align-items: center"
              >
                <div style="margin-left: 5px;width: 28px">数量:</div>
                {{ qrForm.startqty }}
              </div>
              <div style="display: flex;height: 20px;justify-content: flex-start;align-items: center">
                <div style="margin-left: 5px;width: 42px">处理人:</div>
                {{ qrForm.operator }}
              </div>
            </div>
            <div style="width:100%;display: flex;flex-direction: column;">
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: center;align-items: center;text-align: left"
              >
                <!--              <div style="width: 60px;margin-left: 5px;">工单编号:</div>-->
                <div>{{ qrForm.wo_code }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: center;align-items: center ;text-align: left"
              >
                <!--              <div style="width: 60px;margin-left: 5px;">产品编码:</div>-->
                <div>{{ qrForm.partcode }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: center;align-items: center;text-align: left"
              >
                <!--              <div style="width:60px;margin-left: 5px;">产品名称:</div>-->
                <div>{{ qrForm.partname }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: center;align-items: center;text-align: left"
              >
                <!--              <div style="width:60px;margin-left: 5px;">下道工序:</div>-->
                <div>{{ qrForm.nextstepname }}</div>
              </div>
              <div style="display: flex;height: 20%;justify-content: center;align-items: center;text-align: left">
                <!--              <div style="width: 60px;margin-left: 5px;">处理时间:</div>-->
                <div>{{ qrForm.operatorTime }}</div>
              </div>
            </div>
          </div>
        </div>
        <div v-if="isLastPrint" style="display: flex;flex-direction: column">
          <div style="display: flex;font-weight: bold;font-size: 16px;margin-bottom: 20px;">
            <div style="width: 48%;">
              请选择入库条码
            </div>
            <div style="width: 48%;margin-left: 4%;">
              已选中的入库条码
            </div>
          </div>
          <div style="display: flex;">
            <!--          请选择入库条码-->
            <div style="display: flex;flex-direction: column;height: 600px;overflow: auto;width: 48%;">
              <div
                v-for="(item,index) in lastPrintArr"
                :key="item.inbarcode"
                :style="{marginTop:index===0?'':'15px'}"
                style="display: flex;align-items: center;"
              >
                <!--          v-if="printSize===0"-->
                <div style="margin-right:40px">
                  <el-checkbox
                    :key="item.inbarcode"
                    v-model="item.checked"
                    @change="val=>inbarcodeChange(val,item)"
                  />
                </div>
                <div
                  style="display: flex;width: 280px;height: 160px;border: 1px solid #000;text-align: center;font-size: 10px;"
                >
                  <div style="width: 90px;display: flex;flex-direction: column;border-right: 1px solid #000">
                    <div
                      style="display: flex;height: 96px;border-bottom:1px solid #000;
                      justify-content: center;align-items: center;position: relative"
                    >
                      <div
                        id="qrCode2"
                        ref="qrCodeDiv2"
                        style="overflow-y: hidden;height:60px;position: absolute;left: 14px;"
                      />
                    </div>
                    <div
                      style="display: flex;height: 32px;justify-content: flex-start;border-bottom:1px solid #000;align-items: center"
                    >
                      <div style="margin-left: 5px;width: 28px">数量:</div>
                      {{ item.good_qty }}
                    </div>
                    <div style="display: flex;height: 32px;justify-content: flex-start;align-items: center">
                      <div style="margin-left: 5px;width: 42px">处理人:</div>
                      {{ item.username }}
                    </div>
                  </div>
                  <div style="width:190px;display: flex;flex-direction: column">
                    <div
                      style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center;text-align: left"
                    >
                      <div style="width: 60px;margin-left: 5px;">工单编号:</div>
                      <div>{{ item.wo_code }}</div>
                    </div>
                    <div
                      style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center ;text-align: left"
                    >
                      <div style="width: 60px;margin-left: 5px;">产品编码:</div>
                      <div>{{ item.partcode }}</div>
                    </div>
                    <div
                      style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
                    >
                      <div style="width:60px;margin-left: 5px;">产品名称:</div>
                      <div>{{ item.partname }}</div>
                    </div>
                    <div
                      style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
                    >
                      <div style="width:60px;margin-left: 5px;">产品规格:</div>
                      <div>{{ item.partspec ? item.partspec : '/' }}</div>
                    </div>
                    <div
                      style="display: flex;height: 20%;justify-content: flex-start;align-items: center;text-align: left"
                    >
                      <div style="width: 60px;margin-left: 5px;">处理时间:</div>
                      <div>{{ item.lm_date }}</div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <!--          已选中的入库条码-->
            <div
              style="display: flex;flex-direction: column;height: 600px;overflow: auto;width: 48%;margin-left: 50px;"
            >
              <div id="printMe2">
                <div
                  v-for="(item,index) in lastPrintArrSelected"
                  v-if="item.checked"
                  :key="item.inbarcode"
                  :style="{marginTop:index===0?'':'15px'}"
                  style="display: flex;align-items: center;"
                >
                  <div
                    style="display: flex;width: 280px;height: 160px;border: 1px solid #000;text-align: center;font-size: 10px;"
                  >
                    <div style="width: 90px;display: flex;flex-direction: column;border-right: 1px solid #000">
                      <div
                        style="display: flex;height: 96px;border-bottom:1px solid #000;
                        justify-content: center;align-items: center;position: relative"
                      >
                        <div
                          id="qrCode3"
                          ref="qrCodeDiv3"
                          style="overflow-y: hidden;height:60px;position: absolute;left: 14px;"
                        />
                      </div>
                      <div
                        style="display: flex;height: 32px;justify-content: flex-start;border-bottom:1px solid #000;align-items: center"
                      >
                        <div style="margin-left: 5px;width: 28px">数量:</div>
                        {{ item.good_qty }}
                      </div>
                      <div style="display: flex;height: 32px;justify-content: flex-start;align-items: center">
                        <div style="margin-left: 5px;width: 42px">处理人:</div>
                        {{ item.username }}
                      </div>
                    </div>
                    <div style="width:190px;display: flex;flex-direction: column">
                      <div
                        style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center;text-align: left"
                      >
                        <div style="width: 60px;margin-left: 5px;">工单编号:</div>
                        <div>{{ item.wo_code }}</div>
                      </div>
                      <div
                        style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center ;text-align: left"
                      >
                        <div style="width: 60px;margin-left: 5px;">产品编码:</div>
                        <div>{{ item.partcode }}</div>
                      </div>
                      <div
                        style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
                      >
                        <div style="width:60px;margin-left: 5px;">产品名称:</div>
                        <div>{{ item.partname }}</div>
                      </div>
                      <div
                        style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
                      >
                        <div style="width:60px;margin-left: 5px;">产品规格:</div>
                        <div>{{ item.partspec ? item.partspec : '/' }}</div>
                      </div>
                      <div
                        style="display: flex;height: 20%;justify-content: flex-start;align-items: center;text-align: left"
                      >
                        <div style="width: 60px;margin-left: 5px;">处理时间:</div>
                        <div>{{ item.lm_date }}</div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="dialogVisible2 = false;">取 消</el-button>
          <el-button v-waves v-print="printObj2" type="primary">打 印</el-button>
        </div>
      </span>
    </el-dialog>
    <!--    工艺路线对话框-->
    <el-dialog
      v-el-drag-dialog
      :close-on-click-modal="false"
      title="关联工艺路线"
      :visible.sync="dialogVisibleRoute"
      width="800px"
      top="10vh"
      :fullscreen="isIpad"
      class="dialogVisibleRoute"
      @closed="handleCloseRoute"
      @close="handleCloseRoute"
    >
      <div>
        <i class="el-icon-s-comment" style="color:#42b983;" /> 产品名称:{{ dialogFormRoute.projectName }}
      </div>
      <el-divider />
      <div style="margin-bottom: 10px">
        <i class="el-icon-s-operation" style="color:#42b983;" /> 工艺路线集合
      </div>
      <div class="myCheckboxGroup">
        <div
          v-for="item in dialogFormRoute.routeOperationArr"
          :key="item.code"
          :style="{border:item.isSelected1?'1px solid #42b983':'1px solid #eee'}"
          class="myCheckbox"
          @click="myCheckboxClick(item)"
        >
          <input
            class="myCheckboxInput"
            type="checkbox"
            :value="item.code"
            :name="item.name"
            :style="{color:item.isSelected2?'#42b983':'#fff'}"
            @click="myCheckboxInputClick(item)"
          >{{ item.name }}
          <!--            父子点击事件不影响-->
          <!--            onClick="event.cancelBubble = true"-->
        </div>
      </div>
      <el-divider />
      <div>
        <i class="el-icon-s-operation" style="color:#42b983;" /> 默认工艺路线
      </div>
      <div style="margin-top: 20px">
        <el-select
          v-model="defaultroute_code"
          filterable
          style="width: 200px;"
          placeholder="请选择"
          class="defaultroute_code"
        >
          <el-option
            v-for="item in defaultroute_codeArr"
            :key="item.code"
            :label="item.name"
            :value="item.code"
          />
        </el-select>
      </div>
      <el-divider />
      <div style="margin-bottom: 10px">
        <i class="el-icon-s-operation" style="color:#42b983;" /> 工序列表
      </div>
      <div style="overflow-y: scroll">
        <el-table
          ref="projectTableData"
          :data="projectTableData"
          border
          height="280"
          :row-class-name="tableRowClassName"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
        >
          <el-table-column
            prop="seq"
            width="100"
            label="工序序号"
            fixed
          />
          <el-table-column
            prop="stepcode"
            label="工序编码"
            show-tooltip-when-overflow
          />
          <el-table-column
            prop="stepname"
            label="工序名称"
            show-tooltip-when-overflow
          />
          <el-table-column
            prop="enable"
            label="启用状态"
            fixed="right"
          >
            <template slot-scope="{row}">
              <div v-if="row.enable==='Y'">
                <svg-icon icon-class="circleYes" style="margin-right: 2px" />
                是
              </div>
              <div v-if="row.enable==='N'">
                <svg-icon icon-class="circleNo" style="margin-right: 2px" />
                否
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="routeDialogVisibleCancel">取 消</el-button>
          <el-button v-waves type="primary" @click="routeDialogVisibleConfirm">确 定</el-button>
        </div>
      </span>
    </el-dialog>
    <!--    工单sop/工序sop-->
    <el-dialog
      v-el-drag-dialog
      class="sop"
      title="设备SOP预览"
      :visible.sync="SopDialogVisible"
      width="800px"
      :close-on-click-modal="false"
      top="15vh"
      @closed="handleSopClose"
      @close="handleSopClose"
    >
      <el-form inline label-width="110px" style="display:flex">
        <el-form-item label="工单SOP">
          <el-select
            v-model="dialogSopForm.sop"
            style="width:200px"
            placeholder="请选择"
            filterable
            :popper-append-to-body="false"
            @change="sopChange"
          >
            <el-option
              v-for="item in sopArr"
              :key="item.filepath"
              :label="item.filename"
              :value="item.filepath"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="Sop版本">
          <el-input v-model="dialogSopForm.v" disabled style="width: 200px" />
        </el-form-item>
      </el-form>
      <el-button
        v-waves
        type="primary"
        style="margin-left: 37px"
        @click="view"
      >预 览/下 载
      </el-button>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="handleSopClose">取 消</el-button>
          <!--          <el-button-->
          <!--            v-waves-->
          <!--            type="primary"-->
          <!--            :loading="$store.state.app.buttonIsDisabled"-->
          <!--            :disabled="$store.state.app.buttonIsDisabled"-->
          <!--            @click="handleSopConfirm"-->
          <!--          >确 定</el-button>-->
        </div>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import Pagination from '@/components/Pagination'
import { handleDatetime, handleDatetime2, validateCode } from '@/utils/global'
import { getCookie } from '@/utils/auth'
import QRCode from 'qrcodejs2'
import $ from 'jquery'
import elDragDialog from '@/directive/el-drag-dialog'
import waves from '@/directive/waves'
import {
  AddMesOrderCodeSearch,
  AddUpdateMesOrder, DeleteMesOrder,
  MesBadOrderSearch, MesOrderDistribution, MesOrderNewStepContent, MesOrderProcessSopSearch,
  MesOrderSearch, MesOrderSopSearch,
  UpdateMesOrderStepSearch
} from '@/api/WorkOrder'
import { PartSelect } from '@/api/ProductModel'
import { PrentOrganization, PrentOrganizationNoCompany, StepData } from '@/api/GeneralBasicData'
import Sortable from 'sortablejs'
import ElDragSelect from '@/components/DragSelect'
import { MesOrderPrintSearch } from '@/api/GridReport' // base on element-ui
import DateType from '@/components/DateType'
import { PartSelectRpute, RouteSelectStep } from '@/api/basicSettings'
import { DeviceSopSearch } from '@/api/DeviceManager'
export default {
  name: 'WorkOrderList',
  components: {
    Pagination, ElDragSelect, DateType
  },
  directives: { elDragDialog, waves },
  data() {
    return {
      mouseHoverType: 'mouseout',
      mouseHoverTypeDialog: 'mouseout',
      isExpandForm: false,
      isIpad: false,
      mainHeight: 0,
      tableHeight: 0,
      username: '',
      form: {
        wkshopcode: '', // 车间编码
        mesorderstus: '', // 工单状态码
        mesordercode: '', // 工单编号
        partcode: '', // 产品编码
        ordertype: '', // ordertype
        sourceorder: '', // 源单单号
        saleordercode: '', // 销售订单
        partname: '', // 产品名称
        partspec: '', // 产品规格
        creatuser: '', // 创建人员
        // createdate: '', // 创建时间
        datatype: 'ED', // 日期类型(计划开工(PS)、计划完工(PE)、预计交付(ED)、创建日期(CT))
        timeValue: [], // 查询日期
        prop: 'lm_date', // 排序字段
        order: 'desc', // 排序字段
        page: 1, // 第几页
        rows: 20 // 每页多少条
      },
      erporderstusArr: [
        { code: 'NEW', name: '新工单' },
        // { code: 'CREATING', name: '执行中' },
        // { code: 'CREATED', name: '已关闭' }
        { code: 'ALLO', name: '已派发' },
        { code: 'START', name: '开工' },
        { code: 'CLOSED', name: '完工' }
        // { code: 'NOSCHED', name: '待排程' },
        // { code: 'SCHED', name: '已排程' }
      ],
      wkshopcodeArr: [],
      total: 10,
      tableData: [],
      dialogVisible: false,
      dialogForm: {
        mesorderstus: 'NEW', // 工单状态码
        mesordercode: '', // 工单编号
        ordertype: 'PO', // 工单类型
        sourceorderid: '', // 源单id
        sourceorder: '', // 源单单号
        partcode: '', // 产品编码
        partname: '', // 产品名称
        partspec: '', // 产品规格
        mesqty: '', // 工单数量
        wkshopcode: '', // 生产车间编码
        wkshopname: '', // 生产车间名称
        deliverydate: '', // 交付时间
        data_sources: '', // 数据来源
        routecode: '', // 工艺路线
        mesmaxqty: 0, // 工单的最大值
        mesqtyinit: 0// 工单数量初始值
      },
      ordertypeArr: [// 工单类型
        { code: 'PO', name: '标准工单' },
        { code: 'FO', name: '报废补单' }
      ],
      partArr: [], // 产品信息
      wkshopArr: [], // 生产车间数组
      routeArr: [], // 工艺路线数组
      orderlevArr: [
        { code: 1, name: '特级' },
        { code: 2, name: '紧急' },
        { code: 3, name: '正常' }
      ], // 工单等级数组
      operation: '',
      dialogFormRules: {
        mesorderstus: [
          { required: true, message: '请选择订单状态', trigger: ['blur', 'change'] }
        ],
        partcode: [
          { required: true, message: '请选择产品信息', trigger: ['blur', 'change'] }
        ],
        mesordercode: [
          { required: true, validator: validateCode, trigger: ['blur', 'change'] }
        ],
        mesqty: [
          { required: true, message: '请输入工单数量', trigger: ['blur', 'change'] }
        ],
        wkshopcode: [
          { required: true, message: '请选择生产车间', trigger: ['blur', 'change'] }
        ],
        deliverydate: [
          { required: true, message: '请选择预计交付日期', trigger: ['blur', 'change'] }
        ],
        planstartdate: [
          { required: true, message: '请选择开始时间', trigger: ['blur', 'change'] }
        ],
        planenddate: [
          { required: true, message: '请选择结束时间', trigger: ['blur', 'change'] }
        ],
        orderlev: [
          { required: true, message: '请选择工单等级', trigger: ['blur', 'change'] }
        ],
        isAps: [
          { required: true, message: '请选择是否排程', trigger: ['blur', 'change'] }
        ],
        bomId: [
          { required: true, message: '请选择物料清单', trigger: ['blur', 'change'] }
        ]
      },
      dialogVisibleTask: false,
      taskTableData: [],
      dialogVisibleSearch: false,
      searchTableData: [],
      dialogVisibleApprove: false,
      tableDataPrint: [], // 打印页面内容
      printObj: {
        id: 'printMe',
        popTitle: '打印模板',
        preview: false,
        extraHead: '<meta http-equiv="Content-Language" content="zh-cn"/>',
        closeCallback(vue) { // 关闭打印的回调事件(无法确定点击的是确认还是取消)
          console.log('11212', vue)
          // vue.dialogVisible = false
          vue.dialogVisibleApprove = false
        },
        beforeOpenCallback(vue) {
          vue.printLoading = true
          console.log('打开之前')
          console.log()
        },
        openCallback(vue) {
          vue.printLoading = false
          console.log('执行了打印')
        }
      },
      formApprove: {
        m_po: '', // 源单单号
        mesordercode: '',
        partcode: '',
        partname: '',
        partspec: '',
        plan_qty: '',
        routename: '',
        lm_date: ''
      },
      number: '',
      dialogVisible2: false,
      printObj2: {
        id: 'printMe2',
        popTitle: '打印模板',
        preview: false,
        extraHead: '<meta http-equiv="Content-Language" content="zh-cn"/>',
        closeCallback(vue) { // 关闭打印的回调事件(无法确定点击的是确认还是取消)
          console.log('11212', vue)
          // vue.dialogVisible = false
          // vue.dialogVisible2 = false
          // vue.dialogVisible = false
        },
        beforeOpenCallback(vue) {
          vue.printLoading = true
          console.log('打开之前')
          console.log()
        },
        openCallback(vue) {
          vue.printLoading = false
          console.log('执行了打印')
        }
      },
      qrForm: {
        qrvalue: '',
        startqty: '',
        wo_code: '',
        partcode: '',
        partname: '',
        nextstepname: '',
        operator: '', // 操作人
        operatorTime: ''// 操作时间
      },
      dialogVisibleSource: false,
      sourceTableData: [],
      sourceForm: {
        wkshopcode: '', // 车间编码
        mesordercode: '', // 工单编号
        sourceorder: '', // 订单编号
        saleordercode: '', // 销售订单号
        partcode: '', // 产品编码
        partname: '', // 产品名称
        partspec: '', // 产品规格
        creatuser: '', // 创建人员
        // paystartdate: '', // 交付时间
        // paystartdate: '', // 预计开工时间
        // payenddate: '', // 预计完工时间
        createdate: '', // 创建时间
        prop: 'lm_date', // 排序字段
        order: 'desc', // 排序字段
        page: 1, // 第几页
        rows: 20 // 每页多少条
      },
      sourceFormTotal: 10,
      radioSelectedId: '',
      isExpandDialog: false, // 对话框表单是否展开,默认不展开
      dialogVisibleRoute: false,
      dialogFormRoute: {
        projectName: '', // 产品名称
        projectCode: '', // 产品代码
        routeOperationArr: [] // 工艺路线集合
      },
      defaultroute_code: '', // 默认工艺路线选中值
      defaultroute_codeArr: '', // 默认工艺路线数组
      projectTableData: [], // 设备列表
      tableDataDetail: [], // 点击工单表的行 显示详细信息
      printSize: 0,
      printSizeSelectArr: [// 宽*高
        { code: 0, name: '80*50' },
        { code: 1, name: '78*60' },
        { code: 2, name: '60*40' }
        // { code: 2, name: '50*60' },
        // { code: 3, name: '50*40' },
        // { code: 4, name: '50*80' },
        // { code: 5, name: '40*30' }
      ],
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() < Date.now() - 8.64e7
        }
      },
      isLastPrint: false, // 是否是末道打印
      lastPrintArr: [], // 末道打印的数组(所有)
      lastPrintArrSelected: [], // 末道打印的数组(选中)
      switchButton: false,
      routeStepArr: '',
      stepTableData: [],
      sortable: null,
      stepSelectArr: [], // 工序下拉数据
      stepSelectedValue: [], // 下拉选中值
      multipleSelection: [],
      datatypeList: [
        { code: 'PS', name: '预计开工日期' },
        { code: 'PE', name: '预计完工日期' },
        { code: 'ED', name: '预计交付日期' },
        { code: 'CT', name: '工单创建日期' }
      ],
      routecodeArr: [], //
      sourceType: false, // 工序的数据来源
      mesSetting: JSON.parse(localStorage.getItem('mesSetting')),
      SopDialogVisible: false,
      dialogSopForm: { // 设备SOP表单
        sop: '',
        v: ''
      },
      sopArr: [],
      routeCode: '', // 工艺路线code
      partCode: ''
    }
  },
  watch: {
    'stepSelectedValue': {
      // deep: true,
      handler: function(val) {
        // do something with the new and old value of stepSelectedValue
        console.log(val, 1)
        const arr = JSON.parse(JSON.stringify(this.stepTableData))
        const arrStepcode = arr.map(i => i.stepcode)
        this.stepTableData = []
        val.forEach(i => {
          this.stepTableData.push(
            {
              stepcode: i,
              stepname: this.stepSelectArr.find(j => j.stepcode === i).stepname,
              stepprice: arrStepcode.includes(i) ? arr.find(j => j.stepcode === i).stepprice : 0
            }
          )
        })
      }
    }
  },
  activated() {   window.addEventListener('resize', this.getHeight)   this.getHeight() }, created() {
    this.handleRequest()
  },
  mounted() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
    // this.$nextTick(() => {
    //   this.setSort()
    // })
  },
  methods: {
    // 弹出框关闭
    handleSopClose() {
      this.SopDialogVisible = false
      this.dialogSopForm = { // 设备SOP表单
        sop: '',
        v: ''
      }
    },
    // 预览
    view() {
      window.open(process.env.VUE_APP_BASE_API_FILE + this.dialogSopForm.sop)
    },
    sopChange(val) {
      this.dialogSopForm.v = this.sopArr.find(i => i.filepath === val).version
    },
    async pre(row, type) {
      if (type === 1) {
        const data = {
          wocode: row.wo_code,
          materielcode: row.partcode
        }
        const { data: res } = await MesOrderSopSearch(data)
        this.sopArr = res
      }
      if (type === 2) {
        const data = {
          materielcode: this.partCode,
          routecode: this.routeCode ? this.routeCode : '',
          stepcode: row.step_code
        }
        const { data: res } = await MesOrderProcessSopSearch(data)
        this.sopArr = res
      }
      this.SopDialogVisible = true
    },
    // 工序来源切换
    sourceTypeChange(val) {
      this.stepTableData = []
      if (val) {
        this.getMesOrderNewStepContent()
      } else {
        if (this.mesSetting.route) {
          this.routecodeChange()
        } else {
          this.getBasicProcessData()
        }
      }
    },
    DateTypeChange(value) {
      this.form.datatype = value
    },
    cycleTimeChange(val) {
      this.form.timeValue = val
    },
    setSort() {
      const el = this.$refs.stepTableDataRef.$el.querySelectorAll('.el-table__body-wrapper > table > tbody')[0]
      this.sortable = Sortable.create(el, {
        ghostClass: 'sortable-ghost', // Class name for the drop placeholder,
        setData: function(dataTransfer) {
          // to avoid Firefox bug
          // Detail see : https://github.com/RubaXa/Sortable/issues/1012
          dataTransfer.setData('Text', '')
        },
        onEnd: evt => {
          const targetRow = this.stepTableData.splice(evt.oldIndex, 1)[0]
          this.stepTableData.splice(evt.newIndex, 0, targetRow)
          this.stepSelectedValue = this.stepTableData.map(i => i.stepcode)
          // for show the changes, you can delete in you code
          // const tempIndex = this.newList.splice(evt.oldIndex, 1)[0]
          // this.newList.splice(evt.newIndex, 0, tempIndex)
        }
      })
    },
    tableRowClassName({ row, rowIndex }) {
      return 'custom-row'
    },
    handleRequest() {
      this.getMesOrderSearch().then(res => {
        if (res.code === '200') {
          this.getSelect()
          this.getPrentOrganizationNoCompany()
        }
      })
    },
    async getPrentOrganizationNoCompany() {
      const { data: res } = await PrentOrganizationNoCompany()
      this.wkshopcodeArr = res
    },
    async getMesOrderSearch() {
      // let tempDate = this.form.createdate
      // if (tempDate.length > 0) {
      //   tempDate = handleDatetime(tempDate[0]) + '~' + handleDatetime(tempDate[1])
      // }
      const data = {
        wkshopcode: this.form.wkshopcode,
        mesorderstus: this.form.mesorderstus, // 工单状态码
        mesordercode: this.form.mesordercode, // 工单编号
        partcode: this.form.partcode, // 产品编码
        partname: this.form.partname, // 产品名称
        partspec: this.form.partspec, // 产品规格
        creatuser: this.form.creatuser, // 创建人员
        sourceorder: this.form.sourceorder, // 源单单号
        saleordercode: this.form.saleordercode, // 销售订单
        ordertype: this.form.ordertype, // 单据类型
        datatype: this.form.datatype,
        searchdate: this.form.timeValue.join('~'),
        // createdate: this.form.createdate.toString().length > 0 ? handleDatetime(this.form.createdate) : '', // 创建时间
        prop: this.form.prop, // 排序字段
        order: this.form.order, // 排序字段
        page: this.form.page, // 第几页
        rows: this.form.rows // 每页多少条
      }
      const res = await MesOrderSearch(data)
      this.tableData = res.data
      this.total = res.count
      // this.form.createdate = tempDate
      return { code: res.code }
    },
    async getSelect() {
      // 获取产品信息
      const { data: res1 } = await PartSelect()
      this.partArr = res1
      // 获取组织
      const { data: res2 } = await PrentOrganization()
      this.wkshopArr = res2
      // 获取工序
      const { data: res3 } = await StepData()
      this.stepSelectArr = res3
    },
    // 订单状态改变时
    erporderstusChange(val) {
      this.form.mesorderstus = val
    },
    // 排序改变时
    sortChange({ column, prop, order }) {
      if (order === 'descending') {
        order = 'desc'
      } else if (order === 'ascending') {
        order = 'asc'
      } else {
        order = 'desc'
      }
      this.form.order = order
      this.form.prop = prop
      this.getMesOrderSearch()
    },
    sourceSortChange({ column, prop, order }) {
      if (order === 'descending') {
        order = 'desc'
      } else if (order === 'ascending') {
        order = 'asc'
      } else {
        order = 'desc'
      }
      this.sourceForm.order = order
      this.sourceForm.prop = prop
      this.getMesBadOrderSearch()
    },
    // 查询
    search() {
      this.getMesOrderSearch()
    },
    // 重置
    reset(val) {
      this.form.wkshopcode = ''
      this.form.mesorderstus = ''
      this.form.mesordercode = ''
      this.form.partcode = ''
      this.form.partname = ''
      this.form.partspec = ''
      this.form.paydate = ''
      this.form.creatuser = ''
      this.form.sourceorder = ''
      this.form.ordertype = ''
      // this.form.createdate = ''
      this.form.timeValue = []
      this.cycleTime = null
      this.$refs.DateTypeRef.clearValue()
      this.getMesOrderSearch()
    },
    // 新增按钮
    async add(operation) {
      const { data: res } = await AddMesOrderCodeSearch()
      this.dialogForm.mesordercode = res
      this.operation = operation
      this.dialogVisible = true
      this.dialogForm.data_sources = 'MES'
      this.$nextTick(() => {
        this.setSort()
      })
    },
    // 工序任务
    async check(row) {
      // const { data: res } = await SearchWorkStep({ wo_code: row.wo_code })
      // this.taskTableData = res
      //
      // if (this.taskTableData.length === 0) {
      //   return this.$message.info('无生产任务数据!')
      // }
      // this.dialogForm.mesordercode = res[0].wo_code
      // this.dialogVisibleTask = true
    },
    dialogVisibleBack() {
      this.dialogVisibleTask = false
    },
    handleSelectionChange(val) {
      this.multipleSelection = val.map(i => i.wo_code)
    },
    selected(row, index) {
      return row.status === 'NEW' && row.isstep === 'Y'
    },
    // 派发
    send() {
      if (this.multipleSelection.length === 0) {
        return this.$message.info('请先勾选相对应的工单!')
      }
      this.$confirm('是否确认派发?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        MesOrderDistribution(this.multipleSelection).then(res => {
          if (res.code === '200') {
            this.$notify.success('派发成功!')
            this.getMesOrderSearch()
          }
        })
      }).catch(() => {
        this.$notify.info('已取消派发')
      })
    },
    // 删除按钮
    async del(row) {
      if (row.status === 'START' || row.status === 'CLOSED' || row.status === 'SCHED') {
        return this.$message.info('此工单不可删除!')
      }
      this.$confirm('是否确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        const data = {
          souceid: row.sourceid ? row.sourceid : '',
          wocode: row.wo_code,
          m_po: row.m_po,
          orderqty: row.plan_qty
        }
        DeleteMesOrder(data).then(res => {
          if (res.code === '200') {
            this.$notify.success('删除成功!')
            if (this.form.page > 1 && this.tableData.length === 1) {
              this.form.page--
            }
            this.getMesOrderSearch()
          }
        })
      }).catch(() => {
        this.$notify.info('已取消删除')
      })
    },
    // 修改按钮
    async edit(operation, row) {
      this.operation = operation
      this.dialogForm.data_sources = row.data_sources
      this.dialogForm.mesorderstus = row.status
      this.dialogForm.mesordercode = row.wo_code
      this.dialogForm.ordertype = row.wotype
      this.dialogForm.sourceorderid = row.sourceid
      this.dialogForm.sourceorder = row.m_po
      this.dialogForm.partcode = row.partcode
      this.dialogForm.partname = row.partname
      this.dialogForm.partspec = row.partspec
      this.dialogForm.wkshopcode = row.wkshp_code
      this.dialogForm.routecode = row.route_code
      this.dialogForm.deliverydate = row.saleOrderDeliveryDate.substring(0, 11)
      this.dialogForm.mesqty = row.plan_qty
      this.dialogForm.mesqtyinit = row.plan_qty
      const data = {
        sourceid: this.dialogForm.sourceorderid,
        sourcewo: this.dialogForm.sourceorder,
        wocode: this.dialogForm.mesordercode,
        data_sources: this.dialogForm.data_sources
      }
      const { data: res } = await UpdateMesOrderStepSearch(data)
      this.dialogForm.mesmaxqty = res.canupdate_qty
      if (this.mesSetting.route) { // 按工艺路线走模式
        if (!this.dialogForm.routecode) {
          await this.getPartcodeChangeDialog()
        }
        if (res.stepdata.length > 0) {
          res.stepdata.forEach(i => {
            this.stepTableData.push(
              {
                stepcode: i.step_code,
                stepname: i.stepname,
                stepprice: i.stepprice
              }
            )
          })
          this.stepSelectedValue = this.stepTableData.map(i => i.stepcode)
        } else {
          const data2 = {
            wkshopcode: this.dialogForm.wkshopcode,
            partcode: this.dialogForm.partcode
          }
          const { data: res2 } = await MesOrderNewStepContent(data2)
          if (res2.length > 0) {
            res2.forEach(i => {
              this.stepTableData.push(
                {
                  stepcode: i.step_code,
                  // stepname: i.stepname,
                  stepprice: i.stepprice
                }
              )
            })
            this.stepSelectedValue = this.stepTableData.map(i => i.stepcode)
          }
        }
      } else {
        if (res.stepdata.length > 0) {
          res.stepdata.forEach(i => {
            this.stepTableData.push(
              {
                stepcode: i.step_code,
                stepname: i.stepname,
                stepprice: i.stepprice
              }
            )
          })
          this.stepSelectedValue = this.stepTableData.map(i => i.stepcode)
        } else {
          await this.getBasicProcessData()
        }
      }
      this.dialogVisible = true
      this.$nextTick(() => {
        this.setSort()
      })
    },
    // 按工序模式走的时候  引用基础资料 工艺
    async getBasicProcessData() {
      const { data: res } = await PartSelectRpute({ partcode: this.dialogForm.partcode })
      res.sort((a, b) => a.step_seq - b.step_seq)
      this.stepTableData = []
      res.forEach(i => {
        this.stepTableData.push(
          {
            stepcode: i.step_code,
            stepname: i.step_name,
            stepprice: i.unprice
          }
        )
      })
      this.stepSelectedValue = this.stepTableData.map(i => i.stepcode)
    },
    // 工单关闭事件
    orderClose() {
      console.log('工单关闭事件')
    },
    // 对话框产品信息值改变
    partcodeChangeDialog(val) {
      console.log(val)
      this.dialogForm.partname = this.partArr.find(item => item.partcode === val).partname
      this.dialogForm.partcode = this.partArr.find(item => item.partcode === val).partcode
      this.dialogForm.partspec = this.partArr.find(item => item.partcode === val).partspec
      this.dialogForm.routecode = ''
      if (this.mesSetting.route) {
        this.getPartcodeChangeDialog()
      } else {
        this.getBasicProcessData()
      }
    },
    async getPartcodeChangeDialog() {
      const { data: res } = await PartSelectRpute({ partcode: this.dialogForm.partcode })
      this.routecodeArr = res
      // if (this.mesSetting.route) { // 按工艺路线走模式
      this.dialogForm.routecode = this.partArr.find(item => item.partcode === this.dialogForm.partcode).default_route
      if (this.dialogForm.routecode && !this.sourceType) {
        await this.routecodeChange()
      } else {
        await this.getMesOrderNewStepContent()
      }
      // }
      // else { // 按工序走模式
      //   await this.getMesOrderNewStepContent()
      // }
    },
    // 工艺路线值改变
    async routecodeChange() {
      const data = {
        partcode: this.dialogForm.partcode,
        routecode: this.dialogForm.routecode
      }
      const { data: res } = await RouteSelectStep(data)
      this.stepSelectedValue = []
      this.stepTableData = []
      if (res.length > 0) {
        res.sort((a, b) => a.step_seq - b.step_seq)
        res.forEach(i => {
          this.stepTableData.push(
            {
              stepcode: i.step_code,
              // stepname: i.stepname,
              stepprice: i.unprice
            }
          )
        })
        this.stepSelectedValue = this.stepTableData.map(i => i.stepcode)
      }
    },
    async getMesOrderNewStepContent() {
      // if (!this.mesSetting.route && this.operation === 'edit') {
      //   return
      // }
      const data = {
        routecode: this.dialogForm.routecode,
        wkshopcode: this.dialogForm.wkshopcode,
        partcode: this.dialogForm.partcode
      }
      const { data: res } = await MesOrderNewStepContent(data)
      // console.log(res)
      this.stepSelectedValue = []
      this.stepTableData = []
      if (res.length > 0) {
        res.forEach(i => {
          this.stepTableData.push(
            {
              stepcode: i.step_code,
              // stepname: i.stepname,
              stepprice: i.stepprice
            }
          )
        })
        this.stepSelectedValue = this.stepTableData.map(i => i.stepcode)
      }
    },
    // 对话框关闭事件
    handleClose() {
      this.dialogForm = {
        mesorderstus: 'NEW', // 工单状态码
        mesordercode: '', // 工单编号
        ordertype: 'PO', // 工单类型
        sourceorderid: '', // 源单id
        sourceorder: '', // 源单单号
        partcode: '', // 产品编码
        partname: '', // 产品名称
        partspec: '', // 产品规格
        mesqty: '', // 工单数量
        wkshopcode: '', // 生产车间编码
        wkshopname: '', // 生产车间名称
        deliverydate: '', // 交付时间
        data_sources: '' // 数据来源
      }
      this.sourceType = false
      this.stepSelectedValue = []
      this.stepTableData = []
      this.$refs.dialogForm.clearValidate()
    },
    // 对话框取消
    dialogVisibleCancel() {
      this.dialogVisible = false
    },
    // 对话框确认
    dialogVisibleConfirm() {
      this.$refs.dialogForm.validate(valid => {
        if (valid) {
          if (this.dialogForm.ordertype === 'FO' && this.dialogForm.sourceorder.toString().trim().length <= 0) {
            return this.$message.info('源单单号不能为空!')
          }
          if (this.dialogForm.mesqty <= 0) {
            return this.$message.info('工单数量不能等于零!')
          }
          if (this.dialogForm.data_sources === 'ERP' && this.dialogForm.mesmaxqty < this.dialogForm.mesqty) {
            return this.$message.info('此工单的最大修改数值为:' + this.dialogForm.mesmaxqty)
          }
          const workListSub = []
          this.stepTableData.forEach((i, j) => {
            workListSub.push(
              {
                stepseq: j + 1,
                stepcode: i.stepcode,
                stepprice: i.stepprice,
                isbott: j === 0 ? 'Y' : 'N',
                isend: j === this.stepTableData.length - 1 ? 'Y' : 'N'
              }
            )
          })
          if (workListSub.length === 0) {
            return this.$message.info('工序不能为空!')
          }
          const data = {
            wostatus: this.dialogForm.mesorderstus, // 工单状态
            wocode: this.dialogForm.mesordercode, // 工单号
            wotype: this.dialogForm.ordertype, // 工单类型
            sourceid: this.dialogForm.sourceorderid, // 源单id
            sourcewo: this.dialogForm.sourceorder, // 源单单号
            partcode: this.dialogForm.partcode, // 产品编号
            wkshopcode: this.dialogForm.wkshopcode,
            woqty: this.dialogForm.mesqty, // 工单数量
            deliverydate: this.dialogForm.deliverydate, // 交付时间
            data_sources: this.dialogForm.data_sources, // 数据来源
            isstep: workListSub.length > 0 ? 'Y' : 'N', //
            difference: this.dialogForm.mesqty - this.dialogForm.mesqtyinit, // 数据差值
            routecode: this.dialogForm.routecode,
            workListSub
          }
          this.$store.state.app.buttonIsDisabled = true
          AddUpdateMesOrder(data, this.operation === 'add' ? 'Add' : 'Update').then(res => {
            if (res.code === '200') {
              this.dialogVisible = false
              // this.handlePrint()
              this.$message.success(this.operation === 'add' ? '添加成功!' : '保存成功!')
              this.getMesOrderSearch()
              this.$store.state.app.buttonIsDisabled = false
            } else {
              this.$message.error(this.operation === 'add' ? '添加失败!' : '保存失败!')
            }
          })
        }
      })
    },
    // 派发打印
    async sendPrint() {
      const data = {
        username: getCookie('admin'),
        // username: getCookie('username'),
        mesordercode: this.dialogForm.mesordercode
      }
      const res = await MesOrderPrintSearch1(data)
      // const res = await PrintOrder(data)
      if (res.code === '200') {
        // 参数具体说明请参考帮助文档中的“WEB报表(B/S报表)->WEB报表客户端->启动参数说明”部分
        var args = {
          type: 'print', // preview  print
          showOptionDlg: false, // 如果不显示打印对话框而直接打印,将此行注释去掉即可
          report: urlAddRandomNo('./static/grf/产品流传单A4.grf'),
          data: res.data
        }
        webapp_ws_ajax_run(args)
      }
    },
    // 获取页面高度
    getHeight() {
      this.$nextTick(() => {
        this.mainHeight = window.innerHeight - 85
        // this.tableHeight = this.mainHeight - 250
        this.tableHeight = this.mainHeight - 515
        if (window.innerHeight < 769) {
          this.tableHeight = this.tableHeight - 20
        }
        this.isIpad = window.innerHeight < 769 && window.innerWidth < 1367
        this.$refs.tableDataRef.doLayout()
      })
    },
    // 工艺路线放大镜点击
    async searchClick() {
      if (this.dialogForm.routecode === '') {
        return this.$message.info('请先选择工艺路线!')
      }
      this.dialogVisibleSearch = true
      const { data: res } = await SelectRouteStep({ routecode: this.dialogForm.routecode })
      this.searchTableData = res
    },
    dialogVisibleSearchBack() {
      this.dialogVisibleSearch = false
    },
    // 处理打印
    handlePrint(wo_code, saleOrderCode) {
      // const number = Math.random() * Math.random()
      // this.number = number === 0 ? (10 + Math.random()) : number
      // console.log(number)
      this.formApprove.saleOrderCode = this.formApprove.saleOrderCode !== '' ? this.formApprove.saleOrderCode : saleOrderCode
      const data2 = {
        mesordercode: wo_code || this.dialogForm.mesordercode
      }
      MesOrderPrintSearch(data2).then(res2 => {
        if (res2.code === '200') {
          this.dialogVisibleApprove = true
          const res3 = res2.data.recordset
          // this.tableDataPrint = res3
          this.tableDataPrint = this.chunkArray(res3, 8)
          this.formApprove.mesordercode = res3[0].wo_code
          this.formApprove.m_po = res3[0].m_po || '/'
          this.formApprove.partcode = res3[0].partcode
          this.formApprove.partname = res3[0].partname
          this.formApprove.partspec = res3[0].partspec || '/'
          this.formApprove.plan_qty = res3[0].plan_qty
          this.formApprove.routename = localStorage.getItem('username') // 打印人员
          this.formApprove.lm_date = res3[0].lm_date
          this.$nextTick(() => {
            this.tableDataPrint.forEach((item, index) => {
              item.forEach(i => {
                this.bindQRCode(i.seq, i.stepqrcode, 'small')
              })
              this.bindQRCode(index, this.formApprove.mesordercode, 'big')
              const div = document.getElementById('qrCode' + index)
              div.scrollTop = div.scrollHeight // 滚动条位于最底部
            })
            // const div = document.getElementById('qrCode')
            // 这么多代码只需要这一句实现我们所需要的功能,定位div滚动条位置在底部,scrollHeight计算出div的高度,再scrollTop 设置滚动条的高度为多少
            // div.scrollTop = div.scrollHeight // 滚动条位于最底部
            // div.scrollTop = 0 // 滚动条位于最顶部
          })
        }
      })
    },
    dialogVisibleTaskClose() {
      this.dialogForm.mesordercode = ''
    },
    /*
  * 手动点击打印
  * */
    // 返回按钮
    dialogVisibleBackPreview() {
      this.dialogVisibleApprove = false
    },
    chunkArray(array, size) {
      const chunked = []
      let i = 0
      while (i < array.length) {
        chunked.push(array.slice(i, i + size))
        i += size
      }
      return chunked
    },
    // dialogVisibleConfirmPreview(param) {
    //   this.$refs.dialogForm.validate(valid => {
    //     if (valid) {
    //       const data = {
    //         username: getCookie('admin'),
    //         mesordercode: this.dialogForm.mesordercode
    //       }
    //       MesOrderPrintSearch1(data).then(res => {
    //         if (res.code === '200') {
    //           this.dialogVisibleApprove = true
    //           console.log(res, 11)
    //         }
    //       })
    //     }
    //   })
    // },
    // 生成二维码    工单报表二维码
    bindQRCode(seq, text, size) {
      if (size === 'big') {
        new QRCode(this.$refs['qrCodeDiv0' + seq], {
          text: text,
          width: size === 'big' ? 90 : 60,
          height: size === 'big' ? 90 : 60,
          // colorDark: '#333333', // 二维码颜色
          colorDark: '#000', // 二维码颜色
          colorLight: '#ffffff', // 二维码背景色
          correctLevel: QRCode.CorrectLevel.L// 容错率,L/M/H
        })
      } else {
        new QRCode(this.$refs['qrCodeDiv' + seq], {
          text: text,
          width: size === 'big' ? 90 : 60,
          height: size === 'big' ? 90 : 60,
          // colorDark: '#333333', // 二维码颜色
          colorDark: '#000', // 二维码颜色
          colorLight: '#ffffff', // 二维码背景色
          correctLevel: QRCode.CorrectLevel.L// 容错率,L/M/H
        })
      }
    },
    dialogVisibleConfirmClose() {
      this.formApprove.saleOrderCode = ''
      // this.dialogForm.mesordercode = ''
      this.formApprove.mesordercode = ''
      this.formApprove.m_po = ''
      this.formApprove.partcode = ''
      this.formApprove.partname = ''
      this.formApprove.partspec = ''
      this.formApprove.plan_qty = ''
      this.formApprove.routename = ''
      this.formApprove.lm_date = ''
      // this.$refs.qrCodeDiv0.title = ''
      this.tableDataPrint = []
    },
    // 补打按钮
    supplementClick() {
      this.dialogVisibleTask = false
      this.handlePrint()
    },
    // 补打小标签
    supplementSmallClick(row) {
      // let obj = {}
      console.log(row, 21)
      // this.taskTableData.forEach((item, index) => {
      this.tableDataDetail.forEach((item, index) => {
        if (item.seq === row.seq) {
          console.log(item)
          this.qrForm = {
            // qrvalue: item.seq === this.taskTableData.length ? item.wo_code + ';' + item.stepcode : item.wo_code + ';' + this.taskTableData[item.seq].stepcode,
            qrvalue: item.seq === this.tableDataDetail.length ? item.wo_code + ';' + item.stepcode : item.wo_code + ';' + this.tableDataDetail[item.seq].stepcode,
            // startqty: item.seq === this.taskTableData.length ? item.plan_qty : this.taskTableData[item.seq].plan_qty,
            startqty: item.seq === this.tableDataDetail.length ? item.plan_qty : this.tableDataDetail[item.seq].plan_qty,
            wo_code: item.wo_code,
            partcode: item.partcode,
            partname: item.partname,
            // nextstepname: item.seq === this.taskTableData.length ? item.stepname : this.taskTableData[item.seq].stepname,
            nextstepname: item.seq === this.tableDataDetail.length ? item.stepname : this.tableDataDetail[item.seq].stepname,
            operator: getCookie('username'),
            operatorTime: handleDatetime2(new Date())
          }
          this.$nextTick(() => {
            console.log(this.qrForm.qrvalue, 3333)
            this.bindQRCode2(this.qrForm.qrvalue)
            const div = document.getElementById('qrCode2')
            // 这么多代码只需要这一句实现我们所需要的功能,定位div滚动条位置在底部,scrollHeight计算出div的高度,再scrollTop 设置滚动条的高度为多少
            div.scrollTop = div.scrollHeight // 滚动条位于最底部
            // div.scrollTop = 0 // 滚动条位于最顶部
          })
        }
      })
      // this.dialogVisibleTask = false
      this.dialogVisible2 = true
      console.log(this.qrForm, 1111)
    },
    // 补打生产入库条码
    async getProductInHouseLabCode(ordercode) {
      const res = await ProductInHouseLabCode({ ordercode })
      console.log(res)
      this.isLastPrint = true
      this.lastPrintArr = res.data
      this.dialogVisible2 = true
      // 生产二维码
      this.$nextTick(() => {
        this.lastPrintArr.forEach((i, index) => {
          i.checked = false
          new QRCode(this.$refs.qrCodeDiv2[index], {
            text: i.inbarcode,
            width: this.printSize !== 2 ? 60 : 55,
            height: this.printSize !== 2 ? 60 : 55,
            colorDark: '#000', // 二维码颜色
            colorLight: '#ffffff', // 二维码背景色
            correctLevel: QRCode.CorrectLevel.L// 容错率,L/M/H
          })
        })
      })
    },
    dialogVisible2Close() {
      this.qrForm.qrvalue = ''
      this.qrForm.startqty = ''
      this.qrForm.wo_code = ''
      this.qrForm.partcode = ''
      this.qrForm.partname = ''
      this.qrForm.nextstepname = ''
      this.qrForm.operator = ''
      this.qrForm.operatorTime = ''
      // this.$refs.qrCodeDiv2 = ''
      this.isLastPrint = false
      this.lastPrintArr = []
      this.lastPrintArrSelected = []
    },
    // 生成二维码    工序标签二维码
    bindQRCode2(text) {
      new QRCode(this.$refs.qrCodeDiv2, {
        text: text,
        width: this.printSize !== 2 ? 60 : 55,
        height: this.printSize !== 2 ? 60 : 55,
        colorDark: '#000', // 二维码颜色
        colorLight: '#ffffff', // 二维码背景色
        correctLevel: QRCode.CorrectLevel.L// 容错率,L/M/H
      })
    },
    // 报废补单情况下可点击选择
    mesordertsourcesearchclick() {
      if (this.dialogForm.ordertype === 'PO') {
        return this.$message.info('工单类型为报废补单情况下可选择!')
      }
      this.getMesBadOrderSearch()
      this.dialogVisibleSource = true
    },
    async getMesBadOrderSearch() {
      // let tempDate2 = this.sourceForm.paystartdate
      // if (tempDate2.length > 0) {
      //   tempDate2 = handleDatetime(tempDate2[0]) + '~' + handleDatetime(tempDate2[1])
      // }
      let tempDate = this.sourceForm.createdate
      if (tempDate.length > 0) {
        tempDate = handleDatetime(tempDate[0]) + '~' + handleDatetime(tempDate[1])
      }
      const data = {
        wkshopcode: this.form.wkshopcode, // 车间编码
        mesordercode: this.sourceForm.mesordercode, // 工单编号
        sourceorder: '', // 源单单号
        saleordercode: '', // 销售单号
        partcode: this.sourceForm.partcode, // 产品编码
        partname: this.sourceForm.partname, // 产品名称
        partspec: this.sourceForm.partspec, // 产品规格
        // paystartdate: tempDate2, // 交付时间
        // payenddate: tempDate, // 交付时间
        creatuser: this.sourceForm.creatuser, // 创建人员
        createdate: tempDate, // 创建时间
        prop: this.sourceForm.prop, // 排序字段
        order: this.sourceForm.order, // 排序字段
        page: this.sourceForm.page, // 第几页
        rows: this.sourceForm.rows // 每页多少条
      }
      const res = await MesBadOrderSearch(data)
      this.sourceTableData = res.data
      this.sourceFormTotal = res.count
    },
    // 单选框选中获取当前行信息
    // getCurrentRowSource2(id) {
    //   this.radioSelectedId = id
    // },
    // 单选框选中获取当前行信息
    getCurrentRowSource(row, event, column) {
      this.radioSelectedId = row.id
      this.dialogForm.mesqty = row.bad_qty
    },
    sourceSearch() {
      this.getMesBadOrderSearch()
    },
    sourceReset() {
      this.sourceForm.wkshopcode = ''
      this.sourceForm.mesordercode = ''
      this.sourceForm.sourceorder = ''
      this.sourceForm.partcode = ''
      this.sourceForm.partname = ''
      this.sourceForm.partspec = ''
      // this.sourceForm.paystartdate = ''
      // this.sourceForm.payenddate = ''
      this.sourceForm.creatuser = ''
      this.sourceForm.createdate = ''
      this.getMesBadOrderSearch()
    },
    dialogVisibleSourceClose() {
      this.radioSelectedId = ''
      this.sourceForm.wkshopcode = ''
      this.sourceForm.mesordercode = ''
      this.sourceForm.sourceorder = ''
      this.sourceForm.partcode = ''
      this.sourceForm.partname = ''
      this.sourceForm.partspec = ''
      this.sourceForm.paystartdate = ''
      this.sourceForm.payenddate = ''
      this.sourceForm.creatuser = ''
      this.sourceForm.createdate = ''
      this.isExpandDialog = false
      this.sourceTableData = []
    },
    dialogVisibleSourceBack() {
      this.dialogVisibleSource = false
    },
    dialogVisibleSourceConfirm() {
      console.log(this.radioSelectedId)
      this.sourceTableData.forEach(item => {
        if (item.id === this.radioSelectedId) {
          this.dialogForm.sourceorder = item.wo_code
          this.dialogForm.partcode = item.partcode
          this.dialogForm.partspec = item.partspec
        }
      })
      this.dialogVisibleSource = false
    },
    mesordertypeChange(val) {
      if (val === 'PO') {
        this.dialogForm.sourceorder = ''
        this.dialogForm.partcode = ''
        this.dialogForm.partspec = ''
      }
    },
    /* 关联工艺路线模块*/
    // 关联工艺路线
    async routeClick(row) {
      console.log(row)
      // this.defaultroute_code = row.default_route
      this.dialogFormRoute.projectCode = row.partcode
      this.dialogFormRoute.projectName = row.partname
      this.dialogVisibleRoute = true
      const { data: res } = await InventoryFileAssociationRoute({ partcode: this.dialogFormRoute.projectCode })
      this.dialogFormRoute.routeOperationArr = res
      this.dialogFormRoute.routeOperationArr.forEach((item, index) => {
        item.isSelected1 = false
        item.isSelected2 = false
        if (index === 0) {
          item.isSelected1 = true
          this.projectTableData = item.Data
        }
        if (item.flag === 'Y') {
          item.isSelected2 = true
          this.$nextTick(() => {
            $('input:checkbox').eq(index).prop('checked', true)
          })
        }
      })
      this.defaultroute_codeArr = this.dialogFormRoute.routeOperationArr.filter(item => item.flag === 'Y')
    },
    // 对话框关闭
    handleCloseRoute() {
      this.dialogFormRoute.routeOperationArr = []
      this.defaultroute_codeArr = []
      this.defaultroute_code = ''
      this.projectTableData = []
    },
    // 取消
    routeDialogVisibleCancel() {
      this.dialogVisibleRoute = false
    },
    // 确定
    async routeDialogVisibleConfirm() {
      const temp = this.dialogFormRoute.routeOperationArr.filter(item => item.isSelected2)
      if (this.defaultroute_code === '' && temp.length > 0) {
        return this.$message.info('默认工艺路线不能为空!')
      }
      // 提交格式
      const data = []
      this.dialogFormRoute.routeOperationArr.forEach(item => {
        if (item.isSelected2) {
          data.push({ code: item.code, name: item.name })
        }
      })
      const res = await SaveInventoryFile(this.dialogFormRoute.projectCode, this.defaultroute_code, data)
      if (res.code === '200') {
        this.$message.success('保存成功!')
        await this.getMesOrderSearch()
        this.dialogVisibleRoute = false
      }
    },
    // 大盒子点击事件
    myCheckboxClick(val) {
      console.log(val, 1)
      this.dialogFormRoute.routeOperationArr.forEach(item => {
        item.isSelected1 = val.code === item.code
      })
      this.projectTableData = val.Data
    },
    // 小盒子点击事件
    myCheckboxInputClick(val) {
      console.log(val, 2)
      val.isSelected2 = !val.isSelected2
      this.dialogFormRoute.routeOperationArr.forEach((item, index) => {
        if (val.code === item.code) {
          item.flag = !item.flag
        }
      })
      if (val.code === this.defaultroute_code) {
        this.defaultroute_code = ''
      }
      this.defaultroute_codeArr = this.dialogFormRoute.routeOperationArr.filter(item => item.isSelected2)
    },
    //  行点击事件
    async rowClick(row, event, column) {
      this.formApprove.saleOrderCode = row.saleOrderCode
      this.routeCode = row.route_code ? row.route_code : ''
      this.partCode = row.partcode ? row.partcode : ''
      const data = {
        sourceid: row.sourceid,
        sourcewo: row.m_po,
        wocode: row.wo_code,
        data_sources: row.data_sources
      }
      const { data: res } = await UpdateMesOrderStepSearch(data)
      this.tableDataDetail = res.stepdata
    },
    // 工序删除
    stepDel(row) {
      console.log(row)
      const index = this.stepSelectedValue.findIndex(i => i === row.stepcode)
      this.stepSelectedValue.splice(index, 1)
    },
    // 打印工单
    printOrder() {
    },
    //  选择打印尺寸的大小值改变
    printSizeChange(val) {
      this.$nextTick(() => {
        this.bindQRCode2(this.qrForm.qrvalue)
      })
    },
    printMe2StylePadding(val) {
      if (val === 0) {
        return { paddingLeft: '10px', paddingTop: '5px' }
      }
      if (val === 5) {
        return { paddingLeft: '15px', paddingTop: '7px' }
      }
    },
    inbarcodeChange(val, item) {
      // 当 lastPrintArrSelected中未有当前勾选的值是  走push  item  否则走过滤掉item
      if (val) {
        this.lastPrintArrSelected.push(item)
      } else {
        this.lastPrintArrSelected = this.lastPrintArrSelected.filter(i => i.inbarcode !== item.inbarcode)
      }
      // 生产二维码
      this.$nextTick(() => {
        this.lastPrintArrSelected.forEach((i, index) => {
          console.log(i.inbarcode, 'i.inbarcode')
          new QRCode(this.$refs.qrCodeDiv3[index], {
            text: i.inbarcode,
            width: 60,
            height: 60,
            colorDark: '#000', // 二维码颜色
            colorLight: '#ffffff', // 二维码背景色
            correctLevel: QRCode.CorrectLevel.L// 容错率,L/M/H
          })
        })
        // const div = document.getElementById('qrCode3')
        // div.scrollTop = 0 // 滚动条位于最底部
        this.$forceUpdate()
      }, 500)
    },
    stepSelectedValueChange(val) {
      // console.log(val, 123)
    },
    getSummaries(param) {
      const { columns, data } = param
      const sums = []
      const i = 9
      columns.forEach((column, index) => {
        if (index === i) {
          sums[index] = '总数'
          return
        }
        const values = data.map(item => Number(item[column.property]))
        if (column.property === 'plan_qty') {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr)
            if (!isNaN(value)) {
              return prev + curr
              // return Math.round(prev * 100) / 100 + Math.round(curr * 100) / 100
            }
          }, 0)
          sums[index] += ' 单'
        }
      })
      this.$nextTick(() => {
        this.$refs.tableDataRef.doLayout()
      })
      return sums
    }
  }
}
</script>
<style>
.sortable-ghost {
  opacity: .8;
  color: #fff !important;
  background: #42b983 !important;
}
</style>
<style lang="scss" scoped>
$main_color: #42b983;
.stepSelectedValueClass{
  ::v-deep input{
    //min-height: 34px !important;
    height: 68px !important;
  }
}
.dialogVisibleRoute {
  .myCheckboxGroup {
    display: flex;
    flex-wrap: wrap;
    .myCheckbox {
      //border: 1px solid $main_color;
      border: 1px solid #eee;
      display: flex;
      min-width: 100px;
      padding: 10px;
      margin: 10px 30px 0 0;
      border-radius: 5px;
      cursor: default;
      .myCheckboxInput {
        margin: 1px 5px 0 0;
        cursor: pointer;
      }
    }
    //.myCheckbox{
    //  border: 1px solid $main_color;
    //}
    input[type=checkbox] {
      cursor: pointer;
      position: relative;
      width: 14px;
      height: 14px;
      font-size: 14px;
    }
    input[type=checkbox]::after {
      position: absolute;
      top: 0;
      //color: rgb(130, 35, 35);
      color: $main_color;
      width: 14px;
      height: 14px;
      display: inline-block;
      visibility: visible;
      padding-left: 0px;
      text-align: center;
      content: ' ';
      border-radius: 3px
    }
    input[type=checkbox]:checked::after {
      //content: "✓";
      content: "√";
      color: #fff;
      font-size: 12px;
      font-weight: bold;
      background-color: $main_color;
    }
  }
}
.dialogVisibleRoute {
  ::v-deep .el-dialog__body {
    padding: 20px 20px !important;
  }
}
.defaultroute_code ::v-deep .el-input__suffix-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -3px;
}
.el-date-editor {
  font-size: 14px;
}
::v-deep .el-dialog__body {
  padding: 20px 100px !important;
}
.sop {
  ::v-deep .el-dialog__body {
    padding: 50px 80px !important;
  }
}
.dialogVisibleSearch ::v-deep .el-dialog__body {
  padding: 20px 20px !important;
}
.dialogVisibleConfirmClass ::v-deep .el-dialog__body {
  padding: 20px 20px !important;
}
::v-deep .el-table .caret-wrapper {
  transform: scale(0.8);
}
::v-deep .el-button--text {
  color: $main_color;
  font-size: 14px;
  cursor: pointer;
}
::v-deep .el-radio.is-bordered + .el-radio.is-bordered {
  margin: 10px 30px 0px 0;
}
.body ::v-deep .el-form-item {
  margin-bottom: 0;
}
.elForm ::v-deep .el-form-item {
  margin-bottom: 0;
}
.elTableDiv {
  ::v-deep .el-radio__label {
    display: none;
  }
}
.el-table::before {
  height: 0;
}
//.dialogVisibleConfirmClass >>>.el-table--border, .el-table--fit {
//  border-bottom: 2px solid #000 ;
//  //outline: #000 solid 2px !important;
//}
.tableDataPrint ::v-deep div.cell {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.formContent {
  width: 240px;
}
</style>
<style media="print">
/*@media print {*/
@page {
  size: auto;
  margin: 3mm;
}
</style>
<style>
.formContent .el-form-item__label {
  color: #000 !important;
}
</style>
<!--公共页面样式-->
<style lang="scss" scoped>
$main_color: #42b983;
::v-deep .el-range-input {
  font-size: 14px !important;
}
::v-deep .el-range__icon {
  line-height: 28px !important;
}
::v-deep .el-range-separator {
  line-height: 28px !important;
}
::v-deep .el-range-input {
  font-size: 14px;
}
::v-deep .el-range-separator {
  display: flex;
  justify-content: center;
  align-items: center;
}
//::v-deep .el-button--primary, .el-button--default, .el-button--info {
//  height: 34px;
//  display: flex;
//  align-items: center;
//  padding: 0 15px;
//}
::v-deep .el-button--primary {
  //background-color: $main_color !important;
}
::v-deep .el-button--default {
  background-color: #f8f8fa;
  border: none;
}
::v-deep .el-input__inner {
  height: 34px;
  line-height: 34px;
  //color: #a7a7a7;
}
::v-deep .el-dialog__body {
  padding: 20px 100px !important;
}
::v-deep .dialogVisibleRoles .el-dialog__body {
  padding: 20px 20px !important;
}
::v-deep .importPickerClass .el-dialog__body {
  padding: 20px 20px !important;
}
::v-deep .el-dialog__footer {
  display: flex;
  justify-content: flex-end;
}
::v-deep .el-table .caret-wrapper {
  transform: scale(0.8);
}
::v-deep .cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
::v-deep .el-table::before {
  height: 0;
}
::v-deep .el-table__body-wrapper {
  background-color: #f8f8fa;
}
::v-deep .el-table__body .el-table__row.hover-row td {
  background-color: #eaecef;
}
::v-deep .el-form--inline .el-form-item__label {
  color: #a7a7a7;
}
.body ::v-deep .el-divider {
  border: 1px solid #eee;
  width: 99%;
  margin: 10px auto;
}
.body ::v-deep .el-form-item {
  margin-bottom: 0;
}
.userDialogVisible ::v-deep .el-form-item {
  margin-bottom: 0;
}
.dateMini {
  ::v-deep .el-input__inner {
    line-height: 34px;
    height: 34px;
    width: 200px;
    display: flex;
    font-size: 14px !important;
    align-items: center !important;
  }
  ::v-deep .el-input__prefix {
    margin-top: -3px;
  }
  //::v-deep .el-range__icon{
  //  line-height: 28px;
  //}
}
::v-deep .el-select__caret {
  display: flex;
  align-items: center;
  justify-content: center;
}
.tableFixed {
  ::v-deep .el-table__fixed-right {
    height: 100% !important;
  }
  ::v-deep .el-table__fixed {
    height: 100% !important;
  }
}
</style>
<style>
.el-table .custom-row {
  background: #f8f8fa;
}
</style>
<style>
.sortable-ghost {
  opacity: .8;
  color: #fff !important;
  background: #42b983 !important;
}
<template>
  <div>
    <div class="body" :style="{height:mainHeight+'px'}">
      <div class="bodyTopButtonGroup" style="justify-content: space-between">
        <div style="display: flex">
          <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button>
          <el-button v-waves type="success" icon="el-icon-connection" @click="send">派发</el-button>
        </div>
        <!--        <el-button v-waves type="primary" @click="batchUpdate"><i-->
        <!--          class="el-icon-edit"-->
        <!--          style="margin-right: 0;"-->
        <!--        /> 批量绑定-->
        <!--        </el-button>-->
      </div>
      <div class="bodyTopFormGroup">
        <el-form
          ref="form"
          :model="form"
          label-width="100px"
          inline
          style="display: flex;"
        >
          <div class="elForm">
            <el-form-item label="车间名称" style=" display: flex;">
              <el-select
                v-model="form.wkshopcode"
                filterable
                :popper-append-to-body="false"
                style="width: 200px"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in wkshopcodeArr"
                  :key="item.torg_code"
                  :label="item.torg_name"
                  :value="item.torg_code"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="工单状态" style=" display: flex;">
              <el-select
                v-model="form.mesorderstus"
                :popper-append-to-body="false"
                style="width: 200px"
                placeholder="请选择"
                filterable
                @change="erporderstusChange"
              >
                <el-option
                  v-for="item in erporderstusArr"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="工单编号" style=" display: flex;">
              <el-input v-model="form.mesordercode" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="源单单号" style="display: flex;">
              <el-input v-model="form.sourceorder" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <el-form-item v-show="isExpandForm" label="销售订单" style="display: flex;">
              <el-input v-model="form.saleordercode" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <el-form-item v-show="isExpandForm" label="单据类型" style=" display: flex;">
              <el-select
                v-model="form.ordertype"
                :popper-append-to-body="false"
                style="width: 200px"
                placeholder="请选择"
              >
                <!--            @change="mesordertypeChange"-->
                <el-option
                  v-for="item in ordertypeArr"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
            <el-form-item v-show="isExpandForm" label="产品编码" style=" display: flex;">
              <el-input v-model="form.partcode" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <el-form-item v-show="isExpandForm" label="产品名称" style=" display: flex;">
              <el-input v-model="form.partname" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <el-form-item v-show="isExpandForm" label="产品规格" style=" display: flex;">
              <el-input v-model="form.partspec" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <el-form-item v-show="isExpandForm" label="创建人员" style=" display: flex;">
              <el-input v-model="form.creatuser" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <DateType
              ref="DateTypeRef"
              :is-expand-form="isExpandForm"
              style="display:flex;justify-content: center;align-items: center;position: relative"
              :datatype-list="datatypeList"
              @DateTypeChange="DateTypeChange"
              @cycleTimeChange="cycleTimeChange"
            />
          </div>
          <div
            class="bodySearchReset"
            :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}"
          >
            <el-button v-waves type="primary" icon="el-icon-search" @click="search">查询</el-button>
            <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">重置</el-button>
          </div>
        </el-form>
        <div
          class="bodyTopFormExpand"
        >
          <svg-icon
            v-show="mouseHoverType==='mouseout'"
            style="cursor: pointer"
            :icon-class="!isExpandForm?'doubleDown3':'doubleUp3'"
            @mouseenter="mouseHoverType=$event.type"
          />
          <svg-icon
            v-show="mouseHoverType==='mouseenter'"
            style="cursor: pointer"
            :icon-class="!isExpandForm?'doubleDown':'doubleUp'"
            @click="isExpandForm=!isExpandForm"
            @mouseout="mouseHoverType=$event.type"
          />
        </div>
      </div>
      <div class="elTableDiv">
        <el-table
          ref="tableDataRef"
          class="tableFixed"
          :data="tableData"
          :height="isExpandForm?tableHeight:(tableHeight+80)+'px'"
          border
          :summary-method="getSummaries"
          show-summary
          :row-class-name="tableRowClassName"
          :style="{width: 100+'%',height:isExpandForm?tableHeight:(tableHeight+80)+'px'}"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
          @sort-change="sortChange"
          @row-click="rowClick"
          @selection-change="handleSelectionChange"
        >
          <el-table-column
            type="selection"
            width="50"
            :selectable="selected"
          />
          <el-table-column
            prop="rowNum"
            width="50"
            label="序号"
            fixed
          />
          <el-table-column
            prop="status"
            label="工单状态"
            sortable="custom"
            width="110"
            show-tooltip-when-overflow
          >
            <template slot-scope="{row}">
              <div v-if="row.status==='NEW'">新工单</div>
              <!--              <div v-if="row.status==='CREATING'">执行中</div>-->
              <!--              <div v-if="row.status==='CREATED'">已关闭</div>-->
              <div v-if="row.status==='ALLO'">已派发</div>
              <div v-if="row.status==='START'">开工</div>
              <div v-if="row.status==='CLOSED'">完工</div>
              <div v-if="row.status==='NOSCHED'">待排程</div>
              <div v-if="row.status==='SCHED'">已排程</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="isstep"
            label="工艺状态"
            sortable="custom"
            width="110"
            show-tooltip-when-overflow
          >
            <template slot-scope="{row}">
              <el-tag v-if="row.isstep==='Y'" type="success" size="mini">已绑定</el-tag>
              <el-tag v-if="row.isstep==='N'" type="danger" size="mini">未绑定</el-tag>
            </template>
          </el-table-column>
          <el-table-column
            prop="wo_code"
            label="工单编号"
            show-tooltip-when-overflow
            sortable="custom"
            min-width="160"
          />
          <el-table-column
            prop="m_po"
            label="源单单号"
            sortable="custom"
            show-tooltip-when-overflow
            min-width="160"
          >
            <template slot-scope="{row}">
              <div v-if="row.m_po">{{ row.m_po }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="saleOrderCode"
            label="销售订单"
            sortable="custom"
            show-tooltip-when-overflow
            min-width="160"
          >
            <template slot-scope="{row}">
              <div v-if="row.saleOrderCode">{{ row.saleOrderCode }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="wotype"
            label="单据类型"
            sortable="custom"
            show-tooltip-when-overflow
            min-width="120"
          >
            <template slot-scope="{row}">
              <div v-if="row.wotype==='PO'">标准工单</div>
              <div v-else-if="row.wotype==='FO'">报废补单</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="partcode"
            label="产品编码"
            show-tooltip-when-overflow
            sortable="custom"
            min-width="120"
          />
          <el-table-column
            prop="partname"
            min-width="150"
            label="产品名称"
            show-tooltip-when-overflow
            sortable="custom"
          />
          <el-table-column
            prop="partspec"
            label="产品规格"
            sortable="custom"
            width="110"
            show-tooltip-when-overflow
          >
            <template slot-scope="{row}">
              <div v-if="row.partspec">{{ row.partspec }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            v-if="mesSetting.route"
            prop="route_name"
            label="工艺路线"
            sortable="custom"
            show-tooltip-when-overflow
            width="120"
          >
            <template slot-scope="{row}">
              <div v-if="row.route_name">{{ row.route_name }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="plan_qty"
            label="工单数"
            sortable="custom"
            show-tooltip-when-overflow
            width="100"
          />
          <el-table-column
            prop="printcount"
            label="打印次数"
            sortable="custom"
            show-tooltip-when-overflow
            width="110"
          />
          <el-table-column
            prop="priuserdefnvc1"
            label="客户名称"
            width="110"
            sortable="custom"
          >
            <template slot-scope="{row}">
              {{ row.priuserdefnvc1 ? row.priuserdefnvc1 : '/' }}
            </template>
          </el-table-column>
          <el-table-column
            prop="priuserdefnvc6"
            label="客户编码"
            width="110"
            sortable="custom"
          >
            <template slot-scope="{row}">
              {{ row.priuserdefnvc6 ? row.priuserdefnvc6 : '/' }}
            </template>
          </el-table-column>
          <el-table-column
            prop="priuserdefnvc2"
            label="对内名称"
            width="110"
            sortable="custom"
          >
            <template slot-scope="{row}">
              {{ row.priuserdefnvc2 ? row.priuserdefnvc2 : '/' }}
            </template>
          </el-table-column>
          <el-table-column
            prop="priuserdefnvc3"
            label="CTP日期"
            width="110"
            sortable="custom"
          >
            <template slot-scope="{row}">
              {{ row.priuserdefnvc3 ? row.priuserdefnvc3 : '/' }}
            </template>
          </el-table-column>
          <el-table-column
            prop="priuserdefnvc4"
            label="钢刀编号"
            width="110"
            sortable="custom"
          >
            <template slot-scope="{row}">
              {{ row.priuserdefnvc4 ? row.priuserdefnvc4 : '/' }}
            </template>
          </el-table-column>
          <el-table-column
            prop="priuserdefnvc5"
            label="盒型"
            width="110"
            sortable="custom"
          >
            <template slot-scope="{row}">
              {{ row.priuserdefnvc5 ? row.priuserdefnvc5 : '/' }}
            </template>
          </el-table-column>
          <el-table-column
            prop="clerkuser"
            label="销售业务员"
            sortable="custom"
            show-tooltip-when-overflow
            width="150"
          >
            <template slot-scope="{row}">
              <div v-if="row.clerkuser">{{ row.clerkuser }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="wkshp_name"
            label="生产车间"
            show-tooltip-when-overflow
            sortable="custom"
            width="120"
          >
            <template slot-scope="{row}">
              <div v-if="row.wkshp_name">{{ row.wkshp_name }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="plan_startdate"
            label="预计开工日期"
            sortable="custom"
            width="130"
          >
            <template slot-scope="{row}">
              <div v-if="row.plan_startdate">{{ row.plan_startdate.substring(0, 11) }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="plan_enddate"
            label="预计完工日期"
            sortable="custom"
            width="130"
          >
            <template slot-scope="{row}">
              <div v-if="row.plan_enddate">{{ row.plan_enddate.substring(0, 11) }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="saleOrderDeliveryDate"
            label="预计交付日期"
            sortable="custom"
            width="130"
          >
            <template slot-scope="{row}">
              <div v-if="row.saleOrderDeliveryDate">{{ row.saleOrderDeliveryDate.substring(0, 11) }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <!--          <el-table-column-->
          <!--            prop="data_sources"-->
          <!--            show-tooltip-when-overflow-->
          <!--            label="数据来源"-->
          <!--            sortable="custom"-->
          <!--            width="120"-->
          <!--          />-->
          <el-table-column
            prop="lm_user"
            show-tooltip-when-overflow
            label="创建人员"
            sortable="custom"
            width="120"
          />
          <el-table-column
            prop="lm_date"
            label="创建时间"
            show-tooltip-when-overflow
            width="160"
            sortable="custom"
          />
          <el-table-column
            label="操作"
            width="160"
            fixed="right"
          >
            <template slot-scope="{row}">
              <div class="operationClass">
                <el-tooltip v-del-tab-index class="item" effect="dark" content="SOP预览" placement="top">
                  <i
                    v-if="mesSetting.workOrder"
                    class="el-icon-files"
                    style="cursor: pointer;color:#42b983;margin-right: 15px"
                    @click="pre(row,1)"
                  />
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="修改" placement="top">
                  <i
                    class="el-icon-edit-outline"
                    :style="{color:$store.state.settings.theme}"
                    @click="edit('edit',row)"
                  />
                </el-tooltip>
                <el-tooltip v-del-tab-index class="item" effect="dark" content="删除" placement="top">
                  <i class="el-icon-delete" :style="{color:$store.state.settings.theme}" @click="del(row)" />
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="打印工单" placement="top">
                  <!--                  <i-->
                  <!--                    class="el-icon-tickets"-->
                  <!--                    style="cursor: pointer;color: #42b983;margin-right: 15px"-->
                  <!--                    @click="check(row)"-->
                  <!--                  />-->
                  <i
                    :style="{color:$store.state.settings.theme}"
                    class="el-icon-printer"
                    style="cursor: pointer;margin-right: 15px"
                    @click="handlePrint(row.wo_code,row.saleOrderCode,row)"
                  />
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="详情" placement="top">
                  <i
                    class="el-icon-view"
                    style="cursor: pointer;"
                    :style="{color:$store.state.settings.theme}"
                    @click="edit('view',row)"
                  />
                </el-tooltip>
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <!--分页-->
      <pagination
        :total="total"
        :page.sync="form.page"
        :limit.sync="form.rows"
        align="right"
        layout="total,prev, pager, next,sizes,jumper"
        popper-class="select_bottom"
        @pagination="getMesOrderSearch"
      />
      <div class="elTableDiv">
        <el-table
          :data="tableDataDetail"
          border
          height="210px"
          :row-class-name="tableRowClassName"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
        >
          <!--          <el-table-column-->
          <!--            width="50"-->
          <!--            type="index"-->
          <!--            prop="序号"-->
          <!--            fixed-->
          <!--          />   -->
          <el-table-column
            width="50"
            prop="seq"
            label="序号"
            fixed
          />
          <el-table-column
            prop="wo_code"
            show-tooltip-when-overflow
            label="工单编号"
            width="160"
          />
          <!--          <el-table-column-->
          <!--            prop="partcode"-->
          <!--            label="产品编码"-->
          <!--            width="150"-->
          <!--            show-tooltip-when-overflow-->
          <!--          />-->
          <!--          <el-table-column-->
          <!--            prop="partname"-->
          <!--            label="产品名称"-->
          <!--            width="200"-->
          <!--            show-tooltip-when-overflow-->
          <!--          />-->
          <el-table-column
            label="工序编码"
            prop="step_code"
            show-tooltip-when-overflow
            width="150"
          />
          <el-table-column
            label="工序名称"
            show-tooltip-when-overflow
            prop="stepname"
            width="150"
          />
          <el-table-column
            label="工序单价"
            show-tooltip-when-overflow
            prop="stepprice"
          />
          <el-table-column
            label="已生产数量"
            show-tooltip-when-overflow
            prop="produceq_qty"
          />
          <el-table-column
            label="合格数量"
            show-tooltip-when-overflow
            prop="good_qty"
          />
          <el-table-column
            label="不良数量"
            show-tooltip-when-overflow
            prop="ng_qty"
          />
          <el-table-column
            label="工废数量"
            show-tooltip-when-overflow
            prop="laborbad_qty"
          />
          <el-table-column
            label="料废数量"
            show-tooltip-when-overflow
            prop="materielbad_qty"
          />
          <el-table-column
            label="待产数量"
            show-tooltip-when-overflow
            prop="delive_qty"
          />
          <el-table-column
            label="操作"
            width="120"
            fixed="right"
          >
            <template slot-scope="{row}">
              <div class="operationClass">
                <el-tooltip v-del-tab-index class="item" effect="dark" content="SOP预览" placement="top">
                  <i
                    v-if="mesSetting.tech"
                    class="el-icon-files"
                    style="cursor: pointer;color:#42b983;margin-right: 15px"
                    @click="pre(row,2)"
                  />
                </el-tooltip>
                <!--                          <el-tooltip class="item" effect="dark" content="打印工序" placement="top">-->
                <!--                            <i-->
                <!--                              v-if="tableDataDetail.length!==row.seq"-->
                <!--                              class="el-icon-printer"-->
                <!--                              :style="{color:$store.state.settings.theme}"-->
                <!--                              style="cursor: pointer;margin-right: 15px"-->
                <!--                              @click="supplementSmallClick(row)"-->
                <!--                            />-->
                <!--                          </el-tooltip>-->
                <!--                          <el-tooltip class="item" effect="dark" content="补打生产入库条码" placement="top">-->
                <!--                            <i-->
                <!--                              v-if="tableDataDetail.length===row.seq"-->
                <!--                              class="  el-icon-camera"-->
                <!--                              :style="{color:$store.state.settings.theme}"-->
                <!--                              style="cursor: pointer;margin-right: 15px"-->
                <!--                              @click="getProductInHouseLabCode(row.wo_code)"-->
                <!--                            />-->
                <!--                          </el-tooltip>-->
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <!--新增派发对话框-->
    <el-dialog
      v-el-drag-dialog
      :title="operation==='add'?'新增':(operation==='edit'?'修改':'详情')"
      :visible.sync="dialogVisible"
      width="1200px"
      top="8vh"
      :close-on-click-modal="false"
      @closed="handleClose"
      @close="handleClose"
    >
      <el-form
        ref="dialogForm"
        inline
        :rules="dialogFormRules"
        :model="dialogForm"
        label-width="110px"
      >
        <el-divider content-position="left">基本信息</el-divider>
        <el-form-item
          label="工单状态"
          prop="mesorderstus"
        >
          <el-select
            v-model="dialogForm.mesorderstus"
            disabled
            filterable
            :popper-append-to-body="false"
            style="width: 200px"
            placeholder="请选择"
          >
            <el-option
              v-for="item in erporderstusArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="工单编号" prop="mesordercode">
          <!--          <el-input v-model="dialogForm.mesordercode" :disabled="operation!=='add'" style="width: 200px" />-->
          <el-input v-model="dialogForm.mesordercode" disabled style="width: 200px" />
        </el-form-item>
        <!--        <div style="display: flex">-->
        <el-form-item label="工单类型" prop="mesorderstus">
          <el-select
            v-model="dialogForm.ordertype"
            :popper-append-to-body="false"
            style="width: 200px"
            :disabled="operation!=='add'"
            placeholder="请选择"
            @change="mesordertypeChange"
          >
            <el-option
              v-for="item in ordertypeArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
        <!--          <div style="display: flex;flex-wrap: nowrap">-->
        <el-form-item label="源单单号">
          <el-input
            v-model="dialogForm.sourceorder"
            :disabled="dialogForm.ordertype==='PO'"
            style="width: 200px"
          >
            <el-button
              slot="append"
              icon="el-icon-search"
              :disabled="operation!=='add'||dialogForm.ordertype==='PO'"
              @click="mesordertsourcesearchclick"
            />
          </el-input>
        </el-form-item>
        <!--            <el-button-->
        <!--              v-waves-->
        <!--              type="primary"-->
        <!--              style="padding: 0 10px;margin-left: -8px;margin-top: 3px"-->
        <!--              class="el-icon-search"-->
        <!--              :disabled="operation!=='add'||dialogForm.ordertype==='PO'"-->
        <!--              @click="mesordertsourcesearchclick"-->
        <!--            />-->
        <!--          </div>-->
        <!--        </div>-->
        <el-form-item label="工单数量" prop="mesqty">
          <el-input
            v-model="dialogForm.mesqty"
            oninput="value=value.replace(/[^\d]/g,'')"
            style="width: 200px"
          />
          <!--          oninput="value=value.replace(/[^0-9*.{1}0-9*]/g,'')"-->
        </el-form-item>
        <el-form-item label="所属车间" prop="wkshopcode">
          <el-select
            v-model="dialogForm.wkshopcode"
            filterable
            :popper-append-to-body="false"
            style="width: 200px;"
            placeholder="请选择车间"
          >
            <!--            @change="getMesOrderNewStepContent"-->
            <!--            @change="sourceType? getMesOrderNewStepContent():routecodeChange()"-->
            <el-option
              v-for="item in wkshopArr"
              :key="item.torg_code"
              :label="item.torg_name"
              :value="item.torg_code"
            />
          </el-select>
        </el-form-item>
        <el-form-item
          label="产品名称/编码"
          prop="partcode"
        >
          <el-select
            v-model="dialogForm.partcode"
            filterable
            :disabled="operation!=='add'"
            :popper-append-to-body="false"
            style="width: 200px"
            placeholder="请选择"
            @change="partcodeChangeDialog"
          >
            <el-option
              v-for="item in partArr"
              :key="item.partcode"
              :label="item.partname+'/'+item.partcode"
              :value="item.partcode"
            />
          </el-select>
        </el-form-item>
        <!--        <el-form-item v-if="operation!=='add'" label="产品名称" prop="partname">-->
        <!--          <el-input v-model="dialogForm.partname" disabled style="width: 200px" />-->
        <!--        </el-form-item>-->
        <!--        <el-form-item v-if="operation!=='add'" label="产品编码">-->
        <!--          <el-input v-model="dialogForm.partcode" disabled style="width: 200px" />-->
        <!--        </el-form-item>-->
        <el-form-item label="产品规格" prop="partspec">
          <el-input v-model="dialogForm.partspec" disabled style="width: 200px" />
        </el-form-item>
        <!--        :disabled="dialogForm.partcode===''"-->
        <el-form-item v-if="mesSetting.route" label="工艺路线" prop="wkshopcode">
          <el-select
            v-model="dialogForm.routecode"
            filterable
            :popper-append-to-body="false"
            style="width: 200px;"
            placeholder="请选择工艺路线"
            @change="sourceType? getMesOrderNewStepContent():routecodeChange()"
          >
            <el-option
              v-for="item in routecodeArr"
              :key="item.route_code"
              :label="item.route_name"
              :value="item.route_code"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="预计交付日期" prop="deliverydate">
          <el-date-picker
            v-model="dialogForm.deliverydate"
            type="date"
            size="mini"
            :clearable="false"
            class="dateMini"
            :picker-options="pickerOptions"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            placeholder="选择日期"
          />
          <!--          :disabled="dialogForm.deliverydate"-->
        </el-form-item>
        <el-form-item label="工序来源" required>
          <el-switch
            v-model="sourceType"
            style="width: 200px;"
            inactive-text="基础设置"
            active-text="历史最新"
            :disabled="!dialogForm.wkshopcode"
            @change="sourceTypeChange"
          />
        </el-form-item>
        <el-divider content-position="left">工序信息</el-divider>
        <div style="display: flex;align-items: center">
          <div style="font-weight: bolder">工序选择:</div>
          <el-select
            v-model="stepSelectedValue"
            class="stepSelectedValueClass"
            style="width: 930px;"
            multiple
            placeholder="请选择相对应工序"
            @change="stepSelectedValueChange"
          >
            <el-option
              v-for="item in stepSelectArr"
              :key="item.stepcode"
              :label="item.stepname"
              :value="item.stepcode"
            />
          </el-select>
          <!--          <el-drag-select-->
          <!--            v-model="stepSelectedValue"-->
          <!--            style="width:930px;"-->
          <!--            multiple-->
          <!--            placeholder="请选择相对应工序"-->
          <!--            @change="stepSelectedValueChange"-->
          <!--          >-->
          <!--            <el-option-->
          <!--              v-for="item in stepSelectArr"-->
          <!--              :key="item.stepcode"-->
          <!--              :label="item.stepname"-->
          <!--              :value="item.stepcode"-->
          <!--            />-->
          <!--          </el-drag-select>-->
        </div>
        <el-table
          ref="stepTableDataRef"
          :data="stepTableData"
          border
          :row-class-name="tableRowClassName"
          height="300"
          style="width: 100%;margin-top: 15px;"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
          row-key="stepcode"
        >
          <el-table-column
            type="index"
            label="序号"
            width="50"
          />
          <el-table-column
            prop="stepcode"
            show-tooltip-when-overflow
            label="工序编码"
          />
          <el-table-column
            prop="stepname"
            label="工序名称"
            show-tooltip-when-overflow
          />
          <el-table-column
            prop="stepprice"
            label="生产单价"
            show-tooltip-when-overflow
          >
            <template slot-scope="{row}">
              <el-input
                v-model="row.stepprice"
                placeholder="请输入工序单价"
                oninput="value=value.replace(/[^0-9.]/g,'')"
                style="width: 100%"
                @click=""
              />
            </template>
          </el-table-column>
          <el-table-column
            label="操作"
            width="120"
          >
            <template slot-scope="{row}">
              <div class="operationClass">
                <!--                <el-tooltip class="item" effect="dark" content="移动" placement="top">-->
                <i
                  class="el-icon-rank"
                  :style="{color:$store.state.settings.theme}"
                  style="cursor: move"
                />
                <!--                </el-tooltip>-->
                <!--                @click="edit('edit',row)"-->
                <el-tooltip v-del-tab-index class="item" effect="dark" content="删除" placement="top">
                  <i
                    class="el-icon-delete"
                    :style="{color:$store.state.settings.theme}"
                    style="margin-left: 15px;"
                    @click="stepDel(row)"
                  />
                </el-tooltip>
              </div>
            </template>
          </el-table-column>
        </el-table>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="dialogVisibleCancel">取 消</el-button>
          <!--          <el-button v-waves v-if="operation==='add'" type="primary" @click="dialogVisibleConfirmPreview('add')">预览</el-button>-->
          <el-button
            v-if="operation!=='view'&&(dialogForm.mesorderstus==='NEW'||dialogForm.mesorderstus==='ALLO')"
            v-waves
            type="primary"
            :loading="$store.state.app.buttonIsDisabled"
            :disabled="$store.state.app.buttonIsDisabled"
            @click="dialogVisibleConfirm"
          >确 定</el-button>
        </div>
      </span>
    </el-dialog>
    <!-- 工序任务对话框-->
    <el-dialog
      v-el-drag-dialog
      title="工序任务"
      :visible.sync="dialogVisibleTask"
      width="840px"
      top="15vh"
      class="dialogVisibleSearch"
      :close-on-click-modal="false"
      @close="dialogVisibleTaskClose"
    >
      <el-button
        v-waves
        style="margin-bottom: 15px"
        type="primary"
        @click="supplementClick"
      >补打
      </el-button>
      <el-table
        :data="taskTableData"
        border
        :row-class-name="tableRowClassName"
        height="300"
        style="width: 100%;"
        highlight-current-row
        :header-cell-style="this.$headerCellStyle"
        :cell-style="this.$cellStyle"
      >
        <el-table-column
          prop="seq"
          width="50"
          label="序号"
          fixed
        />
        <el-table-column
          prop="wo_code"
          show-tooltip-when-overflow
          label="工单编号"
          width="200"
        />
        <el-table-column
          prop="stepcode"
          label="工序编码"
          show-tooltip-when-overflow
        />
        <el-table-column
          prop="stepname"
          show-tooltip-when-overflow
          label="工序名称"
        />
        <!--        <el-table-column-->
        <!--          prop="flwtype"-->
        <!--          label="工序类型"-->
        <!--        >-->
        <!--          <template slot-scope="{row}">-->
        <!--            <div v-if="row.flwtype==='W'">外协</div>-->
        <!--            <div v-if="row.flwtype==='Z'">自制</div>-->
        <!--          </template>-->
        <!--        </el-table-column>-->
        <!--        <el-table-column-->
        <!--          prop="descr"-->
        <!--          label="工序描述"-->
        <!--        />-->
        <el-table-column
          prop="plan_qty"
          show-tooltip-when-overflow
          label="任务数量"
        />
        <el-table-column
          prop="good_qty"
          show-tooltip-when-overflow
          label="合格数量"
        />
        <el-table-column
          prop="ng_qty"
          show-tooltip-when-overflow
          label="不良数量"
        />
        <el-table-column
          label="操作"
          fixed="right"
        >
          <template slot-scope="{row}">
            <el-button v-waves type="text" style="padding: 0;" @click="supplementSmallClick(row)">补打</el-button>
          </template>
        </el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="dialogVisibleBack">返 回</el-button>
          <!--          <el-button v-waves type="primary" @click="dialogVisibleConfirm">确 定</el-button>-->
        </div>
      </span>
    </el-dialog>
    <!-- 源单单号对话框-->
    <el-dialog
      v-el-drag-dialog
      title="源单单号"
      :visible.sync="dialogVisibleSource"
      width="1200px"
      top="10vh"
      class="dialogVisibleSearch"
      :close-on-click-modal="false"
      @close="dialogVisibleSourceClose"
    >
      <div class="bodyTopFormGroup">
        <el-form
          ref="sourceForm"
          :model="sourceForm"
          label-width="100px"
          inline
          style="display: flex;justify-content: space-between"
        >
          <div class="elForm" style="justify-content: flex-start">
            <!--            <el-form-item-->
            <!--              label="预计开工时间"-->
            <!--              label-width="100px"-->
            <!--              style=" display: flex;font-size: 14px;margin-top: 3px"-->
            <!--            >-->
            <!--              <el-date-picker-->
            <!--                v-model="sourceForm.paystartdate"-->
            <!--                type="daterange"-->
            <!--                range-separator="~"-->
            <!--                class="timeMini"-->
            <!--                size="mini"-->
            <!--                style="width: 200px;display: flex;line-height: 34px;height: 34px;font-size: 14px!important;"-->
            <!--                :clearable="false"-->
            <!--                start-placeholder="开始日期"-->
            <!--                end-placeholder="结束日期"-->
            <!--              />-->
            <!--              &lt;!&ndash;              :picker-options="expireTimeOption"&ndash;&gt;-->
            <!--            </el-form-item>-->
            <!--            <el-form-item-->
            <!--              label="预计完工时间"-->
            <!--              label-width="100px"-->
            <!--              style=" display: flex;font-size: 14px;margin-top: 3px"-->
            <!--            >-->
            <!--              <el-date-picker-->
            <!--                v-model="sourceForm.payenddate"-->
            <!--                type="daterange"-->
            <!--                :clearable="false"-->
            <!--                class="timeMini"-->
            <!--                range-separator="~"-->
            <!--                start-placeholder="开始日期"-->
            <!--                style="width: 200px;display: flex;line-height: 34px ;height: 34px ;font-size: 14px !important;"-->
            <!--                end-placeholder="结束日期"-->
            <!--                size="mini"-->
            <!--              />-->
            <!--            </el-form-item>-->
            <!--            <el-form-item label="工单状态" style=" display: flex;">-->
            <!--              <el-select-->
            <!--                v-model="sourceForm.mesordercode"-->
            <!--                filterable-->
            <!--                :popper-append-to-body="false"-->
            <!--                style="width: 200px"-->
            <!--                placeholder="请选择"-->
            <!--              >-->
            <!--                <el-option-->
            <!--                  v-for="item in erporderstusArr"-->
            <!--                  :key="item.code"-->
            <!--                  :label="item.name"-->
            <!--                  :value="item.code"-->
            <!--                />-->
            <!--              </el-select>-->
            <!--            </el-form-item>-->
            <el-form-item label="车间名称" style=" display: flex;">
              <el-select
                v-model="sourceForm.wkshopcode"
                filterable
                :popper-append-to-body="false"
                style="width: 200px"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in wkshopcodeArr"
                  :key="item.torg_code"
                  :label="item.torg_name"
                  :value="item.torg_code"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="工单编号" style=" display: flex;">
              <el-input v-model="sourceForm.mesordercode" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="产品编码" style=" display: flex;">
              <el-input v-model="sourceForm.partcode" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <el-form-item v-show="isExpandDialog" label="产品名称" style=" display: flex;">
              <el-input v-model="sourceForm.partname" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <!--            <el-form-item v-show="isExpandDialog" label="产品规格" style=" display: flex;">-->
            <!--              <el-input v-model="sourceForm.partspec" style="width: 200px" placeholder="请输入" />-->
            <!--            </el-form-item>-->
            <el-form-item v-show="isExpandDialog" label="创建人员" style=" display: flex;">
              <el-input v-model="sourceForm.creatuser" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <el-form-item
              v-show="isExpandDialog"
              label="创建时间"
              label-width="100px"
              style=" display: flex;font-size: 14px;margin-top: 3px"
            >
              <el-date-picker
                v-model="sourceForm.createdate"
                type="daterange"
                range-separator="~"
                class="timeMini"
                size="mini"
                style="width: 200px;display: flex;line-height: 34px;height: 34px;font-size: 14px!important;"
                :clearable="false"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              />
              <!--              :picker-options="expireTimeOption"-->
            </el-form-item>
          </div>
          <div style="display: flex;align-items: start;margin-top: 3px;z-index: 2;justify-content: end">
            <el-button v-waves type="primary" icon="el-icon-search" @click="sourceSearch">查询</el-button>
            <el-button v-waves type="info" icon="el-icon-refresh" @click="sourceReset">重置</el-button>
          </div>
        </el-form>
        <div
          class="bodyTopFormExpand"
        >
          <svg-icon
            v-show="mouseHoverTypeDialog==='mouseout'"
            style="cursor: pointer"
            :icon-class="!isExpandDialog?'doubleDown3':'doubleUp3'"
            @mouseenter="mouseHoverTypeDialog=$event.type"
          />
          <svg-icon
            v-show="mouseHoverTypeDialog==='mouseenter'"
            style="cursor: pointer"
            :icon-class="!isExpandDialog?'doubleDown':'doubleUp'"
            @click="isExpandDialog=!isExpandDialog"
            @mouseout="mouseHoverTypeDialog=$event.type"
          />
        </div>
      </div>
      <div class="elTableDiv">
        <el-table
          :data="sourceTableData"
          :height="isExpandDialog?(tableHeight+100)+'px':(tableHeight+140)+'px'"
          border
          :row-class-name="tableRowClassName"
          :style="{width: 100+'%',height:isExpandDialog?(tableHeight+100)+'px':(tableHeight+140)+'px',}"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
          @sort-change="sourceSortChange"
          @row-click="getCurrentRowSource"
        >
          <!--          <el-table-column-->
          <!--            type="selection"-->
          <!--            width="50"-->
          <!--          />-->
          <el-table-column
            width="50"
            fixed
          >
            <template slot-scope="{row}">
              <el-radio
                v-model="radioSelectedId"
                :label="row.id"
                style="color: transparent;padding-left: 10px;"
              />
              <!--              @change.native="getCurrentRowSource(row.id)"-->
            </template>
          </el-table-column>
          <el-table-column
            prop="rowNum"
            width="50"
            fixed
            label="序号"
          />
          <!--          <el-table-column-->
          <!--            prop="status"-->
          <!--            label="工单状态"-->
          <!--            show-tooltip-when-overflow-->
          <!--            sortable="custom"-->
          <!--            width="110"-->
          <!--          >-->
          <!--            <template slot-scope="{row}">-->
          <!--              <div v-if="row.status==='NEW'">新订单</div>-->
          <!--              <div v-if="row.status==='CREATING'">部分下达</div>-->
          <!--              <div v-if="row.status==='CREATED'">全部下达</div>-->
          <!--              <div v-if="row.status==='CLOSED'">已关闭</div>-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <el-table-column
            label="工单编号"
            prop="wo_code"
            show-tooltip-when-overflow
            min-width="150"
            sortable="custom"
          >
            <!--            <template slot-scope="{row}">-->
            <!--              <div v-if="row.m_po">{{ row.m_po }}</div>-->
            <!--              <div v-else>{{ row.wo_code }}</div>-->
            <!--            </template>-->
          </el-table-column>
          <el-table-column
            prop="partcode"
            label="产品编码"
            sortable="custom"
            show-tooltip-when-overflow
            min-width="150"
          />
          <el-table-column
            prop="partname"
            label="产品名称"
            sortable="custom"
            show-tooltip-when-overflow
            min-width="150"
          />
          <el-table-column
            prop="partspec"
            label="产品规格"
            show-tooltip-when-overflow
            sortable="custom"
            min-width="110"
          >
            <template slot-scope="{row}">
              <div v-if="row.partspec">{{ row.partspec }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="plan_qty"
            label="任务数量"
            width="150"
            show-tooltip-when-overflow
            sortable="custom"
          />
          <el-table-column
            prop="laborbad_qty"
            label="工废数量"
            width="150"
            show-tooltip-when-overflow
            sortable="custom"
          />
          <el-table-column
            prop="materielbad_qty"
            label="料废数量"
            width="150"
            show-tooltip-when-overflow
            sortable="custom"
          />
          <!--          <el-table-column-->
          <!--            prop="relse_qty"-->
          <!--            show-tooltip-when-overflow-->
          <!--            label="已下单数量"-->
          <!--            width="150"-->
          <!--            sortable="custom"-->
          <!--          />-->
          <el-table-column
            prop="wkshp_name"
            label="生产车间"
            show-tooltip-when-overflow
            sortable="custom"
            width="150"
          >
            <template slot-scope="{row}">
              <div v-if="row.wkshp_name">{{ row.wkshp_name }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <!--          <el-table-column-->
          <!--            prop="plan_startdate"-->
          <!--            label="预计开工时间"-->
          <!--            show-tooltip-when-overflow-->
          <!--            sortable="custom"-->
          <!--            width="130"-->
          <!--          >-->
          <!--            <template slot-scope="{row}">-->
          <!--              <div v-if="row.plan_startdate">{{ row.plan_startdate.substring(0, 11) }}</div>-->
          <!--              <div v-else>/</div>-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <!--          <el-table-column-->
          <!--            prop="plan_enddate"-->
          <!--            label="预计完工时间"-->
          <!--            show-tooltip-when-overflow-->
          <!--            sortable="custom"-->
          <!--            width="130"-->
          <!--          >-->
          <!--            <template slot-scope="{row}">-->
          <!--              <div v-if="row.plan_enddate">{{ row.plan_enddate.substring(0, 11) }}</div>-->
          <!--              <div v-else>/</div>-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <el-table-column
            prop="lm_user"
            label="创建人员"
            show-tooltip-when-overflow
            sortable="custom"
            width="150"
          >
            <template slot-scope="{row}">
              <div v-if="row.lm_user">{{ row.lm_user }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="lm_date"
            label="创建时间"
            show-tooltip-when-overflow
            width="130"
            sortable="custom"
          >
            <template slot-scope="{row}">
              <div v-if="row.lm_date">{{ row.lm_date.substring(0, 11) }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <!--          <el-table-column-->
          <!--            label="操作"-->
          <!--            fixed="right"-->
          <!--            width="80"-->
          <!--          >-->
          <!--            <template slot-scope="{row}">-->
          <!--              <div class="operationClass">-->
          <!--                <el-tooltip class="item" effect="dark" content="下达" placement="top">-->
          <!--                  &lt;!&ndash;                <el-button v-waves type="text" @click="edit('edit',row)">下达</el-button>&ndash;&gt;-->
          <!--                  <i-->
          <!--                    class="el-icon-bottom"-->
          <!--                    style="color:#42b983;cursor: pointer;margin-left: 5px"-->
          <!--                    @click="edit('edit',row)"-->
          <!--                  />-->
          <!--                </el-tooltip>-->
          <!--              </div>-->
          <!--            </template>-->
          <!--          </el-table-column>-->
        </el-table>
      </div>
      <!--分页-->
      <pagination
        :total="sourceFormTotal"
        :page.sync="sourceForm.page"
        :limit.sync="sourceForm.rows"
        align="right"
        layout="total,prev, pager, next,sizes"
        popper-class="select_bottom"
        @pagination="getMesBadOrderSearch"
      />
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="dialogVisibleSourceBack">返 回</el-button>
          <el-button v-waves type="primary" @click="dialogVisibleSourceConfirm">确 定</el-button>
        </div>
      </span>
    </el-dialog>
    <!--打印预览对话框  大标签-->
    <el-dialog
      v-el-drag-dialog
      title=""
      top="7vh"
      :visible.sync="dialogVisibleApprove"
      width="812px"
      class="dialogVisibleConfirmClass"
      append-to-body
      :close-on-click-modal="false"
      @close="dialogVisibleConfirmClose"
    >
      <!-- 要打印的区域 -->
      <div id="printMe" style="padding: 30px">
        <!--        <div v-for="(item,index) in tableDataPrint" :key="index">-->
        <div>
          <div style="font-size: 32px; text-align: center;font-weight:bolder;">流程单</div>
          <div style="display: flex;justify-content: space-around;margin-top: 20px; position: relative;">
            <div style="width: 200%">
              <el-form
                ref="formApprove"
                :model="formApprove"
                label-width="100px"
                inline
                style="display: flex;justify-content: space-between"
              >
                <div class="elForm">
                  <el-form-item label="销售单号:" class="formContent">
                    {{ formApprove.saleOrderCode ? formApprove.saleOrderCode : '/' }}
                  </el-form-item>
                  <el-form-item label="工单编号:" class="formContent">
                    {{ formApprove.mesordercode }}
                  </el-form-item>
                  <el-form-item label="源单单号:" class="formContent">
                    {{ formApprove.m_po }}
                  </el-form-item>
                  <el-form-item label="产品编码:" class="formContent">
                    {{ formApprove.partcode }}
                  </el-form-item>
                  <el-form-item label="产品名称:" class="formContent">
                    {{ formApprove.partname }}
                  </el-form-item>
                  <el-form-item label="产品规格:" class="formContent">
                    {{ formApprove.partspec }}
                  </el-form-item>
                  <el-form-item label="工单数量:" class="formContent">
                    {{ formApprove.plan_qty }}
                  </el-form-item>
                  <el-form-item label="客户名称:" class="formContent">
                    {{ formApprove.priuserdefnvc1 }}
                  </el-form-item>
                  <el-form-item label="客户编码:" class="formContent">
                    {{ formApprove.priuserdefnvc6 }}
                  </el-form-item>
                  <el-form-item label="对内名称:" class="formContent">
                    {{ formApprove.priuserdefnvc2 }}
                  </el-form-item>
                  <el-form-item label="CTP日期:" class="formContent">
                    {{ formApprove.priuserdefnvc3 }}
                  </el-form-item>
                  <el-form-item label="钢刀编号:" class="formContent">
                    {{ formApprove.priuserdefnvc4 }}
                  </el-form-item>
                  <el-form-item label="盒型:" class="formContent">
                    {{ formApprove.priuserdefnvc5 }}
                  </el-form-item>
                  <!--                <el-form-item label="工艺路线:" class="formContent">-->
                  <!--                  {{ formApprove.routename }}-->
                  <!--                </el-form-item>-->
                  <el-form-item label="打印人员:" class="formContent">
                    <!--                  {{ localStorage.getItem('username') }}-->
                    {{ formApprove.routename }}
                  </el-form-item>
                  <el-form-item label="打印时间:" class="formContent">
                    {{ formApprove.lm_date }}
                  </el-form-item>
                </div>
              </el-form>
            </div>
            <!--            <div-->
            <!--              id="qrCode0"-->
            <!--              style="width: 22%;height:90px;-->
            <!--                        margin-top: 20px;-->
            <!--                        overflow-y: scroll;display: flex;-->
            <!--                        justify-content: center;-->
            <!--                        position: relative;"-->
            <!--            >-->
            <!--              <div id="qrCode00" ref="qrCodeDiv00" />-->
            <!--            </div>-->
            <!--            <div style="background-color: #fff;width: 20px;height:120px; position: absolute;right: 0" />-->
            <!--            <div-->
            <!--              style="z-index: 10;background-color:transparent;width: 120px;height:120px; position: absolute;right: 21px"-->
            <!--            />-->
          </div>
          <el-table
            id="table"
            :data="tableDataPrint[0]"
            border
            class="tableDataPrint"
            :header-cell-style="{ background: '#c0c0c0',textAlign:'center',color:'#000',borderColor:'#000',fontSize:'18px'}"
            :cell-style="{textAlign: 'center',color:'#000',borderColor:'#000',fontSize:'18px'}"
            style="width: 100%;margin-top: 20px;text-align: center;border-color: #000"
          >
            <el-table-column
              id="column0"
              prop="seq"
              label="序号"
              width="70"
              align="center"
            />
            <el-table-column
              id="column1"
              prop="stepqrcode"
              label="二维码"
              width="100"
              align="center"
            >
              <template slot-scope="{row}">
                <div :id="'qrCode'+row.seq" :ref="'qrCodeDiv'+row.seq" :key="'qrCodeDiv'+row.seq" class="tableColumn" />
              </template>
            </el-table-column>
            <el-table-column
              id="column2"
              prop="stepname"
              label="工序"
              width="120"
              align="center"
            />
            <el-table-column
              id="column3"
              prop="plan_qty"
              label="加工数量"
              width="100"
              align="center"
            />
            <el-table-column
              id="column4"
              prop="good_qty"
              width="100"
              align="center"
              label="合格数量"
            />
            <el-table-column
              id="column5"
              width="100"
              prop="ng_qty"
              align="center"
              label="不良数量"
            />
            <el-table-column
              id="column6"
              prop="desc"
              align="center"
              width="120"
              label="备注"
            />
          </el-table>
        </div>
        <div v-if="tableDataPrint[1]" style="margin-top: 100px;">
          <div style="font-size: 26px; text-align: center">流程单</div>
          <div style="display: flex;justify-content: space-around;margin-top: 20px; position: relative;">
            <div style="width: 200%">
              <el-form
                ref="formApprove"
                :model="formApprove"
                label-width="100px"
                inline
                style="display: flex;justify-content: space-between"
              >
                <div class="elForm">
                  <el-form-item label="销售单号:" class="formContent">
                    {{ formApprove.saleOrderCode ? formApprove.saleOrderCode : '/' }}
                  </el-form-item>
                  <el-form-item label="工单编号:" class="formContent">
                    {{ formApprove.mesordercode }}
                  </el-form-item>
                  <el-form-item label="源单单号:" class="formContent">
                    {{ formApprove.m_po }}
                  </el-form-item>
                  <el-form-item label="产品编码:" class="formContent">
                    {{ formApprove.partcode }}
                  </el-form-item>
                  <el-form-item label="产品名称:" class="formContent">
                    {{ formApprove.partname }}
                  </el-form-item>
                  <el-form-item label="产品规格:" class="formContent">
                    {{ formApprove.partspec }}
                  </el-form-item>
                  <el-form-item label="工单数量:" class="formContent">
                    {{ formApprove.plan_qty }}
                  </el-form-item>
                  <!--                <el-form-item label="工艺路线:" class="formContent">-->
                  <!--                  {{ formApprove.routename }}-->
                  <!--                </el-form-item>-->
                  <el-form-item label="打印人员:" class="formContent">
                    <!--                  {{ localStorage.getItem('username') }}-->
                    {{ formApprove.routename }}
                  </el-form-item>
                  <el-form-item label="打印时间:" class="formContent">
                    {{ formApprove.lm_date }}
                  </el-form-item>
                </div>
              </el-form>
            </div>
            <!--            <div-->
            <!--              id="qrCode1"-->
            <!--              style="width: 22%;height:90px;-->
            <!--                        margin-top: 20px;-->
            <!--                        overflow-y: scroll;display: flex;-->
            <!--                        justify-content: center;-->
            <!--                        position: relative;"-->
            <!--            >-->
            <!--              <div id="qrCode01" ref="qrCodeDiv01" />-->
            <!--            </div>-->
            <!--            <div style="background-color: #fff;width: 20px;height:120px; position: absolute;right: 0" />-->
            <!--            <div-->
            <!--              style="z-index: 10;background-color:transparent;width: 120px;height:120px; position: absolute;right: 21px"-->
            <!--            />-->
          </div>
          <el-table
            id="table"
            :data="tableDataPrint[1]"
            border
            class="tableDataPrint"
            :header-cell-style="{ background: '#c0c0c0',textAlign:'center',color:'#000',borderColor:'#000',fontSize:'18px'}"
            :cell-style="{textAlign: 'center',color:'#000',borderColor:'#000',fontSize:'18px'}"
            style="width: 100%;margin-top: 20px;text-align: center;border-color: #000"
          >
            <el-table-column
              id="column0"
              prop="seq"
              label="序号"
              width="70"
              align="center"
            />
            <el-table-column
              id="column1"
              prop="stepqrcode"
              label="二维码"
              width="100"
              align="center"
            >
              <template slot-scope="{row}">
                <div :id="'qrCode'+row.seq" :ref="'qrCodeDiv'+row.seq" :key="'qrCodeDiv'+row.seq" class="tableColumn" />
              </template>
            </el-table-column>
            <el-table-column
              id="column2"
              prop="stepname"
              label="工序"
              width="120"
              align="center"
            />
            <el-table-column
              id="column3"
              prop="plan_qty"
              label="加工数量"
              width="100"
              align="center"
            />
            <el-table-column
              id="column4"
              prop="good_qty"
              width="100"
              align="center"
              label="合格数量"
            />
            <el-table-column
              id="column5"
              width="100"
              prop="ng_qty"
              align="center"
              label="不良数量"
            />
            <el-table-column
              id="column6"
              prop="desc"
              align="center"
              width="120"
              label="备注"
            />
          </el-table>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="dialogVisibleBackPreview">返 回</el-button>
          <!--            <el-button v-waves v-if="operation==='add'" type="primary" @click="dialogVisibleConfirm">确 定</el-button>-->
          <!--            <el-button v-waves type="primary" @click="dialogVisibleConfirm">确 定/打 印</el-button>-->
          <el-button v-waves v-print="printObj" type="primary" @click="printObjGetApi">打 印</el-button>
        </div>
      </span>
    </el-dialog>
    <!--打印预览页面  小标签-->
    <el-dialog
      v-el-drag-dialog
      title="预览"
      :visible.sync="dialogVisible2"
      width="1000"
      top="10vh"
      :close-on-click-modal="false"
      @close="dialogVisible2Close"
    >
      <div style="height: 650px;overflow:auto;">
        <!--      下拉框选择打印尺寸-->
        <div v-if="!isLastPrint" style="display: flex;align-items: center;margin: 0 0 20px 0">
          <div>选择打印尺寸:</div>
          <el-select
            v-model="printSize"
            :popper-append-to-body="false"
            style="width: 200px"
            placeholder="请选择"
            @change="printSizeChange"
          >
            <el-option
              v-for="item in printSizeSelectArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </div>
        <!-- 要打印的区域 -->
        <!--      <div id="printMe2" :style="{paddingLeft:'10px',paddingTop: '5px'}">-->
        <div v-if="!isLastPrint" :style="printMe2StylePadding(printSize)">
          <!--      80 * 50-->
          <div
            v-if="printSize===0"
            style="display: flex;width: 280px;height: 160px;border: 1px solid #000;text-align: center;font-size: 10px;"
          >
            <div style="width: 90px;display: flex;flex-direction: column;border-right: 1px solid #000">
              <div
                style="display: flex;height: 96px;border-bottom:1px solid #000;
              justify-content: center;align-items: center;position: relative"
              >
                <div
                  id="qrCode2"
                  ref="qrCodeDiv2"
                  style="overflow-y: hidden;height:60px;position: absolute;left: 14px;"
                />
              </div>
              <div
                style="display: flex;height: 32px;justify-content: flex-start;border-bottom:1px solid #000;align-items: center"
              >
                <div style="margin-left: 5px;width: 28px">数量:</div>
                {{ qrForm.startqty }}
              </div>
              <div style="display: flex;height: 32px;justify-content: flex-start;align-items: center">
                <div style="margin-left: 5px;width: 42px">处理人:</div>
                {{ qrForm.operator }}
              </div>
            </div>
            <div style="width:190px;display: flex;flex-direction: column">
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center;text-align: left"
              >
                <div style="width: 60px;margin-left: 5px;">工单编号:</div>
                <div>{{ qrForm.wo_code }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center ;text-align: left"
              >
                <div style="width: 60px;margin-left: 5px;">产品编码:</div>
                <div>{{ qrForm.partcode }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
              >
                <div style="width:60px;margin-left: 5px;">产品名称:</div>
                <div>{{ qrForm.partname }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
              >
                <div style="width:60px;margin-left: 5px;">下道工序:</div>
                <div>{{ qrForm.nextstepname }}</div>
              </div>
              <div style="display: flex;height: 20%;justify-content: flex-start;align-items: center;text-align: left">
                <div style="width: 60px;margin-left: 5px;">处理时间:</div>
                <div>{{ qrForm.operatorTime }}</div>
              </div>
            </div>
          </div>
          <!--      78 * 60    -->
          <div
            v-if="printSize===1"
            style="display: flex;width: 280px;height: 160px;border: 1px solid #000;text-align: center;font-size: 10px;"
          >
            <div style="width: 90px;display: flex;flex-direction: column;border-right: 1px solid #000">
              <div
                style="display: flex;height: 96px;border-bottom:1px solid #000;
              justify-content: center;align-items: center;position: relative"
              >
                <div
                  id="qrCode2"
                  ref="qrCodeDiv2"
                  style="overflow-y: hidden;height:60px;position: absolute;left: 14px;"
                />
              </div>
              <div
                style="display: flex;height: 32px;justify-content: flex-start;border-bottom:1px solid #000;align-items: center"
              >
                <div style="margin-left: 5px;width: 28px">数量:</div>
                {{ qrForm.startqty }}
              </div>
              <div style="display: flex;height: 32px;justify-content: flex-start;align-items: center">
                <div style="margin-left: 5px;width: 42px">处理人:</div>
                {{ qrForm.operator }}
              </div>
            </div>
            <div style="width:190px;display: flex;flex-direction: column">
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center;text-align: left"
              >
                <div style="width: 60px;margin-left: 5px;">工单编号:</div>
                <div>{{ qrForm.wo_code }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center ;text-align: left"
              >
                <div style="width: 60px;margin-left: 5px;">产品编码:</div>
                <div>{{ qrForm.partcode }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
              >
                <div style="width:60px;margin-left: 5px;">产品名称:</div>
                <div>{{ qrForm.partname }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
              >
                <div style="width:60px;margin-left: 5px;">下道工序:</div>
                <div>{{ qrForm.nextstepname }}</div>
              </div>
              <div style="display: flex;height: 20%;justify-content: flex-start;align-items: center;text-align: left">
                <div style="width: 60px;margin-left: 5px;">处理时间:</div>
                <div>{{ qrForm.operatorTime }}</div>
              </div>
            </div>
          </div>
          <!--      60 * 40    -->
          <div
            v-if="printSize===2"
            style="display: flex;width: 220px;height: 130px;border: 1px solid #000;text-align: center;font-size: 12px"
          >
            <div style="width: 70px;display: flex;flex-direction: column;border-right: 1px solid #000">
              <div
                style="display: flex;height: 60%;border-bottom:1px solid #000;
              justify-content: center;align-items: center;position: relative"
              >
                <div
                  id="qrCode2"
                  ref="qrCodeDiv2"
                  style="overflow-y: hidden;height:71%;position: absolute;left: 7px;"
                />
              </div>
              <div
                style="display: flex;height:  20%;justify-content: flex-start;border-bottom:1px solid #000;align-items: center"
              >
                <div style="margin-left: 3px; ">数量:{{ qrForm.startqty }}</div>
              </div>
              <div style="display: flex;height:  20%;justify-content: flex-start;align-items: center;">
                <div style="margin-left: 3px; ">操作:{{ qrForm.operator }}</div>
              </div>
            </div>
            <div style="width:150px;display: flex;flex-direction: column">
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center;text-align: left"
              >
                <div style="margin-left: 3px;">编号:{{ qrForm.wo_code }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center ;text-align: left"
              >
                <div style="margin-left: 3px;">产品编码:{{ qrForm.partcode }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
              >
                <div style="margin-left: 3px;">产品名称:{{ qrForm.partname }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
              >
                <div style="margin-left: 3px;">下道工序:{{ qrForm.nextstepname }}</div>
              </div>
              <div style="display: flex;height: 20%;justify-content: flex-start;align-items: center;text-align: left">
                <div style=" margin-left: 3px;">时间: {{ qrForm.operatorTime }}</div>
                <!--                <div>{{ qrForm.operatorTime?qrForm.operatorTime.substring(5):'' }}</div>-->
                <!--                <div>{{ qrForm.operatorTime }}</div>-->
              </div>
            </div>
          </div>
          <div
            v-if="printSize===5"
            style="display: flex;width: 140px;height: 80px;border: 1px solid #000;text-align: center;font-size: 10px;"
          >
            <div v-if="false" style="width: 45px;display: flex;flex-direction: column;border-right: 1px solid #000">
              <div
                style="display: flex;height: 60px;border-bottom:1px solid #000;
              justify-content: center;align-items: center;position: relative"
              >
                <div
                  id="qrCode2"
                  ref="qrCodeDiv2"
                  style="overflow-y: hidden;height:60px;position: absolute;left: 14px;"
                />
              </div>
              <div
                style="display: flex;height: 20px;justify-content: flex-start;border-bottom:1px solid #000;align-items: center"
              >
                <div style="margin-left: 5px;width: 28px">数量:</div>
                {{ qrForm.startqty }}
              </div>
              <div style="display: flex;height: 20px;justify-content: flex-start;align-items: center">
                <div style="margin-left: 5px;width: 42px">处理人:</div>
                {{ qrForm.operator }}
              </div>
            </div>
            <div style="width:100%;display: flex;flex-direction: column;">
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: center;align-items: center;text-align: left"
              >
                <!--              <div style="width: 60px;margin-left: 5px;">工单编号:</div>-->
                <div>{{ qrForm.wo_code }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: center;align-items: center ;text-align: left"
              >
                <!--              <div style="width: 60px;margin-left: 5px;">产品编码:</div>-->
                <div>{{ qrForm.partcode }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: center;align-items: center;text-align: left"
              >
                <!--              <div style="width:60px;margin-left: 5px;">产品名称:</div>-->
                <div>{{ qrForm.partname }}</div>
              </div>
              <div
                style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: center;align-items: center;text-align: left"
              >
                <!--              <div style="width:60px;margin-left: 5px;">下道工序:</div>-->
                <div>{{ qrForm.nextstepname }}</div>
              </div>
              <div style="display: flex;height: 20%;justify-content: center;align-items: center;text-align: left">
                <!--              <div style="width: 60px;margin-left: 5px;">处理时间:</div>-->
                <div>{{ qrForm.operatorTime }}</div>
              </div>
            </div>
          </div>
        </div>
        <div v-if="isLastPrint" style="display: flex;flex-direction: column">
          <div style="display: flex;font-weight: bold;font-size: 16px;margin-bottom: 20px;">
            <div style="width: 48%;">
              请选择入库条码
            </div>
            <div style="width: 48%;margin-left: 4%;">
              已选中的入库条码
            </div>
          </div>
          <div style="display: flex;">
            <!--          请选择入库条码-->
            <div style="display: flex;flex-direction: column;height: 600px;overflow: auto;width: 48%;">
              <div
                v-for="(item,index) in lastPrintArr"
                :key="item.inbarcode"
                :style="{marginTop:index===0?'':'15px'}"
                style="display: flex;align-items: center;"
              >
                <!--          v-if="printSize===0"-->
                <div style="margin-right:40px">
                  <el-checkbox
                    :key="item.inbarcode"
                    v-model="item.checked"
                    @change="val=>inbarcodeChange(val,item)"
                  />
                </div>
                <div
                  style="display: flex;width: 280px;height: 160px;border: 1px solid #000;text-align: center;font-size: 10px;"
                >
                  <div style="width: 90px;display: flex;flex-direction: column;border-right: 1px solid #000">
                    <div
                      style="display: flex;height: 96px;border-bottom:1px solid #000;
                      justify-content: center;align-items: center;position: relative"
                    >
                      <div
                        id="qrCode2"
                        ref="qrCodeDiv2"
                        style="overflow-y: hidden;height:60px;position: absolute;left: 14px;"
                      />
                    </div>
                    <div
                      style="display: flex;height: 32px;justify-content: flex-start;border-bottom:1px solid #000;align-items: center"
                    >
                      <div style="margin-left: 5px;width: 28px">数量:</div>
                      {{ item.good_qty }}
                    </div>
                    <div style="display: flex;height: 32px;justify-content: flex-start;align-items: center">
                      <div style="margin-left: 5px;width: 42px">处理人:</div>
                      {{ item.username }}
                    </div>
                  </div>
                  <div style="width:190px;display: flex;flex-direction: column">
                    <div
                      style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center;text-align: left"
                    >
                      <div style="width: 60px;margin-left: 5px;">工单编号:</div>
                      <div>{{ item.wo_code }}</div>
                    </div>
                    <div
                      style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center ;text-align: left"
                    >
                      <div style="width: 60px;margin-left: 5px;">产品编码:</div>
                      <div>{{ item.partcode }}</div>
                    </div>
                    <div
                      style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
                    >
                      <div style="width:60px;margin-left: 5px;">产品名称:</div>
                      <div>{{ item.partname }}</div>
                    </div>
                    <div
                      style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
                    >
                      <div style="width:60px;margin-left: 5px;">产品规格:</div>
                      <div>{{ item.partspec ? item.partspec : '/' }}</div>
                    </div>
                    <div
                      style="display: flex;height: 20%;justify-content: flex-start;align-items: center;text-align: left"
                    >
                      <div style="width: 60px;margin-left: 5px;">处理时间:</div>
                      <div>{{ item.lm_date }}</div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <!--          已选中的入库条码-->
            <div
              style="display: flex;flex-direction: column;height: 600px;overflow: auto;width: 48%;margin-left: 50px;"
            >
              <div id="printMe2">
                <div
                  v-for="(item,index) in lastPrintArrSelected"
                  v-if="item.checked"
                  :key="item.inbarcode"
                  :style="{marginTop:index===0?'':'15px'}"
                  style="display: flex;align-items: center;"
                >
                  <div
                    style="display: flex;width: 280px;height: 160px;border: 1px solid #000;text-align: center;font-size: 10px;"
                  >
                    <div style="width: 90px;display: flex;flex-direction: column;border-right: 1px solid #000">
                      <div
                        style="display: flex;height: 96px;border-bottom:1px solid #000;
                        justify-content: center;align-items: center;position: relative"
                      >
                        <div
                          id="qrCode3"
                          ref="qrCodeDiv3"
                          style="overflow-y: hidden;height:60px;position: absolute;left: 14px;"
                        />
                      </div>
                      <div
                        style="display: flex;height: 32px;justify-content: flex-start;border-bottom:1px solid #000;align-items: center"
                      >
                        <div style="margin-left: 5px;width: 28px">数量:</div>
                        {{ item.good_qty }}
                      </div>
                      <div style="display: flex;height: 32px;justify-content: flex-start;align-items: center">
                        <div style="margin-left: 5px;width: 42px">处理人:</div>
                        {{ item.username }}
                      </div>
                    </div>
                    <div style="width:190px;display: flex;flex-direction: column">
                      <div
                        style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center;text-align: left"
                      >
                        <div style="width: 60px;margin-left: 5px;">工单编号:</div>
                        <div>{{ item.wo_code }}</div>
                      </div>
                      <div
                        style="display: flex;height: 20%;border-bottom:1px solid #000;justify-content: flex-start;align-items: center ;text-align: left"
                      >
                        <div style="width: 60px;margin-left: 5px;">产品编码:</div>
                        <div>{{ item.partcode }}</div>
                      </div>
                      <div
                        style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
                      >
                        <div style="width:60px;margin-left: 5px;">产品名称:</div>
                        <div>{{ item.partname }}</div>
                      </div>
                      <div
                        style="display: flex;height: 20%;border-bottom:1px solid #000 ;justify-content: flex-start;align-items: center;text-align: left"
                      >
                        <div style="width:60px;margin-left: 5px;">产品规格:</div>
                        <div>{{ item.partspec ? item.partspec : '/' }}</div>
                      </div>
                      <div
                        style="display: flex;height: 20%;justify-content: flex-start;align-items: center;text-align: left"
                      >
                        <div style="width: 60px;margin-left: 5px;">处理时间:</div>
                        <div>{{ item.lm_date }}</div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="dialogVisible2 = false;">取 消</el-button>
          <el-button v-waves v-print="printObj2" type="primary">打 印</el-button>
        </div>
      </span>
    </el-dialog>
    <!--    工艺路线对话框-->
    <el-dialog
      v-el-drag-dialog
      :close-on-click-modal="false"
      title="关联工艺路线"
      :visible.sync="dialogVisibleRoute"
      width="800px"
      top="10vh"
      :fullscreen="isIpad"
      class="dialogVisibleRoute"
      @closed="handleCloseRoute"
      @close="handleCloseRoute"
    >
      <div>
        <i class="el-icon-s-comment" style="color:#42b983;" /> 产品名称:{{ dialogFormRoute.projectName }}
      </div>
      <el-divider />
      <div style="margin-bottom: 10px">
        <i class="el-icon-s-operation" style="color:#42b983;" /> 工艺路线集合
      </div>
      <div class="myCheckboxGroup">
        <div
          v-for="item in dialogFormRoute.routeOperationArr"
          :key="item.code"
          :style="{border:item.isSelected1?'1px solid #42b983':'1px solid #eee'}"
          class="myCheckbox"
          @click="myCheckboxClick(item)"
        >
          <input
            class="myCheckboxInput"
            type="checkbox"
            :value="item.code"
            :name="item.name"
            :style="{color:item.isSelected2?'#42b983':'#fff'}"
            @click="myCheckboxInputClick(item)"
          >{{ item.name }}
          <!--            父子点击事件不影响-->
          <!--            onClick="event.cancelBubble = true"-->
        </div>
      </div>
      <el-divider />
      <div>
        <i class="el-icon-s-operation" style="color:#42b983;" /> 默认工艺路线
      </div>
      <div style="margin-top: 20px">
        <el-select
          v-model="defaultroute_code"
          filterable
          style="width: 200px;"
          placeholder="请选择"
          class="defaultroute_code"
        >
          <el-option
            v-for="item in defaultroute_codeArr"
            :key="item.code"
            :label="item.name"
            :value="item.code"
          />
        </el-select>
      </div>
      <el-divider />
      <div style="margin-bottom: 10px">
        <i class="el-icon-s-operation" style="color:#42b983;" /> 工序列表
      </div>
      <div style="overflow-y: scroll">
        <el-table
          ref="projectTableData"
          :data="projectTableData"
          border
          height="280"
          :row-class-name="tableRowClassName"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
        >
          <el-table-column
            prop="seq"
            width="100"
            label="工序序号"
            fixed
          />
          <el-table-column
            prop="stepcode"
            label="工序编码"
            show-tooltip-when-overflow
          />
          <el-table-column
            prop="stepname"
            label="工序名称"
            show-tooltip-when-overflow
          />
          <el-table-column
            prop="enable"
            label="启用状态"
            fixed="right"
          >
            <template slot-scope="{row}">
              <div v-if="row.enable==='Y'">
                <svg-icon icon-class="circleYes" style="margin-right: 2px" />
                是
              </div>
              <div v-if="row.enable==='N'">
                <svg-icon icon-class="circleNo" style="margin-right: 2px" />
                否
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="routeDialogVisibleCancel">取 消</el-button>
          <el-button v-waves type="primary" @click="routeDialogVisibleConfirm">确 定</el-button>
        </div>
      </span>
    </el-dialog>
    <!--    工单sop/工序sop-->
    <el-dialog
      v-el-drag-dialog
      class="sop"
      title="设备SOP预览"
      :visible.sync="SopDialogVisible"
      width="800px"
      :close-on-click-modal="false"
      top="15vh"
      @closed="handleSopClose"
      @close="handleSopClose"
    >
      <el-form inline label-width="110px" style="display:flex">
        <el-form-item label="工单SOP">
          <el-select
            v-model="dialogSopForm.sop"
            style="width:200px"
            placeholder="请选择"
            filterable
            :popper-append-to-body="false"
            @change="sopChange"
          >
            <el-option
              v-for="item in sopArr"
              :key="item.filepath"
              :label="item.filename"
              :value="item.filepath"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="Sop版本">
          <el-input v-model="dialogSopForm.v" disabled style="width: 200px" />
        </el-form-item>
      </el-form>
      <el-button
        v-waves
        type="primary"
        style="margin-left: 37px"
        @click="view"
      >预 览/下 载
      </el-button>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="handleSopClose">取 消</el-button>
          <!--          <el-button-->
          <!--            v-waves-->
          <!--            type="primary"-->
          <!--            :loading="$store.state.app.buttonIsDisabled"-->
          <!--            :disabled="$store.state.app.buttonIsDisabled"-->
          <!--            @click="handleSopConfirm"-->
          <!--          >确 定</el-button>-->
        </div>
      </span>
    </el-dialog>
    <!--   批量修改-->
    <el-dialog
      v-el-drag-dialog
      title="批量修改"
      :visible.sync="dialogVisibleBatchUpdate"
      width="1200px"
      top="8vh"
      :close-on-click-modal="false"
      @closed="handleCloseBatchUpdate"
      @close="handleCloseBatchUpdate"
    >
      <div
        v-if="formData3.filter(i => !i.routecode).length>0&&mesSetting.route"
        style="display: flex;align-items: center"
      >
        <div style="height: 34px;width: 80%;margin-bottom: 10px;">
          <el-alert
            :title="'当前选中'+multipleSelection.length+'个工单,有'+(formData3.filter(i => !i.routecode).length)+'个工单未指定工艺路线,请先指定!'"
            type="error"
            :closable="false"
          />
        </div>
        <el-button
          v-waves
          type="text"
          style="margin-left: 20px;"
          @click="dialogVisibleBatchUpdate=false;$router.push('../materialManager/inventoryList')"
        >点击跳转存货绑定工艺
        </el-button>
      </div>
      <div v-for="(i,index) in formData3" :key="index" class="customDiv">
        <el-form
          ref="dialogForm"
          inline
          :model="i"
          label-width="110px"
        >
          <el-divider content-position="left">基本信息 {{ index + 1 }}</el-divider>
          <el-form-item
            label="工单状态"
            prop="mesorderstus"
          >
            <div style="width: 200px;">{{ erporderstusArr.find(item => item.code === i.mesorderstus).name }}</div>
          </el-form-item>
          <el-form-item label="工单编号" prop="mesordercode">
            <div style="width: 200px;">{{ i.mesordercode }}</div>
          </el-form-item>
          <el-form-item label="工单类型" prop="mesorderstus">
            <div style="width: 200px;">{{ ordertypeArr.find(item => item.code === i.ordertype).name }}</div>
          </el-form-item>
          <el-form-item label="源单单号">
            <div style="width: 200px;">{{ i.sourceorder }}</div>
          </el-form-item>
          <el-form-item label="工单数量" prop="mesqty">
            <div style="width: 200px;">{{ i.mesqty }}</div>
          </el-form-item>
          <el-form-item label="所属车间" prop="wkshopcode">
            <el-select
              v-model="i.wkshopcode"
              filterable
              :popper-append-to-body="false"
              style="width: 200px;"
              placeholder="请选择车间"
            >
              <!--              @change="val=>getMesOrderNewStepContentBatchUpdate(val,index)"-->
              <el-option
                v-for="item in wkshopArr"
                :key="item.torg_code"
                :label="item.torg_name"
                :value="item.torg_code"
              />
            </el-select>
          </el-form-item>
          <el-form-item
            label="产品名称"
            prop="partcode"
          >
            <div style="width: 200px;">{{ partArr.find(item => item.partcode === i.partcode).partname }}</div>
          </el-form-item>
          <el-form-item
            label="产品编码"
            prop="partcode"
          >
            <div style="width: 200px;">{{ i.partcode }}</div>
          </el-form-item>
          <el-form-item label="产品规格" prop="partspec">
            <div style="width: 200px;">{{
              partArr.find(item => item.partcode === i.partcode).partspec ? partArr.find(item => item.partcode === i.partcode).partspec : '/'
            }}
            </div>
          </el-form-item>
          <el-form-item v-if="mesSetting.route" label="工艺路线" prop="wkshopcode">
            <el-select
              v-model="i.routecode"
              filterable
              :popper-append-to-body="false"
              style="width: 200px;"
              placeholder="请选择工艺路线"
              @change="val=>routecodeChangeBatchUpdate(val,index)"
            >
              <el-option
                v-for="item in i.routecodeArr"
                :key="item.route_code"
                :label="item.route_name"
                :value="item.route_code"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="预计交付日期" prop="deliverydate">
            <el-date-picker
              v-model="i.deliverydate"
              type="date"
              size="mini"
              :clearable="false"
              class="dateMini"
              :picker-options="pickerOptions"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
              placeholder="选择日期"
            />
          </el-form-item>
          <el-form-item label="工序来源" required>
            <el-switch
              v-model="i.sourceType"
              style="width: 200px;"
              inactive-text="基础设置"
              active-text="历史最新"
              :disabled="!i.wkshopcode"
              @change="val=>sourceTypeChangeBatchUpdate(val,index)"
            />
          </el-form-item>
          <el-divider content-position="left">工序信息 {{ index + 1 }}</el-divider>
          <div style="display: flex;align-items: center">
            <div style="font-weight: bolder">工序选择:</div>
            <el-select
              v-model="i.stepSelectedValue"
              class="stepSelectedValueClass"
              style="width: 930px;"
              multiple
              placeholder="请选择相对应工序"
              @change="val=>stepSelectedValueChangeBatchUpdate(val,index)"
            >
              <el-option
                v-for="item in stepSelectArr"
                :key="item.stepcode"
                :label="item.stepname"
                :value="item.stepcode"
              />
            </el-select>
          </div>
          <el-table
            :ref="'stepTableDataRef'+index"
            :key="index"
            :data="i.stepTableData"
            border
            :row-class-name="tableRowClassName"
            height="300"
            :header-cell-style="{
              background: '#f8f8fa', padding: '0', color: '#000', fontWeight: 500
            }"
            :cell-style="{padding: '5px 0'}"
            style="width: 100%;margin-top: 15px;"
            highlight-current-row
            row-key="stepcode"
          >
            <el-table-column
              type="index"
              label="序号"
              width="50"
            />
            <el-table-column
              prop="stepcode"
              show-tooltip-when-overflow
              label="工序编码"
            />
            <el-table-column
              prop="stepname"
              label="工序名称"
              show-tooltip-when-overflow
            />
            <el-table-column
              prop="stepprice"
              label="生产单价"
              show-tooltip-when-overflow
            >
              <template slot-scope="{row}">
                <el-input
                  v-model="row.stepprice"
                  placeholder="请输入工序单价"
                  oninput="value=value.replace(/[^0-9.]/g,'')"
                  style="width: 100%"
                />
              </template>
            </el-table-column>
            <el-table-column
              label="操作"
              width="120"
            >
              <template slot-scope="scope">
                <div class="operationClass">
                  <!--                   <i-->
                  <!--                    class="el-icon-rank"-->
                  <!--                    :style="{color:$store.state.settings.theme}"-->
                  <!--                    style="cursor: move"-->
                  <!--                  />-->
                  <el-tooltip v-del-tab-index class="item" effect="dark" content="删除" placement="top">
                    <i
                      class="el-icon-delete"
                      :style="{color:$store.state.settings.theme}"
                      style="margin-left: 15px;"
                      @click="stepDelBatchUpdate(index,scope.$index)"
                    />
                  </el-tooltip>
                </div>
              </template>
            </el-table-column>
          </el-table>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="dialogVisibleCancelBatchUpdate">取 消</el-button>
          <el-button
            v-waves
            type="primary"
            :loading="$store.state.app.buttonIsDisabled"
            :disabled="$store.state.app.buttonIsDisabled"
            @click="dialogVisibleConfirmBatchUpdate"
          >确 定</el-button>
        </div>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import Pagination from '@/components/Pagination'
import { handleDatetime, handleDatetime2, validateCode } from '@/utils/global'
import { getCookie } from '@/utils/auth'
import QRCode from 'qrcodejs2'
import $ from 'jquery'
import elDragDialog from '@/directive/el-drag-dialog'
import waves from '@/directive/waves'
import {
  AddMesOrderCodeSearch,
  AddUpdateMesOrder, AddUpdateMesOrderList, DeleteMesOrder,
  MesBadOrderSearch, MesOrderDistribution, MesOrderNewStepContent, MesOrderProcessSopSearch,
  MesOrderSearch, MesOrderSopSearch, UpdateMesOrderPrintCount, UpdateMesOrderStepListSearch,
  UpdateMesOrderStepSearch
} from '@/api/WorkOrder'
import { PartSelect } from '@/api/ProductModel'
import { PrentOrganization, PrentOrganizationNoCompany, StepData } from '@/api/GeneralBasicData'
import Sortable from 'sortablejs'
import ElDragSelect from '@/components/DragSelect'
import { MesOrderPrintSearch } from '@/api/GridReport' // base on element-ui
import DateType from '@/components/DateType'
import { PartSelectRpute, PartSelectRputeList, RouteSelectStep, RouteSelectStepList } from '@/api/basicSettings'
import { DeviceSopSearch } from '@/api/DeviceManager'
export default {
  name: 'WorkOrderList',
  components: {
    Pagination, ElDragSelect, DateType
  },
  directives: { elDragDialog, waves },
  data() {
    return {
      mouseHoverType: 'mouseout',
      mouseHoverTypeDialog: 'mouseout',
      isExpandForm: false,
      isIpad: false,
      mainHeight: 0,
      tableHeight: 0,
      username: '',
      form: {
        wkshopcode: '', // 车间编码
        mesorderstus: '', // 工单状态码
        mesordercode: '', // 工单编号
        partcode: '', // 产品编码
        ordertype: '', // ordertype
        sourceorder: '', // 源单单号
        saleordercode: '', // 销售订单
        partname: '', // 产品名称
        partspec: '', // 产品规格
        creatuser: '', // 创建人员
        // createdate: '', // 创建时间
        datatype: 'ED', // 日期类型(计划开工(PS)、计划完工(PE)、预计交付(ED)、创建日期(CT))
        timeValue: [], // 查询日期
        prop: 'lm_date', // 排序字段
        order: 'desc', // 排序字段
        page: 1, // 第几页
        rows: 20 // 每页多少条
      },
      erporderstusArr: [
        { code: 'NEW', name: '新工单' },
        // { code: 'CREATING', name: '执行中' },
        // { code: 'CREATED', name: '已关闭' }
        { code: 'ALLO', name: '已派发' },
        { code: 'START', name: '开工' },
        { code: 'CLOSED', name: '完工' }
        // { code: 'NOSCHED', name: '待排程' },
        // { code: 'SCHED', name: '已排程' }
      ],
      wkshopcodeArr: [],
      total: 10,
      tableData: [],
      dialogVisible: false,
      dialogForm: {
        mesorderstus: 'NEW', // 工单状态码
        mesordercode: '', // 工单编号
        ordertype: 'PO', // 工单类型
        sourceorderid: '', // 源单id
        sourceorder: '', // 源单单号
        partcode: '', // 产品编码
        partname: '', // 产品名称
        partspec: '', // 产品规格
        mesqty: '', // 工单数量
        wkshopcode: '', // 生产车间编码
        wkshopname: '', // 生产车间名称
        deliverydate: '', // 交付时间
        data_sources: '', // 数据来源
        routecode: '', // 工艺路线
        mesmaxqty: 0, // 工单的最大值
        mesqtyinit: 0// 工单数量初始值
      },
      ordertypeArr: [// 工单类型
        { code: 'PO', name: '标准工单' },
        { code: 'FO', name: '报废补单' }
      ],
      partArr: [], // 产品信息
      wkshopArr: [], // 生产车间数组
      routeArr: [], // 工艺路线数组
      orderlevArr: [
        { code: 1, name: '特级' },
        { code: 2, name: '紧急' },
        { code: 3, name: '正常' }
      ], // 工单等级数组
      operation: '',
      dialogFormRules: {
        mesorderstus: [
          { required: true, message: '请选择订单状态', trigger: ['blur', 'change'] }
        ],
        partcode: [
          { required: true, message: '请选择产品信息', trigger: ['blur', 'change'] }
        ],
        mesordercode: [
          { required: true, validator: validateCode, trigger: ['blur', 'change'] }
        ],
        mesqty: [
          { required: true, message: '请输入工单数量', trigger: ['blur', 'change'] }
        ],
        wkshopcode: [
          { required: true, message: '请选择生产车间', trigger: ['blur', 'change'] }
        ],
        deliverydate: [
          { required: true, message: '请选择预计交付日期', trigger: ['blur', 'change'] }
        ],
        planstartdate: [
          { required: true, message: '请选择开始时间', trigger: ['blur', 'change'] }
        ],
        planenddate: [
          { required: true, message: '请选择结束时间', trigger: ['blur', 'change'] }
        ],
        orderlev: [
          { required: true, message: '请选择工单等级', trigger: ['blur', 'change'] }
        ],
        isAps: [
          { required: true, message: '请选择是否排程', trigger: ['blur', 'change'] }
        ],
        bomId: [
          { required: true, message: '请选择物料清单', trigger: ['blur', 'change'] }
        ]
      },
      dialogVisibleTask: false,
      taskTableData: [],
      dialogVisibleSearch: false,
      searchTableData: [],
      dialogVisibleApprove: false,
      tableDataPrint: [], // 打印页面内容
      printObj: {
        id: 'printMe',
        popTitle: '打印模板',
        preview: false,
        extraHead: '<meta http-equiv="Content-Language" content="zh-cn"/>',
        closeCallback(vue) { // 关闭打印的回调事件(无法确定点击的是确认还是取消)
          console.log('11212', vue)
          // vue.dialogVisible = false
          vue.dialogVisibleApprove = false
        },
        beforeOpenCallback(vue) {
          vue.printLoading = true
          console.log('打开之前')
          console.log()
        },
        openCallback(vue) {
          vue.printLoading = false
          console.log('执行了打印')
        }
      },
      formApprove: {
        m_po: '', // 源单单号
        mesordercode: '',
        partcode: '',
        partname: '',
        partspec: '',
        plan_qty: '',
        routename: '',
        lm_date: '',
        priuserdefnvc1: '',
        priuserdefnvc2: '',
        priuserdefnvc3: '',
        priuserdefnvc4: '',
        priuserdefnvc5: '',
        priuserdefnvc6: ''
      },
      number: '',
      dialogVisible2: false,
      printObj2: {
        id: 'printMe2',
        popTitle: '打印模板',
        preview: false,
        extraHead: '<meta http-equiv="Content-Language" content="zh-cn"/>',
        closeCallback(vue) { // 关闭打印的回调事件(无法确定点击的是确认还是取消)
          console.log('11212', vue)
          // vue.dialogVisible = false
          // vue.dialogVisible2 = false
          // vue.dialogVisible = false
        },
        beforeOpenCallback(vue) {
          vue.printLoading = true
          console.log('打开之前')
          console.log()
        },
        openCallback(vue) {
          vue.printLoading = false
          console.log('执行了打印')
        }
      },
      qrForm: {
        qrvalue: '',
        startqty: '',
        wo_code: '',
        partcode: '',
        partname: '',
        nextstepname: '',
        operator: '', // 操作人
        operatorTime: ''// 操作时间
      },
      dialogVisibleSource: false,
      sourceTableData: [],
      sourceForm: {
        wkshopcode: '', // 车间编码
        mesordercode: '', // 工单编号
        sourceorder: '', // 订单编号
        saleordercode: '', // 销售订单号
        partcode: '', // 产品编码
        partname: '', // 产品名称
        partspec: '', // 产品规格
        creatuser: '', // 创建人员
        // paystartdate: '', // 交付时间
        // paystartdate: '', // 预计开工时间
        // payenddate: '', // 预计完工时间
        createdate: '', // 创建时间
        prop: 'lm_date', // 排序字段
        order: 'desc', // 排序字段
        page: 1, // 第几页
        rows: 20 // 每页多少条
      },
      sourceFormTotal: 10,
      radioSelectedId: '',
      isExpandDialog: false, // 对话框表单是否展开,默认不展开
      dialogVisibleRoute: false,
      dialogFormRoute: {
        projectName: '', // 产品名称
        projectCode: '', // 产品代码
        routeOperationArr: [] // 工艺路线集合
      },
      defaultroute_code: '', // 默认工艺路线选中值
      defaultroute_codeArr: '', // 默认工艺路线数组
      projectTableData: [], // 设备列表
      tableDataDetail: [], // 点击工单表的行 显示详细信息
      printSize: 0,
      printSizeSelectArr: [// 宽*高
        { code: 0, name: '80*50' },
        { code: 1, name: '78*60' },
        { code: 2, name: '60*40' }
        // { code: 2, name: '50*60' },
        // { code: 3, name: '50*40' },
        // { code: 4, name: '50*80' },
        // { code: 5, name: '40*30' }
      ],
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() < Date.now() - 8.64e7
        }
      },
      isLastPrint: false, // 是否是末道打印
      lastPrintArr: [], // 末道打印的数组(所有)
      lastPrintArrSelected: [], // 末道打印的数组(选中)
      switchButton: false,
      routeStepArr: '',
      stepTableData: [],
      sortable: null,
      stepSelectArr: [], // 工序下拉数据
      stepSelectedValue: [], // 下拉选中值
      multipleSelection: [],
      datatypeList: [
        { code: 'PS', name: '预计开工日期' },
        { code: 'PE', name: '预计完工日期' },
        { code: 'ED', name: '预计交付日期' },
        { code: 'CT', name: '工单创建日期' }
      ],
      routecodeArr: [], //
      sourceType: false, // 工序的数据来源
      mesSetting: JSON.parse(localStorage.getItem('mesSetting')),
      SopDialogVisible: false,
      dialogSopForm: { // 设备SOP表单
        sop: '',
        v: ''
      },
      sopArr: [],
      routeCode: '', // 工艺路线code
      partCode: '',
      dialogVisibleBatchUpdate: false, // 批量修改
      formData3: []
    }
  },
  watch: {
    'stepSelectedValue': {
      // deep: true,
      handler: function(val) {
        // do something with the new and old value of stepSelectedValue
        console.log(val, 1)
        const arr = JSON.parse(JSON.stringify(this.stepTableData))
        const arrStepcode = arr.map(i => i.stepcode)
        this.stepTableData = []
        val.forEach(i => {
          this.stepTableData.push(
            {
              stepcode: i,
              stepname: this.stepSelectArr.find(j => j.stepcode === i).stepname,
              stepprice: arrStepcode.includes(i) ? arr.find(j => j.stepcode === i).stepprice : 0
            }
          )
        })
      }
    }
  },
  activated() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
    this.handleRequest()
  },
  created() {
    this.handleRequest()
  },
  mounted() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
    // this.$nextTick(() => {
    //   this.setSort()
    // })
  },
  methods: {
    stepDelBatchUpdate(index, ind) {
      this.formData3[index].stepTableData.splice(ind, 1)
      this.formData3[index].stepSelectedValue = this.formData3[index].stepTableData.map(i => i.stepcode)
    },
    // 批量修改
    async batchUpdate() {
      if (this.multipleSelection.length === 0) {
        return this.$message.info('请先勾选相对应的工单!')
      }
      const loading = this.$loading({
        lock: true,
        text: '正在加载数据,请稍等...',
        spinner: 'el-icon-loading',
        customClass: 'osloading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
      const data2 = []
      const data3 = []
      this.formData3 = []
      const partcodeArr = []
      this.multipleSelection.forEach(i => {
        partcodeArr.push({
          partcode: i.partcode
        })
        if (this.mesSetting.route) {
          data2.push(
            { partcode: i.partcode, routecode: i.route_code ? i.route_code : i.default_route }
          )
        }
        data3.push({
          sourceid: i.sourceid,
          sourcewo: i.m_po,
          wocode: i.wo_code,
          data_sources: i.data_sources
        })
        this.formData3.push({
          mesorderstus: i.status, // 工单状态码
          mesordercode: i.wo_code, // 工单编号
          ordertype: i.wotype, // 工单类型
          sourceorderid: i.sourceid, // 源单id
          sourceorder: i.m_po, // 源单单号
          partcode: i.partcode, // 产品编码
          partname: i.partname, // 产品名称
          partspec: i.partspec, // 产品规格
          mesqty: i.plan_qty, // 工单数量
          wkshopcode: i.wkshp_code, // 生产车间编码
          wkshopname: i.wkshp_name, // 生产车间名称
          deliverydate: i.saleOrderDeliveryDate.substring(0, 11), // 交付时间
          data_sources: i.data_sources, // 数据来源
          sourceType: this.sourceType, // 工序来源
          routecode: i.route_code ? i.route_code : i.default_route, // 工艺路线
          routecodeArr: [], // 工艺路线数组
          stepSelectedValue: [], // 下拉选中值
          stepTableData: []// 工序表值
        })
      })
      const { data: res3 } = await UpdateMesOrderStepListSearch(data3)
      res3.forEach((i, index) => {
        if (i.stepdata.length > 0) {
          this.formData3[index].stepTableData = i.stepdata
          this.formData3[index].stepSelectedValue = i.stepdata.map(j => j.stepcode)
        }
      })
      const { data: res } = await PartSelectRputeList(partcodeArr)
      if (this.mesSetting.route) {
        res.forEach((i, index) => {
          if (i.routedata.length > 0) {
            this.formData3[index].routecodeArr = i.routedata
          }
        })
      } else {
        this.formData3.forEach((i, index) => {
          if (i.stepTableData.length === 0) {
            i.stepTableData = res[index].stepdata
            i.stepSelectedValue = res[index].stepdata.length > 0 ? res[index].stepdata.map(j => j.stepcode) : []
          }
        })
      }
      if (this.mesSetting.route) {
        const { data: res2 } = await RouteSelectStepList(data2)
        this.formData3.forEach((i, index) => {
          if (i.stepTableData.length === 0) {
            i.stepTableData = res2[index].stepdata
            i.stepSelectedValue = res2[index].stepdata.length > 0 ? res2[index].stepdata.map(j => j.stepcode) : []
          }
        })
      }
      // this.formData3 = this.multipleSelection
      this.dialogVisibleBatchUpdate = true
      loading.close()
    },
    // 对话框关闭
    handleCloseBatchUpdate() {
      this.multipleSelection = []
      this.formData3 = []
      this.$refs.tableDataRef.clearSelection()
    },
    dialogVisibleCancelBatchUpdate() {
      this.dialogVisibleBatchUpdate = false
    },
    async dialogVisibleConfirmBatchUpdate() {
      this.$store.state.app.buttonIsDisabled = true
      let flag = false
      const data = []
      this.formData3.forEach((i, index) => {
        const workListSub = []
        if (i.stepTableData.length > 0) {
          i.stepTableData.forEach((it, j) => {
            workListSub.push(
              {
                stepseq: j + 1,
                stepcode: it.stepcode,
                stepprice: it.stepprice,
                isbott: j === 0 ? 'Y' : 'N',
                isend: j === i.stepTableData.length - 1 ? 'Y' : 'N'
              }
            )
          })
        } else {
          flag = true
        }
        data.push({
          wostatus: i.mesorderstus, // 工单状态
          wocode: i.mesordercode, // 工单号
          wotype: i.ordertype, // 工单类型
          sourceid: i.sourceorderid, // 源单id
          sourcewo: i.sourceorder, // 源单单号
          partcode: i.partcode, // 产品编号
          wkshopcode: i.wkshopcode,
          woqty: i.mesqty, // 工单数量
          deliverydate: i.deliverydate, // 交付时间
          data_sources: i.data_sources, // 数据来源
          isstep: workListSub.length > 0 ? 'Y' : 'N', //
          difference: 0, // 数据差值
          routecode: i.routecode,
          workListSub
        })
      })
      if (flag) {
        this.$store.state.app.buttonIsDisabled = false
        return this.$message.error('数据未维护好,请先检查!')
      }
      const res = await AddUpdateMesOrderList(data)
      if (res.code === '200') {
        this.$message.success('修改操作成功!')
        this.$store.state.app.buttonIsDisabled = false
      }
      await this.getMesOrderSearch()
      this.dialogVisibleBatchUpdate = false
    },
    async sourceTypeChangeBatchUpdate(val, index) {
      if (val) {
        const data = {
          routecode: this.formData3[index].routecode,
          wkshopcode: this.formData3[index].wkshopcode,
          partcode: this.formData3[index].partcode
        }
        const { data: res } = await MesOrderNewStepContent(data)
        this.formData3[index].stepSelectedValue = []
        this.formData3[index].stepTableData = []
        if (res.length > 0) {
          res.forEach(i => {
            this.formData3[index].stepTableData.push(
              {
                stepcode: i.step_code,
                stepname: i.step_name,
                stepprice: i.stepprice
              }
            )
          })
          this.formData3[index].stepSelectedValue = this.formData3[index].stepTableData.map(i => i.stepcode)
        }
      } else {
        if (this.mesSetting.route) {
          // this.routecodeChange()
          const data = {
            partcode: this.formData3[index].partcode,
            routecode: this.formData3[index].routecode
          }
          const { data: res } = await RouteSelectStep(data)
          this.formData3[index].stepSelectedValue = []
          this.formData3[index].stepTableData = []
          if (res.length > 0) {
            res.sort((a, b) => a.step_seq - b.step_seq)
            res.forEach(i => {
              this.formData3[index].stepTableData.push(
                {
                  stepcode: i.step_code,
                  stepname: i.step_name,
                  stepprice: i.unprice
                }
              )
            })
            this.formData3[index].stepSelectedValue = this.formData3[index].stepTableData.map(i => i.stepcode)
          }
        } else {
          // this.getBasicProcessData()
          const { data: res } = await PartSelectRpute({ partcode: this.formData3[index].partcode })
          res.sort((a, b) => a.step_seq - b.step_seq)
          this.formData3[index].stepSelectedValue = []
          this.formData3[index].stepTableData = []
          res.forEach(i => {
            this.formData3[index].stepTableData.push(
              {
                stepcode: i.step_code,
                stepname: i.step_name,
                stepprice: i.unprice
              }
            )
          })
          this.formData3[index].stepSelectedValue = this.formData3[index].stepTableData.map(i => i.stepcode)
        }
      }
    },
    async getMesOrderNewStepContentBatchUpdate(val, index) {
      const data = {
        routecode: this.formData3[index].routecode,
        wkshopcode: this.formData3[index].wkshopcode,
        partcode: this.formData3[index].partcode
      }
      const { data: res } = await MesOrderNewStepContent(data)
      this.formData3[index].stepSelectedValue = []
      this.formData3[index].stepTableData = []
      if (res.length > 0) {
        res.forEach(i => {
          this.formData3[index].stepTableData.push(
            {
              stepcode: i.step_code,
              // stepname: i.stepname,
              stepprice: i.stepprice
            }
          )
        })
        this.formData3[index].stepSelectedValue = this.formData3[index].stepTableData.map(i => i.stepcode)
      }
    },
    async routecodeChangeBatchUpdate(val, index) {
      // this.sourceType
      const data = {
        partcode: this.formData3[index].partcode,
        routecode: this.formData3[index].routecode
      }
      const { data: res } = await RouteSelectStep(data)
      this.formData3[index].stepSelectedValue = []
      this.formData3[index].stepTableData = []
      if (res.length > 0) {
        res.sort((a, b) => a.step_seq - b.step_seq)
        res.forEach(i => {
          this.formData3[index].stepTableData.push(
            {
              stepcode: i.step_code,
              stepname: i.step_name,
              stepprice: i.unprice
            }
          )
        })
        this.formData3[index].stepSelectedValue = this.formData3[index].stepTableData.map(i => i.stepcode)
      }
    },
    // 弹出框关闭
    handleSopClose() {
      this.SopDialogVisible = false
      this.dialogSopForm = { // 设备SOP表单
        sop: '',
        v: ''
      }
    },
    // 预览
    view() {
      window.open(process.env.VUE_APP_BASE_API_FILE + this.dialogSopForm.sop)
    },
    sopChange(val) {
      this.dialogSopForm.v = this.sopArr.find(i => i.filepath === val).version
    },
    async pre(row, type) {
      if (type === 1) {
        const data = {
          wocode: row.wo_code,
          materielcode: row.partcode
        }
        const { data: res } = await MesOrderSopSearch(data)
        this.sopArr = res
      }
      if (type === 2) {
        const data = {
          materielcode: this.partCode,
          routecode: this.routeCode ? this.routeCode : '',
          stepcode: row.step_code
        }
        const { data: res } = await MesOrderProcessSopSearch(data)
        this.sopArr = res
      }
      this.SopDialogVisible = true
    },
    // 工序来源切换
    sourceTypeChange(val) {
      this.stepTableData = []
      if (val) {
        this.getMesOrderNewStepContent()
      } else {
        if (this.mesSetting.route) {
          this.routecodeChange()
        } else {
          this.getBasicProcessData()
        }
      }
    },
    DateTypeChange(value) {
      this.form.datatype = value
    },
    cycleTimeChange(val) {
      this.form.timeValue = val
    },
    setSort() {
      const el = this.$refs.stepTableDataRef.$el.querySelectorAll('.el-table__body-wrapper > table > tbody')[0]
      this.sortable = Sortable.create(el, {
        ghostClass: 'sortable-ghost', // Class name for the drop placeholder,
        setData: function(dataTransfer) {
          // to avoid Firefox bug
          // Detail see : https://github.com/RubaXa/Sortable/issues/1012
          dataTransfer.setData('Text', '')
        },
        onEnd: evt => {
          const targetRow = this.stepTableData.splice(evt.oldIndex, 1)[0]
          this.stepTableData.splice(evt.newIndex, 0, targetRow)
          this.stepSelectedValue = this.stepTableData.map(i => i.stepcode)
          // for show the changes, you can delete in you code
          // const tempIndex = this.newList.splice(evt.oldIndex, 1)[0]
          // this.newList.splice(evt.newIndex, 0, tempIndex)
        }
      })
    },
    tableRowClassName({ row, rowIndex }) {
      return 'custom-row'
    },
    handleRequest() {
      this.getMesOrderSearch().then(res => {
        if (res.code === '200') {
          this.getSelect()
          this.getPrentOrganizationNoCompany()
        }
      })
    },
    async getPrentOrganizationNoCompany() {
      const { data: res } = await PrentOrganizationNoCompany()
      this.wkshopcodeArr = res
    },
    async getMesOrderSearch() {
      // let tempDate = this.form.createdate
      // if (tempDate.length > 0) {
      //   tempDate = handleDatetime(tempDate[0]) + '~' + handleDatetime(tempDate[1])
      // }
      const data = {
        wkshopcode: this.form.wkshopcode,
        mesorderstus: this.form.mesorderstus, // 工单状态码
        mesordercode: this.form.mesordercode, // 工单编号
        partcode: this.form.partcode, // 产品编码
        partname: this.form.partname, // 产品名称
        partspec: this.form.partspec, // 产品规格
        creatuser: this.form.creatuser, // 创建人员
        sourceorder: this.form.sourceorder, // 源单单号
        saleordercode: this.form.saleordercode, // 销售订单
        ordertype: this.form.ordertype, // 单据类型
        datatype: this.form.datatype,
        searchdate: this.form.timeValue.join('~'),
        // createdate: this.form.createdate.toString().length > 0 ? handleDatetime(this.form.createdate) : '', // 创建时间
        prop: this.form.prop, // 排序字段
        order: this.form.order, // 排序字段
        page: this.form.page, // 第几页
        rows: this.form.rows // 每页多少条
      }
      const res = await MesOrderSearch(data)
      this.tableData = res.data
      this.total = res.count
      // this.form.createdate = tempDate
      return { code: res.code }
    },
    async getSelect() {
      // 获取产品信息
      const { data: res1 } = await PartSelect()
      this.partArr = res1
      // 获取组织
      const { data: res2 } = await PrentOrganization()
      this.wkshopArr = res2
      // 获取工序
      const { data: res3 } = await StepData()
      this.stepSelectArr = res3
    },
    // 订单状态改变时
    erporderstusChange(val) {
      this.form.mesorderstus = val
    },
    // 排序改变时
    sortChange({ column, prop, order }) {
      if (order === 'descending') {
        order = 'desc'
      } else if (order === 'ascending') {
        order = 'asc'
      } else {
        order = 'desc'
      }
      this.form.order = order
      this.form.prop = prop
      this.getMesOrderSearch()
    },
    sourceSortChange({ column, prop, order }) {
      if (order === 'descending') {
        order = 'desc'
      } else if (order === 'ascending') {
        order = 'asc'
      } else {
        order = 'desc'
      }
      this.sourceForm.order = order
      this.sourceForm.prop = prop
      this.getMesBadOrderSearch()
    },
    // 查询
    search() {
      this.getMesOrderSearch()
    },
    // 重置
    reset(val) {
      this.form.wkshopcode = ''
      this.form.mesorderstus = ''
      this.form.mesordercode = ''
      this.form.partcode = ''
      this.form.partname = ''
      this.form.partspec = ''
      this.form.paydate = ''
      this.form.creatuser = ''
      this.form.sourceorder = ''
      this.form.ordertype = ''
      // this.form.createdate = ''
      this.form.timeValue = []
      this.cycleTime = null
      this.$refs.DateTypeRef.clearValue()
      this.getMesOrderSearch()
    },
    // 新增按钮
    async add(operation) {
      const { data: res } = await AddMesOrderCodeSearch()
      this.dialogForm.mesordercode = res
      this.operation = operation
      this.dialogVisible = true
      this.dialogForm.data_sources = 'MES'
      this.$nextTick(() => {
        this.setSort()
      })
    },
    // 工序任务
    async check(row) {
      // const { data: res } = await SearchWorkStep({ wo_code: row.wo_code })
      // this.taskTableData = res
      //
      // if (this.taskTableData.length === 0) {
      //   return this.$message.info('无生产任务数据!')
      // }
      // this.dialogForm.mesordercode = res[0].wo_code
      // this.dialogVisibleTask = true
    },
    dialogVisibleBack() {
      this.dialogVisibleTask = false
    },
    handleSelectionChange(val) {
      this.multipleSelection = val
    },
    selected(row, index) {
      return row.status === 'NEW'
      // return row.status === 'NEW' && row.isstep === 'Y'
    },
    // 派发
    send() {
      if (this.multipleSelection.length === 0) {
        return this.$message.info('请先勾选相对应的工单!')
      }
      this.$confirm('是否确认派发?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        MesOrderDistribution(this.multipleSelection.map(i => i.wo_code)).then(res => {
          if (res.code === '200') {
            this.$notify.success('派发成功!')
            this.getMesOrderSearch()
          }
        })
      }).catch(() => {
        this.$notify.info('已取消派发')
      })
    },
    // 删除按钮
    async del(row) {
      if (row.status === 'START' || row.status === 'CLOSED' || row.status === 'SCHED') {
        return this.$message.info('此工单不可删除!')
      }
      this.$confirm('是否确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        const data = {
          souceid: row.sourceid ? row.sourceid : '',
          wocode: row.wo_code,
          m_po: row.m_po,
          orderqty: row.plan_qty
        }
        DeleteMesOrder(data).then(res => {
          if (res.code === '200') {
            this.$notify.success('删除成功!')
            if (this.form.page > 1 && this.tableData.length === 1) {
              this.form.page--
            }
            this.getMesOrderSearch()
          }
        })
      }).catch(() => {
        this.$notify.info('已取消删除')
      })
    },
    // 修改按钮
    async edit(operation, row) {
      this.operation = operation
      this.dialogForm.data_sources = row.data_sources
      this.dialogForm.mesorderstus = row.status
      this.dialogForm.mesordercode = row.wo_code
      this.dialogForm.ordertype = row.wotype
      this.dialogForm.sourceorderid = row.sourceid
      this.dialogForm.sourceorder = row.m_po
      this.dialogForm.partcode = row.partcode
      this.dialogForm.partname = row.partname
      this.dialogForm.partspec = row.partspec
      this.dialogForm.wkshopcode = row.wkshp_code
      this.dialogForm.routecode = row.route_code
      this.dialogForm.deliverydate = row.saleOrderDeliveryDate.substring(0, 11)
      this.dialogForm.mesqty = row.plan_qty
      this.dialogForm.mesqtyinit = row.plan_qty
      const data = {
        sourceid: this.dialogForm.sourceorderid,
        sourcewo: this.dialogForm.sourceorder,
        wocode: this.dialogForm.mesordercode,
        data_sources: this.dialogForm.data_sources
      }
      const { data: res } = await UpdateMesOrderStepSearch(data)
      this.dialogForm.mesmaxqty = res.canupdate_qty
      if (this.mesSetting.route) { // 按工艺路线走模式
        if (!this.dialogForm.routecode) {
          await this.getPartcodeChangeDialog()
        } else {
          const { data: res } = await PartSelectRpute({ partcode: this.dialogForm.partcode })
          this.routecodeArr = res
        }
        if (res.stepdata.length > 0) {
          this.stepTableData = []
          this.stepSelectedValue = []
          res.stepdata.forEach(i => {
            this.stepTableData.push(
              {
                stepcode: i.step_code,
                stepname: i.stepname,
                stepprice: i.stepprice
              }
            )
          })
          this.stepSelectedValue = this.stepTableData.map(i => i.stepcode)
        } else {
          const data2 = {
            wkshopcode: this.dialogForm.wkshopcode,
            partcode: this.dialogForm.partcode
          }
          const { data: res2 } = await MesOrderNewStepContent(data2)
          if (res2.length > 0) {
            res2.forEach(i => {
              this.stepTableData.push(
                {
                  stepcode: i.step_code,
                  // stepname: i.stepname,
                  stepprice: i.stepprice
                }
              )
            })
            this.stepSelectedValue = this.stepTableData.map(i => i.stepcode)
          }
        }
      } else {
        if (res.stepdata.length > 0) {
          res.stepdata.forEach(i => {
            this.stepTableData.push(
              {
                stepcode: i.step_code,
                stepname: i.stepname,
                stepprice: i.stepprice
              }
            )
          })
          this.stepSelectedValue = this.stepTableData.map(i => i.stepcode)
        } else {
          await this.getBasicProcessData()
        }
      }
      this.dialogVisible = true
      this.$nextTick(() => {
        this.setSort()
      })
    },
    // 按工序模式走的时候  引用基础资料 工艺
    async getBasicProcessData() {
      const { data: res } = await PartSelectRpute({ partcode: this.dialogForm.partcode })
      res.sort((a, b) => a.step_seq - b.step_seq)
      this.stepTableData = []
      res.forEach(i => {
        this.stepTableData.push(
          {
            stepcode: i.step_code,
            stepname: i.step_name,
            stepprice: i.unprice
          }
        )
      })
      this.stepSelectedValue = this.stepTableData.map(i => i.stepcode)
    },
    // 工单关闭事件
    orderClose() {
      console.log('工单关闭事件')
    },
    // 对话框产品信息值改变
    partcodeChangeDialog(val) {
      console.log(val)
      this.dialogForm.partname = this.partArr.find(item => item.partcode === val).partname
      this.dialogForm.partcode = this.partArr.find(item => item.partcode === val).partcode
      this.dialogForm.partspec = this.partArr.find(item => item.partcode === val).partspec
      this.dialogForm.routecode = ''
      if (this.mesSetting.route) {
        this.getPartcodeChangeDialog()
      } else {
        this.getBasicProcessData()
      }
    },
    async getPartcodeChangeDialog() {
      const { data: res } = await PartSelectRpute({ partcode: this.dialogForm.partcode })
      this.routecodeArr = res
      // if (this.mesSetting.route) { // 按工艺路线走模式
      this.dialogForm.routecode = this.partArr.find(item => item.partcode === this.dialogForm.partcode).default_route
      if (this.dialogForm.routecode && !this.sourceType) {
        await this.routecodeChange()
      } else {
        await this.getMesOrderNewStepContent()
      }
      // }
      // else { // 按工序走模式
      //   await this.getMesOrderNewStepContent()
      // }
    },
    // 工艺路线值改变
    async routecodeChange() {
      const data = {
        partcode: this.dialogForm.partcode,
        routecode: this.dialogForm.routecode
      }
      const { data: res } = await RouteSelectStep(data)
      this.stepSelectedValue = []
      this.stepTableData = []
      if (res.length > 0) {
        res.sort((a, b) => a.step_seq - b.step_seq)
        res.forEach(i => {
          this.stepTableData.push(
            {
              stepcode: i.step_code,
              // stepname: i.stepname,
              stepprice: i.unprice
            }
          )
        })
        this.stepSelectedValue = this.stepTableData.map(i => i.stepcode)
      }
    },
    async getMesOrderNewStepContent() {
      // if (!this.mesSetting.route && this.operation === 'edit') {
      //   return
      // }
      const data = {
        routecode: this.dialogForm.routecode,
        wkshopcode: this.dialogForm.wkshopcode,
        partcode: this.dialogForm.partcode
      }
      const { data: res } = await MesOrderNewStepContent(data)
      // console.log(res)
      this.stepSelectedValue = []
      this.stepTableData = []
      if (res.length > 0) {
        res.forEach(i => {
          this.stepTableData.push(
            {
              stepcode: i.step_code,
              // stepname: i.stepname,
              stepprice: i.stepprice
            }
          )
        })
        this.stepSelectedValue = this.stepTableData.map(i => i.stepcode)
      }
    },
    // 对话框关闭事件
    handleClose() {
      this.dialogForm = {
        mesorderstus: 'NEW', // 工单状态码
        mesordercode: '', // 工单编号
        ordertype: 'PO', // 工单类型
        sourceorderid: '', // 源单id
        sourceorder: '', // 源单单号
        partcode: '', // 产品编码
        partname: '', // 产品名称
        partspec: '', // 产品规格
        mesqty: '', // 工单数量
        wkshopcode: '', // 生产车间编码
        wkshopname: '', // 生产车间名称
        deliverydate: '', // 交付时间
        data_sources: '' // 数据来源
      }
      this.sourceType = false
      this.stepSelectedValue = []
      this.stepTableData = []
      this.$refs.dialogForm.clearValidate()
    },
    // 对话框取消
    dialogVisibleCancel() {
      this.dialogVisible = false
    },
    // 对话框确认
    dialogVisibleConfirm() {
      this.$refs.dialogForm.validate(valid => {
        if (valid) {
          if (this.dialogForm.ordertype === 'FO' && this.dialogForm.sourceorder.toString().trim().length <= 0) {
            return this.$message.info('源单单号不能为空!')
          }
          if (this.dialogForm.mesqty <= 0) {
            return this.$message.info('工单数量不能等于零!')
          }
          if (this.dialogForm.data_sources === 'ERP' && this.dialogForm.mesmaxqty < this.dialogForm.mesqty) {
            return this.$message.info('此工单的最大修改数值为:' + this.dialogForm.mesmaxqty)
          }
          const workListSub = []
          this.stepTableData.forEach((i, j) => {
            workListSub.push(
              {
                stepseq: j + 1,
                stepcode: i.stepcode,
                stepprice: i.stepprice,
                isbott: j === 0 ? 'Y' : 'N',
                isend: j === this.stepTableData.length - 1 ? 'Y' : 'N'
              }
            )
          })
          if (workListSub.length === 0) {
            return this.$message.info('工序不能为空!')
          }
          const data = {
            wostatus: this.dialogForm.mesorderstus, // 工单状态
            wocode: this.dialogForm.mesordercode, // 工单号
            wotype: this.dialogForm.ordertype, // 工单类型
            sourceid: this.dialogForm.sourceorderid, // 源单id
            sourcewo: this.dialogForm.sourceorder, // 源单单号
            partcode: this.dialogForm.partcode, // 产品编号
            wkshopcode: this.dialogForm.wkshopcode,
            woqty: this.dialogForm.mesqty, // 工单数量
            deliverydate: this.dialogForm.deliverydate, // 交付时间
            data_sources: this.dialogForm.data_sources, // 数据来源
            isstep: workListSub.length > 0 ? 'Y' : 'N', //
            difference: this.dialogForm.mesqty - this.dialogForm.mesqtyinit, // 数据差值
            routecode: this.dialogForm.routecode,
            workListSub
          }
          this.$store.state.app.buttonIsDisabled = true
          AddUpdateMesOrder(data, this.operation === 'add' ? 'Add' : 'Update').then(res => {
            if (res.code === '200') {
              this.dialogVisible = false
              // this.handlePrint()
              this.$message.success(this.operation === 'add' ? '添加成功!' : '保存成功!')
              this.getMesOrderSearch()
              this.$store.state.app.buttonIsDisabled = false
            } else {
              this.$message.error(this.operation === 'add' ? '添加失败!' : '保存失败!')
            }
          })
        }
      })
    },
    // 派发打印
    async sendPrint() {
      const data = {
        username: getCookie('admin'),
        // username: getCookie('username'),
        mesordercode: this.dialogForm.mesordercode
      }
      const res = await MesOrderPrintSearch1(data)
      // const res = await PrintOrder(data)
      if (res.code === '200') {
        // 参数具体说明请参考帮助文档中的“WEB报表(B/S报表)->WEB报表客户端->启动参数说明”部分
        var args = {
          type: 'print', // preview  print
          showOptionDlg: false, // 如果不显示打印对话框而直接打印,将此行注释去掉即可
          report: urlAddRandomNo('./static/grf/产品流传单A4.grf'),
          data: res.data
        }
        webapp_ws_ajax_run(args)
      }
    },
    // 获取页面高度
    getHeight() {
      this.$nextTick(() => {
        this.mainHeight = window.innerHeight - 85
        // this.tableHeight = this.mainHeight - 250
        this.tableHeight = this.mainHeight - 515
        if (window.innerHeight < 769) {
          this.tableHeight = this.tableHeight - 20
        }
        this.isIpad = window.innerHeight < 769 && window.innerWidth < 1367
        this.$refs.tableDataRef.doLayout()
      })
    },
    // 工艺路线放大镜点击
    async searchClick() {
      if (this.dialogForm.routecode === '') {
        return this.$message.info('请先选择工艺路线!')
      }
      this.dialogVisibleSearch = true
      const { data: res } = await SelectRouteStep({ routecode: this.dialogForm.routecode })
      this.searchTableData = res
    },
    dialogVisibleSearchBack() {
      this.dialogVisibleSearch = false
    },
    // 处理打印
    handlePrint(wo_code, saleOrderCode, row) {
      // const number = Math.random() * Math.random()
      // this.number = number === 0 ? (10 + Math.random()) : number
      // console.log(number)
      this.formApprove.priuserdefnvc1 = row.priuserdefnvc1 ? row.priuserdefnvc1 : '/'
      this.formApprove.priuserdefnvc2 = row.priuserdefnvc2 ? row.priuserdefnvc2 : '/'
      this.formApprove.priuserdefnvc3 = row.priuserdefnvc3 ? row.priuserdefnvc3 : '/'
      this.formApprove.priuserdefnvc4 = row.priuserdefnvc4 ? row.priuserdefnvc4 : '/'
      this.formApprove.priuserdefnvc5 = row.priuserdefnvc5 ? row.priuserdefnvc5 : '/'
      this.formApprove.priuserdefnvc6 = row.priuserdefnvc6 ? row.priuserdefnvc6 : '/'
      this.formApprove.saleOrderCode = this.formApprove.saleOrderCode !== '' ? this.formApprove.saleOrderCode : saleOrderCode
      const data2 = {
        mesordercode: wo_code || this.dialogForm.mesordercode
      }
      MesOrderPrintSearch(data2).then(res2 => {
        if (res2.code === '200') {
          this.dialogVisibleApprove = true
          const res3 = res2.data.recordset
          // this.tableDataPrint = res3
          this.tableDataPrint = this.chunkArray(res3, 8)
          this.formApprove.mesordercode = res3[0].wo_code
          this.formApprove.m_po = res3[0].m_po || '/'
          this.formApprove.partcode = res3[0].partcode
          this.formApprove.partname = res3[0].partname
          this.formApprove.partspec = res3[0].partspec || '/'
          this.formApprove.plan_qty = res3[0].plan_qty
          this.formApprove.routename = localStorage.getItem('username') // 打印人员
          this.formApprove.lm_date = res3[0].lm_date
          this.$nextTick(() => {
            this.tableDataPrint.forEach((item, index) => {
              item.forEach(i => {
                this.bindQRCode(i.seq, i.stepqrcode, 'small')
              })
              // this.bindQRCode(index, this.formApprove.mesordercode, 'big')
              // const div = document.getElementById('qrCode' + index)
              // div.scrollTop = div.scrollHeight // 滚动条位于最底部
            })
            // const div = document.getElementById('qrCode')
            // 这么多代码只需要这一句实现我们所需要的功能,定位div滚动条位置在底部,scrollHeight计算出div的高度,再scrollTop 设置滚动条的高度为多少
            // div.scrollTop = div.scrollHeight // 滚动条位于最底部
            // div.scrollTop = 0 // 滚动条位于最顶部
          })
        }
      })
    },
    dialogVisibleTaskClose() {
      this.dialogForm.mesordercode = ''
    },
    /*
  * 手动点击打印
  * */
    // 返回按钮
    dialogVisibleBackPreview() {
      this.dialogVisibleApprove = false
    },
    chunkArray(array, size) {
      const chunked = []
      let i = 0
      while (i < array.length) {
        chunked.push(array.slice(i, i + size))
        i += size
      }
      return chunked
    },
    // dialogVisibleConfirmPreview(param) {
    //   this.$refs.dialogForm.validate(valid => {
    //     if (valid) {
    //       const data = {
    //         username: getCookie('admin'),
    //         mesordercode: this.dialogForm.mesordercode
    //       }
    //       MesOrderPrintSearch1(data).then(res => {
    //         if (res.code === '200') {
    //           this.dialogVisibleApprove = true
    //           console.log(res, 11)
    //         }
    //       })
    //     }
    //   })
    // },
    // 生成二维码    工单报表二维码
    bindQRCode(seq, text, size) {
      if (size === 'big') {
        new QRCode(this.$refs['qrCodeDiv0' + seq], {
          text: text,
          width: size === 'big' ? 90 : 60,
          height: size === 'big' ? 90 : 60,
          // colorDark: '#333333', // 二维码颜色
          colorDark: '#000', // 二维码颜色
          colorLight: '#ffffff', // 二维码背景色
          correctLevel: QRCode.CorrectLevel.L// 容错率,L/M/H
        })
      } else {
        new QRCode(this.$refs['qrCodeDiv' + seq], {
          text: text,
          width: size === 'big' ? 90 : 60,
          height: size === 'big' ? 90 : 60,
          // colorDark: '#333333', // 二维码颜色
          colorDark: '#000', // 二维码颜色
          colorLight: '#ffffff', // 二维码背景色
          correctLevel: QRCode.CorrectLevel.L// 容错率,L/M/H
        })
      }
    },
    dialogVisibleConfirmClose() {
      this.formApprove.saleOrderCode = ''
      // this.dialogForm.mesordercode = ''
      this.formApprove.mesordercode = ''
      this.formApprove.m_po = ''
      this.formApprove.partcode = ''
      this.formApprove.partname = ''
      this.formApprove.partspec = ''
      this.formApprove.plan_qty = ''
      this.formApprove.routename = ''
      this.formApprove.lm_date = ''
      this.formApprove.priuserdefnvc1 = ''
      this.formApprove.priuserdefnvc2 = ''
      this.formApprove.priuserdefnvc3 = ''
      this.formApprove.priuserdefnvc4 = ''
      this.formApprove.priuserdefnvc5 = ''
      this.formApprove.priuserdefnvc6 = ''
      // this.$refs.qrCodeDiv0.title = ''
      this.tableDataPrint = []
    },
    // 补打按钮
    supplementClick() {
      this.dialogVisibleTask = false
      this.handlePrint()
    },
    // 补打小标签
    supplementSmallClick(row) {
      // let obj = {}
      console.log(row, 21)
      // this.taskTableData.forEach((item, index) => {
      this.tableDataDetail.forEach((item, index) => {
        if (item.seq === row.seq) {
          console.log(item)
          this.qrForm = {
            // qrvalue: item.seq === this.taskTableData.length ? item.wo_code + ';' + item.stepcode : item.wo_code + ';' + this.taskTableData[item.seq].stepcode,
            qrvalue: item.seq === this.tableDataDetail.length ? item.wo_code + ';' + item.stepcode : item.wo_code + ';' + this.tableDataDetail[item.seq].stepcode,
            // startqty: item.seq === this.taskTableData.length ? item.plan_qty : this.taskTableData[item.seq].plan_qty,
            startqty: item.seq === this.tableDataDetail.length ? item.plan_qty : this.tableDataDetail[item.seq].plan_qty,
            wo_code: item.wo_code,
            partcode: item.partcode,
            partname: item.partname,
            // nextstepname: item.seq === this.taskTableData.length ? item.stepname : this.taskTableData[item.seq].stepname,
            nextstepname: item.seq === this.tableDataDetail.length ? item.stepname : this.tableDataDetail[item.seq].stepname,
            operator: getCookie('username'),
            operatorTime: handleDatetime2(new Date())
          }
          this.$nextTick(() => {
            console.log(this.qrForm.qrvalue, 3333)
            this.bindQRCode2(this.qrForm.qrvalue)
            const div = document.getElementById('qrCode2')
            // 这么多代码只需要这一句实现我们所需要的功能,定位div滚动条位置在底部,scrollHeight计算出div的高度,再scrollTop 设置滚动条的高度为多少
            div.scrollTop = div.scrollHeight // 滚动条位于最底部
            // div.scrollTop = 0 // 滚动条位于最顶部
          })
        }
      })
      // this.dialogVisibleTask = false
      this.dialogVisible2 = true
      console.log(this.qrForm, 1111)
    },
    // 补打生产入库条码
    async getProductInHouseLabCode(ordercode) {
      const res = await ProductInHouseLabCode({ ordercode })
      console.log(res)
      this.isLastPrint = true
      this.lastPrintArr = res.data
      this.dialogVisible2 = true
      // 生产二维码
      this.$nextTick(() => {
        this.lastPrintArr.forEach((i, index) => {
          i.checked = false
          new QRCode(this.$refs.qrCodeDiv2[index], {
            text: i.inbarcode,
            width: this.printSize !== 2 ? 60 : 55,
            height: this.printSize !== 2 ? 60 : 55,
            colorDark: '#000', // 二维码颜色
            colorLight: '#ffffff', // 二维码背景色
            correctLevel: QRCode.CorrectLevel.L// 容错率,L/M/H
          })
        })
      })
    },
    dialogVisible2Close() {
      this.qrForm.qrvalue = ''
      this.qrForm.startqty = ''
      this.qrForm.wo_code = ''
      this.qrForm.partcode = ''
      this.qrForm.partname = ''
      this.qrForm.nextstepname = ''
      this.qrForm.operator = ''
      this.qrForm.operatorTime = ''
      // this.$refs.qrCodeDiv2 = ''
      this.isLastPrint = false
      this.lastPrintArr = []
      this.lastPrintArrSelected = []
    },
    // 生成二维码    工序标签二维码
    bindQRCode2(text) {
      new QRCode(this.$refs.qrCodeDiv2, {
        text: text,
        width: this.printSize !== 2 ? 60 : 55,
        height: this.printSize !== 2 ? 60 : 55,
        colorDark: '#000', // 二维码颜色
        colorLight: '#ffffff', // 二维码背景色
        correctLevel: QRCode.CorrectLevel.L// 容错率,L/M/H
      })
    },
    // 报废补单情况下可点击选择
    mesordertsourcesearchclick() {
      if (this.dialogForm.ordertype === 'PO') {
        return this.$message.info('工单类型为报废补单情况下可选择!')
      }
      this.getMesBadOrderSearch()
      this.dialogVisibleSource = true
    },
    async getMesBadOrderSearch() {
      // let tempDate2 = this.sourceForm.paystartdate
      // if (tempDate2.length > 0) {
      //   tempDate2 = handleDatetime(tempDate2[0]) + '~' + handleDatetime(tempDate2[1])
      // }
      let tempDate = this.sourceForm.createdate
      if (tempDate.length > 0) {
        tempDate = handleDatetime(tempDate[0]) + '~' + handleDatetime(tempDate[1])
      }
      const data = {
        wkshopcode: this.form.wkshopcode, // 车间编码
        mesordercode: this.sourceForm.mesordercode, // 工单编号
        sourceorder: '', // 源单单号
        saleordercode: '', // 销售单号
        partcode: this.sourceForm.partcode, // 产品编码
        partname: this.sourceForm.partname, // 产品名称
        partspec: this.sourceForm.partspec, // 产品规格
        // paystartdate: tempDate2, // 交付时间
        // payenddate: tempDate, // 交付时间
        creatuser: this.sourceForm.creatuser, // 创建人员
        createdate: tempDate, // 创建时间
        prop: this.sourceForm.prop, // 排序字段
        order: this.sourceForm.order, // 排序字段
        page: this.sourceForm.page, // 第几页
        rows: this.sourceForm.rows // 每页多少条
      }
      const res = await MesBadOrderSearch(data)
      this.sourceTableData = res.data
      this.sourceFormTotal = res.count
    },
    // 单选框选中获取当前行信息
    // getCurrentRowSource2(id) {
    //   this.radioSelectedId = id
    // },
    // 单选框选中获取当前行信息
    getCurrentRowSource(row, event, column) {
      this.radioSelectedId = row.id
      this.dialogForm.mesqty = row.bad_qty
    },
    sourceSearch() {
      this.getMesBadOrderSearch()
    },
    sourceReset() {
      this.sourceForm.wkshopcode = ''
      this.sourceForm.mesordercode = ''
      this.sourceForm.sourceorder = ''
      this.sourceForm.partcode = ''
      this.sourceForm.partname = ''
      this.sourceForm.partspec = ''
      // this.sourceForm.paystartdate = ''
      // this.sourceForm.payenddate = ''
      this.sourceForm.creatuser = ''
      this.sourceForm.createdate = ''
      this.getMesBadOrderSearch()
    },
    dialogVisibleSourceClose() {
      this.radioSelectedId = ''
      this.sourceForm.wkshopcode = ''
      this.sourceForm.mesordercode = ''
      this.sourceForm.sourceorder = ''
      this.sourceForm.partcode = ''
      this.sourceForm.partname = ''
      this.sourceForm.partspec = ''
      this.sourceForm.paystartdate = ''
      this.sourceForm.payenddate = ''
      this.sourceForm.creatuser = ''
      this.sourceForm.createdate = ''
      this.isExpandDialog = false
      this.sourceTableData = []
    },
    dialogVisibleSourceBack() {
      this.dialogVisibleSource = false
    },
    dialogVisibleSourceConfirm() {
      console.log(this.radioSelectedId)
      this.sourceTableData.forEach(item => {
        if (item.id === this.radioSelectedId) {
          this.dialogForm.sourceorder = item.wo_code
          this.dialogForm.partcode = item.partcode
          this.dialogForm.partspec = item.partspec
        }
      })
      this.dialogVisibleSource = false
    },
    mesordertypeChange(val) {
      if (val === 'PO') {
        this.dialogForm.sourceorder = ''
        this.dialogForm.partcode = ''
        this.dialogForm.partspec = ''
      }
    },
    /* 关联工艺路线模块*/
    // 关联工艺路线
    async routeClick(row) {
      console.log(row)
      // this.defaultroute_code = row.default_route
      this.dialogFormRoute.projectCode = row.partcode
      this.dialogFormRoute.projectName = row.partname
      this.dialogVisibleRoute = true
      const { data: res } = await InventoryFileAssociationRoute({ partcode: this.dialogFormRoute.projectCode })
      this.dialogFormRoute.routeOperationArr = res
      this.dialogFormRoute.routeOperationArr.forEach((item, index) => {
        item.isSelected1 = false
        item.isSelected2 = false
        if (index === 0) {
          item.isSelected1 = true
          this.projectTableData = item.Data
        }
        if (item.flag === 'Y') {
          item.isSelected2 = true
          this.$nextTick(() => {
            $('input:checkbox').eq(index).prop('checked', true)
          })
        }
      })
      this.defaultroute_codeArr = this.dialogFormRoute.routeOperationArr.filter(item => item.flag === 'Y')
    },
    // 对话框关闭
    handleCloseRoute() {
      this.dialogFormRoute.routeOperationArr = []
      this.defaultroute_codeArr = []
      this.defaultroute_code = ''
      this.projectTableData = []
    },
    // 取消
    routeDialogVisibleCancel() {
      this.dialogVisibleRoute = false
    },
    // 确定
    async routeDialogVisibleConfirm() {
      const temp = this.dialogFormRoute.routeOperationArr.filter(item => item.isSelected2)
      if (this.defaultroute_code === '' && temp.length > 0) {
        return this.$message.info('默认工艺路线不能为空!')
      }
      // 提交格式
      const data = []
      this.dialogFormRoute.routeOperationArr.forEach(item => {
        if (item.isSelected2) {
          data.push({ code: item.code, name: item.name })
        }
      })
      const res = await SaveInventoryFile(this.dialogFormRoute.projectCode, this.defaultroute_code, data)
      if (res.code === '200') {
        this.$message.success('保存成功!')
        await this.getMesOrderSearch()
        this.dialogVisibleRoute = false
      }
    },
    // 大盒子点击事件
    myCheckboxClick(val) {
      console.log(val, 1)
      this.dialogFormRoute.routeOperationArr.forEach(item => {
        item.isSelected1 = val.code === item.code
      })
      this.projectTableData = val.Data
    },
    // 小盒子点击事件
    myCheckboxInputClick(val) {
      console.log(val, 2)
      val.isSelected2 = !val.isSelected2
      this.dialogFormRoute.routeOperationArr.forEach((item, index) => {
        if (val.code === item.code) {
          item.flag = !item.flag
        }
      })
      if (val.code === this.defaultroute_code) {
        this.defaultroute_code = ''
      }
      this.defaultroute_codeArr = this.dialogFormRoute.routeOperationArr.filter(item => item.isSelected2)
    },
    //  行点击事件
    async rowClick(row, event, column) {
      this.formApprove.saleOrderCode = row.saleOrderCode
      this.routeCode = row.route_code ? row.route_code : ''
      this.partCode = row.partcode ? row.partcode : ''
      const data = {
        sourceid: row.sourceid,
        sourcewo: row.m_po,
        wocode: row.wo_code,
        data_sources: row.data_sources
      }
      const { data: res } = await UpdateMesOrderStepSearch(data)
      this.tableDataDetail = res.stepdata
    },
    // 工序删除
    stepDel(row) {
      console.log(row)
      const index = this.stepSelectedValue.findIndex(i => i === row.stepcode)
      this.stepSelectedValue.splice(index, 1)
    },
    // 打印工单
    printOrder() {
    },
    //  选择打印尺寸的大小值改变
    printSizeChange(val) {
      this.$nextTick(() => {
        this.bindQRCode2(this.qrForm.qrvalue)
      })
    },
    printMe2StylePadding(val) {
      if (val === 0) {
        return { paddingLeft: '10px', paddingTop: '5px' }
      }
      if (val === 5) {
        return { paddingLeft: '15px', paddingTop: '7px' }
      }
    },
    inbarcodeChange(val, item) {
      // 当 lastPrintArrSelected中未有当前勾选的值是  走push  item  否则走过滤掉item
      if (val) {
        this.lastPrintArrSelected.push(item)
      } else {
        this.lastPrintArrSelected = this.lastPrintArrSelected.filter(i => i.inbarcode !== item.inbarcode)
      }
      // 生产二维码
      this.$nextTick(() => {
        this.lastPrintArrSelected.forEach((i, index) => {
          console.log(i.inbarcode, 'i.inbarcode')
          new QRCode(this.$refs.qrCodeDiv3[index], {
            text: i.inbarcode,
            width: 60,
            height: 60,
            colorDark: '#000', // 二维码颜色
            colorLight: '#ffffff', // 二维码背景色
            correctLevel: QRCode.CorrectLevel.L// 容错率,L/M/H
          })
        })
        // const div = document.getElementById('qrCode3')
        // div.scrollTop = 0 // 滚动条位于最底部
        this.$forceUpdate()
      }, 500)
    },
    stepSelectedValueChange(val) {
      // console.log(val, 123)
    },
    stepSelectedValueChangeBatchUpdate(val, index) {
      console.log(val, index)
      this.formData3[index].stepTableData = []
      val.forEach(i => {
        this.formData3[index].stepTableData.push({
          stepcode: i,
          stepname: this.stepSelectArr.find(j => j.stepcode === i).stepname,
          stepprice: 0
        })
      })
    },
    getSummaries(param) {
      const { columns, data } = param
      const sums = []
      const i = 9
      columns.forEach((column, index) => {
        if (index === i) {
          sums[index] = '总数'
          return
        }
        const values = data.map(item => Number(item[column.property]))
        if (column.property === 'plan_qty') {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr)
            if (!isNaN(value)) {
              return prev + curr
              // return Math.round(prev * 100) / 100 + Math.round(curr * 100) / 100
            }
          }, 0)
          sums[index] += ' 单'
        }
      })
      this.$nextTick(() => {
        this.$refs.tableDataRef.doLayout()
      })
      return sums
    },
    async printObjGetApi() {
      const res = await UpdateMesOrderPrintCount({ wo_code: this.formApprove.mesordercode })
      if (res.code === '200') {
        await this.getMesOrderSearch()
      }
    }
  }
}
</script>
<style>
.sortable-ghost {
  opacity: .8;
  color: #fff !important;
  background: #42b983 !important;
}
</style>
<style lang="scss" scoped>
$main_color: #42b983;
.stepSelectedValueClass {
  ::v-deep input {
    //min-height: 34px !important;
    height: 68px !important;
  }
}
.dialogVisibleRoute {
  .myCheckboxGroup {
    display: flex;
    flex-wrap: wrap;
    .myCheckbox {
      //border: 1px solid $main_color;
      border: 1px solid #eee;
      display: flex;
      min-width: 100px;
      padding: 10px;
      margin: 10px 30px 0 0;
      border-radius: 5px;
      cursor: default;
      .myCheckboxInput {
        margin: 1px 5px 0 0;
        cursor: pointer;
      }
    }
    //.myCheckbox{
    //  border: 1px solid $main_color;
    //}
    input[type=checkbox] {
      cursor: pointer;
      position: relative;
      width: 14px;
      height: 14px;
      font-size: 14px;
    }
    input[type=checkbox]::after {
      position: absolute;
      top: 0;
      //color: rgb(130, 35, 35);
      color: $main_color;
      width: 14px;
      height: 14px;
      display: inline-block;
      visibility: visible;
      padding-left: 0px;
      text-align: center;
      content: ' ';
      border-radius: 3px
    }
    input[type=checkbox]:checked::after {
      //content: "✓";
      content: "√";
      color: #fff;
      font-size: 12px;
      font-weight: bold;
      background-color: $main_color;
    }
  }
}
.dialogVisibleRoute {
  ::v-deep .el-dialog__body {
    padding: 20px 20px !important;
  }
}
.defaultroute_code ::v-deep .el-input__suffix-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -3px;
}
.el-date-editor {
  font-size: 14px;
}
::v-deep .el-dialog__body {
  padding: 20px 100px !important;
}
.sop {
  ::v-deep .el-dialog__body {
    padding: 50px 80px !important;
  }
}
.dialogVisibleSearch ::v-deep .el-dialog__body {
  padding: 20px 20px !important;
}
.dialogVisibleConfirmClass ::v-deep .el-dialog__body {
  padding: 20px 20px !important;
}
::v-deep .el-table .caret-wrapper {
  transform: scale(0.8);
}
::v-deep .el-button--text {
  color: $main_color;
  font-size: 14px;
  cursor: pointer;
}
::v-deep .el-radio.is-bordered + .el-radio.is-bordered {
  margin: 10px 30px 0px 0;
}
.body ::v-deep .el-form-item {
  margin-bottom: 0;
}
.elForm ::v-deep .el-form-item {
  margin-bottom: 0;
}
.elTableDiv {
  ::v-deep .el-radio__label {
    display: none;
  }
}
.el-table::before {
  height: 0;
}
//.dialogVisibleConfirmClass >>>.el-table--border, .el-table--fit {
//  border-bottom: 2px solid #000 ;
//  //outline: #000 solid 2px !important;
//}
.tableDataPrint ::v-deep div.cell {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.formContent {
  width: 300px;
}
</style>
<style media="print">
/*@media print {*/
@page {
  size: auto;
  margin: 3mm;
}
</style>
<style>
.formContent .el-form-item__label {
  color: #000 !important;
  font-size: 20px;
}
.formContent .el-form-item__content {
  color: #000 !important;
  font-size: 20px;
}
</style>
<!--公共页面样式-->
<style lang="scss" scoped>
$main_color: #42b983;
::v-deep .el-range-input {
  font-size: 14px !important;
}
::v-deep .el-range__icon {
  line-height: 28px !important;
}
::v-deep .el-range-separator {
  line-height: 28px !important;
}
::v-deep .el-range-input {
  font-size: 14px;
}
::v-deep .el-range-separator {
  display: flex;
  justify-content: center;
  align-items: center;
}
//::v-deep .el-button--primary, .el-button--default, .el-button--info {
//  height: 34px;
//  display: flex;
//  align-items: center;
//  padding: 0 15px;
//}
::v-deep .el-button--primary {
  //background-color: $main_color !important;
}
::v-deep .el-button--default {
  background-color: #f8f8fa;
  border: none;
}
::v-deep .el-input__inner {
  height: 34px;
  line-height: 34px;
  //color: #a7a7a7;
}
::v-deep .el-dialog__body {
  padding: 20px 100px !important;
}
::v-deep .dialogVisibleRoles .el-dialog__body {
  padding: 20px 20px !important;
}
::v-deep .importPickerClass .el-dialog__body {
  padding: 20px 20px !important;
}
::v-deep .el-dialog__footer {
  display: flex;
  justify-content: flex-end;
}
::v-deep .el-table .caret-wrapper {
  transform: scale(0.8);
}
::v-deep .cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
::v-deep .el-table::before {
  height: 0;
}
::v-deep .el-table__body-wrapper {
  background-color: #f8f8fa;
}
::v-deep .el-table__body .el-table__row.hover-row td {
  background-color: #eaecef;
}
::v-deep .el-form--inline .el-form-item__label {
  color: #a7a7a7;
}
.body ::v-deep .el-divider {
  border: 1px solid #eee;
  width: 99%;
  margin: 10px auto;
}
.body ::v-deep .el-form-item {
  margin-bottom: 0;
}
.userDialogVisible ::v-deep .el-form-item {
  margin-bottom: 0;
}
.dateMini {
  ::v-deep .el-input__inner {
    line-height: 34px;
    height: 34px;
    width: 200px;
    display: flex;
    font-size: 14px !important;
    align-items: center !important;
  }
  ::v-deep .el-input__prefix {
    margin-top: -3px;
  }
  //::v-deep .el-range__icon{
  //  line-height: 28px;
  //}
}
::v-deep .el-select__caret {
  display: flex;
  align-items: center;
  justify-content: center;
}
.tableFixed {
  ::v-deep .el-table__fixed-right {
    height: 100% !important;
  }
  ::v-deep .el-table__fixed {
    height: 100% !important;
  }
}
.customDiv {
  ::v-deep .el-divider:first-child {
    width: 120%;
    margin-left: -10%;
  }
}
</style>
<style>
.el-table .custom-row {
  background: #f8f8fa;
}
</style>
<style>
.sortable-ghost {
  opacity: .8;
  color: #fff !important;
  background: #42b983 !important;
}
</style>