|
|
@ -50,10 +50,46 @@ |
|
|
</a-form> |
|
|
</a-form> |
|
|
<!---------- 查询表单form end -----------> |
|
|
<!---------- 查询表单form end -----------> |
|
|
|
|
|
|
|
|
|
|
|
<!---------- 承诺书列表显示区域 begin -----------> |
|
|
|
|
|
<a-card v-if="!isCeo" size="small" :bordered="false" :hoverable="true" style="margin-bottom: 16px;"> |
|
|
|
|
|
<template #title> |
|
|
|
|
|
<span>承诺书列表</span> |
|
|
|
|
|
</template> |
|
|
|
|
|
<div style="display: flex; flex-wrap: wrap; gap: 16px;"> |
|
|
|
|
|
<div |
|
|
|
|
|
v-for="item in noticeList" |
|
|
|
|
|
:key="item.bookId || item.noticeId || item.id" |
|
|
|
|
|
style="display: flex; align-items: center; padding: 8px 12px; background: #f5f5f5; border-radius: 4px; cursor: pointer;" |
|
|
|
|
|
@click="downloadNoticeAttachment(item)" |
|
|
|
|
|
:title="hasAttachment(item) ? '点击下载' : '暂无附件'" |
|
|
|
|
|
> |
|
|
|
|
|
<FileTextOutlined style="font-size: 16px; color: #1890ff; margin-right: 8px;" /> |
|
|
|
|
|
<span style="color: #1890ff; font-size: 14px;">{{ item.bookName || item.title }}</span> |
|
|
|
|
|
<DownloadOutlined v-if="hasAttachment(item)" style="font-size: 12px; color: #1890ff; margin-left: 4px;" /> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
</a-card> |
|
|
|
|
|
<!---------- 承诺书列表显示区域 end -----------> |
|
|
|
|
|
|
|
|
<a-card size="small" :bordered="false" :hoverable="true"> |
|
|
<a-card size="small" :bordered="false" :hoverable="true"> |
|
|
<!---------- 表格操作行 begin -----------> |
|
|
<!---------- 表格操作行 begin -----------> |
|
|
<a-row class="smart-table-btn-block"> |
|
|
<a-row class="smart-table-btn-block"> |
|
|
<div class="smart-table-operate-block"> |
|
|
<div class="smart-table-operate-block"> |
|
|
|
|
|
<!-- user角色只显示律师承诺书按钮 --> |
|
|
|
|
|
<a-button type="primary" @click="handleLawyerUpload" :loading="proofUploadLoading" v-if="isLawyerRole && !isFirmRole"> |
|
|
|
|
|
<UploadOutlined /> |
|
|
|
|
|
上传律师承诺书 |
|
|
|
|
|
</a-button> |
|
|
|
|
|
|
|
|
|
|
|
<!-- cto角色显示两个按钮 --> |
|
|
|
|
|
<a-button type="primary" @click="handleLawyerUpload" :loading="proofUploadLoading" v-if="isFirmRole" style="margin-left: 8px;"> |
|
|
|
|
|
<UploadOutlined /> |
|
|
|
|
|
上传律师承诺书 |
|
|
|
|
|
</a-button> |
|
|
|
|
|
<a-button type="primary" @click="handleFirmUpload" :loading="proofUploadLoading" v-if="isFirmRole" style="margin-left: 8px;"> |
|
|
|
|
|
<UploadOutlined /> |
|
|
|
|
|
上传律所承诺书 |
|
|
|
|
|
</a-button> |
|
|
</div> |
|
|
</div> |
|
|
<div class="smart-table-setting-block"> |
|
|
<div class="smart-table-setting-block"> |
|
|
<TableOperator v-model="columns" :tableId="null" :refresh="queryData" /> |
|
|
<TableOperator v-model="columns" :tableId="null" :refresh="queryData" /> |
|
|
@ -106,6 +142,43 @@ |
|
|
@cancel="handleAgreementCancel" |
|
|
@cancel="handleAgreementCancel" |
|
|
/> |
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
<!-- 上传证明文件弹框 --> |
|
|
|
|
|
<a-modal |
|
|
|
|
|
v-model:visible="showUploadModal" |
|
|
|
|
|
:title="letterType === 'user' ? '上传律师承诺书' : '上传律所承诺书'" |
|
|
|
|
|
@cancel="showUploadModal = false" |
|
|
|
|
|
:confirm-loading="proofUploadLoading" |
|
|
|
|
|
@ok="handleUpload" |
|
|
|
|
|
> |
|
|
|
|
|
<a-form layout="vertical"> |
|
|
|
|
|
<a-form-item label="上传文件" required> |
|
|
|
|
|
<a-upload |
|
|
|
|
|
:file-list="proofFileList" |
|
|
|
|
|
:customRequest="handleCustomUpload" |
|
|
|
|
|
:max-count="1" |
|
|
|
|
|
accept=".jpg,.jpeg,.png" |
|
|
|
|
|
@change="handleFileChange" |
|
|
|
|
|
> |
|
|
|
|
|
<a-button> |
|
|
|
|
|
<UploadOutlined /> |
|
|
|
|
|
选择文件 |
|
|
|
|
|
</a-button> |
|
|
|
|
|
</a-upload> |
|
|
|
|
|
<div v-if="proofFileList.length > 0" style="margin-top: 8px; color: #52c41a; font-size: 12px;"> |
|
|
|
|
|
已选择文件: {{ proofFileList[0].name }} |
|
|
|
|
|
</div> |
|
|
|
|
|
<div style="margin-top: 8px; color: #999; font-size: 12px;"> |
|
|
|
|
|
支持格式:图片(JPG/PNG),文件大小不超过10MB |
|
|
|
|
|
</div> |
|
|
|
|
|
</a-form-item> |
|
|
|
|
|
</a-form> |
|
|
|
|
|
</a-modal> |
|
|
|
|
|
|
|
|
|
|
|
<!-- 图片预览弹框 --> |
|
|
|
|
|
<a-modal :footer="null" :open="previewVisible" @cancel="handleCancelPreview"> |
|
|
|
|
|
<img :src="previewUrl" alt="预览图片" style="width: 100%; max-height: 80vh; object-fit: contain;" /> |
|
|
|
|
|
</a-modal> |
|
|
|
|
|
|
|
|
</a-card> |
|
|
</a-card> |
|
|
</template> |
|
|
</template> |
|
|
<script setup> |
|
|
<script setup> |
|
|
@ -114,8 +187,12 @@ import { message, Modal } from 'ant-design-vue'; |
|
|
import { SmartLoading } from '/@/components/framework/smart-loading'; |
|
|
import { SmartLoading } from '/@/components/framework/smart-loading'; |
|
|
import { letterApi } from '/@/api/business/letter/letter-api'; |
|
|
import { letterApi } from '/@/api/business/letter/letter-api'; |
|
|
import { employeeApi } from '/@/api/system/employee-api'; |
|
|
import { employeeApi } from '/@/api/system/employee-api'; |
|
|
|
|
|
import { noticeApi } from '/@/api/business/oa/notice-api'; |
|
|
|
|
|
import { fileApi } from '/@/api/support/file-api'; |
|
|
import { PAGE_SIZE_OPTIONS } from '/@/constants/common-const'; |
|
|
import { PAGE_SIZE_OPTIONS } from '/@/constants/common-const'; |
|
|
|
|
|
import { loginApi } from '/@/api/system/login-api'; |
|
|
import { smartSentry } from '/@/lib/smart-sentry'; |
|
|
import { smartSentry } from '/@/lib/smart-sentry'; |
|
|
|
|
|
import { FILE_FOLDER_TYPE_ENUM } from '/@/constants/support/file-const'; |
|
|
import TableOperator from '/@/components/support/table-operator/index.vue'; |
|
|
import TableOperator from '/@/components/support/table-operator/index.vue'; |
|
|
import LetterForm from './letter-form.vue'; |
|
|
import LetterForm from './letter-form.vue'; |
|
|
import AgreementModal from '/@/views/system/home/components/agreement.vue'; |
|
|
import AgreementModal from '/@/views/system/home/components/agreement.vue'; |
|
|
@ -124,13 +201,13 @@ import AgreementModal from '/@/views/system/home/components/agreement.vue'; |
|
|
|
|
|
|
|
|
const columns = ref([ |
|
|
const columns = ref([ |
|
|
{ |
|
|
{ |
|
|
title: '承诺书名称', |
|
|
title: '用户名称', |
|
|
dataIndex: 'letterName', |
|
|
dataIndex: 'userName', |
|
|
ellipsis: true, |
|
|
ellipsis: true, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
title: '用户名称', |
|
|
title: '承诺书类型', |
|
|
dataIndex: 'userName', |
|
|
dataIndex: 'letterName', |
|
|
ellipsis: true, |
|
|
ellipsis: true, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
@ -153,18 +230,246 @@ import AgreementModal from '/@/views/system/home/components/agreement.vue'; |
|
|
// 查看详情 |
|
|
// 查看详情 |
|
|
async function viewDetail(record) { |
|
|
async function viewDetail(record) { |
|
|
try { |
|
|
try { |
|
|
// 设置当前letterId并显示弹框 |
|
|
// 检查是否有文件地址 |
|
|
currentLetterId.value = record.letterId; |
|
|
if (!record.fileUrl) { |
|
|
showAgreementModal.value = true; |
|
|
message.warning('该承诺书没有附件文件'); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 直接使用查询结果中的fileUrl进行预览 |
|
|
|
|
|
const fileUrl = record.fileUrl; |
|
|
|
|
|
|
|
|
|
|
|
// 根据文件名推断文件类型 |
|
|
|
|
|
const fileName = record.letterName || ''; |
|
|
|
|
|
const fileExtension = fileName.split('.').pop() || ''; |
|
|
|
|
|
|
|
|
|
|
|
showImagePreview(fileUrl); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('预览承诺书失败:', error); |
|
|
|
|
|
message.error('预览承诺书失败,请稍后重试'); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 图片预览相关 |
|
|
|
|
|
const previewVisible = ref(false); |
|
|
|
|
|
const previewUrl = ref(''); |
|
|
|
|
|
|
|
|
|
|
|
function showImagePreview(url) { |
|
|
|
|
|
previewUrl.value = url; |
|
|
|
|
|
previewVisible.value = true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function handleCancelPreview() { |
|
|
|
|
|
previewVisible.value = false; |
|
|
|
|
|
previewUrl.value = ''; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------- 上传证明功能 ---------------------------- |
|
|
|
|
|
|
|
|
|
|
|
// 上传证明相关状态 |
|
|
|
|
|
const proofFileList = ref([]); |
|
|
|
|
|
const proofUploadLoading = ref(false); |
|
|
|
|
|
const letterType = ref('user'); // 默认为用户类型 |
|
|
|
|
|
const showUploadModal = ref(false); |
|
|
|
|
|
const uploadedFileId = ref(null); |
|
|
|
|
|
|
|
|
|
|
|
// 证明文件上传前验证 |
|
|
|
|
|
function beforeUploadProof(file) { |
|
|
|
|
|
// 检查文件类型 |
|
|
|
|
|
const isImage = file.type === 'image/jpeg' || file.type === 'image/jpg' || file.type === 'image/png'; |
|
|
|
|
|
|
|
|
|
|
|
if (!isImage) { |
|
|
|
|
|
message.error('只能上传PDF、Word文档或图片文件!'); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 检查文件大小(10MB) |
|
|
|
|
|
const isLt10M = file.size / 1024 / 1024 < 10; |
|
|
|
|
|
if (!isLt10M) { |
|
|
|
|
|
message.error('文件大小不能超过10MB!'); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 律师承诺书上传 |
|
|
|
|
|
async function handleLawyerUpload() { |
|
|
|
|
|
try { |
|
|
|
|
|
// 在点击上传按钮时立即检查用户是否已签署承诺书 |
|
|
|
|
|
const hasSigned = await checkUserSigned(); |
|
|
|
|
|
if (hasSigned) { |
|
|
|
|
|
message.warning('您已经签署过律师承诺书,无需重复上传'); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 只有未签约的用户才能打开上传弹框 |
|
|
|
|
|
letterType.value = 'user'; |
|
|
|
|
|
showUploadModal.value = true; |
|
|
|
|
|
proofFileList.value = []; |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('检查签约状态失败:', error); |
|
|
|
|
|
message.error('检查签约状态失败,请稍后重试'); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 律所承诺书上传 |
|
|
|
|
|
async function handleFirmUpload() { |
|
|
|
|
|
try { |
|
|
|
|
|
// 在点击上传按钮时立即检查用户是否已签署承诺书 |
|
|
|
|
|
const hasSigned = await checkUserSigned(); |
|
|
|
|
|
if (hasSigned) { |
|
|
|
|
|
message.warning('您已经签署过律所承诺书,无需重复上传'); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 只有未签约的用户才能打开上传弹框 |
|
|
|
|
|
letterType.value = 'cto'; |
|
|
|
|
|
showUploadModal.value = true; |
|
|
|
|
|
proofFileList.value = []; |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('检查签约状态失败:', error); |
|
|
|
|
|
message.error('检查签约状态失败,请稍后重试'); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 处理文件选择变化 |
|
|
|
|
|
function handleFileChange(info) { |
|
|
|
|
|
let fileList = [...info.fileList]; |
|
|
|
|
|
|
|
|
|
|
|
// 限制只能上传一个文件 |
|
|
|
|
|
fileList = fileList.slice(-1); |
|
|
|
|
|
|
|
|
|
|
|
// 确保文件有正确的originFileObj |
|
|
|
|
|
fileList = fileList.map(file => { |
|
|
|
|
|
if (file.response) { |
|
|
|
|
|
// 组件会将文件信息转换为包含response的对象 |
|
|
|
|
|
file.url = file.response.url; |
|
|
|
|
|
} |
|
|
|
|
|
return file; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
proofFileList.value = fileList; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 自定义上传请求 - 参考公告中的正确实现 |
|
|
|
|
|
async function handleCustomUpload(options) { |
|
|
|
|
|
try { |
|
|
|
|
|
const formData = new FormData(); |
|
|
|
|
|
formData.append('file', options.file); |
|
|
|
|
|
|
|
|
|
|
|
const uploadResult = await fileApi.uploadFile(formData, FILE_FOLDER_TYPE_ENUM.FEEDBACK.value); |
|
|
|
|
|
|
|
|
|
|
|
if (uploadResult.code === 0 && uploadResult.data) { |
|
|
|
|
|
// 上传成功,调用onSuccess回调,并将结果设置到file.response中 |
|
|
|
|
|
options.onSuccess(uploadResult.data); |
|
|
|
|
|
|
|
|
|
|
|
// 同时更新文件列表中的response数据,以便handleUpload函数能检测到 |
|
|
|
|
|
if (proofFileList.value.length > 0) { |
|
|
|
|
|
proofFileList.value[0].response = uploadResult; |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
// 上传失败,调用onError回调 |
|
|
|
|
|
options.onError(new Error(uploadResult.msg || '上传失败')); |
|
|
|
|
|
} |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.error('查看承诺书详情失败:', error); |
|
|
// 异常情况,调用onError回调 |
|
|
// 如果出错,显示错误信息 |
|
|
options.onError(error); |
|
|
Modal.error({ |
|
|
} |
|
|
title: '错误', |
|
|
} |
|
|
content: '获取承诺书详情失败,请稍后重试', |
|
|
|
|
|
okText: '确定', |
|
|
// 保存承诺书 |
|
|
|
|
|
async function handleUpload() { |
|
|
|
|
|
if (proofFileList.value.length === 0) { |
|
|
|
|
|
message.warning('请选择要上传的证明文件'); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
proofUploadLoading.value = true; |
|
|
|
|
|
|
|
|
|
|
|
// 检查文件是否已经上传成功(通过customRequest) |
|
|
|
|
|
const file = proofFileList.value[0]; |
|
|
|
|
|
if (!file.response || !file.response.data) { |
|
|
|
|
|
message.warning('文件尚未上传完成,请稍后重试'); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取已上传文件的ID - 根据接口返回的数据结构 |
|
|
|
|
|
const fileId = file.response.data.fileId; |
|
|
|
|
|
|
|
|
|
|
|
if (!fileId) { |
|
|
|
|
|
message.error('获取文件ID失败,请重新上传文件'); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 调用承诺书保存接口,传递文件ID、类型和文件地址 |
|
|
|
|
|
const saveResult = await letterApi.add({ |
|
|
|
|
|
attachmentIds: fileId, |
|
|
|
|
|
letterType: letterType.value, |
|
|
|
|
|
fileUrl: file.response.data.fileUrl |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (saveResult.code === 0) { |
|
|
|
|
|
// 直接显示接口返回的data内容 |
|
|
|
|
|
message.success(saveResult.data || '承诺书保存成功'); |
|
|
|
|
|
|
|
|
|
|
|
// 清空文件列表 |
|
|
|
|
|
proofFileList.value = []; |
|
|
|
|
|
|
|
|
|
|
|
// 刷新列表 |
|
|
|
|
|
queryData(); |
|
|
|
|
|
|
|
|
|
|
|
// 关闭弹框 |
|
|
|
|
|
showUploadModal.value = false; |
|
|
|
|
|
} else { |
|
|
|
|
|
message.error(saveResult.msg || '保存承诺书失败'); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('保存承诺书失败:', error); |
|
|
|
|
|
message.error('保存失败,请稍后重试'); |
|
|
|
|
|
} finally { |
|
|
|
|
|
proofUploadLoading.value = false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 检查公告是否有附件 |
|
|
|
|
|
function hasAttachment(notice) { |
|
|
|
|
|
// 检查常见的附件字段 |
|
|
|
|
|
return !!(notice.attachment || notice.fileKey || notice.fileId || |
|
|
|
|
|
notice.attachmentId || notice.fileUrl || notice.attachmentUrl); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取公告附件文件key |
|
|
|
|
|
function getAttachmentFileKey(notice) { |
|
|
|
|
|
// 根据常见的附件字段获取文件key |
|
|
|
|
|
return notice.attachment || notice.fileKey || notice.fileId || |
|
|
|
|
|
notice.attachmentId || notice.fileUrl || notice.attachmentUrl; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 下载公告附件 |
|
|
|
|
|
async function downloadNoticeAttachment(notice) { |
|
|
|
|
|
try { |
|
|
|
|
|
SmartLoading.show(); |
|
|
|
|
|
|
|
|
|
|
|
// 获取附件文件key |
|
|
|
|
|
let fileKey = getAttachmentFileKey(notice); |
|
|
|
|
|
|
|
|
|
|
|
if (!fileKey) { |
|
|
|
|
|
message.warning('该公告没有附件文件'); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 使用file-api下载文件 |
|
|
|
|
|
await fileApi.downLoadFile(fileKey); |
|
|
|
|
|
message.success('附件下载成功'); |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('下载公告附件失败:', error); |
|
|
|
|
|
message.error('下载附件失败,请稍后重试'); |
|
|
|
|
|
} finally { |
|
|
|
|
|
SmartLoading.hide(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -202,6 +507,96 @@ import AgreementModal from '/@/views/system/home/components/agreement.vue'; |
|
|
// 总数 |
|
|
// 总数 |
|
|
const total = ref(0); |
|
|
const total = ref(0); |
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------- 角色判断相关 ---------------------------- |
|
|
|
|
|
|
|
|
|
|
|
// 判断用户是否为CEO角色 |
|
|
|
|
|
const isCeo = ref(false); |
|
|
|
|
|
// 判断用户是否为律师角色 |
|
|
|
|
|
const isLawyerRole = ref(false); |
|
|
|
|
|
// 判断用户是否为律所角色 |
|
|
|
|
|
const isFirmRole = ref(false); |
|
|
|
|
|
|
|
|
|
|
|
// 获取登录信息并检查角色 |
|
|
|
|
|
async function getLoginInfo() { |
|
|
|
|
|
try { |
|
|
|
|
|
const res = await loginApi.getLoginInfo(); |
|
|
|
|
|
const loginInfo = res.data; |
|
|
|
|
|
|
|
|
|
|
|
// 根据用户角色判断角色类型 |
|
|
|
|
|
if (loginInfo) { |
|
|
|
|
|
const roleCode = loginInfo.roleCode || ''; |
|
|
|
|
|
const userType = loginInfo.userType || ''; |
|
|
|
|
|
const departmentName = loginInfo.departmentName || ''; |
|
|
|
|
|
|
|
|
|
|
|
// 根据roleCode、userType和部门名称判断角色 |
|
|
|
|
|
const roleLower = roleCode.toLowerCase(); |
|
|
|
|
|
isCeo.value = roleLower === 'ceo'; |
|
|
|
|
|
// 律师角色:user |
|
|
|
|
|
isLawyerRole.value = roleLower === 'user' || userType === 'user'; |
|
|
|
|
|
// 律所角色:cto |
|
|
|
|
|
isFirmRole.value = roleLower === 'cto' || userType === 'cto'; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
console.error('获取登录信息失败:', e); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 检查用户是否已签署承诺书 |
|
|
|
|
|
async function checkUserSigned() { |
|
|
|
|
|
try { |
|
|
|
|
|
// 先获取当前登录用户信息 |
|
|
|
|
|
const loginRes = await loginApi.getLoginInfo(); |
|
|
|
|
|
const loginInfo = loginRes.data; |
|
|
|
|
|
|
|
|
|
|
|
if (!loginInfo || !loginInfo.employeeId) { |
|
|
|
|
|
console.error('无法获取当前用户ID'); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 使用正确的后端接口检查签约状态 |
|
|
|
|
|
const res = await letterApi.isLetter(loginInfo.employeeId); |
|
|
|
|
|
if (res.code === 0 && res.data !== undefined) { |
|
|
|
|
|
// 接口返回true代表已签约,false代表未签约 |
|
|
|
|
|
return res.data === true; |
|
|
|
|
|
} |
|
|
|
|
|
return false; |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('检查用户签约状态失败:', error); |
|
|
|
|
|
// 如果专用接口调用失败,回退到登录信息接口的agreementSignFlag字段 |
|
|
|
|
|
try { |
|
|
|
|
|
const loginRes = await loginApi.getLoginInfo(); |
|
|
|
|
|
const loginInfo = loginRes.data; |
|
|
|
|
|
if (loginInfo) { |
|
|
|
|
|
const agreementSignFlag = loginInfo.agreementSignFlag; |
|
|
|
|
|
return agreementSignFlag === true; |
|
|
|
|
|
} |
|
|
|
|
|
} catch (fallbackError) { |
|
|
|
|
|
console.error('回退检查用户签约状态失败:', fallbackError); |
|
|
|
|
|
} |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------- 公告数据相关 ---------------------------- |
|
|
|
|
|
|
|
|
|
|
|
// 公告列表数据 |
|
|
|
|
|
const noticeList = ref([]); |
|
|
|
|
|
|
|
|
|
|
|
// 查询承诺书数据 |
|
|
|
|
|
async function queryNoticeData() { |
|
|
|
|
|
try { |
|
|
|
|
|
// 使用新的承诺书接口查询数据 |
|
|
|
|
|
const result = await letterApi.queryAllBook(); |
|
|
|
|
|
|
|
|
|
|
|
if (result.data) { |
|
|
|
|
|
noticeList.value = result.data; |
|
|
|
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('查询承诺书数据失败:', error); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 加载所有员工列表 |
|
|
// 加载所有员工列表 |
|
|
async function loadAllEmployees() { |
|
|
async function loadAllEmployees() { |
|
|
if (employeeList.value.length > 0) { |
|
|
if (employeeList.value.length > 0) { |
|
|
@ -287,10 +682,18 @@ import AgreementModal from '/@/views/system/home/components/agreement.vue'; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
onMounted(async () => { |
|
|
|
|
|
// 获取登录信息并检查角色 |
|
|
|
|
|
await getLoginInfo(); |
|
|
|
|
|
|
|
|
queryData(); |
|
|
queryData(); |
|
|
// 页面加载时自动加载员工列表 |
|
|
// 页面加载时自动加载员工列表 |
|
|
loadAllEmployees(); |
|
|
loadAllEmployees(); |
|
|
|
|
|
|
|
|
|
|
|
// 如果不是CEO角色,查询承诺书数据 |
|
|
|
|
|
if (!isCeo.value) { |
|
|
|
|
|
queryNoticeData(); |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// 查看详情 |
|
|
// 查看详情 |
|
|
|