Quellcode durchsuchen

Merge branch 'master' of http://121.40.40.223:3000/zizhong.wang/Lexus-media

306132416@qq.com vor 4 Jahren
Ursprung
Commit
a0d35205d2

+ 6 - 3
src/request/api.js

@@ -9,16 +9,19 @@ axios.defaults.timeout = 5000;
 // 请求拦截器
 axios.interceptors.request.use((config) => {
     let baseData = config.data;
-    if(config.method.toLowerCase() === 'post') {
+    if (config.method.toLowerCase() === 'post') {
         config.data = qs.stringify(config.data);
     }
-    if(config.url === '/firmsUpload'){ //针对上传文件的接口 data不做转义 否则会造成传值为空
+    if (config.url === '/firmsUpload') { //针对上传文件的接口 data不做转义 否则会造成传值为空
         config.data = baseData
         console.log(baseData)
+        config.headers = {
+            'content-Type': 'multipart/form-data'
+        }
     }
     return config;
 }, (err) => {
-    console.log('请求拦截',err);
+    console.log('请求拦截', err);
     return Promise.reject(err);
 })
 

+ 125 - 76
src/views/data/UploadInfor.vue

@@ -10,7 +10,7 @@
           @focus="hideTip"
           @blur="checkName()"
         />
-        <p v-show="tipFlag">资料名称不能重复,请重新输入</p>
+        <p v-show="tipFlag">{{ tipText }}</p>
       </div>
       <div class="inforDes">
         <span>资料描述</span
@@ -71,7 +71,7 @@
             <option
               v-for="(dlr, index) in dlrList"
               :key="index"
-              :value="dlr"
+              :value="dlr.dlrCode || dlr.dlrName"
             ></option>
           </datalist>
           <button @click.prevent="addBySelf">添加</button>
@@ -153,21 +153,23 @@ export default {
   watch: {},
   data() {
     return {
+      allDataNameList: [],
       tipFlag: false, // 是否展示提示
+      tipText: "资料名称不能重复,请重新输入",
       inforName: "",
       inforDes: "",
       materialTime: "",
       scope: "1", //1为共通 , 0为部分
       checkedBoxList: [], // 多选框选中的值
       addByCustomize: "",
-      dlrList: ["北京博瑞1", "北京博瑞2", "北京博瑞3"], // 自定义添加
+      dlrList: [], // 自定义添加
       addGroupList: [], // 添加的小组
       addFlag: [true, true, true, true, true, true], // 长度等于groupList.length
       optionFlag: false, // 是否展示按小组添加的选择栏
       fileDes: [], // 上传的文件名
       file: "", //上传的文件
       // 表格配置
-      sum: 240, // 一共有多少条数据
+      sum: 0, // 一共有多少条数据
       pageSize: 20, // 每页展示的数据
       currentPage: 1,
       areaList: AREASLIST, // 按区域添加
@@ -189,12 +191,20 @@ export default {
   methods: {
     // 检查名字是否重复 失去焦点判断
     checkName: function () {
-      if (this.inforName == 1) {
+      let include = this.allDataNameList.indexOf(this.inforName);
+      if (!this.inforName) {
+        this.tipText = "资料名不能为空";
         this.tipFlag = true;
+        return;
+      } else if (include > 0) {
+        this.tipText = "资料名称不能重复,请重新输入";
+        this.tipFlag = true;
+        return;
       }
     },
     // 名字不重复,隐藏提示
     hideTip: function () {
+      this.tipText = "资料名称不能重复,请重新输入";
       this.tipFlag = false;
     },
     // 素材时间变化
@@ -213,13 +223,13 @@ export default {
     // 保证多选框全区和其他的多选框互斥
     clickCheckbox(i) {
       let list = this.checkedBoxList;
-      let include = list.indexOf('all');
-      if(i===0) {
+      let include = list.indexOf("all");
+      if (i === 0) {
         this.checkedBoxList = [];
-        return
-      } 
-      if (include >= 0){
-        this.checkedBoxList.splice(0, 1)
+        return;
+      }
+      if (include >= 0) {
+        this.checkedBoxList.splice(0, 1);
       }
     },
     // 点击按区域添加button
@@ -229,6 +239,11 @@ export default {
     // 自定义添加
     addBySelf: function () {
       console.log(this.addByCustomize);
+      let data = {
+        dlrCode: this.addByCustomize,
+      };
+      this.getDlrData(data);
+      this.getAllDlr(data);
     },
     // 按小组添加,增加小组
     addGroup: function (index) {
@@ -277,43 +292,54 @@ export default {
           this.currentPage = this.totalPage;
           break;
       }
-      console.log(this.currentPage);
       this.getDlrData(this.currentPage);
     },
     // 点击提交,检查名字是否重复,获取数据
     submit: function () {
       this.checkName();
-      // if(!this.inforName){
-      //   alert('资料名称不能为空');
-      //   return false
-      // }
-      // if(!this.inforDes){
-      //   alert('资料描述不能为空');
-      //   return false
-      // }
-      // if(!this.inforName){
-      //   alert('资料名称不能为空');
-      //   return false
-      // }
       if (!this.tipFlag) {
-        console.log(this.inforName);
-        console.log(this.inforDes);
-        console.log(this.materialTime);
-        console.log(this.scope);
-        console.log(this.tableData);
-        const file = document.getElementById("fileInput").value;
-        console.log(file);
-        // console.log(document.getElementById('fileInput').files[0].name);
+        if (!this.inforDes) {
+          alert("资料描述不能为空");
+          return;
+        }
+        if (!this.materialTime) {
+          alert("素材事件不能为空");
+          return;
+        }
+        if (!this.file) {
+          alert("请导入附件");
+          return;
+        }
+        this.submitRequest();
       }
-      this.submitRequest();
+        this.submitRequest();
+    },
+    // 获取文件名
+    getFileInfo: function (event) {
+      this.file = event.target.files;
+      this.fileDes = [];
+        this.file.forEach((item) => {
+          this.fileDes.push(item.name);
+        });
+    },
+    // 获取当前的月份
+    getLocalMonth: function () {
+      let data = new Date();
+      let year = data.getFullYear();
+      let month = data.getMonth() + 1;
+      if (month < 10) {
+        month = "0" + month;
+      } else {
+        month = month + "";
+      }
+      this.localMonth = year + "-" + month;
     },
     // 提交接口
     submitRequest: function () {
       let paramData = new FormData();
       this.file.forEach((item) => {
-        console.log(item , 1111111);
-        paramData.append("file", this.item);
-      })
+        paramData.append("file", item);
+      });
       paramData.append("dataName", this.inforName);
       paramData.append("dataDesc", this.inforDes);
       paramData.append("sourceTime", this.materialTime);
@@ -322,76 +348,99 @@ export default {
       this.$http
         .uploadFile("/firmsUpload", paramData)
         .then((res) => {
-          console.log(res);
+          if (res.data && res.data.code === 200) {
+            alert("上传成功");
+          } else {
+            alert("上传失败,请重试");
+            console.log(res);
+          }
+        })
+        .catch((err) => {
+          alert("上传失败,请重试");
+          console.log(err);
+        });
+    },
+    // 获取所有资料名称
+    getAllDataName: function () {
+      this.$http({
+        method: "post",
+        url: "/firmsUploadList",
+      })
+        .then((res) => {
+          if (res.data && res.data.code === 200) {
+            (this.allDataNameList = []),
+              res.data.data.forEach((item) => {
+                this.allDataNameList.push(item.informationName);
+              });
+          } else {
+            console.log(res);
+          }
         })
         .catch((err) => {
           console.log(err);
         });
     },
     // 获取所有经销商信息接口
-    getAllDlr: function () {
+    getAllDlr: function (data = {}) {
       this.$http({
-        methods: "post",
+        method: "post",
         url: "/sys/agent/selectAgentInfoList",
-        data: {},
+        data: data,
       })
         .then((res) => {
-          console.log(res);
-          this.dlrList = res.data;
-          // this.tableData = this.tableData // 获取tableData的值
+          if (res.data && res.data.code === 200) {
+            this.dlrList = [];
+            this.AllDlr = res.data.data;
+            let resData = JSON.parse(JSON.stringify(res.data.data));
+            resData.forEach((item) => {
+              // 获取自定义下拉框的值
+              if (item.dlrCode || item.dlrName) {
+                this.dlrList.push({
+                  dlrCode: item.dlrCode,
+                });
+                this.dlrList.push({
+                  dlrName: item.dlrName,
+                });
+              }
+            });
+          } else {
+            console.log(res);
+          }
         })
         .catch((err) => {
           console.log(err);
         });
     },
     // 分页获取所有进销商信息接口
-    getDlrData: function (page) {
+    getDlrData: function (data = {}) {
       this.$http({
-        methods: "post",
+        method: "post",
         url: "/sys/agent/selectAgentInfoPage",
-        data: {
-          page: page
-        },
+        data: data,
       })
         .then((res) => {
-          console.log(res);
-          this.tableData = [
-            { name: "北京博瑞", code: "L020", area: "东区" },
-            { name: "a", code: "a", area: "N" },
-            { name: "a", code: "a", area: "N" },
-          ];
+          if (res.data && res.data.code === 200) {
+            this.tableData = res.data.data;
+            this.sum = res.data.count;
+          } else {
+            console.log(res);
+          }
         })
         .catch((err) => {
           console.log(err);
         });
     },
-    // 获取文件名
-    getFileInfo: function (event) {
-      this.file = event.target.files;
-      this.fileDes = [];
-      this.file.forEach((item) => {
-        this.fileDes.push(item.name);
-      })
-    },
-    // 获取当前的月份
-    getLocalMonth: function () {
-      let data = new Date();
-      let year = data.getFullYear();
-      let month = data.getMonth() + 1;
-      if (month < 10) {
-        month = "0" + month;
-      } else {
-        month = month + "";
-      }
-      this.localMonth = year + "-" + month;
-    },
   },
   mounted() {
     this.getLocalMonth();
   },
   created() {
-    this.getAllDlr(); // 放到点开进销商范围
-    this.getDlrData(1);
+    // 获取所有经销商信息
+    this.getAllDlr();
+    // 获取第一页经销商信息
+    this.getDlrData();
+    // 获取所有的资料名称
+    this.getAllDataName();
   },
 };
 </script>

+ 12 - 15
src/views/data/UploadRecord.vue

@@ -20,7 +20,7 @@
     </div>
     <div class="table">
       <Table
-        :tableData='data'
+        :tableData='tableData'
         @download='download'
         @delet='delet'
         @detail='detail'
@@ -59,13 +59,7 @@ export default {
       sum: 100, // 表格总数据
       currentPage: 1,
       pageSize: 20,
-      data: [
-        {informationName:'雷克萨斯ES上市', filePulishTime:'2021/04',accountScope: '共通', download1: 50, downloadCount: 25, fileUploadDate: '2021/03/10 18:19'},
-        {informationName:'雷克萨斯ES上市', filePulishTime:'2021/04',accountScope: '共通', download1: 50, downloadCount: 25, fileUploadDate: '2021/03/10 18:19'},
-        {informationName:'雷克萨斯ES上市', filePulishTime:'2021/04',accountScope: '共通', download1: 50, downloadCount: 25, fileUploadDate: '2021/03/10 18:19'},
-        {informationName:'雷克萨斯ES上市', filePulishTime:'2021/04',accountScope: '共通', download1: 50, downloadCount: 25, fileUploadDate: '2021/03/10 18:19'},
-        {informationName:'雷克萨斯ES上市', filePulishTime:'2021/04',accountScope: '共通', download1: 50, downloadCount: 25, fileUploadDate: '2021/03/10 18:19'}
-      ],
+      tableData: [],
     }
   },
   computed:{
@@ -128,17 +122,20 @@ export default {
       this.deleteInformationInfo(i);
     },
     detail: function(i) {
-      let id = this.data[i].id || i
+      let id = this.tableData[i].id || i
       this.$router.push({ query: { id: id } });
     },
     // 上传记录列表接口
-    getFirmsUploadList: function(data) {
-      this.$http(({
-        methods: 'post',
+    getFirmsUploadList: function() {
+      this.$http({
+        method: 'post',
         url: '/firmsUploadList',
-        data: data
-      })).then((res) => {
-        console.log(res);
+        data: {}
+      }).then((res) => {
+        if(res.data && res.data.code === 200) {
+          console.log(res.data.data);
+          this.tableData = res.data.data;
+        }
       }).catch((err) => {
         console.log(err);
       })

+ 4 - 4
src/views/data/components/UploadInforTable.vue

@@ -11,11 +11,11 @@
             </tr>
         </thead>
         <tbody>
-            <tr v-for="(obj, index) in tableData" :key="index" :class="{ table_gray: index%2 === 0 }">
+            <tr v-for="(item, index) in tableData" :key="index" :class="{ table_gray: index%2 === 0 }">
                 <td>{{ index + 1 }}</td>
-                <td v-for="(item, index) in obj" :key="index"   >
-                    {{ item }}
-                </td>
+                <td >{{item.dlrName}}</td>
+                <td >{{item.dlrCode}}</td>
+                <td >{{item.localArea}}</td>
                 <td>
                     <img src="../../../img/add.png" @click="changeIcon(index)" v-if="imgFlag[index]">
                     <img src="../../../img/delete.png" @click="changeIcon(index)" v-else>