From afe2fbc5b0375c7c06853fc981deec74e04fd630 Mon Sep 17 00:00:00 2001
From: 杨磊 <505174330@qq.com>
Date: 星期日, 24 八月 2025 11:30:40 +0800
Subject: [PATCH] Merge branch 'master' of http://182.92.203.7:2001/r/xiehe_website

---
 src/views/personalCenter/course.vue |  311 +++++++++++++++++++++++----------------------------
 1 files changed, 139 insertions(+), 172 deletions(-)

diff --git a/src/views/personalCenter/course.vue b/src/views/personalCenter/course.vue
index 226347d..ecb2b1c 100644
--- a/src/views/personalCenter/course.vue
+++ b/src/views/personalCenter/course.vue
@@ -3,20 +3,13 @@
     <div class="personalPage-title">鎴戠殑璇剧▼</div>
     <div class="headerBox">
       <div class="searchBox">
-        <el-input
-          v-model="searchKey"
-          clearable
-          @clear="getData"
-          placeholder="璇疯緭鍏ュ叧閿瓧"
-        >
+        <el-input v-model="searchKey" clearable @clear="getData" placeholder="璇疯緭鍏ュ叧閿瓧">
           <template #append>
             <el-button type="primary" class="searchBtn" :icon="Search" @click="getData" />
           </template>
         </el-input>
       </div>
-      <el-button type="primary" class="applyStartClasses" @click="applyCourse"
-        >鐢宠寮�璇�</el-button
-      >
+      <el-button type="primary" class="applyStartClasses" @click="applyCourse">鐢宠寮�璇�</el-button>
     </div>
     <div class="courseListBox" v-loading="pages.loading">
       <div
@@ -34,7 +27,7 @@
               <div style="width: 300px" v-html="item.reason"></div>
             </template>
             <span v-if="item.applyState == 'Reject'" style="color: red">
-              鎷掔粷鍘熷洜锛歿{ item.reason != "" ? item.reason : "-" }}
+              鎷掔粷鍘熷洜锛歿{ item.reason != '' ? item.reason : '-' }}
             </span>
           </el-tooltip>
           <el-button
@@ -63,11 +56,7 @@
             >
               瀹℃牳涓�
             </div>
-            <div
-              class="stateIcon"
-              v-if="item.applyState == 'Reject'"
-              style="background-color: red"
-            >
+            <div class="stateIcon" v-if="item.applyState == 'Reject'" style="background-color: red">
               鏈�氳繃
             </div>
             <img v-if="item.icon" :src="item.icon" />
@@ -97,13 +86,8 @@
     </div>
     <!-- 鐢宠寮�璇惧脊妗� -->
     <el-dialog v-model="applyCourseDialog" width="750" align-center>
-      <template #title>{{ editData ? "閲嶆柊鐢宠" : "鐢宠寮�璇�" }}</template>
-      <el-form
-        :model="formData"
-        label-position="left"
-        ref="dialogFormRef"
-        label-width="80px"
-      >
+      <template #title>{{ editData ? '閲嶆柊鐢宠' : '鐢宠寮�璇�' }}</template>
+      <el-form :model="formData" label-position="left" ref="dialogFormRef" label-width="80px">
         <el-form-item
           label="璇剧▼鍚嶇О"
           prop="name"
@@ -137,9 +121,7 @@
       <template #footer>
         <div class="dialog-footer">
           <el-button @click="applyCourseDialog = false">鍙栨秷</el-button>
-          <el-button type="primary" @click="submit" :loading="submitLoading"
-            >鎻愪氦</el-button
-          >
+          <el-button type="primary" @click="submit" :loading="submitLoading">鎻愪氦</el-button>
         </div>
       </template>
     </el-dialog>
@@ -156,37 +138,21 @@
               placeholder="璇疯緭鍏ュ叧閿瓧"
             >
               <template #append>
-                <el-button
-                  type="primary"
-                  class="searchBtn"
-                  :icon="Search"
-                  @click="getTextBook"
-                />
+                <el-button type="primary" class="searchBtn" :icon="Search" @click="getTextBook" />
               </template>
             </el-input>
           </div>
         </div>
         <div style="min-height: 370px" v-if="textBookListData.length > 0">
-          <div
-            v-for="(item, index) in textBookListData"
-            :key="index"
-            class="textBookItem"
-          >
-            <el-checkbox
-              class="checkBox"
-              v-model="item.check"
-              @change="selectChange(item)"
-            />
+          <div v-for="(item, index) in textBookListData" :key="index" class="textBookItem">
+            <el-checkbox class="checkBox" v-model="item.check" @change="selectChange(item)" />
             <div class="imgBox autoImgBox">
               <img :src="item.img" />
             </div>
             <p>{{ item.product.name }}</p>
           </div>
         </div>
-        <div
-          class="nullBox"
-          v-if="!textBookPages.loading && textBookListData.length == 0"
-        >
+        <div class="nullBox" v-if="!textBookPages.loading && textBookListData.length == 0">
           <el-empty />
         </div>
       </div>
@@ -211,137 +177,137 @@
 </template>
 
 <script setup lang="ts">
-import { reactive, ref, onMounted, inject, watch } from "vue";
-import { Search } from "@element-plus/icons-vue";
-import { useRouter, useRoute } from "vue-router";
-import { ElMessage } from "element-plus";
+import { reactive, ref, onMounted, inject, watch } from 'vue'
+import { Search } from '@element-plus/icons-vue'
+import { useRouter, useRoute } from 'vue-router'
+import { ElMessage } from 'element-plus'
 // eslint-disable-next-line
-import { getPublicImage } from "@/assets/js/middleGround/tool.js";
+import { getPublicImage } from '@/assets/js/middleGround/tool.js'
 // eslint-disable-next-line
-import defaultImg from "@/assets/images/default-book-img.png";
+import defaultImg from '@/assets/images/default-book-img.png'
 
-const router: any = useRouter();
-const route: any = useRoute();
-const MG: any = inject("MG");
-const selectName = ref("");
+const router: any = useRouter()
+const route: any = useRoute()
+const MG: any = inject('MG')
+const selectName = ref('')
 
 // 鐢宠寮�璇鹃槻鎶杔oading
-const submitLoading = ref(false);
+const submitLoading = ref(false)
 
-const courseList: any = ref([]);
+const courseList: any = ref([])
 
 onMounted(() => {
-  getData();
-});
+  getData()
+})
 
-const searchKey = ref("");
+const searchKey = ref('')
 const pages = reactive({
   page: 1,
   pageSize: 6,
   count: 0,
   loading: true,
-});
+})
 
 // 鑾峰彇璇剧▼
 const getData = () => {
-  pages.loading = true;
+  pages.loading = true
   MG.edu
     .getAppCourseList({
       size: pages.pageSize,
       start: pages.pageSize * pages.page - pages.pageSize,
       sort: {
-        type: "Desc",
-        field: "CreateDate",
+        type: 'Desc',
+        field: 'CreateDate',
       },
       filterList: [],
       searchList: searchKey.value
         ? [
             {
               keywords: searchKey.value,
-              field: "Name",
-              compareType: "Contains",
+              field: 'Name',
+              compareType: 'Contains',
             },
           ]
         : [],
     })
     .then((res: any) => {
-      pages.loading = false;
-      pages.count = res.totalSize;
+      pages.loading = false
+      pages.count = res.totalSize
       courseList.value = res.datas.map((item: any) => {
         return {
           ...item,
           name: item.name,
           id: item.id,
-          icon: item.icon != "default" ? getPublicImage(item.icon, 80) : defaultImg,
+          icon: item.icon != 'default' ? getPublicImage(item.icon, 80) : defaultImg,
           introduction: item.description,
-          reason: item.applyReturnMsg ? JSON.parse(item.applyReturnMsg).reason : "",
-        };
-      });
-    });
-};
+          reason: item.applyReturnMsg ? JSON.parse(item.applyReturnMsg).reason : '',
+        }
+      })
+    })
+}
 
 // 鐢宠寮�璇�
 const applyCourse = () => {
-  editData.value = null;
+  editData.value = null
   formData.value = {
-    name: "",
-    bookName: "",
-    bookId: "",
-    selectData: "",
-    desc: "",
-  };
-  applyCourseDialog.value = true;
-};
+    name: '',
+    bookName: '',
+    bookId: '',
+    selectData: '',
+    desc: '',
+  }
+  applyCourseDialog.value = true
+}
 
-const editData: any = ref(null);
+const editData: any = ref(null)
 const reapplyCourse = (data: any) => {
-  editData.value = data;
+  editData.value = data
   formData.value = {
     name: data.name,
     bookName: data.linkProduct.name,
     bookId: data.linkProduct.id,
-    selectData: "",
+    selectData: '',
     desc: data.description,
-  };
-  applyCourseDialog.value = true;
-};
+  }
+  applyCourseDialog.value = true
+}
 
 // 鐢宠鏁欐潗寮规
-const applyCourseDialog = ref(false);
-const selectTextBookDialog = ref(false);
+const applyCourseDialog = ref(false)
+const selectTextBookDialog = ref(false)
 const formData = ref({
-  name: "",
-  bookName: "",
-  bookId: "",
-  selectData: "",
-  desc: "",
-});
+  name: '',
+  bookName: '',
+  bookId: '',
+  selectData: '',
+  desc: '',
+})
 
 const selectChange = (select: any) => {
   for (let i = 0; i < textBookListData.value.length; i++) {
-    const item: any = textBookListData.value[i];
+    const item: any = textBookListData.value[i]
     if (item.id == select.id) {
-      item.check = true;
+      item.check = true
     } else {
-      item.check = false;
+      item.check = false
     }
   }
-};
+}
 
 const selectTextBookSubmit = () => {
-  const selectData: any = textBookListData.value.filter((item: any) => item.check)[0];
+  const selectData: any = textBookListData.value.filter((item: any) => item.check)[0]
   if (!selectData?.product?.id) {
-    ElMessage.warning("璇烽�夋嫨寮�璇炬暀鏉愶紒");
-    return false;
+    ElMessage.warning('璇烽�夋嫨寮�璇炬暀鏉愶紒')
+    return false
   }
-  formData.value.bookId = selectData.product.id;
-  formData.value.bookName = selectData.product.name;
-  formData.value.selectData = selectData;
-  selectTextBookDialog.value = false;
-};
+  formData.value.bookId = selectData.product.id
+  formData.value.bookName = selectData.product.name
+  formData.value.selectData = selectData
+  selectTextBookDialog.value = false
+}
 
 const submit = () => {
-  submitLoading.value = true;
+  submitLoading.value = true
   if (editData.value) {
     MG.edu
       .updateCourse({
@@ -359,36 +325,36 @@
             }),
           })
           .then((ares: any) => {
-            ElMessage.success("璇剧▼宸查噸鏂扮敵璇凤紝绛夊緟绠$悊鍛樺鏍搞��");
-            applyCourseDialog.value = false;
-            getData();
-          });
-      });
+            ElMessage.success('璇剧▼宸查噸鏂扮敵璇凤紝绛夊緟绠$悊鍛樺鏍搞��')
+            applyCourseDialog.value = false
+            getData()
+          })
+      })
   } else {
-    if (formData.value.name == "") {
+    if (formData.value.name == '') {
       ElMessage({
-        type: "warning",
-        message: "璇峰~鍐欒绋嬪悕绉�",
-      });
-      submitLoading.value = false;
-      return false;
+        type: 'warning',
+        message: '璇峰~鍐欒绋嬪悕绉�',
+      })
+      submitLoading.value = false
+      return false
     }
     if (!formData.value.bookId) {
       ElMessage({
-        type: "warning",
-        message: "璇烽�夋嫨鍏宠仈鏁欐潗",
-      });
-      submitLoading.value = false;
-      return false;
+        type: 'warning',
+        message: '璇烽�夋嫨鍏宠仈鏁欐潗',
+      })
+      submitLoading.value = false
+      return false
     }
     MG.edu
       .applyNewCourse({
         name: formData.value.name,
         description: formData.value.desc,
-        content: "",
-        icon: formData.value.selectData.product.icon ?? "default",
-        type: "course",
-        config: "",
+        content: '',
+        icon: formData.value.selectData.product.icon ?? 'default',
+        type: 'course',
+        config: '',
         applyData: JSON.stringify({
           textBookId: formData.value.bookId,
           textBookName: formData.value.bookName,
@@ -399,17 +365,17 @@
       })
       .then((res: any) => {
         if (res) {
-          ElMessage.success("璇剧▼宸茬敵璇凤紝绛夊緟绠$悊鍛樺鏍搞��");
-          applyCourseDialog.value = false;
-          getData();
+          ElMessage.success('璇剧▼宸茬敵璇凤紝绛夊緟绠$悊鍛樺鏍搞��')
+          applyCourseDialog.value = false
+          getData()
         }
-      });
+      })
   }
-  formData.value.selectData = "";
+  formData.value.selectData = ''
   setTimeout(() => {
-    submitLoading.value = false;
-  }, 1000);
-};
+    submitLoading.value = false
+  }, 1000)
+}
 
 // 鑾峰彇宸茶喘涔扮殑鏁欐潗鍒楄〃
 const textBookPages = reactive({
@@ -417,77 +383,77 @@
   pageSize: 12,
   count: 0,
   loading: false,
-});
-const textBookListData = ref([]);
+})
+const textBookListData = ref([])
 
 const getTextBook = () => {
-  textBookPages.loading = true;
+  textBookPages.loading = true
   const searchData = [
     {
-      keywords: "digitalTextbooks",
-      field: "ProductType",
+      keywords: 'digitalTextbooks',
+      field: 'ProductType',
     },
     {
-      keywords: "mediaBook",
-      field: "ProductType",
+      keywords: 'mediaBook',
+      field: 'ProductType',
     },
     {
       keywords: selectName.value,
-      field: "ProductName",
+      field: 'ProductName',
     },
-  ];
+  ]
   const data = {
     Size: textBookPages.pageSize,
     Start: textBookPages.pageSize * textBookPages.page - textBookPages.pageSize,
     sort: {
-      type: "Desc",
-      field: "CreateDate",
+      type: 'Desc',
+      field: 'CreateDate',
     },
     searchList: searchData,
-  };
+  }
   MG.store
     .getPurchasedProductList(data)
     .then((res: any) => {
-      textBookPages.count = res.totalSize;
+      textBookPages.count = res.totalSize
       textBookListData.value = res.datas.map((item: any) => {
         return {
           ...item,
           img: item.product.icon ? getPublicImage(item.product.icon, 80) : defaultImg,
-        };
-      });
-      textBookPages.loading = false;
+        }
+      })
+      textBookPages.loading = false
     })
     .catch(() => {
-      textBookPages.loading = false;
-    });
-};
+      textBookPages.loading = false
+    })
+}
 
 // 閫夋嫨鏁欐潗
 const selectBook = () => {
-  selectTextBookDialog.value = true;
-  textBookListData.value = [];
-  getTextBook();
-};
+  selectTextBookDialog.value = true
+  textBookListData.value = []
+  getTextBook()
+}
 
 const pageChange = (val: any) => {
-  pages.page = val;
-  getData();
-};
+  pages.page = val
+  getData()
+}
 const handleCurrentChange = (val: any) => {
-  textBookPages.page = val;
-  getTextBook();
-};
+  textBookPages.page = val
+  getTextBook()
+}
 
 const gotoDetail = (data: any) => {
-  if (data.applyState == "Normal") {
+  if (data.applyState == 'Normal') {
     router.push({
-      name: "courseDetail",
+      name: 'courseDetail',
       query: {
         courseId: data.id,
       },
-    });
+    })
   }
-};
+}
 </script>
 
 <style lang="less" scoped>
@@ -520,7 +486,7 @@
 
     .courseItem {
       float: left;
-      width: 46%;
+      width: 45%;
       height: 210px;
       margin: 0 2% 20px;
       border-radius: 8px;
@@ -561,6 +527,7 @@
 
       .itemInfo {
         padding: 10px 20px;
+        box-sizing: border-box;
         flex: 1;
         display: flex;
         .imgBox {

--
Gitblit v1.9.1