From 76008bc03a45062660e6ce6fdd656fd8c63273e0 Mon Sep 17 00:00:00 2001 From: taoxu <2622874537@qq.com> Date: Thu, 7 Dec 2023 16:59:19 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/Mystudent/addstu.vue | 131 +++++++++++++++++-- pages/Mystudent/formstu.vue | 89 +++++++------ pages_teacher/teacher_class/class_detail.vue | 31 ++++- 3 files changed, 188 insertions(+), 63 deletions(-) diff --git a/pages/Mystudent/addstu.vue b/pages/Mystudent/addstu.vue index 215860d..89d0a64 100644 --- a/pages/Mystudent/addstu.vue +++ b/pages/Mystudent/addstu.vue @@ -1,27 +1,33 @@ <template> <view class="searchpage"> - <u-navbar title="搜索" :border-bottom="false" :background="bgc" title-color='#2E4975' title-size='36' + <u-navbar title="添加学生" :border-bottom="false" :background="bgc" title-color='#2E4975' title-size='36' height='36'></u-navbar> + <u-toast ref="uToast" /> <view class="serchbox"> <view class="serchimg"> <image src="https://file.langsi.online/yasiimg/web/static/uVMACkynkipOxuTYDqm0"> </image> </view> - <input type="text" placeholder="搜索相关内容..." class="input" placeholder-style="color:#C7CDD3 "> + <input type="text" + v-model="searchKeyword" + placeholder="搜索相关内容..." + class="input" + placeholder-style="color:#C7CDD3" + @input="search()"> </view> <view class="check_card"> - <view class="check_card_stu" v-for="(item,index ) in stulist" :key="index"> + <view class="check_card_stu " v-for="(item,index ) in stulist" :key="index" @click="toggleSelection(item)" :class="{ 'act1': item.isSelected }"> <view class="check_card_stu_info_left"> <view class="class_card_left"> - <image src=" https://file.langsi.online/yasiimg/web/static/udWNTRG6GulmTtgPRQ49"></image> + <image :src="item.headImgUrl"></image> </view> <view class="class_card_right"> - <view class="class_card_right_top"> - 李斯丹妮 + <view class="class_card_right_top" v-html="highlightSearch(item.nickName)"> + </view> <view class="class_card_right_bot"> - ID:3324 + ID:{{item.id}} </view> </view> </view> @@ -30,9 +36,14 @@ </view> - <view class="zhanwei" style="width: 100%; height: 50rpx;"> + <view class="zhanwei" style="width: 100%; height: 230rpx;"> </view> + <view class="botbtn" @click="addstu()" v-show="selectedIds.length>0"> + <view class="btn"> + 确定添加({{selectedIds.length}}) + </view> + </view> </view> </template> @@ -41,10 +52,13 @@ data() { return { bgc: { - backgroundColor: "#transparent", + backgroundColor: "#F6F9FC", }, checkindex: 1, - stulist:[] + stulist:[], + searchKeyword:'', + orgstulist:[], + selectedIds: [], } }, onLoad(option) { @@ -53,14 +67,81 @@ this.getallstu() }, methods: { + addstu() { + let data = { + memberId: this.selectedIds[0], + // memberId: '1522', + roomId: this.classid + }; + + this.$u.post(`https://api.admin-v2.langsi.online/admin-api/classroom/members/add`, data).then(res => { + if (res.code === 0) { + this.$refs.uToast.show({ + title: '添加成功', + type: 'success', + position:'top' + }) + this.selectedIds=[] + this.fuwei() + }else{ + this.$refs.uToast.show({ + title: '添加失败', + type: 'error', + position:'top' + + }) + this.selectedIds=[] + this.fuwei() + } + }); + }, + toggleSelection(item) { + const selectedIndex = this.selectedIds.indexOf(item.id); + + if (selectedIndex === -1) { + // If not selected, add to the array and apply the 'act1' class + this.selectedIds.push(item.id); + item.isSelected = true; // Add a property to the item to track selection + } else { + // If already selected, remove from the array and remove the 'act1' class + this.selectedIds.splice(selectedIndex, 1); + item.isSelected = false; + } + console.log(this.selectedIds,'selectedIdsselectedIdsselectedIds'); + }, + search() { + // 根据关键字过滤 this.classlist + if (this.searchKeyword !== '') { + const filteredList = JSON.parse(JSON.stringify(this.orgstulist)).filter(item => { + // 匹配 nickName 或者 id + return item.nickName.includes(this.searchKeyword) || item.id.toString().includes(this.searchKeyword); + }); + // 更新 this.classlist 为过滤后的列表 + this.stulist = filteredList; + } else { + this.fuwei(); + } + }, + fuwei() { + + this.stulist = JSON.parse(JSON.stringify(this.orgstulist)); + }, + highlightSearch(name) { + // 使用正则表达式替换匹配到的 searchKeyword 为带有颜色的文字 + if (this.searchKeyword) { + const regex = new RegExp(this.searchKeyword, 'gi'); + return name.replace(regex, match => `<span style="color: #2D7CE6 ;">${match}</span>`); + } + return name; + }, getallstu(){ this.$u.get(`https://api.admin-v2.langsi.online/admin-api/v2/ybs-user/page`).then(res => { if (res.code == 0) { - this.stulist=res.data.list - // this.classlist = res.data.list - // this.isloding = false + this.stulist=res.data.list + this.orgstulist = JSON.parse(JSON.stringify(res.data.list)); + } }) @@ -203,5 +284,29 @@ border: 2rpx solid #2D7CE6; } } + .botbtn{ + padding: 32rpx 32rpx 0 32rpx; + margin-left: -32rpx; + position: fixed; + bottom: 0; + width: 750rpx; + height: 200rpx; + background: #FFFFFF; + box-shadow: 0rpx -10rpx 16rpx 0rpx rgba(202,202,202,0.25); + border-radius: 40rpx 40rpx 0rpx 0rpx; + .btn{ + display: flex; + align-items: center; + justify-content: center; + font-size: 28rpx; + font-family:'PingFang','PingFang'; + font-weight: 800; + color: #FFFFFF; + width: 686rpx; + height: 80rpx; + background: linear-gradient(180deg, #74AFFF 0%, #2D7CE6 100%); + border-radius: 104rpx 104rpx 104rpx 104rpx; + } + } } </style> \ No newline at end of file diff --git a/pages/Mystudent/formstu.vue b/pages/Mystudent/formstu.vue index 8a385f5..e174b40 100644 --- a/pages/Mystudent/formstu.vue +++ b/pages/Mystudent/formstu.vue @@ -20,9 +20,11 @@ </image> </view> <input type="text" - placeholder="搜索相关内容..." - class="input" - placeholder-style="color:#C7CDD3 "> + v-model="searchKeyword" + placeholder="搜索相关内容..." + class="input" + placeholder-style="color:#C7CDD3" + @input="search()"> </view> </view> @@ -32,51 +34,17 @@ </view> <view class="check_card" v-show="checkindex==1"> - <view class="check_card_stu"> + <view class="check_card_stu" v-for="(item,index ) in stulist" :key="index"> <view class="check_card_stu_info_left"> <view class="class_card_left"> - <image src=" https://file.langsi.online/yasiimg/web/static/udWNTRG6GulmTtgPRQ49"></image> + <image :src="item.memberInfo.avatar"></image> </view> <view class="class_card_right"> - <view class="class_card_right_top"> - 李斯丹妮 + <view class="class_card_right_top" v-html="highlightSearch(item.memberInfo.name)"> + </view> <view class="class_card_right_bot"> - ID:3324 - </view> - </view> - </view> - <view class="check_card_stu_info_right"> - <view class="class_info" > - <view class="class_info_top" > - 平均成绩/分 - </view> - <view class="class_info_bot" > - 6 - </view> - </view> - <view class="class_info" > - <view class="class_info_top" > - 作业完成度 - </view> - <view class="class_info_bot" > - 80% - </view> - </view> - - </view> - </view> - <view class="check_card_stu "> - <view class="check_card_stu_info_left"> - <view class="class_card_left"> - <image src=" https://file.langsi.online/yasiimg/web/static/udWNTRG6GulmTtgPRQ49"></image> - </view> - <view class="class_card_right"> - <view class="class_card_right_top"> - 李斯丹妮 - </view> - <view class="class_card_right_bot"> - ID:3324 + ID:{{item.memberInfo.id}} </view> </view> </view> @@ -101,6 +69,7 @@ </view> </view> + </view> <!-- <view class="botbtn"> <view class="btn"> @@ -119,20 +88,54 @@ export default { backgroundColor: "#F6F9FC", }, checkindex: 1, + stulist:[], + searchKeyword:'', + orgstulist:[], + } }, onLoad(option) { // this.classid=option.id this.classid=15 + + }, + onShow() { this.getclassteacher() }, methods: { + + search() { + // 根据关键字过滤 this.classlist + if (this.searchKeyword !== '') { + const filteredList = JSON.parse(JSON.stringify(this.orgstulist)).filter(item => { + // 匹配 nickName 或者 id + return item.memberInfo.name.includes(this.searchKeyword) || item.memberInfo.id.toString().includes(this.searchKeyword); + }); + // 更新 this.classlist 为过滤后的列表 + this.stulist = filteredList; + } else { + this.fuwei(); + } + }, + fuwei() { + + this.stulist = JSON.parse(JSON.stringify(this.orgstulist)); + }, + highlightSearch(name) { + // 使用正则表达式替换匹配到的 searchKeyword 为带有颜色的文字 + if (this.searchKeyword) { + const regex = new RegExp(this.searchKeyword, 'gi'); + return name.replace(regex, match => `<span style="color: #2D7CE6 ;">${match}</span>`); + } + return name; + }, getclassteacher(){ this.$u.get(`https://api.admin-v2.langsi.online/admin-api/classroom/members/list?classId=${this.classid}`).then(res => { if (res.code == 0) { - this.teacherlist=res.data.list + this.stulist=res.data + this.orgstulist = JSON.parse(JSON.stringify(res.data)); // this.classlist = res.data.list // this.isloding = false diff --git a/pages_teacher/teacher_class/class_detail.vue b/pages_teacher/teacher_class/class_detail.vue index b8409a8..2c5fd91 100644 --- a/pages_teacher/teacher_class/class_detail.vue +++ b/pages_teacher/teacher_class/class_detail.vue @@ -37,8 +37,11 @@ <text>班级成员</text> <u-icon name="arrow-right" color="#646D7B" size="16"></u-icon> </view> - <view class="view_images"> - <image :src="item1.url" mode="" v-for="(item1,index) in item.image"></image> + <view class="view_images" > + <image :src="item.memberInfo.avatar" mode="" v-for="(item,index ) in classinfo.members" :key="index" v-if="index<=4"></image> + <view class="shenlue" v-if="classinfo.members.length>4"> + {{classinfo.members.length}} + </view> </view> </view> </view> @@ -123,10 +126,10 @@ onLoad(option) { // this.classid=option.id this.classid=15 - this.getclassinfo() + }, onShow(){ - + this.getclassinfo() }, methods:{ getclassinfo() { @@ -233,7 +236,7 @@ display: flex; justify-content: space-evenly; height: 160rpx; - background: linear-gradient(174deg, #FFF2E4 0%, #FFFFFF 100%); + background: linear-gradient(174deg, #FFF2E4 10%, #FFFFFF 100%); border-radius: 20rpx 20rpx 20rpx 20rpx; // padding: 60rpx; @@ -258,16 +261,30 @@ .view_images { display: flex; - justify-content: space-between; + // justify-content: space-between; margin-top: 20rpx; image { - + margin-right: 16rpx; width: 36rpx; height: 36rpx; } + .shenlue{ + display: flex; + justify-content: center; + align-items: center; + background-color: #FFF2E4; + border-radius: 50%; + width: 36rpx; + height: 36rpx; + font-size: 20rpx; + font-family: PingFang SC, PingFang SC; + font-weight: 800; + color: #F18F21; + + } } .view_operation { From 8aa8d9d4718eb1ccb9e8d639144e56aa682f1435 Mon Sep 17 00:00:00 2001 From: taoxu <2622874537@qq.com> Date: Thu, 7 Dec 2023 17:28:46 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=B8=B2=E6=9F=93=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages_teacher/teacher_class/class_detail.vue | 43 ++++++++++++++++---- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/pages_teacher/teacher_class/class_detail.vue b/pages_teacher/teacher_class/class_detail.vue index 2c5fd91..620a48c 100644 --- a/pages_teacher/teacher_class/class_detail.vue +++ b/pages_teacher/teacher_class/class_detail.vue @@ -2,7 +2,7 @@ <view class="view_body"> <u-navbar :is-back="true" title='班级详情' title-color="#000" :border-bottom="false" :background="true" id="navbar"> </u-navbar> - <view class="view_botton"> + <view class="view_botton" v-if="loading==false"> <view class="view_spoken"> <view> <image src="https://file.langsi.online/yasiimg/web/static/uXJ24nLEqmCb0FkFpmfy" mode=""></image> @@ -24,11 +24,11 @@ </view> </view> </view> - <view class="view_yellowBotton"> + <view class="view_yellowBotton" @click="toaddwork()"> 安排作业 </view> </view> - <view class="view_zy"> + <view class="view_zy" v-if="loading==false"> <view class="view_left" @click="tostu()"> @@ -51,8 +51,11 @@ <text>带班老师</text> <u-icon name="arrow-right" color="#646D7B" size="16"></u-icon> </view> - <view class="view_images"> - <image :src="item1.url" mode="" v-for="(item1,index) in item.image"></image> + <view class="view_images" > + <image :src="item.memberInfo.avatar" mode="" v-for="(item,index ) in classinfo.members" :key="index" v-if="index<=4"></image> + <view class="shenlue" v-if="classinfo.members.length>4"> + {{classinfo.members.length}} + </view> </view> </view> </view> @@ -94,7 +97,7 @@ data() { return { - isShow: false, + isShow: true, operation:[ { @@ -120,7 +123,9 @@ ], classid:0, - classinfo:{} + classinfo:{}, + workinfo:{}, + loading:true } }, onLoad(option) { @@ -130,8 +135,18 @@ }, onShow(){ this.getclassinfo() + this.getworkinfo() }, methods:{ + toaddwork(){ + uni.navigateTo({ + url: "/pages_teacher/teacher_teachers/teacher_addOperation?id=" + this.classinfo.id + }).then(res => { + + }).catch(err => { + + }); + }, getclassinfo() { this.$u.get(`https://api.admin-v2.langsi.online/admin-api/classroom/detail?id=${this.classid}`).then(res => { @@ -140,6 +155,20 @@ this.classinfo=res.data // this.classlist = res.data.list // this.isloding = false + this.loading=false + + + } + }) + }, + getworkinfo() { + this.$u.get(`https://api.admin-v2.langsi.online/admin-api/classroom/work-record?classroomId=${this.classid}`).then(res => { + + + if (res.code == 0) { + this.workinfo=res.data + // this.classlist = res.data.list + // this.isloding = false } }) From 33f9ef440de60beb999892ee258c5aa77da35094 Mon Sep 17 00:00:00 2001 From: taoxu <2622874537@qq.com> Date: Thu, 7 Dec 2023 21:28:50 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=B8=B2=E6=9F=93=20?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=A4=84=E7=90=86=20=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages.json | 13 +- .../{addforwork.vue => addclassforwork.vue} | 173 +++++----- pages_teacher/pages_add/add_students.vue | 9 - .../pages_add/add_studentsforwork.vue | 310 ++++++++++++++++++ pages_teacher/teacher_class/class_detail.vue | 18 +- .../teacher_teachers/teacher_addOperation.vue | 299 ++++++++++------- 6 files changed, 615 insertions(+), 207 deletions(-) rename pages/Mystudent/{addforwork.vue => addclassforwork.vue} (56%) delete mode 100644 pages_teacher/pages_add/add_students.vue create mode 100644 pages_teacher/pages_add/add_studentsforwork.vue 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 @@ </image> </view> <input type="text" + v-model="searchKeyword" placeholder="搜索相关内容..." class="input" - placeholder-style="color:#C7CDD3 "> + placeholder-style="color:#C7CDD3" + @input="search()"> </view> - <view class="teacher_card_box" v-show="showpage==0"> - <view class="teacher_card" > + <view class="teacher_card_box" > + <view class="teacher_card" v-for="(item, index) in classlist" v-if="isloding == false" :key="index" @click="toggleSelection(item)" :class="{ 'act1': item.isSelected }"> <view class="class_card_left"> <image src=" https://file.langsi.online/yasiimg/web/static/udWNTRG6GulmTtgPRQ49"></image> </view> <view class="class_card_right"> - <view class="class_card_right_top"> - 雅思1班 + <view class="class_card_right_top" v-html="highlightSearch(item.name)"> + </view> <view class="class_card_right_bot"> - 共21人 - </view> - </view> - </view> - <view class="teacher_card act1" > - <view class="class_card_left"> - <image src=" https://file.langsi.online/yasiimg/web/static/udWNTRG6GulmTtgPRQ49"></image> - </view> - <view class="class_card_right"> - <view class="class_card_right_top"> - 雅思1班 - </view> - <view class="class_card_right_bot"> - 共21人 - </view> - </view> - </view> - <view class="teacher_card" > - <view class="class_card_left"> - <image src=" https://file.langsi.online/yasiimg/web/static/udWNTRG6GulmTtgPRQ49"></image> - </view> - <view class="class_card_right"> - <view class="class_card_right_top"> - 雅思1班 - </view> - <view class="class_card_right_bot"> - 共21人 + 共{{item.totalMembers}}人 </view> </view> </view> + </view> - <view class="teacher_card_box" v-show="showpage==1"> - <view class="student_card" > - <view class="class_card_left"> - <image src=" https://file.langsi.online/yasiimg/web/static/udWNTRG6GulmTtgPRQ49"></image> - </view> - <view class="class_card_right"> - <view class="class_card_right_top"> - 李斯丹妮 - </view> - <view class="class_card_right_bot"> - ID:3324 - </view> - </view> - </view> - <view class="student_card act1" > - <view class="class_card_left"> - <image src=" https://file.langsi.online/yasiimg/web/static/udWNTRG6GulmTtgPRQ49"></image> - </view> - <view class="class_card_right"> - <view class="class_card_right_top"> - 李斯丹妮 - </view> - <view class="class_card_right_bot"> - ID:3324 - </view> - </view> - </view> - <view class="student_card" > - <view class="class_card_left"> - <image src=" https://file.langsi.online/yasiimg/web/static/udWNTRG6GulmTtgPRQ49"></image> - </view> - <view class="class_card_right"> - <view class="class_card_right_top"> - 李斯丹妮 - </view> - <view class="class_card_right_bot"> - ID:3324 - </view> - </view> - </view> + <view class="zhanwei" style="width: 100%; height: 230rpx;"> + </view> - <view class="botbtn"> - <view class="btn"> - 确定添加(2) + <view class="botbtn" v-if="selectclass.length>0"> + <view class="btn" @click="addclassinfo()"> + 确定添加({{selectclass.length}}) </view> </view> </view> @@ -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 => `<span style="color: #2D7CE6 ;">${match}</span>`); + } + 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 }); + } + }); + + } + }); + }, } } </script> 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 @@ -<template> - <view>添加学生-个人</view> -</template> - -<script> -</script> - -<style> -</style> \ 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 @@ +<template> + <view class="searchpage"> + <u-navbar title="添加学生" :border-bottom="false" :background="bgc" title-color='#2E4975' title-size='36' + height='36'></u-navbar> + <u-toast ref="uToast" /> + <view class="serchbox"> + <view class="serchimg"> + <image src="https://file.langsi.online/yasiimg/web/static/uVMACkynkipOxuTYDqm0"> + + </image> + </view> + <input type="text" + v-model="searchKeyword" + placeholder="搜索相关内容..." + class="input" + placeholder-style="color:#C7CDD3" + @input="search()"> + </view> + <view class="check_card"> + <view class="check_card_stu " v-for="(item,index ) in stulist" :key="index" @click="toggleSelection(item)" :class="{ 'act1': item.isSelected }"> + <view class="check_card_stu_info_left"> + <view class="class_card_left"> + <image :src="item.headImgUrl"></image> + </view> + <view class="class_card_right"> + <view class="class_card_right_top" v-html="highlightSearch(item.nickName)"> + + </view> + <view class="class_card_right_bot"> + ID:{{item.id}} + </view> + </view> + </view> + + </view> + + + </view> + <view class="zhanwei" style="width: 100%; height: 230rpx;"> + + </view> + <view class="botbtn" @click="addstu()" v-show="selectedIds.length>0"> + <view class="btn"> + 确定添加({{selectedIds.length}}) + </view> + </view> + </view> +</template> + +<script> + export default { + data() { + return { + bgc: { + backgroundColor: "#F6F9FC", + }, + checkindex: 1, + stulist:[], + searchKeyword:'', + orgstulist:[], + selectedIds: [], + } + }, + onLoad(option) { + // this.classid=option.id + this.selectedIds=JSON.parse(decodeURIComponent(option.stuinfo)) + + }, + onShow(){ + this.getallstu() + }, + methods: { + addstu() { + uni.setStorageSync('selectedStuInfo', this.selectedIds); + + // 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.selectedIds.indexOf(item.id); + const selectedIndex = this.selectedIds.findIndex(selectedItem => selectedItem.id === item.id); + if (selectedIndex === -1) { + // If not selected, add to the array and apply the 'act1' class + this.selectedIds.push({ name: item.nickName, avatar: item.headImgUrl, id: item.id }); + + item.isSelected = true; // Add a property to the item to track selection + } else { + // If already selected, remove from the array and remove the 'act1' class + this.selectedIds.splice(selectedIndex, 1); + item.isSelected = false; + console.log(this.selectedIds,'selectedIdsselectedIdsselectedIds'); + } + + }, + search() { + // 根据关键字过滤 this.classlist + if (this.searchKeyword !== '') { + const filteredList = JSON.parse(JSON.stringify(this.orgstulist)).filter(item => { + // 匹配 nickName 或者 id + return item.nickName.includes(this.searchKeyword) || item.id.toString().includes(this.searchKeyword); + }); + // 更新 this.classlist 为过滤后的列表 + this.stulist = filteredList; + } else { + this.fuwei(); + } + }, + fuwei() { + + this.stulist = JSON.parse(JSON.stringify(this.orgstulist)); + }, + highlightSearch(name) { + // 使用正则表达式替换匹配到的 searchKeyword 为带有颜色的文字 + if (this.searchKeyword) { + const regex = new RegExp(this.searchKeyword, 'gi'); + return name.replace(regex, match => `<span style="color: #2D7CE6 ;">${match}</span>`); + } + return name; + }, + getallstu(){ + this.$u.get(`https://api.admin-v2.langsi.online/admin-api/v2/ybs-user/page`).then(res => { + + + if (res.code == 0) { + this.stulist=res.data.list + this.orgstulist = JSON.parse(JSON.stringify(res.data.list)); + this.selectedIds.forEach(selectedItem => { + const index = this.stulist.findIndex(item => item.id === selectedItem.id); + if (index !== -1) { + this.$set(this.stulist, index, { ...this.stulist[index], isSelected: true }); + } + }); + + } + }) + } + } + } +</script> + +<style lang="scss"> + page { + background: linear-gradient(183deg, #F0F6FF 0%, #FAFAFA 100%); + } + + .searchpage { + width: 750rpx; + padding: 0 32rpx; + + .serchbox { + padding: 0 32rpx; + display: flex; + flex-wrap: nowrap; + margin-top: 30rpx; + align-items: center; + width: 686rpx; + height: 88rpx; + background: #FFFFFF; + border-radius: 20rpx 20rpx 20rpx 20rpx; + + .serchimg { + width: 30.51rpx; + height: 32rpx; + margin-right: 24rpx; + } + + .input { + margin: 0 auto; + width: 568rpx; + height: 88rpx; + border-radius: 30rpx; + // background-color: #f5f8fc; + // display: flex; + // justify-content: center; + // align-items: center; + // text-align: center; + font-size: 28rpx; + font-family: Source Han Sans CN, Source Han Sans CN-Light; + font-weight: 300; + text-align: left; + color: #a7b9cd; + letter-spacing: 1.2rpx; + line-height: 36rpx; + // padding: 0 100rpx; + // padding-right: 135rpx; + box-sizing: border-box; + + } + } + + .check_card { + margin-top: 20rpx; + + .check_card_stu { + display: flex; + flex-wrap: nowrap; + align-items: center; + justify-content: space-between; + padding: 32rpx; + width: 686rpx; + height: 148rpx; + background: #FFFFFF; + border-radius: 20rpx 20rpx 20rpx 20rpx; + border: 2rpx solid #FFFFFF; + margin-bottom: 20rpx; + + .check_card_stu_info_left { + display: flex; + flex-wrap: nowrap; + + .class_card_left { + width: 76rpx; + height: 76rpx; + } + + .class_card_right { + margin-left: 12rpx; + display: flex; + flex-wrap: wrap; + + .class_card_right_top { + width: 100%; + font-size: 28rpx; + font-family: 'PingFang', 'PingFang'; + font-weight: bold; + color: #072F5A; + } + + .class_card_right_bot { + margin-top: 4rpx; + font-size: 20rpx; + font-family: 'PingFang', 'PingFang'; + font-weight: 500; + color: rgba(7, 47, 90, 0.6); + } + } + } + + .check_card_stu_info_right { + width: 50%; + display: flex; + flex-wrap: nowrap; + align-items: center; + justify-content: space-between; + + .class_info { + width: 110rpx; + display: flex; + flex-wrap: wrap; + justify-content: center; + + .class_info_top { + font-size: 20rpx; + font-family: 'PingFang', 'PingFang'; + font-weight: 500; + color: rgba(7, 47, 90, 0.5); + } + + .class_info_bot { + margin-top: 12rpx; + font-size: 28rpx; + font-family: 'PingFang', 'PingFang'; + font-weight: 800; + color: #2D7CE6; + } + } + } + } + + + .act1 { + border: 2rpx solid #2D7CE6; + } + } + .botbtn{ + padding: 32rpx 32rpx 0 32rpx; + margin-left: -32rpx; + position: fixed; + bottom: 0; + width: 750rpx; + height: 200rpx; + background: #FFFFFF; + box-shadow: 0rpx -10rpx 16rpx 0rpx rgba(202,202,202,0.25); + border-radius: 40rpx 40rpx 0rpx 0rpx; + .btn{ + display: flex; + align-items: center; + justify-content: center; + font-size: 28rpx; + font-family:'PingFang','PingFang'; + font-weight: 800; + color: #FFFFFF; + width: 686rpx; + height: 80rpx; + background: linear-gradient(180deg, #74AFFF 0%, #2D7CE6 100%); + border-radius: 104rpx 104rpx 104rpx 104rpx; + } + } + } +</style> \ 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 @@ <template> <view class="view_body"> - <u-navbar :is-back="true" title='班级详情' title-color="#000" :border-bottom="false" :background="true" id="navbar"> + <u-navbar :is-back="true" title='班级详情' title-color="#2E4975" :border-bottom="false" :background="true" id="navbar"> </u-navbar> <view class="view_botton" v-if="loading==false"> <view class="view_spoken"> @@ -98,7 +98,9 @@ return { isShow: true, - + bgc: { + backgroundColor: "#F6F9FC", + }, operation:[ { image:'https://file.langsi.online/yasiimg/web/static/ukPnTLkhCKU5zhbM7SMu', @@ -129,7 +131,7 @@ } }, onLoad(option) { - // this.classid=option.id + /* > */ // this.classid=option.id this.classid=15 }, @@ -139,8 +141,16 @@ }, methods:{ toaddwork(){ + let classinofs=[ + { + name:this.classinfo.name, + avatar:this.classinfo.avatar, + id:this.classinfo.id, + + } + ] uni.navigateTo({ - url: "/pages_teacher/teacher_teachers/teacher_addOperation?id=" + this.classinfo.id + url: "/pages_teacher/teacher_teachers/teacher_addOperation?classinfo=" + encodeURIComponent(JSON.stringify(classinofs)) }).then(res => { }).catch(err => { diff --git a/pages_teacher/teacher_teachers/teacher_addOperation.vue b/pages_teacher/teacher_teachers/teacher_addOperation.vue index eefbc23..0d42a84 100644 --- a/pages_teacher/teacher_teachers/teacher_addOperation.vue +++ b/pages_teacher/teacher_teachers/teacher_addOperation.vue @@ -1,13 +1,13 @@ <template> <view class="concent"> <view class="view_body"> - <u-navbar :is-back="true" title='添加作业' title-color="#000" :border-bottom="false" :background="true" id="navbar"> + <u-navbar :is-back="true" title='添加作业' title-color="#000" :border-bottom="false" :background="bgc" id="navbar"> </u-navbar> <view class="view_header"> <view class="view_title">标题</view> <view class="view_input"> <u-form-item prop="value"> - <u-input v-model="form.value" :type="type" :border="border" placeholder="输入作业标题" /> + <u-input v-model="worktit" :type="type" :border="border" placeholder="输入作业标题" /> </u-form-item> </view> </view> @@ -15,56 +15,30 @@ <view> <view class="view_tubiao"> <view class="view_title">班级安排</view> - <view class="view_tb"> - - <view class="view_add"> - <text>+</text> - 添加 - </view> + <view class="view_tb" @click="addclass()"> + + </view> </view> - - <view class="class_bj"> - <view class="class_images"> - <view class="class_ys"> - <view class="class_tp"> - <image src="https://file.langsi.online/yasiimg/web/static/u4T48EWFfk5p6yrV3gOw" mode=""></image> - </view> - <view class="class_wz">雅思1班</view> - </view> - <view class="class_ys"> - <view class="class_tp"> - <image src="https://file.langsi.online/yasiimg/web/static/u4T48EWFfk5p6yrV3gOw" mode=""></image> - </view> - <view class="class_wz">雅思1班</view> - </view> - <view class="class_ys"> - <view class="class_tp"> - <image src="https://file.langsi.online/yasiimg/web/static/u4T48EWFfk5p6yrV3gOw" mode=""></image> - </view> - <view class="class_wz">雅思1班</view> - </view> + <view class="noting" v-if="classinfo.length<=0"> + <image src="https://file.langsi.online/yasiimg/web/static/ulqScWZvBYd22CW5uV0H" ></image> + <view class="text1"> + 暂未安排哦! </view> - <!-- 2 --> - <view class="class_images"> - <view class="class_ys"> + <view class="text2" @click="addclass()"> + 去安排 + </view> + </view> + <view class="class_bj"> + + <view class="class_images" > + <view class="class_ys" v-for="(item,index) in classinfo" :key="index"> <view class="class_tp"> <image src="https://file.langsi.online/yasiimg/web/static/u4T48EWFfk5p6yrV3gOw" mode=""></image> </view> - <view class="class_wz">雅思1班</view> - </view> - <view class="class_ys"> - <view class="class_tp"> - <image src="https://file.langsi.online/yasiimg/web/static/u4T48EWFfk5p6yrV3gOw" mode=""></image> - </view> - <view class="class_wz">雅思1班</view> - </view> - <view class="class_ys"> - <view class="class_tp"> - <image src="https://file.langsi.online/yasiimg/web/static/u4T48EWFfk5p6yrV3gOw" mode=""></image> - </view> - <view class="class_wz">雅思1班</view> + <view class="class_wz">{{item.name}}</view> </view> + + </view> </view> </view> @@ -72,58 +46,33 @@ <view> <view class="view_tubiao"> <view class="view_title">学员安排</view> - <view class="view_tb"> + <view class="view_tb" @click="toaddstu()"> - <view class="view_add"> - <text>+</text> - 添加 - </view> + + </view> </view> - - <view class="class_bj"> - <view class="class_images"> - <view class="class_ys"> - <view class="class_tp"> - <image src="https://file.langsi.online/yasiimg/web/static/u4T48EWFfk5p6yrV3gOw" mode=""></image> - </view> - <view class="class_wz">LULY</view> - </view> - <view class="class_ys"> - <view class="class_tp"> - <image src="https://file.langsi.online/yasiimg/web/static/u4T48EWFfk5p6yrV3gOw" mode=""></image> - </view> - <view class="class_wz">Bright</view> - </view> - <view class="class_ys"> - <view class="class_tp"> - <image src="https://file.langsi.online/yasiimg/web/static/u4T48EWFfk5p6yrV3gOw" mode=""></image> - </view> - <view class="class_wz">Bright</view> - </view> + <view class="noting" v-if="stuinfo.length<=0"> + <image src="https://file.langsi.online/yasiimg/web/static/ulqScWZvBYd22CW5uV0H" ></image> + <view class="text1"> + 暂未安排哦! </view> - <!-- 2 --> - <view class="class_images"> - <view class="class_ys"> - <view class="class_tp"> - <image src="https://file.langsi.online/yasiimg/web/static/u4T48EWFfk5p6yrV3gOw" mode=""></image> - </view> - <view class="class_wz">LULY</view> - </view> - <view class="class_ys"> - <view class="class_tp"> - <image src="https://file.langsi.online/yasiimg/web/static/u4T48EWFfk5p6yrV3gOw" mode=""></image> - </view> - <view class="class_wz">Bright</view> - </view> - <view class="class_ys"> - <view class="class_tp"> - <image src="https://file.langsi.online/yasiimg/web/static/u4T48EWFfk5p6yrV3gOw" mode=""></image> - </view> - <view class="class_wz">Bright</view> - </view> + <view class="text2" @click="toaddstu()"> + 去安排 </view> </view> + <view class="class_bj" > + <view class="class_images"> + <view class="class_ys" v-for="(item,index) in stuinfo" :key="index"> + <view class="class_tp"> + <image :src="item.avatar" mode=""></image> + </view> + <view class="class_wz">{{item.name}}</view> + </view> + + </view> + + + </view> </view> <!-- 作业安排 --> <view> @@ -300,34 +249,96 @@ export default { data() { return { - // 表单双向数据绑定 - form: { - value: '', - times:'', - + bgc: { + backgroundColor: "#F6F9FC", }, // prick 时间选择框数据 params: { - year: true, - month: true, - day: true, - hour: false, - minute: false, - second: false - }, - show: false, + year: true, + month: true, + day: true, + hour: true, + minute: false, + second: false + }, + show: false, radio: '', switchVal: false, + classinfo:[], + stuinfo:[], + worktit:'', + times:'', + } }, + onLoad(option) { + uni.removeStorageSync('selectedClassInfo'); + uni.removeStorageSync('selectedStuInfo'); + // this.classinfo=JSON.parse(decodeURIComponent(option.classinfo)) + let classinofs=[ + { + name:'阅读5班', + avatar:'Excepteur', + id:15, + + } + ] + this.classinfo=classinofs + + }, + onShow() { + // Read selectedClassInfo data + const selectedClassInfo = uni.getStorageSync('selectedClassInfo'); + console.log(selectedClassInfo,'selectedClassInfoselectedClassInfo'); + if (selectedClassInfo && selectedClassInfo.length > 0) { + this.classinfo=selectedClassInfo + // Remove duplicates from this.classinfo + // this.classinfo = this.classinfo.filter(item => !selectedClassInfo.some(selectedItem => selectedItem.id === item.id)); + + // // Add non-duplicate items from selectedClassInfo to this.classinfo + // this.classinfo = this.classinfo.concat(selectedClassInfo); + + } + const selectedstuInfo = uni.getStorageSync('selectedStuInfo'); + + if (selectedstuInfo && selectedstuInfo.length > 0) { + this.stuinfo=selectedstuInfo + // Remove duplicates from this.classinfo + // this.stuinfo = this.stuinfo.filter(item => !selectedstuInfo.some(selectedItem => selectedItem.id === item.id)); + + // // Add non-duplicate items from selectedClassInfo to this.classinfo + // this.stuinfo = this.stuinfo.concat(selectedstuInfo); + + } + }, methods:{ + toaddstu(){ + uni.navigateTo({ + url: "/pages_teacher/pages_add/add_studentsforwork?stuinfo=" + encodeURIComponent(JSON.stringify(this.stuinfo)) + + }).then(res => { + + }).catch(err => { + + }); + }, + addclass(){ + uni.navigateTo({ + url: "/pages/Mystudent/addclassforwork?classinfo=" + encodeURIComponent(JSON.stringify(this.classinfo)) + }).then(res => { + + }).catch(err => { + + }); + }, + // 获取截止时间 printValue(e){ - this.form.times=`${e.year}-${e.month}-${e.day}` + this.times=`${e.year}-${e.month}-${e.day}` }, submit() { - } + } } } </script> @@ -366,16 +377,61 @@ justify-content: space-between; align-items: center; margin-top: 46rpx; + .view_tb{ + display: flex; + padding-left: 24rpx; + // align-items: center; + // padding: 11rpx 24rpx 11rpx 24rpx; + width: 120rpx; + height: 52rpx; + background: #FFFFFF; + border-radius: 26rpx 26rpx 26rpx 26rpx; + + border: 2rpx solid #F1F1F1; + + color: #F18F21 ; + font-size: 30rpx; + } + } + .noting{ + display: flex; + flex-wrap: nowrap; + align-items: center; + justify-content: center; + margin-top: 16rpx; + width: 686rpx; + height: 124rpx; + background: #FFFFFF; + border-radius: 20rpx 20rpx 20rpx 20rpx; + image{ + width: 58.19rpx; + height: 60rpx; + } + .text1{ + margin-left: 12rpx; + font-size: 24rpx; + font-family: PingFang SC, PingFang SC; + font-weight: 500; + color: #627698; + } + .text2{ + margin-left: 12rpx; + font-size: 24rpx; + font-family: PingFang SC, PingFang SC; + font-weight: 500; + color: #2D7CE6; + border-bottom: 2px solid #2D7CE6; + } } - .class_bj { margin-top: 16rpx; } .class_images { display: flex; - justify-content: space-between; - margin-top: 20rpx; + flex-wrap: wrap; + // justify-content: space-between; + // margin-top: 20rpx; } .class_tp { @@ -389,8 +445,12 @@ color: #2E4975; margin: 20rpx 0; } - + .class_ys:nth-child(3n) { + margin-right: 0; + } .class_ys { + margin-top: 20rpx; + margin-right: 20rpx; width: 215rpx; height: 96rpx; display: flex; @@ -402,18 +462,23 @@ background: #FFFFFF; border-radius: 20rpx 20rpx 20rpx 20rpx; } + .class_wz { - font-size: 28rpx; - font-family: 'PingFang'; - font-weight: 500; - color: #072F5A; + width: 125rpx; + font-size: 28rpx; + font-family: 'PingFang'; + font-weight: 500; + color: #072F5A; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; } .view_form{ padding: 0rpx 32rpx; background: #FFFFFF; margin-top: 16rpx; -border-radius: 20rpx 20rpx 20rpx 20rpx; + border-radius: 20rpx 20rpx 20rpx 20rpx; } .view_textrea{ height: 260rpx; @@ -432,10 +497,10 @@ border-radius: 20rpx 20rpx 20rpx 20rpx; color: #FFFFFF; } .view_footer{ - width: 100%; + width: 100%; padding: 0 16rpx; height: 144rpx; - border-radius: 40rpx 40rpx 0rpx 0rpx; + border-radius: 40rpx 40rpx 0rpx 0rpx; padding: 32rpx 0rpx; background-color: #fff; box-shadow: 0rpx -10rpx 16rpx 0rpx rgba(202,202,202,0.25); From 317c54a1cf4c48dc6f6cc8c46ad0cd2fd8eff1bb Mon Sep 17 00:00:00 2001 From: taoxu <2622874537@qq.com> Date: Thu, 7 Dec 2023 22:13:54 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/Mystudent/addclassforwork.vue | 12 +++++++++ pages/upload/upload.vue | 27 ++++++++++++++----- .../pages_add/add_studentsforwork.vue | 12 +++++++++ .../teacher_teachers/teacher_addOperation.vue | 16 +++++++++-- 4 files changed, 59 insertions(+), 8 deletions(-) diff --git a/pages/Mystudent/addclassforwork.vue b/pages/Mystudent/addclassforwork.vue index f277030..50e8a14 100644 --- a/pages/Mystudent/addclassforwork.vue +++ b/pages/Mystudent/addclassforwork.vue @@ -106,6 +106,12 @@ export default { const filteredList = JSON.parse(JSON.stringify(this.changeclasslist)).filter(item => item.name.includes(this.searchKeyword)); // 更新 this.classlist 为过滤后的列表 this.classlist = filteredList; + 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 }); + } + }); }else{ this.fuwei() } @@ -122,6 +128,12 @@ export default { fuwei() { this.classlist = JSON.parse(JSON.stringify(this.changeclasslist)); + 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 }); + } + }); }, getclassList() { this.$u.get("https://api.admin-v2.langsi.online/admin-api/classroom/page").then(res => { diff --git a/pages/upload/upload.vue b/pages/upload/upload.vue index 9a7caf4..040281b 100644 --- a/pages/upload/upload.vue +++ b/pages/upload/upload.vue @@ -57,12 +57,27 @@ }, // 获取上传七牛云token getQiniuToken() { - this.$u.get('https://v2.ielts.langsi.online/file/getToken').then(res => { - console.log(res.data); - this.token = res.data.token - }).catch(err => { - console.log(err) - }) + wx.request({ + url: 'https://v2.ielts.langsi.online/file/getToken', + method: 'get', // Adjust the request method as needed + // data: yourData, + header: { + 'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJub3RfeWJzX3VzZXJfa2V5IjoiNWZiYzA4YmUtNDZlMi00NDUzLThmYjQtMjFlNzhjZDIxY2EyIn0.jw2fyMnlNEW-zx8cH6aPh_H-WqEAHDQdh4oCpYg3qBIJZEmw6L4oNWJPvKHM9edmRdLO0p2z7_vlCYoY00NqxA ' + }, + success: (res) => { + console.log(res); + this.token = res.data.data.token + }, + fail: (err) => { + console.log(err); + } + }); + // this.$u.get('https://v2.ielts.langsi.online/file/getToken').then(res => { + // console.log(res.data); + // this.token = res.data.token + // }).catch(err => { + // console.log(err) + // }) }, } diff --git a/pages_teacher/pages_add/add_studentsforwork.vue b/pages_teacher/pages_add/add_studentsforwork.vue index 59e3b63..6ced2bc 100644 --- a/pages_teacher/pages_add/add_studentsforwork.vue +++ b/pages_teacher/pages_add/add_studentsforwork.vue @@ -111,6 +111,12 @@ }); // 更新 this.classlist 为过滤后的列表 this.stulist = filteredList; + this.selectedIds.forEach(selectedItem => { + const index = this.stulist.findIndex(item => item.id === selectedItem.id); + if (index !== -1) { + this.$set(this.stulist, index, { ...this.stulist[index], isSelected: true }); + } + }); } else { this.fuwei(); } @@ -118,6 +124,12 @@ fuwei() { this.stulist = JSON.parse(JSON.stringify(this.orgstulist)); + this.selectedIds.forEach(selectedItem => { + const index = this.stulist.findIndex(item => item.id === selectedItem.id); + if (index !== -1) { + this.$set(this.stulist, index, { ...this.stulist[index], isSelected: true }); + } + }); }, highlightSearch(name) { // 使用正则表达式替换匹配到的 searchKeyword 为带有颜色的文字 diff --git a/pages_teacher/teacher_teachers/teacher_addOperation.vue b/pages_teacher/teacher_teachers/teacher_addOperation.vue index 0d42a84..69e9398 100644 --- a/pages_teacher/teacher_teachers/teacher_addOperation.vue +++ b/pages_teacher/teacher_teachers/teacher_addOperation.vue @@ -31,7 +31,10 @@ <view class="class_bj"> <view class="class_images" > - <view class="class_ys" v-for="(item,index) in classinfo" :key="index"> + <view class="class_ys" v-for="(item,index) in classinfo" :key="index" style="position: relative;"> + <view class="close" style="position: absolute;top: 0rpx;right: 8rpx;width: 20rpx;height: 20rpx;" @click="delcls(item.id)"> + <image src="https://file.langsi.online/yasiimg/web/static/ueH3qwYazyVXmiYoVPJE" mode=""></image> + </view> <view class="class_tp"> <image src="https://file.langsi.online/yasiimg/web/static/u4T48EWFfk5p6yrV3gOw" mode=""></image> </view> @@ -62,7 +65,10 @@ </view> <view class="class_bj" > <view class="class_images"> - <view class="class_ys" v-for="(item,index) in stuinfo" :key="index"> + <view class="class_ys" v-for="(item,index) in stuinfo" :key="index" style="position: relative;"> + <view class="close" style="position: absolute;top: 0rpx;right: 8rpx;width: 20rpx;height: 20rpx;" @click="delstu(item.id)"> + <image src="https://file.langsi.online/yasiimg/web/static/ueH3qwYazyVXmiYoVPJE" mode=""></image> + </view> <view class="class_tp"> <image :src="item.avatar" mode=""></image> </view> @@ -312,6 +318,12 @@ } }, methods:{ + delcls(id){ + this.classinfo = this.classinfo.filter(item => item.id !== id); + }, + delstu(id){ + this.stuinfo = this.stuinfo.filter(item => item.id !== id); + }, toaddstu(){ uni.navigateTo({ url: "/pages_teacher/pages_add/add_studentsforwork?stuinfo=" + encodeURIComponent(JSON.stringify(this.stuinfo)) From f805ef513e0dfa59d08f82924822f3ff2f084a2c Mon Sep 17 00:00:00 2001 From: taoxu <2622874537@qq.com> Date: Fri, 8 Dec 2023 22:57:06 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E6=B8=B2=E6=9F=93=20=E9=A1=B5=E9=9D=A2=20?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86=20=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/Mystudent/addclassforwork.vue | 2 +- .../pages_add/add_studentsforwork.vue | 3 +- .../teacher_teachers/components/compose.vue | 279 +-- .../teacher_teachers/teacher_addOperation.vue | 1089 ++++++----- .../teacher_teachers/teacher_writeadd.vue | 1595 +++++++++++------ 5 files changed, 1875 insertions(+), 1093 deletions(-) diff --git a/pages/Mystudent/addclassforwork.vue b/pages/Mystudent/addclassforwork.vue index 50e8a14..24c840f 100644 --- a/pages/Mystudent/addclassforwork.vue +++ b/pages/Mystudent/addclassforwork.vue @@ -5,7 +5,7 @@ :background="bgc" title-color='#2E4975' title-size='36' - height='36'></u-navbar> + height='36' :custom-back="addclassinfo"></u-navbar> <view class="serchbox"> <view class="serchimg"> <image src="https://file.langsi.online/yasiimg/web/static/uVMACkynkipOxuTYDqm0"> diff --git a/pages_teacher/pages_add/add_studentsforwork.vue b/pages_teacher/pages_add/add_studentsforwork.vue index 6ced2bc..43e338f 100644 --- a/pages_teacher/pages_add/add_studentsforwork.vue +++ b/pages_teacher/pages_add/add_studentsforwork.vue @@ -1,7 +1,7 @@ <template> <view class="searchpage"> <u-navbar title="添加学生" :border-bottom="false" :background="bgc" title-color='#2E4975' title-size='36' - height='36'></u-navbar> + height='36' :custom-back="addstu"></u-navbar> <u-toast ref="uToast" /> <view class="serchbox"> <view class="serchimg"> @@ -71,6 +71,7 @@ }, methods: { addstu() { + console.log('调用了'); uni.setStorageSync('selectedStuInfo', this.selectedIds); // Navigate back to the previous page diff --git a/pages_teacher/teacher_teachers/components/compose.vue b/pages_teacher/teacher_teachers/components/compose.vue index 4e33ba1..0bcbe65 100644 --- a/pages_teacher/teacher_teachers/components/compose.vue +++ b/pages_teacher/teacher_teachers/components/compose.vue @@ -1,153 +1,210 @@ <template> <!-- 外层循环 --> <view> - <view v-for="(item,index) in transformedData" :key="index"> + <view v-for="(item, index) in transformedData" + :key="index"> <!-- 剑18循环 --> <view> <view class="view_bages"> - <view>{{item.examName}}</view> + <view>{{ item.examName }}</view> </view> </view> <!-- 渲染Text --> <view class="substance"> - <text v-for="text in textArr" :key="text" @click="textClick(item,text)" :class="{active: item.active == text}">{{text}}</text> + <text v-for="text in textArr" + :key="text" + @click="textClick(item, text)" + :class="{ active: item.active == text }">{{ text }}</text> </view> <!-- 内容 --> <view class="compose_bodys"> - <view v-for="text in textArr" :key="text" class="zz"> - <view class="compose_body" v-for="Task in taskArr" :key="Task" v-if="item.active == text"> + <view v-for="text in textArr" + :key="text" + class="zz"> + <view class="compose_body" + v-for="Task in taskArr" + :key="Task" + v-if="item.active == text"> <view class="compose_left"> - <view>{{Task}}</view> + <view>{{ Task }}</view> <view> - <text class="fickle">{{item[text][Task].caption}}</text> - <text class="fickle2">{{item[text][Task].themeCaption}}</text> + <text class="fickle">{{ item[text][Task].caption }}</text> + <text class="fickle2">{{ item[text][Task].themeCaption }}</text> </view> </view> <view> - <u-checkbox @change="checkboxChange(item[text][Task].id,$event)" v-model="item[text][Task].subsetArr">{{item.name}}</u-checkbox> + <u-checkbox @change="checkboxChange(item, text, Task, $event)" + v-model="item[text][Task].subsetArr">{{ item.name }}</u-checkbox> </view> </view> </view> </view> </view> </view> - </template> <script> - export default { - data() { - return { - transformedData: [], - // 复选框 - subsetArr:[], - textArr:['test1','test2','test3','test4'], - taskArr:['task1','task2'], - // 接口参数 - comsapi: { - "key": "", - "mode": "home", - "exam": "", - "caption": "0", - "themeCaption": "", - "type": "", - "isStudy": 0, - "isEval": 0 - }, +export default { + data() { + return { + transformedData: [], + // 复选框 + subsetArr: [], + textArr: ['test1', 'test2', 'test3', 'test4'], + taskArr: ['task1', 'task2'], + // 接口参数 + comsapi: { + "key": "", + "mode": "home", + "exam": "", + "caption": "0", + "themeCaption": "", + "type": "", + "isStudy": 0, + "isEval": 0 + }, + orgtransformedData: [], + selectwrite: [], + } + }, + created() { + this.getCompose() + }, + methods: { + //写作接口 + getCompose() { + this.$u.post('https://api.admin-v2.langsi.online/admin-api/writing/all/search', this.comsapi).then(res => { + let arr = res.data + for (let a of arr) { + a.active = 'test1' + } + this.transformedData = arr + this.orgtransformedData = JSON.parse(JSON.stringify(arr)); + // let json = JSON.stringify(this.transformedData) + console.log(this.transformedData, 'this.transformedData'); + }) + }, + textClick(item, text) { + item.active = text + this.$forceUpdate() + }, + checkboxChange(item, text, Task, event) { + const examName = item.examName; + const test = text; // text 就是 test 字段的内容 + const taskId = Task; // Task 就是 task 字段的内容 + const id = String(item[test][taskId].id); + + // 构建对象 + const newObject = { + examName: examName, + test: test, + task: taskId, + id: id, + }; + + // 查找数组中是否已存在相应的对象 + const existingObjectIndex = this.findIndexByFields(this.selectwrite, newObject); + + if (existingObjectIndex === -1) { + // 如果不存在,添加到数组 + this.selectwrite.push(newObject); + } else { + // 如果存在,根据索引删除对象 + this.selectwrite.splice(existingObjectIndex, 1); } + + this.$parent.updatawrite(this.selectwrite) + // 更新其他状态... }, - created() { - this.getCompose() - }, - methods: { - //写作接口 - getCompose() { - this.$u.post('https://api.admin-v2.langsi.online/admin-api/writing/all/search', this.comsapi).then(res => { - let arr = res.data - for(let a of arr) { - a.active = 'test1' - } - this.transformedData =arr - }) - }, - textClick(item, text) { - item.active = text - this.$forceUpdate() - }, - checkboxChange(e,id){ - if(id.value) { - this.subsetArr.push(e) - }else { - let index=this.subsetArr.indexOf(e); - if(e!==-1) { - this.subsetArr.splice(index, 1); + findIndexByFields(array, fields) { + // 根据指定字段值查找对象在数组中的索引 + for (let i = 0; i < array.length; i++) { + let isEqual = true; + for (const key in fields) { + if (fields[key] !== array[i][key]) { + isEqual = false; + break; } } - console.log(this.subsetArr) + if (isEqual) { + return i; + } } - } + return -1; + }, } +} </script> <style lang="scss" scoped> - .view_bages { - font-size: 40rpx; - font-weight: 400; - color: #2E4975; - } - .substance { - margin: 20rpx 0; - text { - padding: 10rpx 30rpx; - margin-right: 20rpx; - background: #FFFFFF; - border-radius: 12rpx 12rpx 12rpx 12rpx; - } - } -.compose_bodys{ - margin: 30rpx 0; +.view_bages { + font-size: 40rpx; + font-weight: 400; + color: #2E4975; } - .compose_body { - display: flex; + +.substance { + margin: 20rpx 0; + + text { + padding: 10rpx 30rpx; + margin-right: 20rpx; background: #FFFFFF; - align-items: center; - justify-content: space-between; - margin: 0rpx 20rpx; - border-bottom: 2rpx solid #F2F2F2; - } - .compose_body:last-child { - border: none; - } - .zz{ - background: #ffff; border-radius: 12rpx 12rpx 12rpx 12rpx; } - .compose_left { - display: flex; - padding: 24rpx 0; - margin: 0 24rpx; - } - .fickle { - padding: 4rpx 22rpx; - font-size: 20rpx; - font-weight: 500; - color: #2D7CE6; - margin-left: 12rpx; - background: #E1EEFF; - border-radius: 8rpx 8rpx 8rpx 8rpx; - } - .fickle2 { - padding: 4rpx 32rpx; - font-size: 20rpx; - font-weight: 500; - color: #FB9734; - margin-left: 12rpx; - background: #FFEBD7; - border-radius: 8rpx 8rpx 8rpx 8rpx; - } - .active { - color: #fff; - background: #007AFF !important; - } +} + +.compose_bodys { + margin: 30rpx 0; +} + +.compose_body { + display: flex; + background: #FFFFFF; + align-items: center; + justify-content: space-between; + margin: 0rpx 20rpx; + border-bottom: 2rpx solid #F2F2F2; +} + +.compose_body:last-child { + border: none; +} + +.zz { + background: #ffff; + border-radius: 12rpx 12rpx 12rpx 12rpx; +} + +.compose_left { + display: flex; + padding: 24rpx 0; + margin: 0 24rpx; +} + +.fickle { + padding: 4rpx 22rpx; + font-size: 20rpx; + font-weight: 500; + color: #2D7CE6; + margin-left: 12rpx; + background: #E1EEFF; + border-radius: 8rpx 8rpx 8rpx 8rpx; +} + +.fickle2 { + padding: 4rpx 32rpx; + font-size: 20rpx; + font-weight: 500; + color: #FB9734; + margin-left: 12rpx; + background: #FFEBD7; + border-radius: 8rpx 8rpx 8rpx 8rpx; +} + +.active { + color: #fff; + background: #007AFF !important; +} </style> diff --git a/pages_teacher/teacher_teachers/teacher_addOperation.vue b/pages_teacher/teacher_teachers/teacher_addOperation.vue index 69e9398..8ed530b 100644 --- a/pages_teacher/teacher_teachers/teacher_addOperation.vue +++ b/pages_teacher/teacher_teachers/teacher_addOperation.vue @@ -1,13 +1,21 @@ <template> <view class="concent"> <view class="view_body"> - <u-navbar :is-back="true" title='添加作业' title-color="#000" :border-bottom="false" :background="bgc" id="navbar"> + <u-navbar :is-back="true" + title='添加作业' + title-color="#000" + :border-bottom="false" + :background="bgc" + id="navbar"> </u-navbar> <view class="view_header"> <view class="view_title">标题</view> <view class="view_input"> <u-form-item prop="value"> - <u-input v-model="worktit" :type="type" :border="border" placeholder="输入作业标题" /> + <u-input v-model="worktit" + :type="type" + :border="border" + placeholder="输入作业标题" /> </u-form-item> </view> </view> @@ -15,33 +23,45 @@ <view> <view class="view_tubiao"> <view class="view_title">班级安排</view> - <view class="view_tb" @click="addclass()"> + <view class="view_tb" + @click="addclass()"> + </view> </view> - <view class="noting" v-if="classinfo.length<=0"> - <image src="https://file.langsi.online/yasiimg/web/static/ulqScWZvBYd22CW5uV0H" ></image> + <view class="noting" + v-if="classinfo.length <= 0"> + <image src="https://file.langsi.online/yasiimg/web/static/ulqScWZvBYd22CW5uV0H"></image> <view class="text1"> 暂未安排哦! </view> - <view class="text2" @click="addclass()"> + <view class="text2" + @click="addclass()"> 去安排 </view> </view> <view class="class_bj"> - - <view class="class_images" > - <view class="class_ys" v-for="(item,index) in classinfo" :key="index" style="position: relative;"> - <view class="close" style="position: absolute;top: 0rpx;right: 8rpx;width: 20rpx;height: 20rpx;" @click="delcls(item.id)"> - <image src="https://file.langsi.online/yasiimg/web/static/ueH3qwYazyVXmiYoVPJE" mode=""></image> + + <view class="class_images"> + <view class="class_ys" + v-for="(item, index) in classinfo" + :key="index" + style="position: relative;"> + <view class="close" + style="position: absolute;top: 0rpx;right: 8rpx;width: 20rpx;height: 20rpx;" + @click="delcls(item.id)"> + <image src="https://file.langsi.online/yasiimg/web/static/ueH3qwYazyVXmiYoVPJE" + mode=""> + </image> </view> <view class="class_tp"> - <image src="https://file.langsi.online/yasiimg/web/static/u4T48EWFfk5p6yrV3gOw" mode=""></image> + <image src="https://file.langsi.online/yasiimg/web/static/u4T48EWFfk5p6yrV3gOw" + mode=""> + </image> </view> - <view class="class_wz">{{item.name}}</view> + <view class="class_wz">{{ item.name }}</view> </view> - - + + </view> </view> </view> @@ -49,35 +69,46 @@ <view> <view class="view_tubiao"> <view class="view_title">学员安排</view> - <view class="view_tb" @click="toaddstu()"> + <view class="view_tb" + @click="toaddstu()"> + </view> </view> - <view class="noting" v-if="stuinfo.length<=0"> - <image src="https://file.langsi.online/yasiimg/web/static/ulqScWZvBYd22CW5uV0H" ></image> + <view class="noting" + v-if="stuinfo.length <= 0"> + <image src="https://file.langsi.online/yasiimg/web/static/ulqScWZvBYd22CW5uV0H"></image> <view class="text1"> 暂未安排哦! </view> - <view class="text2" @click="toaddstu()"> + <view class="text2" + @click="toaddstu()"> 去安排 </view> </view> - <view class="class_bj" > + <view class="class_bj"> <view class="class_images"> - <view class="class_ys" v-for="(item,index) in stuinfo" :key="index" style="position: relative;"> - <view class="close" style="position: absolute;top: 0rpx;right: 8rpx;width: 20rpx;height: 20rpx;" @click="delstu(item.id)"> - <image src="https://file.langsi.online/yasiimg/web/static/ueH3qwYazyVXmiYoVPJE" mode=""></image> + <view class="class_ys" + v-for="(item, index) in stuinfo" + :key="index" + style="position: relative;"> + <view class="close" + style="position: absolute;top: 0rpx;right: 8rpx;width: 20rpx;height: 20rpx;" + @click="delstu(item.id)"> + <image src="https://file.langsi.online/yasiimg/web/static/ueH3qwYazyVXmiYoVPJE" + mode=""> + </image> </view> <view class="class_tp"> - <image :src="item.avatar" mode=""></image> + <image :src="item.avatar" + mode=""></image> </view> - <view class="class_wz">{{item.name}}</view> + <view class="class_wz">{{ item.name }}</view> </view> - + </view> - - + + </view> </view> <!-- 作业安排 --> @@ -89,17 +120,18 @@ </view> <view> <view class="Ielts">IELTS 18</view> - <view style="background-color: #fff; padding: 32rpx 40rpx;"> + <view + style="background-color: #fff; padding: 32rpx 40rpx; border-radius: 20rpx 20rpx 20rpx 20rpx;"> <u-time-line> <u-time-line-item nodeTop="2"> <template v-slot:content> <view> <view style="display: flex;"> - + <view class="Test">Test 2</view> - + <view class="greener">听力</view> - + </view> <view class="u-order-desc"> <text>Part 1:多选题</text> @@ -107,114 +139,105 @@ </view> </template> </u-time-line-item> - <u-time-line-item nodeTop="2"> - <template v-slot:content> - <view> - <view style="display: flex;"> - - <view class="Test">Test 2</view> - - <view class="greener">听力</view> - + <u-time-line-item nodeTop="2"> + <template v-slot:content> + <view> + <view style="display: flex;"> + + <view class="Test">Test 2</view> + + <view class="greener">听力</view> + + </view> + <view class="u-order-desc"> + <text>Part 1:多选题</text> + </view> </view> - <view class="u-order-desc"> - <text>Part 1:多选题</text> + </template> + </u-time-line-item> + <u-time-line-item nodeTop="2"> + <template v-slot:content> + <view> + <view style="display: flex;"> + + <view class="Test">Test 2</view> + + <view class="greener">听力</view> + + </view> + <view class="u-order-desc"> + <text>Part 1:多选题</text> + </view> </view> - </view> - </template> - </u-time-line-item> - <u-time-line-item nodeTop="2"> - <template v-slot:content> - <view> - <view style="display: flex;"> - - <view class="Test">Test 2</view> - - <view class="greener">听力</view> - - </view> - <view class="u-order-desc"> - <text>Part 1:多选题</text> - </view> - </view> - </template> - </u-time-line-item> + </template> + </u-time-line-item> </u-time-line> </view> </view> </view> - <view> - <view class="Ielts">IELTS 18</view> - <view style="background-color: #fff; padding: 32rpx 40rpx;"> - <view style="display: flex; align-items: center;"> - <view class="yuandi"></view> - <view class="Test">Test 2</view> - <view class="ellipses">听力</view> - </view> - <view class="u-order-desc"> - <text>Part 1:多选题</text> - </view> + <view v-for="(item,index) in selectwritelist" :key="index"> + <view class="Ielts">{{item.examName}}</view> + <view style="background-color: #fff; padding: 32rpx 40rpx;border-radius: 20rpx 20rpx 20rpx 20rpx;" v-for="(items,indexs) in item.message" :key="indexs"> + <view style="display: flex; align-items: center;"> + <view class="yuandi"></view> + <view class="Test">{{items.test}}</view> + <view class="ellipses">写作</view> </view> + <view class="u-order-desc"> + <text>{{items.task}}</text> + </view> + </view> </view> <view> <view> - <view class="Ielts">IELTS 18</view> - <view style="background-color: #fff; padding: 32rpx 40rpx;"> + <view class="Ielts"></view> + <view + style="background-color: #fff; padding: 32rpx 40rpx;border-radius: 20rpx 20rpx 20rpx 20rpx;"> <u-time-line> - <u-time-line-item nodeTop="2"> + <u-time-line-item nodeTop="2" + v-for="(item, index) in selectspeak" + :key="index"> <template v-slot:content> <view> - <view style="display: flex;"> - - <view class="Test">Test 2</view> - - <view class="erotic">听力</view> - + <view style="display: flex;flex-wrap: nowrap;"> + + <view class="Test" + style="width: 80%;">{{ item.part }}-{{ item.introduction }}</view> + + <view class="erotic">口语</view> + </view> <view class="u-order-desc"> - <text>Part 1:多选题</text> + <view style="display: inline;"> + <view class="txt">{{ item.topicEn }}:</view> + <view v-for="(items, indexs) in item.speakingType" + :key="indexs" + class="type" + style="display: inline;"> + <view v-if="items == 1">串题</view> + <view v-else-if="items == 2">跟读</view> + <view v-else-if="items == 3">模考</view> + </view> + </view> </view> </view> </template> </u-time-line-item> - <u-time-line-item nodeTop="2"> - - <template v-slot:content> - - <view> - - <view style="display: flex;"> - - <view class="Test">Test 2</view> - - <view class="erotic">听力</view> - - </view> - - <view class="u-order-desc"> - - <text>Part 1:多选题</text> - - </view> - - </view> - - </template> - - </u-time-line-item> + </u-time-line> </view> </view> </view> - <!--按钮 --> - <view style="display: flex; justify-content: center; margin-top: 32rpx;"> - <view class="increase"> - <u-icon name="plus"></u-icon> - 添加 - </view> + <!--按钮 --> + <view style="display: flex; justify-content: center; margin-top: 32rpx;" + @click="addwork()"> + <view class="increase"> + <u-icon name="plus"></u-icon> + 添加 + </view> </view> </view> - + </view> <!-- 截止时间 --> <view> @@ -223,9 +246,17 @@ </view> <view> <view class="view_form"> - <u-picker mode="time" v-model="show" :params="params" @confirm="printValue"></u-picker> + <u-picker mode="time" + v-model="show" + :params="params" + @confirm="printValue"></u-picker> <u-form-item prop="times"> - <u-input v-model="form.times" :type="type" :border="border" placeholder="选择作业截止的时间" @click="show = true" placeholder-style="color: rgba(46,73,117,0.4);font-size: 24rpx;"/> + <u-input v-model="times" + :type="type" + :border="border" + placeholder="选择作业截止的时间" + @click="show = true" + placeholder-style="color: rgba(46,73,117,0.4);font-size: 24rpx;" /> </u-form-item> @@ -238,353 +269,515 @@ <view class="view_title">描述</view> </view> <view class="view_textrea"> - <textarea value="" placeholder="输入你的描述... "placeholder-style="color: rgba(46,73,117,0.4);font-size: 24rpx;"/> - </view> - </view> - </view> - -<!-- 按钮 --> - <view class="view_footer" @click="submit"> - <view class="view_button" >确认添加 </view> - + <textarea value="" + placeholder="输入你的描述... " + placeholder-style="color: rgba(46,73,117,0.4);font-size: 24rpx;" /> + </view> </view> + </view> + + <!-- 按钮 --> + <view class="zhanwei" + style="width: 100%;height: 230rpx;"> + + </view> + <view class="botbtn"> + <view class="btn" + @click="addclassinfo()"> + 确定添加 + </view> + </view> </view> </template> <script> - export default { - data() { - return { - bgc: { - backgroundColor: "#F6F9FC", - }, - // prick 时间选择框数据 - params: { - year: true, - month: true, - day: true, - hour: true, - minute: false, - second: false - }, - show: false, - radio: '', - switchVal: false, - classinfo:[], - stuinfo:[], - worktit:'', - times:'', - - } - }, - onLoad(option) { - uni.removeStorageSync('selectedClassInfo'); - uni.removeStorageSync('selectedStuInfo'); - // this.classinfo=JSON.parse(decodeURIComponent(option.classinfo)) - let classinofs=[ - { - name:'阅读5班', - avatar:'Excepteur', - id:15, - +export default { + data() { + return { + bgc: { + backgroundColor: "#F6F9FC", + }, + // prick 时间选择框数据 + params: { + year: true, + month: true, + day: true, + hour: true, + minute: false, + second: false + }, + show: false, + radio: '', + switchVal: false, + classinfo: [], + stuinfo: [], + worktit: '', + times: '', + selectspeak: [], + selectwrite: [], + selectlisten: [], + selectread: [], + selectwritelist: [] + + } + }, + onLoad(option) { + uni.removeStorageSync('selectedClassInfo'); + uni.removeStorageSync('selectedStuInfo'); + // this.classinfo=JSON.parse(decodeURIComponent(option.classinfo)) + let classinofs = [{ + name: '阅读5班', + avatar: 'Excepteur', + id: 15, + + }] + this.classinfo = classinofs + + }, + onShow() { + // Read selectedClassInfo data + const selectedClassInfo = uni.getStorageSync('selectedClassInfo'); + + if (selectedClassInfo && selectedClassInfo.length > 0) { + this.classinfo = selectedClassInfo + // Remove duplicates from this.classinfo + // this.classinfo = this.classinfo.filter(item => !selectedClassInfo.some(selectedItem => selectedItem.id === item.id)); + + // // Add non-duplicate items from selectedClassInfo to this.classinfo + // this.classinfo = this.classinfo.concat(selectedClassInfo); + + } + const selectedstuInfo = uni.getStorageSync('selectedStuInfo'); + + if (selectedstuInfo && selectedstuInfo.length > 0) { + this.stuinfo = selectedstuInfo + // Remove duplicates from this.classinfo + // this.stuinfo = this.stuinfo.filter(item => !selectedstuInfo.some(selectedItem => selectedItem.id === item.id)); + + // // Add non-duplicate items from selectedClassInfo to this.classinfo + // this.stuinfo = this.stuinfo.concat(selectedstuInfo); + + } + const selectforwork = uni.getStorageSync('selectforwork'); + console.log(selectforwork, 'selectedClassInfoselectedClassInfo'); + if (selectforwork) { + this.selectspeak = selectforwork.selectspeak + this.selectwrite = selectforwork.selectwrite + this.selectlisten = selectforwork.selectlisten + this.selectread = selectforwork.selectread + this.selectwrite = selectforwork.selectwrite; + + const groupedItems = {}; + + this.selectwrite.forEach(item => { + const examName = item.examName; + + if (!groupedItems[examName]) { + groupedItems[examName] = { + examName: examName, + message: [] + }; } - ] - this.classinfo=classinofs - - }, - onShow() { - // Read selectedClassInfo data - const selectedClassInfo = uni.getStorageSync('selectedClassInfo'); - console.log(selectedClassInfo,'selectedClassInfoselectedClassInfo'); - if (selectedClassInfo && selectedClassInfo.length > 0) { - this.classinfo=selectedClassInfo - // Remove duplicates from this.classinfo - // this.classinfo = this.classinfo.filter(item => !selectedClassInfo.some(selectedItem => selectedItem.id === item.id)); - - // // Add non-duplicate items from selectedClassInfo to this.classinfo - // this.classinfo = this.classinfo.concat(selectedClassInfo); - - } - const selectedstuInfo = uni.getStorageSync('selectedStuInfo'); - - if (selectedstuInfo && selectedstuInfo.length > 0) { - this.stuinfo=selectedstuInfo - // Remove duplicates from this.classinfo - // this.stuinfo = this.stuinfo.filter(item => !selectedstuInfo.some(selectedItem => selectedItem.id === item.id)); - - // // Add non-duplicate items from selectedClassInfo to this.classinfo - // this.stuinfo = this.stuinfo.concat(selectedstuInfo); - - } - }, - methods:{ - delcls(id){ - this.classinfo = this.classinfo.filter(item => item.id !== id); - }, - delstu(id){ - this.stuinfo = this.stuinfo.filter(item => item.id !== id); - }, - toaddstu(){ - uni.navigateTo({ - url: "/pages_teacher/pages_add/add_studentsforwork?stuinfo=" + encodeURIComponent(JSON.stringify(this.stuinfo)) - - }).then(res => { - - }).catch(err => { - + + groupedItems[examName].message.push({ + test: item.test, + task: item.task, + id: item.id }); - }, - addclass(){ - uni.navigateTo({ - url: "/pages/Mystudent/addclassforwork?classinfo=" + encodeURIComponent(JSON.stringify(this.classinfo)) - }).then(res => { - - }).catch(err => { - - }); - }, - - // 获取截止时间 - printValue(e){ - this.times=`${e.year}-${e.month}-${e.day}` - }, - submit() { - - } + }); + + // Convert groupedItems object to an array + this.selectwritelist = Object.values(groupedItems); + + console.log(this.selectwritelist, 'selectwritelist'); + // Remove duplicates from this.classinfo + // this.stuinfo = this.stuinfo.filter(item => !selectedstuInfo.some(selectedItem => selectedItem.id === item.id)); + + // // Add non-duplicate items from selectedClassInfo to this.classinfo + // this.stuinfo = this.stuinfo.concat(selectedstuInfo); + + } + + }, + methods: { + mergeObjectsByExamName(existingArray, newArray) { + const mergedArray = []; + + newArray.forEach(newObj => { + const existingObjIndex = existingArray.findIndex(existingObj => existingObj.examName === newObj.examName); + + if (existingObjIndex !== -1) { + // 如果存在相同的 examName,则合并对象 + const existingObj = existingArray[existingObjIndex]; + existingObj.message.push({ + test: newObj.test, + task: newObj.task, + id: newObj.id, + // 其他属性... + }); + + // 更新数组中的对象 + existingArray[existingObjIndex] = existingObj; + } else { + // 如果不存在相同的 examName,则直接添加新对象 + mergedArray.push({ + examName: newObj.examName, + message: [{ + test: newObj.test, + task: newObj.task, + id: newObj.id, + // 其他属性... + }], + // 其他属性... + }); + } + }); + + // 添加 existingArray 中未处理的对象 + existingArray.forEach(existingObj => { + const existingObjIndex = mergedArray.findIndex(obj => obj.examName === existingObj.examName); + if (existingObjIndex === -1) { + mergedArray.push(existingObj); + } + }); + + return mergedArray; + }, + addwork() { + uni.navigateTo({ + url: "/pages_teacher/teacher_teachers/teacher_writeadd?classinfo=" + encodeURIComponent(JSON.stringify(this.classinfo)) + }).then(res => { + + }).catch(err => { + + }); + }, + delcls(id) { + this.classinfo = this.classinfo.filter(item => item.id !== id); + }, + delstu(id) { + this.stuinfo = this.stuinfo.filter(item => item.id !== id); + }, + toaddstu() { + uni.navigateTo({ + url: "/pages_teacher/pages_add/add_studentsforwork?stuinfo=" + encodeURIComponent(JSON.stringify(this.stuinfo)) + + }).then(res => { + + }).catch(err => { + + }); + }, + addclass() { + uni.navigateTo({ + url: "/pages/Mystudent/addclassforwork?classinfo=" + encodeURIComponent(JSON.stringify(this + .classinfo)) + }).then(res => { + + }).catch(err => { + + }); + }, + + // 获取截止时间 + printValue(e) { + this.times = `${e.year}-${e.month}-${e.day}` + }, + submit() { + } } +} </script> <style lang="scss" scoped> - // 样式穿透 - ::v-deep .u-dot { - background: #2D7CE6 !important; - } - .concent { - width: 100vw; - background: linear-gradient(183deg, #F0F6FF 0%, #FAFAFA 100%); - } +.botbtn { + padding: 32rpx 32rpx 0 32rpx; + // margin-left: -32rpx; + position: fixed; + bottom: 0; + width: 750rpx; + height: 200rpx; + background: #FFFFFF; + box-shadow: 0rpx -10rpx 16rpx 0rpx rgba(202, 202, 202, 0.25); + border-radius: 40rpx 40rpx 0rpx 0rpx; + z-index: 999; - .view_body { - width: 91.3%; - margin: 0 auto; - } - - .view_title { + .btn { + display: flex; + align-items: center; + justify-content: center; font-size: 28rpx; - font-family: 'PingFang'; + font-family: 'PingFang', 'PingFang'; font-weight: 800; - color: #2E4975; - } - - .view_input { - line-height: 70rpx; - background: #FFFFFF; - border-radius: 20rpx 20rpx 20rpx 20rpx; - margin-top: 16rpx; - padding: 0 24rpx; - } - - .view_tubiao { - display: flex; - justify-content: space-between; - align-items: center; - margin-top: 46rpx; - .view_tb{ - display: flex; - padding-left: 24rpx; - // align-items: center; - // padding: 11rpx 24rpx 11rpx 24rpx; - width: 120rpx; - height: 52rpx; - background: #FFFFFF; - border-radius: 26rpx 26rpx 26rpx 26rpx; - - border: 2rpx solid #F1F1F1; - - color: #F18F21 ; - font-size: 30rpx; - } - } - .noting{ - display: flex; - flex-wrap: nowrap; - align-items: center; - justify-content: center; - margin-top: 16rpx; + color: #FFFFFF; width: 686rpx; - height: 124rpx; - background: #FFFFFF; - border-radius: 20rpx 20rpx 20rpx 20rpx; - image{ - width: 58.19rpx; - height: 60rpx; - } - .text1{ - margin-left: 12rpx; - font-size: 24rpx; - font-family: PingFang SC, PingFang SC; - font-weight: 500; - color: #627698; - } - .text2{ - margin-left: 12rpx; - font-size: 24rpx; - font-family: PingFang SC, PingFang SC; - font-weight: 500; - color: #2D7CE6; - border-bottom: 2px solid #2D7CE6; - } - } - .class_bj { - margin-top: 16rpx; - } - - .class_images { - display: flex; - flex-wrap: wrap; - // justify-content: space-between; - // margin-top: 20rpx; - } - - .class_tp { - width: 56rpx; - height: 56rpx; - margin-right: 12rpx; - } - .Ielts{ - font-size: 40rpx; - font-weight: 400; - color: #2E4975; - margin: 20rpx 0; - } - .class_ys:nth-child(3n) { - margin-right: 0; - } - .class_ys { - margin-top: 20rpx; - margin-right: 20rpx; - width: 215rpx; - height: 96rpx; - display: flex; - justify-content: center; - align-items: center; - padding: 20rpx; - // width: 215rpx; - height: 96rpx; - background: #FFFFFF; - border-radius: 20rpx 20rpx 20rpx 20rpx; - } - - - .class_wz { - width: 125rpx; - font-size: 28rpx; - font-family: 'PingFang'; - font-weight: 500; - color: #072F5A; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - } - .view_form{ - padding: 0rpx 32rpx; - background: #FFFFFF; - margin-top: 16rpx; - border-radius: 20rpx 20rpx 20rpx 20rpx; - } - .view_textrea{ - height: 260rpx; - background: #FFFFFF; - border-radius: 20rpx 20rpx 20rpx 20rpx;; - margin-top:16rpx; - padding: 28rpx 32rpx; - } - .view_button{ - width: 93.1%; - margin:auto; - text-align: center; - line-height: 80rpx; + height: 80rpx; background: linear-gradient(180deg, #74AFFF 0%, #2D7CE6 100%); border-radius: 104rpx 104rpx 104rpx 104rpx; - color: #FFFFFF; } - .view_footer{ - width: 100%; - padding: 0 16rpx; - height: 144rpx; - border-radius: 40rpx 40rpx 0rpx 0rpx; - padding: 32rpx 0rpx; - background-color: #fff; - box-shadow: 0rpx -10rpx 16rpx 0rpx rgba(202,202,202,0.25); - margin-top: 8rpx; +} + +// 样式穿透 +::v-deep .u-dot { + background: #2D7CE6 !important; +} + +.concent { + width: 100vw; + background: linear-gradient(183deg, #F0F6FF 0%, #FAFAFA 100%); +} + +.view_body { + width: 91.3%; + margin: 0 auto; +} + +.view_title { + font-size: 28rpx; + font-family: 'PingFang'; + font-weight: 800; + color: #2E4975; +} + +.view_input { + line-height: 70rpx; + background: #FFFFFF; + border-radius: 20rpx 20rpx 20rpx 20rpx; + margin-top: 16rpx; + padding: 0 24rpx; +} + +.view_tubiao { + display: flex; + justify-content: space-between; + align-items: center; + margin-top: 46rpx; + + .view_tb { + display: flex; + padding-left: 24rpx; + // align-items: center; + // padding: 11rpx 24rpx 11rpx 24rpx; + width: 120rpx; + height: 52rpx; + background: #FFFFFF; + border-radius: 26rpx 26rpx 26rpx 26rpx; + + border: 2rpx solid #F1F1F1; + + color: #F18F21; + font-size: 30rpx; } - .u-node { - width: 44rpx; - height: 44rpx; - border-radius: 100rpx; - display: flex; - justify-content: center; - align-items: center; - background: #d0d0d0; - } - .u-order-desc { - padding: 20rpx; - background: #F9F9F9; - border-radius: 20rpx 20rpx 20rpx 20rpx; - margin: 12rpx 0rpx; - text { - font-size: 24rpx; - font-weight: 500; - color: #2E4975; - } - } - - .u-order-time { - color: rgb(200, 200, 200); - font-size: 26rpx; - } - .yuandi{ - width: 18rpx; - height: 18rpx; - background: #2D7CE6; - border-radius: 24rpx 24rpx 24rpx 24rpx; - } - .Test{ - font-size: 28rpx; - font-weight: 800; - color: #2E4975; - margin-left: 12rpx; - } - .ellipses{ - font-size: 20rpx; - background: rgba(242,170,2,0.2); - margin-left: 12rpx; - padding: 8rpx 20rpx; - color: #F2AA02; - border-radius: 20rpx 20rpx 20rpx 20rpx; - } - .erotic{ - font-size: 20rpx; - background: rgba(242,63,170,0.1); - margin-left: 12rpx; - padding: 8rpx 20rpx; - color: #F23FEB; - border-radius: 20rpx 20rpx 20rpx 20rpx; - } - .greener{ - font-size: 20rpx; - background: rgba(27,225,178,0.1); - margin-left: 12rpx; - padding: 8rpx 20rpx; - color: #1BE1B2; - border-radius: 20rpx 20rpx 20rpx 20rpx; - } - .increase{ - padding: 26rpx 125rpx; - color: #FFFFFF; - background-color: #F39852; - border-radius: 20rpx 20rpx 20rpx 20rpx; - text-align: center; - } - -</style> +} + +.noting { + display: flex; + flex-wrap: nowrap; + align-items: center; + justify-content: center; + margin-top: 16rpx; + width: 686rpx; + height: 124rpx; + background: #FFFFFF; + border-radius: 20rpx 20rpx 20rpx 20rpx; + + image { + width: 58.19rpx; + height: 60rpx; + } + + .text1 { + margin-left: 12rpx; + font-size: 24rpx; + font-family: PingFang SC, PingFang SC; + font-weight: 500; + color: #627698; + } + + .text2 { + margin-left: 12rpx; + font-size: 24rpx; + font-family: PingFang SC, PingFang SC; + font-weight: 500; + color: #2D7CE6; + border-bottom: 2px solid #2D7CE6; + } +} + +.class_bj { + margin-top: 16rpx; +} + +.class_images { + display: flex; + flex-wrap: wrap; + // justify-content: space-between; + // margin-top: 20rpx; +} + +.class_tp { + width: 56rpx; + height: 56rpx; + margin-right: 12rpx; +} + +.Ielts { + font-size: 40rpx; + font-weight: 400; + color: #2E4975; + margin: 20rpx 0; +} + +.class_ys:nth-child(3n) { + margin-right: 0; +} + +.class_ys { + margin-top: 20rpx; + margin-right: 20rpx; + width: 215rpx; + height: 96rpx; + display: flex; + justify-content: center; + align-items: center; + padding: 20rpx; + // width: 215rpx; + height: 96rpx; + background: #FFFFFF; + border-radius: 20rpx 20rpx 20rpx 20rpx; +} + + +.class_wz { + width: 125rpx; + font-size: 28rpx; + font-family: 'PingFang'; + font-weight: 500; + color: #072F5A; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +.view_form { + padding: 0rpx 32rpx; + background: #FFFFFF; + margin-top: 16rpx; + border-radius: 20rpx 20rpx 20rpx 20rpx; +} + +.view_textrea { + height: 260rpx; + background: #FFFFFF; + border-radius: 20rpx 20rpx 20rpx 20rpx; + ; + margin-top: 16rpx; + padding: 28rpx 32rpx; +} + +.view_button { + width: 93.1%; + margin: auto; + text-align: center; + line-height: 80rpx; + background: linear-gradient(180deg, #74AFFF 0%, #2D7CE6 100%); + border-radius: 104rpx 104rpx 104rpx 104rpx; + color: #FFFFFF; +} + +.view_footer { + width: 100%; + padding: 0 16rpx; + height: 144rpx; + border-radius: 40rpx 40rpx 0rpx 0rpx; + padding: 32rpx 0rpx; + background-color: #fff; + box-shadow: 0rpx -10rpx 16rpx 0rpx rgba(202, 202, 202, 0.25); + margin-top: 8rpx; +} + +.u-node { + width: 44rpx; + height: 44rpx; + border-radius: 100rpx; + display: flex; + justify-content: center; + align-items: center; + background: #d0d0d0; +} + +.u-order-desc { + display: block; + // flex-wrap: nowrap; + padding: 20rpx; + background: #F9F9F9; + border-radius: 20rpx 20rpx 20rpx 20rpx; + margin: 12rpx 0rpx; + + .txt { + + font-size: 24rpx; + font-weight: 500; + color: #2E4975; + } +} + +.u-order-time { + color: rgb(200, 200, 200); + font-size: 26rpx; +} + +.yuandi { + width: 18rpx; + height: 18rpx; + background: #2D7CE6; + border-radius: 24rpx 24rpx 24rpx 24rpx; +} + +.Test { + font-size: 28rpx; + font-weight: 800; + color: #2E4975; + margin-left: 12rpx; +} + +.ellipses { + font-size: 20rpx; + background: rgba(242, 170, 2, 0.2); + margin-left: 12rpx; + padding: 8rpx 20rpx; + color: #F2AA02; + border-radius: 20rpx 20rpx 20rpx 20rpx; +} + +.erotic { + display: flex; + justify-content: center; + align-items: center; + width: 80rpx; + height: 36rpx; + font-size: 20rpx; + background: rgba(242, 63, 170, 0.1); + margin-left: 12rpx; + // padding: 8rpx 20rpx; + color: #F23FEB; + border-radius: 20rpx 20rpx 20rpx 20rpx; +} + +.greener { + font-size: 20rpx; + background: rgba(27, 225, 178, 0.1); + margin-left: 12rpx; + padding: 8rpx 20rpx; + color: #1BE1B2; + border-radius: 20rpx 20rpx 20rpx 20rpx; +} + +.increase { + padding: 26rpx 125rpx; + color: #FFFFFF; + background-color: #F39852; + border-radius: 20rpx 20rpx 20rpx 20rpx; + text-align: center; +} +</style> \ No newline at end of file diff --git a/pages_teacher/teacher_teachers/teacher_writeadd.vue b/pages_teacher/teacher_teachers/teacher_writeadd.vue index eef2e3e..95eb75c 100644 --- a/pages_teacher/teacher_teachers/teacher_writeadd.vue +++ b/pages_teacher/teacher_teachers/teacher_writeadd.vue @@ -1,72 +1,231 @@ <template> <view class="view_template"> <view class="view_body"> - <u-navbar :is-back="true" title='添加作业' title-color="#000" :border-bottom="false" :background="true" id="navbar"> + <u-navbar :is-back="true" + title='添加作业' + title-color="#000" + :border-bottom="false" + :background="true" + id="navbar"> </u-navbar> <!-- 搜索 --> - <view class="view_search" v-if="search"> - <u-search :show-action="false" :animation="true" bg-color="#fff" placeholder="搜索相关内容..." color="#3E97FF"></u-search> + <view class="view_search" + v-if="search"> + <u-search v-model="searchKeyword" + :show-action="false" + :animation="true" + bg-color="#fff" + placeholder="搜索相关内容..." + color="#3E97FF" + @input="searchs()"></u-search> </view> + <!-- <view class="serchbox"> + <view class="serchimg"> + <image src="https://file.langsi.online/yasiimg/web/static/uVMACkynkipOxuTYDqm0"> + + </image> + </view> + <input type="text" + v-model="searchKeyword" + placeholder="搜索相关内容..." + class="input" + placeholder-style="color:#C7CDD3" + @input="search()"> + </view> --> <!--导航栏 --> <view class="view_tabs"> - <u-tabs :list="list" :is-scroll="false" :current="current" @change="change" active-color="#2D7CE6" bg-color="0"></u-tabs> + <u-tabs :list="list" + :is-scroll="false" + :current="current" + @change="change" + active-color="#2D7CE6" + bg-color="0"></u-tabs> </view> <!-- 轮播图 --> - <swiper :interval="5000" :duration="1000" is-scroll="true" :current="current" @change="updateCurrent" class="swiper"> + <swiper :interval="5000" + :duration="1000" + is-scroll="true" + :current="current" + @change="updateCurrent" + class="swiper"> <!-- 口语 --> <swiper-item style="height: 300rpx;"> <view> <view class="view_left"> - <view class="view_left_pd" @click="arrow_xl"> + <view class="view_left_pd" + @click="arrow_xl"> <view class="pull_down"> - <view>{{selectedOption}}</view> - <u-icon name="arrow-down" size="22"></u-icon> + <view>{{ selectedOption }}</view> + <u-icon name="arrow-down" + size="22"></u-icon> </view> - <view class="pull_Down" v-if="arrow"> - <view v-for="(item,index) in options" :key="index" @click="arrow_options(item.id)">{{item.name}}</view> + <view class="pull_Down" + v-if="arrow"> + <view v-for="(item, index) in options" + :key="index" + @click="arrow_options(item.id)">{{ item.name }}</view> </view> </view> </view> <!-- 口语主体 --> - <view v-for="(item,index) in slander" :key="index"> + <view v-for="(item, index) in slanderpart1" v-if="selectedOption=='Part1'" + :key="index"> <view class="view_inuygs"> <view class="header_part"> - <view class="unite">{{item.label}}</view> + <view class="unite">{{ item.label }}</view> </view> - <view class="bottom_one" v-if="part2"> - <view :class="{'active': item.active === '串题'}" @click="clicking(item, '串题')">串题</view> - <view :class="{'active': item.active === '跟读'}" @click="clicking(item, '跟读')">跟读</view> - <view :class="{'active': item.active === '模考'}" @click="clicking(item, '模考')">模考</view> + <view class="bottom_one" + v-if="item.list.length <= 1" + v-for="(items, indexs) in item.list" + :key='indexs'> + <view :class="{ 'active': items.ischuanti === true }" + @click="updateSelectspeak(items, 'ischuanti', indexs)">串题</view> + <view :class="{ 'active': items.isgendu === true }" + @click="updateSelectspeak(items, 'isgendu', indexs)">跟读</view> + <view :class="{ 'active': items.ismk === true }" + @click="updateSelectspeak(items, 'ismk', indexs)">模考</view> </view> </view> - - <!-- part1--> - <view class="slander_for" v-if="grizzly"> - <view class="slander_of" v-for="(items,indexs) in item.list" :key='indexs'> - <view class="textual"> - {{items.topicEn}} - </view> - <view class="bottom_one"> - <view :class="{'active': items.active === '串题'}" @click="clicking(items, '串题')">串题</view> - <view :class="{'active': items.active === '跟读'}" @click="clicking(items, '跟读')">跟读</view> - <view :class="{'active': items.active === '模考'}" @click="clicking(items, '模考')">模考</view> - </view> + + <!-- part1--> + <view class="slander_for" + v-if="item.list.length > 1"> + <view class="slander_of" + v-for="(items, indexs) in item.list" + :key='indexs'> + <view class="textual" v-html="highlightSearch( items.topicEn)"> + + </view> + <view class="bottom_one"> + <view :class="{ 'active': items.ischuanti === true }" + @click="updateSelectspeak(items, 'ischuanti', indexs)">串题</view> + <view :class="{ 'active': items.isgendu === true }" + @click="updateSelectspeak(items, 'isgendu', indexs)">跟读</view> + <view :class="{ 'active': items.ismk === true }" + @click="updateSelectspeak(items, 'ismk', indexs)">模考</view> </view> </view> - <!-- part2--> - <view class="slander_for" v-if="part2"> - <view class="slander_of" v-for="(items,indexs) in item.list" :key='indexs'> - <view class="textual2"> - {{items.topicEn}} - </view> + </view> + <!-- part2--> + <view class="slander_for" + v-if="item.list.length <= 1"> + <view class="slander_of" + v-for="(items, indexs) in item.list" + :key='indexs'> + <view class="textual2" v-html="highlightSearch( items.topicEn)"> + </view> </view> + </view> + </view> + <!-- part2 --> + <view v-for="(item, index) in slanderpart2" v-if="selectedOption=='Part2'" + :key="index"> + <view class="view_inuygs"> + <view class="header_part"> + <view class="unite">{{ item.label }}</view> + </view> + <view class="bottom_one" + v-if="item.list.length <= 1" + v-for="(items, indexs) in item.list" + :key='indexs'> + <view :class="{ 'active': items.ischuanti === true }" + @click="updateSelectspeak(items, 'ischuanti', indexs)">串题</view> + <view :class="{ 'active': items.isgendu === true }" + @click="updateSelectspeak(items, 'isgendu', indexs)">跟读</view> + <view :class="{ 'active': items.ismk === true }" + @click="updateSelectspeak(items, 'ismk', indexs)">模考</view> + </view> + </view> + + <!-- part1--> + <view class="slander_for" + v-if="item.list.length > 1"> + <view class="slander_of" + v-for="(items, indexs) in item.list" + :key='indexs'> + <view class="textual" v-html="highlightSearch( items.topicEn)"> + + </view> + <view class="bottom_one"> + <view :class="{ 'active': items.ischuanti === true }" + @click="updateSelectspeak(items, 'ischuanti', indexs)">串题</view> + <view :class="{ 'active': items.isgendu === true }" + @click="updateSelectspeak(items, 'isgendu', indexs)">跟读</view> + <view :class="{ 'active': items.ismk === true }" + @click="updateSelectspeak(items, 'ismk', indexs)">模考</view> + </view> + </view> + </view> + <!-- part2--> + <view class="slander_for" + v-if="item.list.length <= 1"> + <view class="slander_of" + v-for="(items, indexs) in item.list" + :key='indexs'> + <view class="textual2" v-html="highlightSearch( items.topicEn)"> + + </view> + </view> + </view> + </view> + <!-- part3 --> + <view v-for="(item, index) in slanderpart3" v-if="selectedOption=='Part3'" + :key="index"> + <view class="view_inuygs"> + <view class="header_part"> + <view class="unite">{{ item.label }}</view> + </view> + <view class="bottom_one" + v-if="item.list.length <= 1" + v-for="(items, indexs) in item.list" + :key='indexs'> + <view :class="{ 'active': items.ischuanti === true }" + @click="updateSelectspeak(items, 'ischuanti', indexs)">串题</view> + <view :class="{ 'active': items.isgendu === true }" + @click="updateSelectspeak(items, 'isgendu', indexs)">跟读</view> + <view :class="{ 'active': items.ismk === true }" + @click="updateSelectspeak(items, 'ismk', indexs)">模考</view> + </view> + </view> + + <!-- part1--> + <view class="slander_for" + v-if="item.list.length > 1"> + <view class="slander_of" + v-for="(items, indexs) in item.list" + :key='indexs'> + <view class="textual" v-html="highlightSearch( items.topicEn)"> + + </view> + <view class="bottom_one"> + <view :class="{ 'active': items.ischuanti === true }" + @click="updateSelectspeak(items, 'ischuanti', indexs)">串题</view> + <view :class="{ 'active': items.isgendu === true }" + @click="updateSelectspeak(items, 'isgendu', indexs)">跟读</view> + <view :class="{ 'active': items.ismk === true }" + @click="updateSelectspeak(items, 'ismk', indexs)">模考</view> + </view> + </view> + </view> + <!-- part2--> + <view class="slander_for" + v-if="item.list.length <= 1"> + <view class="slander_of" + v-for="(items, indexs) in item.list" + :key='indexs'> + <view class="textual2" v-html="highlightSearch( items.topicEn)"> + + </view> + </view> + </view> </view> </view> </swiper-item> + <!-- 写作 --> <swiper-item> - + <compose></compose> </swiper-item> <!--听力 --> @@ -80,531 +239,724 @@ </swiper> </view> <!-- 底部按钮 --> - <view :class="search== true ? 'footer2' : 'footer'"> - <view class="footer_button"> - <view :class="search==true ? 'button_andadd' :'button_show'">确定添加(4)</view> - <view class="footer_button_right" v-if="search">口语模考</view> + <view :class="search == true ? 'footer2' : 'footer'" + v-if="totalLength != 0"> + <view class="footer_button" @click="submessage()"> + <view :class="search == true ? 'button_andadd' : 'button_show'">确定添加({{ totalLength }})</view> + <view class="footer_button_right" + v-if="search">口语模考</view> </view> </view> </view> - </view> -</template> +</view></template> <script> - import audiology from './components/audiology.vue' - import reading from './components/reading.vue' - import slander from './components/slander.vue' - import compose from './components/compose.vue' - export default { - data() { - return { - // 导航栏 - list: [{ - name: '口语' - }, - { - name: '写作' - }, - { - name: '听力' - }, - { - name: '阅读' - } - ], - radio: [{ - name: '1', - disabled: false - }], - // 写作 - Compose: [], - num:0, - // 下拉框的v-if布尔值 - radioValue: '', - part1: true, - current: 0, - search: true, - listType: [], - idList: [], - // 口语 - postdata: { - "key": "", - "pageNum": 0, - "mode": "home", - "part": "part1", - "order": "0", - "type": "", - "isStudy": 0, - "isFavorite": 0, - "isEvlua": 0, - "isFun": 0, - "level": 0, - "isNew": 0 - }, - slander: [], - part2:false, - grizzly:true, - categorize: '分类', - // 下拉框的v-if布尔值 - selectedOption: 'Part1', - arrow: false, - arrowDown: false, - options: [{ - id: 1, - name: 'Part1' - }, - { - id: 2, - name: 'Part2' - }, - { - id: 3, - name: 'Part3' - } - ], - userId:null +import audiology from './components/audiology.vue' +import reading from './components/reading.vue' +import slander from './components/slander.vue' +import compose from './components/compose.vue' +export default { + data() { + return { + // 导航栏 + list: [{ + name: '口语' + }, + { + name: '写作' + }, + { + name: '听力' + }, + { + name: '阅读' } - }, - components:{ - audiology, - reading, - compose - }, - created() { - this.getList() - }, - methods: { - upType(index, num) { - this.listType.splice(index, 1, num) + ], + radio: [{ + name: '1', + disabled: false + }], + // 写作 + Compose: [], + num: 0, + // 下拉框的v-if布尔值 + radioValue: '', + part1: true, + current: 1, + search: true, + listType: [], + idList: [], + // 口语 + postdata: { + "key": "", + "pageNum": 0, + "mode": "home", + "part": "part1", + "order": "0", + "type": "", + "isStudy": 0, + "isFavorite": 0, + "isEvlua": 0, + "isFun": 0, + "level": 0, + "isNew": 0 }, - change(index) { - this.current = index; + slanderpart1: [], + originslanderpart1: [], + slanderpart2: [], + originslanderpart2: [], + slanderpart3: [], + originslanderpart3: [], + part2: false, + grizzly: true, + categorize: '分类', + // 下拉框的v-if布尔值 + selectedOption: 'Part1', + arrow: false, + arrowDown: false, + options: [{ + id: 1, + name: 'Part1' }, - // 选中某个单选框时,由radio时触发 - radioCheck(index) { - if (this.radioValue == this.list2[index].id) { - this.radioValue = null - } else { - this.radioValue = this.list2[index].id - } + { + id: 2, + name: 'Part2' }, - //轮播图滑动和tabs保持一致 - updateCurrent(current, source) { - this.current = current.detail.current - if (this.current == 0) { - this.search = true - } else { - this.search = false - } - }, - getList() { - this.$u.post('https://api.admin-v2.langsi.online/admin-api/speaking/topic/home/list', this.postdata).then(res => { - let keyArr = Object.keys(res.data) - let valueArr = Object.values(res.data) - this.slander = keyArr.map((item, index) => { - return { - label: item, - list: valueArr[index] - } - }) - }) - }, - //下拉显示下拉框 - arrow_xl() { - this.arrow = !this.arrow - }, - arrow_xl2() { - this.arrowDown = !this.arrowDown - }, - arrow_options(id) { - this.options.forEach(item => { - if (item.id == id) { - this.selectedOption = item.name - - } else if (id == 2) { - this.postdata.part = "part2" - this.part2=true - this.grizzly = false - this.getList() - } - else if (id == 3) { - this.postdata.part = "part3" - this.part2=true - this.grizzly = false - this.getList() - }else { - this.postdata.part = "part1" - this.part2= false - this.grizzly = true - this.getList() - } - }) - }, - clicking(target, type) { - if (target.active === type) { - this.$set(target, 'active', null); - } else { - this.$set(target, 'active', type); - } - }, - radioGroupChange() { + { + id: 3, + name: 'Part3' + } + ], + totalLength: 0, + searchKeyword: '', + userId: null, + selectspeak: [], + selectwrite: [], + selectlisten: [], + selectread: [] + } + }, + components: { + audiology, + reading, + compose + }, + created() { + this.getList() + }, + methods: { + updatawrite(data){ + this.selectwrite=data + console.log(this.selectwrite, ' this.selectwrite this.selectwrite'); + this.calculateTotalLength() + }, + submessage(){ + const dataToSave = { + selectspeak: this.selectspeak, + selectwrite: this.selectwrite, + selectlisten: this.selectlisten, + selectread: this.selectread + }; + + // 将数据保存在本地缓存中 + uni.setStorageSync('selectforwork', dataToSave); + uni.navigateBack({ + delta: 1, // Number of pages to go back + success(res) { + console.log(res); + }, + fail(err) { + console.error(err); + } + }); + }, + fuwei() { + + // this.slander = JSON.parse(JSON.stringify(this.originslanderpart1)); + // this.selectedIds.forEach(selectedItem => { + // const index = this.stulist.findIndex(item => item.id === selectedItem.id); + // if (index !== -1) { + // this.$set(this.stulist, index, { ...this.stulist[index], isSelected: true }); + // } + // }); + }, + searchs() { + if(this.selectedOption=='Part1'){ + const filteredSlander = []; + + // 将搜索关键字转换为小写,使搜索不区分大小写 + const searchKeywordLowerCase = this.searchKeyword.toLowerCase(); + + // 遍历原始数据 + for (const item of this.originslanderpart1) { + const filteredList = item.list.filter(subItem => { + // 将目标字符串转换为小写,使匹配不区分大小写 + const introductionLowerCase = subItem.introduction.toLowerCase(); + const topicEnLowerCase = subItem.topicEn.toLowerCase(); + + // 检查 introduction 或 topicEn 是否包含小写的 searchKeyword + return ( + introductionLowerCase.includes(searchKeywordLowerCase) || + topicEnLowerCase.includes(searchKeywordLowerCase) + ); + }); + + // 如果有匹配项,添加到 filteredSlander 中 + if (filteredList.length > 0) { + filteredSlander.push({ + label: item.label, + list: filteredList + }); + } } + + // 更新 this.slander + this.slanderpart1 = filteredSlander; + }else if(this.selectedOption=='Part2'){ + const filteredSlander = []; + + // 将搜索关键字转换为小写,使搜索不区分大小写 + const searchKeywordLowerCase = this.searchKeyword.toLowerCase(); + + // 遍历原始数据 + for (const item of this.originslanderpart2) { + const filteredList = item.list.filter(subItem => { + // 将目标字符串转换为小写,使匹配不区分大小写 + const introductionLowerCase = subItem.introduction.toLowerCase(); + const topicEnLowerCase = subItem.topicEn.toLowerCase(); + + // 检查 introduction 或 topicEn 是否包含小写的 searchKeyword + return ( + introductionLowerCase.includes(searchKeywordLowerCase) || + topicEnLowerCase.includes(searchKeywordLowerCase) + ); + }); + + // 如果有匹配项,添加到 filteredSlander 中 + if (filteredList.length > 0) { + filteredSlander.push({ + label: item.label, + list: filteredList + }); + } + } + + // 更新 this.slander + this.slanderpart2 = filteredSlander; + }else if(this.selectedOption=='Part3'){ + const filteredSlander = []; + + // 将搜索关键字转换为小写,使搜索不区分大小写 + const searchKeywordLowerCase = this.searchKeyword.toLowerCase(); + + // 遍历原始数据 + for (const item of this.originslanderpart3) { + const filteredList = item.list.filter(subItem => { + // 将目标字符串转换为小写,使匹配不区分大小写 + const introductionLowerCase = subItem.introduction.toLowerCase(); + const topicEnLowerCase = subItem.topicEn.toLowerCase(); + + // 检查 introduction 或 topicEn 是否包含小写的 searchKeyword + return ( + introductionLowerCase.includes(searchKeywordLowerCase) || + topicEnLowerCase.includes(searchKeywordLowerCase) + ); + }); + + // 如果有匹配项,添加到 filteredSlander 中 + if (filteredList.length > 0) { + filteredSlander.push({ + label: item.label, + list: filteredList + }); + } + } + + // 更新 this.slander + this.slanderpart3 = filteredSlander; + } + + + }, + highlightSearch(name) { + // 使用正则表达式替换匹配到的 searchKeyword 为带有颜色的文字 + if (this.searchKeyword) { + const regex = new RegExp(this.searchKeyword, 'gi'); + return name.replace(regex, match => `<span style="color: #2D7CE6 ;">${match}</span>`); + } + return name; + }, + calculateTotalLength() { + this.totalLength = this.selectspeak.length + this.selectwrite.length + this.selectlisten.length + this.selectread.length; + + }, + calculateTotal(array) { + return array.reduce((total, item) => { + // 假设每个元素都有一个名为value的属性 + return total + (item.value || 0); // 如果value为undefined,将其视为0 + }, 0); + }, + updateSelectspeak(items, type, indexs) { + // 切换slander数组中的值 + items[type] = !items[type]; + + // 获取对应的speakingType值 + const speakingTypeValue = this.getSpeakingTypeValue(type); + + // 检查selectspeak数组中是否已存在对应的对象 + const existingSelectspeak = this.selectspeak.find(select => select.id === items.id); + + if (existingSelectspeak) { + // 如果已存在,在speakingType中添加新的值或移除对应的值 + if (items[type]) { + // 如果选中了该项,请添加speakingType + if (!existingSelectspeak.speakingType.includes(speakingTypeValue)) { + existingSelectspeak.speakingType.push(speakingTypeValue); + } + } else { + // 如果取消选中该项,请删除speakingType + existingSelectspeak.speakingType = existingSelectspeak.speakingType + .filter(value => value !== speakingTypeValue); + + // 如果speakingType为空,则清除selectspeak项 + if (existingSelectspeak.speakingType.length === 0) { + const indexToRemove = this.selectspeak.indexOf(existingSelectspeak); + this.selectspeak.splice(indexToRemove, 1); + } + } + } else { + // 如果不存在,创建新的对象并添加到selectspeak数组中 + if (items[type]) { + this.selectspeak.push({ + // part: indexs, + part: items.part, + topicEn: items.topicEn, + id: items.id, + introduction: items.introduction, + speakingType: [speakingTypeValue] + }); + } + } + this.calculateTotalLength() + console.log(this.selectspeak, 'selectspeakselectspeak'); + }, + getSpeakingTypeValue(type) { + // 返回对应的数字值 + switch (type) { + case 'ischuanti': + return '1'; + case 'isgendu': + return '2'; + case 'ismk': + return '3'; + default: + return ''; + } + }, + upType(index, num) { + this.listType.splice(index, 1, num) + }, + change(index) { + this.current = index; + }, + // 选中某个单选框时,由radio时触发 + radioCheck(index) { + if (this.radioValue == this.list2[index].id) { + this.radioValue = null + } else { + this.radioValue = this.list2[index].id + } + }, + //轮播图滑动和tabs保持一致 + updateCurrent(current, source) { + this.current = current.detail.current + if (this.current == 0) { + this.search = true + } else { + this.search = false + } + }, + getList() { + let postdata= { + "key": "", + "pageNum": 0, + "mode": "home", + "part": "part1", + "order": "0", + "type": "", + "isStudy": 0, + "isFavorite": 0, + "isEvlua": 0, + "isFun": 0, + "level": 0, + "isNew": 0 + } + this.$u.post('https://api.admin-v2.langsi.online/admin-api/speaking/topic/home/list', postdata).then(res => { + if(res.code==0){ + this.getpart2() + } + let keyArr = Object.keys(res.data) + let valueArr = Object.values(res.data) + this.slanderpart1 = keyArr.map((item, index) => { + return { + label: item, + list: valueArr[index] + } + }) + this.originslanderpart1 = keyArr.map((item, index) => { + return { + label: item, + list: valueArr[index] + } + }) + this.originslanderpart1part1 = JSON.parse(JSON.stringify(this.originslanderpart1part1)); + let json = JSON.stringify(res.data) + // console.log(json); + }) + + + + + }, + getpart2(){ + let postdata1= { + "key": "", + "pageNum": 0, + "mode": "home", + "part": "part2", + "order": "0", + "type": "", + "isStudy": 0, + "isFavorite": 0, + "isEvlua": 0, + "isFun": 0, + "level": 0, + "isNew": 0 + } + this.$u.post('https://api.admin-v2.langsi.online/admin-api/speaking/topic/home/list', postdata1).then(res => { + if(res.code==0){ + this.getpart3() + } + let keyArr = Object.keys(res.data) + let valueArr = Object.values(res.data) + this.slanderpart2 = keyArr.map((item, index) => { + return { + label: item, + list: valueArr[index] + } + }) + this.originslanderpart2 = keyArr.map((item, index) => { + return { + label: item, + list: valueArr[index] + } + }) + this.originslanderpart2 = JSON.parse(JSON.stringify(this.originslanderpart2)); + // let json = JSON.stringify(res.data) + + }) + }, + getpart3(){ + let postdata2= { + "key": "", + "pageNum": 0, + "mode": "home", + "part": "part3", + "order": "0", + "type": "", + "isStudy": 0, + "isFavorite": 0, + "isEvlua": 0, + "isFun": 0, + "level": 0, + "isNew": 0 + } + this.$u.post('https://api.admin-v2.langsi.online/admin-api/speaking/topic/home/list', postdata2).then(res => { + let keyArr = Object.keys(res.data) + let valueArr = Object.values(res.data) + this.slanderpart3 = keyArr.map((item, index) => { + return { + label: item, + list: valueArr[index] + } + }) + this.originslanderpart3 = keyArr.map((item, index) => { + return { + label: item, + list: valueArr[index] + } + }) + this.originslanderpart3 = JSON.parse(JSON.stringify(this.originslanderpart3)); + let json = JSON.stringify(res.data) + // console.log(json); + }) + }, + //下拉显示下拉框 + arrow_xl() { + this.arrow = !this.arrow + }, + arrow_xl2() { + this.arrowDown = !this.arrowDown + }, + arrow_options(id) { + this.options.forEach(item => { + if (item.id == id) { + this.selectedOption = item.name + + } else if (id == 2) { + this.postdata.part = "part2" + this.part2 = true + this.grizzly = false + + } + else if (id == 3) { + this.postdata.part = "part3" + this.part2 = true + this.grizzly = false + + } else { + this.postdata.part = "part1" + this.part2 = false + this.grizzly = true + + } + }) + }, + clicking(target, type) { + + }, + radioGroupChange() { + } } +} </script> <style lang="scss" scoped> - .view_template { - width: 100%; - background: linear-gradient(183deg, #F0F6FF 0%, #FAFAFA 100%); +.view_template { + width: 100%; + background: linear-gradient(183deg, #F0F6FF 0%, #FAFAFA 100%); +} + +.serchbox { + padding: 0 32rpx; + display: flex; + flex-wrap: nowrap; + margin-top: 30rpx; + align-items: center; + width: 686rpx; + height: 88rpx; + background: #FFFFFF; + border-radius: 20rpx 20rpx 20rpx 20rpx; + + .serchimg { + width: 30.51rpx; + height: 32rpx; + margin-right: 24rpx; } - .view_body { - height: 89vh; - width: 91.3%; + .input { margin: 0 auto; - border-radius: 0rpx 0rpx 0rpx 0rpx; - - // padding: 32rpx; - .view_search { - height: 88rpx; - margin: 0 auto; - line-height: 88rpx; - background: #FFFFFF; - border-radius: 20rpx 20rpx 20rpx 20rpx; - - } - .view_button { - border-radius: 12rpx 12rpx 12rpx 12rpx; - padding: 12rpx 24rpx; - font-size: 20rpx; - font-weight: 500; - color: rgba(101, 116, 140, 0.8); - } - - .view_buttons { - background: #2D7CE6; - border-radius: 12rpx 12rpx 12rpx 12rpx; - padding: 12rpx 24rpx; - font-size: 20rpx; - font-weight: 500; - color: #FFFFFF; - } - - .view_fff { - background: #FFFFFF; - border-radius: 20rpx 20rpx 20rpx 20rpx; - } - - .view_Do { - display: flex; - justify-content: space-between; - padding: 28rpx 0rpx; - margin: 0 28rpx; - border-bottom: 2rpx solid #F2F2F2; - } - - .view_pushbutton { - display: flex; - } - - .grizzly { - background: #E1EEFF; - border-radius: 8rpx 8rpx 8rpx 8rpx; - font-size: 20rpx; - font-weight: 500; - color: #2D7CE6; - padding: 6rpx 18rpx; - margin-left: 12rpx; - } - - .yellow { - background: #FFEBD7; - border-radius: 8rpx 8rpx 8rpx 8rpx; - font-size: 20rpx; - font-weight: 500; - color: #FB9734; - padding: 6rpx 18rpx; - margin-left: 12rpx; - } - - .view_English { - display: flex; - font-size: 24rpx; - font-weight: 500; - color: #2E4975; - } - - .active { - z-index: 9; - background:#2D7CE6; - color: #fff; - } - - .slander { - height: 352rpx; - background: #FFFFFF; - border-radius: 20rpx 20rpx 20rpx 20rpx; - } - - .slander_behavior { - display: flex; - justify-content: space-between; - padding: 20rpx 0rpx; - border-bottom: 2rpx solid #F2F2F2; - } - - .slander_for { - background: #FFFFFF; - border-radius: 20rpx 20rpx 20rpx 20rpx; - padding: 0 30rpx; - } - - .unite { - width: 270rpx; - font-size: 28rpx; - font-family: 'PingFang'; - font-weight: 800; - color: #2E4975; - margin: 26rpx 0rpx; - } - - .slander_an { - background: #F4F4F4; - border-radius: 12rpx 12rpx 12rpx 12rpx; - font-size: 20rpx; - font-family: 'PingFang'; - font-weight: 500; - color: rgba(101, 116, 140, 0.8); - padding: 10rpx; - margin-right: 15rpx; - } - - .pd_icon { - margin-left: 8rpx; - } - - .highlighted { - - background: rgba(45, 124, 230, 0.1); - border-radius: 12rpx 12rpx 12rpx 12rpx; - color: #2D7CE6; - } - - .part { - font-size: 28rpx; - font-family: 'PingFang'; - font-weight: 500; - color: #2E4975; - - } - - .part2 { - font-size: 28rpx; - font-family: 'PingFang'; - font-weight: 500; - color: #2E4975; - margin-left: 20rpx; - - } - - .swiper { - height: 80%; - } - - swiper-item { - overflow: scroll; - } - .slander_left { - width: 328rpx; - text-overflow: ellipsis; - white-space: nowrap; - overflow: hidden - } - .view_left { - display: flex; - justify-content: left; - margin-top: 20rpx; - } - - .view_inuygs { - display: flex; - justify-content: space-between; - align-items: center; - } - - .view_left_pd { - position: relative; - padding: 12rpx 32rpx; - background: #FFFFFF; - border-radius: 20rpx 20rpx 20rpx 20rpx; - margin-right: 15rpx; - font-size: 24rpx; - color: #072F5A; - } - - .unite { - width: 290rpx; - display: -webkit-box; - -webkit-box-orient: vertical; - overflow: hidden; - -webkit-line-clamp: 1; - font-size: 28rpx; - font-family: 'PingFang'; - font-weight: 800; - color: #2E4975; - - margin-right: 20rpx; - } - - .pull_Down { - position: absolute; - bottom: -184rpx; - left: 50%; - margin-left: -79rpx; - box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(0, 0, 0, 0.25); - border-radius: 20rpx 20rpx 20rpx 20rpx; - background: #FFFFFF; - border-bottom: 2rpx solid #F2F2F2; - - view { - padding: 15rpx 50rpx; - border-bottom: 2rpx solid #F2F2F2; - } - } - - .pull_Down view:last-child { - border: none; - } - - .header_part { - display: flex; - align-items: center; - margin: 26rpx 0rpx; - } - - .slander_an { - padding: 6rpx 18rpx; - background: #fff; - border-radius: 12rpx 12rpx 12rpx 12rpx; - margin-left: 12rpx; - color: #65748C; - } - - .slander_for { - background-color: #fff; - border-radius: 20rpx 20rpx 20rpx 20rpx; - - } - - .slander_of { - display: flex; - align-items: center; - justify-content: space-between; - padding: 24rpx 0; - margin: 0 20rpx; - border-bottom: 2rpx solid #F2F2F2; - - } - - .textual { - width: 290rpx; - display: -webkit-box; - -webkit-box-orient: vertical; - overflow: hidden; - -webkit-line-clamp: 2; - } - - .bottom_one { - display: flex; - view { - padding: 6rpx 18rpx; - background: #F4F4F4; - border-radius: 12rpx 12rpx 12rpx 12rpx; - font-size: 20rpx; - font-weight: 500; - color: rgba(101,116,140,0.8); - margin-left: 15rpx; - } - .active { - background: rgba(45, 124, 230, 0.1); - color: #2D7CE6; - } - } - .pull_down{ - display: flex; - justify-content: space-between; - width: 100rpx; - font-size: 24rpx; - } - - + width: 568rpx; + height: 88rpx; + border-radius: 30rpx; + // background-color: #f5f8fc; + // display: flex; + // justify-content: center; + // align-items: center; + // text-align: center; + font-size: 28rpx; + font-family: Source Han Sans CN, Source Han Sans CN-Light; + font-weight: 300; + text-align: left; + color: #a7b9cd; + letter-spacing: 1.2rpx; + line-height: 36rpx; + // padding: 0 100rpx; + // padding-right: 135rpx; + box-sizing: border-box; } +} - .footer { - position: fixed; - bottom: 0; - width: 100%; +.view_body { + height: 89vh; + width: 91.3%; + margin: 0 auto; + border-radius: 0rpx 0rpx 0rpx 0rpx; + + // padding: 32rpx; + .view_search { + height: 88rpx; + margin: 0 auto; + line-height: 88rpx; background: #FFFFFF; - box-shadow: 0rpx -6rpx 14rpx 0rpx rgba(177, 177, 177, 0.25); - padding: 30rpx 32rpx; - } - .footer2{ - position: fixed; - bottom: 0; - width: 100%; - background: #FFFFFF; - box-shadow: 0rpx -6rpx 14rpx 0rpx rgba(177, 177, 177, 0.25); - padding: 30rpx 32rpx; - margin-top: 25rpx; + border-radius: 20rpx 20rpx 20rpx 20rpx; + } - .footer_button { + .view_button { + border-radius: 12rpx 12rpx 12rpx 12rpx; + padding: 12rpx 24rpx; + font-size: 20rpx; + font-weight: 500; + color: rgba(101, 116, 140, 0.8); + } + + .view_buttons { + background: #2D7CE6; + border-radius: 12rpx 12rpx 12rpx 12rpx; + padding: 12rpx 24rpx; + font-size: 20rpx; + font-weight: 500; + color: #FFFFFF; + } + + .view_fff { + background: #FFFFFF; + border-radius: 20rpx 20rpx 20rpx 20rpx; + } + + .view_Do { display: flex; justify-content: space-between; + padding: 28rpx 0rpx; + margin: 0 28rpx; + border-bottom: 2rpx solid #F2F2F2; } - .button_ky { - padding: 24rpx 52rpx; - border-radius: 104rpx 104rpx 104rpx 104rpx; - color: #2E4975; - background-color: #FAFAFA; + .view_pushbutton { + display: flex; } - .button_andadd { - background: linear-gradient(180deg, #74AFFF 0%, #2D7CE6 100%); - border-radius: 104rpx 104rpx 104rpx 104rpx; - padding: 26rpx 125rpx; - color: #fff; + .grizzly { + background: #E1EEFF; + border-radius: 8rpx 8rpx 8rpx 8rpx; + font-size: 20rpx; + font-weight: 500; + color: #2D7CE6; + padding: 6rpx 18rpx; + margin-left: 12rpx; } - .button_show { - width: 100%; - background: linear-gradient(180deg, #74AFFF 0%, #2D7CE6 100%); - border-radius: 104rpx 104rpx 104rpx 104rpx; - padding: 26rpx 125rpx; - color: #fff; - text-align: center; + .yellow { + background: #FFEBD7; + border-radius: 8rpx 8rpx 8rpx 8rpx; + font-size: 20rpx; + font-weight: 500; + color: #FB9734; + padding: 6rpx 18rpx; + margin-left: 12rpx; } - .view_fff_bottom { - margin-bottom: 54rpx; - } - - .Task { + .view_English { + display: flex; font-size: 24rpx; font-weight: 500; color: #2E4975; } + .active { + z-index: 9; + background: #2D7CE6; + color: #fff; + } + + .slander { + height: 352rpx; + background: #FFFFFF; + border-radius: 20rpx 20rpx 20rpx 20rpx; + } + + .slander_behavior { + display: flex; + justify-content: space-between; + padding: 20rpx 0rpx; + border-bottom: 2rpx solid #F2F2F2; + } + + .slander_for { + background: #FFFFFF; + border-radius: 20rpx 20rpx 20rpx 20rpx; + padding: 0 30rpx; + } + + .unite { + width: 270rpx; + font-size: 28rpx; + font-family: 'PingFang'; + font-weight: 800; + color: #2E4975; + margin: 26rpx 0rpx; + } + + .slander_an { + background: #F4F4F4; + border-radius: 12rpx 12rpx 12rpx 12rpx; + font-size: 20rpx; + font-family: 'PingFang'; + font-weight: 500; + color: rgba(101, 116, 140, 0.8); + padding: 10rpx; + margin-right: 15rpx; + } + + .pd_icon { + margin-left: 8rpx; + } + + .highlighted { + + background: rgba(45, 124, 230, 0.1); + border-radius: 12rpx 12rpx 12rpx 12rpx; + color: #2D7CE6; + } + + .part { + font-size: 28rpx; + font-family: 'PingFang'; + font-weight: 500; + color: #2E4975; + + } + + .part2 { + font-size: 28rpx; + font-family: 'PingFang'; + font-weight: 500; + color: #2E4975; + margin-left: 20rpx; + + } + + .swiper { + height: 80%; + } + + swiper-item { + overflow: scroll; + } + + .slander_left { + width: 328rpx; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden + } + .view_left { display: flex; justify-content: left; margin-top: 20rpx; } + .view_inuygs { + display: flex; + justify-content: space-between; + align-items: center; + } + .view_left_pd { position: relative; padding: 12rpx 32rpx; @@ -612,51 +964,230 @@ border-radius: 20rpx 20rpx 20rpx 20rpx; margin-right: 15rpx; font-size: 24rpx; + color: #072F5A; + } + + .unite { + width: 290rpx; + display: -webkit-box; + -webkit-box-orient: vertical; + overflow: hidden; + -webkit-line-clamp: 1; + font-size: 28rpx; + font-family: 'PingFang'; + font-weight: 800; + color: #2E4975; + + margin-right: 20rpx; } .pull_Down { position: absolute; - bottom: -130rpx; + bottom: -184rpx; left: 50%; margin-left: -79rpx; - box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(0,0,0,0.25); + box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(0, 0, 0, 0.25); border-radius: 20rpx 20rpx 20rpx 20rpx; background: #FFFFFF; border-bottom: 2rpx solid #F2F2F2; + view { padding: 15rpx 50rpx; border-bottom: 2rpx solid #F2F2F2; } } - .pull_DownTow{ + + .pull_Down view:last-child { + border: none; + } + + .header_part { + display: flex; + align-items: center; + margin: 26rpx 0rpx; + } + + .slander_an { + padding: 6rpx 18rpx; + background: #fff; + border-radius: 12rpx 12rpx 12rpx 12rpx; + margin-left: 12rpx; + color: #65748C; + } + + .slander_for { + background-color: #fff; + border-radius: 20rpx 20rpx 20rpx 20rpx; + + } + + .slander_of { + display: flex; + align-items: center; + justify-content: space-between; + padding: 24rpx 0; + margin: 0 20rpx; + border-bottom: 2rpx solid #F2F2F2; + + } + + .textual { + width: 290rpx; + display: -webkit-box; + -webkit-box-orient: vertical; + overflow: hidden; + -webkit-line-clamp: 2; + } + + .bottom_one { + display: flex; + + view { + padding: 6rpx 18rpx; + background: #F4F4F4; + border-radius: 12rpx 12rpx 12rpx 12rpx; + font-size: 20rpx; + font-weight: 500; + color: rgba(101, 116, 140, 0.8); + margin-left: 15rpx; + } + + .active { + background: rgba(45, 124, 230, 0.1); + color: #2D7CE6; + } + } + + .pull_down { + display: flex; + justify-content: space-between; + width: 100rpx; + font-size: 24rpx; + } + + + +} + +.footer { + position: fixed; + bottom: 0; + width: 100%; + background: #FFFFFF; + box-shadow: 0rpx -6rpx 14rpx 0rpx rgba(177, 177, 177, 0.25); + padding: 30rpx 32rpx; +} + +.footer2 { + position: fixed; + bottom: 0; + width: 100%; + background: #FFFFFF; + box-shadow: 0rpx -6rpx 14rpx 0rpx rgba(177, 177, 177, 0.25); + padding: 30rpx 32rpx; + margin-top: 25rpx; +} + +.footer_button { + display: flex; + justify-content: space-between; +} + +.button_ky { + padding: 24rpx 52rpx; + border-radius: 104rpx 104rpx 104rpx 104rpx; + color: #2E4975; + background-color: #FAFAFA; +} + +.button_andadd { + background: linear-gradient(180deg, #74AFFF 0%, #2D7CE6 100%); + border-radius: 104rpx 104rpx 104rpx 104rpx; + padding: 26rpx 125rpx; + color: #fff; +} + +.button_show { + width: 100%; + background: linear-gradient(180deg, #74AFFF 0%, #2D7CE6 100%); + border-radius: 104rpx 104rpx 104rpx 104rpx; + padding: 26rpx 125rpx; + color: #fff; + text-align: center; +} + +.view_fff_bottom { + margin-bottom: 54rpx; +} + +.Task { + font-size: 24rpx; + font-weight: 500; + color: #2E4975; +} + +.view_left { + display: flex; + justify-content: left; + margin-top: 20rpx; +} + +.view_left_pd { + position: relative; + padding: 12rpx 32rpx; + background: #FFFFFF; + border-radius: 20rpx 20rpx 20rpx 20rpx; + margin-right: 15rpx; + font-size: 24rpx; +} + +.pull_Down { + position: absolute; + bottom: -130rpx; + left: 50%; + margin-left: -79rpx; + box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(0, 0, 0, 0.25); + border-radius: 20rpx 20rpx 20rpx 20rpx; + background: #FFFFFF; + border-bottom: 2rpx solid #F2F2F2; + + view { + padding: 15rpx 50rpx; + border-bottom: 2rpx solid #F2F2F2; + } +} + +.pull_DownTow { width: 150rpx; position: absolute; bottom: -133rpx; left: 50%; margin-left: -72rpx; - box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(0,0,0,0.25); + box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(0, 0, 0, 0.25); border-radius: 20rpx 20rpx 20rpx 20rpx; background: #FFFFFF; border-bottom: 2rpx solid #F2F2F2; text-align: center; + view { padding: 15rpx 0rpx; border-bottom: 2rpx solid #F2F2F2; } - - } - .pull_Down view:last-child { - border: none; - } - .sl_body { - background-color: #fff; - } +} - .footer_button_right { - padding: 24rpx 62rpx; - border: 1px solid #2D7CE6; - border-radius: 104rpx 104rpx 104rpx 104rpx; - color: #2D7CE6; - } +.pull_Down view:last-child { + border: none; +} + +.sl_body { + background-color: #fff; +} + +.footer_button_right { + padding: 24rpx 62rpx; + border: 1px solid #2D7CE6; + border-radius: 104rpx 104rpx 104rpx 104rpx; + color: #2D7CE6; +} </style> From 1202742ead2f41c131665e30363efe7fa24f327a Mon Sep 17 00:00:00 2001 From: taoxu <2622874537@qq.com> Date: Sat, 9 Dec 2023 18:15:29 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=B8=B2=E6=9F=93=20?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teacher_teachers/components/audiology.vue | 228 +++++++++++----- .../teacher_teachers/components/compose.vue | 26 +- .../teacher_teachers/components/reading.vue | 177 +++++++++---- .../teacher_teachers/teacher_addOperation.vue | 246 ++++++++++-------- .../teacher_teachers/teacher_writeadd.vue | 35 ++- 5 files changed, 491 insertions(+), 221 deletions(-) diff --git a/pages_teacher/teacher_teachers/components/audiology.vue b/pages_teacher/teacher_teachers/components/audiology.vue index fc50646..d25bd45 100644 --- a/pages_teacher/teacher_teachers/components/audiology.vue +++ b/pages_teacher/teacher_teachers/components/audiology.vue @@ -9,36 +9,42 @@ </view> <view class="substance"> <!-- 渲染Text --> - <text :class="{ 'active': itemActive[item.id] === TextIndex }" v-for="(TextItem,TextIndex) in item.tests" :key="TextIndex" - @click="Bages_addActive(TextIndex,item.id) "> + <text :class="{ 'active': itemActive[item.id] === TextIndex }" + v-for="(TextItem,TextIndex) in item.tests" :key="TextIndex" + @click="Bages_addActive(TextIndex,item.id) "> {{TextItem.name}} </text> </view> <!-- 渲染part --> <view v-for="(TextItem,TextIndex) in item.tests" :key="TextIndex"> - <view v-for="(partitem,partindex) in TextItem.parts" :key="partindex" v-if="itemActive[item.id] === TextIndex"> + <view v-for="(partitem,partindex) in TextItem.parts" :key="partindex" + v-if="itemActive[item.id] === TextIndex"> <view> <view class="Part1"> <view class="imaflex" @click="icon(partitem.id)"> <!-- part前面的图表 --> <view class="image"> - <image src="http://tmp/IFVuR12hLLNO034931f24322ab271b1f57fdf626bcbf.png" mode="" v-if="image"></image> - <image src="http://tmp/8OOgvfEpdnT2e4e421b97006c70b30a9df99e51a6df1.png" mode="" v-else></image> + <image src="http://tmp/IFVuR12hLLNO034931f24322ab271b1f57fdf626bcbf.png" mode="" + v-if="image"></image> + <image src="http://tmp/8OOgvfEpdnT2e4e421b97006c70b30a9df99e51a6df1.png" mode="" + v-else></image> </view> <view>{{partitem.name}}</view> </view> <!-- part的多选框 --> <view> - <u-checkbox @change="checkboxChange(partitem,$event)" v-model="partitem.checked" shape="circle"></u-checkbox> + <u-checkbox @change="checkboxChange(partitem,$event)" v-model="partitem.checked" + shape="circle"></u-checkbox> </view> </view> <view class="partshow" v-if="tk==partitem.id"> <view class="Part2" v-for="(quesitem,quesindex) in partitem.modules" :key="quesindex"> <view class="imaflex"> - <view>{{quesitem.typeText}}</view> + <view>{{quesitem.number}} {{quesitem.typeText}}</view> </view> <view> - <u-checkbox @change="checkoutzj(quesitem,$event)" v-model="quesitem.subsets"></u-checkbox> + <u-checkbox @change="handleCheckboxChange(quesitem)" + v-model="quesitem.subsets"></u-checkbox> </view> </view> </view> @@ -59,6 +65,7 @@ itemActive: {}, image: true, tk: null, + selectwrite: [], } }, @@ -66,78 +73,165 @@ this.hearing() }, methods: { - // 听力调取接口渲染 + updatawrite(data){ + this.selectwrite=data + + }, hearing() { - this.$u.get('https://api.admin-v2.langsi.online/admin-api/ielts/paper/list', { - classify: 1 - }).then(res => { - this.listHearing = res.data - let activeindex = {} - let arr = res.data - for (let parper of arr) { - let test = parper.tests[0] - activeindex[parper.id] = 0 - } - this.itemActive = activeindex - }) + this.$u + .get("https://api.admin-v2.langsi.online/admin-api/ielts/paper/list", { + classify: 1, + }) + .then((res) => { + this.listHearing = res.data; + let activeindex = {}; + let arr = res.data; + for (let parper of arr) { + let test = parper.tests[0]; + activeindex[parper.id] = 0; + } + this.itemActive = activeindex; + this.updateSubsetsInListHearing() + console.log(this.listHearing, "this.itemActivethis.itemActive"); + }); }, - // 听力test点击事件 Bages_addActive(TextIndex, id) { - this.itemActive[id] = TextIndex - this.$forceUpdate() + this.itemActive[id] = TextIndex; + this.$forceUpdate(); }, - // 点击变化图表 icon(id) { - this.image = !this.image - this.tk = id + this.image = !this.image; + this.tk = id; if (this.image == false) { - this.tk = id - }else { - this.tk = null + this.tk = id; + } else { + this.tk = null; } }, - checkboxChange(parat, e) { + checkboxChange(partitem, e) { if (e.value) { - this.checked.push(parat.id) - const allItemsNoSubsets = parat.modules.every(item => !('subsets' in item)); - parat.modules.forEach(item=>{ - this.$set(item, 'subsets', item.id); - item.subsets = item.id; - this.subsets.push(item.id) - console.log( item.subsets) - }) - + this.listHearing.forEach((paper) => { + paper.tests.forEach((test, testIndex) => { + test.parts.forEach((part) => { + if (part.id === partitem.id) { + part.modules.forEach((quesitem, quesIndex) => { + this.addToSelectWrite( + quesitem, + partitem.id, + testIndex + 1, + paper.title + ); + }); + } + }); + }); + }); } else { - let index = this.checked.indexOf(parat.id); - if (index !== -1) { - this.checked.splice(index, 1); - parat.modules.forEach(item=>{ - this.$delete(item, 'subsets'); - const index = this.subsets.indexOf(item.id); - if (index !== -1) { - this.subsets.splice(index, 1); - } - }) - - } + partitem.modules.forEach((quesitem) => { + this.removeFromSelectWrite(quesitem.id); + }); } - console.log(this.checked,'part数组') - this.$forceUpdate() + this.$forceUpdate(); + console.log(this.selectwrite, "selectwriteselectwrite"); + console.log(this.listHearing, "this.listHearing"); + // 在这里执行额外的操作,遍历 selectwrite 中的每一项,更新 listHearing 中的 subsets + this.updateSubsetsInListHearing(); + this.$parent.updatalisten(this.selectwrite) }, - checkoutzj(quesitem, id) { - if (id.value) { - this.subsets.push(quesitem.id) - console.log(quesitem) - } else { - let index2 = this.subsets.indexOf(quesitem.id); - if (index2 !== -1) { - this.subsets.splice(index2, 1); - } + handleCheckboxChange(quesitems) { + const existingIndex = this.selectwrite.findIndex(item => item.id === quesitems.id); + + if (existingIndex !== -1) { + // 如果已存在,将 subsets 设为 false,并清除该项 + this.selectwrite.splice(existingIndex, 1); + quesitems.subsets = false; + } else { + // 如果不存在,添加该项,并将 subsets 设为 true + this.listHearing.forEach((paper) => { + paper.tests.forEach((test, testIndex) => { + test.parts.forEach((part) => { + part.modules.forEach((quesitem, quesIndex) => { + if (quesitem.id == quesitems.id) { + this.addToSelectWrite( + quesitems, + quesitems.id, // 使用 quesitem 的 id + testIndex + 1, // 使用内层循环的 testIndex + paper.title // 使用 quesitem 的 paperTitle + ); + } + }); + }); + }); + }); + quesitems.subsets = true; + } + + console.log(this.selectwrite, 'selectwriteselectwrite'); + this.updateSubsetsInListHearing() + this.$parent.updatalisten(this.selectwrite) + }, + + + + // 在这里添加一个新的方法,用于更新 listHearing 中的 subsets + updateSubsetsInListHearing() { + this.listHearing.forEach((paper) => { + paper.tests.forEach((test) => { + test.parts.forEach((part) => { + part.modules.forEach((quesitem) => { + const selected = this.selectwrite.find((item) => { + return item.id === quesitem.id; + }); + if (selected) { + quesitem.subsets = true; + } else { + quesitem.subsets = false; + } + }); + }); + }); + }); + + // 额外的逻辑,遍历 listHearing 中的每一个 part,判断是否全部 modules 的 subsets 都为 true + this.listHearing.forEach((paper) => { + paper.tests.forEach((test) => { + test.parts.forEach((part) => { + part.checked = part.modules.every((quesitem) => quesitem.subsets); + }); + }); + }); + }, + + // 添加信息到selectwrite数组 + addToSelectWrite(quesitem, partId, testIndex, paperTitle) { + // Split the guideText into words + const words = quesitem.guideText.split(/\s+/); + + // Take the first five words excluding "Complete" + const questionname = words.slice(0, 5).filter(word => word !== "Complete").join(' '); + + const item = { + id: quesitem.id, + paperId: quesitem.paperId, + papername: paperTitle, + partId: partId, + testId: quesitem.testId, + testname: `Test ${testIndex}`, + typeName: quesitem.typeText, + questionname: questionname, + }; + + this.selectwrite.push(item); + }, + + removeFromSelectWrite(itemId) { + const index = this.selectwrite.findIndex((item) => item.id === itemId); + if (index !== -1) { + this.selectwrite.splice(index, 1); } - console.log(this.subsets,'题型数组') - } - } + }, + }, } </script> @@ -200,4 +294,4 @@ height: 20rpx; margin-right: 10rpx; } -</style> +</style> \ No newline at end of file diff --git a/pages_teacher/teacher_teachers/components/compose.vue b/pages_teacher/teacher_teachers/components/compose.vue index 0bcbe65..9e8cb11 100644 --- a/pages_teacher/teacher_teachers/components/compose.vue +++ b/pages_teacher/teacher_teachers/components/compose.vue @@ -71,7 +71,28 @@ export default { created() { this.getCompose() }, + methods: { + updatawrite(data){ + this.selectwrite=data + + }, + updateSubsetArr() { + // 遍历 this.transformedData 中的每个项 + for (const item of this.transformedData) { + // 遍历 this.selectwrite 中的每个对象 + for (const selectedItem of this.selectwrite) { + const { id, test, task } = selectedItem; + + // 检查 task1 中的 id 是否匹配 + if (item[test] && item[test][task] && String(item[test][task].id) === id) { + this.$set(item[test][task], 'subsetArr', true); + } else { + this.$set(item[test][task], 'subsetArr', false); + } + } + } + }, //写作接口 getCompose() { this.$u.post('https://api.admin-v2.langsi.online/admin-api/writing/all/search', this.comsapi).then(res => { @@ -81,8 +102,9 @@ export default { } this.transformedData = arr this.orgtransformedData = JSON.parse(JSON.stringify(arr)); - // let json = JSON.stringify(this.transformedData) - console.log(this.transformedData, 'this.transformedData'); + let json = JSON.stringify(this.transformedData) + // console.log(json, 'this.transformedData'); + this.updateSubsetArr() }) }, textClick(item, text) { diff --git a/pages_teacher/teacher_teachers/components/reading.vue b/pages_teacher/teacher_teachers/components/reading.vue index c550597..9196442 100644 --- a/pages_teacher/teacher_teachers/components/reading.vue +++ b/pages_teacher/teacher_teachers/components/reading.vue @@ -9,36 +9,42 @@ </view> <view class="substance"> <!-- 渲染Text --> - <text :class="{ 'active': itemActive[item.id] === TextIndex }" v-for="(TextItem,TextIndex) in item.tests" :key="TextIndex" - @click="Bages_addActive(TextIndex,item.id) "> + <text :class="{ 'active': itemActive[item.id] === TextIndex }" + v-for="(TextItem,TextIndex) in item.tests" :key="TextIndex" + @click="Bages_addActive(TextIndex,item.id) "> {{TextItem.name}} </text> </view> <!-- 渲染part --> <view v-for="(TextItem,TextIndex) in item.tests" :key="TextIndex"> - <view v-for="(partitem,partindex) in TextItem.parts" :key="partindex" v-if="itemActive[item.id] === TextIndex"> + <view v-for="(partitem,partindex) in TextItem.parts" :key="partindex" + v-if="itemActive[item.id] === TextIndex"> <view> <view class="Part1"> <view class="imaflex" @click="icon(partitem.id)"> <!-- part前面的图表 --> <view class="image"> - <image src="http://tmp/IFVuR12hLLNO034931f24322ab271b1f57fdf626bcbf.png" mode="" v-if="image"></image> - <image src="http://tmp/8OOgvfEpdnT2e4e421b97006c70b30a9df99e51a6df1.png" mode="" v-else></image> + <image src="http://tmp/IFVuR12hLLNO034931f24322ab271b1f57fdf626bcbf.png" mode="" + v-if="image"></image> + <image src="http://tmp/8OOgvfEpdnT2e4e421b97006c70b30a9df99e51a6df1.png" mode="" + v-else></image> </view> <view>{{partitem.name}}</view> </view> <!-- part的多选框 --> <view> - <u-checkbox @change="checkboxChange(partitem,$event)" v-model="partitem.checked" shape="circle"></u-checkbox> + <u-checkbox @change="checkboxChange(partitem,$event)" v-model="partitem.checked" + shape="circle"></u-checkbox> </view> </view> <view class="partshow" v-if="tk==partitem.id"> <view class="Part2" v-for="(quesitem,quesindex) in partitem.modules" :key="quesindex"> <view class="imaflex"> - <view>{{quesitem.typeText}}</view> + <view>{{quesitem.number}}{{quesitem.typeText}}</view> </view> <view> - <u-checkbox @change="checkoutzj(quesitem,$event)" v-model="quesitem.subsets"></u-checkbox> + <u-checkbox @change="handleCheckboxChange(quesitem)" + v-model="quesitem.subsets"></u-checkbox> </view> </view> </view> @@ -59,6 +65,7 @@ itemActive: {}, image: true, tk: null, + selectwrite: [], } }, @@ -66,6 +73,10 @@ this.hearing() }, methods: { + updatawrite(data){ + this.selectwrite=data + + }, // 听力调取接口渲染 hearing() { this.$u.get('https://api.admin-v2.langsi.online/admin-api/ielts/paper/list', { @@ -79,6 +90,7 @@ activeindex[parper.id] = 0 } this.itemActive = activeindex + this.updateSubsetsInListHearing() }) }, // 听力test点击事件 @@ -92,51 +104,128 @@ this.tk = id if (this.image == false) { this.tk = id - }else { + } else { this.tk = null } }, - checkboxChange(parat, e) { + checkboxChange(partitem, e) { if (e.value) { - this.checked.push(parat.id) - const allItemsNoSubsets = parat.modules.every(item => !('subsets' in item)); - parat.modules.forEach(item=>{ - this.$set(item, 'subsets', item.id); - item.subsets = item.id; - this.subsets.push(item.id) - console.log( item.subsets) - }) - + this.listHearing.forEach((paper) => { + paper.tests.forEach((test, testIndex) => { + test.parts.forEach((part) => { + if (part.id === partitem.id) { + part.modules.forEach((quesitem, quesIndex) => { + this.addToSelectWrite( + quesitem, + partitem.id, + testIndex + 1, + paper.title + ); + }); + } + }); + }); + }); } else { - let index = this.checked.indexOf(parat.id); - if (index !== -1) { - this.checked.splice(index, 1); - parat.modules.forEach(item=>{ - this.$delete(item, 'subsets'); - const index = this.subsets.indexOf(item.id); - if (index !== -1) { - this.subsets.splice(index, 1); - } - }) - - } + partitem.modules.forEach((quesitem) => { + this.removeFromSelectWrite(quesitem.id); + }); } - console.log(this.checked,'part数组') - this.$forceUpdate() + this.$forceUpdate(); + + // 在这里执行额外的操作,遍历 selectwrite 中的每一项,更新 listHearing 中的 subsets + this.updateSubsetsInListHearing(); + this.$parent.updataread(this.selectwrite) }, - checkoutzj(quesitem, id) { - if (id.value) { - this.subsets.push(quesitem.id) - console.log(quesitem) + handleCheckboxChange(quesitems) { + const existingIndex = this.selectwrite.findIndex(item => item.id === quesitems.id); + + if (existingIndex !== -1) { + // 如果已存在,将 subsets 设为 false,并清除该项 + this.selectwrite.splice(existingIndex, 1); + quesitems.subsets = false; } else { - let index2 = this.subsets.indexOf(quesitem.id); - if (index2 !== -1) { - this.subsets.splice(index2, 1); - } + // 如果不存在,添加该项,并将 subsets 设为 true + this.listHearing.forEach((paper) => { + paper.tests.forEach((test, testIndex) => { + test.parts.forEach((part) => { + part.modules.forEach((quesitem, quesIndex) => { + if (quesitem.id == quesitems.id) { + this.addToSelectWrite( + quesitems, + quesitems.id, // 使用 quesitem 的 id + testIndex + 1, // 使用内层循环的 testIndex + paper.title // 使用 quesitem 的 paperTitle + ); + } + }); + }); + }); + }); + quesitems.subsets = true; } - console.log(this.subsets,'题型数组') - } + + console.log(this.selectwrite, 'selectwriteselectwrite'); + this.updateSubsetsInListHearing() + this.$parent.updataread(this.selectwrite) + }, + + + + // 在这里添加一个新的方法,用于更新 listHearing 中的 subsets + updateSubsetsInListHearing() { + this.listHearing.forEach((paper) => { + paper.tests.forEach((test) => { + test.parts.forEach((part) => { + part.modules.forEach((quesitem) => { + const selected = this.selectwrite.find((item) => { + return item.id === quesitem.id; + }); + if (selected) { + quesitem.subsets = true; + } else { + quesitem.subsets = false; + } + }); + }); + }); + }); + + // 额外的逻辑,遍历 listHearing 中的每一个 part,判断是否全部 modules 的 subsets 都为 true + this.listHearing.forEach((paper) => { + paper.tests.forEach((test) => { + test.parts.forEach((part) => { + part.checked = part.modules.every((quesitem) => quesitem.subsets); + }); + }); + }); + }, + + // 添加信息到selectwrite数组 + addToSelectWrite(quesitem, partId, testIndex, paperTitle) { + // Split the guideText into words + + const item = { + id: quesitem.id, + paperId: quesitem.paperId, + papername: paperTitle, + partId: partId, + testId: quesitem.testId, + testname: `Test ${testIndex}`, + typeName: quesitem.typeText, + questionname: quesitem.number, + }; + + this.selectwrite.push(item); + }, + + removeFromSelectWrite(itemId) { + const index = this.selectwrite.findIndex((item) => item.id === itemId); + if (index !== -1) { + this.selectwrite.splice(index, 1); + } + }, } } </script> @@ -200,4 +289,4 @@ height: 20rpx; margin-right: 10rpx; } -</style> +</style> \ No newline at end of file diff --git a/pages_teacher/teacher_teachers/teacher_addOperation.vue b/pages_teacher/teacher_teachers/teacher_addOperation.vue index 8ed530b..350d9a2 100644 --- a/pages_teacher/teacher_teachers/teacher_addOperation.vue +++ b/pages_teacher/teacher_teachers/teacher_addOperation.vue @@ -118,73 +118,94 @@ <view class="view_tubiao"> <view class="view_title">作业安排</view> </view> - <view> - <view class="Ielts">IELTS 18</view> + + </view> + <view> + <view v-for="(item,index) in selectreadlist" :key="index"> + <view class="Ielts">{{item.papername}}</view> <view - style="background-color: #fff; padding: 32rpx 40rpx; border-radius: 20rpx 20rpx 20rpx 20rpx;"> + style="background-color: #fff; padding: 32rpx 40rpx;border-radius: 20rpx 20rpx 20rpx 20rpx;"> <u-time-line> - <u-time-line-item nodeTop="2"> + <u-time-line-item nodeTop="2" + v-for="(items,indexs) in item.message" :key="indexs"> <template v-slot:content> <view> - <view style="display: flex;"> - - <view class="Test">Test 2</view> - - <view class="greener">听力</view> - + <view style="display: flex;flex-wrap: nowrap;"> + + <view class="Test" + >{{items.testname}}</view> + + <view class="ellipses">阅读</view> + + </view> <view class="u-order-desc"> - <text>Part 1:多选题</text> - </view> - </view> - </template> - </u-time-line-item> - <u-time-line-item nodeTop="2"> - <template v-slot:content> - <view> - <view style="display: flex;"> - - <view class="Test">Test 2</view> - - <view class="greener">听力</view> - - </view> - <view class="u-order-desc"> - <text>Part 1:多选题</text> - </view> - </view> - </template> - </u-time-line-item> - <u-time-line-item nodeTop="2"> - <template v-slot:content> - <view> - <view style="display: flex;"> - - <view class="Test">Test 2</view> - - <view class="greener">听力</view> - - </view> - <view class="u-order-desc"> - <text>Part 1:多选题</text> + <text>{{items.questionname}} {{items.typeName}}</text> </view> </view> </template> </u-time-line-item> + </u-time-line> </view> </view> </view> - <view v-for="(item,index) in selectwritelist" :key="index"> - <view class="Ielts">{{item.examName}}</view> - <view style="background-color: #fff; padding: 32rpx 40rpx;border-radius: 20rpx 20rpx 20rpx 20rpx;" v-for="(items,indexs) in item.message" :key="indexs"> - <view style="display: flex; align-items: center;"> - <view class="yuandi"></view> - <view class="Test">{{items.test}}</view> - <view class="ellipses">写作</view> + <view> + <view v-for="(item,index) in selectlistenlist" :key="index"> + <view class="Ielts">{{item.papername}}</view> + <view + style="background-color: #fff; padding: 32rpx 40rpx;border-radius: 20rpx 20rpx 20rpx 20rpx;"> + <u-time-line> + <u-time-line-item nodeTop="2" + v-for="(items,indexs) in item.message" :key="indexs"> + <template v-slot:content> + <view> + <view style="display: flex;flex-wrap: nowrap;"> + + <view class="Test" + >{{items.testname}}</view> + + <view class="greener">听力</view> + + + </view> + <view class="u-order-desc"> + <text>{{items.questionname}} {{items.typeName}}</text> + </view> + </view> + </template> + </u-time-line-item> + + </u-time-line> </view> - <view class="u-order-desc"> - <text>{{items.task}}</text> + </view> + </view> + <view> + <view v-for="(item,index) in selectwritelist" :key="index"> + <view class="Ielts">{{item.examName}}</view> + <view + style="background-color: #fff; padding: 32rpx 40rpx;border-radius: 20rpx 20rpx 20rpx 20rpx;"> + <u-time-line> + <u-time-line-item nodeTop="2" + v-for="(items,indexs) in item.message" :key="indexs"> + <template v-slot:content> + <view> + <view style="display: flex;flex-wrap: nowrap;"> + + <view class="Test" + >{{items.test}}</view> + + <view class="ellipses" style="background: rgba(63,122,242,0.2);color: #3F7AF2;">写作</view> + + </view> + <view class="u-order-desc"> + <text>{{items.task}}</text> + </view> + </view> + </template> + </u-time-line-item> + + </u-time-line> </view> </view> </view> @@ -317,7 +338,9 @@ export default { selectwrite: [], selectlisten: [], selectread: [], - selectwritelist: [] + selectwritelist: [], + selectlistenlist: [], + selectreadlist: [], } }, @@ -365,8 +388,8 @@ export default { this.selectwrite = selectforwork.selectwrite this.selectlisten = selectforwork.selectlisten this.selectread = selectforwork.selectread - this.selectwrite = selectforwork.selectwrite; - + // this.selectwrite = selectforwork.selectwrite; + //处理写作数据 const groupedItems = {}; this.selectwrite.forEach(item => { @@ -385,11 +408,66 @@ export default { id: item.id }); }); - - // Convert groupedItems object to an array + + this.selectwritelist = Object.values(groupedItems); + //处理听力数据 + const groupedItems1 = {}; + + this.selectlisten.forEach(item => { + const papername = item.papername; + + if (!groupedItems1[papername]) { + groupedItems1[papername] = { + papername: papername, + message: [] + }; + } + + groupedItems1[papername].message.push({ + id: item.id, + paperId: item.paperId, + // papername: paperTitle, + partId: item.partId, + testId: item.testId, + testname: item.testname, + typeName: item.typeName, + questionname:item. questionname, + }); + }); + + // Convert groupedItems object to an array + this.selectlistenlist = Object.values(groupedItems1); + + const groupedItems2 = {}; + + this.selectread.forEach(item => { + const papername = item.papername; + + if (!groupedItems2[papername]) { + groupedItems2[papername] = { + papername: papername, + message: [] + }; + } + + groupedItems2[papername].message.push({ + id: item.id, + paperId: item.paperId, + // papername: paperTitle, + partId: item.partId, + testId: item.testId, + testname: item.testname, + typeName: item.typeName, + questionname:item. questionname, + }); + }); + + // Convert groupedItems object to an array + this.selectreadlist = Object.values(groupedItems2); - console.log(this.selectwritelist, 'selectwritelist'); + console.log(this.selectreadlist, 'this.selectread'); + console.log(this.selectlistenlist, 'this.selectlisten'); // Remove duplicates from this.classinfo // this.stuinfo = this.stuinfo.filter(item => !selectedstuInfo.some(selectedItem => selectedItem.id === item.id)); @@ -400,52 +478,16 @@ export default { }, methods: { - mergeObjectsByExamName(existingArray, newArray) { - const mergedArray = []; - - newArray.forEach(newObj => { - const existingObjIndex = existingArray.findIndex(existingObj => existingObj.examName === newObj.examName); - - if (existingObjIndex !== -1) { - // 如果存在相同的 examName,则合并对象 - const existingObj = existingArray[existingObjIndex]; - existingObj.message.push({ - test: newObj.test, - task: newObj.task, - id: newObj.id, - // 其他属性... - }); - - // 更新数组中的对象 - existingArray[existingObjIndex] = existingObj; - } else { - // 如果不存在相同的 examName,则直接添加新对象 - mergedArray.push({ - examName: newObj.examName, - message: [{ - test: newObj.test, - task: newObj.task, - id: newObj.id, - // 其他属性... - }], - // 其他属性... - }); - } - }); - - // 添加 existingArray 中未处理的对象 - existingArray.forEach(existingObj => { - const existingObjIndex = mergedArray.findIndex(obj => obj.examName === existingObj.examName); - if (existingObjIndex === -1) { - mergedArray.push(existingObj); - } - }); - - return mergedArray; - }, + addwork() { + const dataToSave = { + selectspeak: this.selectspeak, + selectwrite: this.selectwrite, + selectlisten: this.selectlisten, + selectread: this.selectread + }; uni.navigateTo({ - url: "/pages_teacher/teacher_teachers/teacher_writeadd?classinfo=" + encodeURIComponent(JSON.stringify(this.classinfo)) + url: "/pages_teacher/teacher_teachers/teacher_writeadd?dataToSave=" + encodeURIComponent(JSON.stringify(dataToSave)) }).then(res => { }).catch(err => { diff --git a/pages_teacher/teacher_teachers/teacher_writeadd.vue b/pages_teacher/teacher_teachers/teacher_writeadd.vue index 95eb75c..b4bb3c5 100644 --- a/pages_teacher/teacher_teachers/teacher_writeadd.vue +++ b/pages_teacher/teacher_teachers/teacher_writeadd.vue @@ -226,15 +226,15 @@ <!-- 写作 --> <swiper-item> - <compose></compose> + <compose ref="compose"></compose> </swiper-item> <!--听力 --> <swiper-item> - <audiology></audiology> + <audiology ref="audiology"></audiology> </swiper-item> <!-- 阅读 --> <swiper-item> - <reading></reading> + <reading ref="reading"></reading> </swiper-item> </swiper> </view> @@ -282,7 +282,7 @@ export default { // 下拉框的v-if布尔值 radioValue: '', part1: true, - current: 1, + current: 0, search: true, listType: [], idList: [], @@ -341,16 +341,39 @@ export default { reading, compose }, - created() { + onShow() { this.getList() }, - + onLoad(option) { + + const dataToSave =JSON.parse(decodeURIComponent(option.dataToSave)) + + this.selectspeak=dataToSave.selectspeak + this.selectwrite=dataToSave.selectwrite + this.selectlisten=dataToSave.selectlisten + this.selectread=dataToSave.selectread + + this.$refs.compose.updatawrite(this.selectwrite) + this.$refs.audiology.updatawrite(this.selectlisten) + this.$refs.reading.updatawrite(this.selectread) + this.calculateTotalLength() + }, methods: { updatawrite(data){ this.selectwrite=data console.log(this.selectwrite, ' this.selectwrite this.selectwrite'); this.calculateTotalLength() }, + updataread(data){ + this.selectread=data + console.log(this.selectread, ' this.selectwrite this.selectwrite'); + this.calculateTotalLength() + }, + updatalisten(data){ + this.selectlisten=data + console.log(this.selectlisten, ' this.selectwrite this.selectwrite'); + this.calculateTotalLength() + }, submessage(){ const dataToSave = { selectspeak: this.selectspeak,