Explorar o código

基础课程-添加单元

Mr_pet hai 1 ano
pai
achega
0fcfe5b649

+ 9 - 0
index.html

@@ -17,6 +17,15 @@
       src="https://g.alicdn.com/de/prismplayer/2.11.0/aliplayer-min.js"
     ></script>
     <title>桐艺云校</title>
+    <script>
+      var _hmt = _hmt || [];
+      (function() {
+        var hm = document.createElement("script");
+        hm.src = "https://hm.baidu.com/hm.js?2ae93fd6c7344305ffd4216525ceda14";
+        var s = document.getElementsByTagName("script")[0]; 
+        s.parentNode.insertBefore(hm, s);
+      })();
+    </script>
   </head>
   <body>
     <div id="app"></div>

+ 2 - 1
public/config.js

@@ -45,7 +45,8 @@ function isWhich() {
     } else if(window.location.host.includes('tyyx.txhlwxx.com')) {
         return production
     } else {
-        return local
+      // return local;
+      return production
     }
 }
 window.GLOBAL_CONFIG = isWhich()

+ 2 - 3
src/pages/courseResources.vue

@@ -287,10 +287,9 @@ export default {
     },
     //详情页
     toDetail(transParams) {
-      if (this.chooseNum == '5') {
-        console.log('ksk', transParams);
+      if (transParams.is_wlzy == '1') {
         this.$router.push({ path: '/resourceChapterList', query: { id: transParams.kk_id } });
-      } else {
+      }else {
         this.$router.push({ path: '/resourceChapter', query: { id: transParams.kk_id } });
       }
     },

+ 9 - 4
src/pages/courseResourcesAll.vue

@@ -68,7 +68,7 @@
             <div class="singleEvalStar_right">
               <div class="singleEvalStar">{{ item.subject_name }}</div>
               <div class="singleEvalStar">{{ item.grade_name }}</div>
-              <div class="singleEvalStar">编辑部</div>
+              <div class="singleEvalStar" v-if="false">{{ item.kk_jgmc }}</div>
             </div>
           </div>
           <!-- positing -->
@@ -292,7 +292,11 @@ export default {
     },
     //移步详情页
     toDetail(row, index) {
-      this.$router.push({ path: '/resourceChapter', query: { id: row.kk_id } })
+      if (row.is_wlzy == '1') {
+        this.$router.push({ path: '/resourceChapterList', query: { id: row.kk_id } });
+      }else {
+        this.$router.push({ path: '/resourceChapter', query: { id: row.kk_id } })
+      }
     },
     //翻页
     handleChangePage(val) {
@@ -453,16 +457,17 @@ export default {
       display: flex;
       flex-direction: row;
       flex-wrap: nowrap;
+      justify-content: space-between;
       align-items: center;
       .singleEvalStar_left{
-        width: 50%;
+        width: 70%;
         img {
           width: 18px;
           display: inline-block;
         }
       }
       .singleEvalStar_right{
-        width: 50%;
+        width: 30%;
         display: flex;
         flex-direction: row;
         flex-wrap: nowrap;

+ 27 - 2
src/pages/courseResourcesChapterList.vue

@@ -30,7 +30,7 @@
           </div>
         </div> -->
         <el-collapse class="unitAll" v-model="activeNames" @change="handleChange" accordion >
-          <el-collapse-item title="单元1" :name="index" v-for="(item,index) in 4" :key="index">
+          <el-collapse-item title="单元1" :name="index" v-for="(item,index) in 4" :key="index" @click="handleUnit(item)">
             <div class="UnitChapter">
             <div class="singleUnitChapter" v-for="(item,index) in 3" :key="index">章节{{ index }}</div>
           </div>
@@ -49,7 +49,7 @@
 <script>
 import CommonHeader from "@/components/CommonHeader/index.vue";
 import CommonFooter from "@/components/CommonFooter/index.vue";
-import { courseDetail,courseSourceList } from "./kczy/allApi.js";
+import { courseDetail,courseSourceList,attribDetail } from "./kczy/allApi.js";
 import { user } from "@/store/user.js";
   export default {
   name: 'chapter',
@@ -117,6 +117,26 @@ import { user } from "@/store/user.js";
       })
 
     },
+    initUnitDetail() {
+      let transObj = {
+        kk_id:kkId,
+      }
+      attribDetail(transObj)
+        .then(res => {
+          if (res.code == '1') {
+            let responseData = res.data.details;
+            responseData.forEach(item => {
+              this.unitNames.push(
+                { id: item.ka_id, name: item.ka_name}
+              )
+            })
+            this.dialogFormVisibleChapter = true;
+          }
+        })
+        .catch(err => {
+        console.log('err', err);
+      })
+    },
     /**预览页面*/
     reviewFile(item) {
       let marklable = item.kf_path.substr(item.kf_path.lastIndexOf(".") + 1);
@@ -131,9 +151,14 @@ import { user } from "@/store/user.js";
     searchBtn() {
       this.initSourceData();
     },
+    /**单元手风琴*/
     handleChange(val) {
       console.log(val);
     },
+    /**单元点击*/
+    handleUnit(item) {
+      console.log('item',item);
+    },
 
   },
 

+ 8 - 1
src/pages/kczy/allApi.js

@@ -146,4 +146,11 @@ export const defaultSubject = (data = {}) => {
     url: '/jcxx/subject/index',
     data
   })
-}
+}
+
+//属性分类-批量详情接口
+export const attribDetail = (data = {}) =>
+request({
+  url: '/kczy/attrib/details',
+  data:data
+})

+ 14 - 0
src/pages/personal/components/MyCourse/api.js

@@ -497,3 +497,17 @@ export const files_detail = (data = {}) =>
     data: data
   })
 
+//属性分类-批量添加接口
+export const attribAdd = (data = {}) =>
+  request({
+    url: '/kczy/attrib/adds',
+    data:data
+  })
+
+//属性分类-批量详情接口
+export const attribDetail = (data = {}) =>
+request({
+  url: '/kczy/attrib/details',
+  data:data
+})
+  

+ 110 - 24
src/pages/personal/components/MyCourse/kczy.vue

@@ -67,7 +67,7 @@
                       <el-icon @click.stop="handleEdit(item.kk_id)">
                         <EditPen />
                       </el-icon>
-                      <el-icon @click.stop="handleAddChapter(item.kk_id)" style="margin-left: 20px;" v-if="item.kc_cate_level_2=='11'">
+                      <el-icon @click.stop="handleAddChapter(item.kk_id)" style="margin-left: 20px;" v-if="item.is_wlzy=='1'">
                         <Plus/>
                       </el-icon>
                       <el-icon @click.stop="handleDelete(item.kk_id)" style="margin-left: 20px;">
@@ -88,24 +88,29 @@
       </div>
     </el-card>
 
-    <el-dialog title="收货地址" :visible.sync="dialogFormVisible">
+    <el-dialog v-model="dialogFormVisibleChapter" title=""  width="25%">
+      <div class="" style="text-align: center; margin-bottom: 15px; font-size: 16px;">添加单元名称</div>
       <el-form :model="chapterForm">
-        <el-form-item label="活动名称" :label-width="formLabelWidth">
-          <el-input v-model="chapterForm.name" autocomplete="off"></el-input>
-        </el-form-item>
-        <el-form-item label="活动区域" :label-width="formLabelWidth">
-          <el-select v-model="chapterForm.region" placeholder="请选择活动区域">
-            <el-option label="区域一" value="shanghai"></el-option>
-            <el-option label="区域二" value="beijing"></el-option>
-          </el-select>
-        </el-form-item>
+        <div class="singO"  v-for="(item , index) in unitNames" :key="item.id">
+          <div class="singO_left">
+            <el-form-item :label="'单元名称' + (index+1)+':'" :label-width="formLabelWidth">
+              <el-input v-model="item.name" autocomplete="off" />
+            </el-form-item>
+          </div>
+          <div class="singO_right" ><el-button type="danger" @click="removeUnit(item.id)">删除</el-button></div>
+        </div>
+        
       </el-form>
-      <div slot="footer" class="dialog-footer">
-        <el-button @click="dialogFormVisible = false">取 消</el-button>
-        <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
+      <div style="text-align: left; border-top: 1px dashed #c9c9c9; box-sizing: border-box; padding-top: 10px;">
+      <el-button type="primary" @click="addUnit">添加</el-button>
       </div>
+      <template #footer>
+        <span class="dialog-footer">
+          <el-button @click="dialogFormVisibleChapter = false">取消</el-button>
+          <el-button type="primary" @click="submitForm">提交</el-button>
+        </span>
+      </template>
     </el-dialog>
-    
 
   </div>
 </template>
@@ -113,7 +118,7 @@
 <script>
 import { Delete, EditPen, Plus} from '@element-plus/icons-vue';
 import { ElMessageBox } from 'element-plus'
-import { grade_list, subject_list, cate_list, kc_list, kc_delete } from "./api";
+import { grade_list, subject_list, cate_list, kc_list, kc_delete,attribAdd,attribDetail } from "./api";
 import { getFullUrl } from '@/utils/helper';
 import { user } from '~/store/user';
 export default {
@@ -131,12 +136,15 @@ export default {
       pageSize: 10,
       currentPage: 1,
       total: 0,
-      dialogFormVisible: true,
+      kkId:'',
+      dialogFormVisibleChapter: false,
       chapterForm: {
         name: '',
-        region: '',
       },
-      formLabelWidth: '120px',
+      formLabelWidth: '90px',
+      unitNum:1,
+      unitNum: [1], // 数组,用于循环添加单元
+      unitNames: [{ id: "", name: '' }] // 数组,用于保存所有单元的ID和名称的对象
     }
   },
   components: { Delete, EditPen, Plus, ElMessageBox },
@@ -240,9 +248,66 @@ export default {
       this.setStorage();
     },
     handleAddChapter(kkId) {
-      // this.dialogFormVisible = true
-      console.log('this',this);
-      console.log('kkid', kkId);
+      this.unitNames = [];
+      this.kkId = kkId;
+      let transObj = {
+        kk_id:kkId,
+      }
+      attribDetail(transObj)
+        .then(res => {
+          if (res.code == '1') {
+            console.log('res', res);
+            let responseData = res.data.details;
+            responseData.forEach(item => {
+              this.unitNames.push(
+                { id: item.ka_id, name: item.ka_name}
+              )
+            })
+            this.dialogFormVisibleChapter = true;
+          }
+        })
+        .catch(err => {
+        console.log('err', err);
+      })
+    },
+    addUnit() {
+      this.unitNum.push(this.unitNum.length + 1);
+      // const newId = Number(this.unitNames.length) + 1;
+      // const newId = Date.now();
+      this.unitNames.push({ id: '', name: '' }); // 每次添加单元时,为 unitNames 数组添加一个带有ID的对象
+    },
+    removeUnit(id) {
+      const index = this.unitNames.findIndex(item => item.id === id);
+      if (index !== -1) {
+        this.unitNames.splice(index, 1);
+      }
+    },
+    submitForm() {
+      console.log('json', JSON.stringify(this.unitNames));
+      let transObj = {
+        kk_id:this.kkId,
+        kczy_attrib: this.unitNames.map(item => { 
+          return {
+            ka_id: item.id,
+            ka_name:item.name
+          }
+        }) 
+      }
+      console.log('transObj:', transObj);
+      attribAdd(transObj)
+        .then(res => {
+          if (res.code == '1') {
+            this.dialogFormVisibleChapter = false;
+          }
+        })
+        .catch(err => {
+        console.log('err', err);
+      })
+      
+      return false
+      // 提交表单的逻辑
+      this.dialogFormVisibleChapter = false;
+      // 这里可以提交表单数据或执行其他逻辑
     },
     handleDelete(kk_id) {
       ElMessageBox.confirm('是否确定删除当前课程?', '提示', {
@@ -279,7 +344,7 @@ export default {
       sessionStorage.removeItem("subject_id");
       sessionStorage.removeItem("kc_cate_level_1");
       sessionStorage.removeItem("page");
-    }
+    },
   },
   created() {
     this.initGradeData();
@@ -297,7 +362,12 @@ export default {
         _this.initData();
       }
     }
-  }
+  },
+  computed: {
+    filteredUnitNames() {
+      return this.unitNames.filter(item => item.id !== '');
+    }
+  },
 }
 </script>
 
@@ -459,4 +529,20 @@ export default {
     }
   }
 }
+
+.singO {
+  display: flex;
+  justify-content: space-between;
+  .singO_left{
+    width: 80%;
+  }
+  .singO_right{
+    width: 20%;
+    text-align: right;
+  }
+}
+.unit-row > .el-input {
+  flex: 1; /* 让输入框占据剩余空间 */
+  margin-right: 10px; /* 调整输入框和删除按钮之间的间距 */
+}
 </style>