diff --git a/src/views/canteen/accountCenter/butie/butie/index.vue b/src/views/canteen/accountCenter/butie/butie/index.vue index 4c03f11a..58217370 100644 --- a/src/views/canteen/accountCenter/butie/butie/index.vue +++ b/src/views/canteen/accountCenter/butie/butie/index.vue @@ -1,931 +1,1271 @@ - - - \ No newline at end of file + }); + const successVoList = (result.accInfoVOList || []).map(item => { + const phoneNumber = item.phoneNumber ? decryptWithSM4(item.phoneNumber) : item.phoneNumber; + return { + ...item, + phoneNumber, + amount: amountMap[item.userId] || amountMap[item.userId + ''] || item.amount + }; + }); + const invalidList = [ + ...(result.errVOList || []), + ...(result.invalidVOList || []) + ].map(item => ({ + ...item, + phoneNumber: item.phoneNumber ? decryptWithSM4(item.phoneNumber) : item.phoneNumber + })); + this.importPreviewData = { + ...result, + totalCount: result.totalUserSum, + successVoList, + invalidList + }; + // 关闭导入对话框,打开预览对话框 + this.openImport = false; + this.openImportPreview = true; + } else { + this.$modal.msgError(response.msg || response.message || '校验失败'); + } + }).catch(error => { + this.uploading = false; + this.uploadProgress = 0; + this.$modal.msgError(error.message || '上传失败,请重试'); + }); + }, + // 确认提交导入 + confirmImportSubmit() { + if (!this.importPreviewData.validUserIdList || this.importPreviewData.validUserIdList.length === 0) { + this.$modal.msgError('没有有效的记录可以提交!'); + return; + } + + // 仅提交有效人员及金额明细 + const userIdAmountMap = (this.importPreviewData.successVoList || []) + .filter(item => this.importPreviewData.validUserIdList.includes(String(item.userId))) + .map(item => ({ [item.userId]: item.amount })); + const param = { + userIds: this.importPreviewData.validUserIdList, + userIdAmountMap + }; + + // 调用提交接口 + request({ + url: '/smart-canteen/acc/subsidy/batch/import/add', + method: 'post', + data: param, + headers: { + 'Authorization': 'Bearer ' + getToken() + } + }).then(response => { + if (response.code === 200 || response.code === 0) { + this.$modal.msgSuccess("操作成功"); + this.openImportPreview = false; + this.getList(); + } else { + this.$modal.msgError(response.msg || response.message || '提交失败'); + } + }).catch(error => { + this.$modal.msgError(error.message || '提交失败,请重试'); + }); + }, + // 取消导入 + handleImportCancel() { + this.openImport = false; + this.fileList = []; + this.uploadProgress = 0; + this.uploading = false; + this.importPreviewData = {}; + if (this.$refs.upload) { + this.$refs.upload.clearFiles(); + } + }, + } +}; +