import { Button, Cell, CellGroup, Checkbox, CheckboxGroup, Field, Icon, Image, List, Radio, RadioGroup, Tag, showToast } from 'vant'; import { defineComponent, onMounted, reactive, ref, watch } from 'vue'; import styles from './detail.module.less'; import iconTimer from '@/common/images/icon-timer.png'; import iconTeacher from '@/common/images/icon-teacher-default.png'; import iconEdit from '@/common/images/icon-edit.png'; import iconFace1 from './images/icon-face-1.png'; import iconFace2 from './images/icon-face-2.png'; import iconFace3 from './images/icon-face-3.png'; import iconFace4 from './images/icon-face-4.png'; import iconUploadImg from './images/icon-upload-img.png'; import iconUploadVideo from './images/icon-upload-video.png'; import SkeletionDetailModal from './skeletion-detail.modal'; import MUploader from '@/components/m-uploader'; import MUploaderInside from '@/components/m-uploader/inside'; import MFullRefresh from '@/components/m-full-refresh'; import { coursesStatus, evaluateStatus, problemType } from '@/helpers/constant'; import MEmpty from '@/components/m-empty'; import request from '@/helpers/request'; import dayjs from 'dayjs'; import { useRoute } from 'vue-router'; import MImagePreview from '@/components/m-image-preview'; import { checkFile } from '@/helpers/toolsValidate'; import deepClone from '@/helpers/deep-clone'; import iconVideoDefault from '@common/images/icon-video-c.png'; export default defineComponent({ name: 'detail-list', props: { type: { type: String, default: '' }, evaluateStatus: { type: String, default: '' }, problemType: { type: String, default: '' }, courseType: { type: String, default: '' }, status: { type: String, default: '' } }, setup(props) { const route = useRoute(); const forms = reactive({ isClick: false, imageShow: false, startPosition: 0, imagePreview: [] as string[], listState: { dataShow: true, // 判断是否有数据 loading: true, finished: false, refreshing: false }, params: { evaluateFlag: props.type === 'Evaluated' ? true : false, evaluateStatus: '', problemType: '', courseType: '', status: '', startTime: route.query.date || '', endTime: route.query.date || '', page: 1, rows: 20 }, changeType: null, questionType: null, evaluateList: [] as any, problemTypeList: [] as any, list: [] }); const list = ref([] as any[]); const onRefresh = () => { forms.params.page = 1; getList(); }; const getList = async () => { try { if (forms.isClick) return; forms.isClick = true; const { data } = await request.post( '/api-web/coursePatrolEvaluation/page', { data: forms.params } ); const result = data || {}; // 格式化数据 const rows = result.rows || []; rows.forEach((row: any) => { const attachmentUrlList = row.attachmentUrl ? row.attachmentUrl.split(',') : []; const problemTypeList = row.problemType ? row.problemType.split(',') : []; row.problemTypeList = problemTypeList; // 级别 row.submitEvaluateStatus = row.evaluateStatus || ''; // 问题类型 row.submitProblemType = problemTypeList || []; row.submitProblemDesc = row.problemDesc || ''; // 图片和视屏 row.submitVideoList = []; row.submitImgList = []; attachmentUrlList.forEach((url: any) => { // 判断是否是图片 if (checkFile(url, 'image')) { row.submitImgList.push(url); } else { row.submitVideoList.push(url); } // 判断是否是视频 }); row.attachmentUrlList = attachmentUrlList || []; // 判断是否评价,如果有评价则直接显示评价内容 if (!row.evaluateFlag) { row.isEdit = true; } }); // 判断是否有数据 if (forms.listState.refreshing) { list.value = rows || []; } else { list.value = list.value.concat(rows || []); } forms.listState.finished = result.pageNo >= result.totalPage; forms.params.page = result.pageNo + 1; } catch { forms.listState.finished = true; } finally { forms.listState.dataShow = list.value.length > 0; forms.listState.refreshing = false; forms.listState.loading = false; forms.isClick = false; } }; // 提交评价 const onSubmit = async (item: any) => { try { const url = [...item.submitImgList, ...item.submitVideoList]; // if (!item.submitEvaluateStatus) { showToast('请选择评价'); return; } // 当选择“不合格”的时候,问题类型、问题描述、上传附件为必填项 if (item.submitEvaluateStatus === 'UNQUALIFIED') { if (!item.submitProblemType) { showToast('请选择问题类型'); return; } if (!item.submitProblemDesc) { showToast('请输入问题描述'); return; } // 最大支持3-50汉字 if ( item.submitProblemDesc.length < 3 || item.submitProblemDesc.length <= 50 ) if (url.length <= 0) { showToast('请上传附件'); return; } } const params = { id: item.id, evaluateStatus: item.submitEvaluateStatus, problemType: item.submitProblemType.join(','), problemDesc: item.submitProblemDesc, attachmentUrl: url.join(',') }; if (item.evaluateFlag) { // 修改 await request.post('/api-web/coursePatrolEvaluation/update', { hideLoading: false, data: params }); } else { // 修改 await request.post('/api-web/coursePatrolEvaluation/save', { hideLoading: false, data: { ...params, courseScheduleId: item.courseScheduleId } }); } list.value = []; onRefresh(); } catch { // } }; const onShowPreView = (attachmentUrlList: string[], index: number) => { forms.imagePreview = deepClone(attachmentUrlList); forms.imageShow = true; forms.startPosition = index; }; const formatFace = (type: string) => { if (type === 'EXCELLENT') { return iconFace1; } else if (type === 'GOOD') { return iconFace2; } else if (type === 'QUALIFIED') { return iconFace3; } else if (type === 'UNQUALIFIED') { return iconFace4; } else { return iconFace1; } }; onMounted(() => { for (const key in evaluateStatus) { if (Object.prototype.hasOwnProperty.call(evaluateStatus, key)) { forms.evaluateList.push({ text: evaluateStatus[key], value: key }); } } for (const key in problemType) { if (Object.prototype.hasOwnProperty.call(problemType, key)) { forms.problemTypeList.push({ text: problemType[key], value: key }); } } getList(); }); // 监听 watch( () => [ props.evaluateStatus, props.problemType, props.courseType, props.status ], () => { forms.params.evaluateStatus = props.evaluateStatus; forms.params.problemType = props.problemType; forms.params.courseType = props.courseType; forms.params.status = props.status; list.value = []; onRefresh(); } ); return () => (
onRefresh()} style={{ minHeight: `calc(100vh - var(--header-height) - var(--van-tabs-line-height))` }}> {forms.listState.dataShow ? ( list.value.map((item: any) => { return ( {{ icon: () => ( ), title: () => (
{dayjs(item.startClassTime).format( 'YYYY-MM-DD HH:mm' )} ~{dayjs(item.endClassTime).format('HH:mm')}
), value: () => (
{ item.isEdit = true; }}> {/* 判断是否评价 */} {item.evaluateFlag ? ( <> {evaluateStatus[item.evaluateStatus]} ) : ( {coursesStatus[item.courseStatus]} )}
) }}
{{ icon: () => ( ), title: () => (
{item.courseName}
{item.teacherName}
), value: () => (
{item.attachmentUrlList.map( (file: string, index: number) => index < 3 && (
{ e.stopPropagation(); e.preventDefault(); onShowPreView( item.attachmentUrlList, index ); }}> {checkFile(file, 'image') ? ( ) : ( )} {/* 判断是否大于三个 */} {item.attachmentUrlList.length > 3 && index === 2 ? (
+{item.attachmentUrlList.length - 3}
) : ( '' )}
) )}
) }}
{/* 展示结果 */} {(item.submitProblemType.length > 0 || item.problemDesc) && !item.isEdit ? ( {item.problemTypeList.length > 0 ? (
{item.problemTypeList.map((type: string) => ( {problemType[type]} ))}
) : ( '' )} {item.problemDesc ? (
{item.problemDesc}
) : ( '' )}
) : ( '' )} {/* 未开始的不能进行评价 */} {item.isEdit && item.courseStatus != 'NOT_START' ? ( {forms.evaluateList.map((child: any) => ( {child.text} ))} {/* 当选择“不合格”的时候,问题类型、问题描述、上传附件为必填项 当选择除不合格的其他选项时,问题类型、问题描述不展示,桑川附件为选填 */} {item.submitEvaluateStatus === 'UNQUALIFIED' ? ( <>
问题类型
{forms.problemTypeList.map((child: any) => ( {child.text} ))}
问题描述
) : ( '' )}
上传附件
{/* 评价之后才能取消 */} {item.evaluateFlag ? ( ) : ( '' )}
) : ( '' )}
); }) ) : ( )}
); } });