Browse Source

小组赛组设置-手动编组

YY 2 years ago
parent
commit
f5cd757f6f
1 changed files with 25 additions and 67 deletions
  1. 25 67
      pagesMatch/matchAdmin/mtgroup/add.js

+ 25 - 67
pagesMatch/matchAdmin/mtgroup/add.js

@@ -32,17 +32,19 @@ Page({
                 'form.match_id': data._id, 'form.match_name': data.name,
                 'form.group_id': '', 'form.group_name': '', 'form.project_id': '', 'form.project_name': ''
             });
+            const group = await app.$get(`/matchGroup`, { match_id: data._id }, 'race');
+            if (group.errcode == '0') that.setData({ groupList: group.data });
         }
-        that.watchLogin();
     },
     // 选择组别
-    groupChange: function (e) {
+    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, 'form.project_id': '', 'form.project_name': '' })
+            const project = await app.$get(`/matchProject`, { group_id: data._id }, 'race');
+            if (project.errcode == '0') that.setData({ projectList: project.data });
         }
-        that.watchLogin();
     },
     // 选择组内项目
     projectChange: function (e) {
@@ -57,15 +59,8 @@ Page({
     searchUser: async function (e) {
         const that = this;
         const form = that.data.form;
-        // const arr = await app.$get(`/matchSign`, { match_id: form.match_id, group_id: form.group_id, project_id: form.project_id, pay_status: '1' }, 'race');
-        // if (arr.errcode == '0') that.setData({ signList: arr.data });
-        wx.request({
-            url: `http://192.168.1.197:15001/newCourt/race/v2/api/matchTeamGroup/fgps?project_id=${form.project_id}&person_type=${form.person_type}`,
-            success: (res) => {
-                that.setData({ signList: res.data.data });
-            },
-            error: (e) => { },
-        })
+        const arr = await app.$get(`/matchTeamGroup/fgps?project_id=${form.project_id}&person_type=${form.person_type}`, {}, 'race');
+        if (arr.errcode == '0') that.setData({ signList: arr.data });
     },
     // 选择人员
     personChange: function (e) {
@@ -95,21 +90,14 @@ Page({
 
         }
     },
-    /**
-     * 生命周期函数--监听页面加载
-     */
+    // 生命周期函数--监听页面加载
     onLoad: async function (options) {
         const that = this;
         that.setData({ id: options.id || '' })
         //验证规则函数
         that.initValidate();
         // 监听用户是否登录
-        await that.searchOther();
-        // 监听用户是否登录
         await that.watchLogin();
-    },
-    searchOther: function (e) {
-
     },
     /**
      * 生命周期函数--监听页面初次渲染完成
@@ -118,7 +106,7 @@ Page({
     /**
      * 生命周期函数--监听页面显示
      */
-    onShow: async function () {},
+    onShow: async function () { },
 
     // 监听用户是否登录
     watchLogin: async function () {
@@ -126,26 +114,15 @@ Page({
         wx.getStorage({
             key: 'raceuser',
             success: async res => {
-                that.setData({ raceuser: res.data })
                 // 赛事
                 const match = await app.$get(`/match`, { belong_id: res.data._id }, 'race');
                 if (match.errcode == '0') that.setData({ matchList: match.data });
-                // 已选赛事下的赛事组别
-                if (that.data.form.match_id) {
-                    const group = await app.$get(`/matchGroup`, { match_id: that.data.form.match_id }, 'race');
-                    if (group.errcode == '0') that.setData({ groupList: group.data });
-                }
-                // 已选赛事组别下的组别项目
-                if (that.data.form.group_id) {
-                    const project = await app.$get(`/matchProject`, { group_id: that.data.form.group_id }, 'race');
-                    if (project.errcode == '0') that.setData({ projectList: project.data });
-                }
                 if (that.data.id) {
                     const arr = await app.$get(`/matchTeamGroup/${that.data.id}`, {}, 'race');
                     if (arr.errcode == '0') {
                         // 比赛名称
-                        const match = await app.$get(`/match/${arr.data.match_id}`, {}, 'race');
-                        if (match.errcode == '0') arr.data.match_name = match.data.name;
+                        let match = that.data.matchList.find(i => i._id == arr.data.match_id)
+                        if (match) arr.data.match_name = match.name;
                         // 赛事组别
                         const group = await app.$get(`/matchGroup/${arr.data.group_id}`, {}, 'race');
                         if (group.errcode == '0') arr.data.group_name = group.data.name;
@@ -153,24 +130,19 @@ Page({
                         const project = await app.$get(`/matchProject/${arr.data.project_id}`, {}, 'race');
                         if (project.errcode == '0') arr.data.project_name = project.data.name;
                         // 组内人员
-                        wx.request({
-                            url: `http://192.168.1.197:15001/newCourt/race/v2/api/matchTeamGroup/fgps?project_id=${arr.data.project_id}&person_type=${arr.data.person_type}&team_id=${that.data.id}`,
-                            success: (res) => {
+                        const sign = await app.$get(`/matchTeamGroup/fgps?project_id=${arr.data.project_id}&person_type=${arr.data.person_type}&team_id=${that.data.id}`, {}, 'race');
+                        if (sign.errcode == '0') {
+                            for (const val of sign.data) {
                                 if (arr.data.person_type == 'TeamApply') {
-                                    for (const val of res.data.data) {
-                                        let user_name = arr.data.person.find(i => i == val._id);
-                                        if (user_name) val.checked = true;
-                                    }
+                                    let user_name = arr.data.person.find(i => i == val._id);
+                                    if (user_name) val.checked = true;
                                 } else if (arr.data.person_type == 'User') {
-                                    for (const val of res.data.data) {
-                                        let user_name = arr.data.person.find(i => i == val.user_id);
-                                        if (user_name) val.checked = true;
-                                    }
+                                    let user_name = arr.data.person.find(i => i == val.user_id);
+                                    if (user_name) val.checked = true;
                                 }
-                                that.setData({ signList: res.data.data });
-                            },
-                            error: (e) => { },
-                        })
+                            }
+                            that.setData({ signList: sign.data });
+                        }
                         that.setData({ form: arr.data });
                     }
                 }
@@ -180,34 +152,20 @@ Page({
             }
         })
     },
-    /**
-     * 页面上拉触底事件的处理函数
-     */
     /**
      * 生命周期函数--监听页面隐藏
      */
-    onHide: function () {
-
-    },
-
+    onHide: function () {},
     /**
      * 生命周期函数--监听页面卸载
      */
-    onUnload: function () {
-
-    },
-
+    onUnload: function () { },
     /**
      * 页面相关事件处理函数--监听用户下拉动作
      */
-    onPullDownRefresh: function () {
-
-    },
-
+    onPullDownRefresh: function () { },
     /**
      * 用户点击右上角分享
      */
-    onShareAppMessage: function () {
-
-    }
+    onShareAppMessage: function () { }
 })