update:bug修复
This commit is contained in:
parent
c73c71b54f
commit
d8b7a4f1c1
@ -52,7 +52,7 @@ export const appuserAuditPost = (data) => {
|
||||
* @param {number} [params.PageSize] - 每页条数
|
||||
*/
|
||||
export const appuserLeaderPageGet = (params) => {
|
||||
return http.get('/appuser/leader/page', { params });
|
||||
return http.get('/appuser/member/page', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
@ -67,7 +67,7 @@ export const appuserLeaderPageGet = (params) => {
|
||||
* @param {number} [params.PageSize] - 每页条数
|
||||
*/
|
||||
export const appuserCoachPageGet = (params) => {
|
||||
return http.get('/appuser/coach/page', { params });
|
||||
return http.get('/appuser/member/page', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
@ -85,7 +85,7 @@ export const appuserCoachPageGet = (params) => {
|
||||
* @param {string} [data.remark] - 备注
|
||||
*/
|
||||
export const appuserLeaderSavePost = (data) => {
|
||||
return http.post('/appuser/leader/save', data);
|
||||
return http.post('/appuser/member/save', { ...data, personType: 3});
|
||||
};
|
||||
|
||||
/**
|
||||
@ -103,7 +103,7 @@ export const appuserLeaderSavePost = (data) => {
|
||||
* @param {string} [data.remark] - 备注
|
||||
*/
|
||||
export const appuserCoachSavePost = (data) => {
|
||||
return http.post('/appuser/coach/save', data);
|
||||
return http.post('/appuser/member/save', {data , personType: 2});
|
||||
};
|
||||
|
||||
/**
|
||||
@ -135,7 +135,7 @@ export const appuserMemberStatusPost = (data) => {
|
||||
* @param {number} [params.PageSize] - 每页条数
|
||||
*/
|
||||
export const appuserAthletePageGet = (params) => {
|
||||
return http.get('/appuser/member/page', { ...params, personType: 1 });
|
||||
return http.get('/appuser/member/page', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -63,8 +63,6 @@ export const teamDetailGet = (id) => {
|
||||
* 新增团队
|
||||
* @param {Object} data - 团队信息
|
||||
* @param {string} data.name - 团队名称
|
||||
* @param {string} [data.introduction] - 团队介绍
|
||||
* @param {string} data.establishedDate - 成立日期
|
||||
* @param {Array<number>} [data.leaderIds] - 领队ID列表
|
||||
* @param {Array<number>} [data.coachIds] - 教练ID列表
|
||||
* @param {Array<number>} [data.memberIds] - 成员ID列表
|
||||
|
||||
@ -200,6 +200,7 @@ class Axios {
|
||||
* @returns
|
||||
*/
|
||||
get = <T = any>(url: string, config?: AxiosRequestConfig): Promise<ApiResult<T>> => {
|
||||
console.log('get', url, config);
|
||||
return this.instance.get(url, config);
|
||||
};
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
|
||||
<template>
|
||||
<div class="system-menu-container layout-padding">
|
||||
<div class="cert-form" >
|
||||
<div class="cert-form">
|
||||
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="180px" style="max-width: 800px;">
|
||||
|
||||
<el-form-item label="单位名称:" prop="merchantName">
|
||||
@ -13,17 +12,13 @@
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="营业执照:" prop="businessLicenseUrl">
|
||||
<el-upload class="avatar-uploader"
|
||||
action="/api/certificatetemplate/uploaddoctemplate"
|
||||
:show-file-list="false"
|
||||
:auto-upload="false"
|
||||
:before-upload="beforeUpload"
|
||||
@change="handleUploadChange">
|
||||
<el-upload class="avatar-uploader" action="/api/file/upload" :show-file-list="false"
|
||||
:on-success="handleUploadChange">
|
||||
<div v-if="!formData.businessLicenseUrl" class="upload-placeholder">
|
||||
<i class="el-icon-plus avatar-uploader-icon"></i>
|
||||
<div>上传</div>
|
||||
</div>
|
||||
<el-image v-else :src="formData.businessLicenseUrl" alt="营业执照" style=" height: 200px;" />
|
||||
<el-image v-else :src="formData.businessLicenseUrl" alt="营业执照" style=" height: 200px;" />
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
|
||||
@ -33,7 +28,8 @@
|
||||
|
||||
<el-form-item label="联系方式:" prop="contactPhone">
|
||||
<el-input v-model="formData.contactPhone" placeholder="请输入手机号" style="width:360px;"></el-input>
|
||||
<el-button type="text" @click="onSendCode" style="margin-left:8px;" :disabled="sending || !isPhoneValid">{{ sendButtonText }}</el-button>
|
||||
<el-button type="text" @click="onSendCode" style="margin-left:8px;"
|
||||
:disabled="sending || !isPhoneValid">{{ sendButtonText }}</el-button>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="验证码:" prop="verificationCode">
|
||||
@ -67,16 +63,17 @@ const formData = reactive({
|
||||
address: '',
|
||||
contactPhone: '',
|
||||
verificationCode: '',
|
||||
status: 0
|
||||
status: 0,
|
||||
auditStatus: 0
|
||||
});
|
||||
|
||||
const formRules = {
|
||||
merchantName: [ { required: true, message: '请输入单位名称', trigger: 'blur' } ],
|
||||
creditCode: [ { required: true, message: '请输入统一社会信用代码', trigger: 'blur' } ],
|
||||
businessLicenseUrl: [ { required: true, message: '请上传营业执照', trigger: 'change' } ],
|
||||
address: [ { required: true, message: '请输入地址', trigger: 'blur' } ],
|
||||
contactPhone: [ { required: true, message: '请输入联系方式', trigger: 'blur' }, { validator: (rule, value, cb) => { const reg = /^1[3-9]\d{9}$/; if (!value) return cb(new Error('请输入联系方式')); if (!reg.test(value)) return cb(new Error('请输入正确的手机号')); cb(); }, trigger: 'blur' } ],
|
||||
verificationCode: [ { required: true, message: '请输入验证码', trigger: 'blur' } ]
|
||||
merchantName: [{ required: true, message: '请输入单位名称', trigger: 'blur' }],
|
||||
creditCode: [{ required: true, message: '请输入统一社会信用代码', trigger: 'blur' }],
|
||||
businessLicenseUrl: [{ required: true, message: '请上传营业执照', trigger: 'change' }],
|
||||
address: [{ required: true, message: '请输入地址', trigger: 'blur' }],
|
||||
contactPhone: [{ required: true, message: '请输入联系方式', trigger: 'blur' }, { validator: (rule, value, cb) => { const reg = /^1[3-9]\d{9}$/; if (!value) return cb(new Error('请输入联系方式')); if (!reg.test(value)) return cb(new Error('请输入正确的手机号')); cb(); }, trigger: 'blur' }],
|
||||
verificationCode: [{ required: true, message: '请输入验证码', trigger: 'blur' }]
|
||||
};
|
||||
|
||||
const sending = ref(false);
|
||||
@ -87,7 +84,7 @@ const sendButtonText = computed(() => sending.value ? `${sendTimer.value}s` : '
|
||||
const isPhoneValid = computed(() => { const reg = /^1[3-9]\d{9}$/; return reg.test(formData.contactPhone); });
|
||||
|
||||
const auditText = computed(() => {
|
||||
const s = formData.status;
|
||||
const s = formData.auditStatus;
|
||||
if (s == '0') return '未提交';
|
||||
if (s == '1') return '审核中';
|
||||
if (s == '2') return '审核通过';
|
||||
@ -96,10 +93,10 @@ const auditText = computed(() => {
|
||||
});
|
||||
|
||||
const auditTagType = computed(() => {
|
||||
const s = formData.status;
|
||||
if (s === '2') return 'success';
|
||||
if (s === '3') return 'danger';
|
||||
if (s === '1') return 'warning';
|
||||
const s = formData.auditStatus;
|
||||
if (s == '2') return 'success';
|
||||
if (s == '3') return 'danger';
|
||||
if (s == '1') return 'warning';
|
||||
return '';
|
||||
});
|
||||
|
||||
@ -108,18 +105,8 @@ const beforeUpload = () => {
|
||||
return true;
|
||||
};
|
||||
|
||||
const handleUploadChange = (file) => {
|
||||
// file is Array of files or a single file object depending on el-upload change payload
|
||||
const f = Array.isArray(file) ? file[0] : file;
|
||||
if (!f) return;
|
||||
// try to get raw file
|
||||
const raw = f.raw || f;
|
||||
try {
|
||||
formData.businessLicenseUrl = URL.createObjectURL(raw);
|
||||
} catch (err) {
|
||||
// fallback: if file contains url
|
||||
if (f.url) formData.businessLicenseUrl = f.url;
|
||||
}
|
||||
const handleUploadChange = (response) => {
|
||||
formData.businessLicenseUrl = response[0].url;
|
||||
};
|
||||
|
||||
const loadData = async () => {
|
||||
@ -135,6 +122,7 @@ const loadData = async () => {
|
||||
formData.address = data.address || '';
|
||||
formData.contactPhone = data.contactPhone || '';
|
||||
formData.status = data.status || 0;
|
||||
formData.auditStatus = data.auditStatus || 0;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
@ -149,7 +137,7 @@ const onSendCode = async () => {
|
||||
sendTimer.value = 60;
|
||||
try {
|
||||
const res = await merchantSendverificationcodePost({ phone: formData.contactPhone });
|
||||
if(!res.succeeded) return
|
||||
if (!res.succeeded) return
|
||||
ElMessage.success('验证码已发送');
|
||||
sendInterval.value = setInterval(() => {
|
||||
sendTimer.value -= 1;
|
||||
@ -200,7 +188,6 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.avatar-uploader .el-upload {
|
||||
border: 1px dashed var(--el-border-color);
|
||||
border-radius: 6px;
|
||||
@ -215,8 +202,26 @@ onMounted(() => {
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
.avatar-uploader .el-upload:hover { border-color: var(--el-color-primary); }
|
||||
.avatar-uploader .avatar-uploader-icon { font-size: 28px; color: #8c939d; }
|
||||
.upload-placeholder { color: #8c939d; text-align: center; }
|
||||
.cert-form { background:var(--el-bg-color); padding:24px; border-radius:8px; width: 100%;height: calc(100% ); }
|
||||
|
||||
.avatar-uploader .el-upload:hover {
|
||||
border-color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.avatar-uploader .avatar-uploader-icon {
|
||||
font-size: 28px;
|
||||
color: #8c939d;
|
||||
}
|
||||
|
||||
.upload-placeholder {
|
||||
color: #8c939d;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.cert-form {
|
||||
background: var(--el-bg-color);
|
||||
padding: 24px;
|
||||
border-radius: 8px;
|
||||
width: 100%;
|
||||
height: calc(100%);
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="system-menu-container layout-padding">
|
||||
<ProTable ref="tableRef" :request-api="teamPageGet" @selection-change="handleSelectionChange" :columns="columns" :pagination="true"
|
||||
<ProTable ref="tableRef" :request-api="merchantPageGet" @selection-change="handleSelectionChange" :columns="columns" :pagination="true"
|
||||
:tool-button="false" :initParams="initParam" row-key="userId">
|
||||
<template #tools>
|
||||
<el-popconfirm title="确认批量审核吗?" @confirm="onBatchAudit">
|
||||
@ -18,11 +18,8 @@
|
||||
{{ scope.row.auditRemark }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<template #ss="scope">
|
||||
|
||||
</template>
|
||||
<template #idCardImageUrl="scope">
|
||||
<el-image style="width: 100px;" :src="scope.row.idCardImageUrl" fit="cover"></el-image>
|
||||
<template #businessLicenseUrl="scope">
|
||||
<el-image style="width: 100px;" :src="scope.row.businessLicenseUrl" fit="cover"></el-image>
|
||||
</template>
|
||||
<template #action="scope">
|
||||
<el-button v-auth="'user:general:record'" size="small" text type="primary"
|
||||
@ -73,9 +70,9 @@ import { defineAsyncComponent, ref, reactive } from 'vue';
|
||||
import { ElMessage, ElForm } from 'element-plus';
|
||||
import { auths } from '/@/utils/authFunction';
|
||||
import ProTable from '/@/components/ProTable/index.vue';
|
||||
import { teamPageGet } from '/@/api/match/unitUser';
|
||||
import { appuserAuditPost} from '/@/api/match/appuser';
|
||||
import { eventrecordPageGet , eventrecordCertificatesGet} from '/@/api/match/eventRecord';
|
||||
import { merchantPageGet} from '/@/api/match/merchant';
|
||||
|
||||
const initParam = ref({
|
||||
refresh: true,
|
||||
@ -89,21 +86,12 @@ const statusList = ['info', 'warning', 'success', 'danger'];
|
||||
const columns = ref([
|
||||
{ prop: 'ss', type: 'selection' },
|
||||
{ prop: 'index', label: '序号', align: 'center' },
|
||||
{ prop: 'name', label: '姓名', search: { el: 'input' } },
|
||||
{
|
||||
prop: 'gender',
|
||||
label: '性别',
|
||||
search: {
|
||||
el: 'select',
|
||||
},
|
||||
enum: [
|
||||
{ label: '全部', value: '' },
|
||||
{ label: '男', value: 1 },
|
||||
{ label: '女', value: 2 },
|
||||
],
|
||||
},
|
||||
{ prop: 'mobile', label: '联系电话', search: { el: 'input' } },
|
||||
{ prop: 'idCardImageUrl', label: '身份证' },
|
||||
{ prop: 'merchantName', label: '单位名称', search: { el: 'input' } },
|
||||
{ prop: 'creditCode', label: '统一社会信用代码', search: { el: 'input' } },
|
||||
{ prop: 'address', label: '地址' },
|
||||
|
||||
{ prop: 'phone', label: '联系电话' },
|
||||
{prop: 'businessLicenseUrl', label: '营业执照', width: '130px',},
|
||||
{
|
||||
prop: 'auditStatus',
|
||||
label: '审核状态',
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<ProTable ref="tableRefteam" :request-api="teamPageGet" :columns="columns" :pagination="true"
|
||||
:tool-button="true">
|
||||
<template #tools>
|
||||
<el-button type="primary" icon="ele-Plus" @click="onOpenMenu"> 新增
|
||||
<el-button type="primary" icon="ele-Plus" @click="openTeam()"> 新增团队
|
||||
</el-button>
|
||||
</template>
|
||||
<template #index="scope">
|
||||
@ -13,9 +13,9 @@
|
||||
</template>
|
||||
|
||||
<template #action="scope">
|
||||
<el-button icon="ele-Edit" size="small" text type="primary" @click="onOpenMenu(scope.row.id)">
|
||||
<el-button icon="ele-Edit" size="small" text type="primary" @click="openTeam(scope.row.id)">
|
||||
编辑 </el-button>
|
||||
<el-popconfirm title="确认删除此团队吗?" @confirm="onDeleteMenu(scope.row.id)">
|
||||
<el-popconfirm title="确认删除此团队吗?" @confirm="onDeleteTeam(scope.row.id)">
|
||||
<template #reference>
|
||||
<el-button icon="ele-Delete" size="small" text type="danger">
|
||||
删除
|
||||
@ -53,6 +53,56 @@
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
<!-- 团队新增弹窗 -->
|
||||
<el-dialog title="新增团队" v-model="isShowTeamDialog" width="800px">
|
||||
<el-form ref="teamFormRef" :model="teamFormData" :rules="teamFormRules" label-width="120px" v-if="isShowTeamDialog">
|
||||
<el-form-item label="团队名称" prop="name">
|
||||
<el-input v-model="teamFormData.name" placeholder="请输入团队名称" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="队员">
|
||||
<el-button type="primary" @click="openMemberDialog">添加队员</el-button>
|
||||
<div style="margin-top:8px">
|
||||
<template v-if="teamFormData.memberList && teamFormData.memberList.length">
|
||||
<el-tag v-for="m in teamFormData.memberList" :key="m.id" closable @close="() => removeMember(m.id)" style="margin-right:6px">{{ m.name }}</el-tag>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span class="muted">未选择队员</span>
|
||||
</template>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="领队" prop="leaderIds">
|
||||
<el-select v-model="teamFormData.leaderIds" multiple placeholder="请选择领队">
|
||||
<el-option v-for="opt in leaderOptions" :key="opt.value" :label="opt.label" :value="opt.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="教练" prop="coachIds">
|
||||
<el-select v-model="teamFormData.coachIds" multiple placeholder="请选择教练">
|
||||
<el-option v-for="opt in coachOptions" :key="opt.value" :label="opt.label" :value="opt.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="isShowTeamDialog=false">取消</el-button>
|
||||
<el-button type="primary" @click="onTeamSubmit">确定</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 成员选择弹窗 -->
|
||||
<el-dialog title="选择队员" v-model="isShowMemberDialog" width="900px">
|
||||
<ProTable ref="memberTableRef" :request-api="appuserAthletePageGet" :columns="columnsMember" :pagination="true" />
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="cancelMemberSelection">取消</el-button>
|
||||
<el-button type="primary" @click="confirmMemberSelection">确定</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 弹窗 -->
|
||||
<el-dialog :title="dialogTitle" v-model="isShowDialog" width="width: 800px;">
|
||||
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="200px" style="margin-bottom: 30px;"
|
||||
@ -114,13 +164,13 @@
|
||||
</template>
|
||||
|
||||
<script setup name="sysMenu">
|
||||
import { defineAsyncComponent, ref, reactive } from 'vue';
|
||||
import { defineAsyncComponent, ref, reactive, nextTick } from 'vue';
|
||||
import { ElMessage, ElForm } from 'element-plus';
|
||||
import SysMenuApi from '/@/api/SysMenuApi';
|
||||
import { auths } from '/@/utils/authFunction';
|
||||
import ProTable from '/@/components/ProTable/index.vue';
|
||||
import { teamPageGet, teamDetailGet, teamAddPost, teamDeleteDelete, teamUpdatePut } from '/@/api/match/unitUser';
|
||||
import { appuserAthletePageGet, appuserAthleteAddPost, appuserAthleteUpdatePut, appuserAthleteOcrPost } from '/@/api/match/appuser';
|
||||
import { appuserAthletePageGet, appuserAthleteAddPost, appuserAthleteUpdatePut, appuserAthleteOcrPost, appuserLeaderPageGet, appuserCoachPageGet } from '/@/api/match/appuser';
|
||||
// 定义表单引用类型
|
||||
const formRef = ref();
|
||||
const activeTab = ref('first')
|
||||
@ -161,7 +211,7 @@ const formRules = ref({
|
||||
|
||||
const columns = ref([
|
||||
{ prop: 'index', label: '序号', align: 'center', },
|
||||
{ prop: 'type', label: '团队名称', search: { el: 'input' } },
|
||||
{ prop: 'name', label: '团队名称', search: { el: 'input' } },
|
||||
{ prop: 'leaderNames', label: '领队' },
|
||||
{ prop: 'coachNames', label: '教练' },
|
||||
{ prop: 'action', label: '操作', align: 'center', fixed: 'right' },
|
||||
@ -190,6 +240,205 @@ const columnsSport = ref([
|
||||
|
||||
const isShowDialog = ref(false);
|
||||
const dialogTitle = ref('新增');
|
||||
const tableRefteam = ref(null);
|
||||
|
||||
// 团队新增弹窗相关
|
||||
const isShowTeamDialog = ref(false);
|
||||
const teamFormRef = ref();
|
||||
const teamFormData = ref({
|
||||
id: undefined,
|
||||
name: '',
|
||||
memberIds: [],
|
||||
memberList: [], // [{id,name}]
|
||||
leaderIds: [],
|
||||
coachIds: [],
|
||||
memberNames: '',
|
||||
});
|
||||
|
||||
const teamFormRules = ref({
|
||||
name: [{ required: true, message: '请输入团队名称', trigger: 'blur' }],
|
||||
});
|
||||
|
||||
// 成员选择弹窗(使用 ProTable 的多选能力)
|
||||
const isShowMemberDialog = ref(false);
|
||||
const memberTableRef = ref(null);
|
||||
const columnsMember = ref([
|
||||
{ type: 'selection' },
|
||||
{ prop: 'name', label: '姓名', align: 'center' },
|
||||
{ prop: 'idCard', label: '身份证号', align: 'center' },
|
||||
{ prop: 'phone', label: '联系电话', align: 'center' },
|
||||
]);
|
||||
|
||||
// 领队/教练下拉选项
|
||||
const leaderOptions = ref([]);
|
||||
const coachOptions = ref([]);
|
||||
|
||||
const loadLeaderOptions = async () => {
|
||||
try {
|
||||
const res = await appuserLeaderPageGet({ PageNo: 1, PageSize: 100 , personType:3});
|
||||
if (res && res.succeeded && res.data && Array.isArray(res.data.rows)) {
|
||||
leaderOptions.value = res.data.rows.map((r) => ({ label: r.name, value: r.id }));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载领队失败', error);
|
||||
}
|
||||
};
|
||||
|
||||
const loadCoachOptions = async () => {
|
||||
try {
|
||||
const res = await appuserCoachPageGet({ PageNo: 1, PageSize: 100, personType:2 });
|
||||
if (res && res.succeeded && res.data && Array.isArray(res.data.rows)) {
|
||||
coachOptions.value = res.data.rows.map((r) => ({ label: r.name, value: r.id }));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载教练失败', error);
|
||||
}
|
||||
};
|
||||
|
||||
// 打开新增团队弹窗
|
||||
const openTeam = async (id) => {
|
||||
// reset
|
||||
teamFormData.value = { id: undefined, name: '', memberIds: [], memberList: [], leaderIds: [], coachIds: [], memberNames: '' };
|
||||
await Promise.all([loadLeaderOptions(), loadCoachOptions()]);
|
||||
if (id) {
|
||||
// 编辑:回显数据
|
||||
try {
|
||||
const res = await teamDetailGet(id);
|
||||
if (res && res.succeeded && res.data) {
|
||||
const d = res.data;
|
||||
teamFormData.value.id = d.id;
|
||||
teamFormData.value.name = d.name || '';
|
||||
// 处理成员(后端返回 members 数组,包含 userId / name)
|
||||
if (Array.isArray(d.members)) {
|
||||
// 根据 personType 区分成员类型:1-运动员,2-教练,3-领队
|
||||
const athletes = [];
|
||||
const coachIds = [];
|
||||
const leaderIds = [];
|
||||
d.members.forEach((m) => {
|
||||
const id = m.userId ?? m.id;
|
||||
const name = m.name ?? m.realName ?? m.fullName ?? '';
|
||||
const pt = m.personType ?? m.type ?? null;
|
||||
if (pt === 1 || String(pt) === '1') {
|
||||
athletes.push({ id, name });
|
||||
} else if (pt === 2 || String(pt) === '2') {
|
||||
coachIds.push(id);
|
||||
} else if (pt === 3 || String(pt) === '3') {
|
||||
leaderIds.push(id);
|
||||
} else {
|
||||
// 如果没有 personType,尝试根据标记字段推断(优先填到运动员)
|
||||
athletes.push({ id, name });
|
||||
}
|
||||
});
|
||||
teamFormData.value.memberList = athletes;
|
||||
teamFormData.value.memberIds = athletes.map((m) => m.id);
|
||||
teamFormData.value.memberNames = athletes.map((m) => m.name).join(',');
|
||||
// 优先使用 members 中的领队/教练 id,否则回退到返回的 leaderIds/coaches 字段
|
||||
teamFormData.value.leaderIds = leaderIds.length ? leaderIds : (d.leaderIds ?? d.leaders?.map((l) => l.id) ?? []);
|
||||
teamFormData.value.coachIds = coachIds.length ? coachIds : (d.coachIds ?? d.coaches?.map((c) => c.id) ?? []);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载团队详情失败', error);
|
||||
}
|
||||
}
|
||||
isShowTeamDialog.value = true;
|
||||
};
|
||||
|
||||
// 打开成员选择弹窗
|
||||
const openMemberDialog = () => {
|
||||
isShowMemberDialog.value = true;
|
||||
// ProTable 会自动请求数据(requestAuto = true),清空以前选择
|
||||
// 尝试在表格加载后预选已存在成员
|
||||
nextTick(async () => {
|
||||
try {
|
||||
// 清空已有选择
|
||||
memberTableRef.value?.clearSelection?.();
|
||||
// 等待表格数据加载;尝试重试几次以兼容异步加载
|
||||
const maxRetry = 6;
|
||||
let attempt = 0;
|
||||
const trySelect = () => {
|
||||
const tableDataRef = memberTableRef.value?.tableData;
|
||||
const tableData = tableDataRef && tableDataRef.value ? tableDataRef.value : tableDataRef || [];
|
||||
const tableElRef = memberTableRef.value?.element;
|
||||
const tableEl = tableElRef && tableElRef.value ? tableElRef.value : tableElRef;
|
||||
if (Array.isArray(tableData) && tableData.length) {
|
||||
// 对每个已选 memberId,在表格当前页中找到对应行并选中
|
||||
teamFormData.value.memberIds.forEach((id) => {
|
||||
const row = tableData.find((r) => r.id === id);
|
||||
if (row && tableEl && typeof tableEl.toggleRowSelection === 'function') {
|
||||
tableEl.toggleRowSelection(row, true);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
while (attempt < maxRetry) {
|
||||
if (trySelect()) break;
|
||||
attempt++;
|
||||
// 等待 200ms 再试
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await new Promise((r) => setTimeout(r, 200));
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('预选成员失败', e);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const confirmMemberSelection = () => {
|
||||
const selected = memberTableRef.value?.selectedList || [];
|
||||
// 保持 memberList 为对象数组,方便删除
|
||||
teamFormData.value.memberList = selected.map((s) => ({ id: s.id, name: s.name }));
|
||||
teamFormData.value.memberIds = teamFormData.value.memberList.map((m) => m.id);
|
||||
teamFormData.value.memberNames = teamFormData.value.memberList.map((m) => m.name).join(',');
|
||||
isShowMemberDialog.value = false;
|
||||
};
|
||||
|
||||
const removeMember = (id) => {
|
||||
teamFormData.value.memberList = teamFormData.value.memberList.filter((m) => m.id !== id);
|
||||
teamFormData.value.memberIds = teamFormData.value.memberList.map((m) => m.id);
|
||||
teamFormData.value.memberNames = teamFormData.value.memberList.map((m) => m.name).join(',');
|
||||
};
|
||||
|
||||
const cancelMemberSelection = () => {
|
||||
isShowMemberDialog.value = false;
|
||||
};
|
||||
|
||||
// 提交新增团队
|
||||
const onTeamSubmit = () => {
|
||||
if (!teamFormRef.value) return;
|
||||
teamFormRef.value.validate(async (valid) => {
|
||||
if (!valid) return;
|
||||
try {
|
||||
const payload = {
|
||||
name: teamFormData.value.name,
|
||||
memberIds: teamFormData.value.memberIds,
|
||||
leaderIds: teamFormData.value.leaderIds,
|
||||
coachIds: teamFormData.value.coachIds,
|
||||
};
|
||||
const res = teamFormData.value.id ? await teamUpdatePut({ id: teamFormData.value.id, ...payload }) : await teamAddPost(payload);
|
||||
if (res && res.succeeded) {
|
||||
ElMessage.success('新增团队成功');
|
||||
isShowTeamDialog.value = false;
|
||||
// 刷新团队表格(ProTable 暴露的 getTableList)
|
||||
try {
|
||||
await nextTick();
|
||||
tableRefteam.value?.getTableList?.();
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
// 切回团队页签
|
||||
activeTab.value = 'first';
|
||||
} else {
|
||||
ElMessage.error(res.errors || res.msg || (teamFormData.value.id ? '更新团队失败' : '新增团队失败'));
|
||||
}
|
||||
} catch (error) {
|
||||
ElMessage.error(teamFormData.value.id ? '更新团队失败' : '新增团队失败');
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const onOpenMenu = (row) => {
|
||||
dialogTitle.value = row ? '编辑' : '新增';
|
||||
@ -211,6 +460,7 @@ const onOpenMenu = (row) => {
|
||||
|
||||
//删除菜单
|
||||
const onDeleteMenu = async (id) => {
|
||||
// 保留给其它删除场景(如果需要),目前不改动
|
||||
const { succeeded, errors } = await SysMenuApi.delete({ id });
|
||||
if (succeeded) {
|
||||
ElMessage.success('删除成功');
|
||||
@ -219,6 +469,28 @@ const onDeleteMenu = async (id) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 删除团队(使用正确的 team API)
|
||||
const onDeleteTeam = async (id) => {
|
||||
try {
|
||||
const res = await teamDeleteDelete({ id });
|
||||
if (res && res.succeeded) {
|
||||
ElMessage.success('删除团队成功');
|
||||
// 刷新团队表格
|
||||
try {
|
||||
await nextTick();
|
||||
tableRefteam.value?.getTableList?.();
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
} else {
|
||||
ElMessage.error(res.errors || res.msg || '删除团队失败');
|
||||
}
|
||||
} catch (e) {
|
||||
ElMessage.error('删除团队失败');
|
||||
console.error(e);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// const isSendCode = ref(false)
|
||||
|
||||
@ -97,6 +97,7 @@ import { appuserLeaderPageGet ,appuserLeaderSavePost , appuserMemberDeletePost}
|
||||
const formRef = ref();
|
||||
const initParam = ref({
|
||||
refresh: true,
|
||||
personType:3
|
||||
});
|
||||
const formData = ref({
|
||||
name: '',
|
||||
|
||||
@ -97,6 +97,7 @@ import { appuserCoachPageGet ,appuserLeaderSavePost , appuserMemberDeletePost} f
|
||||
const formRef = ref();
|
||||
const initParam = ref({
|
||||
refresh: true,
|
||||
personType:2
|
||||
});
|
||||
const formData = ref({
|
||||
name: '',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user