Переглянути джерело

教材列表除了权限和查看完毕

1
mo 3 роки тому
батько
коміт
f49e9b34e5

+ 45 - 0
src/views/teachManager/api.js

@@ -0,0 +1,45 @@
+import request2 from '@/utils/request2'
+
+export const addsysMusicScore = data => request2({
+  url: '/api-web/sysMusicScoreCategories/save',
+  data: data,
+  method: 'post',
+  requestType:'json'
+})
+
+// 教材列表
+export const getSysMusicScoreList = data => request2({
+  url: '/api-web/sysMusicScoreCategories/queryPage',
+  params: data,
+  method: 'get',
+})
+
+// 获取教材详情
+
+export const getSysMusicScoreDetail = data => request2({
+  url: '/api-web/sysMusicScoreCategories/get',
+  params: data,
+  method: 'get',
+})
+
+// 修改教程
+export const resetsysMusicScore = data => request2({
+  url: '/api-web/sysMusicScoreCategories/update',
+  data: data,
+  method: 'post',
+  requestType:'json'
+})
+// 启用 停用
+export const enableSysMusicScore = data => request2({
+  url: '/api-web/sysMusicScoreCategories/enable',
+  params: data,
+  method: 'get',
+})
+
+// 删除
+export const removeSysMusicScore = data => request2({
+  url: '/api-web/sysMusicScoreCategories/delete',
+  data: data,
+  method: 'post',
+  requestType:'json'
+})

+ 126 - 24
src/views/teachManager/index.vue

@@ -46,17 +46,17 @@
         >
           <el-table-column
             align="center"
-            prop="studentId"
+            prop="id"
             label="教材编号"
           ></el-table-column>
           <el-table-column
             align="center"
-            prop="studentId"
+            prop="name"
             label="教材名称"
           ></el-table-column>
           <el-table-column
             align="center"
-            prop="studentId"
+            prop="organNames"
             label="可见分部"
           ></el-table-column>
           <el-table-column
@@ -66,22 +66,44 @@
           ></el-table-column>
           <el-table-column
             align="center"
-            prop="studentId"
+            prop="updateTime"
             label="最后更新时间"
           ></el-table-column>
-          <el-table-column
-            align="center"
-            prop="studentId"
-            label="教材状态"
-          ></el-table-column>
+          <el-table-column align="center" prop="studentId" label="教材状态">
+            <template slot-scope="scope">
+              <div>
+                {{ scope.row.enable ? "启用" : "停用" }}
+              </div>
+            </template>
+          </el-table-column>
           <el-table-column align="center" prop="studentId" label="操作">
             <template slot-scope="scope">
               <div>
                 <el-button type="text">查看</el-button>
-                <el-button type="text">修改</el-button>
-                <el-button type="text">停用</el-button>
-                <el-button type="text">启用</el-button>
-                <el-button type="text">删除</el-button>
+                <el-button
+                  type="text"
+                  @click="resetTeach(scope.row)"
+                  v-if="!scope.row.enable"
+                  >修改</el-button
+                >
+                <el-button
+                  type="text"
+                  v-if="scope.row.enable"
+                  @click="stopTeach(scope.row)"
+                  >停用</el-button
+                >
+                <el-button
+                  type="text"
+                  v-if="!scope.row.enable"
+                  @click="stopTeach(scope.row)"
+                  >启用</el-button
+                >
+                <el-button
+                  type="text"
+                  v-if="!scope.row.enable"
+                  @click="removeTeach(scope.row)"
+                  >删除</el-button
+                >
               </div>
             </template>
           </el-table-column>
@@ -100,13 +122,18 @@
       title="新增教材"
       :visible.sync="teachVisible"
       width="800px"
+      v-if="teachVisible"
     >
-     <addTeach />
+      <addTeach
+        @close="teachVisible = false"
+        @getList="getList"
+        ref="addTeach"
+        v-if="teachVisible"
+        :activeRow="activeRow"
+      />
       <span slot="footer" class="dialog-footer">
         <el-button @click="teachVisible = false">取 消</el-button>
-        <el-button type="primary" @click="teachVisible = false"
-          >确 定</el-button
-        >
+        <el-button type="primary" @click="submitAdd">确 定</el-button>
       </span>
     </el-dialog>
   </div>
@@ -117,9 +144,14 @@ import axios from "axios";
 import { getToken } from "@/utils/auth";
 import pagination from "@/components/Pagination/index";
 import load from "@/utils/loading";
-import addTeach from './modals/addTeach'
+import addTeach from "./modals/addTeach";
+import {
+  getSysMusicScoreList,
+  enableSysMusicScore,
+  removeSysMusicScore,
+} from "./api";
 export default {
-  components: { pagination,addTeach },
+  components: { pagination, addTeach },
   data() {
     return {
       searchForm: {
@@ -135,7 +167,8 @@ export default {
         total: 0, // 总条数
         page_size: [10, 20, 40, 50], // 选择限制显示条数
       },
-      teachVisible:false
+      teachVisible: false,
+      activeRow: null,
     };
   },
   //生命周期 - 创建完成(可以访问当前this实例)
@@ -147,16 +180,85 @@ export default {
     this.init();
   },
   methods: {
-    init() {},
-    getList() {},
+    init() {
+      this.getList();
+    },
+    async getList() {
+      try {
+        const res = await getSysMusicScoreList({
+          ...this.searchForm,
+          page: this.rules.page,
+          rows: this.rules.limit,
+        });
+        this.rules.total = res.data.total;
+        this.tableList = res.data.rows;
+      } catch (e) {}
+    },
     search() {
       this.rules.page = 1;
       this.getList();
     },
     onReSet() {},
-    addTeach(){
+    addTeach() {
+      this.activeRow = null;
+      this.teachVisible = true;
+    },
+    submitAdd() {
+      this.$refs.addTeach.addSubmit();
+    },
+    resetTeach(row) {
+      this.activeRow = row;
       this.teachVisible = true;
-    }
+    },
+    async stopTeach(row) {
+      let str = "";
+      if (row.enable) {
+        str = `是否停用${row.name}该教材`;
+      } else {
+        str = `是否启用${row.name}该教材`;
+      }
+      this.$confirm(str, "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(async () => {
+          try {
+            const res = await enableSysMusicScore({ categoriesId: row.id });
+            if (row.enable) {
+              this.$message.success("停用成功");
+            } else {
+              this.$message.success("启用成功");
+            }
+
+            this.getList();
+          } catch (e) {
+            console.log(e);
+          }
+        })
+        .catch((e) => {
+          console.log(e);
+        });
+    },
+    async removeTeach(row) {
+      this.$confirm(`是否删除${row.name}`, "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(async () => {
+          try {
+            const res = await removeSysMusicScore({ id: row.id });
+            this.$message.success("删除成功");
+            this.getList();
+          } catch (e) {
+            console.log(e);
+          }
+        })
+        .catch((e) => {
+          console.log(e);
+        });
+    },
   },
 };
 </script>

+ 105 - 21
src/views/teachManager/modals/addTeach.vue

@@ -1,7 +1,13 @@
 <template>
   <div>
     <el-alert title="教材信息" :closable="false" class="alert" type="info" />
-    <el-form :model="form" :inline="true" label-width="120px" class="form">
+    <el-form
+      :model="form"
+      :inline="true"
+      label-width="120px"
+      class="form"
+      ref="form"
+    >
       <el-row>
         <el-col :span="12">
           <el-form-item
@@ -19,13 +25,17 @@
           </el-form-item>
         </el-col>
         <el-col :span="12">
-          <el-form-item label="教材分类" prop="organId"  :rules="[
+          <el-form-item
+            label="适用分部"
+            prop="organId"
+            :rules="[
               {
                 required: true,
                 message: '请选择适用分部',
                 trigger: 'change',
               },
-            ]">
+            ]"
+          >
             <select-all
               style="width: 260px"
               v-model.trim="form.organId"
@@ -48,7 +58,7 @@
       <el-row>
         <el-form-item
           label="教材封面图"
-          prop="poster"
+          prop="coverImg"
           :rules="[
             {
               required: true,
@@ -58,13 +68,15 @@
           ]"
           label-width="120px"
         >
+          <!--      v-show="!form.coverImg"  -->
           <upload
-            v-if="!form.poster"
-            v-model="form.poster"
+            class="uploadImg"
+            v-model="form.coverImg"
             :imageWidthM="210"
             :imageHeightM="268"
+            ref="uploadImg"
           ></upload>
-          <img v-else :src="form.poster" alt="" width="210px" height="268px" />
+          <!-- <img v-show="form.coverImg" :src="form.coverImg" alt="" width="105px" height="134px" @click="uploadImg"/> -->
           <p style="color: red">
             请上传210*268像素,大小2M以内,格式为jpg、png、gif图片
           </p>
@@ -82,12 +94,14 @@
           >添加分类</el-button
         >
         <el-tree
-          :data="form.data"
+          :data="form.sysMusicScoreCategoriesList"
           node-key="index"
           default-expand-all
           :expand-on-click-node="false"
           draggable
           accordion
+          ref="tree"
+          :props="treeProps"
         >
           >
           <span class="custom-tree-node" slot-scope="{ node, data }">
@@ -112,7 +126,9 @@
 </template>
 <script>
 import Upload from "@/components/Upload/index";
+import { addsysMusicScore, getSysMusicScoreDetail,resetsysMusicScore } from "../api";
 export default {
+  props: ["activeRow"],
   components: {
     Upload,
   },
@@ -121,19 +137,39 @@ export default {
       form: {
         organId: [],
         name: null,
-        data: [],
+        coverImg: "",
+        sysMusicScoreCategoriesList: [],
       },
       index: 0,
+      treeProps: {
+        children: "sysMusicScoreCategoriesList",
+        label: "name",
+      },
     };
   },
-  mounted() {
-    this.$store.dispatch("setBranchs");
+  async mounted() {
+    await this.$store.dispatch("setBranchs");
+    if (this.activeRow?.id) {
+      try {
+        const res = await getSysMusicScoreDetail({ id: this.activeRow.id });
+        this.form.name = res.data.name;
+        this.form.organId = res.data.organId.split(",").map((item) => {
+          return Number(item);
+        });
+        this.form.coverImg = res.data.coverImg;
+        this.form.sysMusicScoreCategoriesList = this.recursionDate(
+          res.data.sysMusicScoreCategoriesList
+        );
+      } catch (e) {}
+    }
   },
   methods: {
     // 递归遍历数组
     recursionDate(arr) {
+
       // 这里来了
       if (arr.length > 0) {
+
         let newArr = [];
         for (let i = 0; i < arr.length; i++) {
           let obj = {
@@ -141,15 +177,23 @@ export default {
             index: arr[i].id,
           };
 
-          if (arr[i].sysMenus && arr[i].sysMenus.length > 0) {
-            obj.children = recursionDate(arr[i].sysMenus);
+          if (
+            arr[i].sysMusicScoreCategoriesList &&
+            arr[i].sysMusicScoreCategoriesList.length > 0
+          ) {
+            obj.sysMusicScoreCategoriesList = this.recursionDate(
+              arr[i].sysMusicScoreCategoriesList
+            );
           }
+
           newArr.push(obj);
         }
+
         return newArr;
       }
     },
     appendItem(data) {
+      console.log(data);
       this.$prompt("请输入教材名称", "提示", {
         confirmButtonText: "确定",
         cancelButtonText: "取消",
@@ -162,19 +206,19 @@ export default {
           // this.form.data.push({ index: `xxx${this.index}`, label: value });
           const newChild = {
             index: `xxx${this.index}`,
-            label: value,
-            children: [],
+            name: value,
+            sysMusicScoreCategoriesList: [],
           };
-          if (!data.children) {
-            this.$set(data, "children", []);
+          if (!data.sysMusicScoreCategoriesList) {
+            this.$set(data, "sysMusicScoreCategoriesList", []);
           }
-          data.children.push(newChild);
+          data.sysMusicScoreCategoriesList.push(newChild);
         })
         .catch(() => {});
     },
     removeItem(node, data) {
       const parent = node.parent;
-      const children = parent.data.children || parent.data;
+      const children = parent.data.sysMusicScoreCategoriesList || parent.data;
       const index = children.findIndex((d) => d.id === data.id);
       children.splice(index, 1);
     },
@@ -183,11 +227,12 @@ export default {
         confirmButtonText: "确定",
         cancelButtonText: "取消",
         closeOnClickModal: false,
+        inputValue: data.name,
         inputPattern: /^.{1,30}$/,
         inputErrorMessage: "请输入1到15个汉字或字符",
       })
         .then(({ value }) => {
-          data.label = value;
+          data.name = value;
           // this.form.data.push({ index: `xxx${this.index}`, label: value });
         })
         .catch(() => {});
@@ -202,11 +247,44 @@ export default {
       })
         .then(({ value }) => {
           this.index += 1;
-          this.form.data.push({ index: `xxx${this.index}`, label: value });
+          this.form.sysMusicScoreCategoriesList.push({
+            index: `xxx${this.index}`,
+            name: value,
+          });
         })
         .catch(() => {});
       // this.form.data.push({})
     },
+    addSubmit() {
+      this.$refs.form.validate(async (flag) => {
+        if (flag) {
+          let { organId, ...rest } = this.form;
+          let obj = {
+            ...rest,
+            organId: organId.join(","),
+          };
+          try {
+            if( this.activeRow.id){
+              obj.id = this.activeRow.id
+             const resut = await resetsysMusicScore(obj)
+              this.$$message.success('修改成功')
+            }else{
+               const resut = await addsysMusicScore(obj);
+               this.$$message.success('添加成功')
+            this.$emit("getList");
+            this.$emit("close");
+            }
+
+          } catch (e) {
+            console.log(e)
+          }
+        }
+      });
+      console.log("提交");
+    },
+    uploadImg() {
+      this.$refs.uploadImg.$refs.upload.submit();
+    },
   },
   computed: {},
 };
@@ -230,4 +308,10 @@ export default {
     margin-left: 5px;
   }
 }
+.uploadImg {
+  /deep/.avatar {
+    width: 105px;
+    height: 134px;
+  }
+}
 </style>

+ 2 - 2
vue.config.js

@@ -17,10 +17,10 @@ const name = defaultSettings.title || '管乐迷后台管理系统' // page titl
 // //  https://online.dayaedu.com
 // let target = 'https://online.dayaedu.com' //线上
 // let target = 'http://192.168.3.139:8000' // 箭河
-// let target = 'http://192.168.3.124:8000' //邹璇
+let target = 'http://192.168.3.124:8000' //邹璇
 // let target = 'http://192.168.3.112:8000' //勇哥
 // let target = 'http://dev.dayaedu.com' // 开发环境
-let target = 'https://test.dayaedu.com' //测试环境
+// let target = 'https://test.dayaedu.com' //测试环境
 // let target = 'http://192.168.3.134:8000' // 乔
 // All configuration item explanations can be find in https://cli.vuejs.org/config/
 module.exports = {