suxinf vor 4 Jahren
Ursprung
Commit
722c401c87

+ 1 - 0
src/views/data/UploadRecord.vue

@@ -142,6 +142,7 @@ export default {
         data: data,
       })
         .then((res) => {
+          console.log(res);
           if (res.data && res.data.code === 200) {
             this.tableData = res.data.data;
             this.sum = res.data.count;

+ 121 - 33
src/views/parameter/PlatformModule.vue

@@ -11,7 +11,7 @@
           @edit="edit"
           @delet_data="deleteData"
           @jump_router="jumpRouter"
-          :pageSize='sum'
+          :pageSize="sum"
         ></Table>
       </div>
       <div class="page">
@@ -23,7 +23,11 @@
         ></Tablepage>
       </div>
       <div class="modal" v-if="modalFlag">
-        <Modal :modalFlag="modalFlag" @hide_modal="showModal" @submit='submit'></Modal>
+        <Modal
+          :modalFlag="modalFlag"
+          @hide_modal="showModal"
+          @submit="submit"
+        ></Modal>
       </div>
     </div>
     <div v-else>
@@ -51,13 +55,7 @@ export default {
       sum: 100, // 一共有多少条数据
       pageSize: 20, // 每页展示的数据
       currentPage: 1,
-      // 表格配置
       tableData: [],
-      getDate: [
-        { platform: "汽车之家", str: "123" },
-        { platform: "其他", str: "124" },
-      ],
-      functionData: [],
       modalFlag: false, // 控制模态框展示
     };
   },
@@ -95,49 +93,139 @@ export default {
       }
       console.log(this.currentPage);
     },
-    // 获取数据
-    getData: function () {
-      this.tableData = [];
-      this.functionData = [];
-      this.getDate.forEach((element) => {
-        this.tableData.push({
-          platform: element.platform,
-        });
-        this.functionData.push({
-          str: element.str,
-        });
-      });
-    },
     // 展示、隐藏模态框
     showModal: function () {
       this.modalFlag = !this.modalFlag;
     },
     // 模态框保存
-    submit: function(plateName) {
-      console.log('plateName保存', plateName);
+    submit: function (plateName) {
+      this.addPublishPlatformInfo(plateName).then(() => {
+        this.selectPublishPlatformPage();
+      });
       this.modalFlag = false;
     },
     // 点击编辑
     edit(index, newName) {
-      console.log(this.functionData[index].str, newName);
+      let id = this.tableData[index]["id"];
+      console.log(id);
+      this.updatePublishPlatformInfo(id, newName).then(() => {
+        this.updatePublishPlatformInfo();
+      });
     },
     // 点击删除
-    deleteData: function(index) {
-      console.log("删除", this.functionData[index].str);
+    deleteData: function (index) {
+      let id = this.tableData[index]['id'];
+      this.deletePublishPlatformInfo(id).then(() => {
+        this.selectPublishPlatformPage();
+      })
     },
     // 点击系列车型
-    jumpRouter: function(index) {
+    jumpRouter: function (index) {
       // 页面变化
       this.$router.push({ query: { tag: "detail" } });
       console.log("点击平台模块", this.functionData[index].str);
     },
-    // 删除数据
-    detletData: function() {
-      console.log('删除数据');
-    }
+    // 新增平台 接口
+    addPublishPlatformInfo: function (platformName) {
+      return new Promise((resolve, reject) => {
+        this.$http({
+          method: "post",
+          url: "/base/publishPlatformManager/addPublishPlatformInfo",
+          data: {
+            platformName,
+          },
+        })
+          .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);
+          });
+      });
+    },
+    // 获取列表 接口
+    selectPublishPlatformPage: function () {
+      this.$http({
+        method: "post",
+        url: "/base/publishPlatformManager/selectPublishPlatformPage",
+        data: {},
+      })
+        .then((res) => {
+          if (res.data && res.data.code === 200) {
+            console.log(res);
+            this.tableData = res.data.data;
+            this.sum = res.data.count;
+          } else {
+            console.log(res);
+          }
+        })
+        .catch((err) => {
+          console.log(err);
+        });
+    },
+    // 编辑接口
+    updatePublishPlatformInfo: function (id, platformName) {
+      return new Promise((resolve, reject) => {
+        this.$http({
+          method: "post",
+          url: "/base/publishPlatformManager/updatePublishPlatformInfo",
+          data: {
+            id,
+            platformName,
+          },
+        })
+          .then((res) => {
+            console.log(res, 1111);
+            if (res.data && res.data.code === 200) {
+              console.log(res);
+              resolve();
+            } else {
+              alert("编辑失败,请重试");
+              console.log(res);
+            }
+          })
+          .catch((err) => {
+            alert("编辑失败,请重试");
+            console.log(err);
+            reject(err);
+          });
+      });
+    },
+    deletePublishPlatformInfo: function (id) {
+      return new Promise((resolve, reject) => {
+        this.$http({
+          method: "post",
+          url: "/base/publishPlatformManager/deletePublishPlatformInfo",
+          data: {
+            id,
+          },
+        })
+          .then((res) => {
+            if (res.data && res.data.code === 200) {
+              console.log(res);
+              resolve();
+            } else {
+              alert("编辑失败,请重试");
+              console.log(res);
+            }
+          })
+          .catch((err) => {
+            alert("编辑失败,请重试");
+            console.log(err);
+            reject(err);
+          });
+      });
+    },
   },
-  mounted() {
-    this.getData();
+  created() {
+    this.selectPublishPlatformPage();
   },
 };
 </script>

+ 15 - 16
src/views/parameter/components/PlatformModule/PlatformTable.vue

@@ -14,12 +14,12 @@
           :class="{ table_gray: index % 2 === 0 }"
         >
           <td style="width: 50%">
-            <p v-if="!editFlag[index]">{{ obj.platform }}</p>
+            <p v-if="!editFlag[index]">{{ obj.platformName }}</p>
             <input
               type="text"
               v-model="newName"
               v-else
-              :placeholder="obj.platform"
+              :placeholder="obj.platformName"
             />
           </td>
           <td style="width: 50%" class="operation">
@@ -71,15 +71,14 @@ export default {
   methods: {
     edit: function (i) {
       this.getEditArr(); // 确保只有一个在编辑
-      this.newName = this.tableData[i] && this.tableData[i].platform;
-      console.log(this.newName);
+      this.newName = this.tableData[i] && this.tableData[i]["platformName"];
       this.editFlag.splice(i, 1, true);
     },
     // 确认编辑
     submitEdit: function (i) {
       if (!this.newName) {
         alert("姓名不能为空");
-      } else if (this.newName === this.tableData[i].platform) {
+      } else if (this.newName === this.tableData[i]["platformName"]) {
         this.newName = ""; // 没有改
       } else {
         this.$emit("edit", i, this.newName);
@@ -93,8 +92,8 @@ export default {
       this.index = i;
     },
     // 点击平台模块
-    plate: function(i) {
-        this.$emit('jump_router', i);
+    plate: function (i) {
+      this.$emit("jump_router", i);
     },
     // 模态框确认删除
     detletData: function () {
@@ -110,9 +109,9 @@ export default {
       let arr = new Array(this.pageSize).fill(false);
       this.editFlag = arr;
     },
-    mounted() {
-      this.getEditArr();
-    },
+  },
+  mounted() {
+    this.getEditArr();
   },
 };
 </script>
@@ -153,12 +152,12 @@ export default {
   }
 }
 .table_gray {
-    background: #f5f5f5
+  background: #f5f5f5;
 }
-.nono{
-    opacity: 0;
-    &:hover{
-        cursor: default!important;
-    }
+.nono {
+  opacity: 0;
+  &:hover {
+    cursor: default !important;
+  }
 }
 </style>