1、不要 全部项目/全部组别的选项,只能选具体的项目/组别
2、筛选出来的数据要进行排名
This commit is contained in:
parent
625d9d167e
commit
54e0f8a8fd
@ -7,9 +7,9 @@ Page({
|
||||
eventIndex: 0,
|
||||
selectedEventId: '',
|
||||
projects: [],
|
||||
projectNames: ['全部项目'],
|
||||
projectNames: [],
|
||||
projectIndex: 0,
|
||||
groupNames: ['全部组别'],
|
||||
groupNames: [],
|
||||
groupIndex: 0,
|
||||
keyword: '',
|
||||
rows: [],
|
||||
@ -49,7 +49,17 @@ Page({
|
||||
onEventChange(e) {
|
||||
const eventIndex = Number(e.detail.value) || 0;
|
||||
const selected = this.data.events[eventIndex];
|
||||
this.setData({ eventIndex, selectedEventId: selected ? selected.id : '', projectIndex: 0, groupIndex: 0, rows: [], searched: false });
|
||||
this.setData({
|
||||
eventIndex,
|
||||
selectedEventId: selected ? selected.id : '',
|
||||
projects: [],
|
||||
projectNames: [],
|
||||
projectIndex: 0,
|
||||
groupNames: [],
|
||||
groupIndex: 0,
|
||||
rows: [],
|
||||
searched: false
|
||||
});
|
||||
this.loadFilters()
|
||||
.then(() => this.queryScores())
|
||||
.catch((err) => wx.showToast({ title: (err && err.message) || '筛选条件加载失败', icon: 'none' }));
|
||||
@ -59,23 +69,39 @@ Page({
|
||||
if (!this.data.selectedEventId) return Promise.resolve();
|
||||
return competition.fetchScoreFilters(this.data.selectedEventId).then((res) => {
|
||||
const projects = Array.isArray(res && res.projects) ? res.projects : [];
|
||||
const groups = Array.isArray(res && res.groupNames) ? res.groupNames : [];
|
||||
const groupNames = projects[0] && Array.isArray(projects[0].groupNames)
|
||||
? projects[0].groupNames
|
||||
: [];
|
||||
this.setData({
|
||||
projects,
|
||||
projectNames: ['全部项目'].concat(projects.map((item) => item.projectName || item.name || '未命名项目')),
|
||||
projectNames: projects.map((item) => item.projectName || item.name || '未命名项目'),
|
||||
projectIndex: 0,
|
||||
groupNames: ['全部组别'].concat(groups),
|
||||
groupNames,
|
||||
groupIndex: 0
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
onProjectChange(e) {
|
||||
this.setData({ projectIndex: Number(e.detail.value) || 0 });
|
||||
const projectIndex = Number(e.detail.value) || 0;
|
||||
const project = this.data.projects[projectIndex];
|
||||
this.setData({
|
||||
projectIndex,
|
||||
groupNames: project && Array.isArray(project.groupNames) ? project.groupNames : [],
|
||||
groupIndex: 0,
|
||||
rows: [],
|
||||
searched: false,
|
||||
expandedId: ''
|
||||
});
|
||||
},
|
||||
|
||||
onGroupChange(e) {
|
||||
this.setData({ groupIndex: Number(e.detail.value) || 0 });
|
||||
this.setData({
|
||||
groupIndex: Number(e.detail.value) || 0,
|
||||
rows: [],
|
||||
searched: false,
|
||||
expandedId: ''
|
||||
});
|
||||
},
|
||||
|
||||
onKeywordInput(e) {
|
||||
@ -94,11 +120,17 @@ Page({
|
||||
// 拦住重复点击"查询"导致的并发请求;首次加载时 loadEvents 已置 loading=true,
|
||||
// 故必须同时判 searched,否则初次查询会被自己拦掉。
|
||||
if (this.data.loading && this.data.searched) return Promise.resolve();
|
||||
const project = this.data.projects[this.data.projectIndex];
|
||||
const groupName = this.data.groupNames[this.data.groupIndex];
|
||||
if (!this.data.selectedEventId || !project || !groupName) {
|
||||
this.setData({ rows: [], searched: true, loading: false, expandedId: '' });
|
||||
return Promise.resolve();
|
||||
}
|
||||
this.setData({ loading: true, expandedId: '' });
|
||||
return competition.queryScores({
|
||||
eventId: this.data.selectedEventId,
|
||||
projectId: this.data.projectIndex > 0 ? this.data.projects[this.data.projectIndex - 1].projectId : undefined,
|
||||
groupName: this.data.groupIndex > 0 ? this.data.groupNames[this.data.groupIndex] : undefined,
|
||||
projectId: project.projectId,
|
||||
groupName,
|
||||
keyword: this.data.keyword
|
||||
}).then((res) => {
|
||||
this.setData({ rows: (res && res.rows) || [], searched: true });
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
<input class="keyword-input" value="{{keyword}}" placeholder="姓名 / 参赛编号" placeholder-class="placeholder" confirm-type="search" bindinput="onKeywordInput" bindconfirm="onSearch" />
|
||||
<text wx:if="{{keyword}}" class="clear-btn" bindtap="onClearKeyword">×</text>
|
||||
</view>
|
||||
<button class="search-btn" loading="{{loading}}" disabled="{{loading || !selectedEventId}}" bindtap="onSearch">查询成绩</button>
|
||||
<button class="search-btn" loading="{{loading}}" disabled="{{loading || !selectedEventId || !projects.length || !groupNames.length}}" bindtap="onSearch">查询成绩</button>
|
||||
</view>
|
||||
|
||||
<view class="result-header" wx:if="{{searched && !loading}}">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user