Browse Source

20211019前端代码提交

mashengyi 3 years ago
parent
commit
949f63ad89
2 changed files with 111 additions and 2 deletions
  1. 56 0
      src/views/selfCar/invoice.vue
  2. 55 2
      src/views/selfCar/selfCarTrade.vue

+ 56 - 0
src/views/selfCar/invoice.vue

@@ -4,6 +4,24 @@
         <el-row>
           <el-col :span="24">
             <div class="top">
+              <div class="top" >
+               <span style="margin-top: 10px;margin-bottom: 10px;">导入文件:</span>
+
+              <el-upload
+                class="upload-demo"
+                ref="upload"
+                style="margin-bottom: 10px"
+                action="http://invoice.back.jkcredit.com/dishonestuser/upload"
+                :on-preview="handlePreview"
+                :on-remove="handleRemove"
+                :on-change="handleSuccess"
+                :auto-upload="false">
+                <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
+                <el-button style="margin-left: 10px;" size="small" type="success" @click="batchUpload" v-loading.fullscreen.lock="fullscreenLoading">批量查询</el-button>
+                <el-button style="margin-left: 555px;" @click="DownloadTemplate">查询模板下载</el-button>
+
+              </el-upload>
+              </div>
              <div class="demo-input-suffix">
                 <el-input  placeholder="客户名称" class="input-demo" v-model="formCondition.companyName"></el-input>
                 <el-input  placeholder="etc卡号" class="input-demo" v-model="formCondition.cardId"></el-input>
@@ -185,6 +203,9 @@ import XLSX from "xlsx";
             formCondition:{
 
             },
+            formUserList: {
+            "file": ""
+            },
            invoiceTable:[],
             hightt:'0px',
             current: 1,
@@ -216,6 +237,41 @@ import XLSX from "xlsx";
               this.total = response.data.data.total;
             }
           },
+
+             // 下载模板
+          DownloadTemplate() {
+            var url = hostUrl+"noCar/templateDownload?fileName=7"
+            window.location.href= url;
+
+          },
+           handleRemove(file, fileList) {
+            console.log(file, fileList);
+          },
+
+          handlePreview(file) {
+            console.log(file);
+          },
+          handleSuccess (a) {
+            this.formUserList.file = a.raw;
+          },
+
+                // 批量上传模板信息
+          async batchUpload() {
+          this.fullscreenLoading = true;
+          const formData = new FormData();
+          formData.append('file', this.formUserList.file);
+          const response = await this.$http.post(`selfCar/batchImportSelfcarInvoices`,formData);
+          var {data: { code, msg, data }} = response;
+          if(code === 0 && msg === '1') {
+              this.fullscreenLoading = false;
+              this.invoiceTable = response.data.data;
+              this.total = response.data.data.length;
+          }else {
+            this.fullscreenLoading = false;
+            this.$message.error('数据存在错误,请检查文件中数据');
+          }
+        },
+
           // 分页方法
           handleSizeChange(val) {
             this.pagesize = val;

+ 55 - 2
src/views/selfCar/selfCarTrade.vue

@@ -4,6 +4,24 @@
         <el-row>
           <el-col :span="24">
             <div class="top">
+               <div class="top" >
+               <span style="margin-top: 10px;margin-bottom: 10px;">导入文件:</span>
+
+              <el-upload
+                class="upload-demo"
+                ref="upload"
+                style="margin-bottom: 10px"
+                action="http://invoice.back.jkcredit.com/dishonestuser/upload"
+                :on-preview="handlePreview"
+                :on-remove="handleRemove"
+                :on-change="handleSuccess"
+                :auto-upload="false">
+                <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
+                <el-button style="margin-left: 10px;" size="small" type="success" @click="batchUpload" v-loading.fullscreen.lock="fullscreenLoading">批量查询</el-button>
+                <el-button style="margin-left: 555px;" @click="DownloadTemplate">查询模板下载</el-button>
+
+              </el-upload>
+              </div>
                <div class="demo-input-suffix">
                <el-input  placeholder="客户名称" class="input-demo" v-model="formCondition.companyName"></el-input>
                 <el-input  placeholder="etc卡号" class="input-demo" v-model="formCondition.cardId"></el-input>
@@ -13,8 +31,8 @@
               <div class="demo-input-suffix" style="margin-top: 5px;margin-left: 10px;">
                  <el-date-picker v-model="formCondition.exTimeBegin" type="daterange" value-format="yyyy-MM-dd HH:mm:SS" range-separator="至" start-placeholder="交易时间始" end-placeholder="交易时间止"></el-date-picker>
                  <el-date-picker v-model="formCondition.aclTimeBegin" type="daterange" value-format="yyyy-MM-dd HH:mm:SS" range-separator="至" start-placeholder="申请开票时间始" end-placeholder="申请开票时间止"></el-date-picker>
-               <el-button type="success" style="margin-left: 1%;" @click="loadData">查询</el-button>
-               <el-button type="success" style="margin-left: 1%;" >更新</el-button>
+                 <el-button type="success" style="margin-left: 1%;" @click="loadData">查询</el-button>
+                 <el-button type="success" style="margin-left: 1%;" >更新</el-button>
                               <el-button type="primary" style="margin-left: 1%;" @click="exportExcel">导出报表</el-button>
               </div>
             </div>
@@ -110,6 +128,9 @@ import XLSX from "xlsx";
             formCondition:{
 
             },
+            formUserList: {
+            "file": ""
+            },
             selfcarTrade:[],
             hightt:'0px',
             current: 1,
@@ -141,6 +162,38 @@ import XLSX from "xlsx";
               this.total = response.data.data.total;
             }
           },
+            // 下载模板
+          DownloadTemplate() {
+            var url = hostUrl+"noCar/templateDownload?fileName=6"
+            window.location.href= url;
+
+          },
+           handleRemove(file, fileList) {
+            console.log(file, fileList);
+          },
+
+          handlePreview(file) {
+            console.log(file);
+          },
+          handleSuccess (a) {
+            this.formUserList.file = a.raw;
+          },
+                      // 批量上传模板信息
+      async batchUpload() {
+      this.fullscreenLoading = true;
+      const formData = new FormData();
+      formData.append('file', this.formUserList.file);
+      const response = await this.$http.post(`selfCar/batchImportSelfcarTrades`,formData);
+      var {data: { code, msg, data }} = response;
+      if(code === 0 && msg === '1') {
+         this.fullscreenLoading = false;
+         this.invoiceTable = response.data.data;
+         this.total = response.data.data.length;
+      }else {
+        this.fullscreenLoading = false;
+        this.$message.error('数据存在错误,请检查文件中数据');
+      }
+    },
           // 分页方法
           handleSizeChange(val) {
             this.pagesize = val;