Browse Source

初步完成需求更新(学习园地自定义-精品典藏增加字段)

shaogen1995 3 years ago
parent
commit
aece6441b6

+ 21 - 2
new_backstage/src/configue/api.js

@@ -277,7 +277,7 @@ export function resetPass(data, cb) {
 export const getTabList = () => {
   return axios({
     method: 'post',
-    url: 'cms/goodsModule/list',
+    url: 'cms/goodsModule/list/goods',
   })
 }
 
@@ -286,7 +286,7 @@ export const addTabList = (data) => {
   return axios({
     method: 'post',
     url: 'cms/goodsModule/save',
-    data
+    data:{...data,module:'goods'}
   })
 }
 
@@ -354,4 +354,23 @@ export const userupdatePwd = (data) => {
     url: 'sys/user/updatePwd',
     data
   })
+}
+
+
+// ------------------------学习园地--------------------------
+// 获取学习园地左侧tab列表
+export const getTabStudyList = () => {
+  return axios({
+    method: 'post',
+    url: 'cms/goodsModule/list/news',
+  })
+}
+
+//学习园地左侧tab列表新增和修改
+export const addTabStudyList = (data) => {
+  return axios({
+    method: 'post',
+    url: 'cms/goodsModule/save',
+    data:{...data,module:'news'}
+  })
 }

+ 2 - 2
new_backstage/src/configue/http.js

@@ -8,9 +8,9 @@ const vue = new Vue();
 var isProduction = process.env.NODE_ENV === "production";
 let loading = "";
 // 线上打包
-const serverName = isProduction ? "/" : "http://192.168.0.245:8003/";
+// const serverName = isProduction ? "/" : "http://192.168.0.245:8003/";
 // 线下调试
-// const serverName = isProduction ? "/" : "http://192.168.0.135:8003/";
+const serverName = isProduction ? "/" : "http://192.168.0.135:8003/";
 
 const serverLocation = window.location.hostname;
 

+ 1 - 1
new_backstage/src/pages/content/collection/componets/img.vue

@@ -51,7 +51,7 @@
     </el-form-item>
     <!-- 新增的链接 -->
     <el-form-item label="链接:">
-      <el-input v-model="form.href"></el-input>
+      <el-input v-model="form.link"></el-input>
     </el-form-item>
   </div>
 </template>

+ 1 - 1
new_backstage/src/pages/content/collection/componets/leftTab.vue

@@ -106,7 +106,7 @@ export default {
   async created() {
     //获取自定义模块的权限
     let temp = localStorage.getItem("XJ_limits_ZDY");
-    temp = JSON.parse(temp);
+    temp = JSON.parse(temp).JPDC;
     this.limits.edit = temp[0].authority;
     this.limits.del = temp[1].authority;
   },

+ 1 - 1
new_backstage/src/pages/content/collection/componets/video.vue

@@ -44,7 +44,7 @@
     </el-form-item>
     <!-- 新增的链接 -->
     <el-form-item label="链接:">
-      <el-input v-model="form.href"></el-input>
+      <el-input v-model="form.link"></el-input>
     </el-form-item>
   </div>
 </template>

+ 20 - 3
new_backstage/src/pages/content/collection/index.vue

@@ -13,7 +13,7 @@
         <el-button
           type="primary"
           style="width: 100%"
-          @click="isShow = true"
+          @click="addModule"
           v-if="limitsEdit"
           >新增模块</el-button
         >
@@ -220,7 +220,19 @@ export default {
         sortType: "time",
       },
       status: "all",
-      menu: [{id:1,name:'...'},{id:2,name:'...'},{id:3,name:'...'},{id:4,name:'...'},{id:5,name:'...'},{id:6,name:'...'},{id:7,name:'...'},{id:8,name:'...'},{id:9,name:'...'},{id:10,name:'...'}],
+      menu: [
+        // 使用的vue里面的menu组件,需要初始化数据,不然刷新会有卡顿
+        { id: 1, name: "..." },
+        { id: 2, name: "..." },
+        { id: 3, name: "..." },
+        { id: 4, name: "..." },
+        { id: 5, name: "..." },
+        { id: 6, name: "..." },
+        { id: 7, name: "..." },
+        { id: 8, name: "..." },
+        { id: 9, name: "..." },
+        { id: 10, name: "..." },
+      ],
       list: {},
       page: {
         size: 25,
@@ -241,6 +253,11 @@ export default {
   },
 
   methods: {
+    // 点击左上方的新增模块
+    addModule() {
+      this.isShow = true;
+      this.isShowId = null;
+    },
     async editTab(id) {
       this.isShowId = id;
       // console.log('点击了编辑',id);
@@ -388,7 +405,7 @@ export default {
     this.getTabList();
     //获取自定义模块的权限
     let temp = localStorage.getItem("XJ_limits_ZDY");
-    temp = JSON.parse(temp);
+    temp = JSON.parse(temp).JPDC;
     this.limitsEdit = temp[0].authority;
   },
 };

+ 163 - 0
new_backstage/src/pages/content/study/componets/leftTab.vue

@@ -0,0 +1,163 @@
+<template>
+  <div class="con-left">
+    <!-- @select="handleSelect($event)" -->
+    <el-menu
+      :default-active="`${type}`"
+      class="el-menu-vertical-demo"
+      @mouseleave.native="ind = null"
+    >
+      <el-submenu index="1">
+        <template slot="title">
+          <i class="el-icon-menu"></i>
+          <span slot="title">{{ title }}</span>
+        </template>
+        <el-menu-item
+          :title="item.name"
+          v-for="item in menu"
+          :key="item.createTime"
+          :index="item.id.toString()"
+          @click="handleSelect(item)"
+          @mouseenter.native="ind = item.id"
+        >
+          {{ item.name }}
+          <div class="hover" v-show="item.id === ind">
+            <i
+              class="el-icon-edit"
+              title="编辑"
+              v-if="item.id !== 4 && item.id !== 5"
+              v-show="limits.edit"
+              @click="editTab($event, item.id)"
+            ></i>
+            <i
+              class="el-icon-close"
+              title="删除"
+              v-if="item.id !== 4 && item.id !== 5"
+              v-show="limits.del"
+              @click="deltTab($event, item.id)"
+            ></i>
+          </div>
+        </el-menu-item>
+        <!-- 鼠标移入的操作 -->
+        <!-- <template v-for="(item, i) in menu">
+          <div
+            class="hover"
+            :key="item.id"
+            :style="{ top: i * 50 + 'px' }"
+            v-show="item.id === ind"
+          >
+            <i
+              v-if="limits.edit"
+              class="el-icon-edit"
+              title="编辑"
+              @click="$emit('editTab', item.id)"
+            ></i>
+            <i
+              v-if="item.id!==1&&item.id!==2&&item.id!==3"
+              v-show="limits.del"
+              class="el-icon-close"
+              title="删除"
+              @click="$emit('deltTab', item.id)"
+            ></i>
+          </div>
+        </template> -->
+      </el-submenu>
+    </el-menu>
+    <!-- <div class="sousuo" @click="isCollapse = !isCollapse">
+      <i :class="isCollapse ? 'el-icon-arrow-right' : 'el-icon-arrow-left'"></i>
+    </div> -->
+  </div>
+</template>
+
+<script>
+export default {
+  name: "con-left",
+  props: ["menu", "title", "default"],
+  data() {
+    return {
+      // 权限的数据
+      limits: {
+        edit: true,
+        del: true,
+      },
+      // type: this.default,
+      ind: null,
+    };
+  },
+  methods: {
+    // 点击编辑模块
+    editTab(e, id) {
+      this.$emit("editTab", id);
+      e.stopPropagation();
+    },
+    // 点击删除模块
+    deltTab(e, id) {
+      this.$emit("deltTab", id);
+      e.stopPropagation();
+    },
+    handleSelect(data) {
+      this.$emit("select", data);
+    },
+  },
+  computed: {
+    type() {
+      return this.default;
+    },
+  },
+  async created() {
+    //获取自定义模块的权限
+    let temp = localStorage.getItem("XJ_limits_ZDY");
+    temp = JSON.parse(temp).XXYD;
+    this.limits.edit = temp[0].authority;
+    this.limits.del = temp[1].authority;
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.con-left {
+  border-right: solid 1px #e5e5e5;
+  position: relative;
+  margin-right: 20px;
+  padding-top: 40px;
+  .sousuo {
+    position: absolute;
+    top: 50%;
+    transform: translateY(-50%);
+    right: -30px;
+  }
+  .hover {
+    cursor: pointer;
+    width: 40px;
+    display: flex;
+    justify-content: right;
+    align-items: center;
+    position: absolute;
+    height: 50px;
+    top: 0;
+    right: 6px;
+    & > i {
+      color: #909399;
+      margin-right: 2px;
+      width: 18px;
+      &:hover {
+        color: #b63c25;
+      }
+    }
+  }
+  /deep/.el-menu-item {
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+  }
+}
+.el-menu-vertical-demo:not(.el-menu--collapse) {
+  height: 600px;
+  overflow-y: auto;
+  overflow-x: hidden;
+  width: 200px;
+  min-height: 400px;
+}
+.el-menu {
+  border-right: none !important;
+}
+</style>

+ 5 - 0
new_backstage/src/pages/content/study/edit.vue

@@ -83,6 +83,11 @@ export default {
           type: this.type,
           ...this.form,
         };
+        //学习园地增加的参数
+        let temp = localStorage.getItem("XJ_studyModuleId");
+        if (temp) params.goodsModuleId = Number(temp);
+        else params.goodsModuleId = 4;
+
         save(this.val, params, () => {
           if (submit) {
             cb && cb();

+ 228 - 36
new_backstage/src/pages/content/study/index.vue

@@ -1,19 +1,39 @@
 <template>
-  <div>
+  <div class="myTab4">
     <main-top>
       <div slot="con" v-if="activeSub['新增']">
-        <el-button @click="goto({ id: 'none',status: 0 })" type="primary"
+        <el-button @click="goto({ id: 'none', status: 0 })" type="primary"
           >新增</el-button
         >
       </div>
     </main-top>
     <div class="tablecon flexcon">
-      <accordion
+      <!-- 新增tab栏的按钮 -->
+      <div class="addTab">
+        <el-button
+          type="primary"
+          style="width: 100%"
+          @click="addModule"
+          v-if="limitsEdit"
+          >新增模块</el-button
+        >
+      </div>
+      <!-- <accordion
         @select="handleMenu"
         :menu="menu"
         :default="subMenu"
         title="学习园地"
+      /> -->
+
+      <LeftTab
+        @editTab="editTab"
+        @deltTab="deltTab"
+        @select="handleMenu"
+        :menu="menu"
+        :default="goodsModuleId"
+        title="学习园地"
       />
+
       <div class="tablebody">
         <status :status="status" @select="selectStatus"></status>
         <search>
@@ -38,8 +58,10 @@
               placeholder="请输入关键字"
             ></el-input>
             <el-button @click="getList" type="primary">查询</el-button>
-            <el-button @click="search.date='',search.inputKey='',getList()" >重置</el-button>
-
+            <el-button
+              @click="(search.date = ''), (search.inputKey = ''), getList()"
+              >重置</el-button
+            >
           </div>
         </search>
         <div class="table">
@@ -62,57 +84,189 @@
             @submit="submit"
             :tableData="list"
           >
-             <template slot-scope="{data}" slot="record">
-              <el-button @click="applyDetail(data,type)" type="text">审核详情</el-button>
+            <template slot-scope="{ data }" slot="record">
+              <el-button @click="applyDetail(data, type)" type="text"
+                >审核详情</el-button
+              >
             </template>
           </vtable>
         </div>
       </div>
     </div>
 
-    <vdialog :show="showApplyDetail" @close="showApplyDetail=false" :tableData="alDetail"></vdialog>
+    <vdialog
+      :show="showApplyDetail"
+      @close="showApplyDetail = false"
+      :tableData="alDetail"
+    ></vdialog>
 
+    <!-- 点击新增模块出现的弹窗 -->
+    <el-dialog
+      :title="ruleForm.id ? '编辑模块' : '新增模块'"
+      :visible="isShow"
+      @close="addTabX"
+    >
+      <el-form
+        :model="ruleForm"
+        ref="ruleForm"
+        label-width="100px"
+        class="demo-ruleForm"
+      >
+        <el-form-item label="模块名称:">
+          <el-input
+            :disabled="isShowId === 4 || isShowId === 5"
+            v-model="ruleForm.name"
+            maxlength="10"
+            show-word-limit
+          ></el-input>
+        </el-form-item>
+        <el-form-item label="展示类型:">
+          <el-radio
+            v-model="ruleForm.type"
+            label="share"
+            :disabled="!!ruleForm.id"
+            >知识共享</el-radio
+          >
+          <el-radio
+            v-model="ruleForm.type"
+            label="info"
+            :disabled="!!ruleForm.id"
+            >知识阅览</el-radio
+          >
+        </el-form-item>
+      </el-form>
+
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="addTabX">取 消</el-button>
+        <el-button type="primary" @click="addTabOK">确 定</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script>
-
-import { raw, menu, menuStr } from "./data";
-import { getList } from "@/configue/api";
+// 导入后面自己写的tab栏组件
+import LeftTab from "./componets/leftTab.vue";
+import { raw, menuStr } from "./data";
+import {
+  getList,
+  getTabStudyList,
+  getTabInfoById,
+  getTabDelById,
+  addTabStudyList,
+} from "@/configue/api";
 
 import { mapGetters } from "vuex";
 
 export default {
+  name: "tabStudy",
+  components: { LeftTab },
   data() {
     return {
-      type:'news',
-      showApplyDetail:false,
-      alDetail:{},
+      limitsEdit: true,
+      type: "news",
+      showApplyDetail: false,
+      alDetail: {},
       search: {
         inputKey: "",
         date: "",
         state: "",
       },
       status: "all",
-      menu,
+      menu: [
+        // 使用的vue里面的menu组件,需要初始化数据,不然刷新会有卡顿
+        { id: 4, name: "..." },
+        { id: 5, name: "..." },
+        { id: 6, name: "..." },
+        { id: 7, name: "..." },
+        { id: 8, name: "..." },
+        { id: 9, name: "..." },
+        { id: 10, name: "..." },
+      ],
       list: {},
       page: {
         size: 25,
         pageNum: 1,
-      }
+      },
+      goodsModuleId: 4,
+      // 点击新增模块
+      isShowId: null,
+      isShow: false,
+      ruleForm: {
+        name: "",
+        type: "share", //类型, info:知识阅览, share:知识共享
+      },
     };
   },
   methods: {
+    // 点击左上方的新增模块
+    addModule() {
+      this.isShow = true;
+      this.isShowId = null;
+    },
+    async editTab(id) {
+      this.isShowId = id;
+      // console.log('点击了编辑',id);
+      let res = await getTabInfoById(id);
+      if (res.code === 0) {
+        this.ruleForm = res.data;
+        this.isShow = true;
+      } else return this.$message.warning(res.msg);
+      // 根据id获取信息
+    },
+    deltTab(id) {
+      this.$confirm(
+        "确定删除吗? 当前模块下如果存在数据,也会一并删除.",
+        "提示",
+        {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning",
+        }
+      ).then(async () => {
+        let res = await getTabDelById(id);
+        if (res.code === 0) {
+          this.$message.success("删除成功!");
+          this.$router.push("/study/info");
+          this.goodsModuleId = 4;
+          this.getTabStudyList();
+        } else return this.$message.warning(res.msg);
+      });
+    },
+    //------------------点击新增模块
+    async addTabOK() {
+      if (this.ruleForm.name.trim() === "")
+        return this.$message.warning("模块名称不能为空");
+      else {
+        let res = await addTabStudyList(this.ruleForm);
+        if (res.code === 0) {
+          this.getTabStudyList();
+          this.isShow = false;
+          this.addTabX();
+          this.$message.success("操作成功");
+        } else this.$message.warning(res.msg);
+      }
+    },
+    addTabX() {
+      this.ruleForm = {
+        name: "",
+        type: "share", 
+      };
+      this.isShow = false;
+    },
+    //----------------------- 新增模块结束
     selectStatus(item) {
       this.status = item.id;
     },
     handleMenu(data) {
+      // 把索引存起来
+      localStorage.setItem("XJ_studyModuleId", data.id);
+      this.goodsModuleId = data.id;
       this.$router.push({
-        params: { ...this.$route.params, type: data },
+        params: { ...this.$route.params, type: data.type, id: data.id },
       });
     },
-    
-    
+
     getList() {
       let { inputKey, date } = this.search;
       getList(
@@ -124,44 +278,82 @@ export default {
           searchKey: inputKey,
           status: this.status == "all" ? "" : this.status,
           type: this.subMenu,
+          goodsModuleId: this.goodsModuleId,
         },
         (data) => {
           this.list = data.data;
         }
       );
     },
+    //封装获取tab列表的方法
+    async getTabStudyList() {
+      let res = await getTabStudyList();
+      this.menu = res.data;
+    },
   },
   computed: {
     ...mapGetters({
       activeMenu: "activeMenu",
-      activeSub:"activeSub"
+      activeSub: "activeSub",
     }),
     data() {
       return raw[this.$route.params.type];
     },
-    subMenu(){
-      return this.$route.params.type
-    }
+    subMenu() {
+      return this.$route.params.type;
+    },
   },
   watch: {
-    subMenu:{
-      deep:true,
-      immediate:true,
-      handler:function (newVal) {
-        this.getAuth(this.activeMenu,menuStr[newVal])
+    goodsModuleId:{
+      deep: true,
+      handler: function () {
+        this.getAuth(this.activeMenu, menuStr[this.subMenu]);
         this.getList();
-      }
+      },
+    },
+    // subMenu: {
+    //   deep: true,
+    //   immediate: true,
+    //   handler: function (newVal) {
+    //     this.getAuth(this.activeMenu, menuStr[newVal]);
+    //     this.getList();
+    //   },
+    // },
+    activeMenu: {
+      deep: true,
+      immediate: true,
+      handler: function (newVal) {
+        this.getAuth(newVal, menuStr[this.subMenu]);
+      },
     },
-    activeMenu:{
-      deep:true,
-      immediate:true,
-      handler:function (newVal) {
-        this.getAuth(newVal,menuStr[this.subMenu])
-      }
-    }
   },
   mounted() {
     this.getList();
   },
+  created() {
+    // 调用获取tab列表方法
+    let myId = localStorage.getItem("XJ_studyModuleId");
+    if (myId) this.goodsModuleId = Number(myId);
+    else this.goodsModuleId = 1;
+    this.getTabStudyList();
+    //获取自定义模块的权限
+    let temp = localStorage.getItem("XJ_limits_ZDY");
+    temp = JSON.parse(temp).XXYD;
+    this.limitsEdit = temp[0].authority;
+  },
 };
 </script>
+<style lang="less" scoped>
+.myTab4 {
+  .tablecon {
+    position: relative;
+    .addTab {
+      width: 201px;
+      z-index: 10;
+      position: absolute;
+      left: 0px;
+      top: 0px;
+    }
+  }
+}
+</style>

+ 9 - 1
new_backstage/src/pages/layout/aside.vue

@@ -67,6 +67,10 @@ export default {
       if (item.id === 200 && this.$route.path !== "/collection/model") {
         localStorage.setItem("XJ_goodsModuleId", 1);
       }
+      //当前页面不在学习园地,进入学习园地的时候把本地存储id变成4
+      if (item.id === 400 && this.$route.path !== "/study/share") {
+        localStorage.setItem("XJ_studyModuleId", 4);
+      }
       let path = {
         path: `/${item.key}${
           item.param ? `/${item.param.map((tt) => tt.default).join("/")}` : ""
@@ -82,9 +86,13 @@ export default {
       });
       // console.log(123,result);
       // 把权限本地存储起来,用来管理新增的功能自定义模块
+      let XJ_limits_ZDY ={
+        JPDC:result.data[1].children[3].children,
+        XXYD:result.data[3].children[2].children
+      }
       localStorage.setItem(
         "XJ_limits_ZDY",
-        JSON.stringify(result.data[1].children[3].children)
+        JSON.stringify(XJ_limits_ZDY)
       );
 
       this.tmpRoute = routes.filter((item) => {