quanyawei
2023-10-09 b760e4eea2fc4f56347ac26ca8bde97b15e164e5
src/views/air/index.vue
@@ -1,123 +1,157 @@
<template>
  <div class="analyseAir">
<!--    头部-->
    <!--    头部-->
    <div class="exTop">
      <div class="cascader-demo">
        <el-select v-model="value" clearable placeholder="请选择地区">
          <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </div>
      <el-date-picker
          v-if="value==='gx'"
          v-model="value3"
          style="margin-right: 5%"
          align="right"
          type="date"
          placeholder="选择日期">
        v-model="value3"
        style="margin-right: 5%"
        align="right"
        type="date"
        placeholder="选择日期"
      >
      </el-date-picker>
      <el-upload
          v-if="value==='gx'"
          class="upload-demo"
          ref="upload1"
          action=""
          accept="xlsx"
          :on-change="handleChange"
          :on-remove="handleRemove"
          :file-list="fileList"
          :limit="1"
          :on-exceed="handleExceed"
          multiple
          :auto-upload="false">
        <el-button slot="trigger" type="primary" size="small">选取文件</el-button>
        <div slot="tip" class="el-upload__tip">上传四国控及市区均值</div>
        v-if="value === 'gx'"
        class="upload-demo"
        ref="upload1"
        action=""
        accept="xlsx"
        :on-change="handleChange"
        :on-remove="handleRemove"
        :file-list="fileList"
        :limit="1"
        :on-exceed="handleExceed"
        multiple
        :auto-upload="false"
      >
        <el-button slot="trigger" type="primary" size="small"
          >选取文件</el-button
        >
        <div slot="tip" class="el-upload__tip" v-if="value === 'gx'">
          上传四国控及市区均值
        </div>
        <div slot="tip" class="el-upload__tip" v-else></div>
      </el-upload>
      <el-upload
          v-if="value==='gx'"
          class="upload-demo"
          ref="upload2"
          action=""
          accept="xlsx"
          :on-change="handleChange2"
          :on-remove="handleRemove2"
          :file-list="fileList2"
          :limit="1"
          :on-exceed="handleExceed"
          multiple
          :auto-upload="false">
        <el-button slot="trigger" type="primary" size="small">选取文件</el-button>
        <div slot="tip" class="el-upload__tip">上传乡镇街道日数据</div>
        v-if="value === 'gx'"
        class="upload-demo"
        ref="upload2"
        action=""
        accept="xlsx"
        :on-change="handleChange2"
        :on-remove="handleRemove2"
        :file-list="fileList2"
        :limit="1"
        :on-exceed="handleExceed"
        multiple
        :auto-upload="false"
      >
        <el-button slot="trigger" type="primary" size="small"
          >选取文件</el-button
        >
        <div slot="tip" class="el-upload__tip" v-if="value === 'gx'">
          上传乡镇街道日数据
        </div>
        <div slot="tip" class="el-upload__tip" v-else></div>
      </el-upload>
      <el-upload
          v-if="value==='gx'"
          class="upload-demo"
          ref="upload3"
          action=""
          accept="xlsx"
          :on-change="handleChange3"
          :on-remove="handleRemove3"
          :file-list="fileList3"
          :limit="1"
          :on-exceed="handleExceed"
          multiple
          :auto-upload="false">
        <el-button slot="trigger" type="primary" size="small">选取文件</el-button>
        <div slot="tip" class="el-upload__tip">上传乡镇街道月累计</div>
        v-if="value === 'gx'"
        class="upload-demo"
        ref="upload3"
        action=""
        accept="xlsx"
        :on-change="handleChange3"
        :on-remove="handleRemove3"
        :file-list="fileList3"
        :limit="1"
        :on-exceed="handleExceed"
        multiple
        :auto-upload="false"
      >
        <el-button slot="trigger" type="primary" size="small"
          >选取文件</el-button
        >
        <div slot="tip" class="el-upload__tip" v-if="value === 'gx'">
          上传乡镇街道月累计
        </div>
        <div slot="tip" class="el-upload__tip" v-else></div>
      </el-upload>
      <el-upload
          v-if="value==='gx'"
          class="upload-demo"
          ref="upload4"
          action=""
          accept="xlsx"
          :on-change="handleChange4"
          :on-remove="handleRemove4"
          :file-list="fileList4"
          :limit="1"
          :on-exceed="handleExceed"
          multiple
          :auto-upload="false">
        <el-button slot="trigger" type="primary" size="small">选取文件</el-button>
        <div slot="tip" class="el-upload__tip">上传乡镇街道改善数据</div>
        v-if="value === 'gx'"
        class="upload-demo"
        ref="upload4"
        action=""
        accept="xlsx"
        :on-change="handleChange4"
        :on-remove="handleRemove4"
        :file-list="fileList4"
        :limit="1"
        :on-exceed="handleExceed"
        multiple
        :auto-upload="false"
      >
        <el-button slot="trigger" type="primary" size="small"
          >选取文件</el-button
        >
        <div slot="tip" class="el-upload__tip" v-if="value === 'gx'">
          上传乡镇街道改善数据
        </div>
        <div slot="tip" class="el-upload__tip" v-else></div>
      </el-upload>
      <el-upload
          v-if="value==='gx'"
          class="upload-demo"
          ref="upload5"
          action=""
          accept="xlsx"
          :on-change="handleChange5"
          :on-remove="handleRemove5"
          :file-list="fileList5"
          :limit="1"
          :on-exceed="handleExceed"
          multiple
          :auto-upload="false">
        <el-button slot="trigger" type="primary" size="small">选取文件</el-button>
        <div slot="tip" class="el-upload__tip">上传国控改善数据</div>
        v-if="value === 'gx'"
        class="upload-demo"
        ref="upload5"
        action=""
        accept="xlsx"
        :on-change="handleChange5"
        :on-remove="handleRemove5"
        :file-list="fileList5"
        :limit="1"
        :on-exceed="handleExceed"
        multiple
        :auto-upload="false"
      >
        <el-button slot="trigger" type="primary" size="small"
          >选取文件</el-button
        >
        <div slot="tip" class="el-upload__tip" v-if="value === 'gx'">
          上传国控改善数据
        </div>
        <div slot="tip" class="el-upload__tip" v-else></div>
      </el-upload>
      <el-upload
          v-if="value==='gx'"
          class="upload-demo"
          ref="upload6"
          action=""
          accept="xlsx"
          :on-change="handleChange6"
          :on-remove="handleRemove6"
          :file-list="fileList6"
          :limit="1"
          :on-exceed="handleExceed"
          multiple
          :auto-upload="false">
        <el-button slot="trigger" type="primary" size="small">选取文件</el-button>
        v-if="value === 'gx'"
        class="upload-demo"
        ref="upload6"
        action=""
        accept="xlsx"
        :on-change="handleChange6"
        :on-remove="handleRemove6"
        :file-list="fileList6"
        :limit="1"
        :on-exceed="handleExceed"
        multiple
        :auto-upload="false"
      >
        <el-button slot="trigger" type="primary" size="small"
          >选取文件</el-button
        >
        <div slot="tip" class="el-upload__tip">上传餐饮油烟超标数据</div>
      </el-upload>
<!--      <el-upload
          v-if="value==='gx'"
      <div v-if="value === 'hn'" style="position: relative">
        <el-upload
          class="upload-demo"
          ref="upload7"
          action=""
@@ -128,11 +162,25 @@
          :limit="1"
          :on-exceed="handleExceed"
          multiple
          :auto-upload="false">
        <el-button slot="trigger" type="primary" size="small">选取文件</el-button>
        <div slot="tip" class="el-upload__tip">上传数据</div>
      </el-upload>
      <el-upload
          :auto-upload="false"
        >
          <el-button slot="trigger" type="primary" size="small"
            >选取文件</el-button
          >
          <div slot="tip" class="el-upload__tip">
            请上传国控点位日污染物浓度及AQI文件
          </div>
        </el-upload>
        <el-button
          type="success"
          @click="submitUpload"
          :disabled="idDisabled"
          size="small"
          style="position: absolute; right: 20%; bottom: -100%"
          >提交文件</el-button
        >
      </div>
      <!--      <el-upload
          v-if="value==='gx'"
          class="upload-demo"
          ref="upload8"
@@ -148,86 +196,117 @@
        <el-button slot="trigger" type="primary" size="small">选取文件</el-button>
        <div slot="tip" class="el-upload__tip">上传数据</div>
      </el-upload>-->
      <div style="position: absolute; bottom: 2%; right: 20%" v-if="value==='gx'">
        <el-button type="success" @click="submitUpload" size="small">提交文件</el-button>
<!--        <el-button type="primary" @click="exportReport" size="small">下载报告</el-button>-->
      <!--      <div style="position: absolute; bottom: 2%; right: 20%">-->
      <div style="position: absolute; right: 20%; padding-top: 20px">
        <el-button
          v-if="value === 'gx'"
          type="success"
          @click="submitUpload"
          size="small"
          >提交文件</el-button
        >
      </div>
    </div>
    <div class="exDown" v-if="value==='gx'">
    <div class="exDown">
      <el-card class="box-card" style="position: relative">
        <div class="block" style="margin-bottom: 30px;">
        <div class="block" style="margin-bottom: 30px">
          <el-date-picker
              v-model="value2"
              type="daterange"
              align="right"
              unlink-panels
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :picker-options="pickerOptions">
            v-model="value2"
            type="daterange"
            align="right"
            unlink-panels
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :picker-options="pickerOptions"
          >
          </el-date-picker>
          <el-select v-model="valueSelect" clearable placeholder="请选择地区">
            <el-option
                v-for="item in optionsSelect"
                :key="item.valueSelect"
                :label="item.label"
                :value="item.valueSelect">
              v-for="item in optionsSelect"
              :key="item.valueSelect"
              :label="item.label"
              :value="item.valueSelect"
            >
            </el-option>
          </el-select>
          <el-button type="primary" @click="selectReport" size="small" class="selectBtn">查询</el-button>
<!--          <el-button type="primary" @click="selectReport" size="small" class="selectBtn">下载多个</el-button>-->
        </div>
        <el-table
            :data="tableData"
            style="width: 100%">
<!--          <el-table-column
          width="100"
          align="center">
            <template slot="header">
              <el-checkbox
                  :indeterminate="isIndeterminate"
                  v-model="checkAll"
                  @change="handleCheckAllChange">全选</el-checkbox>
            </template>
            <template slot-scope="scope">
              <el-checkbox
                  v-model="scope.row.checked"
                  @change="handleCheckOneChange(scope.row)"></el-checkbox>
            </template>
          </el-table-column>-->
          <el-table-column
              prop="name"
              label="报告名称"
             >
          </el-table-column>
          <el-table-column
              prop="time"
              label="提交时间"
           >
          </el-table-column>
          <el-table-column
              prop="date"
              label="创建时间"
          <el-button
            type="primary"
            @click="selectReport(1)"
            size="small"
            class="selectBtn"
            >查询</el-button
          >
          </el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button type="text" size="medium" @click="expReport(scope.row)">下载</el-button>
            </template>
          </el-table-column>
        </el-table>
<!--        <el-pagination
            class="paginationDemo"
          <!--          <el-button type="primary" @click="selectReport" size="small" class="selectBtn">下载多个</el-button>-->
        </div>
        <div style="overflow-y: auto; height: 82%; margin-bottom: 2%">
          <el-table :data="tableData" style="width: 100%">
            <!--          <el-table-column
                      width="100"
                      align="center">
                        <template slot="header">
                          <el-checkbox
                              :indeterminate="isIndeterminate"
                              v-model="checkAll"
                              @change="handleCheckAllChange">全选</el-checkbox>
                        </template>
                        <template slot-scope="scope">
                          <el-checkbox
                              v-model="scope.row.checked"
                              @change="handleCheckOneChange(scope.row)"></el-checkbox>
                        </template>
                      </el-table-column>-->
            <el-table-column prop="name" label="报告名称"> </el-table-column>
            <el-table-column prop="time" label="提交时间"> </el-table-column>
            <el-table-column prop="date" label="创建时间"> </el-table-column>
            <el-table-column label="操作">
              <template slot-scope="scope">
                <el-button
                  type="text"
                  size="medium"
                  v-if="valueSelect === 'gx'"
                  @click="expReport(scope.row)"
                  >下载</el-button
                >
                <!--导出excel-->
                <img
                  src="../../assets/icon/hn_excel.png"
                  alt="蓝天计划excel"
                  v-if="valueSelect === 'hn'"
                  @click="hnExcel(scope.row)"
                  style="margin-left: 0; cursor: pointer"
                />
                <!--导出word -->
                <img
                  src="../../assets/icon/hn_word.png"
                  alt="浑南区环境空气质量报告"
                  v-if="valueSelect === 'hn'"
                  @click="hnExpReport(scope.row)"
                  style="cursor: pointer"
                />
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="block" v-if="isDisplay">
          <el-pagination
            background
            layout="prev, pager, next"
            :total="100">
        </el-pagination>-->
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page.sync="currentPage3"
            :page-size="onePageCount"
            layout="total, prev, pager, next, jumper"
            :total="totalNumber"
          >
          </el-pagination>
        </div>
      </el-card>
    </div>
  </div>
</template>
<script>
import { ExportBriefDataDocx } from '@/utils/exportBriefDataDocx'
import { ExportHunnanExcel } from '@/utils/ExportHunnanExcel'
export default {
  data() {
    return {
@@ -248,53 +327,60 @@
      file7: null,
      file8: null,
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
            picker.$emit('pick', [start, end])
          }
        }]
        shortcuts: [
          {
            text: '最近一周',
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
              picker.$emit('pick', [start, end])
            },
          },
          {
            text: '最近一个月',
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
              picker.$emit('pick', [start, end])
            },
          },
          {
            text: '最近三个月',
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
              picker.$emit('pick', [start, end])
            },
          },
        ],
      },
      value2: [new Date(), new Date()], // 查询报告日期时间
      value3: new Date(), // 提交文件的时间日期
      options: [
        {
          value: 'sy',
          label: '沈阳'
        }, {
          value: 'hn',
          label: '浑南区',
        },
        {
          value: 'gx',
          label: '高新区'
        }
          label: '高新区',
        },
      ],
      value: 'gx', // 地区
      valueSelect: 'gx',
      valueSelect2: 'hn',
      optionsSelect: [
        {
          valueSelect: 'sy',
          label: '沈阳'
        }, {
          valueSelect: 'hn',
          label: '浑南区',
        },
        {
          valueSelect: 'gx',
          label: '高新区'
        }
          label: '高新区',
        },
      ],
      tableData: [],
      sensorTime: [], // 提交文件的日期
@@ -305,13 +391,42 @@
      isIndeterminate: true,
      dateArr: [], // 存储多选的日期
      airData: {},
      reportInfo: {}
      reportInfo: {},
      hunNanAirData: [], // 浑南区word报告数据
      hnexcelID: '',
      idDisabled: false,
      currentPage3: 1, // 前往第几页
      totalNumber: 0, // 总条数
      onePageCount: 8, // 一页多少条
      isDisplay: false, // 是否显示分页
    }
  },
  watch: {
    value(newName, oldName) {
      this.valueSelect = newName
      this.tableData = []
      this.value2 = [new Date(), new Date()]
    },
    valueSelect(newName, oldName) {
      this.tableData = []
    },
  },
  methods: {
    // 分页
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
      this.selectReport(val)
    },
    // 上传
    handleChange(file, fileList) {
      if (file.raw.type !== 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') {
        this.$refs.upload.handleRemove(file)
      if (
        file.raw.type !==
        'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
      ) {
        this.$refs.upload1.handleRemove(file)
        this.$message.warning(`上传文件格式不符合`)
        return
      }
@@ -323,7 +438,10 @@
      this.file1 = fileList[0]
    },
    handleChange2(file, fileList) {
      if (file.raw.type !== 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') {
      if (
        file.raw.type !==
        'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
      ) {
        this.$refs.upload2.handleRemove(file)
        this.$message.warning(`上传文件格式不符合`)
        return
@@ -336,7 +454,10 @@
      this.file2 = fileList[0]
    },
    handleChange3(file, fileList) {
      if (file.raw.type !== 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') {
      if (
        file.raw.type !==
        'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
      ) {
        this.$refs.upload3.handleRemove(file)
        this.$message.warning(`上传文件格式不符合`)
        return
@@ -349,7 +470,10 @@
      this.file3 = fileList[0]
    },
    handleChange4(file, fileList) {
      if (file.raw.type !== 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') {
      if (
        file.raw.type !==
        'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
      ) {
        this.$refs.upload4.handleRemove(file)
        this.$message.warning(`上传文件格式不符合`)
        return
@@ -362,7 +486,10 @@
      this.file4 = fileList[0]
    },
    handleChange5(file, fileList) {
      if (file.raw.type !== 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') {
      if (
        file.raw.type !==
        'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
      ) {
        this.$refs.upload5.handleRemove(file)
        this.$message.warning(`上传文件格式不符合`)
        return
@@ -375,7 +502,11 @@
      this.file5 = fileList[0]
    },
    handleChange6(file, fileList) {
      if (file.raw.type !== 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' && file.raw.type !== 'application/vnd.ms-excel') {
      if (
        file.raw.type !==
          'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' &&
        file.raw.type !== 'application/vnd.ms-excel'
      ) {
        this.$refs.upload6.handleRemove(file)
        this.$message.warning(`上传文件格式不符合`)
        return
@@ -387,8 +518,12 @@
      this.fileList6 = fileList
      this.file6 = fileList[0]
    },
    /* handleChange7(file, fileList) {
      if (file.raw.type !== 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') {
    handleChange7(file, fileList) {
      if (
        file.raw.type !==
          'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' &&
        file.raw.type !== 'application/vnd.ms-excel'
      ) {
        this.$refs.upload7.handleRemove(file)
        this.$message.warning(`上传文件格式不符合`)
        return
@@ -400,33 +535,40 @@
      this.fileList7 = fileList
      this.file7 = fileList[0]
    },
    handleChange8(file, fileList) {
      if (file.raw.type !== 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') {
        this.$refs.upload8.handleRemove(file)
        this.$message.warning(`上传文件格式不符合`)
        return
      }
      this.fileList8 = fileList
      this.file8 = fileList[0]
    },
    handleRemove8(file, fileList) {
      this.fileList8 = fileList
      this.file8 = fileList[0]
    },*/
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`)
      this.$message.warning(
        `当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
          files.length + fileList.length
        } 个文件`
      )
    },
    submitUpload() {
      this.formData2 = []
      if (!this.value3) {
        this.$message({
          message: '请选择时间',
          type: 'warning'
          type: 'warning',
        })
        return
      }
      if (this.file1 && this.file2 && this.file3 && this.file4 && this.file5 && this.file6) {
      if (this.value === 'gx') {
        // 高新区表格导入
        this.gxSubmit()
      } else {
        // 浑南区表格导入
        this.hnSubmit()
      }
    },
    // 提交高新区表格数据
    gxSubmit() {
      if (
        this.file1 &&
        this.file2 &&
        this.file3 &&
        this.file4 &&
        this.file5 &&
        this.file6
      ) {
        const formData = new FormData()
        formData.append(`code`, this.value)
        this.sensorTime = this.newTime(this.value3, 'submit')
@@ -443,33 +585,86 @@
        // formData.append(`file7`, this.file7.raw)
        // formData.append(`file8`, this.file8.raw)
        // 后端上传接口
        this.MultipartFile(formData).then(res => {
          if (res.code === 0) {
            var reportInfo = res.data
            this.value2 = [this.value3, this.value3]
            reportInfo.name = '高新区空气质量分析报告' + reportInfo.time.split('-').join('')
            this.tableData = [reportInfo]
          }
        }).catch(err => {
          console.log(err)
        })
        this.MultipartFile(formData)
          .then((res) => {
            if (res.code === 0) {
              var reportInfo = res.data
              this.value2 = [this.value3, this.value3]
              reportInfo.name =
                '高新区空气质量研判总结报告' +
                reportInfo.time.split('-').join('')
              this.tableData = [reportInfo]
            }
          })
          .catch((err) => {
            console.log(err)
          })
      } else {
        this.$message({
          message: '提交文件数量不符合',
          type: 'warning'
          type: 'warning',
        })
      }
    },
    // 后端上传接口
    MultipartFile(data) {
      return this.$request({
        url: '/excel/excelImport',
        method: 'post',
        headers: { 'Content-Type': 'multipart/form-data' }, // 多文件上传这一句必须加
        data
      })
    // 提交浑南区表格数据
    hnSubmit() {
      if (this.file7) {
        const formData = new FormData()
        formData.append(`code`, this.value)
        this.sensorTime = this.newTime(this.value3, 'submit')
        var date = new Date()
        date = this.newTime(date, 'submit')
        formData.append(`time`, this.sensorTime)
        formData.append(`date`, date)
        formData.append(`files`, this.file7.raw)
        // 后端上传接口
        this.MultipartFile(formData)
          .then((res) => {
            this.idDisabled = false
            if (res.code === 0) {
              this.$message({
                message: '提交成功!',
                type: 'success',
              })
              var reportInfo = res.data
              this.value2 = [this.value3, this.value3]
              reportInfo.name =
                '浑南区报告' + reportInfo.time.split('-').join('')
              this.tableData = [reportInfo]
            } else {
              this.$message.error('提交失败!')
            }
          })
          .catch((err) => {
            console.log(err)
          })
      } else {
        this.$message({
          message: '提交文件数量不符合',
          type: 'warning',
        })
      }
    },
    // 时间处理函数
    // 文件上传接口
    MultipartFile(data) {
      this.idDisabled = true
      if (this.value === 'gx') {
        return this.$request({
          url: '/excel/excelImport',
          method: 'post',
          headers: { 'Content-Type': 'multipart/form-data' }, // 多文件上传这一句必须加
          data,
        })
      } else {
        return this.$request({
          url: '/excel/syExcelImport',
          method: 'post',
          headers: { 'Content-Type': 'multipart/form-data' }, // 多文件上传这一句必须加
          data,
        })
      }
    },
    // 时间处理函数(日期带0)
    newTime(timeArr, name) {
      if (name === 'submit') {
        var date = new Date(timeArr)
@@ -481,7 +676,7 @@
        return y + '-' + m + '-' + d
      } else {
        var arr = []
        timeArr.map(v => {
        timeArr.map((v) => {
          var date = new Date(v)
          var y = date.getFullYear()
          var m = date.getMonth() + 1
@@ -500,11 +695,19 @@
        return arr
      }
    },
    // 时间处理函数(日期不包括0)
    newTimeNotZero(time) {
      var date = new Date(time)
      var y = date.getFullYear()
      var m = date.getMonth() + 1
      var d = date.getDate()
      return y + '-' + m + '-' + d
    },
    // 全选
    handleCheckAllChange(val) {
      // console.info('check all change is ', val)
      this.isIndeterminate = false
      this.tableData.forEach(item => {
      this.tableData.forEach((item) => {
        item.checked = val
        this.dateArr.push(item.date)
      })
@@ -519,7 +722,7 @@
    handleCheckOneChange(obj) {
      // console.info('check one change is ', obj)
      if (obj.checked === false) {
        this.dateArr = this.dateArr.filter(v => {
        this.dateArr = this.dateArr.filter((v) => {
          return v !== obj.date
        })
      } else {
@@ -527,42 +730,98 @@
      }
      var totalCount = this.tableData.length
      let someStatusCount = 0
      this.tableData.forEach(item => {
      this.tableData.forEach((item) => {
        if (item.checked === obj.checked) {
          someStatusCount++
        }
      })
      this.count = someStatusCount
      this.checkAll = totalCount === someStatusCount ? obj.checked : !obj.checked
      this.checkAll =
        totalCount === someStatusCount ? obj.checked : !obj.checked
      this.isIndeterminate = someStatusCount > 0 && someStatusCount < totalCount
    },
    // 下载
    // 高新区报告下载
    expReport(obj) {
      this.$request({
        url: '/excel/excelExport',
        method: 'get',
        params: {
          id: obj.id
        }
      }).then(res => {
        var getData = {}
        getData = res.data
        // 苏州市区放最后
        getData.list1 = this.cityLast(getData.list1)
        getData.list5 = this.cityLast(getData.list5)
        // 高新区放最前边
        getData.list2 = this.cityFirst(getData.list2)
        getData.list3 = this.cityFirst(getData.list3)
        getData.list4 = this.cityFirst(getData.list4)
        this.airData = getData
        this.airData.month = res.data.time.split('月')[0]
        this.airData.day = res.data.time.split('月')[1].split('日')[0]
        var arr = obj.time.split('-')
        this.airData.currentTime = arr[0] + '年' + arr[1] + '月' + arr[2] + '日'
        ExportBriefDataDocx('/airQuality.docx', this.airData, `${obj.name}.docx`)
      }).catch(err => {
        console.log(err)
          id: obj.id,
        },
      })
        .then((res) => {
          console.log(res, 'xia')
          var getData = {}
          getData = res.data
          // 苏州市区放最后
          getData.list1 = this.cityLast(getData.list1)
          getData.list5 = this.cityLast(getData.list5)
          // 高新区/国控站放最前边
          getData.list2 = this.cityFirst2(getData.list2)
          getData.list3 = this.cityFirst2(getData.list3)
          getData.list4 = this.cityFirst(getData.list4)
          this.airData = getData
          var monthZero = res.data.time.split('月')[0]
          if (monthZero.substr(0, 1) === '0') {
            this.airData.month = monthZero.substr(1)
          } else {
            this.airData.month = res.data.time.split('月')[0]
          }
          var dayZero = res.data.time.split('月')[1].split('日')[0]
          if (dayZero.substr(0, 1) === '0') {
            this.airData.day = dayZero.substr(1)
          } else {
            this.airData.day = dayZero
          }
          var arr = obj.date.split('-')
          if (arr[2].substr(0, 1) === '0') {
            arr[2] = arr[2].substr(1)
          }
          if (arr[1].substr(0, 1) === '0') {
            arr[1] = arr[1].substr(1)
          }
          this.airData.currentTime =
            arr[0] + '年' + arr[1] + '月' + arr[2] + '日'
          this.airData.currentYear = arr[0]
          var time1DayZero = ''
          var time1MonthZero = ''
          if (
            res.data.time1.split('年')[1].split('月')[0].substr(0, 1) === '0'
          ) {
            time1MonthZero = res.data.time1
              .split('年')[1]
              .split('月')[0]
              .substr(1)
          } else {
            time1MonthZero = res.data.time1.split('年')[1].split('月')[0]
          }
          if (
            res.data.time1.split('月')[1].split('日')[0].substr(0, 1) === '0'
          ) {
            time1DayZero = res.data.time1
              .split('月')[1]
              .split('日')[0]
              .substr(1)
          } else {
            time1DayZero = res.data.time1.split('月')[1].split('日')[0]
          }
          this.airData.time1 =
            res.data.time1.split('年')[0] +
            '年' +
            time1MonthZero +
            '月' +
            time1DayZero +
            '日'
          ExportBriefDataDocx(
            '/airQuality1.docx',
            this.airData,
            `${obj.name}.docx`
          )
        })
        .catch((err) => {
          console.log(err)
        })
    },
    // 苏州市区放最后
    cityLast(list) {
@@ -573,7 +832,9 @@
          list.splice(i, 1)
        }
      })
      list.push(obj)
      if (obj.place) {
        list.push(obj)
      }
      return list
    },
    // 高新区放最前边
@@ -585,131 +846,241 @@
          list.splice(i, 1)
        }
      })
      list.unshift(obj)
      if (obj.place) {
        list.unshift(obj)
      }
      return list
    },
    // 导出报告
    exportReport() {
      // ExportBriefDataDocx('/airQuality.docx', this.airData, `空气质量报告.docx`)
    // 第二个和第三个表格是国控站/高新区
    cityFirst2(list) {
      var obj = {}
      list.map((v, i) => {
        if (v.place === '国控站') {
          obj = v
          list.splice(i, 1)
        }
        if (v.place === '高新区') {
          obj = v
          list.splice(i, 1)
        }
      })
      if (obj.place) {
        list.unshift(obj)
      }
      return list
    },
    // 浑南区报告下载
    hnExpReport(obj) {
      this.$request({
        url: '/excel/excelExport',
        url: '/excel/hnExcelExport',
        method: 'get',
        params: {
          id: 23
        }
      }).then(res => {
        console.log(res)
        this.airData = res.data
        this.airData.month = res.data.time.split('月')[0]
        this.airData.day = res.data.time.split('月')[1].split('日')[0]
        ExportBriefDataDocx('/airQuality.docx', this.airData, `空气质量报告.docx`)
      }).catch(err => {
        console.log(err)
          id: obj.id,
          // id: 68
        },
      })
      // if (this.isInfo) {
      //   // ExportBriefDataDocx('/airQ.docx', this.airData, `空气质量报告.docx`)
      // } else {
      //   this.$message({
      //     message: '请先提交文件',
      //     type: 'warning'
      //   })
      // }
        .then((res) => {
          // console.log(res)
          this.hunNanAirData = res.data
          // currentTime时间
          var arr = res.data.time2.split('-')
          var currentTime = arr[0] + '年' + arr[1] + '月' + arr[2] + '日'
          var currentYear = arr[0]
          this.hunNanAirData.currentTime = currentTime
          this.hunNanAirData.currentYear = currentYear
          // 对后端传来的09月26日,yearDate进行分割
          var month = res.data.time.split('-')[0]
          if (month.substr(0, 1) === '0') {
            month = month.substr(1)
          }
          this.hunNanAirData.month = month
          var day = res.data.time.split('-')[1]
          if (day.substr(0, 1) === '0') {
            day = day.substr(1)
          }
          this.hunNanAirData.day = day
          ExportBriefDataDocx(
            '/hunnan.docx',
            this.hunNanAirData,
            `浑南区${arr[1]}月${arr[2]}日环境空气质量报告.docx`
          )
        })
        .catch((err) => {
          console.log(err)
        })
    },
    // 浑南区excel下载
    hnExcel(obj) {
      this.$request({
        url: '/excel/syExcelExport',
        method: 'get',
        params: {
          id: obj.id,
        },
      })
        .then((res) => {
          var code2 =
            res.data.code2.substr(0, 2) + '\n' + res.data.code2.substr(2)
          var code4 =
            res.data.code4.substr(0, 2) + '\n' + res.data.code4.substr(2)
          var table1Data = [
            ['', '目标值', '进度', '进度', '同比'],
            ['', '', '', '', ''],
            ['优良天', '300', res.data.code1, '', code2],
            ['', '', '', '', ''],
            ['PM2.5', '41', res.data.code3, '', code4],
            ['', '', '', '', ''],
          ]
          var table3Data = [
            ['', '目标值', '目标值', '进度', '进度'],
            ['', '目标值', '目标值', '进度', '进度'],
            ['优良天', '69', '69', res.data.code5, ''],
            ['', '', '', '', ''],
            ['PM2.5', '40', '40', res.data.code6, ''],
            ['', '', '', '', ''],
          ]
          var table2Data = [
            res.data.list.sy1,
            res.data.list.sy2,
            res.data.list.hnd1,
            res.data.list.hnd2,
            res.data.list.xxj1,
            res.data.list.xxj2,
            res.data.list.hnq1,
            res.data.list.hnq2,
          ]
          var data = new Date()
          var currentYearData = data.getFullYear()
          var jd = res.data.season
          ExportHunnanExcel(
            `蓝天计划挂图作战${obj.time.split('-').join('')}`,
            table1Data,
            table3Data,
            table2Data,
            currentYearData,
            jd
          )
        })
        .catch((err) => {
          console.log(err)
        })
    },
    // 查询报告
    selectReport() {
    selectReport(val) {
      var page = val
      if (this.isDisplay === false) {
        page = 0
      }
      this.sensorTime2 = this.newTime(this.value2, 'select')
      this.$request({
        url: '/excel/selectExcel',
        // url: '/excel/selectExcel',
        url: 'excel/selectExcel',
        method: 'get',
        params: {
          startTime: this.sensorTime2[0],
          endTime: this.sensorTime2[1],
          code: this.valueSelect
        }
      }).then(res => {
        if (res.code === 0) {
          var info = res.data
          info.map(v => {
            v.name = '高新区空气质量分析报告' + v.time.split('-').join('')
          })
          info.sort((a, b) => { return b.time.split('-').join('') - a.time.split('-').join('') })
          this.tableData = info
        }
      }).catch(err => {
        console.log(err)
          code: this.valueSelect,
          pageCount: page,
        },
      })
    }
  }
        .then((res) => {
          if (res.code === 0) {
            var info = []
            if (this.isDisplay) {
              this.totalNumber = res.data.total
              info = res.data.item
            } else {
              info = res.data
            }
            info.map((v) => {
              if (this.valueSelect === 'gx') {
                v.name = '高新区空气质量分析报告' + v.time.split('-').join('')
              } else {
                v.name = '浑南区报告' + v.time.split('-').join('')
              }
            })
            info.sort((a, b) => {
              return b.time.split('-').join('') - a.time.split('-').join('')
            })
            this.tableData = info
          }
        })
        .catch((err) => {
          console.log(err)
        })
    },
  },
}
</script>
<style scoped>
.analyseAir{
.analyseAir {
  width: 100%;
  height: 100%;
  display: flex;
  padding-top: 22px;
}
  .exTop{
    width: 30%;
    height: 95%;
    position: relative;
  }
  .cascader-demo{
    float: left;
    padding: 0% 2%;
  }
  .upload-demo{
    margin-left: 2%;
    /*float: left;*/
    margin-top: 4%;
    height: 65px;
  }
  .upload-demo /deep/ .el-upload-list__item{
    font-size: 15px;
  }
.upload-demo /deep/ .el-upload-list__item:first-child{
.exTop {
  width: 30%;
  /*height: 95%;*/
  position: relative;
  overflow: auto;
  margin-bottom: 2%;
}
.cascader-demo {
  float: left;
  padding: 0% 2%;
}
.upload-demo {
  margin-left: 2%;
  /*float: left;*/
  margin-top: 4%;
  height: 65px;
}
.upload-demo /deep/ .el-upload-list__item {
  font-size: 15px;
}
.upload-demo /deep/ .el-upload-list__item:first-child {
  margin-top: 2px;
}
  .exDown {
    width: 50%;
    height: 95%;
    margin-left: 2%;
    font-size: 18px;
  }
  .exDown /deep/ .el-card{
    width: 100%;
    height: 100%;
  }
  .divPadding{
    width: 80%;
    margin: auto;
  }
  .textCenter{
    text-align: center;
  }
  .fontS14{
    font-size: 14px;
  }
  .upload-demo button{
    margin-right: 10%;
  }
  .upload-demo /deep/ .el-upload{
    margin-right: 10%;
  }
  .selectBtn{
    margin-left: 5%;
  }
  .el-card /deep/ .el-card__body{
    height: 815px;
  }
  .paginationDemo{
    position: absolute;
    left: 0;
    bottom: 3%;
  }
  .el-upload__tip{
    color: red;
  }
.exDown {
  width: 50%;
  height: 95%;
  margin-left: 2%;
  font-size: 18px;
}
.exDown /deep/ .el-card {
  width: 100%;
  height: 100%;
}
.divPadding {
  width: 80%;
  margin: auto;
}
.textCenter {
  text-align: center;
}
.fontS14 {
  font-size: 14px;
}
.upload-demo button {
  margin-right: 10%;
}
.upload-demo /deep/ .el-upload {
  margin-right: 10%;
}
.selectBtn {
  margin-left: 5%;
}
.el-card /deep/ .el-card__body {
  height: 815px;
}
.paginationDemo {
  position: absolute;
  left: 0;
  bottom: 3%;
}
.el-upload__tip {
  color: red;
}
</style>