Pārlūkot izejas kodu

淘汰赛添加

YY 2 gadi atpakaļ
vecāks
revīzija
90639b1435

+ 31 - 29
pagesMatch/matchAdmin/elimmatch/add.js

@@ -9,6 +9,9 @@ const edgeSetting = function (edge) {
 Page({
     data: {
         frameStyle: { useTop: true, name: '添加赛程', leftArrow: true, useBar: false },
+        match_id: '',
+        group_id: '',
+        project_id: '',
         loadChart: false,
         winData: {},
         loseData: {},
@@ -88,46 +91,45 @@ Page({
     /**
      * 生命周期函数--监听页面加载
      */
-    onLoad: function (options) {
-        this.search();
-        this.searchUser();
+    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();
     },
     /**
      * 查询函数
      */
-    async search() {
+    search: async function () {
         const that = this;
-        const match_id = '630ec4700a92b0a015ccfd14';
-        const group_id = "6318277947be96470e849b6a";
-        const project_id = '631827f047be96470e849bc1';
+        const match_id = that.data.match_id;
+        const group_id = that.data.group_id;
+        const project_id = that.data.project_id;
         let arr;
-        wx.request({
-            url: `http://192.168.1.197:15001/newCourt/race/v2/api/eliminate/graphData?match_id=${match_id}&group_id=${group_id}&project_id=${project_id}`,
-            success: (res) => {
-                let data = res?.data?.data
-                const { winData, loseData } = that.groupData(data);
-                const schList = that.schData(data)
-                that.setData({ winData, loseData, schList })
-            }
-        })
-        wx.request({
-            url: `http://192.168.1.197:15001/newCourt/race/v2/api/eliminate/playerList?match_id=${match_id}&group_id=${group_id}&project_id=${project_id}`,
-            success: (res) => {
-                const playerList = res?.data?.data
-                that.setData({ playerList })
-            }
-        })
-        that.searchUser();
+        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}`);
+        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}`);
+        if (arr.errcode == '0' && arr.data.length > 0) {
+            that.setData({ playerList: arr.data })
+        }
     },
     // 查询赛事赛程
     searchUser: async function () {
         const that = this;
-        const match_id = '630ec4700a92b0a015ccfd14';
-        const group_id = "6318277947be96470e849b6a";
-        const project_id = '631827f047be96470e849bc1';
+        const match_id = that.data.match_id;
+        const group_id = that.data.group_id;
+        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 }, 'race');
-        if (arr.errcode == '0') {
+        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 });
+        if (arr.errcode == '0' && arr.total > 0) {
             for (const val of arr.data) {
                 if (val.player_one) {
                     let one = that.data.playerList.find(i => i._id == val.player_one)

+ 52 - 9
pagesMatch/matchAdmin/elimmatch/list.js

@@ -5,6 +5,11 @@ Page({
         frameStyle: { useTop: true, name: '赛程设置', leftArrow: true, useBar: false },
         // 赛事列表
         matchList: [],
+        matchList1: [],
+        // 赛事组别
+        groupList: [],
+        // 组内项目
+        projectList: [],
         match: {},
         dialog: { title: '赛程上分', show: false, type: '1' },
         form: {},
@@ -26,16 +31,53 @@ Page({
     // 添加
     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 : ''}` })
+        that.setData({ dialog: { title: '添加淘汰赛', show: true, type: '1' } })
+    },
+    // 选择赛事
+    matchChange1: 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,
+                '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 });
+        }
+    },
+    // 选择组别
+    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 });
+        }
+    },
+    toSubmit: function (e) {
+        const { group_id, match_id, project_id } = e.detail.value;
+        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}` })
+        } else {
+            wx.showToast({ title: '请选择数据', icon: 'error', duration: 2000 })
+        }
     },
     // 赛程上分
     toScore: function (e) {
         const that = this;
         const { item } = e.currentTarget.dataset;
         that.setData({ form: item })
-        that.setData({ dialog: { title: '赛程上分', show: true, type: '1' } })
+        that.setData({ dialog: { title: '赛程上分', show: true, type: '2' } })
     },
     // 提交保存
     onSubmit: async function (e) {
@@ -84,16 +126,17 @@ Page({
         let data = that.data.matchList[e.detail.value];
         if (data) {
             that.setData({ 'match.id': data._id, 'match.name': data.name });
-            that.setData({ skip: 0, page: 0, list: [] })
             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(`/msgs`, { ...info }, 'race');
+        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)
@@ -122,7 +165,7 @@ Page({
     toClose: function () {
         const that = this;
         that.setData({ form: {} })
-        that.setData({ dialog: { title: '赛程上分', show: false, type: '1' } })
+        that.setData({ dialog: { title: '赛程上分', show: false, type: '2' } })
     },
     /**
      * 生命周期函数--监听页面加载
@@ -157,9 +200,9 @@ Page({
             key: 'raceuser',
             success: async res => {
                 let arr;
-                arr = await app.$get(`/match`, { belong_id: res.data._id }, 'race');  
+                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.data.match.id) that.search();
             },
             fail: async res => {
                 wx.redirectTo({ url: '/pages/index/index' })

+ 32 - 1
pagesMatch/matchAdmin/elimmatch/list.wxml

@@ -11,7 +11,7 @@
                     </picker>
                 </view>
                 <view class="one_2_1">
-                    <button type="primary" bindtap="toCommon" data-route="matchAdmin/elimmatch/add">添加赛程</button>
+                    <button type="primary" bindtap="toCommon" >添加赛程</button>
                 </view>
             </view>
         </view>
@@ -55,6 +55,37 @@
 <dialog dialog="{{dialog}}" bind:toClose="toClose">
     <view slot="info" class="dialog">
         <view class="dialog_1" wx:if="{{dialog.type=='1'}}">
+            <form catchsubmit="toSubmit">
+                <view class="content">
+                    <view class="label">赛事名称:</view>
+                    <view class="value">
+                        <picker bindchange="matchChange1" name="match_id" value="{{form.match_id}}" range-key='name' range="{{matchList}}">
+                            <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="btn">
+                    <button type="primary" size="mini" formType="submit" >提交保存</button>
+                </view>
+            </form>
+        </view>
+        <view class="dialog_1" wx:if="{{dialog.type=='2'}}">
             <form catchsubmit="onSubmit">
                 <view class="content">
                     <view class="label">选手一:</view>