From de573ba4b5885a177cd60ae05de8fdf824dc97b3 Mon Sep 17 00:00:00 2001 From: hebo Date: Fri, 26 Sep 2025 18:10:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E9=BE=99=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/base/server.ts | 7 +- src/api/routine/gw.ts | 4 +- src/pages/components/YwConfirm/index.vue | 10 +- src/pages/view/notice/detail.vue | 788 ++++++++++++++++++++--- src/pages/view/routine/gwlz/index.vue | 433 +++++-------- 5 files changed, 858 insertions(+), 384 deletions(-) diff --git a/src/api/base/server.ts b/src/api/base/server.ts index 21a22d4..ef59792 100644 --- a/src/api/base/server.ts +++ b/src/api/base/server.ts @@ -248,7 +248,12 @@ export const jlSaveApi = async (params: any) => { }; // 根据接龙ID查询接龙执行情况(学生列表) -export const jlzxFindByJlParamsApi = async (params: { jlId: string }) => { +export const jlzxFindByJlParamsApi = async (params: { + jlId: string; + njId?: string; + njmcId?: string; + bjId?: string; +}) => { return await get("/api/jlzx/findByJlParams", params); }; diff --git a/src/api/routine/gw.ts b/src/api/routine/gw.ts index 15e53d2..1ff343e 100644 --- a/src/api/routine/gw.ts +++ b/src/api/routine/gw.ts @@ -149,8 +149,8 @@ export function getGwFlowByIdApi(id: string) { /** * 分页查询某人的待办和已办公文 */ -export function findUserTodosApi(approveStatus: string, jsId: string, pageNum: number = 1, pageSize: number = 20) { - return get('/api/gw/findUserTodos', { approveStatus, jsId, pageNum, pageSize }); +export function findUserTodosApi(dbZt: string, jsId: string, page: number = 1, rows: number = 20) { + return get('/api/gw/findUserTodos', { dbZt, jsId, page, rows }); } // ===== 新增:统一的流程接口 ===== diff --git a/src/pages/components/YwConfirm/index.vue b/src/pages/components/YwConfirm/index.vue index 9c22996..d144427 100644 --- a/src/pages/components/YwConfirm/index.vue +++ b/src/pages/components/YwConfirm/index.vue @@ -25,7 +25,7 @@ - + @@ -86,6 +86,7 @@ const dlgFlag = ref(false); const dlgType = ref(""); const dlgTips = ref(""); const spRemark = ref(""); +const Transferflag = ref(false); const goToMessage = () => { setTimeout(() => { @@ -108,7 +109,11 @@ const closeDlg = () => { }; const showTransfer = () => { - transferRef.value.showDlg(); + Transferflag.value = true; + nextTick(() => { + transferRef.value.showDlg(); + }); + }; const showXtDlg = () => { @@ -160,6 +165,7 @@ const handleTransfer = async (data: any) => { uni.showLoading({ title: "正在转办..." }); await props.transferApi(params); transferRef.value.closeDlg(); + Transferflag.value = false; uni.hideLoading(); emit('transfer'); if (props.autoToMessage) { diff --git a/src/pages/view/notice/detail.vue b/src/pages/view/notice/detail.vue index 2daa545..774fdf1 100644 --- a/src/pages/view/notice/detail.vue +++ b/src/pages/view/notice/detail.vue @@ -1,7 +1,76 @@ diff --git a/src/pages/view/routine/gwlz/index.vue b/src/pages/view/routine/gwlz/index.vue index 3e502a9..5cfc9f1 100644 --- a/src/pages/view/routine/gwlz/index.vue +++ b/src/pages/view/routine/gwlz/index.vue @@ -1,7 +1,7 @@ @@ -118,7 +121,7 @@ import { ref, computed, watch, onMounted, onUnmounted } from "vue"; import { onShow } from "@dcloudio/uni-app"; import { navigateTo } from "@/utils/uniapp"; import BasicSearch from "@/components/BasicSearch/Search.vue"; -import { gwFindPageApi, findUserTodosApi } from "@/api/routine/gw"; +import { findUserTodosApi } from "@/api/routine/gw"; import { gwSqApi, gwSpApi, gwTransferApi, gwStopApi, gwCxtjApi, gwXtApi } from "@/api/routine/gw"; import dayjs from "dayjs"; import { imagUrl } from "@/utils"; @@ -143,7 +146,7 @@ interface GwListItem { id: string; title: string; docType: string; - gwStatus: string; + spJd: string; // 审批进度:A-审批中,Z-审批结束 fileUrl?: string; fileName?: string; fileFormat?: string; @@ -169,174 +172,108 @@ const userStore = useUserStore(); // 数据列表 const dataList = ref([]); -const loading = ref(false); +const pagingRef = ref(null); // 获取当前教师ID const getCurrentTeacherId = () => { const jsData = userStore.getJs; + console.log('用户store数据:', userStore); + console.log('教师数据:', jsData); return jsData?.id || null; }; -// 筛选后的公文列表 -const filteredGwList = computed(() => { - let list = dataList.value; +// z-paging 查询方法 +const queryData = async (pageNo: number, pageSize: number) => { + console.log('queryData 被调用:', { pageNo, pageSize, activeTab: activeTab.value }); - // 对于待办/已办标签,数据已经通过API筛选,不需要再次筛选 - // 只对"全部"标签进行状态筛选 - if (activeTab.value === "all") { - // 这里可以添加额外的筛选逻辑,如果需要的话 + try { + const currentTeacherId = getCurrentTeacherId(); + console.log('当前教师ID:', currentTeacherId); + + if (!currentTeacherId) { + console.log('教师ID为空,停止查询'); + uni.showToast({ + title: '无法获取用户信息', + icon: 'error' + }); + pagingRef.value?.complete([]); + return; + } + + let response: any; + + if (activeTab.value === "all") { + // 全部:不传 dbZt 参数,查询所有 + console.log('调用全部API:', { jsId: currentTeacherId, pageNo, pageSize }); + response = await findUserTodosApi('', currentTeacherId, pageNo, pageSize); + console.log('全部API响应:', response); + } else if (activeTab.value === "pending") { + // 待办:dbZt = 'A' + console.log('调用待办API:', { dbZt: 'A', jsId: currentTeacherId, pageNo, pageSize }); + response = await findUserTodosApi('A', currentTeacherId, pageNo, pageSize); + console.log('待办API响应:', response); + } else if (activeTab.value === "approved") { + // 已办:dbZt = 'B' + console.log('调用已办API:', { dbZt: 'B', jsId: currentTeacherId, pageNo, pageSize }); + response = await findUserTodosApi('B', currentTeacherId, pageNo, pageSize); + console.log('已办API响应:', response); + } + + // 处理单个API响应 + const result = (response as any).data || response; + let newData: GwListItem[] = []; + + if (result.rows && Array.isArray(result.rows)) { + newData = result.rows; + } else if (result.resultCode === 1) { + newData = result.result || []; + } else { + uni.showToast({ + title: result.message || '加载失败', + icon: 'error' + }); + newData = []; + } + + // 按关键词搜索 + if (searchKeyword.value) { + const keyword = searchKeyword.value.toLowerCase(); + newData = newData.filter((item: GwListItem) => + item.title.toLowerCase().includes(keyword) || + (item.gwNo && item.gwNo.toLowerCase().includes(keyword)) || + (item.docType && item.docType.toLowerCase().includes(keyword)) + ); + } + + pagingRef.value?.complete(newData); + + } catch (error) { + console.error('查询数据失败:', error); + uni.showToast({ + title: '查询失败', + icon: 'error' + }); + pagingRef.value?.complete([]); } - - // 按关键词搜索(对所有标签都适用) - if (searchKeyword.value) { - const keyword = searchKeyword.value.toLowerCase(); - list = list.filter((item: GwListItem) => - item.title.toLowerCase().includes(keyword) || - (item.gwNo && item.gwNo.toLowerCase().includes(keyword)) || - (item.docType && item.docType.toLowerCase().includes(keyword)) - ); - } - - return list; -}); +}; // 切换筛选标签 const switchTab = (tabKey: string) => { activeTab.value = tabKey; - - // 获取当前教师ID - const currentTeacherId = getCurrentTeacherId(); - - 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, 50); // 使用合理的分页大小 - - // 检查响应格式 - 根据实际返回的数据结构 - 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(); - } + // 重新加载数据 + pagingRef.value?.reload(); }; // 搜索处理 const handleSearch = (keyword: string) => { searchKeyword.value = keyword; - - // 根据当前标签决定搜索方式 - if (activeTab.value === "all") { - // 全部:使用 findPage API 搜索 - loadAllData(); - } else { - // 待办/已办:只调用 findUserTodos 接口 - const currentTeacherId = getCurrentTeacherId(); - if (currentTeacherId) { - loadUserTodos(activeTab.value, currentTeacherId); - } else { - uni.showToast({ - title: '无法获取用户信息', - icon: 'error' - }); - } - } + // 重新加载数据 + pagingRef.value?.reload(); }; // 跳转到详情页面 const goToDetail = (item: GwListItem) => { - navigateTo(`/pages/view/routine/gwlz/gwFlow?id=${item.id}`); + navigateTo(`/pages/view/routine/gwlz/gwFlow?id=${item.id}&openId=${userStore.getUser.openId}&from=db`); }; // 编辑和删除相关函数已删除 @@ -355,34 +292,30 @@ const createNewGw = () => { }; // 获取状态样式类 -const getStatusClass = (status: string) => { +const getStatusClass = (spJd: string) => { const statusMap: Record = { - 'A': "status-draft", // A暂存 - 'B': "status-submitted", // B提交 - 'C': "status-pending", // C审批中 - 'D': "status-completed", // D已完结 + 'A': "status-pending", // A-审批中 + 'Z': "status-completed", // Z-审批结束 }; - return statusMap[status] || "status-default"; + return statusMap[spJd] || "status-default"; }; // 获取状态文本 -const getStatusText = (status: string) => { +const getStatusText = (spJd: string) => { const statusMap: Record = { - 'A': "暂存", // A暂存 - 'B': "提交", // B提交 - 'C': "审批中", // C审批中 - 'D': "已完结", // D已完结 + 'A': "审批中", // A-审批中 + 'Z': "审批结束", // Z-审批结束 }; - return statusMap[status] || "未知"; + return statusMap[spJd] || "未知"; }; // 获取按钮文本 - 参考教师请假的逻辑 const getButtonText = (item: GwListItem) => { const currentTeacherId = getCurrentTeacherId(); - const { gwStatus, spZbqd, spResult } = item; + const { spJd, spZbqd, spResult } = item; - // 如果是待办状态且当前用户是审批人,显示"审批" - if (currentTeacherId && spZbqd && gwStatus === 'B' && activeTab.value === 'pending') { + // 如果是审批中状态且当前用户是审批人,显示"审批" + if (currentTeacherId && spZbqd && spJd === 'A' && activeTab.value === 'pending') { const approverIds = spZbqd.split(',').map(id => id.trim()); if (approverIds.includes(currentTeacherId)) { return '审批'; @@ -408,7 +341,7 @@ const getButtonText = (item: GwListItem) => { const getButtonClass = (item: GwListItem) => { const buttonText = getButtonText(item); const currentTeacherId = getCurrentTeacherId(); - const { gwStatus, spZbqd, spResult } = item; + const { spJd, spZbqd, spResult } = item; // 审批按钮样式 if (buttonText === '审批') { @@ -590,58 +523,21 @@ const getFileIcon = (fileType: string) => { } }; -// 监听数据变化 -watch(dataList, (val) => { - // 数据变化监听 -}); - // 页面显示时重新加载数据 onShow(() => { - if (activeTab.value === "all") { - loadAllData(); - } else { - // 对于待办/已办,只调用 findUserTodos 接口 - const currentTeacherId = getCurrentTeacherId(); - if (currentTeacherId) { - loadUserTodos(activeTab.value, currentTeacherId); - } else { - uni.showToast({ - title: '无法获取用户信息', - icon: 'error' - }); - } - } + pagingRef.value?.reload(); }); -// 页面加载时也加载一次数据 +// 页面加载时初始化 onMounted(() => { - // 默认加载"待办"数据,只调用 findUserTodos 接口 - const currentTeacherId = getCurrentTeacherId(); - if (currentTeacherId) { - loadUserTodos('pending', currentTeacherId); - } else { - uni.showToast({ - title: '无法获取用户信息', - icon: 'error' - }); - } + console.log('页面加载完成,z-paging ref:', pagingRef.value); + console.log('当前用户store:', userStore); + console.log('当前教师ID:', getCurrentTeacherId()); // 监听来自gwFlow页面的刷新事件 uni.$on('refreshGwList', () => { - if (activeTab.value === "all") { - loadAllData(); - } else { - // 对于待办/已办,只调用 findUserTodos 接口 - const currentTeacherId = getCurrentTeacherId(); - if (currentTeacherId) { - loadUserTodos(activeTab.value, currentTeacherId); - } else { - uni.showToast({ - title: '无法获取用户信息', - icon: 'error' - }); - } - } + console.log('收到刷新事件'); + pagingRef.value?.reload(); }); }); @@ -659,16 +555,31 @@ onUnmounted(() => { background-color: #f5f7fa; } -.list-component { - flex: 1; - overflow: hidden; +// 顶部搜索区域 +.top-section { + position: fixed; + top: 0; + left: 0; + right: 0; + z-index: 100; + background-color: #fff; + border-bottom: 1px solid #eee; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); + padding: 12px; } -.query-component { - padding: 15px; - background-color: white; - border-bottom: 1px solid #eee; - box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04); +// 中间数据区域 +.middle-section { + flex: 1; + margin-top: 140px; // 为顶部区域留出更多空间 + height: calc(100vh - 140px); + background-color: #f5f7fa; +} + +.paging-container { + height: 100%; + padding: 12px; + box-sizing: border-box; } .search-card { @@ -780,14 +691,6 @@ onUnmounted(() => { flex-shrink: 0; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); - &.status-draft { - background: linear-gradient(135deg, #ffa726 0%, #ff9800 100%); - color: white; - } - &.status-submitted { - background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%); - color: white; - } &.status-pending { background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%); color: white; @@ -984,47 +887,9 @@ onUnmounted(() => { } } -// 列表内容样式 -.list-content { - flex: 1; +// z-paging 组件样式 +.paging-container { 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; } // 加载动画