|
@@ -4,13 +4,19 @@ Page({
|
|
|
data: {
|
|
|
frameStyle: { useTop: true, name: '信息维护', leftArrow: true, useBar: false },
|
|
|
form: {},
|
|
|
+ //项目类别
|
|
|
typeList: [],
|
|
|
- genderList: []
|
|
|
+ //性别
|
|
|
+ genderList: [],
|
|
|
+ // 比赛
|
|
|
+ matchList: [],
|
|
|
+ // 赛事分组
|
|
|
+ groupList: []
|
|
|
},
|
|
|
initValidate() {
|
|
|
- const rules = { name: { required: true }, type: { required: true }, age: { required: false }, gender: { required: false }, num: { required: false }, explain: { required: false } }
|
|
|
+ const rules = { name: { required: true }, type: { required: true }, match_name: { required: true }, group_name: { required: true }, age: { required: false }, gender: { required: false }, num: { required: false }, explain: { required: false } }
|
|
|
// 验证字段的提示信息,若不传则调用默认的信息
|
|
|
- const messages = { name: { required: '未输入名称' }, type: { required: '未选择项目类别' }, age: { required: '未输入人数限制' }, gender: { required: '未选择性别限制' }, num: { required: '未输入人数限制' }, explain: { required: '未输入说明' } };
|
|
|
+ const messages = { name: { required: '未输入名称' }, match_name: { required: '未选择比赛赛事' }, group_name: { required: '未选择赛事分组' }, type: { required: '未选择项目类别' }, age: { required: '未输入人数限制' }, gender: { required: '未选择性别限制' }, num: { required: '未输入人数限制' }, explain: { required: '未输入说明' } };
|
|
|
this.WxValidate = new WxValidate(rules, messages)
|
|
|
},
|
|
|
// 返回
|
|
@@ -35,6 +41,24 @@ Page({
|
|
|
that.setData({ 'form.zhType': data.label })
|
|
|
}
|
|
|
},
|
|
|
+ // 比赛名称
|
|
|
+ matchChange: function (e) {
|
|
|
+ const that = this;
|
|
|
+ let data = that.data.matchList[e.detail.value];
|
|
|
+ if (data) {
|
|
|
+ that.setData({ 'form.match_id': data._id })
|
|
|
+ that.setData({ 'form.match_name': data.name })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 赛事分组
|
|
|
+ groupChange: function (e) {
|
|
|
+ const that = this;
|
|
|
+ let data = that.data.groupList[e.detail.value];
|
|
|
+ if (data) {
|
|
|
+ that.setData({ 'form.group_id': data._id })
|
|
|
+ that.setData({ 'form.group_name': data.name })
|
|
|
+ }
|
|
|
+ },
|
|
|
//提交
|
|
|
onSubmit: async function (e) {
|
|
|
const that = this;
|
|
@@ -45,8 +69,8 @@ Page({
|
|
|
return false
|
|
|
} else {
|
|
|
let arr;
|
|
|
- if (params._id) { arr = await app.$post(`/matchProject/${params._id}`, params) }
|
|
|
- else { arr = await app.$post(`/matchProject`, params) }
|
|
|
+ if (params._id) { arr = await app.$post(`/matchProject/${params._id}`, params, 'race') }
|
|
|
+ else { arr = await app.$post(`/matchProject`, params, 'race') }
|
|
|
if (arr.errcode == '0') { wx.showToast({ title: `维护信息完成`, icon: 'success', duration: 2000 }); that.back(); }
|
|
|
else wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
|
}
|
|
@@ -70,8 +94,12 @@ Page({
|
|
|
wx.getStorage({
|
|
|
key: 'user',
|
|
|
success: async res => {
|
|
|
+ let match = await app.$get(`/match`, {}, 'race');
|
|
|
+ if (match.errcode == '0') that.setData({ matchList: match.data })
|
|
|
+ let group = await app.$get(`/matchGroup`, {}, 'race');
|
|
|
+ if (group.errcode == '0') that.setData({ groupList: group.data })
|
|
|
if (that.data.id) {
|
|
|
- let arr = await app.$get(`/matchProject/${that.data.id}`);
|
|
|
+ let arr = await app.$get(`/matchProject/${that.data.id}`, 'race');
|
|
|
if (arr.errcode == '0') {
|
|
|
// 项目类别
|
|
|
let type = typeList.find(i => i.value == arr.data.type);
|