Kaynağa Gözat

添加导出Excel

zhangyu 5 yıl önce
ebeveyn
işleme
27fc23fd40
1 değiştirilmiş dosya ile 144 ekleme ve 41 silme
  1. 144 41
      src/views/ledger/report/index.vue

+ 144 - 41
src/views/ledger/report/index.vue

@@ -5,7 +5,7 @@
       <el-select v-model="value" placeholder="请选择">
         <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
       </el-select>
-      <el-button @click="handleClickDownload" type="primary" style="margin-left: 15px;">导出Excel</el-button>
+      <el-button @click="handleClickDownload" type="primary" :loading="loading" style="margin-left: 15px;">导出Excel</el-button>
     </el-row>
   </div>
 </template>
@@ -13,14 +13,15 @@
 <script>
 import jsontoExcel from "@/utils/JOSNToExcel"
 import { State, Family } from "@/data/mapTable"
-import { getSpaceName, getGraphyId, getEquipmentFamily, countEquip } from "@/api/scan/request"
+import { queryEquip, queryProperty } from "@/api/scan/request"
 import { mapGetters, mapActions } from "vuex"
 
 export default {
   data() {
     return {
-      json: '',
+      loading: false,
       value: '',
+      dataList: [],
       options: [{
         value: 'header1',
         label: '已建立关联的设备资产'
@@ -94,52 +95,154 @@ export default {
         headerName: "设备BIMID"
       }],
       header3: [{
-          fieldName: "Building.BuildLocalName",
-          headerName: "建筑"
-        }, {
-          fieldName: "Floor.FloorLocalName",
-          headerName: "楼层"
-        }, {
-          fieldName: "EquipFamilyList.0.FamilyName",
-          headerName: "资产设备族"
-        }, {
-          fieldName: "EquipLocalName",
-          headerName: "资产本地名称"
-        }, {
-          fieldName: "EquipLocalID",
-          headerName: "资产本地编码"
-        }, {
-          fieldName: "EquipID",
-          headerName: "资产id"
-        }, {
-          fieldName: "CreateTime",
-          headerName: "资产创建时间"
-        }, {
-          fieldName: "CodeType",
-          headerName: "资产现场验证状态"
-        }
+        fieldName: "Building.BuildLocalName",
+        headerName: "建筑"
+      }, {
+        fieldName: "Floor.FloorLocalName",
+        headerName: "楼层"
+      }, {
+        fieldName: "EquipFamilyList.0.FamilyName",
+        headerName: "资产设备族"
+      }, {
+        fieldName: "EquipLocalName",
+        headerName: "资产本地名称"
+      }, {
+        fieldName: "EquipLocalID",
+        headerName: "资产本地编码"
+      }, {
+        fieldName: "EquipID",
+        headerName: "资产id"
+      }, {
+        fieldName: "CreateTime",
+        headerName: "资产创建时间"
+      }, {
+        fieldName: "CodeType",
+        headerName: "资产现场验证状态"
+      }
       ]
     }
-  }, 
-  methods:{
-    handleClickDownload () {
+  },
+  methods: {
+    handleClickDownload() {
+      this.loading = true
+      this.dataList = []
       if (this.value == 'header1') {
-        let json = JSON.parse(this.json).Content.map((item) => {
+        this.getheader1Data()
+      } else if (this.value == 'header2') {
+        this.getheader2Data()
+      } else if (this.value == 'header3') {
+        this.getheader3Data()
+      }
+    },
+    getheader1Data(pageNum) {
+      pageNum = pageNum ? pageNum : 1
+      let params = {
+        Cascade: [
+          {
+            Name: "equipCategory",
+            Projection: ["EquipCode", "EquipName"]
+          },
+          {
+            Name: "property",
+            Projection: ["Family", "EquipLocalName", "EquipLocalID", "EquipID", "CodeType", "CreateTime"]
+          },
+          {
+            Name: "building",
+            Projection: ["BuildLocalName", "BuildName", "BuildID"]
+          },
+          {
+            Name: "floor",
+            Projection: ["FloorLocalName", "FloorName", "FloorID"]
+          }
+        ],
+        Filters: " not propertyId isnull ",
+        PageNumber: pageNum,
+        PageSize: 1000,
+        Projection: ["BuildingId", "FloorId", "Category", "EquipLocalName", "EquipLocalID", "EquipID", "BIMID"]
+      }
+      queryEquip(params, res => {
+        this.dataList = this.dataList.concat(res.Content.map((item) => {
           item.Property.CodeType = State[item.Property.CodeType]
           item.Property.Family = Family[item.Property.Family]
           return item
-        })
-        jsontoExcel.downloadExl(this.header1, json, '已建立关联的资产设备')
-      } else if (this.value == 'header2') {
-        let json = JSON.parse(this.json).Content
-        jsontoExcel.downloadExl(this.header2, json, '未关联资产的设备')
-      } else if (this.value == 'header3') {
-        let json = JSON.parse(this.json).Content.map((item) => {
+        }))
+        if (res.Total / (res.PageSize * res.PageNumber) > 1) {
+          this.getheader1Data(res.PageNumber + 1)
+        } else {
+          let time = +new Date()
+          this.loading = false
+          jsontoExcel.downloadExl(this.header1, this.dataList, `已建立关联的资产设备-${time}`)
+        }
+      })
+    },
+    getheader2Data(pageNum) {
+      pageNum = pageNum ? pageNum : 1
+      let params = {
+        Cascade: [
+          {
+            Name: "equipCategory",
+            Projection: ["EquipCode", "EquipName"]
+          },
+          {
+            Name: "building",
+            Projection: ["BuildLocalName", "BuildName", "BuildID"]
+          },
+          {
+            Name: "floor",
+            Projection: ["FloorLocalName", "FloorName", "FloorID"]
+          }
+        ],
+        Filters: " propertyId isnull ",
+        PageNumber: pageNum,
+        PageSize: 1000,
+        Projection: ["BuildingId", "FloorId", "Category", "EquipLocalName", "EquipLocalID", "EquipID", "BIMID"]
+      }
+      queryEquip(params, res => {
+        this.dataList = this.dataList.concat(res.Content)
+        if (res.Total / (res.PageSize * res.PageNumber) > 1) {
+          this.getheader2Data(res.PageNumber + 1)
+        } else {
+          let time = +new Date()
+          this.loading = false
+          jsontoExcel.downloadExl(this.header2, this.dataList, `未关联资产的设备-${time}`)
+        }
+      })
+    },
+    getheader3Data(pageNum) {
+      pageNum = pageNum ? pageNum : 1
+      let params = {
+        Cascade: [
+          {
+            Name: "equipFamilyList",
+            Projection: [ "Family", "FamilyName" ]
+          },
+          {
+            Name: "building",
+            Projection: [ "BuildLocalName", "BuildName", "BuildID" ]
+          },
+          {
+            Name: "floor",
+            Projection: [ "FloorLocalName", "FloorName", "FloorID" ]
+          }
+        ],
+        Filters: " EquipmentId isnull ",
+        PageNumber: pageNum,
+        PageSize: 1000,
+        Projection: [ "BuildingId", "FloorId", "Family", "EquipLocalName", "EquipLocalID", "EquipID", "CreateTime", "CodeType" ]
+      }
+      queryProperty(params, res => {
+        this.dataList = this.dataList.concat(res.Content.map((item) => {
           item.CodeType = State[item.CodeType]
           return item
-        })
-        jsontoExcel.downloadExl(this.header3, json, '未关联设备的资产')
-      }
+        }))
+        if (res.Total / (res.PageSize * res.PageNumber) > 1) {
+          this.getheader3Data(res.PageNumber + 1)
+        } else {
+          let time = +new Date()
+          this.loading = false
+          jsontoExcel.downloadExl(this.header3, this.dataList, `未关联设备的资产-${time}`)
+        }
+      })
     }
   }
 }