Browse Source

平台板块接口

suxinf 4 years ago
parent
commit
b3350c85d1

+ 9 - 4
src/views/parameter/PlatformModule.vue

@@ -31,7 +31,9 @@
       </div>
     </div>
     <div v-else>
-      <DetailPage />
+      <DetailPage 
+        :parentData='parentData'
+      />
     </div>
   </div>
 </template>
@@ -57,6 +59,7 @@ export default {
       currentPage: 1,
       tableData: [],
       modalFlag: false, // 控制模态框展示
+      parentData: {}
     };
   },
   computed: {
@@ -119,11 +122,12 @@ export default {
         this.selectPublishPlatformPage();
       })
     },
-    // 点击系列车型
+    // 点击平台板块
     jumpRouter: function (index) {
       // 页面变化
       this.$router.push({ query: { tag: "detail" } });
-      console.log("点击平台模块", this.functionData[index].str);
+      this.parentData = this.tableData[index]
+      console.log("点击平台模块",index);
     },
     // 新增平台 接口
     addPublishPlatformInfo: function (platformName) {
@@ -170,7 +174,7 @@ export default {
           console.log(err);
         });
     },
-    // 编辑接口
+    // 编辑平台模块,接口
     updatePublishPlatformInfo: function (id, platformName) {
       return new Promise((resolve, reject) => {
         this.$http({
@@ -198,6 +202,7 @@ export default {
           });
       });
     },
+    // 删除平台模块 接口
     deletePublishPlatformInfo: function (id) {
       return new Promise((resolve, reject) => {
         this.$http({

+ 179 - 75
src/views/parameter/components/PlatformModule/DetailPage.vue

@@ -1,49 +1,57 @@
 <template>
   <div>
-  <div class="car_series">
-    <div class="count">
-      <button @click="showModal">新增板块</button>
-      <Count :sum='sum'></Count>
+    <div class="car_series">
+      <div class="count">
+        <button @click="showModal">新增板块</button>
+        <Count :sum="sum"></Count>
+      </div>
+      <div class="table">
+        <Table
+          :tableData="tableData"
+          @edit="edit"
+          @delet_data="deleteData"
+          :pageSize="sum"
+        ></Table>
+      </div>
+      <div class="page">
+        <Tablepage
+          :totalPage="totalPage"
+          :currentPage="currentPage"
+          @change_page="changePage"
+          @jump_page="jumpPage"
+        ></Tablepage>
+      </div>
+      <div class="modal" v-if="modalFlag">
+        <Modal
+          :modalFlag="modalFlag"
+          @submit="submit"
+          @hide_modal="showModal"
+        ></Modal>
+      </div>
     </div>
-    <div class="table">
-      <Table
-        :tableData='tableData'
-        @edit='edit'
-        @delet_data='deleteData'
-        :pageSize='sum'
-      ></Table>
-    </div>
-    <div class="page">
-      <Tablepage
-        :totalPage='totalPage'
-        :currentPage='currentPage'
-        @change_page='changePage'
-        @jump_page='jumpPage'
-      ></Tablepage>
-    </div>
-    <div class="modal" v-if="modalFlag">
-      <Modal
-        :modalFlag='modalFlag'
-        @submit='submit'
-        @hide_modal='showModal'
-      ></Modal>
-    </div>
-  </div>
   </div>
 </template>
 
 <script>
-import Count from '../../../../components/Count';
-import Tablepage from '../../../../components/TablePage';
-import Table from './DetailPageTable';
+import Count from "../../../../components/Count";
+import Tablepage from "../../../../components/TablePage";
+import Table from "./DetailPageTable";
 import Modal from "./DetailPageModal";
 
 export default {
+  props: {
+    parentData: {
+      type: Object,
+      default: () => {
+        return {};
+      },
+    },
+  },
   components: {
     Count,
     Table,
     Tablepage,
-    Modal
+    Modal,
   },
   data() {
     return {
@@ -51,31 +59,29 @@ export default {
       pageSize: 20, // 每页展示的数据
       currentPage: 1,
       tableData: [],
-      getDate: [{module: 'ES论坛', str: '123'},{module: 'UX论坛', str: '124'},{module: 'RX轮坛', str: '125'},],
-      functionData: [],
       modalFlag: false, // 控制模态框展示
-    }
+    };
   },
-  computed:{
+  computed: {
     // 表格总页数
     totalPage() {
-      return Math.ceil(this.sum/this.pageSize);
+      return Math.ceil(this.sum / this.pageSize);
     },
     // 获取路由参数
     queryTag() {
-      console.log (111, this.$route.query);
-      return (this.$route.query && this.$route.query.tag) ? 0 : 1
-    }
+      console.log(111, this.$route.query);
+      return this.$route.query && this.$route.query.tag ? 0 : 1;
+    },
   },
   methods: {
     // 获取某一页面的数据,展示在表格
-    changePage: function(page) {
+    changePage: function (page) {
       this.currentPage = page;
       console.log(page);
     },
     // 点击上一页,下一页,首页,尾页
-    jumpPage: function(item) {
-      switch(item) {
+    jumpPage: function (item) {
+      switch (item) {
         case 1:
           this.currentPage = 1;
           break;
@@ -91,56 +97,154 @@ export default {
       }
       console.log(this.currentPage);
     },
-    // 获取数据
-    getData: function() {
-      this.tableData = [];
-      this.functionData = [];
-      this.getDate.forEach( (element) => {
-        this.tableData.push(
-          {
-            module: element.module
-          }
-        );
-        this.functionData.push(
-          {
-            str: element.str
-          }
-        )
-      });
-    },
     // 展示、隐藏模态框
-    showModal: function() {
+    showModal: function () {
       this.modalFlag = !this.modalFlag;
     },
     // 点击编辑
-    edit (index, newName) {
-      console.log(this.functionData[index].str, newName);
+    edit(index, newName) {
+      let id = this.tableData[index]['id'];
+      let parentId = this.parentData['id'];
+      this.updatePublishPlatformInfo(parentId, id, newName).then(() => {
+        this.selectPublishPlatformPage();
+      });
     },
     // 点击删除
-    deleteData (index) {
-      console.log('删除', this.functionData[index].str)
+    deleteData(index) {
+      console.log("删除", index);
+      let parentId = this.parentData['id'];
+      let id = this.tableData[index]['id'];
+      this.deletePublishPlatformInfo(parentId, id).then(() => {
+        this.selectPublishPlatformPage();
+      });
     },
-    // 新增车型模态框 保存
-    submit: function(platetName) {
-        console.log('保存', platetName);
-        this.modalFlag = false;
+    // 新增板块模态框 保存
+    submit: function (platetName) {
+      let parentId = this.parentData['id'];
+      this.addPublishPlatformInfo(parentId, platetName)
+      this.modalFlag = false;
+    },
+    // 新增平台 接口
+    addPublishPlatformInfo: function (parentId, platformName) {
+      return new Promise((resolve, reject) => {
+        this.$http({
+          method: "post",
+          url: "/base/publishPlatformManager/addPublishPlatformInfo",
+          data: {
+            parentId,
+            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 (parentId) {
+      this.$http({
+        method: "post",
+        url: "/base/publishPlatformManager/selectPublishPlatformPage",
+        data: {
+          parentId
+        },
+      })
+        .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 (parentId, id, platformName) {
+      return new Promise((resolve, reject) => {
+        this.$http({
+          method: "post",
+          url: "/base/publishPlatformManager/updatePublishPlatformInfo",
+          data: {
+            parentId,
+            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 (parentId, id) {
+      return new Promise((resolve, reject) => {
+        this.$http({
+          method: "post",
+          url: "/base/publishPlatformManager/deletePublishPlatformInfo",
+          data: {
+            parentId,
+            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();
-  }
-}
+    console.log(this.parentData);
+    this.selectPublishPlatformPage(this.parentData['id']);
+  },
+};
 </script>
 
 <style scoped lang="less">
-.car_series{
-  .count{
+.car_series {
+  .count {
     height: 40px;
     width: 100%;
     display: flex;
     justify-content: space-between;
     align-items: center;
-    button{
+    button {
       width: 86px;
       height: 30px;
       position: relative;

+ 4 - 4
src/views/parameter/components/PlatformModule/DetailPageTable.vue

@@ -14,12 +14,12 @@
           :class="{ table_gray: index % 2 === 0 }"
         >
           <td style="width: 50%">
-            <p v-if="!editFlag[index]">{{ obj.module }}</p>
+            <p v-if="!editFlag[index]">{{ obj.platformName }}</p>
             <input
               type="text"
               v-model="newName"
               v-else
-              :placeholder="obj.module"
+              :placeholder="obj.platformName"
             />
           </td>
           <td style="width: 50%" class="operation">
@@ -69,14 +69,14 @@ export default {
   methods: {
     edit: function (i) {
       this.getEditArr(); // 确保只有一个在编辑
-      this.newName = this.tableData[i] && this.tableData[i].module;
+      this.newName = this.tableData[i] && this.tableData[i].platformName;
       console.log(this.newName);
       this.editFlag.splice(i, 1, true);
     },
     // 确认编辑
     submitEdit: function (i) {
       if (!this.newName) {
-        alert("姓名不能为空");
+        alert("板块名称不能为空");
       } else if (this.newName === this.tableData[i].module) {
         this.newName = ""; // 没有改
       } else {