Selaa lähdekoodia

Merge branch 'master' of http://git.cc-lotus.info/ball-court/ball-applet

YY 2 vuotta sitten
vanhempi
commit
03e638a3b2

+ 70 - 22
pagesMatch/matchAdmin/elimmatch/add.js

@@ -6,6 +6,7 @@ const nodeSetting = function (node) {
 const edgeSetting = function (edge) {
     return edge;
 }
+const prefix = ''
 Page({
     data: {
         frameStyle: { useTop: true, name: '添加赛程', leftArrow: true, useBar: false },
@@ -81,15 +82,27 @@ Page({
             that.setData({ 'form.status': data.value, 'form.zhStatus': data.label });
         }
     },
-    //提交查询
+    //保存(单条)
     onSubmit: async function (e) {
         const that = this;
         let form = that.data.form;
         let player = that.data.schList.find(i => i.id == form.id)
         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.searchUser(); }
+        if (form.id) {
+            arr = await app.$post(`${prefix}/eliminate/${form.id}`, form, 'race');
+            if (arr.errcode == 0) {
+                let data = arr?.data;
+                let ri = this.data.schList.findIndex(f => f._id === form._id)
+                if (ri >= 0) {
+                    const list = this.data.schList
+                    this.setStatus(data);
+                    list[ri] = data;
+                    this.setData({ schList: list })
+                }
+            }
+        }
+        if (arr.errcode == '0') { wx.showToast({ title: `维护信息完成`, icon: 'success', duration: 2000 }); that.toClose(); }
         else wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
     },
     // 关闭弹框
@@ -116,13 +129,13 @@ Page({
         const group_id = that.data.group_id;
         const project_id = that.data.project_id;
         let arr;
-        arr = await app.$get(`http://192.168.1.197:15001/newCourt/race/v2/api/eliminate/graphData?match_id=${match_id}&group_id=${group_id}&project_id=${project_id}`);
+        arr = await app.$get(`${prefix}/eliminate/graphData`, { match_id, group_id, project_id }, 'race');
         if (arr.errcode == '0') {
             const { winData, loseData } = that.groupData(arr.data);
             const schList = that.schData(arr.data)
             that.setData({ winData, loseData, schList })
         }
-        arr = await app.$get(`http://192.168.1.197:15001/newCourt/race/v2/api/eliminate/playerList?match_id=${match_id}&group_id=${group_id}&project_id=${project_id}`);
+        arr = await app.$get(`${prefix}/eliminate/playerList`, { match_id, group_id, project_id }, 'race');
         if (arr.errcode == '0' && arr.data.length > 0) {
             that.setData({ playerList: arr.data })
         }
@@ -135,24 +148,57 @@ Page({
         const project_id = that.data.project_id;
         const playerList = that.data.playerList;
         let arr;
-        arr = await app.$get(`/eliminate`, { match_id: match_id, group_id: group_id, project_id: project_id },'race');
+        arr = await app.$get(`${prefix}/eliminate`, { match_id: match_id, group_id: group_id, project_id: project_id }, 'race');
         if (arr.errcode == '0' && arr.total > 0) {
+            console.log(arr.data.length);
             for (const val of arr.data) {
-                if (val.player_one) {
-                    let one = that.data.playerList.find(i => i._id == val.player_one)
-                    if (one) val.player_one_name = one.name;
-                }
-                if (val.player_two) {
-                    let two = that.data.playerList.find(i => i._id == val.player_two)
-                    if (two) val.player_two_name = two.name;
-                }
+                this.setNodeInfo(val)
                 // 状态
-                let status = that.data.statusList.find(i => i.value == val.status)
-                if (status) val.zhStatus = status.label;
+                this.setStatus(val);
             }
             that.setData({ schList: arr.data });
         }
     },
+    /**
+     * 同步图与赛程的人名
+     * @param {Object} data 赛程数据
+     */
+    setNodeInfo(data) {
+        const { player_one, player_one_node, player_one_name, player_two, player_two_node, player_two_name } = data
+        const setNode = (node_id, name) => {
+            const data = this.data.winData;
+            let r = data.nodes.find(f => f.id === node_id)
+            if (r) {
+                const ri = data.nodes.findIndex(f => f.id === node_id)
+                r.name = name;
+                data.nodes[ri] = r;
+                this.setData({ winData: data })
+                return;
+            }
+            data = this.data.loseData;
+            r = data.nodes.find(f => f.id === node_id)
+            if (r) {
+                const ri = data.nodes.findIndex(f => f.id === node_id)
+                r.name = name;
+                data.nodes[ri] = r;
+                this.setData({ loseData: data })
+                return;
+            }
+
+        }
+        if (player_one && player_one_node) setNode(player_one_node, player_one_name)
+        if (player_two && player_two_node) setNode(player_two_node, player_two_name)
+    },
+    /**
+     * 设置状态中文
+     * @param {Object} data 赛程数据
+     */
+    setStatus(data) {
+        let status = this.data.statusList.find(i => i.value == data.status)
+        if (status) data.zhStatus = status.label;
+    },
+
+
     /**
      * 选中选手的处理
      * @param {Object} selected 选中的选手数据
@@ -193,9 +239,11 @@ Page({
             sch.player_two = node.player_id;
             sch.player_two_name = node.name;
         }
-        const schIndex = schList.findIndex(f => f.player_one_node === node.id || f.player_two_node === node.id)
-        schList.splice(schIndex, 1, sch)
-        this.setData({ schList })
+        // const schIndex = schList.findIndex(f => f.player_one_node === node.id || f.player_two_node === node.id)
+        // schList.splice(schIndex, 1, sch)
+        // this.setData({ schList })
+        this.setData({ form: sch })
+        this.onSubmit();
     },
 
     /**
@@ -294,16 +342,16 @@ Page({
             success: async res => {
                 // 场地
                 let arr;
-                arr = await app.$get(`/matchAddress`, { belong_id: res.data._id, is_use: '0' }, 'race');
+                arr = await app.$get(`${prefix}/matchAddress`, { belong_id: res.data._id, is_use: '0' }, 'race');
                 if (arr.errcode == '0') { that.setData({ addressList: arr.data }) }
                 // 裁判
-                arr = await app.$get(`/user`, { parent_id: res.data._id, type: '2' }, 'race')
+                arr = await app.$get(`${prefix}/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' });
+                arr = await app.$get(`${prefix}/dict`, { code: 'schedule_status' });
                 if (arr.errcode == '0' && arr.total > 0) that.setData({ statusList: arr.data[0].list });
             },
             fail: async res => {

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

@@ -33,7 +33,7 @@
                             </view>
                         </view>
                         <view class="btn">
-                            <button type="primary" size="mini" bindtap="toCommon" data-route="refereeAdmin/outschedule/info" data-item="{{item}}">详细信息</button>
+                            <button type="primary" size="mini" bindtap="toCommon" data-route="refereeAdmin/mtschedule/info" data-item="{{item}}">详细信息</button>
                             <button type="primary" size="mini" bindtap="toScore" wx:if="{{item.status=='1'}}" data-item="{{item}}">赛程上分</button>
                             <button type="primary" size="mini" bindtap="toChange" wx:if="{{item.status=='1'&&item.player_one_score==16||item.player_two_score==16}}" data-item="{{item}}">交换场地</button>
                         </view>

+ 3 - 1
pagesMatch/refereeAdmin/outschedule/info.js

@@ -32,9 +32,11 @@ Page({
             key: 'user',
             success: async res => {
                 if (that.data.id) {
-                    const arr = await app.$get(`/msgs/${that.data.id}`, {}, 'race');
+                    const arr = await app.$get(`/eliminate/${that.data.id}`, {}, 'race');
                     if (arr.errcode == '0') {
                         arr.data.zhStatus = that.searchStatus(arr.data.status);
+                        if (arr.data.player_one == arr.data.winner) arr.data.winner_name = arr.data.player_one_name;
+                        else arr.data.winner_name = arr.data.player_two_name;
                         that.setData({ info: arr.data })
                     } else {
                         wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })

+ 1 - 5
pagesMatch/refereeAdmin/outschedule/info.wxml

@@ -13,10 +13,6 @@
                 <text>组别项目:</text>
                 <text>{{info.project_id_name||'暂无'}}</text>
             </view>
-            <view class="one_1">
-                <text>小组名称:</text>
-                <text>{{info.team_id_name||'暂无'}}</text>
-            </view>
             <view class="one_1">
                 <text>场地名称:</text>
                 <text>{{info.address_id_name||'暂无'}}</text>
@@ -63,7 +59,7 @@
             </view>
             <view class="one_1">
                 <text>胜者:</text>
-                <text>{{info.winner||'暂无'}}</text>
+                <text>{{info.winner_name||'暂无'}}</text>
             </view>
         </view>
     </view>

+ 5 - 7
pagesMatch/refereeAdmin/outschedule/list.js

@@ -44,12 +44,12 @@ 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.setData({ skip: 0, page: 0, list: [], form: {} })
                 that.watchLogin()
+                that.toClose();
             }
             else wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
         }
@@ -63,7 +63,7 @@ Page({
             content: '是否确认交换场地?',
             async success(res) {
                 if (res.confirm) {
-                    let arr = await app.$post(`/msgs/${item._id}`, { is_change: '1' }, 'race');
+                    let arr = await app.$post(`/eliminate/${item._id}`, { is_change: '1' }, 'race');
                     if (arr.errcode == '0') {
                         wx.showToast({ title: `交换场地成功`, icon: 'success', duration: 2000 });
                         that.setData({ skip: 0, page: 0, list: [] })
@@ -92,8 +92,6 @@ Page({
     // 关闭弹框
     toClose: function () {
         const that = this;
-        that.setData({ skip: 0, page: 0, list: [], form: {} })
-        that.watchLogin();
         that.setData({ dialog: { title: '赛程上分', show: false, type: '1' } })
     },
     /**
@@ -129,7 +127,7 @@ Page({
             key: 'raceuser',
             success: async res => {
                 let info = { skip: that.data.skip, limit: that.data.limit, referee_id: res.data._id };
-                let arr = await app.$get(`/msgs`, { ...info }, 'race');
+                let arr = await app.$get(`/eliminate`, { ...info }, 'race');
                 if (arr.errcode == '0') {
                     let list = [...that.data.list, ...arr.data]
                     for (const val of list) {

+ 6 - 5
pagesMatch/refereeAdmin/outschedule/list.wxml

@@ -9,14 +9,14 @@
                     <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 wx:if="{{!item.player_one_name&&!item.player_two_name}}">TBD</text>
                                     <text wx:if="{{item.is_change=='0'}}">{{item.player_one_name}}</text>
                                     <text wx:if="{{item.is_change=='1'}}">{{item.player_two_name}}</text>
                                 </view>
@@ -27,6 +27,7 @@
                                     <view class="score" wx:if="{{item.is_change=='1'}}"><text>{{item.player_two_score||0}}</text>-{{item.player_one_score||0}}</view>
                                 </view>
                                 <view class="pk_1">
+                                    <text wx:if="{{!item.player_one_name&&!item.player_two_name}}">TBD</text>
                                     <text wx:if="{{item.is_change=='0'}}">{{item.player_two_name}}</text>
                                     <text wx:if="{{item.is_change=='1'}}">{{item.player_one_name}}</text>
                                 </view>