<template>
  <div>
    <!-- 顶部头部标题部分 -->
    <el-row>
      <el-col
        :span="24"
        class="first-row"
      >
        <div class="tag">重点环节</div>
      </el-col>
    </el-row>
    <el-row>
      <el-col
        :span="24"
        class="second-row"
      > </el-col>
    </el-row>
    <!-- 顶部分割线部分 -->
    <hr style="background-color: #cccccc; height: 1px; border: 0" />
    <!-- 主体表格部分 -->
    <el-tabs type="border-card">
      <!-- 核酸检测选项部分 -->
      <el-tab-pane label="核酸检测">
        <el-row>
          <el-col
            :span="12"
            class="third-row"
          >
            <el-upload
              class="upload-demo"
              action="none"
              accept=".xls,.xlsx"
              :auto-upload="false"
              :limit="1"
              :on-exceed="handleExceed"
              :before-remove="beforeRemove"
              :on-change="checkType"
            >
              <el-button
                class="btnupload"
                slot="trigger"
                size="small"
                type="primary"
              >核酸检测表格导入</el-button>
              <el-button
                class="btnupload"
                style="margin-left: 10px"
                size="small"
                type="success"
                @click="submitUpload"
              >上传到服务器
              </el-button>
              <div
                slot="tip"
                class="el-upload__tip"
              >
                只能上传xls/xlsx文件，且不超过2MB
              </div>
            </el-upload>
            <el-link
              type="primary"
              href="../dist/static/model/NAT.xlsx"
            >模板下载</el-link>
          </el-col>
          <el-col
            :span="12"
            class=""
          >
            <el-button
              type="primary"
              @click="
                dialogFormVisible = true;
                form = {};
              "
            >新增核酸检测</el-button>
          </el-col>

          <!-- 新增核酸检测弹窗 -->
          <el-dialog
            title="新增核酸检测"
            :visible.sync="dialogFormVisible"
          >
            <el-form
              :model="form"
              label-width="auto"
              :rules="rules"
              ref="form"
            >
              <el-form-item
                label="检测对象类别"
                prop="peopleType"
              >
                <el-input v-model="form.peopleType"></el-input>
              </el-form-item>
              <el-form-item
                label="检测人数"
                prop="detectionCount"
              >
                <el-input v-model="form.detectionCount"></el-input>
              </el-form-item>
              <el-form-item
                label="异常人数"
                prop="abnormalCount"
              >
                <el-input v-model="form.abnormalCount"></el-input>
              </el-form-item>
              <el-form-item
                label="检测时间"
                prop="statisticsDate"
              >
                <el-date-picker
                  v-model="form.statisticsDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="选择日期"
                >
                </el-date-picker>
              </el-form-item>
            </el-form>
            <div
              slot="footer"
              class="dialog-footer"
            >
              <el-button
                type="primary"
                @click="addNAT('form')"
              >确 定</el-button>
              <el-button @click="dialogFormVisible = false">取 消</el-button>
            </div>
          </el-dialog>
        </el-row>
        <hr style="background-color: #cccccc; height: 1px; border: 0" />
        <el-row>
          <el-col
            :span="24"
            class="third-row"
          >
            <!-- 核酸检测表单 -->
            <el-table
              v-loading="loading"
              element-loading-text="加载中"
              element-loading-spinner="el-icon-loading"
              :data="tableData"
              style="width: 100%; font-size: 14px"
              highlight-current-row
            >
              <el-table-column
                prop="peopleType"
                label="检测对象类别"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="detectionCount"
                label="检测人数"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="abnormalCount"
                label="异常人数"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="statisticsDate"
                label="检测时间"
                align="center"
              >
              </el-table-column>
              <el-table-column
                label="操作"
                width="280"
                align="center"
              >
                <template slot-scope="{ row }">
                  <el-button
                    type="warning"
                    @click="amendNAT(row)"
                  >修改
                  </el-button>
                  <el-button
                    type="danger"
                    @click="deleteNAT(row.id)"
                  >删除</el-button>
                </template>
              </el-table-column>
            </el-table>
            <!-- 修改核酸检测弹窗 -->
            <el-dialog
              title="修改核酸检测"
              :visible.sync="dialogFormVisible2"
            >
              <el-form
                :model="form"
                label-width="auto"
                :rules="rules"
                ref="form_amend"
              >
                <el-form-item
                  label="检测对象类别"
                  prop="peopleType"
                >
                  <el-input v-model="form.peopleType"></el-input>
                </el-form-item>
                <el-form-item
                  label="检测人数"
                  prop="detectionCount"
                >
                  <el-input v-model="form.detectionCount"></el-input>
                </el-form-item>
                <el-form-item
                  label="异常人数"
                  prop="abnormalCount"
                >
                  <el-input v-model="form.abnormalCount"></el-input>
                </el-form-item>
              </el-form>
              <div
                slot="footer"
                class="dialog-footer"
              >
                <el-button
                  type="primary"
                  @click="hangdleAmendNAT('form_amend')"
                >确 定</el-button>
                <el-button @click="dialogFormVisible2 = false">取 消</el-button>
              </div>
            </el-dialog>
            <!-- 分页器 -->
            <div class="pages">
              <el-pagination
                background
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :page-sizes="[10, 20, 50, 100]"
                :current-page="currentPage"
                :page-size="pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total"
              >
              </el-pagination>
            </div>
          </el-col>
        </el-row>
      </el-tab-pane>
      <!-- 冷链人物同防选项部分 -->
      <el-tab-pane label="冷链人物同防">
        <el-row>
          <el-col
            :span="12"
            class="third-row"
          >
            <el-upload
              class="upload-demo"
              action="none"
              accept=".xls,.xlsx"
              :auto-upload="false"
              :limit="1"
              :on-exceed="handleExceed"
              :before-remove="beforeRemove"
              :on-change="checkType2"
            >
              <el-button
                class="btnupload"
                slot="trigger"
                size="small"
                type="primary"
              >冷链人物同防表格导入</el-button>
              <el-button
                class="btnupload"
                style="margin-left: 10px"
                size="small"
                type="success"
                @click="submitUpload2"
              >上传到服务器
              </el-button>
              <div
                slot="tip"
                class="el-upload__tip"
              >
                只能上传xls/xlsx文件，且不超过2MB
              </div>
            </el-upload>
            <el-link
              type="primary"
              href="../dist/static/model/WithTheCharacters.xlsx"
            >模板下载</el-link>
          </el-col>
          <el-col
            :span="12"
            class=""
          >
            <el-button
              type="primary"
              @click="
                dialogFormVisible_goods = true;
                form2 = {};
              "
            >新增冷链人物同防</el-button>
          </el-col>
          <!-- 新增冷链人物同防弹窗 -->
          <el-dialog
            title="新增冷链人物同防"
            :visible.sync="dialogFormVisible_goods"
          >
            <el-form
              :model="form2"
              label-width="auto"
              :rules="rules2"
              ref="form2"
            >
              <el-form-item
                label="检测对象名称"
                prop="typeName"
              >
                <el-input v-model="form2.typeName"></el-input>
              </el-form-item>
              <el-form-item
                label="屠宰数量（件）"
                prop="slaughterCount"
              >
                <el-input v-model="form2.slaughterCount"></el-input>
              </el-form-item>
              <el-form-item
                label="生产加工数量（件）"
                prop="productionProcessingCount"
              >
                <el-input v-model="form2.productionProcessingCount"></el-input>
              </el-form-item>
              <el-form-item
                label="储存运输数量（件）"
                prop="storageTransportationCount"
              >
                <el-input v-model="form2.storageTransportationCount"></el-input>
              </el-form-item>
              <el-form-item
                label="经营营销数量（件）"
                prop="businessMarketingCount"
              >
                <el-input v-model="form2.businessMarketingCount"></el-input>
              </el-form-item>
              <el-form-item
                label="检测数量合计（件）"
                prop="detectionCount"
              >
                <el-input v-model="form2.detectionCount"></el-input>
              </el-form-item>
              <el-form-item
                label="阳性数量合计（件）"
                prop="abnormalCount"
              >
                <el-input v-model="form2.abnormalCount"></el-input>
              </el-form-item>
              <el-form-item
                label="检测时间"
                prop="statisticsDate"
              >
                <el-date-picker
                  v-model="form2.statisticsDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="选择日期"
                >
                </el-date-picker>
              </el-form-item>
            </el-form>
            <div
              slot="footer"
              class="dialog-footer"
            >
              <el-button
                type="primary"
                @click="addGoods('form2')"
              >确 定</el-button>
              <el-button @click="dialogFormVisible_goods = false">取 消</el-button>
            </div>
          </el-dialog>
        </el-row>
        <hr style="background-color: #cccccc; height: 1px; border: 0" />
        <el-row>
          <el-col
            :span="24"
            class="third-row"
          >
            <!-- 冷链人物同防 -->
            <el-table
              v-loading="loading2"
              element-loading-text="加载中"
              element-loading-spinner="el-icon-loading"
              :data="tableData2"
              style="width: 100%; font-size: 14px"
              highlight-current-row
            >
              <el-table-column
                prop="typeName"
                label="检测对象名称"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="slaughterCount"
                label="屠宰数量（件）"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="productionProcessingCount"
                label="生产加工数量（件）"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="storageTransportationCount"
                label="储存运输数量（件）"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="businessMarketingCount"
                label="经营营销数量（件）"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="detectionCount"
                label="检测数量合计（件）"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="abnormalCount"
                label="阳性数量合计（件）"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="statisticsDate"
                label="检测时间"
                align="center"
              >
              </el-table-column>
              <el-table-column
                label="操作"
                align="center"
                width="300"
              >
                <template slot-scope="{ row }">
                  <el-button
                    type="warning"
                    @click="amendGoods(row)"
                  >修改</el-button>
                  <el-button
                    type="danger"
                    @click="deleteGoods(row.id)"
                  >删除</el-button>
                </template>
              </el-table-column>
            </el-table>
            <!-- 修改冷链人物同防弹窗 -->
            <el-dialog
              title="修改冷链人物同防"
              :visible.sync="dialogFormVisible_goods2"
            >
              <el-form
                :model="form2"
                label-width="auto"
                :rules="rules2"
                ref="form2_amend"
              >
                <el-form-item
                  label="检测对象名称"
                  prop="typeName"
                >
                  <el-input v-model="form2.typeName"></el-input>
                </el-form-item>
                <el-form-item
                  label="屠宰数量（件）"
                  prop="slaughterCount"
                >
                  <el-input v-model="form2.slaughterCount"></el-input>
                </el-form-item>
                <el-form-item
                  label="生产加工数量（件）"
                  prop="productionProcessingCount"
                >
                  <el-input v-model="form2.productionProcessingCount"></el-input>
                </el-form-item>
                <el-form-item
                  label="储存运输数量（件）"
                  prop="storageTransportationCount"
                >
                  <el-input v-model="form2.storageTransportationCount"></el-input>
                </el-form-item>
                <el-form-item
                  label="经营营销数量（件）"
                  prop="businessMarketingCount"
                >
                  <el-input v-model="form2.businessMarketingCount"></el-input>
                </el-form-item>
                <el-form-item
                  label="检测数量合计（件）"
                  prop="detectionCount"
                >
                  <el-input v-model="form2.detectionCount"></el-input>
                </el-form-item>
                <el-form-item
                  label="阳性数量合计（件）"
                  prop="abnormalCount"
                >
                  <el-input v-model="form2.abnormalCount"></el-input>
                </el-form-item>
              </el-form>
              <div
                slot="footer"
                class="dialog-footer"
              >
                <el-button
                  type="primary"
                  @click="hangdleAmendGoods('form2_amend')"
                >确 定</el-button>
                <el-button @click="dialogFormVisible_goods2 = false">取 消</el-button>
              </div>
            </el-dialog>
            <!-- 分页器 -->
            <div class="pages">
              <el-pagination
                background
                @size-change="handleSizeChange2"
                @current-change="handleCurrentChange2"
                :page-sizes="[10, 20, 50, 100]"
                :current-page="currentPage2"
                :page-size="pageSize2"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total2"
              >
              </el-pagination>
            </div>
          </el-col>
        </el-row>
      </el-tab-pane>
      <!-- 发热门诊TOP7选项部分 -->
      <el-tab-pane label="发热门诊TOP7">
        <el-row>
          <el-col
            :span="12"
            class="third-row"
          >
            <el-upload
              class="upload-demo"
              action="none"
              accept=".xls,.xlsx"
              :auto-upload="false"
              :limit="1"
              :on-exceed="handleExceed"
              :before-remove="beforeRemove"
              :on-change="checkType3"
            >
              <el-button
                class="btnupload"
                slot="trigger"
                size="small"
                type="primary"
              >发热门诊TOP7表格导入</el-button>
              <el-button
                class="btnupload"
                style="margin-left: 10px"
                size="small"
                type="success"
                @click="submitUpload3"
              >上传到服务器
              </el-button>
              <div
                slot="tip"
                class="el-upload__tip"
              >
                只能上传xls/xlsx文件，且不超过2MB
              </div>
            </el-upload>
            <el-link
              type="primary"
              href="../dist/static/model/feverClinic.xlsx"
            >模板下载</el-link>
          </el-col>
          <el-col
            :span="12"
            class=""
          >
            <el-button
              type="primary"
              @click="
                dialogFormVisible_hot = true;
                form3 = {};
              "
            >新增发热门诊</el-button>
          </el-col>
        </el-row>
        <!-- 新增发热门诊弹窗 -->
        <el-dialog
          title="新增发热门诊"
          :visible.sync="dialogFormVisible_hot"
        >
          <el-form
            :model="form3"
            label-width="auto"
            :rules="rules3"
            ref="form3"
          >
            <el-form-item
              label="医院名称"
              prop="hospitalName"
            >
              <el-input v-model="form3.hospitalName"></el-input>
            </el-form-item>
            <el-form-item
              label="发热人数"
              prop="feverClinicCount"
            >
              <el-input v-model="form3.feverClinicCount"></el-input>
            </el-form-item>
            <el-form-item
              label="流病史人数"
              prop="epidemicCount"
            >
              <el-input v-model="form3.epidemicCount"></el-input>
            </el-form-item>
            <el-form-item
              label="统计日期"
              prop="statisticsDate"
            >
              <el-date-picker
                v-model="form3.statisticsDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
              >
              </el-date-picker>
            </el-form-item>
          </el-form>
          <div
            slot="footer"
            class="dialog-footer"
          >
            <el-button
              type="primary"
              @click="addHot('form3')"
            >确 定</el-button>
            <el-button @click="dialogFormVisible_hot = false">取 消</el-button>
          </div>
        </el-dialog>
        <hr style="background-color: #cccccc; height: 1px; border: 0" />
        <el-row>
          <el-col
            :span="24"
            class="third-row"
          >
            <!-- 发热门诊TOP7表单 -->
            <el-table
              v-loading="loading3"
              element-loading-text="加载中"
              element-loading-spinner="el-icon-loading"
              :data="tableData3"
              style="width: 100%; font-size: 14px"
              highlight-current-row
            >
              <el-table-column
                prop="hospitalName"
                label="医院名称"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="feverClinicCount"
                label="发热人数"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="epidemicCount"
                label="流病史人数"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="statisticsDate"
                label="统计日期"
                align="center"
              >
              </el-table-column>
              <el-table-column
                label="操作"
                align="center"
                width="300"
              >
                <template slot-scope="{ row }">
                  <el-button
                    type="warning"
                    @click="amendHot(row)"
                  >修改</el-button>
                  <el-button
                    type="danger"
                    @click="deleteHot(row.id)"
                  >删除</el-button>
                </template>
              </el-table-column>
            </el-table>
            <!-- 修改发热门诊弹窗 -->
            <el-dialog
              title="修改发热门诊"
              :visible.sync="dialogFormVisible_hot2"
            >
              <el-form
                :model="form3"
                label-width="auto"
                :rules="rules3"
                ref="form3_amend"
              >
                <el-form-item
                  label="医院名称"
                  prop="hospitalName"
                >
                  <el-input v-model="form3.hospitalName"></el-input>
                </el-form-item>
                <el-form-item
                  label="发热人数"
                  prop="feverClinicCount"
                >
                  <el-input v-model="form3.feverClinicCount"></el-input>
                </el-form-item>
                <el-form-item
                  label="流病史人数"
                  prop="epidemicCount"
                >
                  <el-input v-model="form3.epidemicCount"></el-input>
                </el-form-item>
              </el-form>
              <div
                slot="footer"
                class="dialog-footer"
              >
                <el-button
                  type="primary"
                  @click="hangdleAmendHot('form3_amend')"
                >确 定</el-button>
                <el-button @click="dialogFormVisible_hot2 = false">取 消</el-button>
              </div>
            </el-dialog>

            <!-- 分页器 -->
            <div class="pages">
              <el-pagination
                background
                @size-change="handleSizeChange3"
                @current-change="handleCurrentChange3"
                :page-sizes="[10, 20, 50, 100]"
                :current-page="currentPage3"
                :page-size="pageSize3"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total3"
              >
              </el-pagination>
            </div>
          </el-col>
        </el-row>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: [], // 核酸检测列表
      currentFile: "", // 核酸检测文件
      currentPage: 1, // 核酸检测当前页
      pageSize: 100, // 核酸检测每页记录数
      total: 0, // 核酸检测总行数
      NATid: "",
      dialogFormVisible: false, // 新增核酸检测弹窗控制
      dialogFormVisible2: false, // 修改核酸检测弹窗控制
      loading: true, // 核酸检测列表加载效果
      form: {
        statisticsDate: "",
        peopleType: "",
        detectionCount: "",
        abnormalCount: "",
      },
      rules: {
        statisticsDate: [
          { required: true, message: "请选择统计日期", trigger: "change" },
        ],
        peopleType: [
          { required: true, message: "请输入检测对象类别", trigger: "blur" },
        ],
        detectionCount: [
          { required: true, message: "请输入检测人数", trigger: "blur" },
        ],
        abnormalCount: [
          { required: true, message: "请输入异常人数", trigger: "blur" },
        ],
      },

      tableData2: [], // 人物同防列表
      currentFile2: "", // 人物同防文件
      currentPage2: 1, // 人物同防当前页
      pageSize2: 100, // 人物同防每页记录数
      total2: 0, // 人物同防总行数
      goodsid: "",
      dialogFormVisible_goods: false, // 新增人物同防弹窗控制
      dialogFormVisible_goods2: false, // 修改人物同防弹窗控制
      loading2: true, // 人物同防列表加载效果
      form2: {
        statisticsDate: "",
        typeName: "",
        slaughterCount: "",
        productionProcessingCount: "",
        storageTransportationCount: "",
        businessMarketingCount: "",
        detectionCount: "",
        abnormalCount: "",
      },
      rules2: {
        statisticsDate: [
          { required: true, message: "请选择统计日期", trigger: "change" },
        ],
        typeName: [
          { required: true, message: "请输入检测对象名称", trigger: "blur" },
        ],
        slaughterCount: [
          { required: true, message: "请输入屠宰数量", trigger: "blur" },
        ],
        productionProcessingCount: [
          { required: true, message: "请输入生产加工数量", trigger: "blur" },
        ],
        storageTransportationCount: [
          { required: true, message: "请选择储存运输数量", trigger: "blur" },
        ],
        businessMarketingCount: [
          { required: true, message: "请输入经营营销数量", trigger: "blur" },
        ],
        detectionCount: [
          { required: true, message: "请输入检测总数量", trigger: "blur" },
        ],
        abnormalCount: [
          { required: true, message: "请输入阳性数量", trigger: "blur" },
        ],
      },

      tableData3: [], // 发热门诊列表
      currentFile3: "", // 发热门诊文件
      currentPage3: 1, // 发热门诊当前页
      pageSize3: 100, // 发热门诊每页记录数
      total3: 0, // 发热门诊总行数
      hotId: "",
      dialogFormVisible_hot: false, // 新增发热门诊弹窗控制
      dialogFormVisible_hot2: false, // 修改发热门诊弹窗控制
      loading3: true, // 发热门诊列表加载效果
      form3: {
        statisticsDate: "",
        hospitalName: "",
        feverClinicCount: "",
        epidemicCount: "",
      },
      rules3: {
        statisticsDate: [
          { required: true, message: "请选择统计日期", trigger: "change" },
        ],
        hospitalName: [
          { required: true, message: "请输入医院名称", trigger: "blur" },
        ],
        feverClinicCount: [
          { required: true, message: "请输入发热人数", trigger: "blur" },
        ],
        epidemicCount: [
          { required: true, message: "请输入流病史人数", trigger: "blur" },
        ],
      },

      dateStr: "", // 当前时间戳

      select_datetime1: [], // 选择的时间范围
      select_datetime2: [], // 选择的时间范围
      select_datetime3: [], // 选择的时间范围
      startTime: "",
      endTime: "",
      startTime1: "",
      endTime1: "",
      startTime2: "",
      endTime2: "",
      startTime3: "",
      endTime3: "",
    };
  },
  created() {
    this.get_list();
    this.get_list2();
    this.get_list3();
  },
  methods: {
    //   获取核酸检测列表数据
    async get_list() {
      this.tableData = [];
      let res = await this.$axios.get(
        "/diseaseRight/detectionStatistics/list",
        {
          params: {
            curPage: this.currentPage,
            pageSize: this.pageSize,
          },
        }
      );
      if (res.data.success) {
        this.tableData = res.data.data.list;
        this.total = res.data.data.totalCount;
        this.loading = false;
      } else {
        console.log("请求错误");
      }
    },
    // 新增核酸检测
    addNAT(formName) {
      this.$refs[formName].validate(async (valid) => {
        if (valid) {
          this.dialogFormVisible = false;
          let res = await this.$axios({
            method: "post",
            url: "/diseaseRight/detectionStatistics/save",
            headers: {
              "Admin-Token": sessionStorage.getItem("token"),
            },
            data: this.form,
          });
          // console.log(res);
          if (res.data.success) {
            this.loading = true;
            this.get_list();
            this.$message.success("添加成功!");
          } else {
            this.$message.error("添加失败!");
          }
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    // 修改核酸检测
    amendNAT(row) {
      this.form = { ...row };
      this.form.updateTime = undefined;
      //   console.log(this.form);
      this.NATid = row.id;
      this.dialogFormVisible2 = true;
    },
    // 修改核酸检测请求
    hangdleAmendNAT(formName) {
      this.$refs[formName].validate(async (valid) => {
        if (valid) {
          this.dialogFormVisible2 = false;
          let res = await this.$axios({
            method: "put",
            url: "/diseaseRight/detectionStatistics/update",
            headers: {
              "Admin-Token": sessionStorage.getItem("token"),
            },
            data: this.form,
          });
          // console.log(res);
          if (res.data.success) {
            this.loading = true;
            this.get_list();
            this.$message.success("修改成功!");
          } else {
            this.$message.error("修改失败!");
          }
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    // 删除核酸检测
    deleteNAT(id) {
      this.NATid = id;
      this.$confirm("确定删除吗?", "提示", {
        cancelButtonText: "取消",
        confirmButtonText: "确定",
        type: "warning",
      })
        .then(async () => {
          let res = await this.$axios({
            method: "delete",
            url: "/diseaseRight/detectionStatistics/delete",
            headers: {
              "Admin-Token": sessionStorage.getItem("token"),
            },
            data: [this.NATid],
          });
          if (res.data.success) {
            this.loading = true;
            this.$message.success("删除成功");
            let totalPage = Math.ceil((this.total - 1) / this.pageSize);
            let currentPage =
              this.currentPage > totalPage ? totalPage : this.currentPage;
            this.currentPage = currentPage < 1 ? 1 : currentPage;
            this.get_list();
          } else {
            this.$message.error("删除失败!");
          }
        })
        .catch(() => {
          this.$message.info("已取消");
        });
    },
    // 核酸检测翻页方法
    handleSizeChange(val) {
      this.pageSize = val;
      this.loading = true;
      this.get_list();
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.loading = true;
      this.get_list();
    },
    // 检查核酸检测文件类型大小
    checkType(file, fileList) {
      console.log(fileList);
      let fileType = file.name.substring(file.name.lastIndexOf(".") + 1);
      fileList = [];
      if (fileType !== "xls" && fileType !== "xlsx") {
        this.$message.error("文件格式不正确");
        return false;
      }
      if (file.size / 1024 / 1024 > 2) {
        this.$message.error("文件大小不能超过2M");
        return false;
      }
      this.currentFile = file;
      this.initDate();
    },
    // 上传核酸检测文件
    async submitUpload() {
      if (this.currentFile) {
        let formData = new FormData();
        formData.append("file", this.currentFile.raw);
        let res = await this.$axios({
          method: "post",
          url: `/diseaseRight/detectionStatistics/saveByExcel/${this.dateStr}`,
          headers: {
            "Admin-Token": sessionStorage.getItem("token"),
          },
          data: formData,
        });
        // console.log(res);
        if (res.data.success) {
          this.loading = true;
          this.$message.success("文件上传成功!");
          this.get_list();
        } else {
          this.$message.error("文件上传失败,上传的是否是模板文件!");
          console.log(res.data.message);
        }
      } else {
        this.$message.error("请先导入文件");
        return false;
      }
    },

    // 获取人物同防列表数据
    async get_list2() {
      let res = await this.$axios.get(
        "/diseaseRight/peopleAndGoodsDetectionStatistics/list",
        {
          params: {
            curPage: this.currentPage2,
            pageSize: this.pageSize2,
          },
        }
      );
      if (res.data.success) {
        this.tableData2 = res.data.data.list;
        this.total2 = res.data.data.totalCount;
        this.loading2 = false;
      } else {
        console.log("请求错误");
      }
    },
    // 新增人物同防
    addGoods(formName) {
      this.$refs[formName].validate(async (valid) => {
        if (valid) {
          this.dialogFormVisible_goods = false;
          let res = await this.$axios({
            method: "post",
            url: "/diseaseRight/peopleAndGoodsDetectionStatistics/save",
            headers: {
              "Admin-Token": sessionStorage.getItem("token"),
            },
            data: { datas: [this.form2] },
          });
          // console.log(res);
          if (res.data.success) {
            this.loading2 = true;
            this.get_list2();
            this.$message.success("添加成功!");
          } else {
            this.$message.error("添加失败!");
          }
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    // 修改人物同防
    amendGoods(row) {
      this.form2 = { ...row };
      this.form2.updateTime = undefined;
      this.goodsid = row.id;
      this.dialogFormVisible_goods2 = true;
    },
    // 修改人物同防请求
    hangdleAmendGoods(formName) {
      this.$refs[formName].validate(async (valid) => {
        if (valid) {
          this.dialogFormVisible_goods2 = false;
          let res = await this.$axios({
            method: "put",
            url: "/diseaseRight/peopleAndGoodsDetectionStatistics/update",
            headers: {
              "Admin-Token": sessionStorage.getItem("token"),
            },
            data: this.form2,
          });
          if (res.data.success) {
            this.loading2 = true;
            this.get_list2();
            this.$message.success("修改成功!");
          } else {
            this.$message.error("修改失败!");
          }
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    // 删除人物同防
    deleteGoods(id) {
      this.goodsid = id;
      this.$confirm("确定删除吗?", "提示", {
        cancelButtonText: "取消",
        confirmButtonText: "确定",
        type: "warning",
      })
        .then(async () => {
          let res = await this.$axios({
            method: "delete",
            url: "/diseaseRight/peopleAndGoodsDetectionStatistics/delete",
            headers: {
              "Admin-Token": sessionStorage.getItem("token"),
            },
            data: [this.goodsid],
          });
          if (res.data.success) {
            this.loading2 = true;
            this.$message.success("删除成功");
            let totalPage = Math.ceil((this.total2 - 1) / this.pageSize2);
            let currentPage =
              this.currentPage2 > totalPage ? totalPage : this.currentPage2;
            this.currentPage2 = currentPage < 1 ? 1 : currentPage;
            this.get_list2();
          } else {
            this.$message.error("删除失败!");
          }
        })
        .catch(() => {
          this.$message.info("已取消");
        });
    },
    // 人物同防翻页方法
    handleSizeChange2(val) {
      this.loading2 = true;
      this.pageSize2 = val;
      this.get_list2();
    },
    handleCurrentChange2(val) {
      this.loading2 = true;
      this.currentPage2 = val;
      this.get_list2();
    },
    // 检查人物同防文件类型大小
    checkType2(file, fileList) {
      console.log(fileList);
      let fileType = file.name.substring(file.name.lastIndexOf(".") + 1);
      fileList = [];
      if (fileType !== "xls" && fileType !== "xlsx") {
        this.$message.error("文件格式不正确");
        return false;
      }
      if (file.size / 1024 / 1024 > 2) {
        this.$message.error("文件大小不能超过2M");
        return false;
      }
      this.currentFile2 = file;
      this.initDate();
    },
    // 上传人物同防文件
    async submitUpload2() {
      if (this.currentFile2) {
        let formData = new FormData();
        formData.append("file", this.currentFile2.raw);
        let res = await this.$axios({
          method: "post",
          url: `/diseaseRight/peopleAndGoodsDetectionStatistics/saveByExcel/${this.dateStr}`,
          headers: {
            "Admin-Token": sessionStorage.getItem("token"),
          },
          data: formData,
        });
        // console.log(res);
        if (res.data.success) {
          this.loading2 = true;
          this.$message.success("文件上传成功!");
          this.get_list2();
        } else {
          this.$message.error("文件上传失败,上传的是否是模板文件!");
          console.log(res.data.message);
        }
      } else {
        this.$message.error("请先导入文件");
        return false;
      }
    },

    // 获取发热门诊列表数据
    async get_list3() {
      let res = await this.$axios.get(
        "/diseaseRight/feverClinicOfHospitalStatistics/list",
        {
          params: {
            curPage: this.currentPage3,
            pageSize: this.pageSize3,
          },
        }
      );
      if (res.data.success) {
        this.tableData3 = res.data.data.list;
        // console.log(this.tableData3);
        this.total3 = res.data.data.totalCount;
        this.loading3 = false;
      } else {
        console.log("请求错误");
      }
    },
    // 新增发热门诊
    addHot(formName) {
      this.$refs[formName].validate(async (valid) => {
        if (valid) {
          this.dialogFormVisible_hot = false;
          let res = await this.$axios({
            method: "post",
            url: "/diseaseRight/feverClinicOfHospitalStatistics/save",
            headers: {
              "Admin-Token": sessionStorage.getItem("token"),
            },
            data: { datas: [this.form3] },
          });
          // console.log(this.form3);
          // console.log(res);
          if (res.data.success) {
            this.loading3 = true;
            this.get_list3();
            this.$message.success("添加成功!");
          } else {
            this.$message.error("添加失败!");
          }
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    // 修改发热门诊
    amendHot(row) {
      this.form3 = { ...row };
      this.form3.updateTime = undefined;
      this.hotId = row.id;
      this.dialogFormVisible_hot2 = true;
    },
    // 修改发热门诊请求
    hangdleAmendHot(formName) {
      this.$refs[formName].validate(async (valid) => {
        if (valid) {
          this.dialogFormVisible_hot2 = false;
          let res = await this.$axios({
            method: "put",
            url: "/diseaseRight/feverClinicOfHospitalStatistics/update",
            headers: {
              "Admin-Token": sessionStorage.getItem("token"),
            },
            data: this.form3,
          });
          if (res.data.success) {
            this.loading3 = true;
            this.get_list3();
            this.$message.success("修改成功!");
          } else {
            this.$message.error("修改失败!");
          }
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    // 删除发热门诊
    deleteHot(id) {
      this.hotId = id;
      this.$confirm("确定删除吗?", "提示", {
        cancelButtonText: "取消",
        confirmButtonText: "确定",
        type: "warning",
      })
        .then(async () => {
          let res = await this.$axios({
            method: "delete",
            url: "/diseaseRight/feverClinicOfHospitalStatistics/delete",
            headers: {
              "Admin-Token": sessionStorage.getItem("token"),
            },
            data: [this.hotId],
          });
          if (res.data.success) {
            this.loading3 = true;
            this.$message.success("删除成功");
            let totalPage = Math.ceil((this.total3 - 1) / this.pageSize3);
            let currentPage =
              this.currentPage3 > totalPage ? totalPage : this.currentPage3;
            this.currentPage3 = currentPage < 1 ? 1 : currentPage;
            this.get_list3();
          } else {
            this.$message.error("删除失败!");
          }
        })
        .catch(() => {
          this.$message.info("已取消");
        });
    },
    // 发热门诊翻页方法
    handleSizeChange3(val) {
      this.loading3 = true;
      this.pageSize3 = val;
      this.get_list3();
    },
    handleCurrentChange3(val) {
      this.loading3 = true;
      this.currentPage3 = val;
      this.get_list3();
    },
    // 检查发热门诊文件类型大小
    checkType3(file, fileList) {
      console.log(fileList);
      let fileType = file.name.substring(file.name.lastIndexOf(".") + 1);
      fileList = [];
      if (fileType !== "xls" && fileType !== "xlsx") {
        this.$message.error("文件格式不正确");
        return false;
      }
      if (file.size / 1024 / 1024 > 2) {
        this.$message.error("文件大小不能超过2M");
        return false;
      }
      this.currentFile3 = file;
      this.initDate();
    },
    // 上传发热门诊文件
    async submitUpload3() {
      if (this.currentFile3) {
        let formData = new FormData();
        formData.append("file", this.currentFile3.raw);
        let res = await this.$axios({
          method: "post",
          url: `/diseaseRight/feverClinicOfHospitalStatistics/saveByExcel/${this.dateStr}`,
          headers: {
            "Admin-Token": sessionStorage.getItem("token"),
          },
          data: formData,
        });
        // console.log(res);
        if (res.data.success) {
          this.loading3 = true;
          this.$message.success("文件上传成功!");
          this.get_list3();
        } else {
          this.$message.error("文件上传失败,上传的是否是模板文件!");
          console.log(res.data.message);
        }
      } else {
        this.$message.error("请先导入文件");
        return false;
      }
    },

    //  初始化日期时间
    initDate() {
      //当前设定的日期时间
      let d = new Date();
      var year = d.getFullYear(); // 获取当前年份
      var mon = d.getMonth() + 1; // 获取当前月份
      var day = d.getDate(); // 获取当前日
      this.dateStr = this.getDate(year, mon, day);
    },
    //  获取指定格式 年、月、日
    getDate(y, m, d) {
      m = m > 9 ? m : "0" + m;
      d = d > 9 ? d : "0" + d;

      return y + "-" + m + "-" + d;
    },

    // 文件列表移除文件时的钩子
    beforeRemove(file) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
    // 文件超出个数限制时的钩子
    handleExceed(files, fileList) {
      this.$message.warning("只能同时上传一个文件");
    },
  },
};
</script>

<style scoped>
@import url("zhongdianhuanjie.css");
</style>
