|
@@ -5,6 +5,12 @@ Page({
|
|
|
frameStyle: { useTop: true, name: '小组赛管理', leftArrow: true, useBar: false },
|
|
|
dialog: { title: '赛程上分', show: false, type: '1' },
|
|
|
form: {},
|
|
|
+ // 赛事列表
|
|
|
+ matchList: [],
|
|
|
+ // 组别列表
|
|
|
+ groupList: [],
|
|
|
+ // 组内项目列表
|
|
|
+ projectList: [],
|
|
|
list: [],
|
|
|
total: 0,
|
|
|
page: 0,
|
|
@@ -27,6 +33,11 @@ Page({
|
|
|
that.setData({ skip: 0, page: 0, list: [] });
|
|
|
wx.navigateTo({ url: `/pagesMatch/${route}?id=${item && item._id ? item._id : ''}` })
|
|
|
},
|
|
|
+ // 选择赛事
|
|
|
+ toAdd: function (e) {
|
|
|
+ const that = this;
|
|
|
+ that.setData({ dialog: { title: '选择赛事', show: true, type: '2' } })
|
|
|
+ },
|
|
|
// 赛程上分
|
|
|
toScore: function (e) {
|
|
|
const that = this;
|
|
@@ -34,6 +45,40 @@ Page({
|
|
|
that.setData({ form: item })
|
|
|
that.setData({ dialog: { title: '赛程上分', show: true, type: '1' } })
|
|
|
},
|
|
|
+ // 选择赛事
|
|
|
+ matchChange: async function (e) {
|
|
|
+ const that = this;
|
|
|
+ let data = that.data.matchList[e.detail.value];
|
|
|
+ if (data) {
|
|
|
+ that.setData({ 'form.match_id': data._id, 'form.match_name': data.name, });
|
|
|
+ const group = await app.$get(`/matchGroup`, { match_id: data._id }, 'race');
|
|
|
+ if (group.errcode == '0') that.setData({ groupList: group.data });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 选择组别
|
|
|
+ groupChange: async function (e) {
|
|
|
+ const that = this;
|
|
|
+ let data = that.data.groupList[e.detail.value];
|
|
|
+ if (data) {
|
|
|
+ that.setData({ 'form.group_id': data._id, 'form.group_name': data.name });
|
|
|
+ const arr = await app.$get(`/matchProject`, { match_id: data.match_id, group_id: data._id }, 'race');
|
|
|
+ if (arr.errcode == '0') { that.setData({ projectList: arr.data }) }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 选择项目
|
|
|
+ projectChange: async function (e) {
|
|
|
+ const that = this;
|
|
|
+ let data = that.data.projectList[e.detail.value];
|
|
|
+ if (data) {
|
|
|
+ that.setData({ 'form.project_id': data._id, 'form.project_name': data.name });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ toSubmit: function (e) {
|
|
|
+ const that = this
|
|
|
+ const params = e.detail.value;
|
|
|
+ if (params) { that.setData({ skip: 0, page: 0, list: [] }); that.toClose(); that.watchLogin(); }
|
|
|
+ else { wx.showToast({ title: '请选择数据', icon: 'error', duration: 2000 }) }
|
|
|
+ },
|
|
|
// 提交保存
|
|
|
onSubmit: async function (e) {
|
|
|
const that = this;
|
|
@@ -47,9 +92,9 @@ Page({
|
|
|
let arr = await app.$post(`/msgs/${form.id}`, params, 'race');
|
|
|
if (arr.errcode == '0') {
|
|
|
wx.showToast({ title: `上分成功`, icon: 'success', duration: 2000 });
|
|
|
+ that.setData({ skip: 0, page: 0, list: [], form: {} })
|
|
|
+ that.watchLogin();
|
|
|
that.toClose();
|
|
|
- that.setData({ skip: 0, page: 0, list: [] })
|
|
|
- that.watchLogin()
|
|
|
}
|
|
|
else wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
|
}
|
|
@@ -92,8 +137,6 @@ Page({
|
|
|
// 关闭弹框
|
|
|
toClose: function () {
|
|
|
const that = this;
|
|
|
- that.setData({ skip: 0, page: 0, list: [], form: {} })
|
|
|
- that.watchLogin();
|
|
|
that.setData({ dialog: { title: '赛程上分', show: false, type: '1' } })
|
|
|
},
|
|
|
/**
|
|
@@ -125,20 +168,25 @@ Page({
|
|
|
// 监听用户是否登录
|
|
|
watchLogin: async function () {
|
|
|
const that = this;
|
|
|
+ let form = that.data.form;
|
|
|
wx.getStorage({
|
|
|
key: 'raceuser',
|
|
|
success: async res => {
|
|
|
- let info = { skip: that.data.skip, limit: that.data.limit, referee_id: res.data._id };
|
|
|
- let arr = await app.$get(`/msgs`, { ...info }, 'race');
|
|
|
- if (arr.errcode == '0') {
|
|
|
- let list = [...that.data.list, ...arr.data]
|
|
|
- for (const val of list) {
|
|
|
- let status = that.data.statusList.find(i => i.value == val.status)
|
|
|
- if (status) val.zhStatus = status.label;
|
|
|
- }
|
|
|
- that.setData({ list })
|
|
|
- that.setData({ total: arr.total })
|
|
|
- } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
|
|
|
+ let match = await app.$get(`/match`, {}, 'race');
|
|
|
+ if (match.errcode == '0') { that.setData({ matchList: match.data }) }
|
|
|
+ if (form.group_id && form.match_id && form.project_id) {
|
|
|
+ let info = { skip: that.data.skip, limit: that.data.limit, referee_id: res.data._id, group_id: form.group_id, match_id: form.match_id, project_id: form.project_id }
|
|
|
+ let arr = await app.$get(`/msgs`, { ...info }, 'race');
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ let list = [...that.data.list, ...arr.data]
|
|
|
+ for (const val of list) {
|
|
|
+ let status = that.data.statusList.find(i => i.value == val.status)
|
|
|
+ if (status) val.zhStatus = status.label;
|
|
|
+ }
|
|
|
+ that.setData({ list })
|
|
|
+ that.setData({ total: arr.total })
|
|
|
+ } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
|
|
|
+ }
|
|
|
},
|
|
|
fail: async res => {
|
|
|
wx.redirectTo({ url: '/pages/index/index' })
|