fix bugs
This commit is contained in:
@@ -59,6 +59,7 @@
|
||||
<script>
|
||||
import CustomTabs from '../../components/custom-tabs/custom-tabs.vue';
|
||||
import ConfirmModal from '../../components/confirm-modal/confirm-modal.vue';
|
||||
import athleteAPI from '@/api/athlete.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -69,39 +70,51 @@ export default {
|
||||
return {
|
||||
tabs: ['选手', '联系人'],
|
||||
currentTab: 0,
|
||||
playerList: [
|
||||
{
|
||||
id: 1,
|
||||
name: '张三',
|
||||
idCard: '123456789000000000'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '张三',
|
||||
idCard: '123456789000000000'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '张三',
|
||||
idCard: '123456789000000000'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: '张三',
|
||||
idCard: '123456789000000000'
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: '张三',
|
||||
idCard: '123456789000000000'
|
||||
}
|
||||
],
|
||||
playerList: [],
|
||||
showDeleteModal: false,
|
||||
showSuccessToast: false,
|
||||
currentItem: null
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
this.loadPlayerList()
|
||||
},
|
||||
onShow() {
|
||||
// 从新增/编辑页面返回时重新加载列表
|
||||
this.loadPlayerList()
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 加载选手列表
|
||||
*/
|
||||
async loadPlayerList() {
|
||||
try {
|
||||
const res = await athleteAPI.getAthleteList({
|
||||
current: 1,
|
||||
size: 100
|
||||
})
|
||||
|
||||
let list = []
|
||||
if (res.records) {
|
||||
list = res.records
|
||||
} else if (Array.isArray(res)) {
|
||||
list = res
|
||||
}
|
||||
|
||||
// 数据映射
|
||||
this.playerList = list.map(item => ({
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
idCard: item.idCard || item.idCardNumber,
|
||||
gender: item.gender,
|
||||
team: item.team,
|
||||
phone: item.phone
|
||||
}))
|
||||
} catch (err) {
|
||||
console.error('加载选手列表失败:', err)
|
||||
}
|
||||
},
|
||||
|
||||
handleTabChange(index) {
|
||||
this.currentTab = index;
|
||||
},
|
||||
@@ -125,18 +138,31 @@ export default {
|
||||
this.currentItem = item;
|
||||
this.showDeleteModal = true;
|
||||
},
|
||||
confirmDelete() {
|
||||
async confirmDelete() {
|
||||
this.showDeleteModal = false;
|
||||
// 执行删除操作
|
||||
const index = this.playerList.findIndex(item => item.id === this.currentItem.id);
|
||||
if (index > -1) {
|
||||
this.playerList.splice(index, 1);
|
||||
|
||||
try {
|
||||
// 调用删除API
|
||||
await athleteAPI.removeAthlete(this.currentItem.id)
|
||||
|
||||
// 从列表中移除
|
||||
const index = this.playerList.findIndex(item => item.id === this.currentItem.id);
|
||||
if (index > -1) {
|
||||
this.playerList.splice(index, 1);
|
||||
}
|
||||
|
||||
// 显示成功提示
|
||||
this.showSuccessToast = true;
|
||||
setTimeout(() => {
|
||||
this.showSuccessToast = false;
|
||||
}, 2000);
|
||||
} catch (err) {
|
||||
console.error('删除选手失败:', err)
|
||||
uni.showToast({
|
||||
title: '删除失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
// 显示成功提示
|
||||
this.showSuccessToast = true;
|
||||
setTimeout(() => {
|
||||
this.showSuccessToast = false;
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user