|
@@ -1,12 +1,10 @@
|
|
|
const app = getApp();
|
|
|
+import WxValidate from '../../../utils/wxValidate';
|
|
|
Page({
|
|
|
data: {
|
|
|
frameStyle: { useTop: true, name: '自动建组', leftArrow: true, useBar: false },
|
|
|
+ raceuser: {},
|
|
|
list: [],
|
|
|
- total: 0,
|
|
|
- page: 0,
|
|
|
- skip: 0,
|
|
|
- limit: 5,
|
|
|
dialog: { title: '审核申请', show: false, type: '1' },
|
|
|
form: {},
|
|
|
//比赛列表
|
|
@@ -18,6 +16,12 @@ Page({
|
|
|
// 成员
|
|
|
memberList: []
|
|
|
},
|
|
|
+ initValidate() {
|
|
|
+ const rules = { rise: { required: true } }
|
|
|
+ // 验证字段的提示信息,若不传则调用默认的信息
|
|
|
+ const messages = { rise: { required: '取前几' } };
|
|
|
+ this.WxValidate = new WxValidate(rules, messages)
|
|
|
+ },
|
|
|
// 返回
|
|
|
back: function () { wx.navigateBack({ delta: 1 }) },
|
|
|
// 设置条件
|
|
@@ -46,21 +50,20 @@ Page({
|
|
|
}
|
|
|
that.setData({ list })
|
|
|
},
|
|
|
+ //选中成员
|
|
|
checkboxChange(e) {
|
|
|
- const member = this.data.form.person
|
|
|
- const values = e.detail.value
|
|
|
+ const that = this;
|
|
|
+ const member = that.data.memberList;
|
|
|
+ const values = e.detail.value;
|
|
|
for (let i = 0, lenI = member.length; i < lenI; ++i) {
|
|
|
member[i].checked = false
|
|
|
for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
|
|
|
- if (member[i].value === values[j]) {
|
|
|
+ if (member[i].user_id === values[j]) {
|
|
|
member[i].checked = true
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- this.setData({
|
|
|
- 'form.person': member
|
|
|
- })
|
|
|
},
|
|
|
// 赛事
|
|
|
matchChange: async function (e) {
|
|
@@ -90,11 +93,32 @@ Page({
|
|
|
that.setData({ 'form.project_id': data._id, 'form.project_name': data.name });
|
|
|
}
|
|
|
},
|
|
|
+ // 修改
|
|
|
personSubmit: async function (e) {
|
|
|
const that = this;
|
|
|
const params = e.detail.value;
|
|
|
- console.log(params);
|
|
|
+ const form = that.data.form;
|
|
|
+ const list = that.data.list;
|
|
|
+ //选中的成员
|
|
|
+ let member = that.data.memberList.filter(i => i.checked == true)
|
|
|
+ //未选择成员
|
|
|
+ let mem = that.data.memberList.filter(i => i.checked != true)
|
|
|
+ params.person = [...form.person, ...member];
|
|
|
+ if (!this.WxValidate.checkForm(params)) {
|
|
|
+ const error = this.WxValidate.errorList[0];
|
|
|
+ wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ for (const val of list) {
|
|
|
+ if (val.name == form.name) { val.name = params.name; val.rise = params.rise; val.remark = params.remark; val.person = params.person; }
|
|
|
+ }
|
|
|
+ that.setData({ memberList: mem });
|
|
|
+ wx.showToast({ title: `小组赛维护信息完成`, icon: 'success', duration: 2000 });
|
|
|
+ that.toClose();
|
|
|
+ that.watchLogin(list);
|
|
|
+ }
|
|
|
},
|
|
|
+ //自动生成
|
|
|
onSubmit: async function (e) {
|
|
|
const that = this;
|
|
|
const params = e.detail.value;
|
|
@@ -106,15 +130,37 @@ Page({
|
|
|
}
|
|
|
else wx.showToast({ title: `${arr.errmsg}`, icon: 'none', duration: 2000 })
|
|
|
},
|
|
|
+ //保存全部
|
|
|
+ toSave: async function () {
|
|
|
+ const that = this;
|
|
|
+ const list = that.data.list;
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '是否确认保存全部?',
|
|
|
+ async success(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ let arr = await app.$post(`/matchTeamGroup/saveAll`, list, 'race')
|
|
|
+ if (arr.errcode == '0') { wx.showToast({ title: `保存全部完成`, icon: 'success', duration: 2000 }); that.back() }
|
|
|
+ else wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
// 关闭弹框
|
|
|
toClose: function () {
|
|
|
const that = this;
|
|
|
+ that.setData({ form: {} })
|
|
|
that.setData({ dialog: { title: '设置条件', show: false, type: '1' } })
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
- onLoad: function (options) { },
|
|
|
+ onLoad: function (options) {
|
|
|
+ const that = this;
|
|
|
+ //验证规则函数
|
|
|
+ that.initValidate();
|
|
|
+ },
|
|
|
+
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
@@ -122,10 +168,19 @@ Page({
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
- onShow: function () {
|
|
|
+ onShow: async function () {
|
|
|
const that = this;
|
|
|
+ // 查询其他信息
|
|
|
+ await that.searchOther();
|
|
|
// 监听用户是否登录
|
|
|
- that.watchLogin();
|
|
|
+ await that.watchLogin();
|
|
|
+ },
|
|
|
+ searchOther: async function () {
|
|
|
+ const that = this;
|
|
|
+ const raceuser = that.data.raceuser;
|
|
|
+ let arr;
|
|
|
+ arr = await app.$get(`/match`, { belong_id: raceuser._id }, 'race');
|
|
|
+ if (arr.errcode == '0') that.setData({ matchList: arr.data });
|
|
|
},
|
|
|
// 监听用户是否登录
|
|
|
watchLogin: async function (e) {
|
|
@@ -133,10 +188,7 @@ Page({
|
|
|
wx.getStorage({
|
|
|
key: 'raceuser',
|
|
|
success: async res => {
|
|
|
- let arr;
|
|
|
- arr = await app.$get(`/match`, { belong_id: '630ec0480a92b0a015ccfbe1' }, 'race');
|
|
|
- if (arr.errcode == '0') that.setData({ matchList: arr.data });
|
|
|
- that.setData({ list: e });
|
|
|
+ that.setData({ list: e, raceuser: res.data });
|
|
|
},
|
|
|
fail: async res => {
|
|
|
wx.redirectTo({ url: '/pages/index/index' })
|