From d2be196da480346d1f111ca1f02b9852694aa2ca Mon Sep 17 00:00:00 2001
From: guanqb <18720758508@163.com>
Date: Fri, 02 Feb 2024 18:49:47 +0800
Subject: [PATCH] 1

---
 src/views/publicSecurity/ninePlaceManage/situationRectification.vue |   43 ++++++++++++++++++++-
 src/views/publicSecurity/ninePlaceManage/hiddenDangerStatistics.vue |   34 +++++++++++++++++
 2 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/src/views/publicSecurity/ninePlaceManage/hiddenDangerStatistics.vue b/src/views/publicSecurity/ninePlaceManage/hiddenDangerStatistics.vue
index 55684cd..ffc3542 100644
--- a/src/views/publicSecurity/ninePlaceManage/hiddenDangerStatistics.vue
+++ b/src/views/publicSecurity/ninePlaceManage/hiddenDangerStatistics.vue
@@ -5,6 +5,10 @@
             @row-update="rowUpdate" @row-save="rowSave" :before-open="beforeOpen" @search-change="searchChange"
             @search-reset="searchReset" @selection-change="selectionChange" @current-change="currentChange"
             @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad">
+            <template slot="menuLeft">
+                <el-button type="warning" size="small" plain icon="el-icon-download" @click="handleExport">导出
+                </el-button>
+            </template>
         </avue-crud>
     </basic-container>
 </template>
@@ -173,7 +177,31 @@
         },
 
     },
+
     methods: {
+        getLastMouth (str = '-') {
+            let today = new Date()
+            let lastMouth = new Date()
+            let nowTime = today.getTime()
+            let ms = 24 * 3600 * 1000 * -30
+            today.setTime(parseInt(nowTime))
+            lastMouth.setTime(parseInt(nowTime + ms))
+            let oYear = today.getFullYear()
+            let oMoth = (today.getMonth() + 1).toString()
+            if (oMoth.length <= 1) oMoth = "0" + oMoth
+            let oDay = today.getDate().toString()
+            if (oDay.length <= 1) oDay = "0" + oDay
+            let mYear = lastMouth.getFullYear()
+            let mMoth = (lastMouth.getMonth() + 1).toString()
+            if (mMoth.length <= 1) mMoth = "0" + mMoth
+            let mDay = lastMouth.getDate().toString()
+            if (mDay.length <= 1) mDay = "0" + mDay
+            let todayDate = oYear + str + oMoth + str + oDay
+            let lastMouthDate = mYear + str + mMoth + str + mDay
+            console.log('[todayDate, lastMouthDate]', [todayDate, lastMouthDate])
+            return [todayDate, lastMouthDate]
+        },
+
         summaryMethod ({ columns, data }) {
             const sums = []
             if (columns.length > 0) {
@@ -362,6 +390,12 @@
 
         onLoad (page, params = {}) {
             this.loading = true
+            if (!this.query.startTime) {
+                this.query = {
+                    startTime: this.getLastMouth[1],
+                    endTime: this.getLastMouth[0],
+                }
+            }
             getYHTJList(page.currentPage, page.pageSize, this.query).then(res => {
                 console.log('getZGQKList', res.data.data)
                 const data = res.data.data
diff --git a/src/views/publicSecurity/ninePlaceManage/situationRectification.vue b/src/views/publicSecurity/ninePlaceManage/situationRectification.vue
index fdd7165..e081389 100644
--- a/src/views/publicSecurity/ninePlaceManage/situationRectification.vue
+++ b/src/views/publicSecurity/ninePlaceManage/situationRectification.vue
@@ -5,6 +5,10 @@
             :before-open="beforeOpen" @search-change="searchChange" @search-reset="searchReset"
             @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
             @refresh-change="refreshChange" @on-load="onLoad">
+            <template slot="menuLeft">
+                <el-button type="warning" size="small" plain icon="el-icon-download" @click="handleExport">导出
+                </el-button>
+            </template>
         </avue-crud>
     </basic-container>
 </template>
@@ -14,8 +18,23 @@
     mapGetters
 } from "vuex"
 import {
-    getZGQKList
+    getZGQKList, exportZGQKList
 } from "@/api/publicSecurity/ninePlaceManage"
+import NProgress from 'nprogress'
+import 'nprogress/nprogress.css'
+import Qs from "qs"
+import {
+    exportBlob
+} from "@/api/common"
+import {
+    getToken
+} from '@/util/auth'
+import {
+    downloadXls
+} from "@/util/util"
+import {
+    dateNow
+} from "@/util/date"
 
 export default {
     data () {
@@ -39,7 +58,6 @@
                 searchShow: true,
                 searchMenuSpan: 3,
                 menu: false,
-                header: false,
                 border: true,
                 index: true,
                 editBtn: false,
@@ -151,6 +169,27 @@
 
     },
     methods: {
+        handleExport () {
+            this.$confirm("是否导出整改情况数据?", "提示", {
+                confirmButtonText: "确定",
+                cancelButtonText: "取消",
+                type: "warning"
+            }).then(() => {
+                NProgress.start()
+                var data = {
+                    ...this.query
+                }
+                data = Qs.stringify(data)
+                exportBlob(
+                    `/api/blade-taskPlaceRectification/taskPlaceRectification/exportRectificationStatistics?${this.website.tokenHeader}=${getToken()}&` + data
+                ).then(res => {
+                    console.log('exportBlob', res)
+                    downloadXls(res.data, `房屋数据表${dateNow()}.xlsx`)
+                    NProgress.done()
+                })
+            })
+        },
+
         rowSave (row, done, loading) {
             if (row.imageUrls.length > 0) {
                 var urls = []

--
Gitblit v1.9.3