Browse Source

参数设置接口问题

suxinf 4 years ago
parent
commit
45c83b95c7

+ 1 - 1
src/App.vue

@@ -36,7 +36,7 @@ export default {
     return {
       navTitle1: ' > 数据管理',
       navTitle2: '',
-      isManufacturer: 'distributor', // distributor 经销商 manufacturer 厂商
+      isManufacturer: 'manufacturer', // distributor 经销商 manufacturer 厂商
     }
   },
   methods: {

+ 3 - 3
src/views/data/UploadInfor.vue

@@ -244,11 +244,11 @@ export default {
     },
     // 自定义添加
     addBySelf: function () {
-      let data = {
+      let dataObj = {
         queryParams: this.addByCustomize,
       };
-      this.getDlrData(data);
-      this.getAllDlr(data);
+      this.getDlrData(dataObj);
+      this.getAllDlr(dataObj);
     },
     // 按小组添加,增加小组
     addGroup: function (index) {

+ 12 - 8
src/views/parameter/LinkUpload.vue

@@ -111,12 +111,18 @@ export default {
       this.modalFlag = !this.modalFlag;
     },
     // 点击编辑
-    edit(index, newName) {
-      console.log(index, newName);
+    edit(index, newCount) {
+      let id = this.tableData[index]['id'];
+      this.updateGroupInfo(id, newCount).then(() => {
+        this.selectMediaPublishList();
+      })
     },
     // 点击删除
     deleteData(index) {
-      console.log("删除", index);
+      let id = this.tableData[index]['id'];
+      this.deleteGroupInfo(id).then(() => {
+        this.selectMediaPublishList();
+      })
     },
     // 模态框保存
     submit: function (time, num, obj) {
@@ -126,7 +132,6 @@ export default {
     },
     // slectPlatForm
     slectPlatForm: function (e) {
-      // console.log(1111, this.selectedForm);
       let index = e.target.options.selectedIndex;
       this.selectedplateForm = this.optionList[index];
       let id = this.optionList[0]['id'];
@@ -178,7 +183,7 @@ export default {
           if (res.data && res.data.code === 200) {
             console.log(res, 2222);
             this.sum = res.data.count;
-            this.tableData.push(res.data.data[0]); // 有八条是null,会报错,暂时取第一条
+            this.tableData = res.data.data;
             console.log(this.tableData);
           } else {
             console.log(res);
@@ -189,18 +194,17 @@ export default {
         });
     },
     // 编辑,接口
-    updateGroupInfo: function (id, platformName) {
+    updateGroupInfo: function (id, publishCount) {
       return new Promise((resolve, reject) => {
         this.$http({
           method: "post",
           url: "/sys/group/updateGroupInfo",
           data: {
             id,
-            platformName,
+            publishCount,
           },
         })
           .then((res) => {
-            console.log(res, 1111);
             if (res.data && res.data.code === 200) {
               console.log(res);
               resolve();

+ 42 - 7
src/views/parameter/components/Grouping/GroupMember.vue

@@ -95,16 +95,30 @@ export default {
     },
     // 点击删除
     deleteData (index) {
+      let req = {
+        id: this.tableData[index]['id'],
+        groupId: this.groupId
+      }
+      this.deleteAgentInfo(req).then(() => {
+        this.selectAgentInfoPage(this.groupId);
+      })
       console.log('删除', index);
     },
     // 新增车型模态框 保存
-    submit: function(list1, list2) {
+    submit: function(list) {
+      let req = {
+        groupId: this.groupId,
+        agentId: list
+      }
+      console.log(req, '入参')
+      this.groupAddDlr(req).then(() => {
+        this.selectAgentInfoPage(this.groupId);
+      })
        ///sys/agentGroup/bindAgentGroup 调用这个接口来新增小组成员
       // 入参 {
       //  groupId:groupId
       //  agentId:[经销商id1,经销商id2]
       // }
-        console.log('保存', list1, list2);
         this.modalFlag = false;
     },
     // 获取列表 接口
@@ -118,7 +132,7 @@ export default {
       })
         .then((res) => {
           if (res.data && res.data.code === 200) {
-            console.log(res);
+            console.log(res, '列表');
             this.tableData = res.data.data;
             this.sum = res.data.count;
           } else {
@@ -130,14 +144,12 @@ export default {
         });
     },
     // 删除平台模块 接口
-    deleteAgentInfo: function (groupId) {
+    deleteAgentInfo: function (data={}) {
       return new Promise((resolve, reject) => {
         this.$http({
           method: "post",
           url: "/sys/agent/deleteAgentInfo",
-          data: {
-            groupId
-          },
+          data
         })
           .then((res) => {
             if (res.data && res.data.code === 200) {
@@ -155,6 +167,29 @@ export default {
           });
       });
     },
+    // 新增分组下的经销商
+    groupAddDlr: function (data) {
+      return new Promise((resolve, reject) => {
+        this.$http({
+          method: "post",
+          url: "/sys/agentGroup/bindAgentGroup",
+          data
+        })
+          .then((res) => {
+            if (res.data && res.data.code === 200) {
+              console.log(res);
+              resolve();
+            } else {
+              alert("新增失败,请重试");
+              console.log(res);
+            }
+          })
+          .catch((err) => {
+            console.log(err);
+            reject(err);
+          });
+      });
+    },
   },
   mounted() {
     this.selectAgentInfoPage(this.groupId);

+ 62 - 50
src/views/parameter/components/Grouping/GroupMemberModal.vue

@@ -7,7 +7,7 @@
           <div v-for="(item, index) in areaList" :key="index">
             <input
               type="checkbox"
-              :value="item.sign"
+              :value="item.area"
               v-model="checkedBoxList"
             /><span>{{ item.area }}</span>
           </div>
@@ -20,11 +20,12 @@
             list="drls"
             class="inputStyle focusStyle"
             v-model="addByCustomize"
+            placeholder="DLR Code / 经销商"
           />
-          <datalist id="drls" value="12">
-            <option value="BMW" />
-            <option value="Ford" />
-            <option value="Volvo" />
+          <datalist id="drls">
+            <option v-for="(item, index) in dlrList" :key="index" :value="item">
+              {{ item }}
+            </option>
           </datalist>
           <button @click.prevent="addBySelf">添加</button>
         </div>
@@ -34,8 +35,9 @@
         <div class="table">
           <Table
             :tableData="tableData"
+            :currentPage="currentPage"
+            :pageSize="pageSize"
             @change_icon="changeIcon"
-            :imgFlag="imgFlag"
           >
           </Table>
         </div>
@@ -92,7 +94,7 @@ export default {
   },
   data() {
     return {
-      sum: 120,
+      sum: 0,
       pageSize: 10,
       currentPage: 1,
       areaList: [
@@ -123,37 +125,47 @@ export default {
         },
       ], // 按区域添加
       checkedBoxList: [],
-      addByCustomize: [],
+      addByCustomize: "",
       tableData: [],
-      imgFlag: new Array(this.pageSize).fill(true), // 筛选栏用添加图片还是删除图片
       dlrList: [],
       AllDlr: [],
+      idList: [],
     };
   },
   methods: {
     submit: function () {
-      this.$emit("submit", this.checkedBoxList, this.addByCustomize);
+      this.dlrIdList();
+      this.$emit("submit", this.idList);
     },
     hideModal: function () {
       this.$emit("hide_modal");
     },
     // 点击按区域添加button
     addByArea: function () {
-      console.log(this.checkedBoxList);
+      let req = {
+        localArea: this.checkedBoxList,
+      };
+      this.getDlrData(req);
     },
     // 自定义添加
     addBySelf: function () {
-      console.log(this.addByCustomize);
+      let req = {
+        queryParams: this.addByCustomize,
+      };
+      this.getDlrData(req);
     },
     // 筛选
     changeIcon: function (i) {
-      this.imgFlag.splice(i, 1, !this.imgFlag[i]);
-      console.log(i);
+      let index = (this.currentPage - 1) * this.pageSize + i;
+      this.AllDlr[index].flag = !this.AllDlr[index].flag;
     },
     // 获取某一页面的数据,展示在表格
     changePage: function (page) {
       this.currentPage = page;
-      console.log(page);
+      this.tableData = this.AllDlr.slice(
+        (this.currentPage - 1) * this.pageSize,
+        this.currentPage * this.pageSize
+      );
     },
     // 点击上一页,下一页,首页,尾页
     jumpPage: function (item) {
@@ -171,43 +183,24 @@ export default {
           this.currentPage = this.totalPage;
           break;
       }
-      console.log(this.currentPage);
+      this.tableData = this.AllDlr.slice(
+        (this.currentPage - 1) * this.pageSize,
+        this.currentPage * this.pageSize
+      );
     },
     mousewheel: function (e) {
       e.preventDefault();
     },
-    // 获取所有经销商信息接口
-    getAllDlr: function (data = {}) {
-      this.$http({
-        method: "post",
-        url: "/sys/agent/selectAgentInfoList",
-        data: data,
-      })
-        .then((res) => {
-          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);
-        });
+    // 选中经销商的id 组成列表
+    dlrIdList: function () {
+      this.idList = [];
+      this.AllDlr.forEach((element) => {
+        if(element.flag) {
+          this.idList.push(element.id);
+        }
+      });
     },
-    // 分页获取所有进销商信息接口
+    // 获取进销商信息 接口
     getDlrData: function (data = {}) {
       this.$http({
         method: "post",
@@ -215,9 +208,29 @@ export default {
         data: data,
       })
         .then((res) => {
+          this.tableData = [];
+          this.AllDlr = [];
+          this.dlrList = [];
           if (res.data && res.data.code === 200) {
-            this.tableData = res.data.data;
+            // 整合数据, 主要目的是加一个 flag,在用户点击筛选的时候,好判断
+            res.data.data.forEach((item) => {
+              this.AllDlr.push({
+                id: item.id,
+                dlrCode: item.dlrCode,
+                dlrName: item.dlrName,
+                localArea: item.localArea,
+                flag: true,
+              });
+            });
             this.sum = res.data.count;
+            this.tableData = this.AllDlr.slice(0, this.pageSize);
+            // 获取自定义添加datalist下拉框的值
+            if (this.dlrList.length === 0) {
+              this.AllDlr.forEach((item) => {
+                this.dlrList.push(item.dlrName);
+                this.dlrList.push(item.dlrCode);
+              });
+            }
           } else {
             console.log(res);
           }
@@ -229,7 +242,7 @@ export default {
   },
   created() {
     this.getDlrData();
-  }
+  },
 };
 </script>
 
@@ -248,7 +261,6 @@ export default {
     width: 800px;
     height: 650px;
     background-color: #fff;
-    transform: translateY(-50px);
     padding: 20px 30px;
     .addByArea {
       display: flex;

+ 16 - 21
src/views/parameter/components/Grouping/ModalTable.vue

@@ -16,15 +16,15 @@
           :key="index"
           :class="{ table_gray: index % 2 === 0 }"
         >
-          <td >{{ index + 1 }}</td>
-          <td>{{ obj.dlrCode }}</td>
-          <td>{{ obj.dlrName }}</td>
-          <td>{{ obj.localArea }}</td>
-          <td >
+          <td style="width: 10%">{{ (currentPage-1) * pageSize + 1 + index }}</td>
+          <td style="width: 40%">{{ obj.dlrName }}</td>
+          <td style="width: 20%">{{ obj.dlrCode }}</td>
+          <td style="width: 15%">{{ obj.localArea }}</td>
+          <td style="width: 15%">
             <img
               src="../../../../img/add.png"
               @click="changeIcon(index)"
-              v-if="imgFlag[index]"
+              v-if="!obj.flag"
             />
             <img
               src="../../../../img/delete.png"
@@ -48,23 +48,19 @@ export default {
         return [];
       },
     },
-    // imgFlag
-    imgFlag: {
-      type: Array,
-      default: () => {
-        let arr = new Array(20).fill(20);
-        return arr;
-      },
-    },
     // 每页表格共有多少数据
     pageSize: {
       type: Number,
       default: 20,
     },
+    // 当前展示第几页
+    currentPage: {
+      type: Number,
+      default: 1,
+    },
   },
   methods: {
     changeIcon: function (index) {
-      console.log(index);
       this.$emit("change_icon", index);
     },
   },
@@ -99,17 +95,16 @@ export default {
       }
     }
     tbody {
-        tr{
+      tr {
         height: 36px;
-
-        }
+      }
       td {
         background: #ffffff;
         height: 36px;
         width: 20%;
-        img{
-            height: 20px;
-            width: 20px;
+        img {
+          height: 20px;
+          width: 20px;
         }
       }
     }

+ 13 - 14
src/views/parameter/components/LinkUpload/Table.vue

@@ -15,15 +15,11 @@
           :key="index"
           :class="{ table_gray: index % 2 === 0 }"
         >
-          <td>{{obj.createDate || ''}}</td>
-          <td>{{obj.publishPlatformName || ''}}</td>
+          <td>{{ obj.publishMonth || "" }}</td>
+          <td>{{ obj.publishPlatformName || "" }}</td>
           <td style="width: 20%">
-            <p v-if="!editFlag[index]">{{ obj.publishCount || '' }}</p>
-            <input
-              type="text"
-              v-model="newName"
-              v-else
-            />
+            <p v-if="!editFlag[index]">{{ obj.publishCount || "" }}</p>
+            <input type="text" v-model="newName" v-else />
           </td>
           <td style="width: 25%" class="operation">
             <span @click="edit(index)" v-if="!editFlag[index]">编辑</span>
@@ -72,18 +68,21 @@ export default {
   methods: {
     edit: function (i) {
       this.getEditArr(); // 确保只有一个在编辑
-      this.newName = this.tableData[i] && this.tableData[i].num;
+      this.newName = this.tableData[i] && this.tableData[i].publishCount;
       console.log(this.newName);
       this.editFlag.splice(i, 1, true);
     },
     // 确认编辑
     submitEdit: function (i) {
-      if (!this.newName || typeof this.newName !== "number") {
-        alert("空值或者不是数字");
-      } else if (this.newName === this.tableData[i].publishCount) {
+      let newCount = +this.newName;
+      if (!newCount) {
+        alert("请填写链接上传数量");
+      } else if (newCount === this.tableData[i].publishCount) {
         this.newName = ""; // 没有改
+      } else if (Math.ceil(newCount) !== newCount || Math.ceil(newCount) <=0) {
+        alert("链接上传数量必须是大于零的整数");
       } else {
-        this.$emit("edit", i, this.newName);
+        this.$emit("edit", i, newCount);
       }
       this.newName = "";
       this.editFlag.splice(i, 1, false);
@@ -110,7 +109,7 @@ export default {
   },
   created() {
     this.getEditArr();
-  }
+  },
 };
 </script>