import { computed, defineComponent, onMounted, reactive, ref } from 'vue'; import styles from './index.module.less'; import MSticky from '@/components/m-sticky'; import MHeader from '@/components/m-header'; import icon_detail_bg from '../images/icon_detail_bg.png'; import icon_music from '@common/images/icon-music.png'; import { Button, Cell, CellGroup, Checkbox, CheckboxGroup, Field, Grid, GridItem, Image, Picker, Popup, showToast } from 'vant'; import MStudent from '../component/m-student'; import { IMusicGroup, IStudentDetail } from '../type'; import Assignment from '../component/Assignment'; import Attendance from '../component/Attendance'; import icon_pen from '@common/images/icon_pen.png'; import icon_phone from '../images/icon-phone.png'; import icon_message from '../images/icon-message.png'; import SkeletionDetail from './skeletion-detail'; import { useRoute } from 'vue-router'; import { api_organizationGetGradeList, api_studentManageQuitMusicGroup, api_studentManageUpdateGrade, api_studentManageUserDetail, api_studentManageUserMusicGroup } from '../api'; export default defineComponent({ name: 'student-manage-detail', setup() { const route = useRoute(); const studentId: string | undefined = route.query?.studentId?.toString() || ''; const musicGroupIds: string[] = route.query.musicGroupIds?.toString()?.split(',') || []; const detailData = reactive({ skelet: true, /** 加载 */ loading: false, /** 乐团 */ groupShow: false, /** 退团 */ quitShow: false, /** 确定退团 */ quitConfirmShow: false, /** 联系方式 */ cancelShow: false, /** 年级 */ gradeShow: false, gradeOptions: [[], []] as any, musicGroup: [] as IMusicGroup[], musicGroupTitle: '全部乐团', musicGroupId: musicGroupIds[0] || '', student: {} as IStudentDetail, /** 年级列表 */ gradeList: null as any, /** 退团列表 */ quitList: [] as any[], /** 退团原因 */ reason: '', quitLoading: false }); const checkboxRefs = ref([]); /** 获取学生乐团 */ const getMusicGroup = () => { api_studentManageUserMusicGroup(studentId).then(res => { if (Array.isArray(res.data)) { detailData.musicGroup = res.data.map((item: any) => { return { text: item.name, value: item.id, gradeType: item.gradeType }; }); if (detailData.musicGroup.length === 1) { detailData.musicGroupTitle = detailData.musicGroup[0].text; } } }); }; /** 获取年级分布 */ const getGradeList = () => { if (detailData.student.organId && detailData.musicGroup.length) { if (detailData.gradeList) return; console.log(detailData.musicGroup); const gradeType = Array.from( new Set(detailData.musicGroup.map(group => group.gradeType)) ).join(','); console.log('🚀 ~ gradeType:', gradeType); api_organizationGetGradeList( detailData.student.organId, gradeType ).then(res => { detailData.gradeList = res.data; detailData.gradeOptions[0] = Object.entries(res.data).map( (value: any) => { return { text: value[1], value: value[0] }; } ); detailData.gradeOptions[1] = new Array(30) .fill(1) .map((_, index: number) => ({ text: `${index + 1}班`, value: `${index + 1}班` })); }); return; } setTimeout(() => { getGradeList(); }, 30); }; const getDatail = () => { detailData.loading = true; api_studentManageUserDetail({ studentId: studentId, musicGroupId: detailData.musicGroupId || '' }) .then(res => { if (res.data) { if (res.data.phone) { res.data.phone = res.data.phone.slice(0, 3) + '****' + res.data.phone.slice(-4); } detailData.student = res.data; getGradeList(); } }) .finally(() => { setTimeout(() => { detailData.loading = false; detailData.skelet = false; }, 500); }); }; onMounted(() => { getMusicGroup(); getDatail(); }); const quitName = computed(() => { const text = detailData.musicGroup .filter(group => detailData.quitList.includes(group.value)) .map(group => { return '“' + group.text + '”'; }) .join('、'); return `${detailData.student.studentName}从${text}`; }); /** 设置学生班级 */ const handleSetGrade = async (selectedOptions: any[]) => { const res = await api_studentManageUpdateGrade({ currentClass: selectedOptions[1].value, // 班级 currentGrade: selectedOptions[0].text, // 年级 currentGradeNum: selectedOptions[0].value, // 年级(数字表示) musicGroupId: detailData.musicGroupId, // 乐团ID studentId: detailData.student.studentId // 学生ID }); console.log(res); if (res.code === 200) { showToast('修改成功'); } getDatail(); }; /** 退团 */ const handleQuite = async () => { if (!detailData.reason) { showToast('请填写退团原因'); return; } detailData.quitLoading = true; try { const res = await api_studentManageQuitMusicGroup({ musicGroupId: detailData.quitList.join(','), reason: detailData.reason, reasonEnum: 'OTHER', userId: detailData.student.studentId }); detailData.quitConfirmShow = false; if (res.code === 200) { detailData.quitList = []; getDatail(); } } catch (error) {} detailData.quitLoading = false; }; /** 去聊天 */ const openIm = () => { postMessage({ api: 'joinChatGroup', content: { type: 'single', // single 单人 multi 多人 id: detailData.student.studentId } }); }; /** 打电话 */ const hanldeCallPhone = () => { postMessage({ api: 'callPhone', content: { phone: detailData.student.phone } }); }; return () => (
1 ? true : false} clickable={detailData.musicGroup.length > 1 ? true : false} center border={false} onClick={() => { if (detailData.musicGroup.length < 2) return; detailData.groupShow = true; }}> {{ icon: () => }}
(detailData.quitShow = true)} onContact={() => (detailData.cancelShow = true)} />
基本信息
性别
{detailData.student.gender ? '男' : '女'}
联系电话
{detailData.student.phone}
年级
{ if (detailData.student.inGroupStatus === 'OUT') return; detailData.gradeShow = true; }}> {detailData.student.currentGrade}年级 {detailData.student.currentClass} {detailData.student.inGroupStatus !== 'OUT' && ( )}
艺术实践
{detailData.student.artPracticeCount}次
{detailData.student.quitTime && (
退团时间
{detailData.student.quitTime}
)}
{/* 切换乐团 */} (detailData.groupShow = false)} onConfirm={value => { const option = value.selectedOptions[0]; const oldGroupId = detailData.musicGroupId; detailData.musicGroupId = option.value; detailData.musicGroupTitle = option.text; detailData.groupShow = false; if (oldGroupId != option.value) { getDatail(); } }} /> {/* 联系方式 */}
联系方式
{{ icon: () => ( ) }} {{ icon: () => ( ) }}
{/* 设置班级 */} (detailData.gradeShow = false)} onConfirm={value => { detailData.gradeShow = false; handleSetGrade(value.selectedOptions); }} /> {/* 选择退团列表 */}
选择乐团
请选择要退出的乐团:
{detailData.musicGroup.map( (group: IMusicGroup, index: number) => { return ( { checkboxRefs.value[index]?.toggle(); }}> {{ value: () => ( (checkboxRefs.value[index] = el)} shape="square" name={group.value} onClick={(e: Event) => e.stopPropagation() }> ) }} ); } )}
{/* 确定退团 */}
学员退团
确认要将学员 {quitName.value} 中退团吗?
*退团原因:
确认后,我们将在7个工作日内与学生联系退费事宜
); } });