 <template>
  <div class="examination">
    <div class="common-head-search">
      <el-form :inline="true">
        <el-form-item label="物料名称">
          <el-input
            v-model="search.matName"
            size="small"
            @keyup.enter.native="searchData()"
            placeholder="请输入查询内容"
            style="width: 200px; margin-right: 10px"
          ></el-input>
        </el-form-item>
        <el-form-item label="任务日期">
          <el-date-picker
            v-model="search.entrTime"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            size="small"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button
            icon="el-icon-search"
            type="goon"
            size="mini"
            @click="searchData"
            >查询</el-button
          >
          <el-button
            icon="el-icon-refresh"
            type="info"
            plain
            size="mini"
            @click="reset"
            >重置</el-button
          >
        </el-form-item>
      </el-form>
    </div>
    <el-row>
      <el-col :span="9">
        <el-tabs type="border-card" v-model="activeName" @tab-click="tabClick">
          <el-tab-pane label="待接任务" name="first">
            <span slot="label"
              >待接任务<el-badge
                :max="10"
                :hidden="leftPage.totalPage == 0"
                style="margin-top: -18px"
                :value="leftPage.totalPage"
              ></el-badge
            ></span>
            <div class="common-title-div" style="height: auto">
              <div class="common-title-name">
                <img
                  style="width: 25px; height: 25px"
                  src="../../../../assets/img/imgScreen/logo.png"
                />
                未接收
              </div>
              <div>
                <el-button
                  icon="el-icon-check"
                  type="goon"
                  size="mini"
                  :loading="saveLoading"
                  v-privilege="activeMenu + 'receive'"
                  @click="saveData"
                  >接收</el-button
                >
              </div>
            </div>
            <div class="common-table-div">
              <el-table
                v-loading="allDataLoading"
                @selection-change="clickRowData"
                border
                :height="theight3"
                highlight-current-row
                :data="table.data"
                :icore-filter-flag="icoreFilterFlag"
                :header-cell-style="tableHeaderCellStyle"
                :summary-method="getSummaries"
                show-summary
              >
                <el-table-column
                  type="index"
                  label="NO"
                  align="center"
                ></el-table-column>
                <el-table-column
                  type="selection"
                  width="55"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="batchNo"
                  label="批次号"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="matName"
                  label="物料名称"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="planDeptName"
                  label="计划车间"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="gradeName"
                  label="牌号"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="testItemName"
                  label="任务名称"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="140px"
                  prop="taskDate"
                  label="任务日期"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="80px"
                  prop="entrTypeName"
                  label="委托类型"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="80px"
                  prop="sampleTypeName"
                  label="样品类型"
                  align="center"
                ></el-table-column>
                <!-- <el-table-column :show-overflow-tooltip="true" sortable min-width="120px" prop="matName" label="物料名称" align="center"></el-table-column> -->
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="80px"
                  prop="testTypeName"
                  label="检验类型"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="carNo"
                  label="车号"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="120px"
                  prop="pointName"
                  label="取样地点"
                  align="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100px"
                  prop="memo"
                  label="备注"
                  align="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="95px"
                  prop="createMan"
                  label="创建人"
                  align="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="160px"
                  prop="createTime"
                  label="创建时间"
                  align="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="95px"
                  prop="updateMan"
                  label="修改人"
                  align="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="160px"
                  prop="updateTime"
                  label="修改时间"
                  align="center"
                ></el-table-column>
              </el-table>
            </div>
            <div class="common-foot-style">
              <el-pagination
                @size-change="leftPageSize"
                @current-change="leftPageCurrent"
                :current-page="leftPage.pageNum"
                :page-sizes="[100, 200, 500, 800]"
                :page-size="leftPage.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="leftPage.totalPage"
                background
              >
              </el-pagination>
            </div>
          </el-tab-pane>
          <el-tab-pane label="已接任务" name="second">
            <div class="common-title-div" style="height: auto">
              <div class="common-title-name" style="margin-right: 10px">
                <img
                  style="width: 25px; height: 25px"
                  src="../../../../assets/img/imgScreen/logo.png"
                />
                已接收
              </div>
              <div>
                <el-button
                  icon="el-icon-back"
                  type="danger"
                  size="mini"
                  :loading="backLoading"
                  v-privilege="activeMenu + 'back'"
                  @click="back"
                  >退回</el-button
                >
                <el-button
                  icon="el-icon-check"
                  type="goon"
                  size="mini"
                  :loading="subLoading"
                  v-privilege="activeMenu + 'submit'"
                  @click="submitData"
                  >提交</el-button
                >
                <el-button
                  icon="el-icon-check"
                  type="goon"
                  size="mini"
                  @click="samplingInspection"
                  v-privilege="activeMenu + 'inspection'"
                  >取样检验</el-button
                >
                <el-input
                  v-model="values"
                  ref="autoInput"
                  size="mini"
                  style="display: inline-block; width: 150px"
                  @input="autoSubmit()"
                  placeholder="扫码接收"
                  clearable
                  :disabled="inputLoading"
                ></el-input>
                <!-- <el-button icon="el-icon-remove-outline" type="danger" size="mini" @click="declarationData">异常申报</el-button> -->
                <!-- <el-button icon="el-icon-printer" type="goon" size="mini" @click="printQRCode">打印条形码</el-button> -->
              </div>
            </div>
            <div class="common-table-div">
              <el-table
                id="excelTable"
                v-loading="dataLoading"
                ref="dataTable"
                @cell-click="searchFollow"
                border
                :height="theight1"
                highlight-current-row
                :data="table.list"
                :icore-filter-flag="icoreFilterFlag"
                :header-cell-style="tableHeaderCellStyle"
                :cell-class-name="tableRowClassName"
                :summary-method="getSummaries"
                show-summary
              >
                <el-table-column
                  type="index"
                  label="NO"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="batchNo"
                  label="批次号"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="matName"
                  label="物料名称"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="planDeptName"
                  label="计划车间"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="gradeName"
                  label="牌号"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="testItemName"
                  label="任务名称"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="140px"
                  prop="taskDate"
                  label="任务日期"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="140px"
                  prop="checkTime"
                  label="外检时间"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="sampleNo"
                  label="样号"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="80px"
                  prop="stateFlagName"
                  label="状态"
                  align="center"
                ></el-table-column>
                <!-- <el-table-column :show-overflow-tooltip="true" sortable min-width="80px" prop="validFlagName" label="数据状态" align="center"></el-table-column> -->
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="80px"
                  prop="entrTypeName"
                  label="委托类型"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="80px"
                  prop="sampleTypeName"
                  label="样品类型"
                  align="center"
                ></el-table-column>
                <!-- <el-table-column :show-overflow-tooltip="true" sortable min-width="120px" prop="matName" label="物料名称" align="center"></el-table-column> -->
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="80px"
                  prop="testTypeName"
                  label="检验类型"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="carNo"
                  label="车号"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="120px"
                  prop="pointName"
                  label="取样地点"
                  align="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100px"
                  prop="memo"
                  label="备注"
                  align="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="95px"
                  prop="createMan"
                  label="创建人"
                  align="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="160px"
                  prop="createTime"
                  label="创建时间"
                  align="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="95px"
                  prop="updateMan"
                  label="修改人"
                  align="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="160px"
                  prop="updateTime"
                  label="修改时间"
                  align="center"
                ></el-table-column>
              </el-table>
            </div>
            <div class="common-foot-style">
              <el-pagination
                @size-change="pageSizeChange"
                @current-change="pageCurrentChange"
                :current-page="page.pageNum"
                :page-sizes="[10, 20, 50, 100, 200]"
                :page-size="page.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="page.totalPage"
                background
              >
              </el-pagination>
            </div>
          </el-tab-pane>
          <el-tab-pane label="已提交" name="thirdly">
            <div class="common-title-div" style="height: auto">
              <div class="common-title-name" style="margin-right: 10px">
                <img
                  style="width: 25px; height: 25px"
                  src="../../../../assets/img/imgScreen/logo.png"
                />
                已提交
              </div>
              <div>
                <el-button
                icon="el-icon-check"
                type="danger"
                size="mini"
                :loading="rollbackLoading"
                v-privilege="activeMenu + 'submit'"
                @click="rollback"
              >撤回</el-button
              ></div>
            </div>
            <div class="common-table-div">
              <el-table
                id="excelTable"
                v-loading="dataLoading"
                ref="dataTable"
                @cell-click="searchSubData"
                @selection-change="selectRow"
                border
                :height="theight1"
                highlight-current-row
                :data="table.subList"
                :icore-filter-flag="icoreFilterFlag"
                :header-cell-style="tableHeaderCellStyle"
                :cell-class-name="tableRowClassName"
                :summary-method="getSummaries"
                show-summary
              >
                <el-table-column
                  type="index"
                  label="NO"
                  align="center"
                ></el-table-column>
                <el-table-column
                  type="selection"
                  width="45"
                  fixed="left"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="batchNo"
                  label="批次号"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="matName"
                  label="物料名称"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="planDeptName"
                  label="计划车间"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="gradeName"
                  label="牌号"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="testItemName"
                  label="任务名称"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="140px"
                  prop="taskDate"
                  label="任务日期"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="140px"
                  prop="checkTime"
                  label="外检时间"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="sampleNo"
                  label="样号"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="80px"
                  prop="stateFlagName"
                  label="状态"
                  align="center"
                ></el-table-column>
                <!-- <el-table-column :show-overflow-tooltip="true" sortable min-width="80px" prop="validFlagName" label="数据状态" align="center"></el-table-column> -->
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="80px"
                  prop="entrTypeName"
                  label="委托类型"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="80px"
                  prop="sampleTypeName"
                  label="样品类型"
                  align="center"
                ></el-table-column>
                <!-- <el-table-column :show-overflow-tooltip="true" sortable min-width="120px" prop="matName" label="物料名称" align="center"></el-table-column> -->
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="80px"
                  prop="testTypeName"
                  label="检验类型"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="carNo"
                  label="车号"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="120px"
                  prop="pointName"
                  label="取样地点"
                  align="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="100px"
                  prop="memo"
                  label="备注"
                  align="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="95px"
                  prop="createMan"
                  label="创建人"
                  align="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="160px"
                  prop="createTime"
                  label="创建时间"
                  align="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="95px"
                  prop="updateMan"
                  label="修改人"
                  align="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="160px"
                  prop="updateTime"
                  label="修改时间"
                  align="center"
                ></el-table-column>
              </el-table>
            </div>
            <div class="common-foot-style">
              <el-pagination
                @size-change="subPageSizeChange"
                @current-change="subPageCurrentChange"
                :current-page="subPage.pageNum"
                :page-sizes="[10, 20, 50, 100, 200]"
                :page-size="subPage.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="subPage.totalPage"
                background
              >
              </el-pagination>
            </div>
          </el-tab-pane>
        </el-tabs>
      </el-col>
      <el-col :span="15">
        <div class="common-title-div" style="margin-top: 40px; height: auto">
          <div class="common-title-name">
            <img
              style="width: 25px; height: 25px"
              src="../../../../assets/img/imgScreen/logo.png"
            />
            任务项目
          </div>
          <div>
            <el-button
              icon="el-icon-check"
              type="goon"
              size="mini"
              :loading="saveDataLoading"
              v-privilege="activeMenu + 'save'"
              @click="saveDepData"
              >保存</el-button
            >
          </div>
        </div>
        <div class="common-table-div">
          <el-table
            v-loading="dataLoading2"
            ref="dataTable2"
            border
            :height="theight2"
            @row-dblclick="showCell"
            :row-class-name="tableRowName"
            highlight-current-row
            :data="table.list2"
            :icore-filter-flag="icoreFilterFlag"
            :header-cell-style="tableHeaderCellStyle"
            :cell-class-name="tableRowClassName2"
            :summary-method="getSummaries"
            show-summary
          >
            <el-table-column
              type="index"
              label="NO"
              align="center"
            ></el-table-column>
            <el-table-column
              sortable
              :show-overflow-tooltip="true"
              min-width="120px"
              prop="anlyItemName"
              label="分析项目名称"
              align="center"
            ></el-table-column>
            <el-table-column
              sortable
              :show-overflow-tooltip="true"
              min-width="120px"
              prop="anlyValue"
              label="执行结果"
              align="center"
            >
              <template slot-scope="{ row }">
                <el-select
                  :disabled="saveRow.stateFlag == 1"
                  v-if="row.index === tabClickIndex && !row.showInput"
                  clearable
                  allow-create
                  v-model="row.anlyValue"
                  filterable
                  collapse-tags
                  size="small"
                >
                  <el-option
                    v-for="(item, index) in row.defaultList"
                    :key="index"
                    :label="item"
                    :value="item"
                  >
                  </el-option>
                </el-select>
                <el-input
                  :disabled="saveRow.stateFlag == 1"
                  type="number"
                  :min="0"
                  :controls="false"
                  oninput="value=value.replace(/[^0-9.]/g,'')"
                  v-if="row.index === tabClickIndex && row.showInput"
                  @blur="saveCell"
                  v-model="row.anlyValue"
                  @keyup.enter.native="saveCell"
                  size="small"
                  style="width: 100%"
                ></el-input>
                <span v-else>{{ row.anlyValue }}</span>
              </template>
            </el-table-column>
            <el-table-column
              :show-overflow-tooltip="true"
              sortable
              min-width="100"
              align="center"
              prop="unitName"
              label="单位"
            ></el-table-column>
            <el-table-column
              :show-overflow-tooltip="true"
              sortable
              min-width="100"
              align="center"
              prop="formulaName"
              label="计算公式"
            ></el-table-column>
            <el-table-column
              :show-overflow-tooltip="true"
              sortable
              min-width="100"
              align="center"
              prop="reviseRuleName"
              label="修约规则"
            ></el-table-column>
            <!-- <el-table-column :show-overflow-tooltip="true" sortable min-width="120px" prop="defaultValue" label="默认值" align="center"></el-table-column>
            <el-table-column :show-overflow-tooltip="true" sortable min-width="80px" prop="validFlag1" label="数据状态" align="center"></el-table-column> -->
            <el-table-column
              sortable
              :show-overflow-tooltip="true"
              min-width="120px"
              prop="savePath1"
              label="上传图片"
            >
              <template slot-scope="scope">
                <el-upload
                  class="upload"
                  style="display: inline-block"
                  action=""
                  :multiple="false"
                  :show-file-list="false"
                  accept=""
                  :http-request="httpRequest"
                >
                  <el-button
                    type="goon"
                    :disabled="saveRow.stateFlag == 1"
                    size="mini"
                    @click="saveUpload(scope.row)"
                    icon="el-icon-upload2"
                  ></el-button>
                </el-upload>
                <span>{{ scope.row.cretImg.oldFileName }}</span>
              </template>
            </el-table-column>
            <el-table-column
              sortable
              :show-overflow-tooltip="true"
              min-width="100px"
              label="下载、预览"
              align="center"
            >
              <template slot-scope="scope">
                <el-tooltip
                  content="下载文件"
                  placement="bottom"
                  effect="light"
                >
                  <el-button
                    :disabled="!scope.row.cretImg1"
                    type="goon"
                    size="mini"
                    icon="el-icon-download"
                    circle
                    @click="
                      downloadFile(
                        scope.$index,
                        scope.row.id,
                        scope.row.cretImg.fileName,
                        scope.row.cretImg.oldFileName,
                        'LIMS_CRET_TMP_M'
                      )
                    "
                  >
                  </el-button>
                </el-tooltip>
                <el-tooltip
                  content="预览照片"
                  placement="bottom"
                  effect="light"
                >
                  <el-button
                    :disabled="!scope.row.cretImg1"
                    type="warning"
                    size="mini"
                    icon="el-icon-view"
                    circle
                    @click="
                      imgPreView(
                        scope.$index,
                        scope.row.id,
                        scope.row.cretImg.fileName,
                        'LIMS_CRET_TMP_M'
                      )
                    "
                  >
                  </el-button>
                </el-tooltip>
              </template>
            </el-table-column>
            <el-table-column
              sortable
              :show-overflow-tooltip="true"
              min-width="80px"
              prop="memo"
              label="备注"
              align="center"
            ></el-table-column>
            <el-table-column
              sortable
              :show-overflow-tooltip="true"
              min-width="80px"
              prop="createMan"
              label="创建人"
              align="center"
            ></el-table-column>
            <el-table-column
              sortable
              :show-overflow-tooltip="true"
              min-width="140px"
              prop="createTime"
              label="创建时间"
              align="center"
            ></el-table-column>
            <el-table-column
              sortable
              :show-overflow-tooltip="true"
              min-width="80px"
              prop="updateMan"
              label="修改人"
              align="center"
            ></el-table-column>
            <el-table-column
              sortable
              :show-overflow-tooltip="true"
              min-width="140px"
              prop="updateTime"
              label="修改时间"
              align="center"
            ></el-table-column>
            <el-table-column
              sortable
              :show-overflow-tooltip="true"
              min-width="60px"
              prop="isReport"
              label="是否报出"
              align="center"
            ></el-table-column>
          </el-table>
        </div>
        <!-- <div class="common-foot-style">
            <el-pagination  @size-change="pageSizeChange2" @current-change="pageCurrentChange2"
              :current-page="page2.pageNum" :page-sizes="[10, 20, 50, 100, 200]" :page-size="page2.pageSize" layout="total, sizes, prev, pager, next, jumper"
              :total="page2.totalPage" background>
            </el-pagination>
        </div> -->
      </el-col>
    </el-row>
    <!-- 图片预览 -->
    <el-dialog :visible.sync="imgVisible" width="70%">
      <div slot="title" class="titleBox">
        <i class="el-icon-document" style="font-size: 20px"></i>
        <span style="margin-left: 10px; font-size: 18px">图片预览</span>
      </div>
      <div style="text-align: center">
        <img :src="imgPreViews" alt="" />
      </div>
    </el-dialog>
  </div>
</template>
<script>
import {
  getCookie,
  formatDate
} from '@/utils/util.js';
import {
  cookieUserId,
  cookieUserName
} from '@/config/config.js'
import JsBarcode from 'jsbarcode'
let userName = getCookie(cookieUserName);
let userId = getCookie(cookieUserId);
export default {
  data () {
    return {
      table: {
        list: [],
        list2: [],
        data: [],
        subList: []
      },
      saveRow: {},
      allData: [],
      imgVisible: false,
      imgPreViews: '',
      tabClickIndex: null,
      saveLoading: false,
      saveDataLoading: false,
      subLoading: false,
      backLoading: false,
      stopLoading: false,
      startLoading: false,
      allDataLoading: false,
      dataLoading: false,
      dataLoading2: false,
      icoreFilterFlag: true,
      rollbackLoading:false,
      leftPage: {
        pageSize: 200,
        pageNum: 1,
        totalPage: 0
      },
      subPage: {
        pageSize: 50,
        pageNum: 1,
        totalPage: 0
      },
      page: {
        pageSize: 50,
        pageNum: 1,
        totalPage: 0
      },
      page2: {
        pageSize: 50,
        pageNum: 1,
        totalPage: 0
      },
      list: [],
      scId: '',
      showFlag: false,
      Params: {},
      showFlag2: false,
      Params2: {},
      entrOrgNameType: [],
      sampleTypeNameType: [],
      multipleSelection3: [],
      multipleSelection4: [],
      multipleSelect:[],
      theight1: 0,
      theight2: 0,
      theight3: 0,
      search: {
        entrTime: '',
        matName: ''
      },
      uploadFile: {},
      savePlanData: {},
      saveSubRow: {},
      action_prod: window.location.protocol + '//' + window.location.host,
      activeName: 'first',
      activeMenu: '',
      inputLoading: false,
      values: ''
    }
  },
  created () {
    this.theight2 = window.innerHeight - 185 < 249 ? 249 : window.innerHeight - 185
    this.theight3 = window.innerHeight - 230
    this.theight1 = window.innerHeight - 230
    this.search.entrTime = [this.getYNM(new Date()), this.getYNM(new Date())]
    this.activeMenu = window.top.localStorage.getItem('activeMenu')
  },
  mounted () {
    this.searchData()
    // this.addScreen();
    // this.addScreen2()
  },
  methods: {
    getYNM (date) {
      let year = date.getFullYear().toString();
      let month = date.getMonth() + 1;
      let day = date.getDate();
      month = month < 10 ? "0" + month : month;
      day = day < 10 ? "0" + day : day;
      return `${year}-${month}-${day}`;
    },
    getSummaries (param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = "合计";
        }
        if (index === 1) {
          sums[index] = data.length;
        }
      });
      return sums;
    },
    tabClick (tab, event) {
      this.table.list2 = []
    },
    // 扫码打印
    autoSubmit (val) {
      if (!this.values) {
        this.$message.warning('请先用扫码枪扫描标签')
        return
      }
      if (!this.timeId) {
        this.timeId = setTimeout(() => {
          this.inputLoading = true
          this.axios.post('pass/testManagement/v1/limssamplechecks/sampleCheckToScan', {functionCode: '484006', scanCode: this.values, scanName: 'sampleNo'}, { individualType: 'json' }).then(async res => {
            if (res.code == 0 || res.code == 200) {
              this.$message.success('操作成功')
              this.searchData()
            } else {
              this.$message.error(res.message)
            }
            this.values = ''
            this.inputLoading = false
          })
          this.timeId = null;
        }, 1000);
      }
    },
    // 接收
    saveData () {
      if (this.allData.length < 1) {
        this.$message.warning('请点击勾选中未接收外检任务中的数据')
        return
      }
      this.saveLoading = true
      this.axios.post('pass/testManagement/v1/limssamplechecks/saveLimsSampleCheck', this.allData, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.$message.success(res.message);
          this.searchData()
        } else {
          this.$message.error(res.message)
        }
        this.saveLoading = false
      }).catch(e => {
        this.saveLoading = false
        this.$message.error(e.message)
      })
    },
    //提交
    submitData () {
      if (JSON.stringify(this.saveRow) === "{}") {
        this.$message.warning('请点击选中一条您要提交的数据')
        return
      }
      if (this.saveRow.stateFlag != 0) {
        this.$message.warning('请选择状态为已处理的数据提交')
        return
      }
      this.subLoading = true
      this.axios.post('pass/testManagement/v1/limssamplechecks/submit?id=' + this.saveRow.scId).then(res => {
        if (res.succeed) {
          this.$message.success(res.message);
          this.searchData()
        } else {
          this.$message.error(res.message)
        }
        this.subLoading = false
      }).catch(e => {
        this.subLoading = false
        this.$message.error(e.message)
      })
    },
    rollback(){
      if (this.multipleSelect.length == 0){
          this.$message.warning('请至少勾选一条数据!')
          return
      }
      let ids = []
      for (let i=0;i<this.multipleSelect.length;i++){
        ids.push(this.multipleSelect[i].id)
      }
      this.rollbackLoading = true
      this.$confirm('确定退回所有勾选的数据！', '撤回', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.axios.post('pass/testManagement/v1/limssamplechecks/cancelSubmit',ids,{ individualType: 'json' }).then(res => {
          if (res.code == 0 || res.code == 200){
            this.$message.success(res.message)
            this.rollbackLoading = false
            this.searchData()
          }else {
            this.$message.warning(res.message)
            this.rollbackLoading = false
          }
      }).catch(e => {
          this.$message.error(e.message);
          this.rollbackLoading = false
        })
      }).catch(ex => {
        this.$message.warning('取消提交!');
        this.rollbackLoading = false
      })
    },
    // 退回
    back () {
      if (JSON.stringify(this.saveRow) === "{}") {
        this.$message.warning('请点击选中一条您要退回的数据')
        return
      }
      if (this.saveRow.stateFlag != 0) {
        this.$message.warning('该状态不能退回，请选择状态为已处理的数据')
        return
      }
      this.backLoading = true
      this.axios.post('pass/testManagement/v1/limssamplechecks/sendBack?id=' + this.saveRow.id, { individualType: 'json' }).then(res => {
        if (res.succeed) {
          this.$message.success(res.message);
          this.searchData()
        } else {
          this.$message.error(res.message)
        }
        this.backLoading = false
      }).catch(e => {
        this.backLoading = false
        this.$message.error(e.message)
      })
    },
    declarationData () {
      this.$message.warning('此操作为跳转操作，后期完善')
    },
    samplingInspection () { },
    printQRCode () { },
    //删除
    abolishData () {
      if (JSON.stringify(this.saveRow) === "{}") {
        this.$message.warning('请点击选中一条您要停用的数据')
        return
      }
      this.stopLoading = true
      this.axios.post('pass/testManagement/v1/limssamplechecks/inValid?id=' + this.saveRow.scId).then(res => {
        if (res.succeed) {
          this.$message.success(res.message);
          this.searchData()
        } else {
          this.$message.error(res.message)
        }
        this.stopLoading = false
      }).catch(e => {
        this.stopLoading = false
        this.$message.error(e.message)
      })
    },
    // 启用
    recoverData () {
      if (JSON.stringify(this.saveRow) === "{}") {
        this.$message.warning('请点击选中一条您要启用的数据')
        return
      }
      this.startLoading = true
      this.axios.post('pass/testManagement/v1/limssamplechecks/valid?id=' + this.saveRow.scId).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.$message.success(res.message);
          this.searchData()
        } else {
          this.$message.error(res.message)
        }
        this.startLoading = false
      }).catch(e => {
        this.startLoading = false
        this.$message.error(e.message)
      })
    },
    showCell (row) {
      this.tabClickIndex = row.index
    },
    saveCell (row) {
      this.tabClickIndex = null
    },
    tableRowName ({ row, rowIndex }) {
      row.index = rowIndex
    },
    // 保存任务项目数据
    saveDepData () {
      if (this.table.list2.length < 1) {
        this.$message.warning('任务项目表中无数据，不可进行保存');
        return
      }
      if (this.saveSubRow.stateFlag == 1) {
        this.$message.warning('数据已提交，不能进行保存操作，请选择状态为未提交的数据')
        return
      }
      this.table.list2.forEach(item=>{
        item.isReport = item.isReport==='否'?'0':'1'
      })
      this.saveDataLoading = true
      this.axios.post('pass/testManagement/v1/limssamplecheckds/updateLimsSampleCheckDs', this.table.list2, { individualType: 'json' }).then(res => {
        if (res.succeed) {
          this.$message.success('保存成功');
          this.depData(this.scId);
        } else {
          this.$message.error(res.message)
        }
        this.saveDataLoading = false
      }).catch(e => {
        this.saveDataLoading = false
        this.$message.error(e.message)
      })
    },
    //点击选中数据
    clickRowData (val) {
      this.allData = val
    },
    //查询
    searchData () {
      this.page.pageNum = 1;
      this.page.pageSize = 50
      this.subPage.pageNum = 1
      this.subPage.pageSize = 50
      this.leftPage.pageNum = 1
      this.leftPage.pageSize = 200
      this.mainData()
      this.subData()
      this.leftMainData()
    },
    leftMainData () {
      // this.allData = {}
      this.allDataLoading = true;
      let startTime = ''
      let endTime = ''
      if (!this.search.entrTime) {
        startTime = ''
        endTime = ''
      } else {
        startTime = this.search.entrTime[0] + ' 00:00:00'
        endTime = this.search.entrTime[1] + ' 23:59:59'
      }
      let obj = {
        "object": { "matName": this.search.matName },
        'list': [-1],
        'mode': userId,
        'startTime': startTime,
        'endTime': endTime,
        'pageIndex': this.page.pageNum,
        'pageSize': this.page.pageSize
      }
      this.axios.post('pass/testManagement/v1/limssamplechecks/queryLimsSampleCheckPage/', obj, { individualType: 'json' }).then(res => {
        this.allDataLoading = false;
        if (res.code == 0 || res.code == 200) {
          this.table.data = res.data.list;
          this.leftPage.totalPage = res.data.total;
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.allDataLoading = false;
        this.$message.error(e.message)
      });
    },
    mainData () {
      this.saveRow = {}
      this.table.list2 = []
      this.dataLoading = true;
      let startTime = ''
      let endTime = ''
      if (!this.search.entrTime) {
        startTime = ''
        endTime = ''
      } else {
        startTime = this.search.entrTime[0] + ' 00:00:00'
        endTime = this.search.entrTime[1] + ' 23:59:59'
      }
      let obj = {
        "object": { "matName": this.search.matName },
        'list': [0],
        'mode': userId,
        'startTime': startTime,
        'endTime': endTime,
        'pageIndex': this.page.pageNum,
        'pageSize': this.page.pageSize
      }
      this.axios.post('pass/testManagement/v1/limssamplechecks/queryLimsSampleCheckPage/', obj, { individualType: 'json' }).then(res => {
        this.dataLoading = false;
        if (res.code == 0 || res.code == 200) {
          this.table.list = res.data.list;
          this.table.list.forEach(item => {
            item.stateFlagName = item.stateFlag === '-1' ? '未处理' : item.stateFlag === '0' ? '已处理' : item.stateFlag === '1' ? '提交' : ''
            item.validFlagName = item.validFlag === '0' ? '无效' : item.validFlag === '1' ? '有效' : ''
            item.entrTime1 = formatDate(item.entrTime, 'yyyy-MM-dd')
          })
          // if (this.table.list.length > 0) {
          //   this.$refs.dataTable.setCurrentRow(this.table.list[0])
          //   this.searchFollow(this.table.list[0])
          // }
          this.page.totalPage = res.data.total;
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.dataLoading = false;
        this.$message.error(e.message)
      });
    },
    subData () {
      this.saveSubRow = {}
      this.table.list2 = []
      this.dataLoading = true;
      let startTime = ''
      let endTime = ''
      if (!this.search.entrTime) {
        startTime = ''
        endTime = ''
      } else {
        startTime = this.search.entrTime[0] + ' 00:00:00'
        endTime = this.search.entrTime[1] + ' 23:59:59'
      }
      let obj = {
        "object": { "matName": this.search.matName },
        'list': [1],
        'mode': userId,
        'startTime': startTime,
        'endTime': endTime,
        'pageIndex': this.subPage.pageNum,
        'pageSize': this.subPage.pageSize
      }
      this.axios.post('pass/testManagement/v1/limssamplechecks/queryLimsSampleCheckPage/', obj, { individualType: 'json' }).then(res => {
        this.dataLoading = false;
        if (res.code == 0 || res.code == 200) {
          this.table.subList = res.data.list;
          this.table.subList.forEach(item => {
            item.stateFlagName = item.stateFlag === '-1' ? '未处理' : item.stateFlag === '0' ? '已处理' : item.stateFlag === '1' ? '提交' : ''
            item.validFlagName = item.validFlag === '0' ? '无效' : item.validFlag === '1' ? '有效' : ''
            item.entrTime1 = formatDate(item.entrTime, 'yyyy-MM-dd')
          })
          this.subPage.totalPage = res.data.total;
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.dataLoading = false;
        this.$message.error(e.message)
      });
    },
    searchFollow (row) {
      this.saveRow = row
      this.saveSubRow = {}
      this.table.list2 = []
      this.scId = row.scId ? row.scId : ''
      if (!this.scId) {
        return
      }
      this.tabClickIndex = null
      this.page2.pageNum = 1
      this.page2.pageSize = 50
      this.depData(this.scId)
    },
    searchSubData (row) {
      this.saveSubRow = row
      this.saveRow = {}
      this.table.list2 = []
      let scId = row.scId ? row.scId : ''
      if (!scId) {
        return
      }
      this.tabClickIndex = null
      this.page2.pageNum = 1
      this.page2.pageSize = 50
      this.depData(scId)
    },
    selectRow(val){
      this.multipleSelect = val
    },
    depData (id) {
      this.dataLoading2 = true;
      this.axios.post('pass/testManagement/v1/limssamplecheckds/queryLimsSampleCheckD?scId=' + id).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.table.list2 = res.data;
          this.table.list2.forEach(item => {
            item.showInput = item.unitName == '无' ? false : true
            item.defaultList = item.defaultValue ? item.defaultValue.split('#') : []
            item.anlyValue = item.anlyValue ? item.anlyValue : item.defaultList[0]
            item.validFlag1 = item.validFlag === '0' ? '已停用' : item.validFlag === '1' ? '已启用' : ''
            item.isReport = item.isReport === '1' ? '是' : '否'
            if (!item.savePath1) {
              item.cretImg = {}
            } else {
              item.cretImg = JSON.parse(item.savePath1)
            }
            item.cretImg1 = item.cretImg.oldFileName ? item.cretImg.oldFileName : ''
          })
          this.page2.totalPage = res.data.total;
        } else {
          this.$message.error(res.message)
        }
        this.dataLoading2 = false;
      }).catch(e => {
        this.dataLoading2 = false;
        this.$message.error(e.message)
      });
    },
    reset () {
      this.search.matName = '';
      this.search.entrTime = [this.getYNM(new Date()), this.getYNM(new Date())]
      this.searchData();
    },
    handleSelectionChange (val) {
      this.multipleSelection3 = val;
    },
    leftPageSize (size) {
      this.leftPage.pageNum = 1
      this.leftPage.pageSize = size;
      this.leftMainData()
    },
    leftPageCurrent (index) {
      this.leftPage.pageNum = index;
      this.leftMainData()
    },
    pageSizeChange (size) {
      this.page.pageNum = 1
      this.page.pageSize = size;
      this.mainData();
    },
    pageCurrentChange (index) {
      this.page.pageNum = index;
      this.mainData();
    },
    subPageSizeChange (size) {
      this.subPage.pageNum = 1
      this.subPage.pageSize = size;
      this.subData();
    },
    subPageCurrentChange (index) {
      this.subPage.pageNum = index;
      this.subData();
    },
    pageSizeChange2 (size) {
      this.page2.pageNum = 1
      this.page2.pageSize = size;
      this.depData(this.scId);
    },
    pageCurrentChange2 (index) {
      this.page2.pageNum = index;
      this.depData(this.scId);
    },
    addScreen () {
      this.$nextTick(() => {
        let ss = document.createElement('div');
        ss.innerHTML = '筛选';
        ss.style = 'text-align: center;'
        this.$refs.dataTable.$el.getElementsByClassName('el-table__fixed')[0].getElementsByTagName('td')[0].appendChild(ss);
      });
    },
    addScreen2 () {
      this.$nextTick(() => {
        let ss = document.createElement('div');
        ss.innerHTML = '筛选';
        ss.style = 'text-align: center;'
        this.$refs.dataTable2.$el.getElementsByClassName('el-table__fixed')[0].getElementsByTagName('td')[0].appendChild(ss);
      });
    },
    saveUpload (row) {
      this.savePlanData = row
    },
    httpRequest: function (e) {
      if (!e.file) { return false }
      let file = new FormData()
      file.append('file', e.file)
      let config = { headers: { 'Content-Type': 'multipart/form-data' } }
      this.axios.post('pass/testManagement/v1/file/upload', file, config).then(res => {
        if (res.code === '0' || res.code === '200') {
          this.uploadFile = res.data[0]
          this.savePlanData.savePath1 = {}
          this.savePlanData.savePath1.oldFileName = this.uploadFile.oldFileName
          this.savePlanData.savePath1.fileName = this.uploadFile.fileName
          let obj = {
            list: [this.uploadFile.filePk],
            object: {
              objId: this.savePlanData.id,
              objName: "LIMS_SAMPLE_CHECK_D",
            }
          }
          this.axios.post('pass/testManagement/v1/limslrcfilesaves/updateListLrcFileSave', obj, { individualType: 'json' }).then(res => {
            if (res.code == 0 || res.code == 200) {
              this.axios.post('pass/testManagement/v1/limssamplesmpds/update', this.savePlanData, { individualType: 'json' }).then(res => {
                if (res.code == 0 || res.code == 200) {
                  this.$message.success(res.message)
                  this.depData(this.scId);
                } else {
                  this.$message.error(res.message)
                }
              }).catch(e => {
                this.$message.error(e.message)
              })
            } else {
              this.$message.error(res.message)
            }
          }).catch(e => {
            this.$message.error(e.message)
          })
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },
    downloadFile (index, objId, objFileName, oldFileName, objType) {
      let obj = {
        objId: objId,
        objName: objType,
        fileName: objFileName//文件新名字
      }
      let fileRow = {}
      this.axios.post('pass/testManagement/v1/limslrcfilesaves/queryListLrcFileSave', obj, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          fileRow = res.data[res.data.length - 1]
          this.axios.get('pass/testManagement/v1/file/download/' + fileRow.fileName, { responseType: 'blob' }, { headers: { 'content-type': 'application/x-www-form-urlencoded' } }).then(res => {
            let blob = new Blob([res]);
            let fileName = oldFileName;
            let elink = document.createElement('a');
            elink.download = fileName;
            elink.style.display = 'none';
            elink.target = "_blank";
            elink.href = URL.createObjectURL(blob);
            document.body.appendChild(elink);
            elink.click();
            URL.revokeObjectURL(elink.href); // 释放URL对象
            document.body.removeChild(elink);
          })
          // this.download(this.action_prod + fileRow.fileUrl, 'download.txt', 'text/plain', fileRow.oldFileName);
        } else {
          this.$message.error(res.message)
        }
      }).catch(err => {
        this.$message.error(err.message)
      })
    },
    imgPreView (index, objId, objFileName, objType) {
      let obj = {
        objId: objId,
        objName: objType,
        fileName: objFileName
      }
      let fileRow = {}
      this.axios.post('pass/testManagement/v1/limslrcfilesaves/queryListLrcFileSave', obj, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          console.log(this.action_prod, 'this.action_prod');
          fileRow = res.data[res.data.length - 1]
          this.imgPreViews = ''
          this.imgPreViews = this.action_prod + '/icore.icp.web/pass/testManagement/v1/file/download/' + fileRow.fileName
          this.imgVisible = true
          // var form = $('<form>'); // 定义一个form表单
          // form.attr('id', 'downloadform');
          // form.attr('style', 'display:none');
          // form.attr('target', '_blank');
          // form.attr('method', 'get');
          // form.attr('action', this.action_prod + fileRow.fileUrl);
          // var input1 = $('<input>');
          // input1.attr('type', 'hidden');
          // form.append(input1);
          // $('body').append(form); // 将表单放置在web中
          // form.submit(); // 表单提交
          // $('#downloadform').remove();
        } else {
          this.$message.error(res.message)
        }
      }).catch(err => {
        this.$message.error(err.message)
      })
    },
    tableRowClassName ({
      row, column, rowIndex, columnIndex
    }) {
      if (columnIndex === 5) {
        if (row.validFlag !== '1') {
          return 'error-row';
        }
      }
      if (columnIndex === 4) {
        if (row.stateFlag === '1') {
          return 'error-green';
        }
        return '';
      }
    },
    tableRowClassName2 ({
      row, column, rowIndex, columnIndex
    }) {
      if (columnIndex === 5) {
        if (row.validFlag !== '1') {
          return 'error-row';
        }
        return '';
      }
    },
    tableHeaderCellStyle () {
      return 'color: rgb(255,255,255);border-bottom: 1px solid #DCDFE7;'
    }
  }
}
</script>
<style  scoped>
</style>
