|
@@ -15,11 +15,13 @@ Page({
|
|
|
// 小组设置列表
|
|
|
teamList: [],
|
|
|
// 裁判
|
|
|
- coachList: [],
|
|
|
+ refereeList: [],
|
|
|
// 场地
|
|
|
addressList: [],
|
|
|
// 选手
|
|
|
- memberList: []
|
|
|
+ memberList: [],
|
|
|
+ // 赛程状态
|
|
|
+ statusList: []
|
|
|
},
|
|
|
initValidate() {
|
|
|
const rules = { match_id: { required: true }, group_id: { required: true }, project_id: { required: true }, team_id: { required: true }, address_id: { required: true }, referee_id: { required: true }, match_time: { required: true }, player_type: { required: true }, player_one: { required: true }, player_two: { required: true } }
|
|
@@ -34,7 +36,7 @@ Page({
|
|
|
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 });
|
|
|
+ that.setData({ 'form.match_id': data._id, 'form.match_id_name': data.name });
|
|
|
const arr = await app.$get(`/matchGroup`, { match_id: data._id }, 'race');
|
|
|
if (arr.errcode == '0') { that.setData({ groupList: arr.data }) }
|
|
|
}
|
|
@@ -44,7 +46,7 @@ Page({
|
|
|
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 });
|
|
|
+ that.setData({ 'form.group_id': data._id, 'form.group_id_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 }) }
|
|
|
}
|
|
@@ -54,7 +56,7 @@ Page({
|
|
|
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 });
|
|
|
+ that.setData({ 'form.project_id': data._id, 'form.project_id_name': data.name });
|
|
|
const arr = await app.$get(`/matchTeamGroup`, { match_id: data.match_id, group_id: data.group_id, project_id: data._id }, 'race');
|
|
|
if (arr.errcode == '0') { that.setData({ teamList: arr.data }) }
|
|
|
}
|
|
@@ -64,19 +66,12 @@ Page({
|
|
|
const that = this;
|
|
|
let data = that.data.teamList[e.detail.value];
|
|
|
if (data) {
|
|
|
- that.setData({ 'form.team_id': data._id, 'form.team_name': data.name });
|
|
|
+ that.setData({ 'form.team_id': data._id, 'form.team_id_name': data.name });
|
|
|
const arr = await app.$get(`/matchTeamGroup/${data._id}`, {}, 'race');
|
|
|
if (arr.errcode == '0') {
|
|
|
- if (arr.data.person_type == 'User') { that.setData({ 'form.player_type': '0', 'form.type_name': '单打' }) }
|
|
|
- if (arr.data.person_type == 'TeamApply') { that.setData({ 'form.player_type': '1', 'form.type_name': '双打' }) }
|
|
|
- for (const val of arr.data.person) {
|
|
|
- let memberList = [];
|
|
|
- val.map(function (item, index) {
|
|
|
- var member = {}; member['name'] = item.user_name; member['id'] = item; memberList[index] = member
|
|
|
- })
|
|
|
- that.setData({ memberList });
|
|
|
- console.log(that.data.memberList);
|
|
|
- }
|
|
|
+ if (arr.data.person_type == 'User') { that.setData({ 'form.player_type': 'User', 'form.type_name': '单打' }) }
|
|
|
+ if (arr.data.person_type == 'TeamApply') { that.setData({ 'form.player_type': 'TeamApply', 'form.type_name': '双打' }) }
|
|
|
+ that.setData({ memberList: arr.data.person });
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -86,15 +81,15 @@ Page({
|
|
|
const that = this;
|
|
|
let data = that.data.addressList[e.detail.value];
|
|
|
if (data) {
|
|
|
- that.setData({ 'form.address_id': data._id, 'form.address_name': data.name });
|
|
|
+ that.setData({ 'form.address_id': data._id, 'form.address_id_name': data.name });
|
|
|
}
|
|
|
},
|
|
|
// 裁判
|
|
|
- coachChange: async function (e) {
|
|
|
+ refereeChange: async function (e) {
|
|
|
const that = this;
|
|
|
- let data = that.data.coachList[e.detail.value];
|
|
|
+ let data = that.data.refereeList[e.detail.value];
|
|
|
if (data) {
|
|
|
- that.setData({ 'form.coach_id': data._id, 'form.coach_name': data.name });
|
|
|
+ that.setData({ 'form.referee_id': data._id, 'form.referee_id_name': data.name });
|
|
|
}
|
|
|
},
|
|
|
// 确认选择
|
|
@@ -107,7 +102,7 @@ Page({
|
|
|
const that = this;
|
|
|
let data = that.data.memberList[e.detail.value];
|
|
|
if (data) {
|
|
|
- that.setData({ 'form.player_one': data._id, 'form.member_one_name': data.name });
|
|
|
+ that.setData({ 'form.player_one': data.id, 'form.player_one_name': data.name });
|
|
|
}
|
|
|
},
|
|
|
// 选手一
|
|
@@ -115,13 +110,23 @@ Page({
|
|
|
const that = this;
|
|
|
let data = that.data.memberList[e.detail.value];
|
|
|
if (data) {
|
|
|
- that.setData({ 'form.player_two': data._id, 'form.member_two_name': data.name });
|
|
|
+ that.setData({ 'form.player_two': data.id, 'form.player_two_name': data.name });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 选择状态
|
|
|
+ statusChange: function (e) {
|
|
|
+ const that = this;
|
|
|
+ let data = that.data.statusList[e.detail.value];
|
|
|
+ if (data) {
|
|
|
+ that.setData({ 'form.status': data.value, 'form.zhStatus': data.label });
|
|
|
}
|
|
|
},
|
|
|
// 提交保存
|
|
|
onSubmit: async function (e) {
|
|
|
const that = this;
|
|
|
const params = e.detail.value;
|
|
|
+ const form = that.data.form;
|
|
|
+ params.match_time = form.match_time;
|
|
|
if (!this.WxValidate.checkForm(params)) {
|
|
|
const error = this.WxValidate.errorList[0];
|
|
|
wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
|
|
@@ -152,17 +157,20 @@ Page({
|
|
|
const that = this;
|
|
|
const raceuser = that.data.raceuser;
|
|
|
let arr;
|
|
|
+ // 状态
|
|
|
+ arr = await app.$get(`/dict`, { code: 'schedule_status' });
|
|
|
+ if (arr.errcode == '0' && arr.total > 0) that.setData({ statusList: arr.data[0].list });
|
|
|
// 比赛
|
|
|
- arr = await app.$get(`/match`, { belong_id: '630ec0480a92b0a015ccfbe1' }, 'race');
|
|
|
+ arr = await app.$get(`/match`, { belong_id: raceuser._id, status: '2' }, 'race');
|
|
|
if (arr.errcode == '0') that.setData({ matchList: arr.data });
|
|
|
// 场地
|
|
|
- arr = await app.$get(`/matchAddress`, { belong_id: '630ec0480a92b0a015ccfbe1' }, 'race');
|
|
|
+ arr = await app.$get(`/matchAddress`, { belong_id: raceuser._id, is_use: '0' }, 'race');
|
|
|
if (arr.errcode == '0') that.setData({ addressList: arr.data });
|
|
|
// 裁判
|
|
|
arr = await app.$get(`/user`, { type: '2' }, 'race');
|
|
|
if (arr.errcode == '0') {
|
|
|
for (const val of arr.data) { val.name = val.user_id.name }
|
|
|
- that.setData({ coachList: arr.data });
|
|
|
+ that.setData({ refereeList: arr.data });
|
|
|
}
|
|
|
},
|
|
|
// 监听用户是否登录
|
|
@@ -173,32 +181,16 @@ Page({
|
|
|
success: async res => {
|
|
|
that.setData({ raceuser: res.data })
|
|
|
if (that.data.id) {
|
|
|
- if (that.data.id) {
|
|
|
- const arr = await app.$get(`/msgs/${that.data.id}`, {}, 'race');
|
|
|
- if (arr.errcode == '0') {
|
|
|
- let aee;
|
|
|
- // 比赛
|
|
|
- aee = await app.$get(`/match/${arr.data.match_id}`, {}, 'race');
|
|
|
- if (aee.errcode == '0') arr.data.match_name = aee.data.name;
|
|
|
- // 组别
|
|
|
- aee = await app.$get(`/matchGroup/${arr.data.group_id}`, {}, 'race');
|
|
|
- if (aee.errcode == '0') arr.data.project_name = aee.data.name;
|
|
|
- // 项目
|
|
|
- aee = await app.$get(`/matchProject/${arr.data.project_id}`, {}, 'race');
|
|
|
- if (aee.errcode == '0') arr.data.group_name = aee.data.name
|
|
|
- // 小组赛设置
|
|
|
- aee = await app.$get(`/matchTeamGroup/${arr.data.team_id}`, {}, 'race');
|
|
|
- if (aee.errcode == '0') arr.data.team_name = aee.data.name
|
|
|
- // 裁判
|
|
|
- aee = await app.$get(`/user/${arr.data.referee_id}`, {}, 'race');
|
|
|
- if (aee.errcode == '0') arr.data.referee_name = aee.data.name
|
|
|
- // 场地
|
|
|
- aee = await app.$get(`/matchAddress/${arr.data.address_id}`, {}, 'race');
|
|
|
- if (aee.errcode == '0') arr.data.address_name = aee.data.name
|
|
|
- that.setData({ info: arr.data })
|
|
|
- } else {
|
|
|
- wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
|
- }
|
|
|
+ const arr = await app.$get(`/msgs/${that.data.id}`, {}, 'race');
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ // 状态
|
|
|
+ let status = that.data.statusList.find(i => i.value == arr.data.status)
|
|
|
+ if (status) arr.data.zhStatus = status.label;
|
|
|
+ if (arr.data.player_type == 'User') { arr.data.type_name = '单打' }
|
|
|
+ if (arr.data.player_type == 'TeamApply') { arr.data.type_name = '双打' }
|
|
|
+ that.setData({ form: arr.data })
|
|
|
+ } else {
|
|
|
+ wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
|
}
|
|
|
}
|
|
|
},
|