 <template>
  <!-- 采样任务-中控 -->
  <div class="examination">
    <div class="common-head-search">
      <el-form :inline="true">
        <el-form-item label="物料名称">
          <el-input
            v-model="search.matName"
            @keyup.enter.native="searchData()"
            size="small"
            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="matName"
                  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
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="120px"
                  prop="suppName"
                  label="发货单位"
                  align="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="120px"
                  prop="acceptName"
                  label="收货单位"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="sampleTypeName"
                  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="100px"
                  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="100px" prop="stdName" label="采样方法" align="center"></el-table-column> -->
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="entrTypeName"
                  label="委托类别"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="pointName"
                  label="取样地点"
                  align="center"
                ></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>
            </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-button icon="el-icon-remove-outline" type="danger" size="mini" @click="declarationData">异常申报</el-button> -->
              </div>
            </div>
            <div class="common-table-div">
              <el-table
                id="excelTable"
                v-loading="dataLoading"
                ref="dataTable"
                @row-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="matName"
                  label="物料名称"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="80px"
                  prop="stateFlag1"
                  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="smpTime"
                  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
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="120px"
                  prop="suppName"
                  label="发货单位"
                  align="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="120px"
                  prop="acceptName"
                  label="收货单位"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="sampleTypeName"
                  label="样品类型"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="testTypeName"
                  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="100px"
                  prop="carNo"
                  label="车号"
                  align="center"
                ></el-table-column>
                <!-- <el-table-column :show-overflow-tooltip="true" sortable min-width="100px" prop="stdName" label="采样方法" align="center"></el-table-column> -->
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="entrTypeName"
                  label="委托类别"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="pointName"
                  label="取样地点"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="ruleId"
                  label="抽样规则"
                  align="left"
                >
                  <template slot-scope="{ row }">
                    <el-button
                      v-show="row.ruleId"
                      type="primary"
                      style="padding: 0"
                      size="mini"
                      @click="searchs(row)"
                      icon="el-icon-search"
                    ></el-button>
                    <span>{{ row.ruleId }}</span>
                  </template>
                </el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="envId"
                  label="环境信息"
                  align="center"
                ></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>
            </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-back"
                  type="danger"
                  size="mini"
                  :loading="backLoading1"
                  v-privilege="activeMenu + 'back'"
                  @click="tuihui"
                  >退回</el-button
                >
                <el-button
                  icon="el-icon-printer"
                  type="goon"
                  size="mini"
                  :loading="printLoading"
                  v-privilege="activeMenu + 'print'"
                  @click="printQRCode"
                  >打印条形码</el-button
                >
              </div>
            </div>
            <div class="common-table-div">
              <el-table
                id="excelTable"
                v-loading="dataLoading"
                @row-click="searchSubData"
                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
                  :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="80px"
                  prop="stateFlag1"
                  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="smpTime"
                  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
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="120px"
                  prop="suppName"
                  label="发货单位"
                  align="center"
                ></el-table-column>
                <el-table-column
                  sortable
                  :show-overflow-tooltip="true"
                  min-width="120px"
                  prop="acceptName"
                  label="收货单位"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="sampleTypeName"
                  label="样品类型"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="testTypeName"
                  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="100px"
                  prop="carNo"
                  label="车号"
                  align="center"
                ></el-table-column>
                <!-- <el-table-column :show-overflow-tooltip="true" sortable min-width="100px" prop="stdName" label="采样方法" align="center"></el-table-column> -->
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="entrTypeName"
                  label="委托类别"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="pointName"
                  label="取样地点"
                  align="center"
                ></el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="ruleId"
                  label="抽样规则"
                  align="left"
                >
                  <template slot-scope="{ row }">
                    <el-button
                      v-show="row.ruleId"
                      type="primary"
                      style="padding: 0"
                      size="mini"
                      @click="searchs(row)"
                      icon="el-icon-search"
                    ></el-button>
                    <span>{{ row.ruleId }}</span>
                  </template>
                </el-table-column>
                <el-table-column
                  :show-overflow-tooltip="true"
                  sortable
                  min-width="100px"
                  prop="envId"
                  label="环境信息"
                  align="center"
                ></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>
            </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="170px"
              prop="anlyValue"
              label="执行结果"
              align="center"
            >
              <template slot-scope="{ row }">
                <el-select
                  :disabled="saveRow.stateFlag == 1"
                  v-if="
                    row.index === tabClickIndex &&
                    !row.showInput &&
                    row.anlyItemName !== '日期'
                  "
                  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-date-picker
                  v-model="row.anlyValue"
                  type="date"
                  size="small"
                  @change="dateChange(row, row.anlyValue)"
                  v-if="
                    row.index === tabClickIndex &&
                    !row.showInput &&
                    row.anlyItemName === '日期'
                  "
                >
                </el-date-picker>
                <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 &&
                    row.anlyItemName !== '日期'
                  "
                  @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 sortable :show-overflow-tooltip="true" min-width="120px" prop="defaultValue" label="默认值" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" 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="100px"
              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>
        </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
      @close="closeDialog"
      :visible.sync="dialogTableVisible"
      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>
      <el-form
        :model="form"
        ref="form"
        v-show="showButton"
        :rules="rules"
        label-width="80px"
        :inline="true"
        size="normal"
      >
        <el-form-item prop="ruleTypeNo" label="规则类型">
          <el-select
            v-model="form.ruleTypeNo"
            filterable
            @change="filterData"
            collapse-tags
            size="small"
          >
            <el-option
              v-for="item in ruleTypeNameType"
              :key="item.baseCode"
              :label="item.baseName"
              :value="item.baseCode"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item prop="ruleNo" label="规则名称" size="normal">
          <el-select
            v-model="form.ruleNo"
            filterable
            collapse-tags
            size="small"
          >
            <el-option
              v-for="item in ruleTypeName"
              :key="item.ruleNo"
              :label="item.ruleName"
              :value="item.ruleNo"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button
            icon="el-icon-search"
            type="goon"
            size="mini"
            :loading="classifyLoading"
            @click="searchRule"
            >查询</el-button
          >
        </el-form-item>
      </el-form>
      <el-row :gutter="20">
        <el-col :span="12">
          <div class="common-title-name">
            <img
              style="width: 25px; height: 25px; margin-left: 20px"
              src="../../../../assets/img/imgScreen/logo.png"
            />
            <span>输入项目</span>
            <el-button
              icon="el-icon-check"
              type="goon"
              v-show="showButton"
              :loading="accountLoading"
              size="mini"
              @click="accounting"
              >核算</el-button
            >
          </div>
          <el-table
            v-loading="dataLoading"
            ref="dataTable"
            highlight-current-row
            border
            :icore-filter-flag="icoreFilterFlag"
            :height="300"
            :data="sample.tableData1"
            :header-cell-style="tableHeaderCellStyle"
          >
            <el-table-column
              type="index"
              label="NO"
              align="center"
            ></el-table-column>
            <el-table-column
              sortable
              :show-overflow-tooltip="true"
              min-width="80px"
              prop="ruleItemName"
              label="输入项目"
              align="center"
            ></el-table-column>
            <el-table-column
              sortable
              :show-overflow-tooltip="true"
              min-width="160px"
              prop="ruleItemValue"
              label="输入结果"
              align="center"
            >
              <template slot-scope="{ row }">
                <el-input
                  v-model="row.ruleItemValue"
                  oninput="value=value.replace(/[^0-9.]/g,'')"
                  style="width: 100%"
                  size="mini"
                ></el-input>
              </template>
            </el-table-column>
          </el-table>
        </el-col>
        <el-col :span="12">
          <div class="common-title-name">
            <img
              style="width: 25px; height: 25px; margin-left: 20px"
              src="../../../../assets/img/imgScreen/logo.png"
            />
            <span>输出项目</span>
          </div>
          <el-table
            v-loading="dataLoading2"
            ref="dataTable2"
            border
            :icore-filter-flag="icoreFilterFlag"
            :height="300"
            :data="sample.tableData2"
            :header-cell-style="tableHeaderCellStyle"
          >
            <el-table-column
              type="index"
              label="NO"
              align="center"
            ></el-table-column>
            <el-table-column
              sortable
              min-width="80px"
              :show-overflow-tooltip="true"
              prop="ruleItemName"
              label="输出项目"
              align="center"
            ></el-table-column>
            <el-table-column
              sortable
              min-width="160px"
              :show-overflow-tooltip="true"
              prop="ruleItemValue"
              label="输出结果"
              align="center"
            ></el-table-column>
          </el-table>
        </el-col>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button
          type="goon"
          size="mini"
          icon="el-icon-check"
          v-show="showButton"
          :loading="addLoading"
          @click="addData"
          >确定</el-button
        >
        <el-button
          size="mini"
          type="goon"
          icon="el-icon-remove-outline"
          @click="closeDialog"
          >取消</el-button
        >
      </span>
    </el-dialog>
    <!-- 图片预览 -->
    <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 id="printContainer2" v-show="false">
      <div id="printContent">
        <div style="height: 180px">
          <!-- <div style="text-align: center">
            <strong style="font-size: 14px">广西北港新材料有限公司</strong>
          </div> -->
          <div>
            <div
              style="
                font-size: 11px;
                margin-left: 20px;
                word-wrap: break-word;
                word-break: normal;
              "
            >
              物料名称：{{
                saveSubRow.matName +
                "(" +
                (saveSubRow.smpDeliName ? saveSubRow.smpDeliName : "") +
                ")"
              }}
            </div>
            <div
              style="
                font-size: 12px;
                font-weight: 800;
                margin-left: 20px;
                word-wrap: break-word;
                word-break: normal;
              "
            >
              样品编号：{{ saveSubRow.sampleNo }}
            </div>
            <div
              style="
                font-size: 12px;
                margin-left: 20px;
                word-wrap: break-word;
                word-break: normal;
              "
            >
              备注信息：{{
                (saveSubRow.carNo ? saveSubRow.carNo : "") +
                "/" +
                (saveSubRow.pointName ? saveSubRow.pointName : "")
              }}
            </div>
            <div
              style="
                font-size: 12px;
                margin-left: 20px;
                word-wrap: break-word;
                word-break: normal;
              "
            >
              生产信息：{{
                (saveSubRow.date ? saveSubRow.date : saveSubRow.smpTimeName) +
                "/" +
                (saveSubRow.classVal ? saveSubRow.classVal : "") +
                "/" +
                (saveSubRow.classify ? saveSubRow.classify : "") +
                "/" +
                (saveSubRow.heatNo ? saveSubRow.heatNo : "")
              }}
            </div>
            <div
              style="
                font-size: 12px;
                margin-left: 20px;
                word-wrap: break-word;
                word-break: normal;
              "
            >
              炉次：{{ saveSubRow.lots }}
            </div>
            <!-- <div style="font-size: 12px; height: 17px; margin-left: 20px">
              班 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;值：{{ saveSubRow.classVal }}
            </div>
            <div style="font-size: 12px; height: 17px; margin-left: 20px">
              班 &nbsp;&nbsp;次：{{ saveSubRow.classify }}
            </div> -->
          </div>
          <div style="text-align: center; margin-bottom: 0; margin-top: 5px">
            <img id="barcode" />
          </div>
          <div style="page-break-after: always"></div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import {
  getCookie,
  formatDate
} from '@/utils/util.js';
import {
  cookieUserId,
  cookieUserName
} from '@/config/config.js'
let userName = getCookie(cookieUserName);
let userId = getCookie(cookieUserId);
import { ajaxCtx } from '@/config/config.js';
import JsBarcode from 'jsbarcode'
export default {
  data () {
    return {
      table: {
        list: [],
        list2: [],
        data: [],
        subList: []
      },
      sample: {
        tableData1: [],
        tableData2: []
      },
      printLoading: false,
      printTest: false,
      subTableData: [],
      saveAccount: {},
      ruleDatas: [],
      ruleTypeName: [],
      rules: {
        ruleTypeNo: [{ required: true, message: '不能为空', trigger: 'change' }],
        ruleNo: [{ required: true, message: '不能为空', trigger: 'change' }],
      },
      tabClickIndex: null,
      showButton: true,
      allDataLoading: false,
      accountLoading: false,
      saveLoading: false,
      saveDataLoading: false,
      subLoading: false,
      backLoading: false,
      dataLoading: false,
      dataLoading2: false,
      icoreFilterFlag: true,
      dialogTableVisible: false,
      form: {
        ruleTypeNo: '',
        ruleNo: ''
      },
      imgPreViews: '',
      imgVisible: 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
      },
      addLoading: false,
      ruleTableData: [],
      classifyLoading: false,
      chooseRow: {},
      saveRow: {},
      allData: [],
      scId: '',
      ruleTypeNameType: [],
      multipleSelection3: [],
      theight1: 0,
      theight2: 0,
      theight3: 0,
      search: {
        entrTime: '',
        matName: ''
      },
      uploadFile: {},
      savePlanData: {},
      saveSubRow: {},
      action_prod: window.location.protocol + '//' + window.location.host,
      activeName: 'first',
      activeMenu: '',
      backLoading1: false
    }
  },
  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.axios.post("pass/baseManagement/v1/limsbaseinfos/queryBaseInfoByBaseCode", { validFlag: 1, baseCode: 4838 }, { individualType: 'json' }).then(res => {
      this.ruleTypeNameType = res.data;
    })
    this.ruleData()
    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;
    },
    getCode (code, arr, codeKey, nameKey) {
      if (!code) {
        return '';
      }
      let targetRow = arr.find(item => {
        return item[codeKey] === code;
      });
      return targetRow ? targetRow[nameKey] : '';
    },
    tabClick (tab, event) {
      this.table.list2 = []
    },
    //筛选出规则名称
    filterData (val) {
      this.ruleTypeName = []
      this.form.ruleNo = ''
      if (!val) {
        this.ruleTypeName = this.ruleDatas
        return
      }
      this.ruleDatas.map(item => {
        if (item.ruleTypeCode == val) {
          this.ruleTypeName.push(item)
        }
      })
    },
    //业务规则按条件查询出符合的数据
    searchRule () {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.saveAccount = {}
          this.sample.tableData1 = []
          this.sample.tableData2 = []
          this.subTableData = []
          this.classifyLoading = true
          this.axios.post('pass/baseManagement/v1/limsbaseruleds/queryLimsBaseRuleDList', { ruleNo: this.form.ruleNo }, { individualType: 'json' }).then(res => {
            if (res.code == 0 || res.code == 200) {
              let data = res.data
              this.subTableData = data
              data.forEach(item => {
                item.ruleItemValue = item.ruleItemValue ? item.ruleItemValue : item.defaultValue
                if (item.isPara == 1) {
                  this.sample.tableData1.push(item)
                } else {
                  this.sample.tableData2.push(item)
                }
                this.classifyLoading = false
              })
            } else {
              this.classifyLoading = false
              this.$message.error(res.message)
            }
            this.saveLoading = false
          }).catch(e => {
            this.saveLoading = false
            this.$message.error(e.message)
          })
        }
      });
    },
    accountClick (row) {
      this.saveAccount = row
    },
    //核算
    accounting () {
      if (this.sample.tableData1.length < 1) {
        this.$message.warning('表格中无数据,无法进行核算')
        return
      }
      let flag = false
      let data1 = ''
      let data2 = ''
      this.sample.tableData1.forEach(item => {
        if (!item.ruleItemValue) {
          flag = true
        }
        if (item.ruleItemOrder == 1) {
          data1 = item.ruleItemValue
        } else if (item.ruleItemOrder == 2) {
          data2 = item.ruleItemValue
        }
      })
      if (flag) {
        this.$message.warning('表格中的输入结果不能为空')
        return
      }
      this.accountLoading = true
      let data = this.getCode(this.form.ruleNo, this.ruleTypeName, 'ruleNo', 'callApi')
      let objdata = {
        method: data,
        parameter: {
          'proportion': data1,
          'sampleNum': data2,
        }
      }
      this.axios.post('pass/testManagement/v1/api/reflection/executeDyMethodUtil', objdata, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          //将数组重新赋值，解决DOM树不重新渲染的问题
          let data = JSON.parse(JSON.stringify(this.sample.tableData2))
          this.sample.tableData2 = []
          //如果规则名称为比率抽样,则将返回的数据进行拆分
          if (this.form.ruleNo == 'R0004') {
            //1.将返回的字符串转换成对象 2.将对象的key,value循环出来
            let resultData = JSON.parse(res.data)
            let resultKeys = Object.keys(resultData)
            let resultValues = Object.values(resultData)
            data.forEach((item, index) => {
              let indexs = resultKeys.findIndex(items => item.ruleItemName == items)
              item.ruleItemValue = resultValues[indexs] instanceof Array ? JSON.stringify(resultValues[indexs]) : resultValues[indexs]
            })
          } else {
            data.forEach(item => {
              item.ruleItemValue = res.data
            })
          }
          this.sample.tableData2 = data
          this.$message.success(res.message);
        } else {
          this.$message.error(res.message)
        }
        this.accountLoading = false
      }).catch(e => {
        this.accountLoading = false
        this.$message.error(e.message)
      })
    },
    //抽样弹出框
    samplingInspection () {
      if (JSON.stringify(this.saveRow) === "{}") {
        this.$message.warning('请点击选中一条您要抽样的数据')
        return
      }
      this.dialogTableVisible = true
    },
    //抽样保存
    addData () {
      if (this.sample.tableData2.length < 1) {
        this.$message.warning('输出项目中无数据，请先查询要执行此操作的数据')
        return
      }
      for (let i = 0; i < this.sample.tableData2.length; i++) {
        if (!this.sample.tableData2[i].ruleItemValue) {
          this.$message.warning('输出项目中无输出结果，不能进行确定操作')
          return
        }
      }
      // 合并已接收任务数据
      let obj = Object.assign({}, this.saveRow)
      //通过规则名称查询出对应的数据行
      let tempData = this.ruleTypeName.find(item => {
        if (item.ruleNo == this.form.ruleNo) {
          return item
        }
      })
      obj.limsBaseRule = tempData
      let tempArr = JSON.parse(JSON.stringify(this.sample.tableData1))
      this.sample.tableData2.map(item => {
        tempArr.push(item)
      })
      obj.limsBaseRuleDS = tempArr
      this.addLoading = true
      this.axios.post('pass/testManagement/v1/limssamplesmps/sampling', obj, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.dialogTableVisible = false
          this.$message.success(res.message);
          this.searchData()
        } else {
          this.$message.error(res.message)
        }
        this.addLoading = false
      }).catch(e => {
        this.addLoading = false
        this.$message.error(e.message)
      })
    },
    // 日期选中
    dateChange (item, val) {
      if (val) {
        item.anlyValue = formatDate(val, 'yyyy-MM-dd')
      }
    },
    closeDialog () {
      this.saveAccount = {}
      this.form = {
        ruleNo: '',
        ruleTypeNo: ''
      }
      this.sample.tableData1 = []
      this.sample.tableData2 = []
      this.showButton = true
      this.addLoading = false
      this.dialogTableVisible = false
    },
    //查看抽样规则
    searchs (row) {
      this.axios.post('pass/testManagement/v1/limsdataruleds/queryLimsDataRuleDByRuleId?ruleId=' + row.ruleId, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          let data = res.data
          data.forEach(item => {
            if (item.isPara == 1) {
              this.sample.tableData1.push(item)
            } else {
              this.sample.tableData2.push(item)
            }
          })
          this.showButton = false
          this.dialogTableVisible = true
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },
    // 查询规则名称数据
    ruleData () {
      this.ruleDatas = []
      this.ruleTypeName = []
      let obj = {
        object: {
          ruleTypeCode: this.form.ruleTypeNo,
          validFlag: 1
        },
        pageIndex: 1,
        pageSize: 9999,
      }
      this.axios.post('pass/baseManagement/v1/limsbaserules/queryLimsBaseRuleInfoPage', obj, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          let data = res.data.list
          data.forEach(item => {
            item.validFlag1 = item.validFlag == 0 ? '无效' : item.validFlag == 1 ? '有效' : ''
          })
          this.ruleTypeName = this.ruleDatas = data
        } else {
          this.$message.error(res.message)
        }
        this.saveLoading = false
      }).catch(e => {
        this.saveLoading = false
        this.$message.error(e.message)
      })
    },
    // 接收
    saveData () {
      if (this.allData.length < 1) {
        this.$message.warning('请点击勾选中未接收采样任务中的数据')
        return
      }
      this.saveLoading = true
      this.axios.post('pass/testManagement/v1/limssamplesmps/saveLimsSampleSmp', 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.saveDataLoading = true
      this.axios.post('pass/testManagement/v1/limssamplesmpds/updateLimsSampleSmpDs', this.table.list2, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.axios.post('pass/testManagement/v1/limssamplesmps/submitLimsSampleSmp?id=' + this.saveRow.ssId).then(res => {
            if (res.code == 0 || res.code == 200) {
              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)
          })
        } else {
          this.subLoading = false
          this.$message.error(res.message)
        }
        this.saveDataLoading = false
      }).catch(e => {
        this.subLoading = false
        this.saveDataLoading = false
        this.$message.error(e.message)
      })
    },
    // 退回
    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/limssamplesmps/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)
      })
    },
    // 退回
    tuihui () {
      if (JSON.stringify(this.saveSubRow) === "{}") {
        this.$message.warning('请点击选中一条您要退回的数据')
        return
      }
      this.backLoading1 = true
      this.axios.post('pass/testManagement/v1/limssamplesmps/sendBackToSubmit?id=' + this.saveSubRow.id, { individualType: 'json' }).then(res => {
        if (res.succeed) {
          this.$message.success(res.message);
          this.searchData()
        } else {
          this.$message.error(res.message)
        }
        this.backLoading1 = false
      }).catch(e => {
        this.backLoading1 = false
        this.$message.error(e.message)
      })
    },
    declarationData () {
      this.$message.warning('此操作为跳转操作，后期完善')
    },
    // 获取任务项目
    getAnlyItem (list) {
      let classVal = '', classify = '', lots = '', date = ''
      if (list.length > 0) {
        let val = list.find(y => y.anlyItemName === '班别');
        let groupClass = list.find(u => u.anlyItemName === '班次');
        let heatClass = list.find(u => u.anlyItemName === '炉次');
        let dateClass = list.find(u => u.anlyItemName === '日期');
        if (val) {
          classVal = val['anlyValue']
        }
        if (groupClass) {
          classify = groupClass['anlyValue']
        }
        if (heatClass) {
          lots = heatClass['anlyValue']
        }
        if (dateClass) {
          date = dateClass['anlyValue']
        }
      }
      return {
        classVal,
        classify,
        lots,
        date
      }
    },
    async getMoreMsg () {
      const data = await this.axios.post('pass/testManagement/v1/limssamplepreps/saveLimsSamplePrepToScan', { scanCode: this.saveSubRow.markNo, scanName: 'markNo' }, { individualType: 'json' })
      console.log(data, '获取信息')
      let { shift, team } = data.data.limsSamplePreps
      return { shift, team }
    },
    // 打印条形码
    async printQRCode () {
      if (JSON.stringify(this.saveSubRow) === "{}") {
        this.$message.warning('请点击您要打印的数据')
        return
      }
      if (this.saveSubRow.stateFlag != 1) {
        this.$message.warning('未提交的数据不能进行打印操作，请选择已提交的数据')
        return
      }
      // const { shift, team } = await this.getMoreMsg()
      const { classVal, classify, lots, date } = this.getAnlyItem(this.table.list2)
      console.log(classVal, classify, lots, date)
      this.saveSubRow.classVal = classVal
      this.saveSubRow.classify = classify
      this.saveSubRow.lots = lots
      this.saveSubRow.date = date
      // 或者该数据的分析项目
      this.saveSubRow.smpTimeName = this.saveSubRow.smpTime ? formatDate(this.saveSubRow.smpTime, 'yyyy-MM-dd') : '';
      JsBarcode("#barcode", this.saveSubRow.sampleNo, {
        format: 'CODE128',
        lineColor: '#000',
        background: '#fff',
        width: 1,
        height: 35,
        displayValue: false
      })
      this.printLoading = true
      setTimeout(() => {
        this.printLoading = false
        this.printPage('printContent');
      }, 1500)
    },
    //删除
    abolishData () {
      if (this.multipleSelection3.length < 1) {
        this.$message.warning('请勾选一条您要停用的数据！')
        return
      }
      if (this.multipleSelection3.length !== 1) {
        this.$message.warning('每次只能一条数据！')
        return
      }
      let obj = {}
      this.multipleSelection3.forEach(item => {
        obj = item
      })
      this.axios.post('pass/testManagement/v1/limssamplesmps/inValid?id=' + obj.ssId).then(res => {
        if (res.succeed) {
          this.$message.success('停用成功');
          this.searchData()
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },
    // 启用
    recoverData () {
      if (this.multipleSelection3.length < 1) {
        this.$message.warning('请勾选一条您要启用的数据！')
        return
      }
      if (this.multipleSelection3.length !== 1) {
        this.$message.warning('每次只能一条数据！')
        return
      }
      let obj = {}
      this.multipleSelection3.forEach(item => {
        obj = item
      })
      this.axios.post('pass/testManagement/v1/limssamplesmps/valid?id=' + obj.ssId).then(res => {
        if (res.succeed) {
          this.$message.success('启用成功');
          this.searchData()
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        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.saveDataLoading = true
      this.axios.post('pass/testManagement/v1/limssamplesmpds/updateLimsSampleSmpDs', this.table.list2, { individualType: 'json' }).then(res => {
        if (res.succeed) {
          this.$message.success(res.message);
          this.depData(this.scId);
        } else {
          this.$message.error(res.message)
        }
        this.saveDataLoading = false
      }).catch(e => {
        this.saveDataLoading = false
        this.$message.error(e.message)
      })
    },
    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_SMP_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)
      })
    },
    //查询
    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()
    },
    //点击选中数据
    clickRowData (val) {
      this.allData = val
    },
    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,
          'sampleTypeCode': '480102'
        },
        'list': [-1],
        'mode': userId,
        'startTime': startTime,
        'endTime': endTime,
        'pageIndex': this.leftPage.pageNum,
        'pageSize': this.leftPage.pageSize,
      }
      this.axios.post('pass/testManagement/v1/limssamplesmps/queryLimsSampleSmpPage/', 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,
          'sampleTypeCode': '480102'
        },
        'list': [0],
        'mode': userId,
        'startTime': startTime,
        'endTime': endTime,
        'pageIndex': this.page.pageNum,
        'pageSize': this.page.pageSize,

      }
      this.axios.post('pass/testManagement/v1/limssamplesmps/queryLimsSampleSmpPage/', 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.stateFlag1 = 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,
          'sampleTypeCode': '480102'
        },
        'list': [1],
        'mode': userId,
        'startTime': startTime,
        'endTime': endTime,
        'pageIndex': this.subPage.pageNum,
        'pageSize': this.subPage.pageSize,

      }
      this.axios.post('pass/testManagement/v1/limssamplesmps/queryLimsSampleSmpPage/', 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.stateFlag1 = 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.ssId ? row.ssId : ''
      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.ssId ? row.ssId : ''
      if (!scId) {
        return
      }
      this.tabClickIndex = null
      this.page2.pageNum = 1
      this.page2.pageSize = 50
      this.depData(scId)
    },
    depData (id) {
      this.dataLoading2 = true;
      this.axios.post('pass/testManagement/v1/limssamplesmpds/queryLimsSampleSmpD?ssId=' + id).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.table.list2 = res.data;
          this.table.list2.forEach(item => {
            if (item.anlyItemName === '日期' && item.anlyValue - 0 === 0) {
              item.anlyValue = formatDate(new Date(), 'yyyy-MM-dd')
            }
            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' ? '已启用' : ''
            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);
      });
    },
    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 +'/icore.icp.web/pass/testManagement/v1/file/download/' + fileRow.fileName);
          // 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 === 8) {
        if (row.validFlag !== '1') {
          return 'error-row';
        }
      }
      if (columnIndex === 1) {
        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>
.el-dialog__wrapper .el-dialog .el-dialog__header {
  height: 56px;
  background: rgb(64, 158, 255);
  border-radius: 4px 4px 0 0;
  color: #fff;
  padding: 14px 24px !important;
}
</style>
