Browse Source

淘汰赛

YY 2 năm trước cách đây
mục cha
commit
2a52745fe4

+ 23 - 10
pagesMatch/matchAdmin/elimmatch/add.js

@@ -37,7 +37,9 @@ Page({
         // 场地
         addressList: [],
         // 裁判列表
-        refereeList: []
+        refereeList: [],
+        // 状态列表
+        statusList: [],
     },
     // 返回
     back: function () { wx.navigateBack({ delta: 1 }) },
@@ -71,6 +73,14 @@ Page({
         const that = this;
         that.setData({ [`form.${e.detail.name}`]: e.detail.datetime });
     },
+    // 选择状态
+    statusChange: function (e) {
+        const that = this;
+        let data = that.data.statusList[e.detail.value];
+        if (data) {
+            that.setData({ 'form.status': data.value, 'form.zhStatus': data.label });
+        }
+    },
     //提交查询
     onSubmit: async function (e) {
         const that = this;
@@ -79,7 +89,7 @@ Page({
         form = { ...form, player_one: player.player_one, player_two: player.player_two }
         let arr;
         if (form.id) { arr = await app.$post(`http://192.168.1.197:15001/newCourt/race/v2/api/eliminate/${form.id}`, form, 'race'); }
-        if (arr.errcode == '0') { wx.showToast({ title: `维护信息完成`, icon: 'success', duration: 2000 }); that.toClose(); that.search(); }
+        if (arr.errcode == '0') { wx.showToast({ title: `维护信息完成`, icon: 'success', duration: 2000 }); that.toClose(); that.searchUser(); }
         else wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
     },
     // 关闭弹框
@@ -93,9 +103,6 @@ Page({
      */
     onLoad: async function (options) {
         const that = this
-        // const match_id = '630ec4700a92b0a015ccfd14';
-        // const group_id = "6318277947be96470e849b6a";
-        // const project_id = '631827f047be96470e849bc1';
         that.setData({ match_id: options.match_id, group_id: options.group_id, project_id: options.project_id })
         await this.search();
         await this.searchUser();
@@ -128,7 +135,7 @@ Page({
         const project_id = that.data.project_id;
         const playerList = that.data.playerList;
         let arr;
-        arr = await app.$get(`http://192.168.1.197:15001/newCourt/race/v2/api/eliminate`, { match_id: match_id, group_id: group_id, project_id: project_id });
+        arr = await app.$get(`/eliminate`, { match_id: match_id, group_id: group_id, project_id: project_id },'race');
         if (arr.errcode == '0' && arr.total > 0) {
             for (const val of arr.data) {
                 if (val.player_one) {
@@ -139,6 +146,9 @@ Page({
                     let two = that.data.playerList.find(i => i._id == val.player_two)
                     if (two) val.player_two_name = two.name;
                 }
+                // 状态
+                let status = that.data.statusList.find(i => i.value == val.status)
+                if (status) val.zhStatus = status.label;
             }
             that.setData({ schList: arr.data });
         }
@@ -287,11 +297,14 @@ Page({
                 arr = await app.$get(`/matchAddress`, { belong_id: res.data._id, is_use: '0' }, 'race');
                 if (arr.errcode == '0') { that.setData({ addressList: arr.data }) }
                 // 裁判
-                const aee = await app.$get(`/user`, { parent_id: res.data._id, type: '2' }, 'race')
-                if (aee.errcode == '0') {
-                    for (const val of aee.data) { val.name = val.user_id.name }
-                    that.setData({ refereeList: aee.data })
+                arr = await app.$get(`/user`, { parent_id: res.data._id, type: '2' }, 'race')
+                if (arr.errcode == '0') {
+                    for (const val of arr.data) { val.name = val.user_id.name }
+                    that.setData({ refereeList: arr.data })
                 }
+                // 状态
+                arr = await app.$get(`/dict`, { code: 'schedule_status' });
+                if (arr.errcode == '0' && arr.total > 0) that.setData({ statusList: arr.data[0].list });
             },
             fail: async res => {
                 wx.redirectTo({ url: '/pages/index/index' })

+ 11 - 0
pagesMatch/matchAdmin/elimmatch/add.wxml

@@ -31,6 +31,9 @@
                                             <view class="change_1 textOver">
                                                 <view>{{s.match_time||'暂无时间'}}</view>
                                             </view>
+                                            <view class="change_1 textOver">
+                                                <view>{{s.zhStatus||'暂无状态'}}</view>
+                                            </view>
                                         </view>
                                         <view class="name">
                                             <view class="name_1">{{s.player_one_name || s.player_one_node}}</view>
@@ -79,6 +82,14 @@
                         <datatime-picker datetime="{{form.match_time}}" name="match_time" bind:datetimeChange="datetimeChange"></datatime-picker>
                     </view>
                 </view>
+                <view class="content">
+                    <view class="label">赛程状态:</view>
+                    <view class="value">
+                        <picker mode="selector" bindchange="statusChange" name="status" value="{{form.status}}" range="{{statusList}}" range-key="label">
+                            <view class="picker">{{form.zhStatus||'请选择赛程状态'}}</view>
+                        </picker>
+                    </view>
+                </view>
                 <view class="btn">
                     <button type="primary" size="mini" formType="submit">提交保存</button>
                 </view>

+ 3 - 2
pagesMatch/matchAdmin/elimmatch/edit.js

@@ -144,7 +144,7 @@ Page({
      */
     onLoad: async function (options) {
         const that = this;
-        that.setData({ id: options && options.id || '' })
+        that.setData({ id: options && options.id || '631af83bec197f4678f23360' })
         //验证规则函数
         that.initValidate();
         // 监听用户是否登录
@@ -181,7 +181,8 @@ Page({
                 // 查询其他信息
                 await that.searchOther();
                 if (that.data.id) {
-                    const arr = await app.$get(`/msgs/${that.data.id}`, {}, 'race');
+                    console.log('1');
+                    const arr = await app.$get(`/eliminate/${that.data.id}`, {}, 'race');
                     if (arr.errcode == '0') {
                         // 状态
                         let status = that.data.statusList.find(i => i.value == arr.data.status)

+ 11 - 62
pagesMatch/matchAdmin/elimmatch/edit.wxml

@@ -4,63 +4,31 @@
             <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 class="value">{{form._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_id_name||'请选择赛事'}}</view>
-                        </picker>
-                    </view>
+                    <view class="value">{{form.match_id_name}} </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_id_name||'请选择赛事分组'}}</view>
-                        </picker>
-                    </view>
+                    <view class="value">{{form.group_id_name}}</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_id_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_id_name||'请选择小组名称'}}</view>
-                        </picker>
-                    </view>
+                    <view class="value">{{form.project_id_name}}</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_id_name||'请选择场地名称'}}</view>
-                        </picker>
-                    </view>
+                    <view class="value">{{form.address_id_name}} </view>
                 </view>
                 <view class="content">
                     <view class="label">裁判名称:</view>
-                    <view class="value">
-                        <picker mode="selector" bindchange="refereeChange" name="referee_id" value="{{form.referee_id}}" range="{{refereeList}}" range-key="name">
-                            <view class="picker">{{form.referee_id_name||'请选择裁判名称'}}</view>
-                        </picker>
-                    </view>
+                    <view class="value">{{form.referee_id_name}}</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 class="value">{{form.match_time}}</view>
                 </view>
                 <view class="content" style="display: none;">
                     <view class="label">选手类型:</view>
@@ -70,38 +38,19 @@
                 </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 class="value">{{form.type_name}}</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.player_one_name||'请选择选手一'}}</view>
-                        </picker>
-                    </view>
+                    <view class="value">{{form.player_one_name}}</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.player_two_name||'请选择选手二'}}</view>
-                        </picker>
-                    </view>
+                    <view class="value">{{form.player_two_name}}</view>
                 </view>
                 <view class="content">
                     <view class="label">赛程状态:</view>
-                    <view class="value">
-                        <view class="value">
-                            <picker mode="selector" bindchange="statusChange" name="status" value="{{form.status}}" range="{{statusList}}" range-key="label">
-                                <view class="picker">{{form.zhStatus||'请选择赛程状态'}}</view>
-                            </picker>
-                        </view>
-                    </view>
-                </view>
-                <view class="btn">
-                    <button type="primary" size="mini" formType="submit">提交保存</button>
+                    <view class="value">{{form.zhStatus}}</view>
                 </view>
             </form>
         </view>

+ 36 - 53
pagesMatch/matchAdmin/elimmatch/list.js

@@ -10,8 +10,11 @@ Page({
         groupList: [],
         // 组内项目
         projectList: [],
+        // 比赛
         match: {},
-        dialog: { title: '赛程上分', show: false, type: '1' },
+        // 按钮
+        btn: '',
+        dialog: { title: '选择赛事', show: false, type: '1' },
         form: {},
         list: [],
         total: 0,
@@ -29,9 +32,16 @@ Page({
     // 返回
     back: function () { wx.navigateBack({ delta: 1 }) },
     // 添加
+    toAdd: function (e) {
+        const that = this;
+        that.setData({ btn: e.currentTarget.dataset.btn })
+        that.setData({ dialog: { title: '选择赛事', show: true, type: '1' } })
+    },
+    //添加信息,信息维护
     toCommon: function (e) {
         const that = this;
-        that.setData({ dialog: { title: '添加淘汰赛', show: true, type: '1' } })
+        const { item, route } = e.currentTarget.dataset;
+        wx.navigateTo({ url: `/pagesMatch/${route}?id=${item && item._id ? item._id : ''}` })
     },
     // 选择赛事
     matchChange1: async function (e) {
@@ -65,13 +75,33 @@ Page({
         }
     },
     toSubmit: function (e) {
+        const that = this
         const { group_id, match_id, project_id } = e.detail.value;
+        that.setData({ 'match.match_id': match_id, 'match.group_id': group_id, 'match.project_id': project_id, })
         if (match_id && group_id && project_id) {
-            wx.navigateTo({ url: `/pagesMatch/matchAdmin/elimmatch/add?match_id=${match_id}&group_id=${group_id}&project_id=${project_id}` })
+            if (that.data.btn == '2') {
+                wx.navigateTo({ url: `/pagesMatch/matchAdmin/elimmatch/add?match_id=${match_id}&group_id=${group_id}&project_id=${project_id}` }); that.toClose();
+            } else that.search(e.detail.value); that.toClose();
         } else {
             wx.showToast({ title: '请选择数据', icon: 'error', duration: 2000 })
         }
     },
+    search: async function (e) {
+        const that = this;
+        let match = that.data.match;
+        let arr;
+        let info = { skip: that.data.skip, limit: that.data.limit, match_id: match.match_id, group_id: match.group_id, project_id: match.project_id };
+        arr = await app.$get(`http://192.168.1.197:15001/newCourt/race/v2/api/eliminate`, { ...info });
+        if (arr.errcode == '0') {
+            let list = [...that.data.list, ...arr.data]
+            for (const val of list) {
+                let status = that.data.statusList.find(i => i.value == val.status)
+                if (status) val.zhStatus = status.label;
+            }
+            that.setData({ list })
+            that.setData({ total: arr.total })
+        } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
+    },
     // 赛程上分
     toScore: function (e) {
         const that = this;
@@ -89,63 +119,16 @@ Page({
             wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
             return false
         } else {
-            let arr = await app.$post(`/msgs/${form.id}`, params, 'race');
+            let arr = await app.$post(`/eliminate/${form.id}`, params,'race');
             if (arr.errcode == '0') {
                 wx.showToast({ title: `上分成功`, icon: 'success', duration: 2000 });
                 that.toClose();
                 that.setData({ skip: 0, page: 0, list: [] })
-                that.watchLogin()
+                that.search()
             }
             else wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
         }
     },
-    // 删除
-    toDel: function (e) {
-        const that = this;
-        const { item } = e.currentTarget.dataset;
-        wx.showModal({
-            title: '提示',
-            content: '是否确认删除该条数据?',
-            async success(res) {
-                if (res.confirm) {
-                    const arr = await app.$delete(`/msgs/${item._id}`, {}, 'race');
-                    if (arr.errcode == '0') {
-                        wx.showToast({ title: `删除信息成功`, icon: 'success', duration: 2000 })
-                        that.setData({ skip: 0, page: 0, list: [] })
-                        that.watchLogin()
-                    } else {
-                        wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
-                    }
-                }
-            }
-        })
-    },
-    // 选择赛事
-    matchChange: function (e) {
-        const that = this;
-        let data = that.data.matchList[e.detail.value];
-        if (data) {
-            that.setData({ 'match.id': data._id, 'match.name': data.name });
-            that.search(data);
-            that.setData({ skip: 0, page: 0, list: [] })
-        }
-    },
-    search: async function (e) {
-        const that = this;
-        let match = that.data.match;
-        let info = { skip: that.data.skip, limit: that.data.limit, match_id: match.id };
-        let arr = await app.$get(`/http://192.168.1.197:15001/newCourt/race/v2/api/eliminate`, { ...info });
-        if (arr.errcode == '0') {
-            // console.log(arr.data);
-            let list = [...that.data.list, ...arr.data]
-            for (const val of list) {
-                let status = that.data.statusList.find(i => i.value == val.status)
-                if (status) val.zhStatus = status.label;
-            }
-            that.setData({ list })
-            that.setData({ total: arr.total })
-        } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
-    },
     // 分页
     toPage: function () {
         const that = this;
@@ -202,7 +185,7 @@ Page({
                 let arr;
                 arr = await app.$get(`/match`, { belong_id: res.data._id }, 'race');
                 if (arr.errcode == '0') { that.setData({ matchList: arr.data }) }
-                if (that.data.match && that.data.match.id) that.search();
+                // if (that.data.match) that.search();
             },
             fail: async res => {
                 wx.redirectTo({ url: '/pages/index/index' })

+ 24 - 15
pagesMatch/matchAdmin/elimmatch/list.wxml

@@ -6,12 +6,10 @@
             </view>
             <view class="one_2">
                 <view class="one_2_1">
-                    <picker mode="selector" bindchange="matchChange" name="id" value="{{match.id}}" range="{{matchList}}" range-key="name">
-                        <button type="primary" class="textOver">{{match.name||'选择赛事'}}</button>
-                    </picker>
+                    <button type="primary" bindtap="toAdd" data-btn="{{1}}">选择赛事</button>
                 </view>
                 <view class="one_2_1">
-                    <button type="primary" bindtap="toCommon" >添加赛程</button>
+                    <button type="primary" bindtap="toAdd" data-btn="{{2}}">维护赛程</button>
                 </view>
             </view>
         </view>
@@ -21,30 +19,28 @@
                     <view class="list" wx:for="{{list}}" wx:key="item">
                         <view class="list_0">
                             <view class="name">
-                                <text>{{item.match_id_name}}</text>
-                                <text>{{item.group_id_name}}</text>
-                                <text>{{item.project_id_name}}</text>
-                                <text>{{item.team_id_name}}</text>
-                                <text>{{item.address_id_name}}</text>
+                                <text>{{item.match_id.name||'暂无'}}</text>
+                                <text>{{item.group_id.name||'暂无'}}</text>
+                                <text>{{item.project_id.name||'暂无'}}</text>
+                                <text>{{item.address_id.name||'暂无场地'}}</text>
                             </view>
                             <view class="pk">
                                 <view class="pk_1">
-                                    <text>{{item.player_one_name}}</text>
+                                    <text>{{item.player_one_name||'暂无'}}</text>
                                 </view>
                                 <view class="pk_2">
-                                    <view class="time">{{item.match_time}}</view>
+                                    <view class="time">{{item.match_time||'0000-00-00 00:00'}}</view>
                                     <view class="status">{{item.zhStatus}}</view>
                                     <view class="score"><text>{{item.player_one_score||0}}</text>-{{item.player_two_score||0}}</view>
                                 </view>
                                 <view class="pk_1">
-                                    <text>{{item.player_two_name}}</text>
+                                    <text>{{item.player_two_name||'暂无'}}</text>
                                 </view>
                             </view>
                         </view>
                         <view class="btn">
-                            <button type="primary" size="mini" bindtap="toCommon" data-route="matchAdmin/elimmatch/edit" data-item="{{item}}">信息维护</button>
+                            <button type="primary" size="mini" bindtap="toCommon" data-route="matchAdmin/elimmatch/edit" data-item="{{item}}">详细信息</button>
                             <button type="primary" size="mini" bindtap="toScore" wx:if="{{item.status=='1'}}" data-item="{{item}}">赛程上分</button>
-                            <button type="warn" size="mini" bindtap="toDel" wx:if="{{item.status=='0'}}" data-item="{{item}}">赛事删除</button>
                         </view>
                     </view>
                 </view>
@@ -81,7 +77,7 @@
                     </view>
                 </view>
                 <view class="btn">
-                    <button type="primary" size="mini" formType="submit" >提交保存</button>
+                    <button type="primary" size="mini" formType="submit">提交保存</button>
                 </view>
             </form>
         </view>
@@ -111,6 +107,19 @@
                         <input type="text" name="player_two_score" value="{{form.player_two_score}}" placeholder="请输入选手二比分" />
                     </view>
                 </view>
+                <view class="content">
+                    <view class="label">胜者:</view>
+                    <view class="value">
+                        <radio-group name="winner">
+                            <label>
+                                <radio value="{{form.player_one}}" checked="{{form.player_one==form.winner?true:false}}" />{{form.player_one_name}}
+                            </label>
+                            <label>
+                                <radio value="{{form.player_two}}" checked="{{form.player_two==form.winner?true:false}}" />{{form.player_two_name}}
+                            </label>
+                        </radio-group>
+                    </view>
+                </view>
                 <view class="btn">
                     <button type="primary" size="mini" formType="submit">提交保存</button>
                 </view>