quanyawei
2024-03-15 4595b8b5a9c7afdeff9929022bfa3ca31a24ce06
src/views/dailyreport/index.vue
@@ -2,7 +2,7 @@
  <div class="dailyreport">
    <div class="dailyBox">
      <div class="dailyTop">
        <el-select
        <!-- <el-select
          v-model="cityChoose"
          placeholder="请选择区域"
        >
@@ -12,7 +12,18 @@
            :label="item.label"
            :value="item.value"
          />
        </el-select>
        </el-select> -->
        <el-cascader
          ref="myCascader"
          v-model="newRegion"
          placeholder=""
          :options="options"
          :props="{ checkStrictly: true }"
          clearable
          change-on-select
          style="flex: 1"
          @change="getCity"
        />
        <el-select
          v-model="equipChoose1"
          placeholder="请选择设备"
@@ -118,6 +129,11 @@
              label="报告名称"
            />
            <el-table-column
              prop="mac"
              align="center"
              label="mac"
            />
            <el-table-column
              prop="time"
              align="center"
              label="提交时间"
@@ -159,7 +175,7 @@
      :visible.sync="openBox"
    >
      <div class="openTop">
        <el-select
        <!-- <el-select
          v-model="cityChoose2"
          placeholder="请选择区域"
        >
@@ -169,7 +185,18 @@
            :label="item.label"
            :value="item.value"
          />
        </el-select>
        </el-select> -->
        <el-cascader
          ref="myUpCascader"
          v-model="newUpRegion"
          placeholder=""
          :options="options"
          :props="{ checkStrictly: true }"
          clearable
          change-on-select
          style="flex: 1"
          @change="getUpCity"
        />
        <el-select
          v-model="equipChoose2"
          placeholder="请选择设备"
@@ -783,7 +810,7 @@
</template>
<script>
import { exportDocx } from '@/utils/exportImageFile'
// import { exportDocx } from '@/utils/exportImageFile'
import { exportUAVImage } from '@/utils/exportUAVImage'
import requestObj from '@/utils/request'
import Map from '@/components/PlanMap/Map'
@@ -792,28 +819,13 @@
  data () {
    return {
      handSelectData: [],
      cityChoose: 'gx', // 默认查询高新区走行车
      cityChoose2: 'gx', // 默认上传高新区图片
      cityOptions: [
        {
          value: 'gx',
          label: '盐城市'
        }
        // , {
        //   value: 'gx',
        //   label: '高新区'
        // }, {
        //   value: 'hn',
        //   label: '浑南区'
        // }
      ],
      cityOptions2: [{
        value: 'gx',
        label: '高新区'
      }, {
        value: 'hn',
        label: '浑南区'
      }],
      options: [],
      newRegion: [],
      newUpRegion: [],
      cityForm: {},
      cityUpForm: {},
      cityChoose: '', // 默认查询高新区走行车
      cityChoose2: '', // 默认上传高新区图片
      equipChoose1: 'car',
      equipChoose2: 'car',
      equipOptions1: [{
@@ -1052,6 +1064,7 @@
    immediate: true
  },
  created () {
    this.getRegion()
    // 走航车数组
    this.$request({
      url: 'cruiser/selectCruisers',
@@ -1062,29 +1075,79 @@
    }).catch(err => {
      console.log(err)
    })
    // 无人机数组
    // this.$request({
    //   url: 'uav/getUavDaily',
    //   method: 'get'
    // }).then(res => {
    //   this.planMac = res.data
    // }).catch(err => {
    //   console.log(err)
    // })
  },
  methods: {
    getCity () {
      console.log('this.$refs.myCascader.getCheckedNodes()[0]', this.$refs.myCascader.getCheckedNodes()[0])
      if (this.newRegion.length > 0) { // 点击清空时,也会触发change事件,避免报错,先判断一下是否有值在来获取选择的节点
        const { label: org, value: orgid } =
          this.$refs.myCascader.getCheckedNodes()[0]
        this.cityForm = { org, orgid }
        console.log('this.cityForm', this.cityForm)
        this.cityChoose = orgid
      } else {
        this.cityForm = {}
        this.cityChoose = ''
      }
    },
    getUpCity () {
      if (this.newUpRegion.length > 0) { // 点击清空时,也会触发change事件,避免报错,先判断一下是否有值在来获取选择的节点
        const { label: org, value: orgid } =
          this.$refs.myUpCascader.getCheckedNodes()[0]
        this.cityUpForm = { org, orgid }
        console.log('this.cityUpForm', this.cityUpForm)
        this.cityChoose2 = orgid
      } else {
        this.cityUpForm = {}
        this.cityChoose2 = ''
      }
    },
    getRegion () {
      this.$request({
        url: '/organization/getMapPath',
        method: 'get',
        params: {
          organizationId: this.$store.state.orgId
        }
      })
        .then((res) => {
          const data = res.data
          for (let i = 0; i < data.length; i++) {
            this.options.push({
              value: data[i].provinceCode,
              label: data[i].provinceName
            })
            this.options[i].children = []
            for (let j = 0; j < data[i].cities.length; j++) {
              this.options[i].children.push({
                value: data[i].cities[j].cityCode,
                label: data[i].cities[j].cityName
              })
              // 盐城暂不需要区
              if (data[i].cities[j].cityCode !== 320900) {
                this.options[i].children[j].children = []
                for (let k = 0; k < data[i].cities[j].areas.length; k++) {
                  this.options[i].children[j].children.push({
                    value: data[i].cities[j].areas[k].areaCode,
                    label: data[i].cities[j].areas[k].areaName
                  })
                }
              }
            }
          }
        })
        .catch((err) => {
          // console.log('请求Region失败')
          console.log(err)
        })
      // console.log('请求Region结束')
    },
    handleSelectionChange (e) {
      this.handSelectData = e.map(i => i.id)
      console.log('this.handSelectData', this.handSelectData)
    },
    // 模拟下载
    exportDom () {
      // const url1 = `http://47.99.64.149:8081//static/img/7f633687-8321-4f89-bffc-9a52f94cfb77.jpg`
      // const url2 = `http://47.99.64.149:8081//static/img/7f633687-8321-4f89-bffc-9a52f94cfb77.jpg`
      // const url3 = `http://47.99.64.149:8081//static/img/7f633687-8321-4f89-bffc-9a52f94cfb77.jpg`
      // const url4 = `http://47.99.64.149:8081//static/img/7f633687-8321-4f89-bffc-9a52f94cfb77.jpg`
      // this.UAVReport.fileLists[1] = [url1, url2]
      // this.UAVReport.fileLists[3] = [url3, url4, url3]
      const baseUrl = `${requestObj.baseUrl}/static/img/`
      var images = [['7f633687-8321-4f89-bffc-9a52f94cfb77.jpg', '7f633687-8321-4f89-bffc-9a52f94cfb77.jpg'], [], [], ['7f633687-8321-4f89-bffc-9a52f94cfb77.jpg', '7f633687-8321-4f89-bffc-9a52f94cfb77.jpg', '7f633687-8321-4f89-bffc-9a52f94cfb77.jpg'], [], [], [], []]
      var info = 0
@@ -1113,6 +1176,7 @@
    },
    // 查询走行车报告
    selectExport () {
      console.log(this.cityChoose)
      this.selectTime = this.newTime(this.value1)
      if (this.cityChoose && this.equipChoose1 && this.selectTime[1]) {
        // 判断无人机or走航车
@@ -1142,12 +1206,15 @@
          }
          info.map(v => {
            var time = v.time.split('-').join('')
            v.name = `盐城市走航监测报告${time}`
            // if (this.cityChoose === 'gx') {
            //   v.name = `高新区走航监测报告${time}`
            // } else if (this.cityChoose === 'yc') {
            //   v.name = `盐城市走航监测报告${time}`
            // } else {
            //   v.name = `浑南区走航监测报告${time}`
            // }
            v.name = this.cityForm.org + `${time}`
          })
          info.sort((a, b) => { return b.time.split('-').join('') - a.time.split('-').join('') })
          this.tableData = info
@@ -1211,11 +1278,14 @@
              this.equipChoose1 = this.equipChoose2
              this.cityChoose = this.cityChoose2
              var reportInfo = res.data
              if (this.cityChoose2 === 'gx') {
                reportInfo.name = '盐城市走航监测报告' + reportInfo.time.split('-').join('')
              } else {
                reportInfo.name = '浑南区走航监测报告' + reportInfo.time.split('-').join('')
              }
              // if (this.cityChoose2 === 'gx') {
              //   reportInfo.name = '高新区走航监测报告' + reportInfo.time.split('-').join('')
              // } else if (this.cityChoose === 'yc') {
              //   reportInfo.name = '盐城市走航监测报告' + reportInfo.time.split('-').join('')
              // } else {
              //   reportInfo.name = '浑南区走航监测报告' + reportInfo.time.split('-').join('')
              // }
              reportInfo.name = this.cityForm.org + '走航监测报告' + reportInfo.time.split('-').join('')
              this.tableData = [reportInfo]
            } else if (res.code === -47) {
              this.$message(res.message)
@@ -1284,12 +1354,15 @@
            this.equipChoose1 = this.equipChoose2
            this.cityChoose = this.cityChoose2
            var reportInfo = res.data
            reportInfo.name = '盐城市飞行监测报告' + reportInfo.time.split('-').join('')
            // if (this.cityChoose === 'gx') {
            //   reportInfo.name = '高新区飞行监测报告' + reportInfo.time.split('-').join('')
            // } else if (this.cityChoose === 'yc') {
            //   reportInfo.name = '盐城市飞行监测报告' + reportInfo.time.split('-').join('')
            // } else {
            //   reportInfo.name = '浑南区飞行监测报告' + reportInfo.time.split('-').join('')
            // }
            reportInfo.name = this.cityForm.org + '走航监测报告' + reportInfo.time.split('-').join('')
            this.tableData = [reportInfo]
          } else if (res.code === -47) {
            this.$message(res.message)
@@ -1324,39 +1397,15 @@
          ids: this.handSelectData
        }
      }).then(res => {
        this.getOutExcel('盐城市走航监测报告.docx', res)
        // const baseUrl = `${requestObj.baseUrl}/static/img/`
        // var imagesObj = res.data.images
        // this.sailingReport = { ...this.sailingReport, ...res.data.code }
        // // const url1 = `http://47.99.64.149:8081//static/img/7f633687-8321-4f89-bffc-9a52f94cfb77.jpg`
        // if (imagesObj) {
        //   for (let i = 0; i < imagesObj.length; i++) {
        //     this.sailingReport.fileLists[i] = [{ url: baseUrl + imagesObj[i] }]
        //   }
        // }
        // this.sailingReport.index = imagesObj.length
        // var data2 = obj.date.split('-')
        // this.sailingReport.date2 = data2[0] + '年' + data2[1] + '月' + data2[2] + '日'
        // var time = []
        // for (let i = 0; i < res.data.code.time.length; i++) {
        //   time.push(res.data.code.time[i])
        // }
        // this.sailingReport.time0 = time[0]
        // if (time.length === 2) {
        //   this.sailingReport.time1 = time[1]
        // }
        // if (time.length === 3) {
        //   this.sailingReport.time1 = time[1]
        //   this.sailingReport.time2 = time[2]
        // }
        // if (this.cityChoose === 'gx') {
        //   this.sailingReport.city = '高新区'
        // } else if (this.cityChoose === 'yc') {
        //   this.sailingReport.city = '盐城市'
        // } else {
        //   this.sailingReport.city = '浑南区'
        // }
        // exportDocx('/sailingReport1.docx', this.sailingReport, `${obj.name}.docx`)苏州高新区
        // 盐城
        // exportDocx('/yanchengReport.docx', this.sailingReport, `${obj.name}.docx`)
        this.sailingReport.city = this.cityForm.org
        this.getOutExcel(`${this.sailingReport.city}.docx`, res)
      }).catch(err => {
        console.log(err)
      })
@@ -1436,11 +1485,14 @@
          this.UAVReport.time1 = time[1]
          this.UAVReport.time2 = time[2]
        }
        if (this.cityChoose === 'gx') {
          this.UAVReport.city = '盐城市'
        } else {
          this.UAVReport.city = '浑南区'
        }
        // if (this.cityChoose === 'yc') {
        //   this.UAVReport.city = '盐城市'
        // } else if (this.cityChoose === 'gx') {
        //   this.UAVReport.city = '高新区'
        // } else {
        //   this.UAVReport.city = '浑南区'
        // }
        this.UAVReport.city = this.cityForm.org
        exportUAVImage('/UAVReport.docx', this.UAVReport, `${obj.name}.docx`)
      }).catch(err => {
        console.log(err)
@@ -1878,7 +1930,7 @@
}
</script>
<style scoped>
<style scoped >
.dailyreport{
  width: 100%;
  height: 100%;