zs 2 anos atrás
pai
commit
7281f75e18

+ 193 - 11
pagesMatch/matchAdmin/mtschedule/add.js

@@ -1,38 +1,220 @@
 const app = getApp();
+import WxValidate from '../../../utils/wxValidate';
 Page({
     data: {
         frameStyle: { useTop: true, name: '赛程信息', leftArrow: true, useBar: false },
+        raceuser: {},
+        id: '',
+        form: {},
+        // 赛事列表
+        matchList: [],
+        // 组别列表
+        groupList: [],
+        // 组内项目列表
+        projectList: [],
+        // 小组设置列表
+        teamList: [],
+        // 裁判
+        coachList: [],
+        // 场地
+        addressList: [],
+        // 选手
+        memberList: []
+    },
+    initValidate() {
+        const rules = { match_id: { required: true }, group_id: { required: true }, project_id: { required: true }, team_id: { required: true }, address_id: { required: true }, referee_id: { required: true }, match_time: { required: true }, player_type: { required: true }, player_one: { required: true }, player_two: { required: true } }
+        // 验证字段的提示信息,若不传则调用默认的信息
+        const messages = { match_id: { required: '比赛赛事' }, group_id: { required: '赛事分组' }, project_id: { required: '组内项目' }, team_id: { required: '小组名称' }, address_id: { required: '场地名称' }, referee_id: { required: '裁判名称' }, match_time: { required: '比赛时间' }, player_type: { required: '选手类型' }, player_one: { required: '选手一' }, player_two: { required: '选手二' } };
+        this.WxValidate = new WxValidate(rules, messages)
     },
     // 返回
     back: function () { wx.navigateBack({ delta: 1 }) },
+    // 赛事
+    matchChange: async function (e) {
+        const that = this;
+        let data = that.data.matchList[e.detail.value];
+        if (data) {
+            that.setData({ 'form.match_id': data._id, 'form.match_name': data.name });
+            const arr = await app.$get(`/matchGroup`, { match_id: data._id }, 'race');
+            if (arr.errcode == '0') { that.setData({ groupList: arr.data }) }
+        }
+    },
+    // 组别
+    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 });
+            const arr = await app.$get(`/matchProject`, { match_id: data.match_id, group_id: data._id }, 'race');
+            if (arr.errcode == '0') { that.setData({ projectList: arr.data }) }
+        }
+    },
+    // 项目
+    projectChange: async function (e) {
+        const that = this;
+        let data = that.data.projectList[e.detail.value];
+        if (data) {
+            that.setData({ 'form.project_id': data._id, 'form.project_name': data.name });
+            const arr = await app.$get(`/matchTeamGroup`, { match_id: data.match_id, group_id: data.group_id, project_id: data._id }, 'race');
+            if (arr.errcode == '0') { that.setData({ teamList: arr.data }) }
+        }
+    },
+    // 小组
+    teamChange: async function (e) {
+        const that = this;
+        let data = that.data.teamList[e.detail.value];
+        if (data) {
+            that.setData({ 'form.team_id': data._id, 'form.team_name': data.name });
+            const arr = await app.$get(`/matchTeamGroup/${data._id}`, {}, 'race');
+            if (arr.errcode == '0') {
+                if (arr.data.person_type == 'User') { that.setData({ 'form.player_type': '0', 'form.type_name': '单打' }) }
+                if (arr.data.person_type == 'TeamApply') { that.setData({ 'form.player_type': '1', 'form.type_name': '双打' }) }
+                for (const val of arr.data.person) {
+                    let memberList = [];
+                    val.map(function (item, index) {
+                        var member = {}; member['name'] = item.user_name; member['id'] = item; memberList[index] = member
+                    })
+                    that.setData({ memberList });
+                    console.log(that.data.memberList);
+                }
+            }
 
+        }
+    },
+    // 场地
+    addressChange: async function (e) {
+        const that = this;
+        let data = that.data.addressList[e.detail.value];
+        if (data) {
+            that.setData({ 'form.address_id': data._id, 'form.address_name': data.name });
+        }
+    },
+    // 裁判
+    coachChange: async function (e) {
+        const that = this;
+        let data = that.data.coachList[e.detail.value];
+        if (data) {
+            that.setData({ 'form.coach_id': data._id, 'form.coach_name': data.name });
+        }
+    },
+    // 确认选择
+    datetimeChange: function (e) {
+        const that = this;
+        that.setData({ [`form.${e.detail.name}`]: e.detail.datetime });
+    },
+    // 选手一
+    oneMemberChange: async function (e) {
+        const that = this;
+        let data = that.data.memberList[e.detail.value];
+        if (data) {
+            that.setData({ 'form.player_one': data._id, 'form.member_one_name': data.name });
+        }
+    },
+    // 选手一
+    twoMemberChange: async function (e) {
+        const that = this;
+        let data = that.data.memberList[e.detail.value];
+        if (data) {
+            that.setData({ 'form.player_two': data._id, 'form.member_two_name': data.name });
+        }
+    },
+    // 提交保存
+    onSubmit: async function (e) {
+        const that = this;
+        const params = e.detail.value;
+        if (!this.WxValidate.checkForm(params)) {
+            const error = this.WxValidate.errorList[0];
+            wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
+            return false
+        } else {
+            let arr;
+            if (that.data.id) { arr = await app.$post(`/msgs/${that.data.id}`, params, 'race'); }
+            else { arr = await app.$post(`/msgs`, 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 })
+        }
+    },
     /**
      * 生命周期函数--监听页面加载
      */
-    onLoad: function (options) { },
-    /**
-     * 生命周期函数--监听页面初次渲染完成
-     */
-    onReady: function () { },
-    /**
-     * 生命周期函数--监听页面显示
-     */
-    onShow: function () {
+    onLoad: async function (options) {
         const that = this;
+        that.setData({ id: options.id || '' })
+        //验证规则函数
+        that.initValidate();
+        // 查询其他信息
+        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: '630ec0480a92b0a015ccfbe1' }, 'race');
+        if (arr.errcode == '0') that.setData({ matchList: arr.data });
+        // 场地
+        arr = await app.$get(`/matchAddress`, { belong_id: '630ec0480a92b0a015ccfbe1' }, 'race');
+        if (arr.errcode == '0') that.setData({ addressList: arr.data });
+        // 裁判
+        arr = await app.$get(`/user`, { type: '2' }, 'race');
+        if (arr.errcode == '0') {
+            for (const val of arr.data) { val.name = val.user_id.name }
+            that.setData({ coachList: arr.data });
+        }
     },
     // 监听用户是否登录
     watchLogin: async function () {
         const that = this;
         wx.getStorage({
             key: 'raceuser',
-            success: async res => { },
+            success: async res => {
+                that.setData({ raceuser: res.data })
+                if (that.data.id) {
+                    if (that.data.id) {
+                        const arr = await app.$get(`/msgs/${that.data.id}`, {}, 'race');
+                        if (arr.errcode == '0') {
+                            let aee;
+                            // 比赛
+                            aee = await app.$get(`/match/${arr.data.match_id}`, {}, 'race');
+                            if (aee.errcode == '0') arr.data.match_name = aee.data.name;
+                            // 组别
+                            aee = await app.$get(`/matchGroup/${arr.data.group_id}`, {}, 'race');
+                            if (aee.errcode == '0') arr.data.project_name = aee.data.name;
+                            // 项目
+                            aee = await app.$get(`/matchProject/${arr.data.project_id}`, {}, 'race');
+                            if (aee.errcode == '0') arr.data.group_name = aee.data.name
+                            // 小组赛设置
+                            aee = await app.$get(`/matchTeamGroup/${arr.data.team_id}`, {}, 'race');
+                            if (aee.errcode == '0') arr.data.team_name = aee.data.name
+                            // 裁判
+                            aee = await app.$get(`/user/${arr.data.referee_id}`, {}, 'race');
+                            if (aee.errcode == '0') arr.data.referee_name = aee.data.name
+                            // 场地
+                            aee = await app.$get(`/matchAddress/${arr.data.address_id}`, {}, 'race');
+                            if (aee.errcode == '0') arr.data.address_name = aee.data.name
+                            that.setData({ info: arr.data })
+                        } else {
+                            wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
+                        }
+                    }
+                }
+            },
             fail: async res => {
                 wx.redirectTo({ url: '/pages/index/index' })
             }
         })
     },
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady: function () { },
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () { },
     /**
      * 页面上拉触底事件的处理函数
      */

+ 6 - 5
pagesMatch/matchAdmin/mtschedule/add.json

@@ -1,6 +1,7 @@
 {
-    "component": true,
-    "usingComponents": {
-      "mobile-main": "/commpents/mobile-frame/index"
-    }
-  }
+  "component": true,
+  "usingComponents": {
+    "mobile-main": "/commpents/mobile-frame/index",
+    "datatime-picker": "/commpents/datetime-picker/index"
+  }
+}

+ 24 - 13
pagesMatch/matchAdmin/mtschedule/add.less

@@ -1,23 +1,34 @@
 @import (css) "/app.wxss";
 
 .main {
-    height: var(--twoHeight);
     background-color: var(--mainColor);
 
     .one {
-        width: 100vw;
-    }
-}
+        .content {
+            display: flex;
+            flex-direction: row;
+            border-bottom: 1px dashed var(--f1Color);
+            padding: 2vw 0;
+            margin: 0 2vw 2vw 2vw;
+
+            .value {
+                flex-grow: 1;
+                color: var(--blackColor);
+
+                textarea {
+                    position: static;
+                    width: 72vw;
+                }
+            }
+        }
 
-.scroll-view {
-    position: absolute;
-    top: 0;
-    left: 0;
-    right: 0;
-    bottom: 0;
+        .btn {
+            text-align: center;
+            margin: 3vw 0;
 
-    .list-scroll-view {
-        display: flex;
-        flex-direction: column;
+            button {
+                margin: 0 2vw;
+            }
+        }
     }
 }

+ 105 - 1
pagesMatch/matchAdmin/mtschedule/add.wxml

@@ -1,7 +1,111 @@
 <mobile-main frameStyle="{{frameStyle}}" bind:back="back">
     <view slot="info" class="container main">
         <view class="one">
-            基本页面
+            <form catchsubmit="onSubmit">
+                <view class="content" style="display: none;">
+                    <view class="label">数据id:</view>
+                    <view class="value">
+                        <input type="text" name="_id" value="{{form._id}}" placeholder="请输入数据id" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">比赛名称:</view>
+                    <view class="value">
+                        <picker mode="selector" bindchange="matchChange" name="match_id" value="{{form.match_id}}" range="{{matchList}}" range-key="name">
+                            <view class="picker">{{form.match_name||'请选择赛事'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">赛事组别:</view>
+                    <view class="value">
+                        <picker mode="selector" bindchange="groupChange" name="group_id" value="{{form.group_id}}" range="{{groupList}}" range-key="name">
+                            <view class="picker">{{form.group_name||'请选择赛事分组'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">组内项目:</view>
+                    <view class="value">
+                        <picker mode="selector" bindchange="projectChange" name="project_id" value="{{form.project_id}}" range="{{projectList}}" range-key="name">
+                            <view class="picker">{{form.project_name||'请选择组内项目'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">小组名称:</view>
+                    <view class="value">
+                        <picker mode="selector" bindchange="teamChange" name="team_id" value="{{form.team_id}}" range="{{teamList}}" range-key="name">
+                            <view class="picker">{{form.team_name||'请选择小组名称'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">场地名称:</view>
+                    <view class="value">
+                        <picker mode="selector" bindchange="addressChange" name="address_id" value="{{form.address_id}}" range="{{addressList}}" range-key="name">
+                            <view class="picker">{{form.address_name||'请选择场地名称'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">裁判名称:</view>
+                    <view class="value">
+                        <picker mode="selector" bindchange="coachChange" name="coach_id" value="{{form.coach_id}}" range="{{coachList}}" range-key="name">
+                            <view class="picker">{{form.coach_name||'请选择裁判名称'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">比赛时间:</view>
+                    <view class="value">
+                        <datatime-picker datetime="{{form.match_time}}" name="match_time" bind:datetimeChange="datetimeChange"></datatime-picker>
+                    </view>
+                </view>
+                <view class="content" style="display: none;">
+                    <view class="label">选手类型:</view>
+                    <view class="value">
+                        <input type="text" name="player_type" value="{{form.player_type}}" placeholder="请输入选手类型" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">选手类型:</view>
+                    <view class="value">
+                        <input type="text" name="type_name" value="{{form.type_name}}" disabled placeholder="请输入选手类型" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">选手一:</view>
+                    <view class="value">
+                        <picker mode="selector" bindchange="oneMemberChange" name="player_one" value="{{form.player_one}}" range="{{memberList}}" range-key="name">
+                            <view class="picker">{{form.member_one_name||'请选择选手一'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">选手一比分:</view>
+                    <view class="value">
+                        <input type="text" name="player_one_score" value="{{form.player_one_score}}" placeholder="请输入选手一比分" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">选手二:</view>
+                    <view class="value">
+                        <picker mode="selector" bindchange="twoMemberChange" name="player_two" value="{{form.player_two}}" range="{{memberList}}" range-key="name">
+                            <view class="picker">{{form.member_two_name||'请选择选手二'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">选手二比分:</view>
+                    <view class="value">
+                        <input type="text" name="player_two_score" value="{{form.player_two_score}}" placeholder="请输入选手一比分" />
+                    </view>
+                </view>
+                <view class="btn">
+                    <button type="primary" size="mini" formType="submit">提交保存</button>
+                </view>
+            </form>
         </view>
     </view>
 </mobile-main>

+ 19 - 12
pagesMatch/matchAdmin/mtschedule/add.wxss

@@ -1,19 +1,26 @@
 @import "/app.wxss";
 .main {
-  height: var(--twoHeight);
   background-color: var(--mainColor);
 }
-.main .one {
-  width: 100vw;
+.main .one .content {
+  display: flex;
+  flex-direction: row;
+  border-bottom: 1px dashed var(--f1Color);
+  padding: 2vw 0;
+  margin: 0 2vw 2vw 2vw;
 }
-.scroll-view {
-  position: absolute;
-  top: 0;
-  left: 0;
-  right: 0;
-  bottom: 0;
+.main .one .content .value {
+  flex-grow: 1;
+  color: var(--blackColor);
 }
-.scroll-view .list-scroll-view {
-  display: flex;
-  flex-direction: column;
+.main .one .content .value textarea {
+  position: static;
+  width: 72vw;
+}
+.main .one .btn {
+  text-align: center;
+  margin: 3vw 0;
+}
+.main .one .btn button {
+  margin: 0 2vw;
 }

+ 7 - 0
pagesMatch/matchAdmin/mtschedule/list.js

@@ -5,6 +5,13 @@ Page({
     },
     // 返回
     back: function () { wx.navigateBack({ delta: 1 }) },
+    // 添加
+    toCommon: function (e) {
+        const that = this;
+        const { item, route } = e.currentTarget.dataset;
+        that.setData({ skip: 0, page: 0, list: [] });
+        wx.navigateTo({ url: `/pagesMatch/${route}?id=${item && item._id ? item._id : ''}` })
+    },
 
     /**
      * 生命周期函数--监听页面加载

+ 1 - 1
pagesMatch/matchAdmin/mtschedule/list.wxml

@@ -5,7 +5,7 @@
                 <input type="text" placeholder="请输入关键词" />
             </view>
             <view class="one_2">
-                <button type="primary" bindtap="toCommon" data-route="match/add">添加</button>
+                <button type="primary" bindtap="toCommon" data-route="matchAdmin/mtschedule/add">添加</button>
             </view>
         </view>
         <view class="two">

+ 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 }); }

+ 2 - 4
project.config.json

@@ -26,7 +26,7 @@
         "checkInvalidKey": true,
         "checkSiteMap": true,
         "uploadWithSourceMap": true,
-        "compileHotReLoad": false,
+        "compileHotReLoad": true,
         "lazyloadPlaceholderEnable": false,
         "useMultiFrameRuntime": true,
         "useApiHook": true,
@@ -45,9 +45,7 @@
         "disableUseStrict": false,
         "minifyWXML": true,
         "showES6CompileOption": false,
-        "useCompilerPlugins": false,
-        "useStaticServer": true,
-        "ignoreUploadUnusedFiles": true
+        "useCompilerPlugins": false
     },
     "compileType": "miniprogram",
     "libVersion": "2.19.4",