一日常规
This commit is contained in:
parent
43ea733eac
commit
073e462d71
@ -151,3 +151,10 @@ export function getGwFlowByIdApi(id: string) {
|
|||||||
export function gwTransferApi(params: any) {
|
export function gwTransferApi(params: any) {
|
||||||
return post('/api/gw/transfer', params);
|
return post('/api/gw/transfer', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询某人的待办和已办公文
|
||||||
|
*/
|
||||||
|
export function findUserTodosApi(approveStatus: string, jsId: string, pageNum: number = 1, pageSize: number = 20) {
|
||||||
|
return get('/api/gw/findUserTodos', { approveStatus, jsId, pageNum, pageSize });
|
||||||
|
}
|
||||||
|
|||||||
@ -46,11 +46,11 @@ const props = withDefaults(defineProps<{
|
|||||||
}>(), {
|
}>(), {
|
||||||
data: () => ({
|
data: () => ({
|
||||||
id: "",
|
id: "",
|
||||||
qjlx: "事假",
|
qjlx: "",
|
||||||
qjkstime: "2025-08-28 12:00:00",
|
qjkstime: "",
|
||||||
qjjstime: "2025-08-29 12:00:00",
|
qjjstime: "",
|
||||||
qjsc: "24小时",
|
qjsc: "",
|
||||||
qjsy: "测试请假",
|
qjsy: "",
|
||||||
dkfs: 0,
|
dkfs: 0,
|
||||||
sprList: [],
|
sprList: [],
|
||||||
csrList: [],
|
csrList: [],
|
||||||
@ -87,7 +87,7 @@ const [register, { setValue, getValue }] = useForm({
|
|||||||
component: "BasicPicker",
|
component: "BasicPicker",
|
||||||
componentProps: {
|
componentProps: {
|
||||||
api: findByPid,
|
api: findByPid,
|
||||||
param: { pid: 1007011432 },
|
param: { pid: 1405417393 },
|
||||||
rangeKey: "dictionaryValue",
|
rangeKey: "dictionaryValue",
|
||||||
savaKey: "dictionaryCode",
|
savaKey: "dictionaryCode",
|
||||||
},
|
},
|
||||||
|
|||||||
@ -305,8 +305,7 @@ import {
|
|||||||
canPreview,
|
canPreview,
|
||||||
previewFile as previewFileUtil,
|
previewFile as previewFileUtil,
|
||||||
previewVideo as previewVideoUtil,
|
previewVideo as previewVideoUtil,
|
||||||
previewImage as previewImageUtil,
|
previewImage as previewImageUtil
|
||||||
downloadFile as downloadFileUtil
|
|
||||||
} from "@/utils/filePreview";
|
} from "@/utils/filePreview";
|
||||||
|
|
||||||
// 类型定义
|
// 类型定义
|
||||||
@ -450,62 +449,28 @@ const canCurrentUserOperate = computed(() => {
|
|||||||
|
|
||||||
// 获取公文信息
|
// 获取公文信息
|
||||||
const getGwInfo = async () => {
|
const getGwInfo = async () => {
|
||||||
console.log("=== getGwInfo 开始执行 ===");
|
|
||||||
console.log("当前 gwId.value:", gwId.value);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log("准备调用API接口: getGwFlowByIdApi");
|
|
||||||
console.log("API参数:", { id: gwId.value });
|
|
||||||
|
|
||||||
// 调用新的API接口获取公文流程信息
|
// 调用新的API接口获取公文流程信息
|
||||||
const response = await getGwFlowByIdApi(gwId.value);
|
const response = await getGwFlowByIdApi(gwId.value);
|
||||||
console.log("API调用完成,响应结果:", response);
|
|
||||||
|
|
||||||
if (response.resultCode === 1) {
|
if (response.resultCode === 1) {
|
||||||
console.log("API调用成功,开始处理数据");
|
|
||||||
|
|
||||||
// 设置公文信息
|
// 设置公文信息
|
||||||
gwInfo.value = response.result.gwInfo;
|
gwInfo.value = response.result.gwInfo;
|
||||||
console.log("设置公文信息:", gwInfo.value);
|
|
||||||
console.log("公文信息字段详情:", {
|
|
||||||
title: gwInfo.value.title,
|
|
||||||
docType: gwInfo.value.docType,
|
|
||||||
urgencyLevel: gwInfo.value.urgencyLevel,
|
|
||||||
tjrId: gwInfo.value.tjrId,
|
|
||||||
createdTime: gwInfo.value.createdTime
|
|
||||||
});
|
|
||||||
|
|
||||||
// 设置审批人、抄送人、操作日志信息
|
// 设置审批人、抄送人、操作日志信息
|
||||||
approvers.value = response.result.approvers || [];
|
approvers.value = response.result.approvers || [];
|
||||||
ccUsers.value = response.result.ccUsers || [];
|
ccUsers.value = response.result.ccUsers || [];
|
||||||
operationLogs.value = response.result.operationLogs || [];
|
operationLogs.value = response.result.operationLogs || [];
|
||||||
|
|
||||||
console.log("设置审批人:", approvers.value);
|
|
||||||
console.log("设置抄送人:", ccUsers.value);
|
|
||||||
console.log("设置操作日志:", operationLogs.value);
|
|
||||||
|
|
||||||
console.log("成功获取公文流程信息:", {
|
|
||||||
gwInfo: gwInfo.value,
|
|
||||||
approvers: approvers.value,
|
|
||||||
ccUsers: ccUsers.value,
|
|
||||||
operationLogs: operationLogs.value
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
console.log("API调用失败,错误信息:", response.message);
|
|
||||||
throw new Error(response.message || '获取数据失败');
|
throw new Error(response.message || '获取数据失败');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取公文信息失败:", error);
|
|
||||||
console.log("API调用失败,无法获取数据");
|
|
||||||
|
|
||||||
// 清空所有数据
|
// 清空所有数据
|
||||||
gwInfo.value = {} as GwInfo;
|
gwInfo.value = {} as GwInfo;
|
||||||
approvers.value = [];
|
approvers.value = [];
|
||||||
ccUsers.value = [];
|
ccUsers.value = [];
|
||||||
operationLogs.value = [];
|
operationLogs.value = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("=== getGwInfo 执行完成 ===");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -566,9 +531,6 @@ const handleReject = () => {
|
|||||||
|
|
||||||
// 转办处理
|
// 转办处理
|
||||||
const handleTransfer = () => {
|
const handleTransfer = () => {
|
||||||
// 跳转到转办页面
|
|
||||||
console.log("转办公文:", gwId.value);
|
|
||||||
|
|
||||||
// 构建跳转参数,包含所有必要的数据
|
// 构建跳转参数,包含所有必要的数据
|
||||||
const params = {
|
const params = {
|
||||||
id: gwId.value,
|
id: gwId.value,
|
||||||
@ -628,26 +590,13 @@ const approveGw = async () => {
|
|||||||
// 获取当前用户ID - 应该从jsData中获取
|
// 获取当前用户ID - 应该从jsData中获取
|
||||||
const currentUserId = getJs?.id;
|
const currentUserId = getJs?.id;
|
||||||
if (!currentUserId) {
|
if (!currentUserId) {
|
||||||
console.error('无法获取当前用户信息,jsData:', getJs);
|
|
||||||
throw new Error('无法获取当前用户信息');
|
throw new Error('无法获取当前用户信息');
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('=== 调试信息 ===');
|
|
||||||
console.log('当前用户ID:', currentUserId);
|
|
||||||
console.log('jsData详情:', getJs);
|
|
||||||
console.log('userdata详情:', getUser);
|
|
||||||
console.log('审批人列表:', approvers.value);
|
|
||||||
console.log('审批人列表长度:', approvers.value?.length || 0);
|
|
||||||
|
|
||||||
// 获取当前用户在审批人列表中的ID
|
// 获取当前用户在审批人列表中的ID
|
||||||
const currentUserApproverId = getCurrentUserApproverId(currentUserId);
|
const currentUserApproverId = getCurrentUserApproverId(currentUserId);
|
||||||
console.log('找到的审批人ID:', currentUserApproverId);
|
|
||||||
|
|
||||||
if (!currentUserApproverId) {
|
if (!currentUserApproverId) {
|
||||||
console.error('无法找到当前用户的审批人记录,详细信息:');
|
|
||||||
console.error('approvers数组:', approvers.value);
|
|
||||||
console.error('当前用户ID:', currentUserId);
|
|
||||||
console.error('用户信息:', { getUser, getJs });
|
|
||||||
throw new Error('无法获取当前用户的审批人记录');
|
throw new Error('无法获取当前用户的审批人记录');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -661,11 +610,8 @@ const approveGw = async () => {
|
|||||||
currentUserId: currentUserId
|
currentUserId: currentUserId
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('同意数据:', approveData);
|
|
||||||
|
|
||||||
// 调用同意API - 使用正确的API函数
|
// 调用同意API - 使用正确的API函数
|
||||||
const response = await gwApproveApi(approveData);
|
const response = await gwApproveApi(approveData);
|
||||||
console.log('API响应:', response);
|
|
||||||
|
|
||||||
// 隐藏加载提示
|
// 隐藏加载提示
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
@ -696,7 +642,6 @@ const approveGw = async () => {
|
|||||||
// 隐藏加载提示
|
// 隐藏加载提示
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
|
|
||||||
console.error("同意公文失败:", error);
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: error.message || "同意失败",
|
title: error.message || "同意失败",
|
||||||
icon: "error",
|
icon: "error",
|
||||||
@ -723,61 +668,23 @@ const getCurrentUserApproverStatus = () => {
|
|||||||
|
|
||||||
// 获取当前用户在审批人列表中的ID
|
// 获取当前用户在审批人列表中的ID
|
||||||
const getCurrentUserApproverId = (currentUserId: string) => {
|
const getCurrentUserApproverId = (currentUserId: string) => {
|
||||||
console.log('=== getCurrentUserApproverId 函数调试 ===');
|
|
||||||
console.log('传入的currentUserId:', currentUserId);
|
|
||||||
console.log('approvers.value:', approvers.value);
|
|
||||||
console.log('approvers.value长度:', approvers.value?.length || 0);
|
|
||||||
|
|
||||||
if (!approvers.value || approvers.value.length === 0) {
|
if (!approvers.value || approvers.value.length === 0) {
|
||||||
console.log('approvers数组为空或未定义,返回null');
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找当前用户对应的审批人记录
|
// 查找当前用户对应的审批人记录
|
||||||
console.log('开始查找审批人记录...');
|
|
||||||
approvers.value.forEach((approver, index) => {
|
|
||||||
console.log(`审批人${index + 1}:`, {
|
|
||||||
id: approver.id,
|
|
||||||
userId: approver.userId,
|
|
||||||
userName: approver.userName,
|
|
||||||
deptName: approver.deptName,
|
|
||||||
order: approver.order,
|
|
||||||
status: approver.status,
|
|
||||||
approveStatus: approver.approveStatus
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const currentUserApprover = approvers.value.find(approver => {
|
const currentUserApprover = approvers.value.find(approver => {
|
||||||
const matchByUserId = approver.userId === currentUserId;
|
const matchByUserId = approver.userId === currentUserId;
|
||||||
const matchById = approver.id === currentUserId;
|
const matchById = approver.id === currentUserId;
|
||||||
console.log(`检查审批人 ${approver.userName}:`, {
|
|
||||||
userId: approver.userId,
|
|
||||||
id: approver.id,
|
|
||||||
currentUserId: currentUserId,
|
|
||||||
matchByUserId,
|
|
||||||
matchById
|
|
||||||
});
|
|
||||||
return matchByUserId || matchById;
|
return matchByUserId || matchById;
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('找到的审批人记录:', currentUserApprover);
|
return currentUserApprover?.id || null;
|
||||||
const result = currentUserApprover?.id || null;
|
|
||||||
console.log('返回结果:', result);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 预览单个附件(从gwInfo直接获取)
|
// 预览单个附件(从gwInfo直接获取)
|
||||||
const previewSingleFile = () => {
|
const previewSingleFile = () => {
|
||||||
console.log("=== 预览单个附件 ===");
|
|
||||||
console.log("附件信息:", {
|
|
||||||
fileUrl: gwInfo.value.fileUrl,
|
|
||||||
fileName: gwInfo.value.fileName,
|
|
||||||
fileFormat: gwInfo.value.fileFormat
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!gwInfo.value.fileUrl) {
|
if (!gwInfo.value.fileUrl) {
|
||||||
console.error("没有找到附件URL");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -785,10 +692,6 @@ const previewSingleFile = () => {
|
|||||||
const fileName = gwInfo.value.fileName || '未知文件';
|
const fileName = gwInfo.value.fileName || '未知文件';
|
||||||
const fileFormat = gwInfo.value.fileFormat || '';
|
const fileFormat = gwInfo.value.fileFormat || '';
|
||||||
|
|
||||||
console.log("处理后的文件URL:", fileUrl);
|
|
||||||
console.log("文件名:", fileName);
|
|
||||||
console.log("文件格式:", fileFormat);
|
|
||||||
|
|
||||||
// 根据文件类型选择预览方式
|
// 根据文件类型选择预览方式
|
||||||
if (isVideo(fileFormat)) {
|
if (isVideo(fileFormat)) {
|
||||||
handlePreviewVideoSingle(fileUrl, fileName);
|
handlePreviewVideoSingle(fileUrl, fileName);
|
||||||
@ -805,7 +708,6 @@ const previewSingleFile = () => {
|
|||||||
// 下载单个附件
|
// 下载单个附件
|
||||||
const downloadSingleFile = () => {
|
const downloadSingleFile = () => {
|
||||||
if (!gwInfo.value.fileUrl) {
|
if (!gwInfo.value.fileUrl) {
|
||||||
console.error("没有找到附件URL");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -814,39 +716,64 @@ const downloadSingleFile = () => {
|
|||||||
const fileFormat = gwInfo.value.fileFormat || '';
|
const fileFormat = gwInfo.value.fileFormat || '';
|
||||||
const fullFileName = fileFormat ? `${fileName}.${fileFormat}` : fileName;
|
const fullFileName = fileFormat ? `${fileName}.${fileFormat}` : fileName;
|
||||||
|
|
||||||
console.log("下载单个附件:", { fileUrl, fullFileName });
|
// 方法1: 使用 fetch 和 blob 方式强制下载
|
||||||
|
fetch(fileUrl)
|
||||||
|
.then(response => {
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('网络请求失败');
|
||||||
|
}
|
||||||
|
return response.blob();
|
||||||
|
})
|
||||||
|
.then(blob => {
|
||||||
|
const downloadUrl = window.URL.createObjectURL(blob);
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = downloadUrl;
|
||||||
|
link.download = fullFileName; // 使用 download 属性强制下载
|
||||||
|
link.style.display = 'none';
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
window.URL.revokeObjectURL(downloadUrl);
|
||||||
|
|
||||||
downloadFileUtil(fileUrl, fullFileName)
|
|
||||||
.then(() => {
|
|
||||||
console.log('文件下载成功');
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '下载成功',
|
title: '开始下载',
|
||||||
icon: 'success'
|
icon: 'success'
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((error: any) => {
|
.catch(error => {
|
||||||
console.error('文件下载失败:', error);
|
console.error('fetch下载失败:', error);
|
||||||
|
// 方法2: 如果fetch失败,尝试直接打开链接
|
||||||
|
try {
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = fileUrl;
|
||||||
|
link.download = fullFileName;
|
||||||
|
link.target = '_blank';
|
||||||
|
link.style.display = 'none';
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
|
||||||
|
uni.showToast({
|
||||||
|
title: '开始下载',
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
|
} catch (fallbackError) {
|
||||||
|
console.error('备用下载也失败:', fallbackError);
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '下载失败',
|
title: '下载失败',
|
||||||
icon: 'error'
|
icon: 'error'
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 文件预览
|
// 文件预览
|
||||||
const previewFile = (file: FileInfo) => {
|
const previewFile = (file: FileInfo) => {
|
||||||
console.log("=== 处理文件预览 ===");
|
|
||||||
console.log("文件信息:", file);
|
|
||||||
|
|
||||||
// 确定文件URL和名称
|
// 确定文件URL和名称
|
||||||
const fileUrl = file.resourUrl ? imagUrl(file.resourUrl) : file.url;
|
const fileUrl = file.resourUrl ? imagUrl(file.resourUrl) : file.url;
|
||||||
const fileName = file.resourName ? `${file.resourName}.${file.resSuf}` : file.name;
|
const fileName = file.resourName ? `${file.resourName}.${file.resSuf}` : file.name;
|
||||||
const fileSuf = file.resSuf || file.name.split('.').pop() || '';
|
const fileSuf = file.resSuf || file.name.split('.').pop() || '';
|
||||||
|
|
||||||
console.log("处理后的文件URL:", fileUrl);
|
|
||||||
console.log("文件名:", fileName);
|
|
||||||
console.log("文件后缀:", fileSuf);
|
|
||||||
|
|
||||||
// 根据文件类型选择预览方式
|
// 根据文件类型选择预览方式
|
||||||
if (isVideo(fileSuf)) {
|
if (isVideo(fileSuf)) {
|
||||||
handlePreviewVideo(file);
|
handlePreviewVideo(file);
|
||||||
@ -867,11 +794,7 @@ const handlePreviewDocument = (file: FileInfo) => {
|
|||||||
const fileSuf = file.resSuf || file.name.split('.').pop() || '';
|
const fileSuf = file.resSuf || file.name.split('.').pop() || '';
|
||||||
|
|
||||||
previewFileUtil(fileUrl, fileName, fileSuf)
|
previewFileUtil(fileUrl, fileName, fileSuf)
|
||||||
.then(() => {
|
|
||||||
console.log('文档预览成功');
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
console.error('文档预览失败:', error);
|
|
||||||
// 预览失败时尝试下载
|
// 预览失败时尝试下载
|
||||||
downloadFileAction(file);
|
downloadFileAction(file);
|
||||||
});
|
});
|
||||||
@ -882,11 +805,7 @@ const handlePreviewDocumentSingle = (fileUrl: string, fileName: string, fileForm
|
|||||||
const fullFileName = fileFormat ? `${fileName}.${fileFormat}` : fileName;
|
const fullFileName = fileFormat ? `${fileName}.${fileFormat}` : fileName;
|
||||||
|
|
||||||
previewFileUtil(fileUrl, fullFileName, fileFormat)
|
previewFileUtil(fileUrl, fullFileName, fileFormat)
|
||||||
.then(() => {
|
|
||||||
console.log('单个附件文档预览成功');
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
console.error('单个附件文档预览失败:', error);
|
|
||||||
// 预览失败时尝试下载
|
// 预览失败时尝试下载
|
||||||
downloadSingleFile();
|
downloadSingleFile();
|
||||||
});
|
});
|
||||||
@ -894,35 +813,20 @@ const handlePreviewDocumentSingle = (fileUrl: string, fileName: string, fileForm
|
|||||||
|
|
||||||
// 视频预览
|
// 视频预览
|
||||||
const handlePreviewVideo = (file: FileInfo) => {
|
const handlePreviewVideo = (file: FileInfo) => {
|
||||||
console.log('=== 处理视频预览 ===');
|
|
||||||
console.log('视频文件:', file);
|
|
||||||
|
|
||||||
const videoUrl = file.resourUrl ? imagUrl(file.resourUrl) : file.url;
|
const videoUrl = file.resourUrl ? imagUrl(file.resourUrl) : file.url;
|
||||||
const videoName = file.resourName || file.name;
|
const videoName = file.resourName || file.name;
|
||||||
|
|
||||||
console.log('处理后的视频URL:', videoUrl);
|
|
||||||
|
|
||||||
previewVideoUtil(videoUrl, videoName)
|
previewVideoUtil(videoUrl, videoName)
|
||||||
.then(() => {
|
|
||||||
console.log('视频预览成功');
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
console.error('视频预览失败:', error);
|
// 视频预览失败时的处理
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 单个附件视频预览
|
// 单个附件视频预览
|
||||||
const handlePreviewVideoSingle = (videoUrl: string, videoName: string) => {
|
const handlePreviewVideoSingle = (videoUrl: string, videoName: string) => {
|
||||||
console.log('=== 处理单个附件视频预览 ===');
|
|
||||||
console.log('视频URL:', videoUrl);
|
|
||||||
console.log('视频名称:', videoName);
|
|
||||||
|
|
||||||
previewVideoUtil(videoUrl, videoName)
|
previewVideoUtil(videoUrl, videoName)
|
||||||
.then(() => {
|
|
||||||
console.log('单个附件视频预览成功');
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
console.error('单个附件视频预览失败:', error);
|
// 视频预览失败时的处理
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -931,25 +835,16 @@ const handlePreviewImage = (file: FileInfo) => {
|
|||||||
const imageUrl = file.resourUrl ? imagUrl(file.resourUrl) : file.url;
|
const imageUrl = file.resourUrl ? imagUrl(file.resourUrl) : file.url;
|
||||||
|
|
||||||
previewImageUtil(imageUrl)
|
previewImageUtil(imageUrl)
|
||||||
.then(() => {
|
|
||||||
console.log('图片预览成功');
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
console.error('图片预览失败:', error);
|
// 图片预览失败时的处理
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 单个附件图片预览
|
// 单个附件图片预览
|
||||||
const handlePreviewImageSingle = (imageUrl: string) => {
|
const handlePreviewImageSingle = (imageUrl: string) => {
|
||||||
console.log('=== 处理单个附件图片预览 ===');
|
|
||||||
console.log('图片URL:', imageUrl);
|
|
||||||
|
|
||||||
previewImageUtil(imageUrl)
|
previewImageUtil(imageUrl)
|
||||||
.then(() => {
|
|
||||||
console.log('单个附件图片预览成功');
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
console.error('单个附件图片预览失败:', error);
|
// 图片预览失败时的处理
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -963,24 +858,54 @@ const downloadFileAction = (file: FileInfo) => {
|
|||||||
const fileUrl = file.resourUrl ? imagUrl(file.resourUrl) : file.url;
|
const fileUrl = file.resourUrl ? imagUrl(file.resourUrl) : file.url;
|
||||||
const fileName = file.resourName ? `${file.resourName}.${file.resSuf}` : file.name;
|
const fileName = file.resourName ? `${file.resourName}.${file.resSuf}` : file.name;
|
||||||
|
|
||||||
console.log("下载文件:", file);
|
// 方法1: 使用 fetch 和 blob 方式强制下载
|
||||||
console.log("下载URL:", fileUrl);
|
fetch(fileUrl)
|
||||||
console.log("文件名:", fileName);
|
.then(response => {
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('网络请求失败');
|
||||||
|
}
|
||||||
|
return response.blob();
|
||||||
|
})
|
||||||
|
.then(blob => {
|
||||||
|
const downloadUrl = window.URL.createObjectURL(blob);
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = downloadUrl;
|
||||||
|
link.download = fileName; // 使用 download 属性强制下载
|
||||||
|
link.style.display = 'none';
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
window.URL.revokeObjectURL(downloadUrl);
|
||||||
|
|
||||||
downloadFileUtil(fileUrl, fileName)
|
|
||||||
.then(() => {
|
|
||||||
console.log('文件下载成功');
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '下载成功',
|
title: '开始下载',
|
||||||
icon: 'success'
|
icon: 'success'
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((error: any) => {
|
.catch(error => {
|
||||||
console.error('文件下载失败:', error);
|
console.error('fetch下载失败:', error);
|
||||||
|
// 方法2: 如果fetch失败,尝试直接打开链接
|
||||||
|
try {
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = fileUrl;
|
||||||
|
link.download = fileName;
|
||||||
|
link.target = '_blank';
|
||||||
|
link.style.display = 'none';
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
|
||||||
|
uni.showToast({
|
||||||
|
title: '开始下载',
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
|
} catch (fallbackError) {
|
||||||
|
console.error('备用下载也失败:', fallbackError);
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '下载失败',
|
title: '下载失败',
|
||||||
icon: 'error'
|
icon: 'error'
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1150,113 +1075,74 @@ const getCreatorName = (tjrId: string) => {
|
|||||||
// 如果缓存中没有找到,返回ID
|
// 如果缓存中没有找到,返回ID
|
||||||
return `用户${tjrId}`;
|
return `用户${tjrId}`;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取创建人信息失败:", error);
|
|
||||||
return `用户${tjrId}`;
|
return `用户${tjrId}`;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
console.log("=== onMounted 开始执行 ===");
|
|
||||||
|
|
||||||
// 尝试多种方式获取页面参数
|
// 尝试多种方式获取页面参数
|
||||||
let pageId = "";
|
let pageId = "";
|
||||||
|
|
||||||
// 方式1: 通过 getCurrentPages() 获取
|
// 方式1: 通过 getCurrentPages() 获取
|
||||||
const pages = getCurrentPages();
|
const pages = getCurrentPages();
|
||||||
console.log("getCurrentPages() 结果:", pages);
|
|
||||||
|
|
||||||
if (pages.length > 0) {
|
if (pages.length > 0) {
|
||||||
const currentPage = pages[pages.length - 1];
|
const currentPage = pages[pages.length - 1];
|
||||||
console.log("当前页面对象:", currentPage);
|
|
||||||
|
|
||||||
// 尝试不同的属性获取参数
|
// 尝试不同的属性获取参数
|
||||||
const options = (currentPage as any).options || {};
|
const options = (currentPage as any).options || {};
|
||||||
const route = (currentPage as any).route || "";
|
|
||||||
const fullPath = (currentPage as any).fullPath || "";
|
|
||||||
|
|
||||||
console.log("页面参数 options:", options);
|
|
||||||
console.log("页面路由 route:", route);
|
|
||||||
console.log("完整路径 fullPath:", fullPath);
|
|
||||||
|
|
||||||
pageId = options.id || "";
|
pageId = options.id || "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 方式2: 如果方式1没有获取到,尝试从URL解析
|
// 方式2: 如果方式1没有获取到,尝试从URL解析
|
||||||
if (!pageId) {
|
if (!pageId) {
|
||||||
console.log("尝试从URL解析参数");
|
|
||||||
try {
|
try {
|
||||||
// 获取当前页面URL
|
// 获取当前页面URL
|
||||||
const currentUrl = window.location.href;
|
const currentUrl = window.location.href;
|
||||||
console.log("当前页面URL:", currentUrl);
|
|
||||||
|
|
||||||
// 在uni-app H5环境中,参数通常在hash部分
|
// 在uni-app H5环境中,参数通常在hash部分
|
||||||
const hash = window.location.hash;
|
const hash = window.location.hash;
|
||||||
console.log("页面hash:", hash);
|
|
||||||
|
|
||||||
if (hash && hash.includes('?')) {
|
if (hash && hash.includes('?')) {
|
||||||
// 从hash中提取查询参数
|
// 从hash中提取查询参数
|
||||||
const queryString = hash.split('?')[1];
|
const queryString = hash.split('?')[1];
|
||||||
console.log("查询参数字符串:", queryString);
|
|
||||||
|
|
||||||
// 解析查询参数
|
// 解析查询参数
|
||||||
const urlParams = new URLSearchParams(queryString);
|
const urlParams = new URLSearchParams(queryString);
|
||||||
pageId = urlParams.get('id') || "";
|
pageId = urlParams.get('id') || "";
|
||||||
console.log("从hash解析到的id:", pageId);
|
|
||||||
} else {
|
} else {
|
||||||
// 尝试从search部分解析(备用方案)
|
// 尝试从search部分解析(备用方案)
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
pageId = urlParams.get('id') || "";
|
pageId = urlParams.get('id') || "";
|
||||||
console.log("从search解析到的id:", pageId);
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("URL解析失败:", error);
|
// URL解析失败
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 方式3: 如果前两种方式都没有获取到,尝试从路由参数获取
|
// 方式3: 如果前两种方式都没有获取到,尝试从路由参数获取
|
||||||
if (!pageId) {
|
if (!pageId) {
|
||||||
console.log("尝试从路由参数获取");
|
|
||||||
try {
|
try {
|
||||||
// 获取当前页面的完整路径
|
// 获取当前页面的完整路径
|
||||||
const currentPath = window.location.pathname;
|
const currentPath = window.location.pathname;
|
||||||
console.log("当前页面路径:", currentPath);
|
|
||||||
|
|
||||||
// 从路径中提取参数(如果路径包含参数)
|
// 从路径中提取参数(如果路径包含参数)
|
||||||
const pathMatch = currentPath.match(/\/gwFlow\/([^/?]+)/);
|
const pathMatch = currentPath.match(/\/gwFlow\/([^/?]+)/);
|
||||||
if (pathMatch) {
|
if (pathMatch) {
|
||||||
pageId = pathMatch[1];
|
pageId = pathMatch[1];
|
||||||
console.log("从路径提取的id:", pageId);
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("路径解析失败:", error);
|
// 路径解析失败
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置gwId
|
// 设置gwId
|
||||||
gwId.value = pageId;
|
gwId.value = pageId;
|
||||||
console.log("最终获取到的 gwId:", gwId.value);
|
|
||||||
|
|
||||||
if (gwId.value) {
|
if (gwId.value) {
|
||||||
console.log("gwId 存在,开始调用 getGwInfo()");
|
|
||||||
getGwInfo();
|
getGwInfo();
|
||||||
} else {
|
|
||||||
console.log("gwId 不存在,无法调用接口");
|
|
||||||
console.log("请检查URL参数是否正确,例如: ?id=1157408920235544576");
|
|
||||||
|
|
||||||
// 显示调试信息
|
|
||||||
console.log("=== 调试信息 ===");
|
|
||||||
console.log("当前页面完整信息:", {
|
|
||||||
href: window.location.href,
|
|
||||||
pathname: window.location.pathname,
|
|
||||||
search: window.location.search,
|
|
||||||
hash: window.location.hash
|
|
||||||
});
|
|
||||||
|
|
||||||
// 不再需要测试ID,因为参数解析已经修复
|
|
||||||
console.log("参数解析完成,但未找到有效的ID");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("=== onMounted 执行完成 ===");
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -1,19 +1,25 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="gw-list-page">
|
<view class="gw-list-page">
|
||||||
<!-- 列表组件 -->
|
<!-- 搜索和筛选组件 -->
|
||||||
<view class="list-component">
|
|
||||||
<BasicListLayout @register="register" v-model="dataList">
|
|
||||||
<!-- 搜索和筛选组件放在top插槽中 -->
|
|
||||||
<template #top>
|
|
||||||
<view class="query-component">
|
<view class="query-component">
|
||||||
<view class="search-card">
|
<view class="search-card">
|
||||||
<!-- 搜索框 -->
|
<!-- 搜索框和查询按钮 -->
|
||||||
<view class="search-item">
|
<view class="search-item">
|
||||||
|
<view class="search-container">
|
||||||
<BasicSearch
|
<BasicSearch
|
||||||
placeholder="搜索公文标题、编号或类型"
|
placeholder="搜索公文标题、编号或类型"
|
||||||
@search="handleSearch"
|
@search="handleSearch"
|
||||||
class="search-input"
|
class="search-input"
|
||||||
|
v-model="searchKeyword"
|
||||||
/>
|
/>
|
||||||
|
<u-button
|
||||||
|
text="查询"
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
class="search-button"
|
||||||
|
@click="handleSearch(searchKeyword)"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 筛选标签 -->
|
<!-- 筛选标签 -->
|
||||||
@ -30,10 +36,21 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-slot="{ data }">
|
<!-- 列表内容 -->
|
||||||
<view class="gw-card">
|
<view class="list-content">
|
||||||
|
<!-- 加载状态 -->
|
||||||
|
<view v-if="loading" class="loading-container">
|
||||||
|
<view class="loading-text">加载中...</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 数据列表 -->
|
||||||
|
<view v-else>
|
||||||
|
<view
|
||||||
|
v-for="(data, index) in filteredGwList"
|
||||||
|
:key="data.id || index"
|
||||||
|
class="gw-card"
|
||||||
|
>
|
||||||
<view class="card-header">
|
<view class="card-header">
|
||||||
<text class="gw-title">{{ data.title }}</text>
|
<text class="gw-title">{{ data.title }}</text>
|
||||||
<text class="gw-status" :class="getStatusClass(data.gwStatus)">
|
<text class="gw-status" :class="getStatusClass(data.gwStatus)">
|
||||||
@ -56,16 +73,13 @@
|
|||||||
<view class="attachments-list">
|
<view class="attachments-list">
|
||||||
<!-- 统一处理所有附件 -->
|
<!-- 统一处理所有附件 -->
|
||||||
<view
|
<view
|
||||||
v-for="(file, index) in parseFileList(data)"
|
v-for="(file, fileIndex) in parseFileList(data)"
|
||||||
:key="index"
|
:key="fileIndex"
|
||||||
class="attachment-item"
|
class="attachment-item"
|
||||||
@click="previewAttachmentFile(file)"
|
@click="previewAttachmentFile(file)"
|
||||||
>
|
>
|
||||||
<view class="attachment-icon">
|
<view class="attachment-icon">
|
||||||
<text v-if="isImage(getFileSuffix(file))">🖼️</text>
|
<text>📄</text>
|
||||||
<text v-else-if="isVideo(getFileSuffix(file))">🎥</text>
|
|
||||||
<text v-else-if="canPreview(getFileSuffix(file))">📄</text>
|
|
||||||
<text v-else>📎</text>
|
|
||||||
</view>
|
</view>
|
||||||
<text class="attachment-name">{{ getFileName(file) }}</text>
|
<text class="attachment-name">{{ getFileName(file) }}</text>
|
||||||
</view>
|
</view>
|
||||||
@ -85,20 +99,12 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
|
||||||
|
|
||||||
<!-- 新建公文按钮已隐藏 -->
|
<!-- 空状态 -->
|
||||||
<!-- <template #bottom>
|
<view v-if="!loading && filteredGwList.length === 0" class="empty-container">
|
||||||
<view class="flex-row items-center pb-10 pt-5">
|
<view class="empty-text">暂无数据</view>
|
||||||
<u-button
|
</view>
|
||||||
text="新建公文"
|
|
||||||
class="mx-15"
|
|
||||||
type="primary"
|
|
||||||
@click="createNewGw"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
</template> -->
|
|
||||||
</BasicListLayout>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@ -108,21 +114,12 @@ import { ref, computed, watch, onMounted, onUnmounted } from "vue";
|
|||||||
import { onShow } from "@dcloudio/uni-app";
|
import { onShow } from "@dcloudio/uni-app";
|
||||||
import { navigateTo } from "@/utils/uniapp";
|
import { navigateTo } from "@/utils/uniapp";
|
||||||
import BasicSearch from "@/components/BasicSearch/Search.vue";
|
import BasicSearch from "@/components/BasicSearch/Search.vue";
|
||||||
import BasicLayout from "@/components/BasicLayout/Layout.vue";
|
import { gwFindPageApi, findUserTodosApi } from "@/api/routine/gw";
|
||||||
import BasicListLayout from "@/components/BasicListLayout/ListLayout.vue";
|
|
||||||
import { useLayout } from "@/components/BasicListLayout/hooks/useLayout";
|
|
||||||
import { gwFindPageApi } from "@/api/routine/gw";
|
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { imagUrl } from "@/utils";
|
import { imagUrl } from "@/utils";
|
||||||
import { useUserStore } from "@/store/modules/user";
|
import { useUserStore } from "@/store/modules/user";
|
||||||
import {
|
import {
|
||||||
isVideo,
|
previewFile as previewFileUtil
|
||||||
isImage,
|
|
||||||
canPreview,
|
|
||||||
previewFile as previewFileUtil,
|
|
||||||
previewVideo as previewVideoUtil,
|
|
||||||
previewImage as previewImageUtil,
|
|
||||||
downloadFile as downloadFileUtil
|
|
||||||
} from "@/utils/filePreview";
|
} from "@/utils/filePreview";
|
||||||
|
|
||||||
// 附件类型定义
|
// 附件类型定义
|
||||||
@ -153,32 +150,20 @@ interface GwListItem {
|
|||||||
|
|
||||||
// 筛选标签
|
// 筛选标签
|
||||||
const filterTabs = [
|
const filterTabs = [
|
||||||
|
{ key: "pending", label: "待办" },
|
||||||
|
{ key: "approved", label: "已办" },
|
||||||
{ key: "all", label: "全部" },
|
{ key: "all", label: "全部" },
|
||||||
{ key: "C", label: "审批中" },
|
|
||||||
{ key: "D", label: "已完结" },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const activeTab = ref("all");
|
const activeTab = ref("pending");
|
||||||
const searchKeyword = ref("");
|
const searchKeyword = ref("");
|
||||||
|
|
||||||
// 获取用户store
|
// 获取用户store
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
// 使用 BasicListLayout
|
|
||||||
const [register, { reload, setParam }] = useLayout({
|
|
||||||
api: gwFindPageApi,
|
|
||||||
componentProps: {
|
|
||||||
defaultPageSize: 20,
|
|
||||||
},
|
|
||||||
param: {
|
|
||||||
title: "",
|
|
||||||
docType: "",
|
|
||||||
gwStatus: "",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// 数据列表
|
// 数据列表
|
||||||
const dataList = ref<GwListItem[]>([]);
|
const dataList = ref<GwListItem[]>([]);
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
// 获取当前教师ID
|
// 获取当前教师ID
|
||||||
const getCurrentTeacherId = () => {
|
const getCurrentTeacherId = () => {
|
||||||
@ -190,12 +175,13 @@ const getCurrentTeacherId = () => {
|
|||||||
const filteredGwList = computed(() => {
|
const filteredGwList = computed(() => {
|
||||||
let list = dataList.value;
|
let list = dataList.value;
|
||||||
|
|
||||||
// 按状态筛选
|
// 对于待办/已办标签,数据已经通过API筛选,不需要再次筛选
|
||||||
if (activeTab.value !== "all") {
|
// 只对"全部"标签进行状态筛选
|
||||||
list = list.filter((item: GwListItem) => item.gwStatus === activeTab.value);
|
if (activeTab.value === "all") {
|
||||||
|
// 这里可以添加额外的筛选逻辑,如果需要的话
|
||||||
}
|
}
|
||||||
|
|
||||||
// 按关键词搜索
|
// 按关键词搜索(对所有标签都适用)
|
||||||
if (searchKeyword.value) {
|
if (searchKeyword.value) {
|
||||||
const keyword = searchKeyword.value.toLowerCase();
|
const keyword = searchKeyword.value.toLowerCase();
|
||||||
list = list.filter((item: GwListItem) =>
|
list = list.filter((item: GwListItem) =>
|
||||||
@ -211,21 +197,135 @@ const filteredGwList = computed(() => {
|
|||||||
// 切换筛选标签
|
// 切换筛选标签
|
||||||
const switchTab = (tabKey: string) => {
|
const switchTab = (tabKey: string) => {
|
||||||
activeTab.value = tabKey;
|
activeTab.value = tabKey;
|
||||||
// 更新查询参数并重新加载
|
|
||||||
const gwStatus = tabKey === "all" ? "" : tabKey;
|
// 获取当前教师ID
|
||||||
setParam({ gwStatus });
|
const currentTeacherId = getCurrentTeacherId();
|
||||||
reload();
|
|
||||||
|
if (tabKey === "all") {
|
||||||
|
// 全部:调用 findPage API
|
||||||
|
loadAllData();
|
||||||
|
} else if (tabKey === "pending") {
|
||||||
|
// 待办:只调用 findUserTodos API,传 approveStatus = 'pending'
|
||||||
|
if (currentTeacherId) {
|
||||||
|
loadUserTodos('pending', currentTeacherId);
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: '无法获取用户信息',
|
||||||
|
icon: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (tabKey === "approved") {
|
||||||
|
// 已办:只调用 findUserTodos API,传 approveStatus = 'approved'
|
||||||
|
if (currentTeacherId) {
|
||||||
|
loadUserTodos('approved', currentTeacherId);
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: '无法获取用户信息',
|
||||||
|
icon: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 加载全部数据(调用 findPage 接口)
|
||||||
|
const loadAllData = async () => {
|
||||||
|
try {
|
||||||
|
loading.value = true;
|
||||||
|
uni.showLoading({ title: '加载中...' });
|
||||||
|
|
||||||
|
const response = await gwFindPageApi({
|
||||||
|
title: searchKeyword.value,
|
||||||
|
docType: searchKeyword.value,
|
||||||
|
gwStatus: ""
|
||||||
|
});
|
||||||
|
|
||||||
|
// 检查响应格式 - 根据实际返回的数据结构
|
||||||
|
const result = (response as any).data || response;
|
||||||
|
|
||||||
|
// 适配分页查询返回的数据结构 {total, page, records, rows}
|
||||||
|
if (result.rows && Array.isArray(result.rows)) {
|
||||||
|
dataList.value = result.rows;
|
||||||
|
} else if (result.resultCode === 1) {
|
||||||
|
// 兼容旧的数据结构
|
||||||
|
dataList.value = result.result || [];
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: result.message || '加载失败',
|
||||||
|
icon: 'error'
|
||||||
|
});
|
||||||
|
dataList.value = [];
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载全部数据失败:', error);
|
||||||
|
uni.showToast({
|
||||||
|
title: '加载失败',
|
||||||
|
icon: 'error'
|
||||||
|
});
|
||||||
|
dataList.value = [];
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
uni.hideLoading();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 加载用户待办/已办数据(只调用 findUserTodos 分页接口)
|
||||||
|
const loadUserTodos = async (approveStatus: string, jsId: string) => {
|
||||||
|
try {
|
||||||
|
loading.value = true;
|
||||||
|
uni.showLoading({ title: '加载中...' });
|
||||||
|
|
||||||
|
// 只调用 findUserTodos 分页接口
|
||||||
|
const response = await findUserTodosApi(approveStatus, jsId, 1, 1000); // 设置较大的pageSize以获取所有数据
|
||||||
|
|
||||||
|
// 检查响应格式 - 根据实际返回的数据结构
|
||||||
|
const result = (response as any).data || response;
|
||||||
|
|
||||||
|
// 适配分页查询返回的数据结构 {total, page, records, rows}
|
||||||
|
if (result.rows && Array.isArray(result.rows)) {
|
||||||
|
dataList.value = result.rows;
|
||||||
|
} else if (result.resultCode === 1) {
|
||||||
|
// 兼容旧的数据结构
|
||||||
|
dataList.value = result.result || [];
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: result.message || '加载失败',
|
||||||
|
icon: 'error'
|
||||||
|
});
|
||||||
|
dataList.value = [];
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载用户待办/已办数据失败:', error);
|
||||||
|
uni.showToast({
|
||||||
|
title: '加载失败',
|
||||||
|
icon: 'error'
|
||||||
|
});
|
||||||
|
dataList.value = [];
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
uni.hideLoading();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 搜索处理
|
// 搜索处理
|
||||||
const handleSearch = (keyword: string) => {
|
const handleSearch = (keyword: string) => {
|
||||||
searchKeyword.value = keyword;
|
searchKeyword.value = keyword;
|
||||||
// 更新查询参数并重新加载,支持按标题和类型搜索
|
|
||||||
setParam({
|
// 根据当前标签决定搜索方式
|
||||||
title: keyword,
|
if (activeTab.value === "all") {
|
||||||
docType: keyword // 同时按类型搜索
|
// 全部:使用 findPage API 搜索
|
||||||
|
loadAllData();
|
||||||
|
} else {
|
||||||
|
// 待办/已办:只调用 findUserTodos 接口
|
||||||
|
const currentTeacherId = getCurrentTeacherId();
|
||||||
|
if (currentTeacherId) {
|
||||||
|
loadUserTodos(activeTab.value, currentTeacherId);
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: '无法获取用户信息',
|
||||||
|
icon: 'error'
|
||||||
});
|
});
|
||||||
reload();
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 跳转到详情页面
|
// 跳转到详情页面
|
||||||
@ -351,7 +451,6 @@ const parseFileList = (data: any) => {
|
|||||||
// 预览单个附件(从data直接获取)
|
// 预览单个附件(从data直接获取)
|
||||||
const previewAttachment = (data: any) => {
|
const previewAttachment = (data: any) => {
|
||||||
if (!data.fileUrl) {
|
if (!data.fileUrl) {
|
||||||
console.error("没有找到附件URL");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,24 +458,16 @@ const previewAttachment = (data: any) => {
|
|||||||
const fileName = data.fileName || '未知文件';
|
const fileName = data.fileName || '未知文件';
|
||||||
const fileFormat = data.fileFormat || '';
|
const fileFormat = data.fileFormat || '';
|
||||||
|
|
||||||
// 根据文件类型选择预览方式
|
|
||||||
if (isVideo(fileFormat)) {
|
// 统一使用 kkview 预览
|
||||||
previewVideoUtil(fileUrl, fileName)
|
|
||||||
.then(() => console.log('视频预览成功'))
|
|
||||||
.catch((error: any) => console.error('视频预览失败:', error));
|
|
||||||
} else if (isImage(fileFormat)) {
|
|
||||||
previewImageUtil(fileUrl)
|
|
||||||
.then(() => console.log('图片预览成功'))
|
|
||||||
.catch((error: any) => console.error('图片预览失败:', error));
|
|
||||||
} else if (canPreview(fileFormat)) {
|
|
||||||
const fullFileName = fileFormat ? `${fileName}.${fileFormat}` : fileName;
|
const fullFileName = fileFormat ? `${fileName}.${fileFormat}` : fileName;
|
||||||
previewFileUtil(fileUrl, fullFileName, fileFormat)
|
previewFileUtil(fileUrl, fullFileName, fileFormat)
|
||||||
.then(() => console.log('文档预览成功'))
|
.catch((error: any) => {
|
||||||
.catch((error: any) => console.error('文档预览失败:', error));
|
uni.showToast({
|
||||||
} else {
|
title: '预览失败',
|
||||||
// 不支持预览的文件类型,直接下载
|
icon: 'error'
|
||||||
downloadAttachment(data);
|
});
|
||||||
}
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 预览附件文件(从files数组获取)
|
// 预览附件文件(从files数组获取)
|
||||||
@ -386,84 +477,21 @@ const previewAttachmentFile = (file: FileInfo) => {
|
|||||||
const fileSuf = getFileSuffix(file);
|
const fileSuf = getFileSuffix(file);
|
||||||
|
|
||||||
if (!fileUrl) {
|
if (!fileUrl) {
|
||||||
console.error("没有找到文件URL");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据文件类型选择预览方式
|
|
||||||
if (isVideo(fileSuf)) {
|
|
||||||
previewVideoUtil(fileUrl, fileName)
|
|
||||||
.then(() => console.log('视频预览成功'))
|
|
||||||
.catch((error: any) => console.error('视频预览失败:', error));
|
|
||||||
} else if (isImage(fileSuf)) {
|
|
||||||
previewImageUtil(fileUrl)
|
|
||||||
.then(() => console.log('图片预览成功'))
|
|
||||||
.catch((error: any) => console.error('图片预览失败:', error));
|
|
||||||
} else if (canPreview(fileSuf)) {
|
|
||||||
previewFileUtil(fileUrl, fileName, fileSuf)
|
|
||||||
.then(() => console.log('文档预览成功'))
|
|
||||||
.catch((error: any) => console.error('文档预览失败:', error));
|
|
||||||
} else {
|
|
||||||
// 不支持预览的文件类型,直接下载
|
|
||||||
downloadAttachmentFile(file);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 下载单个附件
|
// 统一使用 kkview 预览
|
||||||
const downloadAttachment = (data: any) => {
|
const fullFileName = fileSuf ? `${fileName}.${fileSuf}` : fileName;
|
||||||
if (!data.fileUrl) {
|
previewFileUtil(fileUrl, fullFileName, fileSuf)
|
||||||
console.error("没有找到附件URL");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const fileUrl = imagUrl(data.fileUrl);
|
|
||||||
const fileName = data.fileName || '未知文件';
|
|
||||||
const fileFormat = data.fileFormat || '';
|
|
||||||
const fullFileName = fileFormat ? `${fileName}.${fileFormat}` : fileName;
|
|
||||||
|
|
||||||
downloadFileUtil(fileUrl, fullFileName)
|
|
||||||
.then(() => {
|
|
||||||
console.log('文件下载成功');
|
|
||||||
uni.showToast({
|
|
||||||
title: '下载成功',
|
|
||||||
icon: 'success'
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
console.error('文件下载失败:', error);
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '下载失败',
|
title: '预览失败',
|
||||||
icon: 'error'
|
icon: 'error'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 下载附件文件
|
|
||||||
const downloadAttachmentFile = (file: FileInfo) => {
|
|
||||||
const fileUrl = file.resourUrl ? imagUrl(file.resourUrl) : (file.url ? imagUrl(file.url) : '');
|
|
||||||
const fileName = file.resourName || file.name || '未知文件';
|
|
||||||
|
|
||||||
if (!fileUrl) {
|
|
||||||
console.error("没有找到文件URL");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
downloadFileUtil(fileUrl, fileName)
|
|
||||||
.then(() => {
|
|
||||||
console.log('文件下载成功');
|
|
||||||
uni.showToast({
|
|
||||||
title: '下载成功',
|
|
||||||
icon: 'success'
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
console.error('文件下载失败:', error);
|
|
||||||
uni.showToast({
|
|
||||||
title: '下载失败',
|
|
||||||
icon: 'error'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 获取文件名
|
// 获取文件名
|
||||||
const getFileName = (file: FileInfo) => {
|
const getFileName = (file: FileInfo) => {
|
||||||
@ -508,17 +536,51 @@ watch(dataList, (val) => {
|
|||||||
|
|
||||||
// 页面显示时重新加载数据
|
// 页面显示时重新加载数据
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
reload();
|
if (activeTab.value === "all") {
|
||||||
|
loadAllData();
|
||||||
|
} else {
|
||||||
|
// 对于待办/已办,只调用 findUserTodos 接口
|
||||||
|
const currentTeacherId = getCurrentTeacherId();
|
||||||
|
if (currentTeacherId) {
|
||||||
|
loadUserTodos(activeTab.value, currentTeacherId);
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: '无法获取用户信息',
|
||||||
|
icon: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 页面加载时也加载一次数据
|
// 页面加载时也加载一次数据
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
reload();
|
// 默认加载"待办"数据,只调用 findUserTodos 接口
|
||||||
|
const currentTeacherId = getCurrentTeacherId();
|
||||||
|
if (currentTeacherId) {
|
||||||
|
loadUserTodos('pending', currentTeacherId);
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: '无法获取用户信息',
|
||||||
|
icon: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 监听来自gwFlow页面的刷新事件
|
// 监听来自gwFlow页面的刷新事件
|
||||||
uni.$on('refreshGwList', () => {
|
uni.$on('refreshGwList', () => {
|
||||||
console.log('收到刷新事件,重新加载数据');
|
if (activeTab.value === "all") {
|
||||||
reload();
|
loadAllData();
|
||||||
|
} else {
|
||||||
|
// 对于待办/已办,只调用 findUserTodos 接口
|
||||||
|
const currentTeacherId = getCurrentTeacherId();
|
||||||
|
if (currentTeacherId) {
|
||||||
|
loadUserTodos(activeTab.value, currentTeacherId);
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: '无法获取用户信息',
|
||||||
|
icon: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -560,8 +622,14 @@ onUnmounted(() => {
|
|||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.search-container {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
.search-input {
|
.search-input {
|
||||||
width: 100%;
|
flex: 1;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
background-color: #f8f9fa;
|
background-color: #f8f9fa;
|
||||||
border: 1px solid #e9ecef;
|
border: 1px solid #e9ecef;
|
||||||
@ -571,6 +639,15 @@ onUnmounted(() => {
|
|||||||
color: #333;
|
color: #333;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.search-button {
|
||||||
|
height: 40px !important;
|
||||||
|
width: 15% !important;
|
||||||
|
border-radius: 8px !important;
|
||||||
|
font-size: 14px !important;
|
||||||
|
font-weight: 500 !important;
|
||||||
|
flex-shrink: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
.filter-tabs {
|
.filter-tabs {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
@ -722,7 +799,8 @@ onUnmounted(() => {
|
|||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.3s ease;
|
transition: all 0.3s ease;
|
||||||
max-width: 200px;
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
|
||||||
&:active {
|
&:active {
|
||||||
transform: translateY(1px);
|
transform: translateY(1px);
|
||||||
@ -743,6 +821,7 @@ onUnmounted(() => {
|
|||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -814,6 +893,49 @@ onUnmounted(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 列表内容样式
|
||||||
|
.list-content {
|
||||||
|
flex: 1;
|
||||||
|
padding: 15px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载状态样式
|
||||||
|
.loading-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
padding: 40px 20px;
|
||||||
|
background-color: white;
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-text {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #666;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 空状态样式
|
||||||
|
.empty-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
padding: 60px 20px;
|
||||||
|
background-color: white;
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-text {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #999;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
// 加载动画
|
// 加载动画
|
||||||
.gw-card {
|
.gw-card {
|
||||||
animation: fadeInUp 0.3s ease-out;
|
animation: fadeInUp 0.3s ease-out;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user