|
@@ -10,31 +10,85 @@ Page({
|
|
frameStyle: { useTop: true, name: '编排信息管理', leftArrow: true, useBar: false },
|
|
frameStyle: { useTop: true, name: '编排信息管理', leftArrow: true, useBar: false },
|
|
// 主体高度
|
|
// 主体高度
|
|
infoHeight: '',
|
|
infoHeight: '',
|
|
|
|
+ form: {},
|
|
// 比赛id
|
|
// 比赛id
|
|
id: '',
|
|
id: '',
|
|
// 比赛信息
|
|
// 比赛信息
|
|
matchInfo: {},
|
|
matchInfo: {},
|
|
|
|
+ // 参赛团队
|
|
|
|
+ matchteamList: [],
|
|
|
|
+ // 红方数据
|
|
|
|
+ redInfo: {},
|
|
|
|
+ // 蓝方数据
|
|
|
|
+ blueInfo: {},
|
|
},
|
|
},
|
|
//验证必填项
|
|
//验证必填项
|
|
initValidate() {
|
|
initValidate() {
|
|
- const rules = { match_name: { required: true }, }
|
|
|
|
|
|
+ const rules = { red_id: { required: true }, blue_id: { required: true }, date: { required: true }, time: { required: true }, }
|
|
// 验证字段的提示信息,若不传则调用默认的信息
|
|
// 验证字段的提示信息,若不传则调用默认的信息
|
|
- const messages = { match_name: { required: '请输入比赛名称' }, };
|
|
|
|
|
|
+ const messages = { red_id: { required: '选择红方' }, blue_id: { required: '选择蓝方' }, date: { required: '选择日期' }, time: { required: '选择时间' } };
|
|
this.WxValidate = new WxValidate(rules, messages)
|
|
this.WxValidate = new WxValidate(rules, messages)
|
|
},
|
|
},
|
|
back: function () {
|
|
back: function () {
|
|
wx.navigateBack({ url: '/pages/lays/index' })
|
|
wx.navigateBack({ url: '/pages/lays/index' })
|
|
},
|
|
},
|
|
|
|
+ // 选择红方
|
|
|
|
+ redChange: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ let index = e.detail.value;
|
|
|
|
+ let data = that.data.matchteamList[index];
|
|
|
|
+ if (data) {
|
|
|
|
+ that.setData({ 'form.red_id': data._id, 'form.red_name': data.team_name })
|
|
|
|
+ that.setData({ redInfo: data })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 选择蓝方
|
|
|
|
+ blueChange: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ let index = e.detail.value;
|
|
|
|
+ let data = that.data.matchteamList[index];
|
|
|
|
+ if (data) {
|
|
|
|
+ that.setData({ 'form.blue_id': data._id, 'form.blue_name': data.team_name })
|
|
|
|
+ that.setData({ blueInfo: data })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 日期选择
|
|
|
|
+ dateChange: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ that.setData({ 'form.date': e.detail.value });
|
|
|
|
+ that.setData({ 'form.match_time': that.data.form.date + ' ' + that.data.form.time })
|
|
|
|
+ },
|
|
|
|
+ // 时间选择
|
|
|
|
+ timeChange: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ that.setData({ 'form.time': e.detail.value });
|
|
|
|
+ that.setData({ 'form.match_time': that.data.form.date + ' ' + that.data.form.time })
|
|
|
|
+ },
|
|
// 保存信息
|
|
// 保存信息
|
|
- onSubmit: function (e) {
|
|
|
|
|
|
+ onSubmit: async function (e) {
|
|
const that = this;
|
|
const that = this;
|
|
|
|
+ let red = that.data.redInfo;
|
|
|
|
+ let blue = that.data.blueInfo;
|
|
let parmas = e.detail.value;
|
|
let parmas = e.detail.value;
|
|
|
|
+ parmas.red_name = red.team_name;
|
|
|
|
+ parmas.red_logo = red.logo;
|
|
|
|
+ parmas.red_members = red.members;
|
|
|
|
+ parmas.blue_name = blue.team_name;
|
|
|
|
+ parmas.blue_logo = blue.logo;
|
|
|
|
+ parmas.blue_members = blue.members;
|
|
if (!this.WxValidate.checkForm(parmas)) {
|
|
if (!this.WxValidate.checkForm(parmas)) {
|
|
const error = this.WxValidate.errorList[0];
|
|
const error = this.WxValidate.errorList[0];
|
|
wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
|
|
wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
|
|
return false
|
|
return false
|
|
} else {
|
|
} else {
|
|
- console.log(parmas);
|
|
|
|
|
|
+ const arr = await app.$post(`/courtAdmin/api/schedule`, parmas);
|
|
|
|
+ if (arr.errcode === 0) {
|
|
|
|
+ wx.showToast({ title: '保存成功', icon: 'success', duration: 2000 })
|
|
|
|
+ that.back();
|
|
|
|
+ } else {
|
|
|
|
+ wx.showToast({ title: arr.errmsg, icon: 'error', duration: 2000 })
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
/**
|
|
/**
|
|
@@ -42,7 +96,7 @@ Page({
|
|
*/
|
|
*/
|
|
onLoad: function (options) {
|
|
onLoad: function (options) {
|
|
const that = this;
|
|
const that = this;
|
|
- that.setData({ id: '6254da6515156e74edf8bbfc' })
|
|
|
|
|
|
+ that.setData({ id: options.id})
|
|
//验证规则函数
|
|
//验证规则函数
|
|
this.initValidate();
|
|
this.initValidate();
|
|
// 计算高度
|
|
// 计算高度
|
|
@@ -66,24 +120,8 @@ Page({
|
|
that.setData({ 'form.match_id': arr.data._id, 'form.match_name': arr.data.name })
|
|
that.setData({ 'form.match_id': arr.data._id, 'form.match_name': arr.data.name })
|
|
}
|
|
}
|
|
// 参赛团队
|
|
// 参赛团队
|
|
- const aee = await app.$get(`/courtAdmin/api/match`, { match_id: id, status: 1 });
|
|
|
|
- console.log(aee);
|
|
|
|
- // wx.request({
|
|
|
|
- // url: `${app.globalData.publicUrl}/courtAdmin/api/match/${id}`,
|
|
|
|
- // method: 'get',
|
|
|
|
- // data: {},
|
|
|
|
- // success(res) {
|
|
|
|
- // that.setData({ form: res.data.data })
|
|
|
|
- // }
|
|
|
|
- // })
|
|
|
|
- // wx.request({
|
|
|
|
- // url: `${app.globalData.publicUrl}/courtAdmin/api/matchteam`,
|
|
|
|
- // method: 'get',
|
|
|
|
- // data: { match_id: id, status: 1 },
|
|
|
|
- // success(res) {
|
|
|
|
- // that.setData({ cateArray: res.data.data })
|
|
|
|
- // }
|
|
|
|
- // })
|
|
|
|
|
|
+ const aee = await app.$get(`/courtAdmin/api/matchteam`, { match_id: id, status: 1 });
|
|
|
|
+ if (aee.errcode === 0) that.setData({ matchteamList: aee.data })
|
|
},
|
|
},
|
|
fail: res => {
|
|
fail: res => {
|
|
return wx.redirectTo({ url: '/pages/login/index', })
|
|
return wx.redirectTo({ url: '/pages/login/index', })
|