Переглянути джерело

下载接口,反馈功能,分页,路由跳转修复

liuYb 4 роки тому
батько
коміт
49eced98ad

+ 52 - 73
src/components/Modal.vue

@@ -1,7 +1,6 @@
 <template>
   <div class="modal-backdrop">
     <div class="modal">
-      <!--  id="unloadFile" :style="mainStyles"-->
       <div class="modal-header">
         <span>编辑</span>
       </div>
@@ -29,7 +28,7 @@
               <option
                 v-for="(item, index) in carSeries"
                 :key="index"
-                :value="item.id"
+                :value="item.typeName"
               >
                 {{ item.typeName }}
               </option>
@@ -134,12 +133,6 @@ export default {
         return "";
       },
     },
-    /*   sonPlatformId: {
-      type: String,
-      default: () => {
-        return "";
-      },
-    }, */
     releasePlate: {
       type: Array,
       default: () => {
@@ -154,7 +147,6 @@ export default {
       carType: [],
       content1: [],
       content2: [],
-      // releasePlate: [],this.LinkData.carTypeName
 
       carS: "",
       carT: "",
@@ -163,7 +155,7 @@ export default {
       content1Id: "",
       content2Id: "",
 
-      carTypeName: "",
+      carTypeId: "",
       contentTypeName: "",
       informationId: "",
       mediaTitle: "",
@@ -176,43 +168,14 @@ export default {
       ziliaoTime: "",
       contentName1: "",
       contentName2: "",
-
     };
   },
   methods: {
     closeSelf() {
       this.$emit("closeme");
-       console.log(this.LinkData);
+      console.log(this.LinkData);
     },
-    /*  getAllFileInfo: function () {
-      let obj = {};
-      //获取资料名
-      obj = this.dataName.find(function (item) {
-        return item.id === this.ziliaoId;
-      });
-      this.ziliaoName = obj.informationName;
-      //获取车系
-      obj = this.carSeries.find(function (item) {
-        return item.id === this.ziliaoId;
-      });
-      this.carTypeName = obj.typeName;
-      //获取车型 this.carT
-      //获取平台 this.selectedPlatform,
-      let info = {
-        informationName: this.ziliaoName,
-        releaseTime: this.ziliaoTime,
-        carService: this.carTypeName,
-        carType: this.carT,
-        releasePlate: this.selectedPlatform,
-        releaseMedia: this.releaseP,
-        contentClass: "",
-        articleTitle: this.mediaTitle,
-        articleLink: this.mediaUrl,
-      };
-      console.log(info);
-    }, */
-    //message: "没有找到经销商信息"// url: "/importDealerFeedback",
-    //message: "没有要导入的文件"
+
     edit: function () {
       let obj = {};
       //获取资料名
@@ -221,12 +184,14 @@ export default {
         return item.id === idVal;
       });
       this.ziliaoName = obj.informationName;
-      //获取车系
-      let idCarS = this.carS;
+      //获取车系 id
+      let nameCarS = this.carS;
       obj = this.carSeries.find(function (item) {
-        return item.id === idCarS;
+        return item.typeName === nameCarS;
       });
-      this.carTypeName = obj.typeName;
+      console.log("chexi ", obj)
+      //carTypeId  表示车系 id
+      this.carTypeId = obj.id;
       //获取车型名 this.carT
       //获取平台名 this.selectedPlatform,
 
@@ -243,7 +208,7 @@ export default {
           dataId: this.ziliaoId,
           informationName: this.ziliaoName,
           releaseTime: this.ziliaoTime,
-          carService: this.carTypeName,
+          carService: this.carS,
           carType: this.carT,
           releasePlate: this.selectedPlatform,
           releaseMedia: this.releaseP,
@@ -260,12 +225,14 @@ export default {
     chooseDataName: function () {
       this.$http({
         url: "/firmsUploadListByAgent",
+        //url: "/firmsLinkUpload",
         method: "post",
         data: {},
       })
         .then((res) => {
           if (res.data.code === 200) {
             this.dataName = res.data.data;
+            console.log(this.dataName);
           }
         })
         .catch((err) => {
@@ -273,25 +240,7 @@ export default {
         });
     },
     //发布版块
-    /*  chooseReleasePlate: function () {
-      console.log(this.sonPlatformId)
-      this.$http({
-        url: "/base/publishPlatformManager/selectPublishPlatformList",
-        method: "post",
-        data: {
-          parentId: this.sonPlatformId
-        },
-      })
-        .then((res) => {
-          console.log(res)
-          if (res.data.code === 200) {
-            this.releasePlate = res.data.data;
-          }
-        })
-        .catch((err) => {
-          console.log(err);
-        });
-    }, */
+    /*  chooseReleasePlate: function () {}, */
 
     //不分页查询车系车型信息
     chooseCarSeries: function () {
@@ -311,11 +260,19 @@ export default {
         });
     },
     chooseCarType: function () {
+      //获取车系 id
+      let obj={};
+      let nameCarS = this.carS;
+      obj = this.carSeries.find(function (item) {
+        return item.typeName === nameCarS;
+      });
+      this.carTypeId = obj.id;
+
       this.$http({
         url: "/base/carTypeManager/selectCarTypeList",
         method: "post",
         data: {
-          parentId: this.carS || -1,
+          parentId: this.carTypeId || -1,
         },
       })
         .then((res) => {
@@ -404,15 +361,31 @@ export default {
           console.log(err);
         });
     },
-    
+
     initialData: function () {
-      this.ziliaoId=this.LinkData.id;
-      this.carS=this.LinkData.carTypeName;
-      this.carT=this.LinkData.carPlatformName;
-      console.log(this.LinkData);
-      console.log(this.ziliaoId);
-    }
+      // this.ziliaoId = this.LinkData.id;
+      this.mediaTitle = this.LinkData.mediaTitle;
+      this.mediaUrl = this.LinkData.mediaUrl;
+      this.carS = this.LinkData.carTypeName;
+      
+      this.carT = this.LinkData.carPlatformName;
+      let time = this.LinkData.publishDate;
+      let m = time.slice(time.length-2,time.length);
+      let y = time.slice(0,4);
+      let temp=y + "-" + m + "-" + "01";
+      this.ziliaoTime = temp;
+      console.log("console.log(this.forceUpdate);", typeof time, m ,y);
 
+      //缺少对应列表值 已有资料名在数据中无法查询到
+      this.releaseP = this.LinkData.publishSourceName;
+      
+      this.contentName1 = this.LinkData.contentTypeName;
+      this.contentName2 = this.LinkData.contentTypeName;
+    },
+    /*  forceUpdata: function () { 
+      this.$forceUpdate();
+      console.log("console.log(this.forceUpdate);");
+    }, */
   },
   mounted() {
     this.chooseDataName();
@@ -420,8 +393,14 @@ export default {
     this.firstContent1Classify();
     this.firstContent2Classify();
     //this.chooseReleasePlate();
+
     this.initialData();
   },
+/*   created() {
+    console.log(this.LinkData);
+    this.ziliaoId = this.LinkData.id;
+    console.log(this.ziliaoId);
+  }, */
 };
 </script>
 

+ 44 - 35
src/views/data/InforList.vue

@@ -1,6 +1,6 @@
 <template>
   <div>
-    <div class="upload_record" v-if="initialPage">
+    <div class="upload_record" v-if="!isShowDetail">
       <!--   <h1>资料列表</h1> -->
       <div class="search HeadLeft">
         <div class="input">
@@ -70,7 +70,7 @@
                 <td>{{ obj.accountScope === 1 ? "共通" : "部分" }}</td>
                 <td>{{ obj.fileUploadDate || "2021/01/10 12:12" }}</td>
                 <td>{{ obj.download > 0 ? "已下载" : "未下载" }}</td>
-                <td>{{ obj.report === '1' ? "已反馈" : "未反馈" }}</td>
+                <td>{{ obj.report === "1" ? "已反馈" : "未反馈" }}</td>
 
                 <td v-if="operation" :style="trStyle" class="operationStyle">
                   <span
@@ -128,11 +128,12 @@ export default {
   },
   data() {
     return {
+      nowIndex: 0,
       searchName: "",
       timeSortVal: "",
       reportSortVal: "",
       downloadSortVal: "",
-      initialPage: this.detailVisible,
+      //initialPage: true,
       tableHeaderD: [
         "资料名称",
         "素材时间",
@@ -150,7 +151,7 @@ export default {
               url: "/dealerDownload",
               data: {
                 informationId: obj.id,
-               // agentId: obj.agentId,
+                // agentId: obj.agentId,
               },
             };
             this.downloadPost(config);
@@ -199,6 +200,7 @@ export default {
         height: "30px",
         overflow: "hidden",
       },
+      onlineUrl:'http://8.136.230.133:8080'
     };
   },
   computed: {
@@ -206,6 +208,9 @@ export default {
     totalPage() {
       return Math.ceil(this.sum / this.pageSize);
     },
+    isShowDetail() {
+      return this.$route.query && this.$route.query.tag ? true : false;
+    },
   },
   methods: {
     feedback: () => {
@@ -236,15 +241,18 @@ export default {
           break;
       }
       console.log(this.currentPage);
+      this.getDataListPage(this.currentPage)
     },
     //下载文件
     downloadPost: function (config) {
       console.log("下载文件:", config);
-      return new Promise((resolve, reject) => {
+      let url = this.onlineUrl+"/dealerDownload?informationId="+config.data.informationId 
+      window.open(url)
+    /*   return new Promise((resolve, reject) => {
         this.$http({
           url: config.url,
-          method: "post",
-          data: config.data,
+          method: "get",
+          params: config.data,
         })
           .then((res) => {
             console.log(res);
@@ -261,7 +269,7 @@ export default {
           .catch((err) => {
             reject(err);
           });
-      });
+      }); */
     },
     //查看详情
     showDetail: function (config) {
@@ -278,14 +286,18 @@ export default {
         .catch((err) => {
           console.log(err);
         });
-      this.initialPage = !this.initialPage;
+      //this.initialPage = !this.initialPage;
+      this.$router.push({ query: { tag: "infoListDetail" } });
     },
     //获取资料列表
     getDataList: function () {
       this.$http({
         url: "/firmsUploadListByAgent",
         method: "post",
-        data: {},
+        data: {
+          Page: this.currentPage,
+          Rows: this.pageSize,
+        },
       })
         .then((res) => {
           console.log(res);
@@ -298,7 +310,28 @@ export default {
           console.log(err);
         });
     },
-    //获取新的资料列表
+    //分页 获取资料列表
+    getDataListPage: function (nowpage) {
+      this.$http({
+        url: "/firmsUploadListByAgent",
+        method: "post",
+        data: {
+          Page: nowpage,
+          Rows: this.pageSize,
+        },
+      })
+        .then((res) => {
+          console.log(res);
+          if (res.data.code === 200) {
+            this.tableData = res.data.data;
+            //this.sum = res.data.count;
+          }
+        })
+        .catch((err) => {
+          console.log(err);
+        });
+    },
+    //条件筛选 获取新的资料列表
     newGetDataList: function (config) {
       console.log("new Getdata1", config);
       this.$http({
@@ -317,30 +350,6 @@ export default {
           console.log(err);
         });
     },
-    //以时间排序
-    /*     sortByTime: function () {
-      let asc = this.timeSortVal === "asc" ? false : true;
-      let data = {
-        asc: asc,
-      };
-      this.newGetDataList(data);
-    }, */
-    //反馈筛选
-    /* sortByReport: function () {
-      let reportId = this.reportSortVal === "already" ? true : false;
-      let data = {
-        reportId: reportId,
-      };
-      this.newGetDataList(data);
-    }, */
-    //下载筛选
-    /* sortByDownload: function () {
-      if (this.downloadSortVal === "notyet") {
-        console.log("notyet");
-      } else if (this.downloadSortVal === "already") {
-        console.log("already");
-      }
-    }, */
     //搜索资料名
     searchByName: function () {
       console.log("insearchByName", this.searchName);

+ 150 - 13
src/views/data/UploadLink.vue

@@ -37,8 +37,8 @@
             <td v-if="flag">{{ index + 1 }}</td>
             <td>{{ obj.publishDate }}</td>
             <!-- 发布日期 -->
-            <td>{{ obj.informationId }}</td>
-            <!-- 资料名称 待定-->
+            <td>{{ obj.informationName }}</td>
+            <!-- 资料名称 -->
             <td>{{ obj.carTypeName }}</td>
             <!-- 车系 -->
             <td>{{ obj.carPlatformName }}</td>
@@ -85,10 +85,12 @@
     </div>
     <div class="pageBottom">
       <div class="fileOperation">
-        <span class="operationStyle xiahuaxian">导入模板</span>
+        <span class="operationStyle xiahuaxian" @click="importTemplate"
+          >导入模板</span
+        >
         <!--  <button @click="toggleModal3()">导入</button> -->
         <!-- <button @click="importDataList">导入</button> -->
-        <label for="fileInput" @change="onImportExcel()"
+        <label for="fileInput" @change="getFileInfo($event)"
           >导入<input
             type="file"
             name="fileName"
@@ -96,14 +98,13 @@
             multiple
             accept=".xlsx, .xls"
         /></label>
-        <!-- <button @click="toggleModal4()">导出</button> -->
-        <label for="fileOutput" @change="onOutputExcel()"
-          >导出<input
+        <!-- <button @click="toggleModal4()">导出</button> <input
             type="file"
             name="fileName"
             id="fileOutput"
             accept=".xlsx, .xls"
-        /></label>
+        />-->
+        <label for="fileOutput" @click="onOutputExcel()">导出</label>
       </div>
       <TablePage
         :currentPage="currentPage"
@@ -174,6 +175,7 @@ export default {
 
       releasePlate: [],
       selectedPlatform: "",
+      selectedPlatformId: "",
       nowIndex: 0,
       /* modal */
       feedbackTimeLimit: 6,
@@ -270,6 +272,7 @@ export default {
         queryParams: null,
         startTime: null,
       },
+      file: "",
     };
   },
   computed: {
@@ -396,10 +399,8 @@ export default {
               i++, j++
             ) {
               this.tableData.splice(i, 1, data[j]);
-              console.log("399", this.tableData);
             }
             console.log(data.length, this.tableData.length);
-            console.log(data[0]);
             console.log(this.tableData);
           }
         })
@@ -430,10 +431,70 @@ export default {
         });*/
     },
     //导出excel
-    onOutputExcel: function () {},
+    onOutputExcel: function () {
+      this.$http({
+        url: "/exportNoFactory",
+        method: "get",
+        params: {
+          //id: this.selectedPlatformId //当期平台id
+        },
+      })
+        .then((res) => {
+          console.log(res);
+          if (res.data.code === 200) {
+            console.log(res.data);
+          }
+        })
+        .catch((err) => {
+          console.log(err);
+        });
+    },
     //导入excel
     onImportExcel: function () {
-      //
+      this.$http({
+        url: "/importDealerFeedback",
+        method: "get",
+        params: {},
+      })
+        .then((res) => {
+          console.log(res);
+          if (res.data.code === 200) {
+            console.log(res.data);
+          }
+        })
+        .catch((err) => {
+          console.log(err);
+        });
+    },
+    // 获取文件
+    getFileInfo: function (event) {
+      this.file = event.target.files;
+
+      let fileDes = [];
+      this.file.forEach((item) => {
+        fileDes.push(item.name);
+      });
+      console.log(fileDes);
+      this.submitRequest();
+    },
+    // 导入接口
+    submitRequest: function () {
+      let paramData = new FormData();
+      paramData.append("file", this.file);
+      this.$http
+        .uploadFile("/importDealerFeedback", paramData)
+        .then((res) => {
+          if (res.data && res.data.code === 200) {
+            console.log("上传成功!");
+          } else {
+            alert("上传失败,请重试");
+            console.log(res);
+          }
+        })
+        .catch((err) => {
+          alert("上传失败,请重试");
+          console.log(err);
+        });
     },
     //获取平台列表
     getPlatform: function () {
@@ -462,7 +523,7 @@ export default {
         return item.platformName === val;
       });
       this.selectedPlatform = val;
-
+      this.selectedPlatformId=obj.id;
       //获取可发布数量
       this.getReleaseQuantity(obj.id);
 
@@ -528,6 +589,82 @@ export default {
           console.log(err);
         });
     },
+    //导入模板
+    importTemplate: function () {
+      this.$http({
+        //url: "/exportNoFactory",
+        url: "/downloadTemplate",
+        method: "get",
+        params: {
+          templateName: "反馈链接上传导入表模板(经销商).xlsx",
+        },
+      })
+        .then((res) => {
+          console.log(res);
+          if (res.data.code === 200) {
+            console.log(res.data);
+          }
+        })
+        .catch((err) => {
+          console.log(err);
+        });
+      /*    return new Promise((resolve, reject) => {
+        this.$http({
+          url: "/exportNoFactory",
+          method: "get",
+          params: "反馈链接上传导入表模板(经销商).xlsx"
+        })
+          .then((res) => {
+            console.log(res);
+            resolve(res);
+            let link = document.createElement("a");
+            link.href = window.URL.createObjectURL(new Blob([res.data]));
+            link.target = "_blank";
+            //文件名和格式
+            link.download = "文件模板.xlsx";
+            document.body.appendChild(link);
+            link.click();
+            document.body.removeChild(link);
+          })
+          .catch((err) => {
+            reject(err);
+          });
+      }); */
+    },
+    //导入
+    importFile: function () {
+      this.$http({
+        url: "/importDealerFeedback",
+        method: "get",
+        params: "反馈链接上传导入表模板(经销商).xlsx",
+      })
+        .then((res) => {
+          console.log(res);
+          if (res.data.code === 200) {
+            console.log(res.data);
+          }
+        })
+        .catch((err) => {
+          console.log(err);
+        });
+    },
+    //导出
+ /*    outputFile: function () {
+      this.$http({
+        url: "/exportNoFactory",
+        method: "get",
+        params: "反馈链接上传导入表模板(经销商).xlsx",
+      })
+        .then((res) => {
+          console.log(res);
+          if (res.data.code === 200) {
+            console.log(res.data);
+          }
+        })
+        .catch((err) => {
+          console.log(err);
+        });
+    }, */
   },
   mounted() {
     this.getPlatform();

+ 32 - 14
src/views/data/components/InfoListItemDetail.vue

@@ -13,7 +13,7 @@
           <span>上传时间:</span>
           <span>{{ detailData[nowIndex].fileUploadDate }}</span>
         </div>
-       <!--  <div class="multiDetail">
+        <!--  <div class="multiDetail">
           <div class="firstColumn">
             <span>车系:</span>
             <span>{{
@@ -84,6 +84,7 @@ export default {
   data() {
     return {
       dataObj: {},
+      onlineUrl: "http://8.136.230.133:8080",
     };
   },
   computed: {
@@ -95,21 +96,32 @@ export default {
   methods: {
     // 下载附件
     downloadFile: function (index) {
-      let config={
+      let config = {
         informationId: this.fileData[index].informationId,
         fileId: this.fileData[index].id,
-      }
-      console.log("下载附件:", config);
-      return new Promise((resolve, reject) => {
+      };
+
+      let url =
+        this.onlineUrl +
+        "/selectInformationFileList?informationId=" +
+        config.informationId; //+
+      /* "&" +
+        "fileId=" +
+        config.fileId; */
+      console.log("下载附件:", config, url);
+      window.open(url);
+      /* 
+       return new Promise((resolve, reject) => {
         this.$http({
           //dealerDownload
           //url: '/selectInformationFileList',
-          url: '/dealerDownload',
-          method: "post",
-          data: config,
+          url: "/dealerDownload",
+          method: "get",
+          params: config,
         })
           .then((res) => {
             console.log(res);
+            window.open(res)
             resolve(res);
             let link = document.createElement("a");
             link.href = window.URL.createObjectURL(new Blob([res.data]));
@@ -123,10 +135,15 @@ export default {
           .catch((err) => {
             reject(err);
           });
-      });
+      }); */
     },
+
+    /* infoListDetail: function (i) {
+      this.$emit("infoListDetail", i);
+    }, */
   },
   mounted() {
+    /* this.infoListDetail(this.nowIndex); */
   },
 };
 </script>
@@ -167,17 +184,18 @@ export default {
   display: flex;
   align-items: center;
 }
-.firstColumn, .secondColumn {
+.firstColumn,
+.secondColumn {
   display: flex;
   align-items: center;
 }
 .firstColumn span:nth-child(1) {
- /*  width: 80px; */
+  /*  width: 80px; */
   display: block;
   margin-right: 16px;
 }
 .secondColumn span:nth-child(1) {
-/*   width: 80px; */
+  /*   width: 80px; */
   display: block;
   margin-left: 40px;
   margin-right: 16px;
@@ -193,7 +211,7 @@ export default {
 /* .detail span:nth-child(2){
   width: 150px;
 } */
-.filesName p{
-  color: #4B8EC7;
+.filesName p {
+  color: #4b8ec7;
 }
 </style>