Browse Source

教材类型多选

natasha 6 months ago
parent
commit
5a794d922f
1 changed files with 91 additions and 62 deletions
  1. 91 62
      src/views/courseList.vue

+ 91 - 62
src/views/courseList.vue

@@ -206,19 +206,23 @@
             name="name_english"
           />
         </el-form-item>
-        <el-form-item label="教材类型" label-width="90px" prop="type_id">
+        <el-form-item label="教材类型" label-width="90px" prop="type_name_list">
           <!-- -->
           <el-select
             ref="typeSelects"
-            v-model="formDialog.type_id"
+            v-model="formDialog.type_name_list"
             name="bookType"
             placeholder="请选择教材类型"
+            filterable
+            multiple
+            allow-create
+            default-first-option
           >
             <el-option
               v-for="(item, index) in typeList"
               :key="'type' + index"
-              :label="item.name"
-              :value="item.id"
+              :label="item"
+              :value="item"
             />
           </el-select>
         </el-form-item>
@@ -272,7 +276,7 @@
         </el-form-item>
         <el-form-item
           class="label-input"
-          label="丛书编号"
+          label="所属丛书"
           label-width="90px"
           prop="series_code"
         >
@@ -371,7 +375,7 @@
 import { validNull, validPrice } from "@/utils/validate";
 import Header from "@/components/inputModules/common/Header";
 import Nav from "@/components/inputModules/common/Nav";
-import { getContent, getContentFile } from "@/api/ajax";
+import { getContent, getContentFile, TextbookAPI } from "@/api/ajax";
 import Cookies from "js-cookie";
 import { getToken } from "@/utils/auth";
 
@@ -432,6 +436,7 @@ export default {
         id: "",
         publisher: "",
         theme_color: "",
+        type_name_list: [],
         type_id: "",
       },
       agencyList: [
@@ -467,7 +472,7 @@ export default {
         publish_number: [
           { required: true, trigger: "blur", validator: validateNull },
         ],
-        type_id: [
+        type_name_list: [
           { required: true, message: "请选择教材类型", trigger: "change" },
         ],
         org_id: [{ required: true, message: "请选择机构", trigger: "change" }],
@@ -576,20 +581,20 @@ export default {
       this.getList();
     },
     handleClick(row) {
-    //   if (row.publish_status == 1) {
-    //     this.$message({
-    //       type: "warning",
-    //       message: "此教材处于上架状态不可以进行编辑",
-    //     });
-    //     return false;
-    //   }
+      //   if (row.publish_status == 1) {
+      //     this.$message({
+      //       type: "warning",
+      //       message: "此教材处于上架状态不可以进行编辑",
+      //     });
+      //     return false;
+      //   }
       sessionStorage.setItem("Bookdetail", JSON.stringify(row));
       this.$router.push("/input?bookId=" + row.id);
     },
     // 预览
     handleView(row) {
       sessionStorage.setItem("Bookdetail", JSON.stringify(row));
-      this.$router.push("/courseview?bookId=" + row.id+"&showCourse=true");
+      this.$router.push("/courseview?bookId=" + row.id + "&showCourse=true");
     },
     // 激活码
     handleDiscount(row) {
@@ -597,49 +602,55 @@ export default {
     },
     // 生成临时链接
     handleCreatLink(row) {
-        var date1 = new Date(); 
-        var date2 = new Date(date1); 
-        date2.setDate(date1.getDate() + 30); 
-        let endtime = date2.getFullYear() + "-" + (date2.getMonth() + 1) + "-" + date2.getDate()
-        getContentFile('login_control-CreateValidDateEncryptionString', {
-            end_date: endtime,
+      var date1 = new Date();
+      var date2 = new Date(date1);
+      date2.setDate(date1.getDate() + 90);
+      let endtime =
+        date2.getFullYear() +
+        "-" +
+        (date2.getMonth() + 1) +
+        "-" +
+        date2.getDate();
+      getContentFile("login_control-CreateValidDateEncryptionString", {
+        end_date: endtime,
+      })
+        .then((res) => {
+          let link =
+            "https://" +
+            window.location.host +
+            "/GCLS-Book/#/BookBrowsing?bookId=" +
+            row.id +
+            "&encryption=" +
+            res.encryption_string;
+          document.getElementById("temporaryLinks").innerHTML = link;
+          var doc = document,
+            text = doc.getElementById("temporaryLinks"),
+            range,
+            selection;
+          if (doc.body.createTextRange) {
+            range = doc.body.createTextRange();
+            range.moveToElementText(text);
+            range.select();
+          } else if (window.getSelection) {
+            selection = window.getSelection();
+            range = doc.createRange();
+            range.selectNodeContents(text);
+            selection.removeAllRanges();
+            selection.addRange(range);
+          }
+          document.execCommand("copy");
+          this.$message({
+            message: "复制成功",
+            type: "success",
+          });
+          window.getSelection().removeAllRanges();
         })
-            .then((res) => {
-                let link =
-                    "https://" +
-                    window.location.host +
-                    "/GCLS-Book/#/BookBrowsing?bookId=" +
-                    row.id+"&encryption="+res.encryption_string;
-                document.getElementById("temporaryLinks").innerHTML = link;
-                var doc = document,
-                    text = doc.getElementById("temporaryLinks"),
-                    range,
-                    selection;
-                if (doc.body.createTextRange) {
-                    range = doc.body.createTextRange();
-                    range.moveToElementText(text);
-                    range.select();
-                } else if (window.getSelection) {
-                    selection = window.getSelection();
-                    range = doc.createRange();
-                    range.selectNodeContents(text);
-                    selection.removeAllRanges();
-                    selection.addRange(range);
-                }
-                document.execCommand("copy");
-                this.$message({
-                    message: "复制成功",
-                    type: "success",
-                });
-                window.getSelection().removeAllRanges();
-            })
-            .catch(() => {
-                this.$message({
-                    message: "生成失败,请稍后重试",
-                    type: "warning",
-                });
-            });
-      
+        .catch(() => {
+          this.$message({
+            message: "生成失败,请稍后重试",
+            type: "warning",
+          });
+        });
     },
     // 新建教材
     handleAdd() {
@@ -661,6 +672,7 @@ export default {
         publisher: "",
         theme_color: "",
         type_id: "",
+        type_name_list: [],
       };
       this.agency = "";
       this.fileList = [];
@@ -705,7 +717,10 @@ export default {
             MethodName = "book-book_manager-AddBook";
           }
           //   this.formDialog.publish_status = 1;
-          this.formDialog.publish_status = this.tableData[this.rowIndex].publish_status ? this.tableData[this.rowIndex].publish_status : 0
+          this.formDialog.publish_status = this.tableData[this.rowIndex]
+            .publish_status
+            ? this.tableData[this.rowIndex].publish_status
+            : 0;
           let data = JSON.parse(JSON.stringify(_this.formDialog));
           getContent(MethodName, data)
             .then((res) => {
@@ -740,6 +755,7 @@ export default {
         order_column: "create_time:desc",
         publish_status: this.form.publish_status,
         is_control_publish_scope: "false",
+        is_enable_book_org_free_license_query: "false",
       };
       getContent(MethodName, data).then((res) => {
         let _this = this;
@@ -825,11 +841,10 @@ export default {
     },
     // 教材类型列表
     getTypeList() {
-      let MethodName = "dict_manager-GetBookTypeList";
+      let MethodName = "book-book_manager-GetBookTypeList";
       let data = {};
-      getContentFile(MethodName, data).then((res) => {
+      TextbookAPI(MethodName, data).then((res) => {
         this.typeList = res.type_list;
-        console.log(this.typeList);
       });
     },
     // 处理教材价格 最多两位小数
@@ -871,7 +886,12 @@ export default {
       this.formDialog.price = null;
       this.agency = "";
       this.fileList = [];
+      this.fileListVideo = [];
+      this.fileListAudio = [];
+      this.fileListOtheraudio = [];
+      this.fileListDoc = [];
       this.formDialog.description = "";
+      this.formDialog.type_name_list = [];
     },
     // 编辑书籍信息
     handleEdit(row, index) {
@@ -889,6 +909,9 @@ export default {
       };
       getContent(MethodName, data)
         .then((res) => {
+          if (res.type_name && res.type_name_list.length === 0) {
+            res.type_name_list = [res.type_name];
+          }
           this.formDialog = {
             id: res.id,
             name: res.name,
@@ -906,6 +929,7 @@ export default {
             edition: res.edition,
             theme_color: res.theme_color,
             type_id: res.type_id,
+            type_name_list: res.type_name_list,
           };
           if (res.picture_url) {
             let obj = {
@@ -981,7 +1005,12 @@ export default {
       this.formDialog.price = null;
       this.agency = "";
       this.fileList = [];
+      this.fileListVideo = [];
+      this.fileListAudio = [];
+      this.fileListOtheraudio = [];
+      this.fileListDoc = [];
       this.formDialog.description = "";
+      this.formDialog.type_name_list = [];
       done();
     },
   },
@@ -1064,4 +1093,4 @@ export default {
 .el-dialog {
   font-size: 0;
 }
-</style>
+</style>