Quellcode durchsuchen

问题修改&&php导入文件接口

suxinf vor 4 Jahren
Ursprung
Commit
df68ada88d

+ 133 - 57
src/components/Modal.vue

@@ -11,7 +11,12 @@
         </div>
         <div class="bodyRow timeWidth">
           <span>发布时间</span
-          ><input type="date" placeholder="选择时间" :max="localDay" v-model="ziliaoTime" />
+          ><input
+            type="date"
+            placeholder="选择时间"
+            :max="localDay"
+            v-model="ziliaoTime"
+          />
         </div>
         <div class="bodyRow">
           <!--  <div class="contentCol1">
@@ -66,7 +71,7 @@
               </select>
             </div>
             <div v-else>
-              <input type="text" v-model="releaseP">
+              <input type="text" v-model="releaseP" />
             </div>
           </div>
         </div>
@@ -158,7 +163,7 @@ export default {
     modalTitle: {
       type: String,
       default: "编辑",
-    }
+    },
   },
   data() {
     return {
@@ -197,8 +202,9 @@ export default {
 
       releaseChannel: [],
       releasePlate: [],
-      userId: '',
+      userId: "",
       localDay: "",
+      noEditFlag: false,
     };
   },
   methods: {
@@ -218,7 +224,73 @@ export default {
       }
       this.localDay = year + "-" + month + "-" + day;
     },
+    // 判断非空
+    boforeEdit: function () {
+      this.releaseP = (this.releaseP || '').replace(/\s/g, "");
+      this.mediaTitle = (this.mediaTitle || '').replace(/\s/g, "");
+      if (!this.ziliaoTime) {
+        this.noEditFlag = true;
+        alert("发布时间不能为空");
+        return;
+      }
+      if (!this.carT) {
+        this.noEditFlag = true;
+        alert("请选择车型");
+        return;
+      }
+      if (!this.releaseC) {
+        this.noEditFlag = true;
+        alert("请选择发布渠道");
+        return;
+      }
+      if (!this.releaseP) {
+        this.noEditFlag = true;
+        alert("请选择平台版块");
+        return;
+      }
+      if (!this.contentName1) {
+        this.noEditFlag = true;
+        alert("请选择稿件类别");
+        return;
+      }
+      if (!this.contentName2) {
+        this.noEditFlag = true;
+        alert("请选择内容分类");
+        return;
+      }
+      if (!this.readCount || this.readCount < 0) {
+        this.noEditFlag = true;
+        alert("请填写阅读量");
+        return;
+      }
+      if (!this.goodCount || this.goodCount < 0) {
+        this.noEditFlag = true;
+        alert("请填写点赞量");
+        return;
+      }
+      if (!this.bbsCount || this.bbsCount < 0) {
+        this.noEditFlag = true;
+        alert("请填写评论量");
+        return;
+      }
+      if (!this.lookingCount || this.lookingCount < 0) {
+        this.noEditFlag = true;
+        alert("请填写正确的再看/转发");
+        return;
+      }
+      if (!this.mediaTitle) {
+        this.noEditFlag = true;
+        alert("标题不能为空");
+        return;
+      }
+      if (!this.mediaUrl) {
+        this.noEditFlag = true;
+        alert("链接不能为空");
+        return;
+      }
+    },
     edit: function () {
+      this.noEditFlag = false;
       let obj = {};
       //获取资料名
       /*  let idVal = this.ziliaoId;
@@ -226,62 +298,65 @@ export default {
         return item.id === idVal;
       });
       this.ziliaoName = obj.informationName; */
-      //获取车系 id
-      let nameCarS = this.carS;
-      obj = this.carSeries.find(function (item) {
-        return item.typeName === nameCarS;
-      });
-      console.log("chexi ", obj);
-      //carTypeId  表示车系 id
-      // this.carTypeId = obj.id;
+      this.boforeEdit();
+      if (!this.noEditFlag) {
+        //获取车系 id
+        let nameCarS = this.carS;
+        obj = this.carSeries.find(function (item) {
+          return item.typeName === nameCarS;
+        });
+        console.log("chexi ", obj);
+        //carTypeId  表示车系 id
+        // this.carTypeId = obj.id;
 
-      //当前月份
-      let date = new Date();
-      let m = date.getMonth() + 1;
-      let y = date.getFullYear();
-      let d = y + "/" + m;
-      let config = {
-        url: "",
-        data: {
-          id: "", //主键值
-          month: d,
-          dealerId: this.userId,
-          dataId: this.ziliaoId,
-          informationName: this.ziliaoName,
-          releaseTime: this.ziliaoTime,
-          carService: this.carS,
-          carType: this.carT,
+        //当前月份
+        let date = new Date();
+        let m = date.getMonth() + 1;
+        let y = date.getFullYear();
+        let d = y + "/" + m;
+        let config = {
+          url: "",
+          data: {
+            id: "", //主键值
+            month: d,
+            dealerId: this.userId,
+            dataId: this.ziliaoId,
+            informationName: this.ziliaoName,
+            releaseTime: this.ziliaoTime,
+            carService: this.carS,
+            carType: this.carT,
 
-          //发布平台  渠道
-          releaseMedia: this.releaseC,
-          //发布板块
-          releasePlate: this.releaseP,
+            //发布平台  渠道
+            releaseMedia: this.releaseC,
+            //发布板块
+            releasePlate: this.releaseP,
 
-          draftGenre: this.contentName1,
+            draftGenre: this.contentName1,
 
-          //内容分类2?
-          contentClass: this.contentName2,
-          articleTitle: this.mediaTitle,
-          articleLink: this.mediaUrl,
+            //内容分类2?
+            contentClass: this.contentName2,
+            articleTitle: this.mediaTitle,
+            articleLink: this.mediaUrl,
 
-          readCount: this.readCount,
-          goodCount: this.goodCount,
-          bbsCount: this.bbsCount,
-          lookingCount: this.lookingCount,
-        },
-      };
+            readCount: this.readCount,
+            goodCount: this.goodCount,
+            bbsCount: this.bbsCount,
+            lookingCount: this.lookingCount,
+          },
+        };
 
-      if (this.LinkData.id) {
-        //编辑
-        config.url = "/updateDealerFeedback";
-        config.data.id = this.LinkData.id;
-      } else {
-        //新增
-        config.url = "/dealerFeedback";
-      }
+        if (this.LinkData.id) {
+          //编辑
+          config.url = "/updateDealerFeedback";
+          config.data.id = this.LinkData.id;
+        } else {
+          //新增
+          config.url = "/dealerFeedback";
+        }
 
-      this.$emit("update", config);
-      this.$emit("closeme");
+        this.$emit("update", config);
+        this.$emit("closeme");
+      }
     },
     //资料名称列表
     chooseDataName: function () {
@@ -342,7 +417,7 @@ export default {
         url: "/base/carTypeManager/selectCarTypeList",
         method: "post",
         data: {
-          parentId: this.carTypeId || '-',
+          parentId: this.carTypeId || "-",
         },
       })
         .then((res) => {
@@ -431,9 +506,10 @@ export default {
 
     initialData: function () {
       this.ziliaoName = this.fileName;
-      if(this.LinkData.informationId) this.ziliaoId = this.LinkData.informationId;
-      else{
-        this.ziliaoId =  this.$route.query.informationId;
+      if (this.LinkData.informationId)
+        this.ziliaoId = this.LinkData.informationId;
+      else {
+        this.ziliaoId = this.$route.query.informationId;
       }
 
       this.mediaTitle = this.LinkData.mediaTitle;

+ 5 - 1
src/request/api.js

@@ -1,5 +1,6 @@
 import axios from 'axios';
 import qs from 'qs';
+import { php_url } from "../config/env"
 // axios.defaults.baseURL = 'http://192.168.2.122:8080/api';
 axios.defaults.baseURL = '/api';
 axios.defaults.timeout = 5000;
@@ -9,6 +10,7 @@ axios.defaults.timeout = 5000;
 // 请求拦截器
 axios.interceptors.request.use((config) => {
     let baseData = config.data;
+    console.log('请求拦截', config);
     if (config.method.toLowerCase() === 'post') {
         config.data = qs.stringify(config.data);
     }
@@ -21,7 +23,9 @@ axios.interceptors.request.use((config) => {
     if (config.url === '/importDealerFeedback') { //针对经销商导入文件的接口 data不做转义 否则会造成传值为空
         config.data = baseData
     }
-
+    if(config.url === php_url + "/lexus_php/api/report_import.php") {
+        config.data = baseData
+    }
     return config;
 }, (err) => {
     console.log('请求拦截', err);

+ 32 - 18
src/views/data/UploadLink.vue

@@ -284,7 +284,7 @@ export default {
       file: "",
       dictList: [],
       onlineUrl: env_url, //'http://8.140.188.129:8080'线上 //http://8.136.230.133:8080 //测试,
-      otherUrl:php_url,
+      otherUrl: php_url,
       userId: '',
       //截止日期
       endTime: "",
@@ -359,7 +359,6 @@ export default {
     },
     /* 编辑内容,,Modal传参 */
     editTitle: function (val) {
-      console.log("edit文件:", val);
       this.$http({
         url: val.url,
         method: "post",
@@ -519,28 +518,43 @@ export default {
       this.file.forEach((item) => {
         fileDes.push(item.name);
       });
-        this.submitRequest();
+      this.submitRequest();
     },
     // 导入接口
     submitRequest: function () {
-      let paramData = new FormData();
+      const paramData = new FormData();
       this.file.forEach((item) => {
         paramData.append("file", item);
       });
-      this.$http
-        .uploadFile("/importDealerFeedback", paramData)
-        .then((res) => {
-          if (res.data && res.data.code === 200) {
-            console.log("上传成功!");
-          } else {
-            alert(res.data.message);
-            console.log(res);
-          }
-        })
-        .catch((err) => {
-          alert("上传失败,请重试");
-          console.log(err);
-        });
+      paramData.append("agentId", this.userId);
+      // this.$http
+      //   .uploadFile("/importDealerFeedback", paramData)
+      //   .then((res) => {
+      //     console.log(res);
+      //     if (res.data && res.data.code === 200) {
+      //       console.log("上传成功!");
+      //     } else {
+      //       alert(res.data.message);
+      //     }
+      //   })
+      //   .catch((err) => {
+      //     alert("上传失败,请重试");
+      //     console.log(err);
+      //   });
+      axiosTest({
+        method: 'post',
+        url: this.otherUrl + '/lexus_php/api/report_import.php',
+        data: paramData,
+        dataType: "json", //声明成功使用json数据类型回调
+        cache: false,
+        processData: false,
+        contentType: false,
+      }
+      ).then((res) => {
+        console.log(res);
+      }).catch((err) => {
+        console.log(err);
+      })
     },
     //获取平台列表
     getPlatform: function () {

+ 123 - 48
src/views/data/components/UploadLinkEditModal.vue

@@ -11,7 +11,12 @@
         </div>
         <div class="bodyRow timeWidth">
           <span>发布时间</span
-          ><input type="date" placeholder="选择时间"  :max="localDay" v-model="ziliaoTime" />
+          ><input
+            type="date"
+            placeholder="选择时间"
+            :max="localDay"
+            v-model="ziliaoTime"
+          />
         </div>
         <div class="bodyRow">
           <div class="contentCol1">
@@ -48,10 +53,10 @@
                 <option v-for="(item, index) in releasePlate" :key="index">
                   {{ item.platformName || "-" }}
                 </option>
-              </select>              
+              </select>
             </div>
             <div v-else>
-              <input type="text" v-model="releaseP">
+              <input type="text" v-model="releaseP" />
             </div>
           </div>
         </div>
@@ -68,7 +73,7 @@
             <span>内容分类</span
             ><select name="" id="" v-model="contentName2">
               <option v-for="(item, index) in content2" :key="index">
-                {{ item.dictName || '-' }}
+                {{ item.dictName || "-" }}
               </option>
             </select>
           </div>
@@ -155,8 +160,9 @@ export default {
       mediaTitle: this.LinkData.mediaTitle || "", //'文章标题',
       mediaUrl: this.LinkData.mediaUrl || "",
       dictList: [],
-      initParentId: '',
+      initParentId: "",
       localDay: "",
+      noEditFlag: false,
     };
   },
   methods: {
@@ -182,52 +188,121 @@ export default {
     closeSelf: function () {
       this.$emit("closeme");
     },
+    // 判断非空
+    boforeEdit: function () {
+      this.releaseP = (this.releaseP || '').replace(/\s/g, "");
+      this.mediaTitle = (this.mediaTitle || '').replace(/\s/g, "");
+      if (!this.ziliaoTime) {
+        this.noEditFlag = true;
+        alert("发布时间不能为空");
+        return;
+      }
+      if (!this.carTypeValue) {
+        this.noEditFlag = true;
+        alert("请选择车型");
+        return;
+      }
+      if (!this.releaseC) {
+        this.noEditFlag = true;
+        alert("请选择发布渠道");
+        return;
+      }
+      if (!this.releaseP) {
+        this.noEditFlag = true;
+        alert("请选择平台版块");
+        return;
+      }
+      if (!this.contentName1) {
+        this.noEditFlag = true;
+        alert("请选择稿件类别");
+        return;
+      }
+      if (!this.contentName2) {
+        this.noEditFlag = true;
+        alert("请选择内容分类");
+        return;
+      }
+      if (!this.readCount || this.readCount < 0) {
+        this.noEditFlag = true;
+        alert("请填写阅读量");
+        return;
+      }
+      if (!this.goodCount || this.goodCount < 0) {
+        this.noEditFlag = true;
+        alert("请填写点赞量");
+        return;
+      }
+      if (!this.bbsCount || this.bbsCount < 0) {
+        this.noEditFlag = true;
+        alert("请填写评论量");
+        return;
+      }
+      if (!this.lookingCount || this.lookingCount < 0) {
+        this.noEditFlag = true;
+        alert("请填写正确的再看/转发");
+        return;
+      }
+      if (!this.mediaTitle) {
+        this.noEditFlag = true;
+        alert("标题不能为空");
+        return;
+      }
+      if (!this.mediaUrl) {
+        this.noEditFlag = true;
+        alert("链接不能为空");
+        return;
+      }
+    },
     edit() {
-      //当前月份
-      let date = new Date();
-      let m = date.getMonth() + 1;
-      let y = date.getFullYear();
-      let d = y + "/" + m;
-      let config = {
-        url: "",
-        data: {
-          id: "",
-          month: d,
-          dealerId: this.userId,
-          dataId: this.ziliaoId,
-          informationName: this.ziliaoName,
-          //   releaseTime: this.ziliaoTime,
-          releaseTime: this.ziliaoTime,
-          carType: this.carTypeValue,
+      this.noEditFlag = false;
+      this.boforeEdit();
+      if (!this.noEditFlag) {
+        //当前月份
+        let date = new Date();
+        let m = date.getMonth() + 1;
+        let y = date.getFullYear();
+        let d = y + "/" + m;
+        let config = {
+          url: "",
+          data: {
+            id: "",
+            month: d,
+            dealerId: this.userId,
+            dataId: this.ziliaoId,
+            informationName: this.ziliaoName,
+            //   releaseTime: this.ziliaoTime,
+            releaseTime: this.ziliaoTime,
+            carType: this.carTypeValue,
 
-          //发布平台  渠道
-          releaseMedia: this.releaseC,
-          //发布板块
-          releasePlate: this.releaseP,
+            //发布平台  渠道
+            releaseMedia: this.releaseC,
+            //发布板块
+            releasePlate: this.releaseP,
 
-          draftGenre: this.contentName1,
+            draftGenre: this.contentName1,
 
-          //内容分类2?
-          contentClass: this.contentName2,
-          articleTitle: this.mediaTitle,
-          articleLink: this.mediaUrl,
+            //内容分类2?
+            contentClass: this.contentName2,
+            articleTitle: this.mediaTitle,
+            articleLink: this.mediaUrl,
 
-          readCount: this.readCount,
-          goodCount: this.goodCount,
-          bbsCount: this.bbsCount,
-          lookingCount: this.lookingCount,
-          //   informationId: "1386025423408103425"
-        },
-      };
-      if (this.LinkData.id) {
-        config.url = "/updateDealerFeedback";
-        config.data.id = this.LinkData.id;
-      } else {
-        //新增
-        config.url = "/dealerFeedback";
+            readCount: this.readCount,
+            goodCount: this.goodCount,
+            bbsCount: this.bbsCount,
+            lookingCount: this.lookingCount,
+            //   informationId: "1386025423408103425"
+          },
+        };
+        if (this.LinkData.id) {
+          config.url = "/updateDealerFeedback";
+          config.data.id = this.LinkData.id;
+        } else {
+          //新增
+          config.url = "/dealerFeedback";
+        }
+        this.$emit("update", config);
+        this.closeSelf();
       }
-      this.$emit("update", config);
-      this.closeSelf();
     },
     // 获取当前的月份
     getLocalMonth: function () {
@@ -291,7 +366,7 @@ export default {
                 this.releaseChannel = res.data.data;
                 this.releaseChannel.forEach((item) => {
                   if (item.platformName === initPlat) {
-                      this.initParentId = item.id;
+                    this.initParentId = item.id;
                   }
                 });
               } else {
@@ -302,7 +377,7 @@ export default {
           })
           .catch((err) => {
             console.log(err);
-            reject()
+            reject();
           });
       });
     },
@@ -378,7 +453,7 @@ export default {
       let req = {
         parentId: this.initParentId,
       };
-      this.channelType(req)
+      this.channelType(req);
     });
     this.selectSysDataDictList().then(() => {
       this.getContent1();