“1024人事工作流修改1.0版本”

This commit is contained in:
weizhong committed 2025-10-24 10:08:18 +08:00
1 parent 2f2e303781
commit 13cabfcb6c
236 files changed
+2510 -59666

No files matched your search

+312 -451
View File
@@ -78,6 +78,14 @@
<el-tag :type="getStatusTagType(scope.row.status)">{{ scope.row.statusText }}</el-tag>
</template>
</el-table-column>
<el-table-column label="工作流状态" align="center" prop="approvalStatusText" min-width="110">
<template #default="scope">
<el-tag v-if="scope.row.approvalStatus" :type="getApprovalStatusTagType(scope.row.approvalStatus)">
{{ scope.row.approvalStatusText || '-' }}
</el-tag>
<el-tag v-else type="info">未启动</el-tag>
</template>
</el-table-column>
<el-table-column label="申请时间" align="center" prop="applyTime" min-width="160" :show-overflow-tooltip="true" />
<el-table-column label="操作" align="center" width="240">
<template #default="scope">
@@ -90,6 +98,25 @@
v-hasPermi="['rs:overseas:query']"
></el-button>
</el-tooltip>
<!-- 待审批状态:显示审批按钮 -->
<el-tooltip content="审批" placement="top" v-if="scope.row.approvalStatus === 'waiting' && scope.row.taskId">
<el-button
link
type="success"
icon="Check"
@click="handleApproval(scope.row)"
v-hasPermi="['overseas:application:*:approve']"
></el-button>
</el-tooltip>
<!-- 已启动工作流:显示查看流程按钮 -->
<el-tooltip content="查看流程" placement="top" v-if="scope.row.approvalStatus && scope.row.approvalStatus !== 'draft'">
<el-button
link
type="info"
icon="Postcard"
@click="handleViewProcess(scope.row)"
></el-button>
</el-tooltip>
<!-- 待审核状态:显示撤回按钮 -->
<el-tooltip content="撤回申请" placement="top" v-if="scope.row.status === '0'">
<el-button
@@ -194,9 +221,6 @@
<el-card shadow="never" class="button-card table-card">
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button icon="Download" @click="handleExportRecord" v-hasPermi="['rs:overseas:export']">导出</el-button>
</el-col>
<right-toolbar v-model:showSearch="showRecordSearch" @queryTable="getRecordList"></right-toolbar>
</el-row>
</template>
@@ -445,6 +469,17 @@
destroy-on-close
>
<template #default>
<!-- 工作流按钮组件 -->
<approvalButton
v-if="state.pageType"
@submitForm="submitForm"
@approvalVerifyOpen="approvalVerifyOpen"
@handleApprovalRecord="handleApprovalRecord"
:id="state.applicationForm.applicationId"
:status="state.applicationForm.approvalStatus"
:pageType="state.pageType"
/>
<div style="max-height: 65vh; overflow-y: auto; padding-right: 10px;">
<el-form ref="applicationFormRef" :model="applicationForm" :rules="applicationRules" label-width="120px">
@@ -705,86 +740,6 @@
@click="handleRegistrationAttachment"
>登记备案附件</el-button
> -->
<!-- 盖章文件上传区域 -->
<div class="stamped-file-upload-section" style="margin: 10px 0; padding: 10px; border: 1px dashed #dcdfe6; border-radius: 4px;">
<div style="font-size: 14px; color: #606266; margin-bottom: 8px;">
<el-icon><Document /></el-icon>
出国境登记表盖章上传
</div>
<div style="font-size: 12px; color: #ff4757; margin-bottom: 8px;">
请先提交出国登记流程,审批通过后下载"登记备案附件",并加盖公章后,在此上传盖章文件后再提交审批
</div>
<div class="attachment-upload-container">
<el-upload
ref="stampedFileUpload"
:file-list="stampedFileList"
class="upload-demo"
drag
list-type="picture-card"
:on-preview="handleStampedFilePreview"
:action="uploadStampedFileAction"
:headers="uploadHeaders"
:data="{ applicationId: applicationForm.applicationId || 0 }"
:auto-upload="true"
:before-upload="beforeStampedFileUpload"
:on-success="handleStampedFileUploadSuccess"
:on-error="handleStampedFileUploadError"
:on-remove="handleStampedFileRemoveConfirm"
:on-change="handleStampedFileChange"
:limit="1"
:show-file-list="true"
accept=".pdf,.jpg,.jpeg,.png"
>
<template #tip>
<div class="el-upload__tip">
支持PDF、JPG、PNG格式,文件大小不超过10MB,只能上传1个文件
</div>
</template>
<!-- 调整拖拽上传图标与文字在同一行、居中对齐 -->
<div class="el-upload-dragger1">
<el-icon class="el-icon--upload"><UploadFilled /></el-icon>
<div class="el-upload__text"><em>点击上传</em></div>
</div>
<!-- 自定义文件卡片缩略图(含文件名) -->
<template #file="{ file }">
<div class="upload-file-card">
<!-- 缩略图区域 -->
<div class="upload-file-thumb">
<ImagePreview v-if="isImageFileStamped(file) && file.url" :src="getFileOssIdStamped(file)" class="upload-thumb-image" :isOssId="true" />
<div v-else class="upload-file-placeholder">
<el-icon><Document /></el-icon>
<span class="file-ext">{{ getFileExtStamped(file.name) }}</span>
</div>
<!-- loading 遮罩只在上传中显示 -->
<div v-if="file.status === 'uploading'" class="upload-file-loading">
<el-icon class="is-loading"><Loading /></el-icon>
<span class="loading-text">上传中...</span>
</div>
</div>
<!-- 文件名称 -->
<div class="upload-file-name" :title="file.name">
{{ getShortFileNameStamped(file.name) }}
</div>
<!-- 操作按钮区域 - 固定在文件名下方 -->
<div class="upload-file-card-actions" v-if="file.status && file.status !== 'ready'">
<el-button-group size="small">
<el-button type="success" @click.stop="handleDownloadStampedAttachment(file)" title="下载" :disabled="file.status !== 'success'">
<el-icon><Download /></el-icon>
</el-button>
<el-button type="danger" @click.stop="handleStampedFileRemoveConfirm(file)" title="删除">
<el-icon><Delete /></el-icon>
</el-button>
</el-button-group>
</div>
</div>
</template>
</el-upload>
</div>
</div>
<!-- 党籍保留附件上传区域(仅当中共党员且出国天数>30天时显示) -->
<div
@@ -798,6 +753,20 @@
<div style="font-size: 12px; color: #606266; margin-bottom: 8px;">
您是中共党员且出国天数超过30天,需要先提交党籍保留流程,审批通过后下载并上传盖章附件
</div>
<!-- 下载PDF空白模板按钮 -->
<div style="margin-bottom: 10px;">
<el-button
type="primary"
size="small"
icon="Download"
@click="handleDownloadPartyRetention"
>
下载党籍保留申请PDF模板
</el-button>
<span style="margin-left: 10px; font-size: 12px; color: #909399;">
* 请先下载空白模板并手工填写,然后上传盖章后的文件
</span>
</div>
<div class="attachment-upload-container">
<el-upload
ref="partyRetentionUpload"
@@ -1113,6 +1082,15 @@
<!-- 申请详情操作按钮 -->
<template #footer v-if="state.viewData && 'applicationId' in state.viewData && !('recordId' in state.viewData)">
<div class="dialog-footer">
<!-- 下载党籍保留申请按钮(仅党员且出国天数>30天时显示) -->
<el-button
v-if="shouldShowPartyRetentionDownload(state.viewData as OverseasApplicationVO)"
type="success"
@click="handleDownloadPartyRetention"
icon="Document"
>
下载党籍保留申请
</el-button>
<el-button @click="state.viewDialog.visible = false">关闭</el-button>
</div>
</template>
@@ -1130,7 +1108,7 @@
<el-descriptions-item label="现工作部门">{{ state.viewData.department || '-' }}</el-descriptions-item>
<el-descriptions-item label="职称">{{ (state.viewData as OverseasRecordVO).professionalTitle || '-' }}</el-descriptions-item>
<el-descriptions-item label="职务">{{ state.viewData.position || '-' }}</el-descriptions-item>
<el-descriptions-item label="职务">{{ (state.viewData as OverseasRecordVO).positionText || state.viewData.position || '-' }}</el-descriptions-item>
<el-descriptions-item label="申领证件名称">{{ (state.viewData as OverseasRecordVO).documentName || '-' }}</el-descriptions-item>
<!-- 证件信息 -->
@@ -1269,7 +1247,7 @@
</el-table-column>
<el-table-column label="审批结果" align="center" prop="approvalStatus" width="100">
<template #default="scope">
<el-tag :type="getApprovalStatusTagType(scope.row.approvalStatus)">
<el-tag :type="getOldApprovalStatusTagType(scope.row.approvalStatus)">
<span v-if="scope.row.approvalStatus === '0'">待审核</span>
<span v-else-if="scope.row.approvalStatus === '1'">通过</span>
<span v-else-if="scope.row.approvalStatus === '2'">拒绝</span>
@@ -1289,6 +1267,20 @@
</div>
</template>
</el-dialog>
<!-- 工作流提交审批对话框 -->
<submitVerify
ref="submitVerifyRef"
:task-variables="{}"
@submitCallback="submitSuccess"
/>
<!-- 工作流审批记录对话框 -->
<approvalRecord
ref="approvalRecordRef"
:businessId="state.applicationForm.applicationId"
flowCode="overseas-application"
/>
</div>
</template>
@@ -1308,7 +1300,6 @@ import {
cancelOverseasApplication,
delOverseasApplication,
exportOverseasApplication,
exportOverseasRecord,
approveOverseasApplication,
getOverseasApprovalHistory,
downloadRegistrationTemplate,
@@ -1335,6 +1326,13 @@ import { parseTime } from '@/utils/ruoyi';
import { checkPermi } from '@/utils/permission';
import { getToken } from '@/utils/auth';
import request from '@/utils/request';
// 工作流组件导入
import approvalButton from '@/components/Process/approvalButton.vue';
import submitVerify from '@/components/Process/submitVerify.vue';
import approvalRecord from '@/components/Process/approvalRecord.vue';
// 工作流API导入
import { startWorkFlow } from '@/api/workflow/task';
import { cancelProcessApply } from '@/api/workflow/instance';
// 响应式数据
const { proxy } = getCurrentInstance() as any;
@@ -1346,6 +1344,9 @@ const applicationQueryForm = ref<any>(null);
const recordQueryForm = ref<any>(null);
const attachmentFormRef = ref<any>(null);
const attachmentUploadRef = ref<any>(null);
// 工作流组件引用
const submitVerifyRef = ref<any>(null);
const approvalRecordRef = ref<any>(null);
// 附件相关数据
const attachmentList = ref<OverseasAttachmentVO[]>([]);
@@ -1403,6 +1404,7 @@ const state = reactive({
applicationForm: {} as OverseasApplicationForm,
isResubmitMode: false, // 标记是否为重新提交模式
submitLoading: false, // 提交loading状态
pageType: '', // 页面类型:add-新增,update-编辑,approval-审批
applicationRules: {
applicantName: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
gender: [{ required: true, message: '性别不能为空', trigger: 'change' }],
@@ -1479,9 +1481,6 @@ const state = reactive({
{ label: '提前结束', value: '2' }
],
// 盖章文件上传相关
stampedFileList: [] as any[],
// 党籍保留附件上传相关
partyRetentionFileList: [] as any[],
showPartyRetentionUpload: false // 是否显示党籍保留上传组件
@@ -1510,15 +1509,9 @@ const {
currentApplication,
statusOptions,
purposeOptions,
completionStatusOptions,
stampedFileList
completionStatusOptions
} = toRefs(state);
// 上传盖章文件的action地址
const uploadStampedFileAction = computed(() => {
return import.meta.env.VITE_APP_BASE_API + '/rs/overseas/application/uploadStampedFile';
});
// 上传文件的headers配置
const uploadHeaders = computed(() => {
return {
@@ -1685,12 +1678,13 @@ const resetRecordQuery = () => {
// 新增登记
const handleAddApplication = () => {
// 显示文件通知阅读弹窗
state.noticeDialog.visible = true;
state.countdown = 5;
state.countdownActive = true;
state.readCompleted = false;
startCountdown();
// 跳转到新增申请页面
proxy.$router.push({
path: '/rs/overseas/overseas-form',
query: {
type: 'add'
}
});
};
// 开始倒计时
@@ -1712,6 +1706,7 @@ const handleReadComplete = () => {
// 重置申请表单并打开申请对话框
resetApplicationForm();
state.applicationDialog.title = '新增因私出国(境)申请登记报备表';
state.pageType = 'add'; // 设置页面类型为新增
state.applicationDialog.visible = true;
};
@@ -1726,25 +1721,14 @@ const handleCloseNotice = () => {
// 编辑申请
const handleUpdateApplication = async (row: OverseasApplicationVO) => {
resetApplicationForm();
try {
const response = await getOverseasApplication(row.applicationId);
state.applicationForm = response.data;
state.applicationDialog.title = '修改因私出国(境)申请登记报备表';
state.applicationDialog.visible = true;
// 加载附件列表
await loadAttachmentList(row.applicationId);
// 在下一个tick中恢复签名
nextTick(() => {
if (response.data.signature && signatureCanvas.value) {
restoreSignature(response.data.signature);
}
});
} catch (error) {
console.error('获取申请详情失败:', error);
}
// 跳转到编辑申请页面
proxy.$router.push({
path: '/rs/overseas/overseas-form',
query: {
type: 'edit',
id: row.applicationId
}
});
};
// 查看申请详情
@@ -1807,34 +1791,14 @@ const handleSubmitApplication = (row: OverseasApplicationVO) => {
// 修改并重新提交申请(用于已拒绝状态)
const handleUpdateAndResubmitApplication = async (row: OverseasApplicationVO) => {
try {
// 获取申请详情
const response = await getOverseasApplication(row.applicationId);
if (response.code === 200 && response.data) {
// 设置表单数据
Object.assign(state.applicationForm, response.data);
// 设置为编辑模式并标记为重新提交
state.applicationForm.applicationId = row.applicationId;
state.isResubmitMode = true;
// 打开编辑对话框
state.applicationDialog.visible = true;
state.applicationDialog.title = '修改并重新提交因私出国(境)申请登记报备表';
// 在下一个tick中恢复签名
nextTick(() => {
if (response.data.signature && signatureCanvas.value) {
restoreSignature(response.data.signature);
}
});
} else {
ElMessage.error('获取申请详情失败');
// 跳转到编辑申请页面,标记为重新提交模式
proxy.$router.push({
path: '/rs/overseas/overseas-form',
query: {
type: 'resubmit',
id: row.applicationId
}
} catch (error) {
console.error('获取申请详情失败:', error);
ElMessage.error('获取申请详情失败');
}
});
};
// 取消申请
@@ -1963,8 +1927,8 @@ const handleExportApplication = async () => {
}
};
// 工具函数
const getApprovalStatusTagType = (status: string): 'success' | 'warning' | 'danger' | 'info' | 'primary' => {
// 工具函数 - 原审批状态标签(老接口使用:0-待审核,1-通过,2-拒绝)
const getOldApprovalStatusTagType = (status: string): 'success' | 'warning' | 'danger' | 'info' | 'primary' => {
const typeMap: Record<string, 'success' | 'warning' | 'danger' | 'info' | 'primary'> = {
'0': 'warning', // 待审核
'1': 'success', // 通过
@@ -1973,15 +1937,163 @@ const getApprovalStatusTagType = (status: string): 'success' | 'warning' | 'dang
return typeMap[status] || 'info';
};
const handleExportRecord = async () => {
try {
await exportOverseasRecord(state.recordQueryParams);
ElMessage.success('导出成功');
} catch (error) {
console.error('导出失败:', error);
// ==================== 工作流相关方法 ====================
/**
* 工作流状态标签样式映射(Warm-Flow工作流状态)
*/
const getApprovalStatusTagType = (status: string): 'success' | 'warning' | 'danger' | 'info' | 'primary' => {
const statusMap: Record<string, 'success' | 'warning' | 'danger' | 'info' | 'primary'> = {
'draft': 'info', // 草稿 - 灰色
'waiting': 'warning', // 待审批 - 橙色
'finish': 'success', // 已完成 - 绿色
'back': 'danger', // 已退回 - 红色
'cancel': 'info', // 已取消 - 灰色
};
return statusMap[status] || 'info';
};
/**
* 点击审批按钮 - 跳转到审批页面
*/
const handleApproval = (row: OverseasApplicationVO) => {
console.log('📋 [审批] 打开审批页面,申请ID:', row.applicationId, '任务ID:', row.taskId);
// 设置页面类型为审批模式
state.pageType = 'approval';
state.applicationDialog.title = '出国申请审批';
// 加载申请详情
getOverseasApplication(row.applicationId).then((response: any) => {
state.applicationForm = response.data;
state.applicationDialog.visible = true;
}).catch((error: any) => {
console.error('❌ [审批] 加载申请详情失败:', error);
ElMessage.error('加载申请详情失败');
});
};
/**
* 查看流程图(标准工作流模式)
*/
const handleViewProcess = (row: OverseasApplicationVO) => {
console.log('📊 [查看流程] 打开流程图,申请ID:', row.applicationId);
if (approvalRecordRef.value && row.applicationId) {
// 使用标准工作流组件查看审批记录
approvalRecordRef.value.open(row.applicationId, 'overseas-application');
} else {
ElMessage.warning('无法查看流程信息');
}
};
/**
* 提交表单 - 暂存或提交审批(标准工作流模式)
* @param type 'draft'-暂存, 'submit'-提交审批
*/
const submitForm = async (type: string) => {
console.log('📝 [提交表单] 类型:', type);
// 验证表单
if (!applicationFormRef.value) {
ElMessage.error('表单引用不存在');
return;
}
const valid = await applicationFormRef.value.validate().catch(() => false);
if (!valid) {
ElMessage.warning('请正确填写所有必填项');
return;
}
try {
// 1. 保存业务数据
let applicationId = state.applicationForm.applicationId;
if (applicationId) {
// 更新
await updateOverseasApplication(state.applicationForm);
} else {
// 新增
const response = await addOverseasApplication(state.applicationForm);
applicationId = response.data;
state.applicationForm.applicationId = applicationId;
}
// 2. 如果是提交审批,使用标准工作流API
if (type === 'submit') {
// 标准工作流启动参数
const workflowData = {
flowCode: 'overseas-application',
businessId: String(applicationId),
variables: {
applicantName: state.applicationForm.applicantName,
department: state.applicationForm.department,
destination: state.applicationForm.destination,
duration: state.applicationForm.duration,
budget: state.applicationForm.budget
}
};
// 启动工作流
const workflowResponse = await startWorkFlow(workflowData);
// 打开审批确认对话框
if (submitVerifyRef.value && workflowResponse.data?.taskId) {
submitVerifyRef.value.openDialog(workflowResponse.data.taskId);
}
ElMessage.success('申请已提交,进入审批流程');
state.applicationDialog.visible = false;
getApplicationList();
} else {
// 暂存成功
ElMessage.success('暂存成功');
state.applicationDialog.visible = false;
getApplicationList();
}
} catch (error: any) {
console.error('❌ [提交表单] 失败:', error);
ElMessage.error(error.message || '操作失败');
}
};
/**
* 打开审批确认对话框(标准工作流模式)
*/
const approvalVerifyOpen = (taskId: string) => {
console.log('🔍 [审批确认] 打开审批对话框, taskId:', taskId);
if (submitVerifyRef.value && taskId) {
submitVerifyRef.value.openDialog(taskId);
} else {
ElMessage.error('无法打开审批对话框');
}
};
/**
* 打开审批记录对话框(标准工作流模式)
*/
const handleApprovalRecord = () => {
console.log('📜 [审批记录] 打开审批记录');
if (approvalRecordRef.value && state.applicationForm.applicationId) {
approvalRecordRef.value.open(state.applicationForm.applicationId, 'overseas-application');
} else {
ElMessage.warning('无法查看审批记录');
}
};
/**
* 提交成功回调
*/
const submitSuccess = () => {
console.log('✅ [提交成功] 刷新列表');
ElMessage.success('操作成功');
state.applicationDialog.visible = false;
getApplicationList();
};
// 表单相关方法
const resetApplicationForm = () => {
applicationFormRef.value?.resetFields();
@@ -2026,9 +2138,6 @@ const resetApplicationForm = () => {
budget: 0
};
// 重置盖章文件上传列表
state.stampedFileList = [];
// 重置签名画布
nextTick(() => {
if (signatureCanvas.value) {
@@ -2040,12 +2149,6 @@ const resetApplicationForm = () => {
const submitApplicationForm = () => {
applicationFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
// ✅ 盖章文件上传检查(必填项)
if (!state.applicationForm.stampedFileUploadStatus || state.applicationForm.stampedFileUploadStatus === '0') {
ElMessage.warning('请先上传出国境登记表盖章文件才能提交申请!');
return;
}
// 党籍保留附件上传检查已移除(不再作为必填项)
// const isPartyMember = state.applicationForm.politicalStatus === '1' || state.applicationForm.politicalStatus === '中共党员';
// const needRetention = isPartyMember && state.applicationForm.duration && state.applicationForm.duration > 30;
@@ -2057,19 +2160,19 @@ const submitApplicationForm = () => {
// }
// }
// 前端调用后端校验接口
// 前端调用后端校验接口(已禁用出国登记前置条件校验)
try {
const validation = await validateApplicationPrerequisites(
state.applicationForm.politicalStatus,
state.applicationForm.duration
);
// 检查出国登记前置条件
const registrationValidation = validation.data.registrationValidation;
if (!registrationValidation.isValid) {
ElMessage.error(registrationValidation.message);
return;
}
// 检查出国登记前置条件(已禁用 - 允许直接提交申请)
// const registrationValidation = validation.data.registrationValidation;
// if (!registrationValidation.isValid) {
// ElMessage.error(registrationValidation.message);
// return;
// }
// 检查党籍保留前置条件(如果有返回结果)
const retentionValidation = validation.data.retentionValidation;
@@ -2700,303 +2803,60 @@ const handleDownloadReceipt = async (row: OverseasRecordVO) => {
}
};
// ====================================
// 盖章文件上传相关方法
// ====================================
// 处理上传文件数量超限
const handleStampedFileExceed = () => {
ElMessage.warning('只能上传一个盖章文件');
};
// 上传前的验证
const beforeStampedFileUpload = async (file: File) => {
// 检查文件格式
const isValidFormat = ['application/pdf', 'image/jpeg', 'image/jpg', 'image/png'].includes(file.type);
if (!isValidFormat) {
ElMessage.error('只支持PDF、JPG、PNG格式的文件!');
return false;
}
// 判断是否应该显示党籍保留申请下载按钮
const shouldShowPartyRetentionDownload = (application: OverseasApplicationVO) => {
if (!application) return false;
// 检查文件大小(10MB)
const isValidSize = file.size / 1024 / 1024 < 10;
if (!isValidSize) {
ElMessage.error('文件大小不能超过10MB!');
return false;
}
// 检查是否为中共党员
const isPartyMember = application.politicalStatus === '1' ||
application.politicalStatus === '中共党员' ||
application.politicalStatusText === '中共党员';
// 🔴 关键修复:如果是新增模式(没有applicationId),先保存申请记录
if (!state.applicationForm.applicationId) {
try {
ElMessage.info('正在保存申请记录...');
// 执行必要的字段映射(日期格式转换)
if (state.applicationForm.startDate) {
state.applicationForm.startDate = dayjs(state.applicationForm.startDate).format('YYYY-MM-DD');
}
if (state.applicationForm.endDate) {
state.applicationForm.endDate = dayjs(state.applicationForm.endDate).format('YYYY-MM-DD');
}
if (state.applicationForm.birthDate) {
state.applicationForm.birthDate = dayjs(state.applicationForm.birthDate).format('YYYY-MM-DD');
}
// actualStartDate 和 actualEndDate 字段不属于申请表单,已删除
// 🔴 关键修复:字段映射(参考submitApplicationForm的逻辑)
// 1. 同步destination字段
if (state.applicationForm.destinationCountry) {
state.applicationForm.destination = state.applicationForm.destinationCountry;
}
// 2. 处理身份证号(如果证件是身份证)
if (!state.applicationForm.idNumber && state.applicationForm.documentNumber) {
state.applicationForm.idNumber = state.applicationForm.documentNumber;
}
// 3. 处理户籍所在地(默认使用部门名称)
if (!state.applicationForm.registeredAddress) {
state.applicationForm.registeredAddress = state.applicationForm.department || '待填写';
}
// 4. 处理行程安排(自动生成)
if (!state.applicationForm.itinerary || state.applicationForm.itinerary.trim() === '') {
const startDate = state.applicationForm.startDate || '待定';
const endDate = state.applicationForm.endDate || '待定';
const destination = state.applicationForm.destination || state.applicationForm.destinationCountry || '待定';
const exitReason = state.applicationForm.exitReason || '因公出国';
state.applicationForm.itinerary = `${exitReason},计划于${startDate}至${endDate}期间前往${destination},具体行程安排待确定。`;
}
// 5. 处理出国天数
if (!state.applicationForm.duration || state.applicationForm.duration < 1) {
state.applicationForm.duration = 1;
}
// 6. 处理人员类别代码
if (!state.applicationForm.personnelCategory) {
const isPartyMember = state.applicationForm.politicalStatus === '1' ||
state.applicationForm.politicalStatus === '中共党员';
state.applicationForm.personnelCategory = isPartyMember ? '01' : '99';
}
// 保存申请记录(草稿状态)
const response = await addOverseasApplication(state.applicationForm);
// 🔴 重要:从响应中获取新创建的applicationId
if (response.data && response.data.applicationId) {
state.applicationForm.applicationId = response.data.applicationId;
ElMessage.success('申请记录已保存,现在可以上传盖章文件了');
} else {
ElMessage.error('保存申请记录失败,无法获取申请ID');
return false;
}
return true;
} catch (error) {
console.error('保存申请记录失败:', error);
ElMessage.error('保存申请记录失败,请先手动保存');
return false;
}
}
// 检查出国天数是否大于30天
const duration = Number(application.duration) || 0;
const needRetention = duration > 30;
return true;
return isPartyMember && needRetention;
};
// 上传成功回调
const handleStampedFileUploadSuccess = (response: any, file: any) => {
if (response.code === 200) {
// 更新表单数据
state.applicationForm.stampedRegistrationFilePath = response.data.filePath;
state.applicationForm.stampedRegistrationFileName = response.data.fileName;
state.applicationForm.stampedFileUploadTime = response.data.uploadTime;
state.applicationForm.stampedFileUploadStatus = '1';
ElMessage.success('盖章文件上传成功!');
} else {
ElMessage.error(response.msg || '上传失败');
}
};
// 上传失败回调
const handleStampedFileUploadError = (error: any) => {
console.error('盖章文件上传失败:', error);
ElMessage.error('盖章文件上传失败,请重试');
};
// 移除文件回调
const handleStampedFileRemove = () => {
// 清空表单数据
state.applicationForm.stampedRegistrationFilePath = '';
state.applicationForm.stampedRegistrationFileName = '';
state.applicationForm.stampedFileUploadTime = '';
state.applicationForm.stampedFileUploadStatus = '0';
// 清空文件列表(重要:解决删除后文件仍显示的问题)
state.stampedFileList = [];
ElMessage.info('已移除盖章文件');
};
// 盖章文件-文件变更
const handleStampedFileChange = (file: any, fileList: any) => {
console.log('盖章文件变更:', file, fileList);
state.stampedFileList = fileList;
};
// 盖章文件-删除确认
const handleStampedFileRemoveConfirm = (file: any) => {
ElMessageBox.confirm('确定要删除这个文件吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
handleStampedFileRemove();
})
.catch(() => {
// 取消删除
});
};
// 盖章文件-文件预览
const handleStampedFilePreview = (file: any) => {
if (isImageFileStamped(file)) {
// 图片预览
window.open(file.url);
} else {
// 其他文件下载
handleDownloadStampedAttachment(file);
}
};
// 盖章文件-判断是否为图片
const isImageFileStamped = (file: any) => {
const imageTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/bmp', 'image/webp'];
return imageTypes.includes(file.raw?.type) || (file.url && /\.(jpg|jpeg|png|gif|bmp|webp)$/i.test(file.name));
};
// 盖章文件-获取文件OSS ID
const getFileOssIdStamped = (file: any) => {
return file.ossId || '';
};
// 盖章文件-获取文件扩展名
const getFileExtStamped = (fileName: string) => {
const ext = fileName.split('.').pop()?.toUpperCase();
return ext || 'FILE';
};
// 盖章文件-获取缩写的文件名
const getShortFileNameStamped = (fileName: string) => {
if (!fileName) return '';
const lastDotIndex = fileName.lastIndexOf('.');
if (lastDotIndex === -1) {
return fileName.length > 12 ? fileName.substring(0, 12) + '...' : fileName;
}
const name = fileName.substring(0, lastDotIndex);
const ext = fileName.substring(lastDotIndex);
if (name.length <= 8) {
return fileName;
}
return name.substring(0, 8) + '...' + ext;
};
// 盖章文件-下载附件
const handleDownloadStampedAttachment = async (file: any) => {
let fileName = file.name || 'stamped_file';
// 优先使用file.raw(刚上传的文件,还没保存到服务器)
if (file.raw) {
console.log('下载刚上传的文件(使用raw对象)');
try {
const fileBlob = fileName.toLowerCase().endsWith('.pdf')
? new Blob([file.raw], { type: 'application/pdf' })
: file.raw;
const url = URL.createObjectURL(fileBlob);
const link = document.createElement('a');
link.href = url;
link.download = fileName;
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
setTimeout(() => {
URL.revokeObjectURL(url);
}, 100);
ElMessage.success('文件下载成功');
return;
} catch (error) {
console.error('下载raw文件失败:', error);
ElMessage.error('下载文件失败');
return;
}
}
// 检查是否有applicationId(已保存的申请)
if (!state.applicationForm.applicationId || state.applicationForm.applicationId === 0) {
ElMessage.warning('请先保存申请后再下载附件');
return;
}
// 从服务器下载已保存的文件
// 下载党籍保留申请PDF空白模板
const handleDownloadPartyRetention = async () => {
try {
console.log('从服务器下载已保存的文件,applicationId:', state.applicationForm.applicationId);
ElMessage.info('正在生成PDF,请稍候...');
const response = await fetch(import.meta.env.VITE_APP_BASE_API + '/rs/overseas/application/downloadStampedFile/' + state.applicationForm.applicationId, {
method: 'GET',
headers: {
'Authorization': `Bearer ${getToken() || ''}`,
'clientid': import.meta.env.VITE_APP_CLIENT_ID || '',
'referer': window.location.origin,
}
// 使用request工具发送请求,自动包含认证头
const response = await request({
url: '/rs/overseas/record/downloadPartyRetention',
method: 'get',
responseType: 'blob' // 指定响应类型为blob
});
if (!response.ok) {
const errorText = await response.text();
console.error('下载失败响应:', errorText);
throw new Error('下载失败: ' + response.status);
}
const contentType = response.headers.get('content-type');
console.log('下载文件Content-Type:', contentType);
const blob = await response.blob();
console.log('下载文件Blob大小:', blob.size, 'bytes');
// 创建blob并触发下载(response已经是blob对象)
const blob = response instanceof Blob
? new Blob([response], { type: 'application/pdf' })
: new Blob([response.data], { type: 'application/pdf' });
// 获取服务器返回的文件名
if (state.applicationForm.stampedRegistrationFileName) {
fileName = state.applicationForm.stampedRegistrationFileName;
console.log('📥 生成的Blob大小:', blob.size, 'bytes');
console.log('📥 Blob类型:', blob.type);
if (blob.size === 0) {
throw new Error('下载的文件为空');
}
// 如果是PDF文件,设置正确的MIME类型
const fileBlob = fileName.toLowerCase().endsWith('.pdf')
? new Blob([blob], { type: 'application/pdf' })
: blob;
const url = window.URL.createObjectURL(fileBlob);
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = fileName;
link.download = `党籍保留申请_${new Date().getTime()}.pdf`;
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
setTimeout(() => {
window.URL.revokeObjectURL(url);
}, 100);
ElMessage.success('文件下载成功');
} catch (error) {
console.error('下载文件失败:', error);
ElMessage.error('下载文件失败,请稍后重试');
window.URL.revokeObjectURL(url);
ElMessage.success('PDF下载成功!');
} catch (error: any) {
console.error('❌ 下载PDF失败:', error);
ElMessage.error('下载失败: ' + (error.message || '未知错误'));
}
};
@@ -3312,6 +3172,7 @@ const formatFileSize = (bytes: number): string => {
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
};
// ==================== 附件管理相关方法 ====================
// 查询申请的附件列表
@@ -1,781 +0,0 @@
<template>
<div class="app-container">
<el-card class="box-card">
<!-- 选项卡 -->
<el-tabs v-model="activeTab" type="border-card" @tab-change="handleTabChange">
<!-- 党籍保留审批选项卡 -->
<el-tab-pane label="党籍保留审批" name="pending">
<div class="tab-content">
<!-- 搜索区域 -->
<transition :enter-active-class="animate.searchAnimate.enter" :leave-active-class="animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" label-width="100px">
<el-row :gutter="20">
<el-col :span="5">
<el-form-item label="姓名" prop="name">
<el-input v-model="queryParams.name" placeholder="请输入姓名" clearable @keyup.enter="handleQuery" />
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="身份证号" prop="idNumber">
<el-input v-model="queryParams.idNumber" placeholder="请输入身份证号" clearable @keyup.enter="handleQuery" />
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="工作部门" prop="department">
<el-input v-model="queryParams.department" placeholder="请输入工作部门" clearable @keyup.enter="handleQuery" />
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="目的地" prop="destination">
<el-input v-model="queryParams.destination" placeholder="请输入目的地" clearable @keyup.enter="handleQuery" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24" class="search-btn-container">
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
</div>
</transition>
<!-- 操作按钮和表格 -->
<el-card shadow="never" class="button-card table-card">
<template #header>
<el-row :gutter="10" class="mb8">
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
</template>
<!-- 数据表格 -->
<el-table v-loading="loading" border :data="retentionList" @row-dblclick="handleView">
<el-table-column label="序号" type="index" width="60" align="center">
<template #default="scope">
{{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
</template>
</el-table-column>
<el-table-column label="姓名" align="center" prop="name" width="100" :show-overflow-tooltip="true" />
<el-table-column label="身份证号" align="center" prop="idCard" width="180" :show-overflow-tooltip="true" />
<el-table-column label="出国时间" align="center" min-width="220" :show-overflow-tooltip="true">
<template #default="scope">
<span v-if="scope.row.travelStartDate && scope.row.travelEndDate">
{{ scope.row.travelStartDate }} 至 {{ scope.row.travelEndDate }}
</span>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="停留天数" align="center" width="100" :show-overflow-tooltip="true">
<template #default="scope">
<span v-if="scope.row.stayDays">{{ scope.row.stayDays }} 天</span>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="目的地" align="center" prop="destination" width="120" :show-overflow-tooltip="true" />
<el-table-column label="党支部" align="center" prop="partyBranch" width="150" :show-overflow-tooltip="true" />
<el-table-column label="申请状态" align="center" width="100" :show-overflow-tooltip="true">
<template #default="scope">
<el-tag :type="getStatusTagType(scope.row.status)">{{ scope.row.statusText }}</el-tag>
</template>
</el-table-column>
<el-table-column label="申请时间" align="center" prop="applicationTime" width="160" :show-overflow-tooltip="true" />
<el-table-column label="操作" align="center" width="280" fixed="right">
<template #default="scope">
<el-tooltip content="查看详情" placement="top">
<el-button
link
type="primary"
icon="View"
@click="handleView(scope.row)"
v-hasPermi="['rs:partyretention:query']"
></el-button>
</el-tooltip>
<el-tooltip content="审批通过" placement="top">
<el-button
link
type="success"
icon="Check"
@click="handleApprove(scope.row)"
v-hasPermi="['rs:partyretention:approve']"
></el-button>
</el-tooltip>
<el-tooltip content="审批拒绝" placement="top">
<el-button
link
type="danger"
icon="Close"
@click="handleReject(scope.row)"
v-hasPermi="['rs:partyretention:approve']"
></el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</el-card>
</div>
</el-tab-pane>
<!-- 审批记录选项卡 -->
<el-tab-pane label="审批记录" name="history">
<div class="tab-content">
<!-- 搜索区域 -->
<transition :enter-active-class="animate.searchAnimate.enter" :leave-active-class="animate.searchAnimate.leave">
<div v-show="showHistorySearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="historyQueryFormRef" :model="historyQueryParams" label-width="100px">
<el-row :gutter="20">
<el-col :span="5">
<el-form-item label="姓名" prop="name">
<el-input v-model="historyQueryParams.name" placeholder="请输入姓名" clearable @keyup.enter="handleHistoryQuery" />
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="身份证号" prop="idNumber">
<el-input v-model="historyQueryParams.idNumber" placeholder="请输入身份证号" clearable @keyup.enter="handleHistoryQuery" />
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="工作部门" prop="department">
<el-input v-model="historyQueryParams.department" placeholder="请输入工作部门" clearable @keyup.enter="handleHistoryQuery" />
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="审批状态" prop="status">
<el-select v-model="historyQueryParams.status" placeholder="请选择审批状态" clearable style="width: 100%">
<el-option label="已通过" value="2" />
<el-option label="已拒绝" value="3" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24" class="search-btn-container">
<el-form-item>
<el-button type="primary" icon="Search" @click="handleHistoryQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetHistoryQuery">重置</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
</div>
</transition>
<!-- 操作按钮和表格 -->
<el-card shadow="never" class="button-card table-card">
<template #header>
<el-row :gutter="10" class="mb8">
<right-toolbar v-model:showSearch="showHistorySearch" @queryTable="getHistoryList"></right-toolbar>
</el-row>
</template>
<!-- 数据表格 -->
<el-table v-loading="historyLoading" border :data="historyList" @row-dblclick="handleViewHistory">
<el-table-column label="序号" type="index" width="60" align="center">
<template #default="scope">
{{ (historyQueryParams.pageNum - 1) * historyQueryParams.pageSize + scope.$index + 1 }}
</template>
</el-table-column>
<el-table-column label="姓名" align="center" prop="name" width="100" :show-overflow-tooltip="true" />
<el-table-column label="身份证号" align="center" prop="idCard" width="180" :show-overflow-tooltip="true" />
<el-table-column label="出国时间" align="center" min-width="220" :show-overflow-tooltip="true">
<template #default="scope">
<span v-if="scope.row.travelStartDate && scope.row.travelEndDate">
{{ scope.row.travelStartDate }} 至 {{ scope.row.travelEndDate }}
</span>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="停留天数" align="center" width="100" :show-overflow-tooltip="true">
<template #default="scope">
<span v-if="scope.row.stayDays">{{ scope.row.stayDays }} 天</span>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="目的地" align="center" prop="destination" width="120" :show-overflow-tooltip="true" />
<el-table-column label="审批状态" align="center" prop="statusText" width="120">
<template #default="scope">
<el-tag :type="getStatusTagType(scope.row.status)">{{ scope.row.statusText }}</el-tag>
</template>
</el-table-column>
<el-table-column label="审批时间" align="center" prop="updateTime" width="160" :show-overflow-tooltip="true" />
<el-table-column label="操作" align="center" width="200" fixed="right">
<template #default="scope">
<el-tooltip content="查看详情" placement="top">
<el-button
link
type="primary"
icon="View"
@click="handleViewHistory(scope.row)"
v-hasPermi="['rs:partyretention:query']"
></el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<pagination
v-show="historyTotal > 0"
:total="historyTotal"
v-model:page="historyQueryParams.pageNum"
v-model:limit="historyQueryParams.pageSize"
@pagination="getHistoryList"
/>
</el-card>
</div>
</el-tab-pane>
</el-tabs>
</el-card>
<!-- 查看详情弹窗 -->
<el-dialog title="党籍保留审批详情" v-model="viewDialog.visible" width="900px" :close-on-click-modal="false" destroy-on-close>
<div class="detail-content" v-loading="viewDialog.loading">
<div class="detail-section">
<h4 class="section-title">申请信息</h4>
<el-descriptions :column="2" border>
<el-descriptions-item label="申请人姓名">{{ viewData.name }}</el-descriptions-item>
<el-descriptions-item label="身份证号">{{ viewData.idCard }}</el-descriptions-item>
<el-descriptions-item label="配偶姓名">{{ viewData.spouse || '无' }}</el-descriptions-item>
<el-descriptions-item label="目的地">{{ viewData.destination }}</el-descriptions-item>
<el-descriptions-item label="出国目的" :span="2">{{ viewData.purpose }}</el-descriptions-item>
<el-descriptions-item label="出国时间" :span="2">
{{ formatDate(viewData.travelStartDate) }} 至 {{ formatDate(viewData.travelEndDate) }}
</el-descriptions-item>
<el-descriptions-item label="停留天数">{{ viewData.stayDays }}天</el-descriptions-item>
<el-descriptions-item label="党支部">{{ viewData.partyBranch }}</el-descriptions-item>
<el-descriptions-item label="职务">{{ viewData.position || '无' }}</el-descriptions-item>
<el-descriptions-item label="亲属姓名">{{ viewData.relativeName || '无' }}</el-descriptions-item>
</el-descriptions>
</div>
<div class="detail-section">
<h4 class="section-title">审批信息</h4>
<el-descriptions :column="2" border>
<el-descriptions-item label="申请状态">
<el-tag :type="getStatusTagType(viewData.status)">{{ viewData.statusText }}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="申请时间">{{ viewData.applicationTime }}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ viewData.createTime }}</el-descriptions-item>
<el-descriptions-item label="更新时间">{{ viewData.updateTime }}</el-descriptions-item>
</el-descriptions>
</div>
</div>
<template #footer>
<div class="dialog-footer">
<el-button @click="viewDialog.visible = false">关 闭</el-button>
<!-- 待审批状态下显示审批按钮 -->
<template v-if="viewData.status === '1'">
<el-button type="success" icon="Check" @click="handleApproveInDialog" v-hasPermi="['rs:partyretention:approve']">
审批通过
</el-button>
<el-button type="danger" icon="Close" @click="handleRejectInDialog" v-hasPermi="['rs:partyretention:approve']">
审批拒绝
</el-button>
</template>
</div>
</template>
</el-dialog>
<!-- 审批通过弹窗 -->
<el-dialog title="审批通过" v-model="approveDialog.visible" width="500px" :close-on-click-modal="false" destroy-on-close>
<el-form ref="approveFormRef" :model="approveForm" label-width="100px">
<el-form-item label="审批意见">
<el-input
v-model="approveForm.approvalOpinion"
type="textarea"
:rows="4"
placeholder="请输入审批意见(非必填)"
maxlength="500"
show-word-limit
/>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button @click="approveDialog.visible = false">取 消</el-button>
<el-button type="success" @click="submitApprove" :loading="approveDialog.loading">确认通过</el-button>
</div>
</template>
</el-dialog>
<!-- 审批拒绝弹窗 -->
<el-dialog title="审批拒绝" v-model="rejectDialog.visible" width="500px" :close-on-click-modal="false" destroy-on-close>
<el-form ref="rejectFormRef" :model="rejectForm" :rules="rejectRules" label-width="100px">
<el-form-item label="拒绝理由" prop="approvalOpinion">
<el-input
v-model="rejectForm.approvalOpinion"
type="textarea"
:rows="4"
placeholder="请输入拒绝理由(必填)"
maxlength="500"
show-word-limit
/>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button @click="rejectDialog.visible = false">取 消</el-button>
<el-button type="danger" @click="submitReject" :loading="rejectDialog.loading">确认拒绝</el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue';
import { ElMessage } from 'element-plus';
import type { FormInstance } from 'element-plus';
import {
getPendingPartyRetentionList,
getPartyRetentionList,
getPartyRetention,
approvePartyRetention,
type PartyRetentionApprovalQuery,
type PartyRetentionVO,
type ApprovalRequest
} from '@/api/rs/party-membership-retention';
// 动画配置
const animate = {
searchAnimate: {
enter: 'animate__animated animate__fadeInDown',
leave: 'animate__animated animate__fadeOutUp'
}
};
// 选项卡
const activeTab = ref('pending');
// 待审批查询相关
const showSearch = ref(true);
const loading = ref(false);
const retentionList = ref<PartyRetentionVO[]>([]);
const total = ref(0);
const queryParams = ref<PartyRetentionApprovalQuery>({
pageNum: 1,
pageSize: 10,
name: '',
idNumber: '',
department: '',
destination: '',
status: '1' // 默认查询待审批状态
});
const queryFormRef = ref<FormInstance>();
// 审批记录查询相关
const showHistorySearch = ref(true);
const historyLoading = ref(false);
const historyList = ref<PartyRetentionVO[]>([]);
const historyTotal = ref(0);
const historyQueryParams = ref<PartyRetentionApprovalQuery>({
pageNum: 1,
pageSize: 10,
name: '',
idNumber: '',
department: '',
destination: '',
status: '' // 不设置默认值,可查询已通过和已拒绝
});
const historyQueryFormRef = ref<FormInstance>();
// 查看详情
const viewDialog = reactive({
visible: false,
loading: false
});
const viewData = ref<any>({});
// 审批通过表单
const approveDialog = reactive({
visible: false,
loading: false
});
const approveFormRef = ref<FormInstance>();
const approveForm = ref<ApprovalRequest>({
retentionId: '',
approvalOpinion: '',
approved: true
});
// 审批拒绝表单
const rejectDialog = reactive({
visible: false,
loading: false
});
const rejectFormRef = ref<FormInstance>();
const rejectForm = ref<ApprovalRequest>({
retentionId: '',
approvalOpinion: '',
approved: false
});
const rejectRules = {
approvalOpinion: [{ required: true, message: '请输入拒绝理由', trigger: 'blur' }]
};
// 工具方法
const formatDate = (date: string) => {
if (!date) return '';
return new Date(date).toLocaleDateString('zh-CN');
};
const getStatusTagType = (status: string): 'success' | 'warning' | 'info' | 'primary' | 'danger' => {
const tagTypes: Record<string, 'success' | 'warning' | 'info' | 'primary' | 'danger'> = {
'0': 'info', // 草稿
'1': 'warning', // 待审批
'2': 'success', // 已通过
'3': 'danger' // 已拒绝
};
return tagTypes[status] || 'info';
};
// 查询列表
const getList = async () => {
loading.value = true;
try {
const response = await getPendingPartyRetentionList(queryParams.value);
retentionList.value = response.rows;
total.value = response.total;
} catch (error) {
ElMessage.error('获取待审批列表失败');
} finally {
loading.value = false;
}
};
// 搜索
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
// 重置
const resetQuery = () => {
queryParams.value = {
pageNum: 1,
pageSize: 10,
name: '',
idNumber: '',
department: '',
destination: '',
status: '1'
};
queryFormRef.value?.resetFields();
getList();
};
// 查看详情
const handleView = async (row: PartyRetentionVO) => {
viewDialog.loading = true;
viewDialog.visible = true;
try {
const response = await getPartyRetention(row.retentionId);
console.log('详情数据:', response.data);
console.log('statusText:', response.data.statusText);
// 如果后端没有返回 statusText,手动计算
if (!response.data.statusText && response.data.status) {
const statusMap: Record<string, string> = {
'0': '草稿',
'1': '待审核',
'2': '已通过',
'3': '已拒绝',
'4': '已撤回'
};
response.data.statusText = statusMap[response.data.status] || '未知状态';
}
viewData.value = response.data;
} catch (error) {
ElMessage.error('获取详情失败');
viewDialog.visible = false;
} finally {
viewDialog.loading = false;
}
};
// 审批通过
const handleApprove = (row: PartyRetentionVO) => {
approveForm.value = {
retentionId: row.retentionId,
approvalOpinion: '',
approved: true
};
approveDialog.visible = true;
};
// 在详情弹窗中审批通过
const handleApproveInDialog = () => {
viewDialog.visible = false;
approveForm.value = {
retentionId: viewData.value.retentionId,
approvalOpinion: '',
approved: true
};
approveDialog.visible = true;
};
// 提交审批通过
const submitApprove = async () => {
approveDialog.loading = true;
try {
console.log('审批请求参数:', approveForm.value);
const response = await approvePartyRetention(approveForm.value);
console.log('审批响应数据:', response);
ElMessage.success('审批通过成功');
approveDialog.visible = false;
// 刷新当前选项卡数据
if (activeTab.value === 'pending') {
getList();
} else if (activeTab.value === 'history') {
getHistoryList();
}
} catch (error) {
console.error('审批通过失败详情:', error);
const errorMsg = (error as any)?.message || (error as any)?.msg || '审批通过失败';
ElMessage.error(errorMsg);
} finally {
approveDialog.loading = false;
}
};
// 审批拒绝
const handleReject = (row: PartyRetentionVO) => {
rejectForm.value = {
retentionId: row.retentionId,
approvalOpinion: '',
approved: false
};
rejectDialog.visible = true;
};
// 在详情弹窗中审批拒绝
const handleRejectInDialog = () => {
viewDialog.visible = false;
rejectForm.value = {
retentionId: viewData.value.retentionId,
approvalOpinion: '',
approved: false
};
rejectDialog.visible = true;
};
// 提交审批拒绝
const submitReject = () => {
rejectFormRef.value?.validate(async valid => {
if (valid) {
rejectDialog.loading = true;
try {
console.log('审批拒绝请求参数:', rejectForm.value);
const response = await approvePartyRetention(rejectForm.value);
console.log('审批拒绝响应数据:', response);
ElMessage.success('审批拒绝成功');
rejectDialog.visible = false;
// 刷新当前选项卡数据
if (activeTab.value === 'pending') {
getList();
} else if (activeTab.value === 'history') {
getHistoryList();
}
} catch (error) {
console.error('审批拒绝失败详情:', error);
const errorMsg = (error as any)?.message || (error as any)?.msg || '审批拒绝失败';
ElMessage.error(errorMsg);
} finally {
rejectDialog.loading = false;
}
}
});
};
// 选项卡切换
const handleTabChange = (tabName: string) => {
if (tabName === 'pending') {
getList();
} else if (tabName === 'history') {
getHistoryList();
}
};
// 审批记录列表查询
const getHistoryList = async () => {
historyLoading.value = true;
try {
// 构建查询参数,查询已通过(2)和已拒绝(3)的数据
const params = { ...historyQueryParams.value };
const response = await getPartyRetentionList(params);
// 过滤出已通过和已拒绝的数据
historyList.value = response.rows.filter((item: PartyRetentionVO) => item.status === '2' || item.status === '3');
historyTotal.value = historyList.value.length;
} catch (error) {
ElMessage.error('获取审批记录失败');
} finally {
historyLoading.value = false;
}
};
// 审批记录搜索
const handleHistoryQuery = () => {
historyQueryParams.value.pageNum = 1;
getHistoryList();
};
// 审批记录重置
const resetHistoryQuery = () => {
historyQueryParams.value = {
pageNum: 1,
pageSize: 10,
name: '',
idNumber: '',
department: '',
destination: '',
status: ''
};
historyQueryFormRef.value?.resetFields();
getHistoryList();
};
// 查看审批记录详情
const handleViewHistory = async (row: PartyRetentionVO) => {
viewDialog.loading = true;
viewDialog.visible = true;
try {
const response = await getPartyRetention(row.retentionId);
console.log('审批记录详情数据:', response.data);
console.log('statusText:', response.data.statusText);
// 如果后端没有返回 statusText,手动计算
if (!response.data.statusText && response.data.status) {
const statusMap: Record<string, string> = {
'0': '草稿',
'1': '待审核',
'2': '已通过',
'3': '已拒绝',
'4': '已撤回'
};
response.data.statusText = statusMap[response.data.status] || '未知状态';
}
viewData.value = response.data;
} catch (error) {
ElMessage.error('获取详情失败');
viewDialog.visible = false;
} finally {
viewDialog.loading = false;
}
};
// 生命周期
onMounted(() => {
getList();
});
</script>
<style scoped>
/* 页面容器基础样式 */
.app-container {
padding: 20px;
margin: 0;
width: 100%;
box-sizing: border-box;
}
/* 卡片样式 */
.box-card {
margin-bottom: 20px;
}
/* 选项卡内容区域 */
.tab-content {
padding: 0;
}
/* 搜索按钮容器 */
.search-btn-container {
display: flex;
justify-content: flex-end;
margin-top: 10px;
}
.search-btn-container :deep(.el-form-item) {
margin-bottom: 0 !important;
}
/* 表格卡片样式 */
.table-card {
margin-top: 10px;
}
.button-card {
border: none;
}
/* 详情内容样式 */
.detail-content {
max-height: 600px;
overflow-y: auto;
}
.detail-section {
margin-bottom: 20px;
}
.detail-section:last-child {
margin-bottom: 0;
}
.section-title {
margin: 0 0 15px 0;
padding-bottom: 8px;
border-bottom: 1px solid #e4e7ed;
color: #303133;
font-size: 14px;
font-weight: 500;
}
.dialog-footer {
display: flex;
justify-content: flex-end;
gap: 10px;
}
:deep(.el-descriptions__label) {
font-weight: 500;
}
:deep(.el-table .cell) {
padding: 8px 0;
}
.mt-4 {
margin-top: 1rem;
}
</style>
File diff suppressed because it is too large. Load diff