Browse Source

自动建组

zs 2 years ago
parent
commit
5b8195362e

+ 70 - 18
pagesMatch/matchAdmin/mtgroup/auto.js

@@ -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' })

+ 10 - 0
pagesMatch/matchAdmin/mtgroup/auto.less

@@ -8,6 +8,10 @@
         width: 100vw;
         text-align: center;
         margin: 2vw 0;
+
+        .button {
+            margin: 0 0 0 2vw;
+        }
     }
 
     .two {
@@ -76,6 +80,12 @@
             flex-grow: 1;
             color: var(--blackColor);
 
+            .label {
+                display: flex;
+                flex-direction: row;
+                margin: 0 0 1vw 0;
+            }
+
         }
     }
 

+ 27 - 2
pagesMatch/matchAdmin/mtgroup/auto.wxml

@@ -1,7 +1,8 @@
 <mobile-main frameStyle="{{frameStyle}}" bind:back="back">
     <view slot="info" class="container main">
         <view class="one">
-            <button type="primary" size="mini" bindtap="toSet">设置条件</button>
+            <button class="button" type="primary" size="mini" bindtap="toSet">设置条件</button>
+            <button class="button" type="primary" size="mini" bindtap="toSave">保存全部</button>
         </view>
         <view class="two">
             <view class="list" wx:for="{{list}}" wx:key="index">
@@ -12,7 +13,7 @@
                 </view>
                 <view class="person">
                     <view class="tagname" wx:for="{{item.person}}" wx:for-item="tag" wx:key="tag">
-                        {{'张爽'}} <text class="iconfont icon-shanchu" bindtap="toDel" data-name="{{item.name}}" data-tag="{{tag}}"></text>
+                        {{tag.user_name}} <text class="iconfont icon-shanchu" bindtap="toDel" data-name="{{item.name}}" data-tag="{{tag}}"></text>
                     </view>
                 </view>
             </view>
@@ -60,6 +61,30 @@
         </view>
         <view class="dialog_1" wx:if="{{dialog.type=='2'}}">
             <form catchsubmit="personSubmit">
+                <view class="content" style="display: none;">
+                    <view class="label">赛事名称:</view>
+                    <view class="value">
+                        <input type="text" name="match_id" value="{{form.match_id}}" />
+                    </view>
+                </view>
+                <view class="content" style="display: none;">
+                    <view class="label">赛事组别:</view>
+                    <view class="value">
+                        <input type="text" name="group_id" value="{{form.group_id}}" />
+                    </view>
+                </view>
+                <view class="content" style="display: none;">
+                    <view class="label">组内项目:</view>
+                    <view class="value">
+                        <input type="text" name="project_id" value="{{form.project_id}}" />
+                    </view>
+                </view>
+                <view class="content" style="display: none;">
+                    <view class="label">人员类型:</view>
+                    <view class="value">
+                        <input name="person_type" value="{{form.person_type}}" placeholder="请输入人员类型" disabled />
+                    </view>
+                </view>
                 <view class="content">
                     <view class="label">组名:</view>
                     <view class="value">

+ 8 - 0
pagesMatch/matchAdmin/mtgroup/auto.wxss

@@ -8,6 +8,9 @@
   text-align: center;
   margin: 2vw 0;
 }
+.main .one .button {
+  margin: 0 0 0 2vw;
+}
 .main .two .list {
   width: 92vw;
   margin: 0 2vw 2vw 2vw;
@@ -63,6 +66,11 @@
   flex-grow: 1;
   color: var(--blackColor);
 }
+.dialog_1 .content .value .label {
+  display: flex;
+  flex-direction: row;
+  margin: 0 0 1vw 0;
+}
 .dialog_1 .btn {
   text-align: center;
   margin: 3vw 0;

+ 1 - 1
pagesMatch/system/index.js

@@ -49,7 +49,7 @@ Page({
                     const aee = await app.$get(`/user/${arr.data.user_id}`);
                     if (aee.errcode == '0') { arr.data.user_id = aee.data; }
                     that.setData({ user: arr.data })
-                    let btnData = match_menu.find((i) => i.type == arr.data.type);
+                    let btnData = match_menu.find((i) => i.type == '1');
                     that.setData({ list: [...btnData.menu, ...school_sysmenu] })
                 }
                 else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }); }