diff --git a/pages.json b/pages.json index e21b33c..a4d67f3 100644 --- a/pages.json +++ b/pages.json @@ -90,7 +90,7 @@ } }, { - "path" : "pages/Mystudent/addforwork", + "path" : "pages/Mystudent/addclassforwork", "style" : { "navigationBarTitleText": "", @@ -195,6 +195,17 @@ "enablePullDownRefresh": false, "navigationStyle": "custom" } + }, + // 作业添加学生 + { + "path" : "pages_add/add_studentsforwork", + "style" : + { + "navigationBarTitleText": "", + "navigationBarBackgroundColor": "#4473f6", + "enablePullDownRefresh": false, + "navigationStyle": "custom" + } } ] diff --git a/pages/Mystudent/addforwork.vue b/pages/Mystudent/addclassforwork.vue similarity index 56% rename from pages/Mystudent/addforwork.vue rename to pages/Mystudent/addclassforwork.vue index 11885a4..f277030 100644 --- a/pages/Mystudent/addforwork.vue +++ b/pages/Mystudent/addclassforwork.vue @@ -13,95 +13,34 @@ + placeholder-style="color:#C7CDD3" + @input="search()"> - - + + - - 雅思1班 + + - 共21人 - - - - - - - - - - 雅思1班 - - - 共21人 - - - - - - - - - - 雅思1班 - - - 共21人 + 共{{item.totalMembers}}人 + - - - - - - - - 李斯丹妮 - - - ID:3324 - - - - - - - - - - 李斯丹妮 - - - ID:3324 - - - - - - - - - - 李斯丹妮 - - - ID:3324 - - - + + - - - 确定添加(2) + + + 确定添加({{selectclass.length}}) @@ -115,10 +54,92 @@ export default { backgroundColor: "#transparent", }, showpage:1, + classlist:{}, + changeclasslist:{}, + isloding:true, + selectclass: [], + searchKeyword:'' + } }, + onLoad(option) { + this.selectclass=JSON.parse(decodeURIComponent(option.classinfo)) + }, + onShow() { + this.getclassList() + }, methods: { - + addclassinfo(){ + uni.setStorageSync('selectedClassInfo', this.selectclass); + + // Navigate back to the previous page + uni.navigateBack({ + delta: 1, // Number of pages to go back + success(res) { + console.log(res); + }, + fail(err) { + console.error(err); + } + }); + }, + toggleSelection(item) { + const selectedIndex = this.selectclass.findIndex(selectedItem => selectedItem.id === item.id); + + if (selectedIndex === -1) { + // If not selected, add to the array and apply the 'act1' class + this.selectclass.push({ name: item.name, avatar: item.avatar, id: item.id }); + item.isSelected = true; + } else { + item.isSelected = false; + // If already selected, remove from the array and remove the 'act1' class + this.selectclass.splice(selectedIndex, 1); + } + console.log(this.selectclass, 'this.selectclass'); + }, + isSelectedClass(item) { + return this.selectclass.some(selectedItem => selectedItem.id === item.id); + }, + search() { + // 根据关键字过滤 this.classlist + if(this.searchKeyword!=''){ + const filteredList = JSON.parse(JSON.stringify(this.changeclasslist)).filter(item => item.name.includes(this.searchKeyword)); + // 更新 this.classlist 为过滤后的列表 + this.classlist = filteredList; + }else{ + this.fuwei() + } + + }, + highlightSearch(name) { + // 使用正则表达式替换匹配到的 searchKeyword 为带有颜色的文字 + if (this.searchKeyword) { + const regex = new RegExp(this.searchKeyword, 'gi'); + return name.replace(regex, match => `${match}`); + } + return name; + }, + fuwei() { + + this.classlist = JSON.parse(JSON.stringify(this.changeclasslist)); + }, + getclassList() { + this.$u.get("https://api.admin-v2.langsi.online/admin-api/classroom/page").then(res => { + + if (res.code === 0) { + this.classlist = res.data.list; + this.changeclasslist = JSON.parse(JSON.stringify(this.classlist)); + this.isloding = false; + this.selectclass.forEach(selectedItem => { + const index = this.classlist.findIndex(item => item.id === selectedItem.id); + if (index !== -1) { + this.$set(this.classlist, index, { ...this.classlist[index], isSelected: true }); + } + }); + + } + }); + }, } } diff --git a/pages_teacher/pages_add/add_students.vue b/pages_teacher/pages_add/add_students.vue deleted file mode 100644 index ed3f2a7..0000000 --- a/pages_teacher/pages_add/add_students.vue +++ /dev/null @@ -1,9 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages_teacher/pages_add/add_studentsforwork.vue b/pages_teacher/pages_add/add_studentsforwork.vue new file mode 100644 index 0000000..59e3b63 --- /dev/null +++ b/pages_teacher/pages_add/add_studentsforwork.vue @@ -0,0 +1,310 @@ + + + + + \ No newline at end of file diff --git a/pages_teacher/teacher_class/class_detail.vue b/pages_teacher/teacher_class/class_detail.vue index 620a48c..c67606f 100644 --- a/pages_teacher/teacher_class/class_detail.vue +++ b/pages_teacher/teacher_class/class_detail.vue @@ -1,6 +1,6 @@