|
@@ -22,6 +22,8 @@ Page({
|
|
|
groundList: [],
|
|
|
refereeList: [],
|
|
|
|
|
|
+ arrangeData: {},
|
|
|
+
|
|
|
// picker
|
|
|
show: false,
|
|
|
personList: [],
|
|
@@ -160,7 +162,20 @@ Page({
|
|
|
d.refereeModelName = `referee_id-${i}`;
|
|
|
d.timeModelName = `match_time-${i}`;
|
|
|
}
|
|
|
- this.setData({ raceList })
|
|
|
+ const oRaceList = this.data.raceList;
|
|
|
+ for (const race of raceList) {
|
|
|
+ const { node_id_one, node_id_two } = race;
|
|
|
+ const r = oRaceList.find(f => f.node_id_one === node_id_one && f.node_id_two === node_id_two)
|
|
|
+ if (r) {
|
|
|
+ const ri = oRaceList.findIndex(f => f.node_id_one === node_id_one && f.node_id_two === node_id_two)
|
|
|
+ const { groundModelName, refereeModelName, timeModelName } = race
|
|
|
+ r = { ...r, groundModelName, refereeModelName, timeModelName }
|
|
|
+ oRaceList.splice(ri, 1, r)
|
|
|
+ } else {
|
|
|
+ oRaceList.push(race)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.setData({ raceList: oRaceList })
|
|
|
},
|
|
|
|
|
|
|
|
@@ -171,8 +186,29 @@ Page({
|
|
|
this.setData({ data })
|
|
|
// 请求 小组赛的 胜者列表
|
|
|
await this.searchWinnerList();
|
|
|
+ await this.search();
|
|
|
await this.searchOthers()
|
|
|
},
|
|
|
+ // 查询已安排的数据
|
|
|
+ async search() {
|
|
|
+ let res = await app.$get(`/newCourt/api/eliminatArrange/getOne`, this.query)
|
|
|
+ if (app.$checkRes(res)) {
|
|
|
+ const { arrange } = res.data;
|
|
|
+ this.setData({
|
|
|
+ arrangeData: res.data,
|
|
|
+ arrangeList: arrange
|
|
|
+ })
|
|
|
+ }
|
|
|
+ res = await app.$get(`/newCourt/api/eliminateRace`, this.query)
|
|
|
+ if (app.$checkRes(res)) {
|
|
|
+ this.setData({
|
|
|
+ raceList: res.data
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // 数据本地化处理下
|
|
|
+ this.getRaceList();
|
|
|
+ },
|
|
|
+
|
|
|
// 获取该项目的小组,形成晋级图
|
|
|
async getTeams() {
|
|
|
const res = await app.$get(`/newCourt/api/raceTeam`, this.query)
|
|
@@ -275,19 +311,33 @@ Page({
|
|
|
let arrangeList = this.data.arrangeList;
|
|
|
|
|
|
// arrangeList:需要将match_id,grouping_id,project_id 也放入,确定是这个项目的淘汰赛
|
|
|
- const arrange = { arrange: arrangeList, ...this.query }
|
|
|
+ let arrange = this.data.arrangeData;
|
|
|
+ if (!arrange._id) {
|
|
|
+ arrange = { arrange: arrangeList, ...this.query }
|
|
|
+ }
|
|
|
// raceList:淘汰赛的比赛赛程
|
|
|
raceList = raceList.map(i => {
|
|
|
const { groundModelName, refereeModelName, timeModelName, ...others } = i
|
|
|
return { ...others, ...this.query }
|
|
|
})
|
|
|
// 创建安排
|
|
|
- let res = await app.$post('/newCourt/api/eliminatArrange', arrange)
|
|
|
- if(app.$checkRes(res)) {
|
|
|
- console.log('淘汰赛安排创建成功')
|
|
|
+ let res
|
|
|
+ if (arrange._id) {
|
|
|
+ res = await app.$post(`/newCourt/api/eliminatArrange/${arrange._id}`, arrange)
|
|
|
+ if (app.$checkRes(res)) {
|
|
|
+ console.log('淘汰赛安排创建成功')
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ res = await app.$post(`/newCourt/api/eliminatArrange`, arrange)
|
|
|
+ if (app.$checkRes(res)) {
|
|
|
+ console.log('淘汰赛安排创建成功')
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
res = await app.$post('/newCourt/api/eliminateRace/saveAll', raceList)
|
|
|
- console.log(res)
|
|
|
+ wx.showToast({
|
|
|
+ title: '保存成功',
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
});
|