From 98eb6ed5f227cfbe2acd44cb7a98fa7af2c104f1 Mon Sep 17 00:00:00 2001 From: Lx <935448346@qq.com> Date: Wed, 2 Apr 2025 18:05:36 +0800 Subject: [PATCH] 0402-2 --- newPages/examinationAdd/index.vue | 149 +++++++++++++++-------------- newPages/examinationList/index.vue | 80 ++++++++++++---- 2 files changed, 139 insertions(+), 90 deletions(-) diff --git a/newPages/examinationAdd/index.vue b/newPages/examinationAdd/index.vue index 38dd68c..160d637 100644 --- a/newPages/examinationAdd/index.vue +++ b/newPages/examinationAdd/index.vue @@ -18,20 +18,13 @@ 是否通过 - {{ selectedValue || '请选择' }} - - @@ -57,13 +50,11 @@ @cancel="showTimePicker = false" > {{ process.examTime ? formatDate(process.examTime) : '选择时间' }} - - - + 考试类型 - C1 + {{ courseType }} 考试科目 @@ -85,18 +76,8 @@ {{ subjectValue || '请选择科目' }} - - - 备注 @@ -111,16 +92,6 @@ multiple :maxCount="2" > - @@ -141,17 +112,19 @@ export default { showTimePicker: false, subjectShow: false, ifPassColumns: [['已通过', '未通过']], - subjectColumns: [['科目一', '科目四' ]], + subjectColumns: [['科目一']], selectedValue: '', subjectValue: '', fileList: [], imageUrl: this.$imagesUrl, userInfo: [], + courseType: null, + courseCompleteStatusList: {}, process: { userName: null, userId: null, subject:null, - courseType: null, + examNum: null, examStatus: null, examScore: null, @@ -159,7 +132,7 @@ export default { examTime: null, images: null, tenantId: null, - + courseId: null, }, constants: {} }; @@ -171,16 +144,14 @@ export default { computed: { displayFileList() { return this.fileList.map(item => { - // 如果 url 已经是完整路径(http/https),直接使用 if (item.url.startsWith('http')) { return item; } - // 否则拼接全局前缀(注意处理路径分隔符) const prefix = this.$imagesUrl.endsWith('/') ? this.$imagesUrl : `${this.$imagesUrl}/`; const fullUrl = item.url.startsWith('/') - ? `${prefix}${item.url.slice(1)}` // 避免双斜杠(如 https://domain.com//path) - : `${prefix}${item.url}`; // 直接拼接(如 https://domain.com/path) + ? `${prefix}${item.url.slice(1)}` + : `${prefix}${item.url}`; return { ...item, @@ -204,10 +175,10 @@ export default { }; // 更新数据 - this.process.examStatus = statusMap[value.value[0]]; // 存储数值\ + this.process.examStatus = statusMap[value.value[0]]; console.log('value[0]', value.value[0]) - this.selectedValue = value.value[0]; // 存储文字,供页面显示 - this.show = false; // 关闭弹窗 + this.selectedValue = value.value[0]; + this.show = false; console.log('examStatus:', this.process.examStatus); console.log('process', this.process) @@ -222,10 +193,10 @@ export default { }; // 更新数据 - this.process.subject = statusMap[value.value[0]]; // 存储数值\ + this.process.subject = statusMap[value.value[0]]; console.log('value[0]', value.value[0]) - this.subjectValue = value.value[0]; // 存储文字,供页面显示 - this.subjectShow = false; // 关闭弹窗 + this.subjectValue = value.value[0]; + this.subjectShow = false; console.log('subject:', this.process.subject); console.log('process', this.process) @@ -233,8 +204,8 @@ export default { onConfirmExamTime(value) { console.log("选中的时间:", value); - this.process.examTime = value; // 保存到 process.examTime - this.showTimePicker = false; // 关闭时间选择器 + this.process.examTime = value; + this.showTimePicker = false; }, // 格式化时间戳的方法 formatDate(timestamp) { @@ -247,31 +218,21 @@ export default { return `${year}-${month}-${day} ${hours}:${minutes}`; }, - // 删除图片 - /* deletePic(event) { - this[`fileList${event.name}`].splice(event.index, 1) - if (event.name == '1') { - this.photoUrl.splice(event.index, 1) - } - if (event.name == '2') { - this.videoUr = null - } - - }, */ + deletePic(event) { - this.fileList.splice(event.index, 1); // 直接操作唯一的 fileList + this.fileList.splice(event.index, 1); }, // 新增图片 async afterRead(event) { - let lists = [].concat(event.file); // 兼容单个和多个文件 + let lists = [].concat(event.file); let fileListLen = this.fileList.length; for (let i = 0; i < lists.length; i++) { try { - const resultUrl = await this.uploadFilePromise(lists[i].url); // 上传图片并获取 URL + const resultUrl = await this.uploadFilePromise(lists[i].url); let item = { status: 'success', - url: resultUrl, // 服务器返回的 URL + url: resultUrl, }; this.fileList.splice(fileListLen, 0, item); fileListLen++; @@ -288,7 +249,7 @@ export default { filePath: filePath, }).then((res) => { if (res.data && res.data.url) { - resolve(res.data.url); // 返回图片 URL + resolve(res.data.url); console.log('返回', res) console.log('返回url', res.data.url) } else { @@ -303,7 +264,7 @@ export default { url: '/app-api/small/drive/school-course-order/page', method: 'GET', params: { - userId: this.userId, + userId: this.userInfo.id, paymentStatus:'2', ifEnd: 0, }, @@ -311,23 +272,65 @@ export default { }).then(res => { this.orderList = res.data.records; console.log('订单信息',res.data) - + if(res.data.records.length > 0){ + const tempData = res.data.records[0] + this.process.courseId = tempData.courseId + this.courseType = tempData.courseType + this.process.tenantId = tempData.tenantId + this.getCourseCompleteStatus() + } }); }, + + getCourseCompleteStatus(){ + console.log('userId', this.userId) + console.log('courseId', this.process.courseId) + request({ + url:'/app-api/process/page', + method: 'GET', + params: { + userId: this.userInfo.id, + courseId: this.process.courseId, + } + }).then(res => { + this.courseCompleteStatusList = res.data.records + console.log('res.data',res.data) + if(this.courseCompleteStatusList.length > 0){ + console.log('courseCompleteStatusList', this.courseCompleteStatusList) + const subject2 = this.courseCompleteStatusList.find(item => item.subject === 2) + const subject3 = this.courseCompleteStatusList.find(item => item.subject === 3) + + if (subject2?.status === 2 && subject3?.status === 2) { + this.subjectColumns = [['科目一', '科目四']] + } + } + }) + }, saveData() { + if(this.process.subject === 1 && this.courseCompleteStatusList.length <= 0){ + console.log('this.courseCompleteStatusList',this.courseCompleteStatusList) + uni.showToast({ title: '请联系驾校人员', icon: 'none' }); + return; + + } + if(this.process.subject === 4 && this.courseCompleteStatusList.length <= 0){ + + uni.showToast({ title: '请联系驾校人员', icon: 'none' }); + return; + + } + console.log('courseCompleteStatusList', this.courseCompleteStatusList.length) this.process.userId = this.userInfo.id this.process.tenantId = this.userInfo.tenantId - // 1. 拼接图片 URL this.process.images = this.fileList?.map(item => item.url).join(',') || ''; console.log('process', this.process) - // 2. 校验必填字段(可选) - if (!this.process.userId || !this.process.subject) { - uni.showToast({ title: '用户ID和科目不能为空', icon: 'none' }); + if (!this.process.userId || !this.process.subject || !this.process.examScore || !this.process.examStatus || !this.process.examTime) { + uni.showToast({ title: '信息填写不完整', icon: 'none' }); return; } - + request({ url: '/app-api/process/updateProcess', method: 'PUT', @@ -340,8 +343,8 @@ export default { duration: 1000 }); setTimeout(() => { - uni.navigateTo({ - url: '/newPages/examinationList/index' + uni.navigateBack({ + delta: 1 }); }, 1500); }else{ diff --git a/newPages/examinationList/index.vue b/newPages/examinationList/index.vue index a49f5ef..03af137 100644 --- a/newPages/examinationList/index.vue +++ b/newPages/examinationList/index.vue @@ -15,7 +15,7 @@ 考试结果录入 - + - - + {{ formatDate(item.examTime) }} + {{item.courseName}} + :style="{ color: item.examScore }" + >{{item.examScore}} + :style="{ color: item.examStatus }" + >{{ getStatusText(item.examStatus) }} - + {{getCourseTypeText(item.subject)}} - + {{item.courseType}} - - - - + @@ -91,6 +89,8 @@