|
@@ -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 => {
|