quanyawei
2023-10-26 725225aab4797b01dd5bf7c70031d41dae033dff
fix:走行车导出
1 files modified
161 ■■■■■ changed files
src/views/sectionReport/index.vue 161 ●●●●● patch | view | raw | blame | history
src/views/sectionReport/index.vue
@@ -8,8 +8,7 @@
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
          />
        </el-select>
      </div>
      <div>
@@ -19,8 +18,7 @@
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
          />
        </el-select>
      </div>
      <div>
@@ -35,8 +33,7 @@
            :key="index"
            :label="item.name"
            :value="item.mac"
          >
          </el-option>
          />
        </el-select>
      </div>
      <div class="block">
@@ -48,14 +45,13 @@
          end-placeholder="结束日期"
          :picker-options="pickerOptions"
          value-format="yyyy-MM-dd HH:mm:ss"
        >
        </el-date-picker>
        />
      </div>
      <div>
        <el-button type="primary" @click="selectReport">查询</el-button>
      </div>
      <div>
        <!-- <el-button type="primary" @click="exportword">导出word</el-button> -->
        <el-button type="primary" @click="exportword"> 导出word </el-button>
      </div>
    </div>
    <el-dialog title="路段超标值" :visible.sync="dialogVisible" width="60%">
@@ -66,24 +62,21 @@
          "
          style="width: 100%"
        >
          <el-table-column type="index" width="180" label="序号">
          </el-table-column>
          <el-table-column label="道路" prop="road"> </el-table-column>
          <el-table-column label="平均尘负荷(克/平方米)" prop="value">
          </el-table-column>
          <el-table-column type="index" width="180" label="序号" />
          <el-table-column label="道路" prop="road" />
          <el-table-column label="平均尘负荷(克/平方米)" prop="value" />
        </el-table>
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="PageNum"
          :page-size="PageSize"
          layout="total, prev, pager, next, jumper"
          :total="total"
        >
        </el-pagination>
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
        <el-upload
          class="upload-demo"
          ref="upload"
          class="upload-demo"
          action=""
          :on-change="handleChange"
          :on-remove="handleRemove"
@@ -92,9 +85,9 @@
          :limit="10"
          style="margin-top: 1rem"
        >
          <el-button slot="trigger" size="small" type="primary"
            >选取文件</el-button
          >
          <el-button slot="trigger" size="small" type="primary">
            选取文件
          </el-button>
          <div slot="tip" class="el-upload__tip" style="color: red">
            上传路段图片(可选可不选,图片大小低于1MB)
          </div>
@@ -102,21 +95,21 @@
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" :disabled="isDisplay" @click="baoC"
          >下载</el-button
        >
        <el-button type="primary" :disabled="isDisplay" @click="baoC">
          下载
        </el-button>
      </div>
    </el-dialog>
    <el-table
      :data="tableData"
      style="width: 100%; overflow-y: auto; height: 82%"
    >
      <el-table-column prop="time" label="报告名称"> </el-table-column>
      <el-table-column prop="time" label="报告名称" />
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="medium" @click="expReport(scope.row)"
            >下载</el-button
          >
          <el-button type="text" size="medium" @click="expReport(scope.row)">
            下载
          </el-button>
        </template>
      </el-table-column>
    </el-table>
@@ -183,7 +176,7 @@
          // 最大时间  最小时间
          this.timeOne = minDate.getTime() // 当选一个日期时 就是最小日期
          // // 如何你选择了两个日期了,就把那个变量置空
          if (maxDate) this.timeOne = ''
          if (maxDate) { this.timeOne = '' }
        },
        disabledDate: (time) => {
          if (this.timeOne) {
@@ -199,7 +192,7 @@
            return time.getTime() > new Date()
          }
        },
        reportName: ''
        reportName: '',
      },
    }
  },
@@ -213,6 +206,28 @@
      }
    },
  },
  //生命周期 - 创建完成(可以访问当前 this 实例)
  created () {
    this.$request({
      url: 'cruiser/selectCruisers',
      method: 'get',
    })
      .then((res) => {
        this.carMac = res.data
      })
      .catch((err) => {
        console.log(err)
      })
  },
  //生命周期 - 挂载完成(可以访问 DOM 元素)
  mounted () { },
  beforeCreate () { }, //生命周期 - 创建之前
  beforeMount () { }, //生命周期 - 挂载之前
  beforeUpdate () { }, //生命周期 - 更新之前
  updated () { }, //生命周期 - 更新之后
  beforeDestroy () { }, //生命周期 - 销毁之前
  destroyed () { }, //生命周期 - 销毁完成
  activated () { },
  //方法集合
  methods: {
    baoC() {
@@ -250,9 +265,11 @@
      //     this.valueDate.fileLists[i] = [{ url: baseUrl + imagesObj[i] }]
      //   }
      // }
      console.log(this.fileList, '123')
      const formData = new FormData()
      formData.append(`id`, this.id)
      formData.append(`mac`, this.carInput)
      formData.append(`time1`, this.value1[0])
      formData.append(`time2`, this.value1[1])
      this.fileList.map((v) => {
        formData.append(`files`, v.raw)
        console.log(v.raw)
@@ -263,7 +280,8 @@
        method: 'post',
        headers: { 'Content-Type': 'multipart/form-data' }, // 多文件上传这一句必须加
        data: formData,
      }).then((res) => {
      })
        .then((res) => {
        console.log(res)
        // this.valueDate=res.data
        const baseUrl = `${requestObj.baseUrl}/static/img/`
@@ -287,7 +305,7 @@
        var num = 0
        for (let i = 0; i < images.length; i++) {
          // console.log(images)
          if (!this.valueDate.fileLists[i]) this.valueDate.fileLists[i] = []
            if (!this.valueDate.fileLists[i]) { this.valueDate.fileLists[i] = [] }
          if (images[i].length) {
            num++
            info += images[i].length
@@ -298,7 +316,7 @@
          }
        }
        // images=[]
        console.log(this.valueDate.fileLists,'images');
          console.log(this.valueDate.fileLists, 'images')
        res.data.list1.map((item, index) => {
          item.index = index + 1
        })
@@ -311,7 +329,11 @@
        this.valueDate.list1 = res.data.list1
        this.valueDate.list2 = res.data.list2
        this.valueDate.time = res.data.time
        exportLUImage('/Section.docx', this.valueDate, `${this.reportName}.docx`)
          exportLUImage(
            '/Section.docx',
            this.valueDate,
            `${this.reportName}.docx`
          )
      })
    },
    handleRemove(file, fileList) {
@@ -333,7 +355,43 @@
    openPic() {
      this.dialogVisible = true
    },
    exportword () {
      if (this.carInput === '') {
        this.$message('请选择走航车')
        return false
      }
      this.dateList = []
      this.columnList = []
      this.$request({
        url: 'cruiser/dailyDustlds',
        method: 'post',
        data: {
          mac: this.carInput,
          startTime: this.value1[0],
          endTime: this.value1[1],
        },
        responseType: 'blob',
      })
        .then((res) => {
          this.getOutExcel('走航报告', res)
        })
        .catch(res => {
          this.$message(res.message)
        })
    },
    getOutExcel (fileName, res) {
      let blob = new Blob([res], {
        type: `application/msword`, //word文档为msword,pdf文档为pdf
      })
      let objectUrl = URL.createObjectURL(blob)
      let link = document.createElement('a')
      link.href = objectUrl
      link.setAttribute('download', fileName)
      document.body.appendChild(link)
      link.click()
    },
    selectReport() {
      if (this.carInput === '') {
        this.$message('请选择走航车')
@@ -361,7 +419,9 @@
          }
          info.map((v) => {
            console.log(v)
            var time = v.time.substring(0, 10).split('-').join('')
            var time = v.time.substring(0, 10)
              .split('-')
              .join('')
            if (this.cityChoose === 'gx') {
              v.time = `苏州高新区道路积尘负荷走航监测报告${time}`
            } else {
@@ -386,7 +446,8 @@
        params: {
          id: obj.id,
        },
      }).then((res) => {
      })
        .then((res) => {
        // console.log(res)
        this.tableData1 = res.data.list
        this.total = res.data.count
@@ -409,29 +470,7 @@
        }
      })
    },
  },
  //生命周期 - 创建完成(可以访问当前 this 实例)
  created() {
    this.$request({
      url: 'cruiser/selectCruisers',
      method: 'get',
    })
      .then((res) => {
        this.carMac = res.data
      })
      .catch((err) => {
        console.log(err)
      })
  },
  //生命周期 - 挂载完成(可以访问 DOM 元素)
  mounted() {},
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  }, //如果页面有keep-alive缓存功能,这个函数会触发
}
</script>
<style scoped>