Browse Source

金额导出

xiao547607 4 years ago
parent
commit
5e93f0f7c4
3 changed files with 59 additions and 12 deletions
  1. 6 1
      src/api/bus/priceInfo.js
  2. 0 1
      src/api/bus/routeInfo.js
  3. 53 10
      src/views/bus/routeInfo-price-list.vue

+ 6 - 1
src/api/bus/priceInfo.js

@@ -45,6 +45,11 @@ function searchRoutePrice(formData){
   return request.post(constant.serverUrl + "/bus/priceInfo/searchRoutePrice", formData);
 }
 
+function exportXls(formData) {
+  //导出xls
+  return request.post(constant.serverUrl + "/bus/priceInfo/exportXls", formData);
+}
+
 export default {
-  pageList,create,edit,add,update,remove,batchRemove,searchRoutePrice
+  pageList,create,edit,add,update,remove,batchRemove,searchRoutePrice,exportXls
 }

+ 0 - 1
src/api/bus/routeInfo.js

@@ -50,7 +50,6 @@ function updateMapPath(formModel) {
   });
 }
 
-
 export default {
   create, edit, add, update, remove, batchRemove, pageList,updateMapPath
 }

+ 53 - 10
src/views/bus/routeInfo-price-list.vue

@@ -11,6 +11,14 @@
     </el-breadcrumb>
     <el-divider></el-divider>
     <el-row class="button-group">
+      <el-button
+          type="primary"
+          size="mini"
+          icon="ios-search"
+          @click="changePage()"
+          :loading="loading"
+          >查询</el-button
+        >
       <el-button
         type="primary"
         size="small"
@@ -19,6 +27,14 @@
         @click="batchImportVisible = true"
         >导入</el-button
       >
+      <el-button
+        type="primary"
+        size="small"
+        plain
+        icon="el-icon-download"
+        :loading="xlsLoading"
+        @click="downloadAll"
+      >导出数据</el-button>
     </el-row>
     <el-table
       :data="tableData"
@@ -62,7 +78,7 @@
       <el-form label-width="150px">
         <el-form-item label="模板下载">
           <el-link
-            href="http://rccs.oss-cn-hangzhou.aliyuncs.com/smart-bus/excel/routeInfo.xls"
+            href="http://ipcps.oss-cn-hangzhou.aliyuncs.com/upload/picture/2019/4/importTemplate.xlsx"
             type="primary"
             target="_blank"
             >点击下载模板</el-link
@@ -71,7 +87,7 @@
         <el-form-item label="上传文件">
           <el-upload
             class="upload-demo"
-            accept=".xls"
+            accept=".xlsx"
             :action="uploadUrlXls"
             :data="uploadXlsData"
             :headers="headers"
@@ -90,7 +106,7 @@
               >点击上传</el-button
             >
             <div slot="tip" class="el-upload__tip">
-              只能上传xls文件,且不超过500kb
+              只能上传xlsx文件,且不超过500kb
             </div>
           </el-upload>
         </el-form-item>
@@ -156,12 +172,12 @@ export default {
     indexMethod(index) {
       return (this.pageIndex - 1) * this.pageSize + (index + 1);
     },
-    changePage(routeId) {
+    changePage() {
       var self = this;
       self.loading = true;
       var formData = new FormData();
 
-      formData.append("routeId", routeId);
+      formData.append("routeId", self.routeId);
 
       priceInfoApi
         .searchRoutePrice(formData)
@@ -209,7 +225,7 @@ export default {
             if (jsonData.result) {
               // var index = self.tableData.indexOf(record);
               // self.tableData.splice(index, 1);
-              self.changePage(self.pageIndex,self.routeId);
+              self.changePage();
 
               self.$message({
                 type: "success",
@@ -227,7 +243,7 @@ export default {
       this.showModal = false;
 
       if (refreshed) {
-        this.changePage(this.pageIndex,this.routeId);
+        this.changePage();
       }
     },
 
@@ -246,14 +262,14 @@ export default {
         self.xlsLoading = false;
         self.$message.success(response.message);
         this.batchImportFileList = [];
-        this.changePage(this.routeId);
+        this.changePage();
         this.uploadCompanyId = "";
         this.uploadXlsData.companyId = "";
         this.batchImportVisible = false;
       } else {
         //this.$message.error(response.message);
         this.batchImportFileList = [];
-        this.changePage(this.routeId);
+        this.changePage();
 
         if (response.data != null) {
           //下载有错误信息提示的报表
@@ -289,11 +305,38 @@ export default {
         } 个文件`
       );
     },
+    downloadAll() {
+      //导出
+      var self = this;
+      var formData = new FormData();
+
+      formData.append("routeId", self.routeId);
+
+      self.xlsLoading = true;
+      self.loading = true;
+
+      priceInfoApi.exportXls(formData).then(function (response) {
+        self.xlsLoading = false;
+        self.loading = false;
+        var jsonData = response.data;
+        if (jsonData.result) {
+          if (jsonData.data != null) {
+            self.$message({
+              showClose: true,
+              type: "success",
+              dangerouslyUseHTMLString: true,
+              message: `报表已生成,<a href="${jsonData.data}" target="_blank">点击下载报表</a>&nbsp;`,
+              duration: 30000,
+            });
+          }
+        }
+      });
+    },
   },
   mounted: function () {
     var routeId = this.$route.query.routeId;
     this.routeId = routeId;
-    this.changePage(routeId);
+    this.changePage();
   },
 };
 </script>