diff --git a/mobile/src/pages/xg/xsjcxx/xsqj/leaveEdit/index.vue b/mobile/src/pages/xg/xsjcxx/xsqj/leaveEdit/index.vue index 51862ed9..111cf56e 100644 --- a/mobile/src/pages/xg/xsjcxx/xsqj/leaveEdit/index.vue +++ b/mobile/src/pages/xg/xsjcxx/xsqj/leaveEdit/index.vue @@ -132,10 +132,6 @@ - {{ form.needCancel === '1' ? '需要' : '不需要' }} @@ -190,19 +186,6 @@ - @@ -380,14 +363,6 @@ - - - - - - @@ -750,76 +718,6 @@ export default { await this.initWechatSDK(); }, - // 微信选择图片 - // async chooseWechatImage() { - // if (!this.isWechatBrowser) { - // this.addWechatLog('非微信环境,无法使用微信选择图片功能', 'error'); - // uni.showToast({ - // title: '请在微信中打开', - // icon: 'none', - // }); - // return; - // } - - // if (!this.wechatSDK.isInitialized) { - // this.addWechatLog('微信SDK未初始化,尝试重新初始化...', 'warning'); - // await this.initWechatSDK(); - - // if (!this.wechatSDK.isInitialized) { - // uni.showToast({ - // title: '微信SDK未就绪', - // icon: 'none', - // }); - // return; - // } - // } - - // // 检查文件数量限制 - // if (this.attachmentList.length >= 15) { - // uni.showToast({ - // title: '最多只能上传15个文件', - // icon: 'none', - // }); - // return; - // } - - // this.wechatImageLoading = true; - // this.uploadProgress = 0; - // this.addWechatLog('开始选择微信图片...', 'info'); - - // try { - // // 计算剩余可选择的图片数量 - // const remainingCount = 5 - this.attachmentList.length; - // const selectCount = Math.min(remainingCount, 9); - - // this.addWechatLog(`可选择图片数量: ${selectCount}`, 'info'); - - // const result = await this.wechatSDK.chooseImage({ - // count: selectCount, - // sizeType: ['original', 'compressed'], - // sourceType: ['album', 'camera'], - // }); - - // this.addWechatLog(`成功选择了 ${result.localIds.length} 张图片`, 'success'); - - // // 处理选中的图片 - // if (result.localIds && result.localIds.length > 0) { - // await this.processWechatImages(result.localIds); - // } - // } catch (error) { - // console.error('微信选择图片失败:', error); - // this.addWechatLog(`选择图片失败: ${error.message}`, 'error'); - - // uni.showToast({ - // title: '选择图片失败', - // icon: 'none', - // }); - // } finally { - // this.wechatImageLoading = false; - // this.uploadProgress = 0; - // } - // }, - // 上传微信图片到OSS(参考stuMsgDialog.vue的实现) async uploadWechatImageToOSS(localId) { try { @@ -890,114 +788,6 @@ export default { } }, - // 处理微信选中的图片(支持多文件上传) - // async processWechatImages(localIds) { - // this.addWechatLog(`开始处理 ${localIds.length} 张微信图片...`, 'info'); - - // // 检查文件数量限制 - // if (this.attachmentList.length + localIds.length > 15) { - // const canUpload = 15 - this.attachmentList.length; - // if (canUpload <= 0) { - // uni.showToast({ - // title: '最多只能上传15个文件', - // icon: 'none', - // }); - // return; - // } - - // // 只处理允许上传的数量 - // localIds = localIds.slice(0, canUpload); - // uni.showToast({ - // title: `已选择前${canUpload}张图片`, - // icon: 'none', - // duration: 2000, - // }); - // } - - // const totalFiles = localIds.length; - // let successCount = 0; - // let failureCount = 0; - - // for (let i = 0; i < totalFiles; i++) { - // const localId = localIds[i]; - - // // 计算总体进度 - // const overallProgress = Math.round((i / totalFiles) * 100); - // this.addWechatLog( - // `正在处理第 ${i + 1}/${totalFiles} 张图片... (${overallProgress}%)`, - // 'info', - // ); - - // try { - // // 创建文件对象并添加到列表(显示上传中状态) - // const file = { - // uid: `wechat_${Date.now()}_${i}`, - // name: `微信图片_${Date.now()}_${i + 1}.jpg`, - // url: localId, - // localId: localId, - // status: 'uploading', - // type: 'image/jpeg', - // size: 0, // 微信API无法直接获取文件大小 - // source: 'wechat', - // progress: 0, - // }; - - // // 添加到附件列表(立即显示) - // this.attachmentList.push(file); - - // // 上传到OSS - // const uploadResult = await this.uploadWechatImageToOSS(localId); - - // // 更新文件信息 - // file.status = 'success'; - // file.ossId = uploadResult.ossId; - // file.url = uploadResult.url; - // file.name = uploadResult.fileName || file.name; - // file.size = uploadResult.fileSize || 0; - // file.progress = 100; - - // successCount++; - // this.addWechatLog(`✅ 第 ${i + 1} 张图片上传成功: ${file.name}`, 'success'); - // } catch (error) { - // console.error(`处理微信图片失败:`, error); - - // // 更新失败的文件状态 - // const failedFile = this.attachmentList.find((f) => f.localId === localId); - // if (failedFile) { - // failedFile.status = 'error'; - // failedFile.progress = 0; - // } - - // failureCount++; - // this.addWechatLog(`❌ 第 ${i + 1} 张图片上传失败: ${error.message}`, 'error'); - // } - - // // 重置单个文件的进度条 - // this.uploadProgress = 0; - // } - - // // 显示最终结果 - // const resultMessage = `上传完成: 成功${successCount}个,失败${failureCount}个`; - // this.addWechatLog(resultMessage, successCount > 0 ? 'success' : 'warning'); - - // if (successCount > 0) { - // uni.showToast({ - // title: `成功上传${successCount}个文件`, - // icon: 'success', - // duration: 2000, - // }); - // } - - // if (failureCount > 0) { - // uni.showModal({ - // title: '部分文件上传失败', - // content: `${failureCount}个文件上传失败,请检查网络后重试`, - // showCancel: false, - // confirmText: '知道了', - // }); - // } - // }, - // 打开地图查看位置 async openLocationInMap() { if (!this.form.leaveLocation) { @@ -1715,18 +1505,6 @@ export default { } }, - // 保留原有方法作为备用(标记为废弃) - // async tryWeChatLocation() { - // console.warn('tryWeChatLocation 方法已废弃,请使用 tryWeChatLocationWithSDK 方法'); - // return this.tryWeChatLocationWithSDK(); - // }, - - // 一键定位:优先使用微信JSSDK,失败回退到uni.getLocation - // async handleGetWeChatLocation() { - // console.warn('handleGetWeChatLocation 方法已废弃,请使用 handleGetLocation 方法'); - // return this.handleGetLocation(); - // }, - // 回退定位(浏览器/APP内置能力) async handleFallbackLocation() { return new Promise((resolve) => { @@ -1904,8 +1682,6 @@ export default { } else { this.form.leaveDuration = diffDays.toFixed(2); } - - } }, @@ -2058,11 +1834,6 @@ export default { target.closest('.image-actions') || target.closest('u-button') || target.tagName === 'BUTTON'; - - // 如果点击的是操作按钮区域,不触发预览 - // if (!isActionButton) { - // this.handleImagePreview(image, index); - // } }, // 删除按钮点击处理(更强的事件处理) @@ -2240,26 +2011,12 @@ export default { // 显示选择文件类型的操作菜单 uni.showActionSheet({ - // itemList: ['选择图片', '选择文档', '微信选择图片'], itemList: ['选择图片'], success: (res) => { switch (res.tapIndex) { case 0: this.chooseDocuments(); break; - // case 1: - // this.chooseImages(); - // break; - // case 2: - // if (this.isWechatBrowser) { - // this.chooseWechatImage(); - // } else { - // uni.showToast({ - // title: '请在微信中使用', - // icon: 'none', - // }); - // } - // break; } }, fail: () => { @@ -2268,38 +2025,6 @@ export default { }); }, - // 选择图片文件 - // chooseImages() { - // uni.chooseImage({ - // count: Math.min(9, 15 - this.attachmentList.length), - // sizeType: ['original', 'compressed'], - // sourceType: ['album', 'camera'], - // success: (res) => { - // console.log('选择图片成功:', res); - // const files = res.tempFilePaths.map((path, index) => { - // const tempFile = res.tempFiles?.[index]; - // return { - // name: path.split('/').pop() || `image_${Date.now()}_${index}.jpg`, - // path: path, - // url: path, - // tempFilePath: path, - // size: tempFile?.size || 0, - // type: tempFile?.type || 'image/jpeg', - // }; - // }); - - // this.handleFileUpload({ tempFiles: files }); - // }, - // fail: (err) => { - // console.error('选择图片失败:', err); - // uni.showToast({ - // title: '选择图片失败', - // icon: 'none', - // }); - // }, - // }); - // }, - // 选择文档文件 chooseDocuments() { // 使用uni.chooseFile选择文档 @@ -2831,72 +2556,6 @@ export default { // 下载图片并保存到相册 async downloadAndSaveImage(downloadUrl, fileName) { return new Promise(async (resolve, reject) => { - // #ifdef MP-WEIXIN - // 微信小程序:使用downloadFile下载到临时文件,然后保存到相册 - // uni.downloadFile({ - // url: this.getFullApiUrl(downloadUrl), - // header: this.getRequestHeaders(), - // success: (res) => { - // console.log('✅ 图片下载成功:', res); - // if (res.statusCode === 200) { - // // 保存到相册 - // uni.saveImageToPhotosAlbum({ - // filePath: res.tempFilePath, - // success: () => { - // console.log('✅ 图片保存到相册成功'); - // uni.hideLoading(); - // uni.showToast({ - // title: '图片已保存到相册', - // icon: 'success', - // duration: 2000, - // }); - // resolve(); - // }, - // fail: (err) => { - // console.error('❌ 保存图片到相册失败:', err); - // uni.hideLoading(); - // if (err.errMsg.includes('auth deny')) { - // uni.showModal({ - // title: '权限提示', - // content: - // '需要授权访问相册才能保存图片,请在设置中开启权限', - // showCancel: false, - // }); - // } else { - // uni.showToast({ - // title: '保存图片失败', - // icon: 'none', - // }); - // } - // reject(err); - // }, - // }); - // } else { - // uni.hideLoading(); - // uni.showToast({ - // title: '图片下载失败', - // icon: 'none', - // }); - // reject(new Error('下载失败')); - // } - // }, - // fail: (error) => { - // console.error('❌ 图片下载失败:', error); - // uni.hideLoading(); - // uni.showToast({ - // title: '图片下载失败', - // icon: 'none', - // }); - // reject(error); - // }, - // }); - // #endif - - // #ifdef H5 - // H5环境:直接使用浏览器下载 - // this.downloadFileInBrowser(downloadUrl, fileName); - // const downloadUrl = `/resource/oss/download/${image.ossId}`; - // 调用下载接口并等待完成 const response = await downloadFile(downloadUrl, fileName); @@ -2927,72 +2586,6 @@ export default { // 下载文档并打开预览 async downloadAndOpenDocument(downloadUrl, fileName) { return new Promise(async (resolve, reject) => { - // #ifdef MP-WEIXIN - // 微信小程序:下载到临时文件并直接打开 - // uni.downloadFile({ - // url: this.getFullApiUrl(downloadUrl), - // header: this.getRequestHeaders(), - // success: (res) => { - // console.log('✅ 文档下载成功:', res); - // if (res.statusCode === 200) { - // uni.hideLoading(); - // // 直接打开文档预览 - // uni.openDocument({ - // filePath: res.tempFilePath, - // fileType: this.getFileType(fileName), - // success: () => { - // console.log('✅ 文档打开成功'); - // resolve(); - // }, - // fail: (err) => { - // console.error('❌ 文档打开失败:', err); - // // 如果无法直接打开,提供其他选项 - // uni.showModal({ - // title: '无法预览', - // content: '该文件格式不支持预览,您可以选择其他操作', - // showCancel: true, - // cancelText: '取消', - // confirmText: '分享文件', - // success: (modalRes) => { - // if (modalRes.confirm) { - // // 可以通过分享功能让用户保存文件 - // // #ifdef MP-WEIXIN - // wx.shareFileMessage && - // wx.shareFileMessage({ - // filePath: res.tempFilePath, - // fileName: fileName, - // }); - // // #endif - // } - // }, - // }); - // reject(err); - // }, - // }); - // } else { - // uni.hideLoading(); - // uni.showToast({ - // title: '文档下载失败', - // icon: 'none', - // }); - // reject(new Error('下载失败')); - // } - // }, - // fail: (error) => { - // console.error('❌ 文档下载失败:', error); - // uni.hideLoading(); - // uni.showToast({ - // title: '文档下载失败', - // icon: 'none', - // }); - // reject(error); - // }, - // }); - // // #endif - - // // #ifdef H5 - // // H5环境:直接使用浏览器下载 - // this.downloadFileInBrowser(downloadUrl, fileName); // 调用下载接口并等待完成 const response = await downloadFile(downloadUrl, fileName); @@ -3020,19 +2613,6 @@ export default { }); }, - // 获取完整的API地址 - getFullApiUrl(url) { - if (url.startsWith('http')) { - return url; - } - // 从配置中获取base URL - const baseURL = - process.env.NODE_ENV === 'development' - ? 'http://localhost:8080' - : 'https://your-api-domain.com'; - return baseURL + url; - }, - // 获取请求头(包含认证信息) getRequestHeaders() { const headers = {}; @@ -3062,17 +2642,6 @@ export default { return typeMap[ext] || ''; }, - // H5环境下的文件下载 - downloadFileInBrowser(downloadUrl, fileName) { - const link = document.createElement('a'); - link.href = this.getFullApiUrl(downloadUrl); - link.download = fileName; - link.target = '_blank'; - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); - }, - // 预览图片文件 previewImageFile(file) { console.log('=== 预览图片文件 ===', file); @@ -3541,31 +3110,6 @@ export default { if (workflowResponse.code === 200) { this.$refs.submitVerifyRef.openDialog(workflowResponse.data.taskId); - // 启动工作流成功提示 - // uni.showToast({ - // title: '工作流启动成功', - // icon: 'success', - // duration: 1500, - // }); - // 延迟返回上一页,确保用户看到成功提示 - // setTimeout(() => { - // // 通知上一页刷新数据 - // uni.$emit('refreshLeaveList'); - // uni.navigateBack(); - // }, 1600); - } else { - // 启动工作流失败 - // uni.showToast({ - // title: workflowResponse.msg || '启动工作流失败', - // icon: 'none', - // duration: 2000, - // }); - // 延迟返回上一页,确保用户看到失败提示 - // setTimeout(() => { - // // 通知上一页刷新数据 - // uni.$emit('refreshLeaveList'); - // uni.navigateBack(); - // }, 2100); } } catch (error) { console.error('启动工作流失败:', error); @@ -3574,13 +3118,6 @@ export default { icon: 'none', duration: 2000, }); - - // 延迟返回上一页,确保用户看到错误提示 - // setTimeout(() => { - // // 通知上一页刷新数据 - // uni.$emit('refreshLeaveList'); - // uni.navigateBack(); - // }, 2100); } }, @@ -3667,37 +3204,6 @@ export default { } }, 1600); }, - - // // 文件选择前事件 - 应该在用户点击选择图片后首先触发 - // handleBeforeRead(event) { - // console.log('文件选择前事件触发:', event); - // uni.showToast({ - // title: '正在选择文件...', - // icon: 'loading', - // duration: 1000, - // }); - // return true; // 允许继续选择文件 - // }, - - // // 预览点击事件 - // handleClickPreview(event) { - // console.log('点击预览事件:', event); - // }, - - // // 上传进度事件 - // handleUploadProgress(event) { - // console.log('上传进度事件:', event); - // }, - - // // 上传成功事件 - // handleUploadSuccess(event) { - // console.log('上传成功事件:', event); - // }, - - // // 上传错误事件 - // handleUploadError(event) { - // console.log('上传错误事件:', event); - // }, }, };