Commit e844184d authored by wangxuelai's avatar wangxuelai

'选择班级逻辑修改'

parent 09953ae4
......@@ -16,8 +16,11 @@ import {
deepCopy
} from '../../../utilities/index.js';
import {
erpClassListGet,
} from '../../../service/business/common.js';
getMemberMe,
} from '../../../service/common.js';
import {
courseList
} from '../../../service/business/coursemgt.js';
var app = getApp();
Page({
data: {
......@@ -28,7 +31,10 @@ Page({
classes: [],
chooseClasses: [],
classList: [],
courseList: [],
page: 1,
type: 1,
teacherId: 0
},
onLoad: function(options) { // Do some initialize when page load.
const that = this;
......@@ -40,7 +46,7 @@ Page({
sid,
classes: !class_ids ? [] : JSON.parse(decodeURIComponent(class_ids)),
});
this.getClassList();
this.getMyRoleInfo()
},
onReady: function() { // Do something when page ready.
......@@ -54,39 +60,53 @@ Page({
},
// 切换选择班级 start
getMyRoleInfo () {
getMemberMe({
school_id: this.data.sid
}).then((res) => {
const { code, data } = res;
if (code == 200) {
this.setData({
teacherId: data.schoolTeacher.id,
})
this.getClassList();
}
})
},
tabChange(e) {
const { type } = e.currentTarget.dataset;
if (type == this.data.type) {
return;
}
this.setData({
type,
classes: [],
chooseClasses: [],
})
this.getClassList();
},
getClassList() {
let dakarole = LocalStorage.getItem('dakarole');
erpClassListGet({
page: this.data.page,
// perPage: this.data.circlePerpage,
perPage: 200,//重新选择问题,所以这里暂不分页了
let extra = '';
if (this.data.type == 1) {
extra = 'class';
} else if (this.data.type == 2) {
extra = 'class, my_class';
}
courseList({
school_id: this.data.sid,
// my: dakarole==2 ? 1: this.data.my
page: 1,
perPage: 100,
extra,
}).then((res) => {
const {
code,
data
} = res;
if (code != 200) { // 失败的处理
} else {
const { code, data } = res;
if (code == 200) {
this.setData({
classList: data.list,
});
const { chooseClasses } = this.data;
this.data.classes.forEach((ele) => {
const item = data.list.find(e => e.id == ele);
if (item) {
chooseClasses.push({
title: item.title,
id: item.id
})
}
})
this.setData({
chooseClasses
courseList: data.list
})
} else {
}
}).catch((e) => {
})
},
chooseClass (e) {
......
{
"navigationBarTitleText": "新建作业打卡",
"navigationBarTitleText": "选择班级",
"usingComponents": {
"sjd-media-editor": "../../../components/newsjdmediaeditor",
"sound-recording": "../../../components/soundrecording",
......
......@@ -2,18 +2,22 @@
<view class="container">
<view class="themetypebox">
<view class="themetab">
<view class="themetypeitem active">全部班级</view>
<view class="themetypeitem ">只看我的</view>
<view class="themetypeitem {{type==1 ? 'active' : ''}}" data-type="1" bindtap="tabChange">全部班级</view>
<view class="themetypeitem {{type==2 ? 'active' : ''}}" data-type="2" bindtap="tabChange">只看我的</view>
</view>
</view>
<view class="listbox">
<view class="listitem" hover-class="none" hover-stop-propagation="false" wx:for="{{classList}}" wx:key="id" data-item="{{item}}" bindtap="chooseClass">
<view class="classtitle">{{item.title}}</view>
<view class="rightbox">
<view class="teachername">
<text wx:for="{{item.school_teachers}}" wx:key="id" wx:for-item="teacher">{{teacher.nickname}}</text>
<view class="courseitem" wx:for="{{courseList}}" wx:for-item="course" wx:key="id">
<view class="coursetitle">{{course.title}}</view>
<view class="listbox">
<view class="listitem" hover-class="none" hover-stop-propagation="false" wx:for="{{course.classes}}" wx:key="id" data-item="{{item}}" bindtap="chooseClass">
<view class="classtitle">{{item.title}}</view>
<view class="rightbox">
<view class="teachername">
<text wx:for="{{item.school_teachers}}" wx:key="id" wx:for-item="teacher" wx:if="{{teacherId == teacher.id}}" wx:for-index="tindex" class="{{teacherId == teacher.id ? 'my' : ''}}">{{teacher.nickname}}{{item.school_teachers.length > 1 ? '、': ''}}</text>
<text wx:for="{{item.school_teachers}}" wx:key="id" wx:for-item="teacher" wx:if="{{teacherId != teacher.id}}" wx:for-index="tindex" class="{{teacherId == teacher.id ? 'my' : ''}}">{{teacher.nickname}}{{item.school_teachers.length > 1 ? '、': ''}}</text>
</view>
<image class="selectedicon" src="{{imageRoot}}2b/common/{{filter.indexOf(classes, item.id) == -1 ? 'notselect' : 'select'}}.png"></image>
</view>
<image class="selectedicon" src="{{imageRoot}}2b/common/{{filter.indexOf(classes, item.id) == -1 ? 'notselect' : 'select'}}.png"></image>
</view>
</view>
</view>
......
.container {
padding-bottom: 150rpx;
}
.coursetitle {
color: #222222;
font-size: 26rpx;
font-weight: 600;
padding: 0 20rpx;
margin-top: 40rpx;
}
.themetypebox {
/* margin-bottom: 20px; */
background-color: #fff;
......@@ -53,7 +63,7 @@
}
.listitem {
padding: 28rpx 0;
border-top: 1px solid #F1F2F3;
border-bottom: 1px solid #F1F2F3;
}
.teachername {
max-width: 230rpx;
......@@ -61,6 +71,10 @@
text-overflow: ellipsis;
white-space: nowrap;
margin-right: 10rpx;
color: #999999;
}
.teachername .my {
color: #FEA917;
}
.savebtn {
width:630rpx;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment