一日常规

This commit is contained in:
hebo 2025-09-08 22:33:14 +08:00
parent 43ea733eac
commit 073e462d71
4 changed files with 459 additions and 444 deletions

View File

@ -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 });
}

View File

@ -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",
}, },

View File

@ -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: 1URL // 2: 1URL
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 H5hash // uni-app H5hash
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>

View File

@ -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;