公文流转
This commit is contained in:
parent
7f3c9705cc
commit
8fe418f37e
@ -115,3 +115,32 @@ export function fileDeleteApi(params: any) {
|
|||||||
export function userSearchApi(params: any) {
|
export function userSearchApi(params: any) {
|
||||||
return get('/api/user/search', params);
|
return get('/api/user/search', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取公文详情
|
||||||
|
*/
|
||||||
|
export function getGwDetailApi(params: any) {
|
||||||
|
return get('/api/gw/findById', params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索用户(用于审批人、抄送人选择)
|
||||||
|
*/
|
||||||
|
export function searchUsersApi(params: any) {
|
||||||
|
return get('/api/user/search', params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存变更(审批人、抄送人变更等)
|
||||||
|
*/
|
||||||
|
export function saveChangesApi(params: any) {
|
||||||
|
return post('/api/gw/saveChanges', params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID查询公文流程信息
|
||||||
|
* 通过id查询yfzc_xxts表的xxzb_id,关联yfzc_gw表获取数据
|
||||||
|
*/
|
||||||
|
export function getGwFlowByIdApi(id: string) {
|
||||||
|
return get(`/api/gw/getGwFlowById?id=${id}`);
|
||||||
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<template #default="{ data }">
|
<template #default="{ data }">
|
||||||
<view class="white-bg-color r-md p-15 mb-15 flex-row" @click="goToDetail(data)">
|
<view class="white-bg-color r-md p-15 mb-15 flex-row no-side-margin" @click="goToDetail(data)">
|
||||||
<view class="card-left">
|
<view class="card-left">
|
||||||
<view class="card-title">{{ data.xxbt }}</view>
|
<view class="card-title">{{ data.xxbt }}</view>
|
||||||
<view class="card-desc" v-html="data.xxzy"></view>
|
<view class="card-desc" v-html="data.xxzy"></view>
|
||||||
@ -29,8 +29,10 @@
|
|||||||
<text>{{ getTimeAgo(data.xxtstime) }}</text>
|
<text>{{ getTimeAgo(data.xxtstime) }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="card-right" v-if="dbLxMap[data.xxlx]">
|
<view class="card-right">
|
||||||
<view class="tag" :class="dbLxMap[data.xxlx].className">{{ dbLxMap[data.xxlx].label }}</view>
|
<view class="tag" :class="getTagClass(data.xxlx)">
|
||||||
|
{{ getTagText(data.xxlx) }}
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@ -114,6 +116,30 @@ const goToDetail = (data: any) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 获取标签样式类
|
||||||
|
const getTagClass = (xxlx: string) => {
|
||||||
|
// 根据xxlx字段值返回对应的样式类
|
||||||
|
const tagClassMap: Record<string, string> = {
|
||||||
|
'通知': 'tag-notice',
|
||||||
|
'任务': 'tag-task',
|
||||||
|
'审批': 'tag-approval',
|
||||||
|
'提醒': 'tag-reminder',
|
||||||
|
'公文': 'tag-official-document', // 为公文添加特定样式
|
||||||
|
'default': 'tag-default'
|
||||||
|
};
|
||||||
|
|
||||||
|
return tagClassMap[xxlx] || tagClassMap['default'];
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取标签显示文本
|
||||||
|
const getTagText = (xxlx: string) => {
|
||||||
|
// 移除调试信息
|
||||||
|
// console.log('xxlx字段值:', xxlx, '类型:', typeof xxlx);
|
||||||
|
|
||||||
|
// 如果xxlx有值,直接显示;否则显示默认文本
|
||||||
|
return xxlx || '通知';
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@ -244,56 +270,110 @@ const goToDetail = (data: any) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 移除左右空白的卡片
|
||||||
|
.no-side-margin {
|
||||||
|
margin-left: 0;
|
||||||
|
margin-right: 0;
|
||||||
|
border-radius: 0; // 移除圆角,让卡片完全贴合边缘
|
||||||
|
}
|
||||||
|
|
||||||
.card-right {
|
.card-right {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: center;
|
||||||
flex-shrink: 0; // 防止被压缩
|
flex-shrink: 0; // 防止被压缩
|
||||||
flex: 0 0 75px;
|
flex: 0 0 70px; // 减小右侧区域宽度
|
||||||
|
margin-left: 15px;
|
||||||
|
|
||||||
.tag {
|
.tag {
|
||||||
border-radius: 4px;
|
border-radius: 6px; // 稍微减小圆角
|
||||||
font-size: 13px;
|
font-size: 12px; // 减小字体大小
|
||||||
font-weight: bold;
|
font-weight: 600;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
flex: 1 0 1px;
|
width: 50px; // 减小标签宽度
|
||||||
width: 60px;
|
height: 50px; // 减小标签高度,保持正方形
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 0 10px;
|
padding: 6px 3px; // 减小内边距
|
||||||
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12); // 稍微减小阴影
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
line-height: 1.2; // 确保文字垂直居中
|
||||||
|
|
||||||
&.db-xs-qj {
|
// 通知类型 - 蓝色渐变
|
||||||
background-color: #447ade;
|
&.tag-notice {
|
||||||
|
background: linear-gradient(135deg, #447ade 0%, #5a8de8 100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.db-js-qj {
|
// 任务类型 - 绿色渐变
|
||||||
background-color: #19be6b;
|
&.tag-task {
|
||||||
|
background: linear-gradient(135deg, #19be6b 0%, #23d160 100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.db-task {
|
// 审批类型 - 橙色渐变
|
||||||
background-color: #ff9f0a; // 橙色
|
&.tag-approval {
|
||||||
|
background: linear-gradient(135deg, #ff9f0a 0%, #ffb340 100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.submit {
|
// 提醒类型 - 紫色渐变
|
||||||
background-color: #8e8e93; // 灰色
|
&.tag-reminder {
|
||||||
|
background: linear-gradient(135deg, #9c27b0 0%, #ba68c8 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 公文类型 - 青色渐变
|
||||||
|
&.tag-official-document {
|
||||||
|
background: linear-gradient(135deg, #1abc9c 0%, #1dd2af 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 默认类型 - 深蓝色渐变(替代灰色)
|
||||||
|
&.tag-default {
|
||||||
|
background: linear-gradient(135deg, #34495e 0%, #5d6d7e 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
transform: translateY(-1px); // 减小悬停效果
|
||||||
|
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确保文字在正方形标签中正确显示
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
display: block;
|
||||||
|
height: 0;
|
||||||
|
width: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.stats {
|
// 响应式优化
|
||||||
display: flex;
|
@media (max-width: 375px) {
|
||||||
align-items: center;
|
.card-right {
|
||||||
font-size: 12px;
|
flex: 0 0 60px; // 适配新的标签尺寸
|
||||||
color: #999;
|
margin-left: 10px;
|
||||||
|
|
||||||
.icon {
|
.tag {
|
||||||
margin-left: 8px;
|
width: 45px; // 适配小屏幕
|
||||||
display: flex;
|
height: 45px; // 保持正方形
|
||||||
align-items: center;
|
font-size: 11px; // 减小字体
|
||||||
|
padding: 5px 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 320px) {
|
||||||
|
.card-right {
|
||||||
|
flex: 0 0 55px; // 适配新的标签尺寸
|
||||||
|
margin-left: 8px;
|
||||||
|
|
||||||
|
.tag {
|
||||||
|
width: 40px; // 适配小屏幕
|
||||||
|
height: 40px; // 保持正方形
|
||||||
|
font-size: 10px; // 减小字体
|
||||||
|
padding: 4px 2px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -327,9 +327,17 @@ onLoad((options) => {
|
|||||||
// 预加载教师数据到缓存
|
// 预加载教师数据到缓存
|
||||||
const preloadTeacherData = async () => {
|
const preloadTeacherData = async () => {
|
||||||
try {
|
try {
|
||||||
|
// 显示教师数据预加载遮罩层
|
||||||
|
uni.showLoading({
|
||||||
|
title: '正在加载教师数据...',
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
|
||||||
// 检查缓存是否已存在
|
// 检查缓存是否已存在
|
||||||
const existingCache = uni.getStorageSync('globalTeacherData');
|
const existingCache = uni.getStorageSync('globalTeacherData');
|
||||||
if (existingCache && existingCache.length > 0) {
|
if (existingCache && existingCache.length > 0) {
|
||||||
|
console.log('教师数据缓存已存在,跳过预加载');
|
||||||
|
uni.hideLoading();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,6 +357,8 @@ const preloadTeacherData = async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
uni.setStorageSync('teacherCache', teacherCache);
|
uni.setStorageSync('teacherCache', teacherCache);
|
||||||
|
|
||||||
|
console.log('教师数据预加载完成,共', teacherResult.result.length, '条记录');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查本地存储中的教师数据
|
// 检查本地存储中的教师数据
|
||||||
@ -358,73 +368,100 @@ const preloadTeacherData = async () => {
|
|||||||
// 将本地数据也存储到全局缓存中
|
// 将本地数据也存储到全局缓存中
|
||||||
uni.setStorageSync('globalTeacherData', localData.allJs.result);
|
uni.setStorageSync('globalTeacherData', localData.allJs.result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 隐藏教师数据预加载遮罩层
|
||||||
|
uni.hideLoading();
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
// 隐藏教师数据预加载遮罩层
|
||||||
|
uni.hideLoading();
|
||||||
|
|
||||||
console.error('预加载教师数据失败:', error);
|
console.error('预加载教师数据失败:', error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 页面加载完成
|
// 页面加载完成
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// 预加载教师数据到缓存
|
// 显示页面加载遮罩层
|
||||||
await preloadTeacherData();
|
uni.showLoading({
|
||||||
|
title: '正在加载...',
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
|
||||||
// 尝试多种方式获取路由参数
|
|
||||||
let isEditMode = false;
|
|
||||||
let routeGwId = '';
|
|
||||||
|
|
||||||
// 方式1: 通过 getCurrentPages 获取
|
|
||||||
try {
|
try {
|
||||||
const pages = getCurrentPages();
|
// 预加载教师数据到缓存
|
||||||
const currentPage = pages[pages.length - 1];
|
await preloadTeacherData();
|
||||||
const options = (currentPage as any).options;
|
|
||||||
|
|
||||||
if (options?.mode === 'edit' && options?.id) {
|
// 尝试多种方式获取路由参数
|
||||||
isEditMode = true;
|
let isEditMode = false;
|
||||||
routeGwId = options.id;
|
let routeGwId = '';
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('获取路由参数失败:', error);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 方式2: 通过 onLoad 生命周期获取(如果页面有 onLoad)
|
// 方式1: 通过 getCurrentPages 获取
|
||||||
if (!isEditMode || !routeGwId) {
|
|
||||||
// 这里可以添加 onLoad 的逻辑
|
|
||||||
}
|
|
||||||
|
|
||||||
// 方式3: 通过 uni.getStorageSync 获取(如果之前存储过)
|
|
||||||
if (!isEditMode || !routeGwId) {
|
|
||||||
try {
|
try {
|
||||||
const storedMode = uni.getStorageSync('gwEditMode');
|
const pages = getCurrentPages();
|
||||||
const storedId = uni.getStorageSync('gwEditId');
|
const currentPage = pages[pages.length - 1];
|
||||||
|
const options = (currentPage as any).options;
|
||||||
|
|
||||||
if (storedMode === 'edit' && storedId) {
|
if (options?.mode === 'edit' && options?.id) {
|
||||||
isEditMode = true;
|
isEditMode = true;
|
||||||
routeGwId = storedId;
|
routeGwId = options.id;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取本地存储失败:', error);
|
console.error('获取路由参数失败:', error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 方式2: 通过 onLoad 生命周期获取(如果页面有 onLoad)
|
||||||
|
if (!isEditMode || !routeGwId) {
|
||||||
|
// 这里可以添加 onLoad 的逻辑
|
||||||
|
}
|
||||||
|
|
||||||
|
// 方式3: 通过 uni.getStorageSync 获取(如果之前存储过)
|
||||||
|
if (!isEditMode || !routeGwId) {
|
||||||
|
try {
|
||||||
|
const storedMode = uni.getStorageSync('gwEditMode');
|
||||||
|
const storedId = uni.getStorageSync('gwEditId');
|
||||||
|
|
||||||
|
if (storedMode === 'edit' && storedId) {
|
||||||
|
isEditMode = true;
|
||||||
|
routeGwId = storedId;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取本地存储失败:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置全局公文ID变量
|
||||||
|
gwId.value = routeGwId;
|
||||||
|
|
||||||
|
// 等待下一个tick,确保表单完全初始化
|
||||||
|
await nextTick();
|
||||||
|
|
||||||
|
if (isEditMode && routeGwId) {
|
||||||
|
// 编辑模式:从公文接口获取公文详情数据
|
||||||
|
console.log('编辑模式:从公文接口获取数据');
|
||||||
|
await getGwDetail(routeGwId);
|
||||||
|
} else {
|
||||||
|
// 新建模式:从流程设置接口获取初始化数据
|
||||||
|
console.log('新建模式:从流程设置接口获取初始化数据');
|
||||||
|
await getLcglSetData();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 最后设置当前用户信息和时间(确保缓存数据已准备好)
|
||||||
|
await setCurrentUserInfo();
|
||||||
|
|
||||||
|
// 隐藏页面加载遮罩层
|
||||||
|
uni.hideLoading();
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
// 隐藏页面加载遮罩层
|
||||||
|
uni.hideLoading();
|
||||||
|
console.error('页面加载失败:', error);
|
||||||
|
|
||||||
|
uni.showToast({
|
||||||
|
title: '页面加载失败',
|
||||||
|
icon: 'error'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置全局公文ID变量
|
|
||||||
gwId.value = routeGwId;
|
|
||||||
|
|
||||||
// 等待下一个tick,确保表单完全初始化
|
|
||||||
await nextTick();
|
|
||||||
|
|
||||||
if (isEditMode && routeGwId) {
|
|
||||||
// 编辑模式:获取公文详情并填充表单,同时获取最新的流程设置数据
|
|
||||||
await Promise.all([
|
|
||||||
getGwDetail(routeGwId),
|
|
||||||
getLcglSetData()
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
// 新增模式:获取流程设置数据
|
|
||||||
await getLcglSetData();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 最后设置当前用户信息和时间(确保缓存数据已准备好)
|
|
||||||
await setCurrentUserInfo();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 注意:ensureTeacherDataCached 函数已移除,BasicJsPicker 组件会自动处理教师数据获取
|
// 注意:ensureTeacherDataCached 函数已移除,BasicJsPicker 组件会自动处理教师数据获取
|
||||||
@ -554,21 +591,33 @@ const setCurrentUserInfo = async () => {
|
|||||||
// 获取流程设置数据
|
// 获取流程设置数据
|
||||||
const getLcglSetData = async () => {
|
const getLcglSetData = async () => {
|
||||||
try {
|
try {
|
||||||
|
console.log('从流程设置接口获取初始化数据');
|
||||||
|
|
||||||
|
// 显示数据获取遮罩层
|
||||||
|
uni.showLoading({
|
||||||
|
title: '正在获取流程设置...',
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
ruleId: 'yfzc_gw',
|
ruleId: 'yfzc_gw',
|
||||||
page: 1,
|
page: 1,
|
||||||
pageSize: 1
|
pageSize: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log('流程设置查询参数:', params);
|
||||||
const response = await lcglSetFindPageApi(params);
|
const response = await lcglSetFindPageApi(params);
|
||||||
|
console.log('流程设置接口响应:', response);
|
||||||
|
|
||||||
if (response && response.rows && response.rows.length > 0) {
|
if (response && response.rows && response.rows.length > 0) {
|
||||||
lcglSetData.value = response.rows[0];
|
lcglSetData.value = response.rows[0];
|
||||||
|
console.log('获取到的流程设置数据:', lcglSetData.value);
|
||||||
|
|
||||||
// 保存审批规则到全局变量
|
// 保存审批规则到全局变量
|
||||||
// 只有在 spRule 为空时才设置,避免覆盖公文详情中的规则
|
// 只有在 spRule 为空时才设置,避免覆盖公文详情中的规则
|
||||||
if (lcglSetData.value.spRule && !spRule.value) {
|
if (lcglSetData.value.spRule && !spRule.value) {
|
||||||
spRule.value = lcglSetData.value.spRule;
|
spRule.value = lcglSetData.value.spRule;
|
||||||
|
console.log('从流程设置获取审批规则:', lcglSetData.value.spRule);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 等待一段时间确保组件完全初始化
|
// 等待一段时间确保组件完全初始化
|
||||||
@ -581,6 +630,7 @@ const getLcglSetData = async () => {
|
|||||||
if (spIdArray.length > 0) {
|
if (spIdArray.length > 0) {
|
||||||
try {
|
try {
|
||||||
setValue({ spId: spIdArray });
|
setValue({ spId: spIdArray });
|
||||||
|
console.log('设置审批人默认值:', spIdArray);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('设置审批人默认值失败:', error);
|
console.error('设置审批人默认值失败:', error);
|
||||||
}
|
}
|
||||||
@ -594,13 +644,28 @@ const getLcglSetData = async () => {
|
|||||||
if (ccIdArray.length > 0) {
|
if (ccIdArray.length > 0) {
|
||||||
try {
|
try {
|
||||||
setValue({ ccId: ccIdArray });
|
setValue({ ccId: ccIdArray });
|
||||||
|
console.log('设置抄送人默认值:', ccIdArray);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('设置抄送人默认值失败:', error);
|
console.error('设置抄送人默认值失败:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('流程设置数据初始化完成');
|
||||||
|
|
||||||
|
// 隐藏数据获取遮罩层
|
||||||
|
uni.hideLoading();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.log('未找到流程设置数据');
|
||||||
|
|
||||||
|
// 隐藏数据获取遮罩层
|
||||||
|
uni.hideLoading();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
// 隐藏数据获取遮罩层
|
||||||
|
uni.hideLoading();
|
||||||
|
|
||||||
console.error("获取流程设置失败:", error);
|
console.error("获取流程设置失败:", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -608,10 +673,19 @@ const getLcglSetData = async () => {
|
|||||||
// 获取公文详情
|
// 获取公文详情
|
||||||
const getGwDetail = async (gwId: string) => {
|
const getGwDetail = async (gwId: string) => {
|
||||||
try {
|
try {
|
||||||
|
console.log('从公文接口获取公文详情,ID:', gwId);
|
||||||
|
|
||||||
|
// 显示数据获取遮罩层
|
||||||
|
uni.showLoading({
|
||||||
|
title: '正在获取公文详情...',
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
|
||||||
const response = await gwFindByIdApi({ id: gwId });
|
const response = await gwFindByIdApi({ id: gwId });
|
||||||
|
|
||||||
if (response && response.result) {
|
if (response && response.result) {
|
||||||
const gwDetail = response.result;
|
const gwDetail = response.result;
|
||||||
|
console.log('获取到的公文详情:', gwDetail);
|
||||||
|
|
||||||
// 填充表单
|
// 填充表单
|
||||||
const formData = {
|
const formData = {
|
||||||
@ -641,11 +715,11 @@ const getGwDetail = async (gwId: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 保存审批规则到全局变量(编辑模式)
|
// 保存审批规则到全局变量(编辑模式)
|
||||||
// 优先使用公文详情中的审批规则,如果没有则使用流程设置中的规则
|
// 优先使用公文详情中的审批规则
|
||||||
if (gwDetail.spRule) {
|
if (gwDetail.spRule) {
|
||||||
spRule.value = gwDetail.spRule;
|
spRule.value = gwDetail.spRule;
|
||||||
|
console.log('从公文详情获取审批规则:', gwDetail.spRule);
|
||||||
}
|
}
|
||||||
// 注意:如果公文详情中没有 spRule,会在 getLcglSetData 中设置
|
|
||||||
|
|
||||||
// 编辑模式下,确保提交人信息正确设置
|
// 编辑模式下,确保提交人信息正确设置
|
||||||
if (gwDetail.tjrId) {
|
if (gwDetail.tjrId) {
|
||||||
@ -670,7 +744,15 @@ const getGwDetail = async (gwId: string) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('公文详情数据填充完成');
|
||||||
|
|
||||||
|
// 隐藏数据获取遮罩层
|
||||||
|
uni.hideLoading();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
// 隐藏数据获取遮罩层
|
||||||
|
uni.hideLoading();
|
||||||
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "获取公文详情失败",
|
title: "获取公文详情失败",
|
||||||
icon: "error",
|
icon: "error",
|
||||||
@ -678,6 +760,9 @@ const getGwDetail = async (gwId: string) => {
|
|||||||
navigateTo("/pages/view/routine/gwlz/index");
|
navigateTo("/pages/view/routine/gwlz/index");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
// 隐藏数据获取遮罩层
|
||||||
|
uni.hideLoading();
|
||||||
|
|
||||||
console.error("获取公文详情失败:", error);
|
console.error("获取公文详情失败:", error);
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "获取详情失败",
|
title: "获取详情失败",
|
||||||
@ -720,13 +805,24 @@ const autoFillDefaultValues = async () => {
|
|||||||
// 暂存草稿
|
// 暂存草稿
|
||||||
const saveDraft = async () => {
|
const saveDraft = async () => {
|
||||||
try {
|
try {
|
||||||
|
// 显示遮罩层和加载提示
|
||||||
|
uni.showLoading({
|
||||||
|
title: '正在保存草稿...',
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
|
||||||
const value = await getValue();
|
const value = await getValue();
|
||||||
|
|
||||||
// 暂存时只验证必填字段,不验证审批人
|
// 暂存时只验证必填字段,不验证审批人
|
||||||
if (!validateDraftForm(value)) return;
|
if (!validateDraftForm(value)) {
|
||||||
|
// 验证失败时隐藏加载提示
|
||||||
|
uni.hideLoading();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 验证文件是否上传
|
// 验证文件是否上传
|
||||||
if (!value.fileUrl) {
|
if (!value.fileUrl) {
|
||||||
|
uni.hideLoading();
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "请上传附件",
|
title: "请上传附件",
|
||||||
icon: "error",
|
icon: "error",
|
||||||
@ -756,6 +852,9 @@ const saveDraft = async () => {
|
|||||||
// 调用保存API(新增或更新)
|
// 调用保存API(新增或更新)
|
||||||
await gwSaveApi(processedData);
|
await gwSaveApi(processedData);
|
||||||
|
|
||||||
|
// 隐藏加载提示
|
||||||
|
uni.hideLoading();
|
||||||
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "草稿保存成功",
|
title: "草稿保存成功",
|
||||||
icon: "success",
|
icon: "success",
|
||||||
@ -763,6 +862,9 @@ const saveDraft = async () => {
|
|||||||
|
|
||||||
navigateTo("/pages/view/routine/gwlz/index");
|
navigateTo("/pages/view/routine/gwlz/index");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
// 隐藏加载提示
|
||||||
|
uni.hideLoading();
|
||||||
|
|
||||||
console.error("保存草稿失败:", error);
|
console.error("保存草稿失败:", error);
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "保存失败",
|
title: "保存失败",
|
||||||
@ -774,12 +876,23 @@ const saveDraft = async () => {
|
|||||||
// 提交公文
|
// 提交公文
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
try {
|
try {
|
||||||
|
// 显示遮罩层和加载提示
|
||||||
|
uni.showLoading({
|
||||||
|
title: '正在提交公文...',
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
|
||||||
const value = await getValue();
|
const value = await getValue();
|
||||||
|
|
||||||
if (!validateForm(value)) return;
|
if (!validateForm(value)) {
|
||||||
|
// 验证失败时隐藏加载提示
|
||||||
|
uni.hideLoading();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 验证文件是否上传
|
// 验证文件是否上传
|
||||||
if (!value.fileUrl) {
|
if (!value.fileUrl) {
|
||||||
|
uni.hideLoading();
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "请上传附件",
|
title: "请上传附件",
|
||||||
icon: "error",
|
icon: "error",
|
||||||
@ -788,6 +901,7 @@ const submit = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!value.spId || value.spId.length === 0) {
|
if (!value.spId || value.spId.length === 0) {
|
||||||
|
uni.hideLoading();
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "请至少选择一名审批人",
|
title: "请至少选择一名审批人",
|
||||||
icon: "error",
|
icon: "error",
|
||||||
@ -817,6 +931,9 @@ const submit = async () => {
|
|||||||
// 调用保存API(新增或更新)
|
// 调用保存API(新增或更新)
|
||||||
await gwSaveApi(processedData);
|
await gwSaveApi(processedData);
|
||||||
|
|
||||||
|
// 隐藏加载提示
|
||||||
|
uni.hideLoading();
|
||||||
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "公文提交成功",
|
title: "公文提交成功",
|
||||||
icon: "success",
|
icon: "success",
|
||||||
@ -824,6 +941,9 @@ const submit = async () => {
|
|||||||
|
|
||||||
navigateTo("/pages/view/routine/gwlz/index");
|
navigateTo("/pages/view/routine/gwlz/index");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
// 隐藏加载提示
|
||||||
|
uni.hideLoading();
|
||||||
|
|
||||||
console.error("提交公文失败:", error);
|
console.error("提交公文失败:", error);
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "提交失败",
|
title: "提交失败",
|
||||||
|
|||||||
@ -5,26 +5,20 @@
|
|||||||
<view class="gw-info-section">
|
<view class="gw-info-section">
|
||||||
<view class="section-title">公文信息</view>
|
<view class="section-title">公文信息</view>
|
||||||
<view class="info-item">
|
<view class="info-item">
|
||||||
<text class="label">标题:</text>
|
<text class="label">公文标题:</text>
|
||||||
<text class="value">{{ gwInfo.title }}</text>
|
<text class="value title-bold">{{ gwInfo.title }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="info-item">
|
<view class="info-item">
|
||||||
<text class="label">编号:</text>
|
<text class="label">公文类型:</text>
|
||||||
<text class="value">{{ gwInfo.gwNo }}</text>
|
<text class="value">{{ gwInfo.docType }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="info-item">
|
<view class="info-item">
|
||||||
<text class="label">类型:</text>
|
<text class="label">紧急程度:</text>
|
||||||
<text class="value">{{ gwInfo.gwType }}</text>
|
<text class="value">{{ getUrgencyText(gwInfo.urgencyLevel) }}</text>
|
||||||
</view>
|
|
||||||
<view class="info-item">
|
|
||||||
<text class="label">状态:</text>
|
|
||||||
<text class="value status-tag" :class="getStatusClass(gwInfo.status)">
|
|
||||||
{{ getStatusText(gwInfo.status) }}
|
|
||||||
</text>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="info-item">
|
<view class="info-item">
|
||||||
<text class="label">创建人:</text>
|
<text class="label">创建人:</text>
|
||||||
<text class="value">{{ gwInfo.createdBy }}</text>
|
<text class="value">{{ getCreatorName(gwInfo.tjrId) }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="info-item">
|
<view class="info-item">
|
||||||
<text class="label">创建时间:</text>
|
<text class="label">创建时间:</text>
|
||||||
@ -251,9 +245,75 @@
|
|||||||
import { ref, reactive, onMounted } from "vue";
|
import { ref, reactive, onMounted } from "vue";
|
||||||
import BasicLayout from "@/components/BasicLayout/Layout.vue";
|
import BasicLayout from "@/components/BasicLayout/Layout.vue";
|
||||||
import BasicSearch from "@/components/BasicSearch/Search.vue";
|
import BasicSearch from "@/components/BasicSearch/Search.vue";
|
||||||
import { getGwDetailApi, searchUsersApi, saveChangesApi } from "@/api/routine/gw";
|
import { getGwDetailApi, searchUsersApi, saveChangesApi, getGwFlowByIdApi } from "@/api/routine/gw";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
|
// 类型定义
|
||||||
|
interface GwInfo {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
gwNo: string;
|
||||||
|
gwType: string;
|
||||||
|
status: string;
|
||||||
|
createdBy: string;
|
||||||
|
createdTime: Date;
|
||||||
|
files: FileInfo[];
|
||||||
|
approvers?: Approver[];
|
||||||
|
ccUsers?: CCUser[];
|
||||||
|
operationLogs?: OperationLog[];
|
||||||
|
docType: string; // 新增
|
||||||
|
urgencyLevel: string; // 新增
|
||||||
|
tjrId: string; // 新增
|
||||||
|
}
|
||||||
|
|
||||||
|
interface FileInfo {
|
||||||
|
name: string;
|
||||||
|
size: number;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Approver {
|
||||||
|
id: string;
|
||||||
|
userName: string;
|
||||||
|
deptName: string;
|
||||||
|
order: number;
|
||||||
|
status: string;
|
||||||
|
isRemoved?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CCUser {
|
||||||
|
id: string;
|
||||||
|
userName: string;
|
||||||
|
deptName: string;
|
||||||
|
status: string;
|
||||||
|
isRemoved?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OperationLog {
|
||||||
|
id: string;
|
||||||
|
operatorName: string;
|
||||||
|
operationType: string;
|
||||||
|
operationContent: string;
|
||||||
|
operationTime: Date;
|
||||||
|
beforeChange?: string;
|
||||||
|
afterChange?: string;
|
||||||
|
remark?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface User {
|
||||||
|
id: string;
|
||||||
|
userName: string;
|
||||||
|
deptName: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface LogData {
|
||||||
|
operationType: string;
|
||||||
|
operationContent: string;
|
||||||
|
beforeChange: string;
|
||||||
|
afterChange: string;
|
||||||
|
remark?: string;
|
||||||
|
}
|
||||||
|
|
||||||
// 获取页面参数
|
// 获取页面参数
|
||||||
const gwId = ref("");
|
const gwId = ref("");
|
||||||
|
|
||||||
@ -263,11 +323,11 @@ const showAddCCModal = ref(false);
|
|||||||
const showLogDetailModal = ref(false);
|
const showLogDetailModal = ref(false);
|
||||||
|
|
||||||
// 数据
|
// 数据
|
||||||
const gwInfo = ref<any>({});
|
const gwInfo = ref<GwInfo>({} as GwInfo);
|
||||||
const approvers = ref<any[]>([]);
|
const approvers = ref<Approver[]>([]);
|
||||||
const ccUsers = ref<any[]>([]);
|
const ccUsers = ref<CCUser[]>([]);
|
||||||
const operationLogs = ref<any[]>([]);
|
const operationLogs = ref<OperationLog[]>([]);
|
||||||
const currentLog = ref<any>({});
|
const currentLog = ref<OperationLog>({} as OperationLog);
|
||||||
const selectedPosition = ref("");
|
const selectedPosition = ref("");
|
||||||
|
|
||||||
// 位置选项
|
// 位置选项
|
||||||
@ -280,29 +340,69 @@ const positionOptions = [
|
|||||||
|
|
||||||
// 获取公文信息
|
// 获取公文信息
|
||||||
const getGwInfo = async () => {
|
const getGwInfo = async () => {
|
||||||
|
console.log("=== getGwInfo 开始执行 ===");
|
||||||
|
console.log("当前 gwId.value:", gwId.value);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 调用获取公文详情API
|
console.log("准备调用API接口: getGwFlowByIdApi");
|
||||||
const result = await getGwDetailApi(gwId);
|
console.log("API参数:", { id: gwId.value });
|
||||||
gwInfo.value = result;
|
|
||||||
approvers.value = result.approvers || [];
|
// 调用新的API接口获取公文流程信息
|
||||||
ccUsers.value = result.ccUsers || [];
|
const response = await getGwFlowByIdApi(gwId.value);
|
||||||
operationLogs.value = result.operationLogs || [];
|
console.log("API调用完成,响应结果:", response);
|
||||||
|
|
||||||
|
if (response.resultCode === 1) {
|
||||||
|
console.log("API调用成功,开始处理数据");
|
||||||
|
|
||||||
|
// 设置公文信息
|
||||||
|
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 || [];
|
||||||
|
ccUsers.value = response.result.ccUsers || [];
|
||||||
|
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 {
|
||||||
|
console.log("API调用失败,错误信息:", response.message);
|
||||||
|
throw new Error(response.message || '获取数据失败');
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取公文信息失败:", error);
|
console.error("获取公文信息失败:", error);
|
||||||
// 如果API调用失败,使用模拟数据
|
console.log("API调用失败,无法获取数据");
|
||||||
console.log("使用模拟数据");
|
|
||||||
gwInfo.value = mockGwDetail;
|
// 清空所有数据
|
||||||
approvers.value = mockGwDetail.approvers || [];
|
gwInfo.value = {} as GwInfo;
|
||||||
ccUsers.value = mockGwDetail.ccUsers || [];
|
approvers.value = [];
|
||||||
operationLogs.value = mockGwDetail.operationLogs || [];
|
ccUsers.value = [];
|
||||||
|
operationLogs.value = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("=== getGwInfo 执行完成 ===");
|
||||||
};
|
};
|
||||||
|
|
||||||
// 搜索审批人
|
// 搜索审批人
|
||||||
const searchApprovers = async (keyword: string) => {
|
const searchApprovers = async (keyword: string) => {
|
||||||
try {
|
try {
|
||||||
const result = await searchUsersApi(keyword);
|
const result = await searchUsersApi(keyword);
|
||||||
return result;
|
return result.result || [];
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("搜索审批人失败:", error);
|
console.error("搜索审批人失败:", error);
|
||||||
return [];
|
return [];
|
||||||
@ -310,8 +410,8 @@ const searchApprovers = async (keyword: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 添加审批人
|
// 添加审批人
|
||||||
const addApprover = (user: any) => {
|
const addApprover = (user: User) => {
|
||||||
const newApprover = {
|
const newApprover: Approver = {
|
||||||
...user,
|
...user,
|
||||||
order: getNextOrder(),
|
order: getNextOrder(),
|
||||||
status: "pending",
|
status: "pending",
|
||||||
@ -332,7 +432,7 @@ const addApprover = (user: any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 移除审批人
|
// 移除审批人
|
||||||
const removeApprover = (approver: any) => {
|
const removeApprover = (approver: Approver) => {
|
||||||
approver.isRemoved = true;
|
approver.isRemoved = true;
|
||||||
|
|
||||||
// 记录操作日志
|
// 记录操作日志
|
||||||
@ -351,7 +451,7 @@ const removeApprover = (approver: any) => {
|
|||||||
const searchCCUsers = async (keyword: string) => {
|
const searchCCUsers = async (keyword: string) => {
|
||||||
try {
|
try {
|
||||||
const result = await searchUsersApi(keyword);
|
const result = await searchUsersApi(keyword);
|
||||||
return result;
|
return result.result || [];
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("搜索抄送人失败:", error);
|
console.error("搜索抄送人失败:", error);
|
||||||
return [];
|
return [];
|
||||||
@ -359,8 +459,8 @@ const searchCCUsers = async (keyword: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 添加抄送人
|
// 添加抄送人
|
||||||
const addCCUser = (user: any) => {
|
const addCCUser = (user: User) => {
|
||||||
const newCCUser = {
|
const newCCUser: CCUser = {
|
||||||
...user,
|
...user,
|
||||||
status: "unread",
|
status: "unread",
|
||||||
isRemoved: false,
|
isRemoved: false,
|
||||||
@ -380,7 +480,7 @@ const addCCUser = (user: any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 移除抄送人
|
// 移除抄送人
|
||||||
const removeCCUser = (ccUser: any) => {
|
const removeCCUser = (ccUser: CCUser) => {
|
||||||
ccUser.isRemoved = true;
|
ccUser.isRemoved = true;
|
||||||
|
|
||||||
// 记录操作日志
|
// 记录操作日志
|
||||||
@ -393,12 +493,12 @@ const removeCCUser = (ccUser: any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 位置确认
|
// 位置确认
|
||||||
const onPositionConfirm = (e) => {
|
const onPositionConfirm = (e: any) => {
|
||||||
selectedPosition.value = e.value[0];
|
selectedPosition.value = e.value[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
// 获取下一个顺序号
|
// 获取下一个顺序号
|
||||||
const getNextOrder = () => {
|
const getNextOrder = (): number => {
|
||||||
const activeApprovers = approvers.value.filter(a => !a.isRemoved);
|
const activeApprovers = approvers.value.filter(a => !a.isRemoved);
|
||||||
return activeApprovers.length + 1;
|
return activeApprovers.length + 1;
|
||||||
};
|
};
|
||||||
@ -412,10 +512,9 @@ const reorderApprovers = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 添加操作日志
|
// 添加操作日志
|
||||||
const addOperationLog = (log) => {
|
const addOperationLog = (log: LogData) => {
|
||||||
const newLog = {
|
const newLog: OperationLog = {
|
||||||
id: Date.now(),
|
id: Date.now().toString(),
|
||||||
operatorId: "current_user_id", // 当前用户ID
|
|
||||||
operatorName: "当前用户", // 当前用户名
|
operatorName: "当前用户", // 当前用户名
|
||||||
operationType: log.operationType,
|
operationType: log.operationType,
|
||||||
operationContent: log.operationContent,
|
operationContent: log.operationContent,
|
||||||
@ -429,7 +528,7 @@ const addOperationLog = (log) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 显示操作日志详情
|
// 显示操作日志详情
|
||||||
const showLogDetail = (log) => {
|
const showLogDetail = (log: OperationLog) => {
|
||||||
currentLog.value = log;
|
currentLog.value = log;
|
||||||
showLogDetailModal.value = true;
|
showLogDetailModal.value = true;
|
||||||
};
|
};
|
||||||
@ -448,7 +547,7 @@ const saveChanges = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const changeData = {
|
const changeData = {
|
||||||
gwId: gwId,
|
gwId: gwId.value,
|
||||||
approvers: approvers.value,
|
approvers: approvers.value,
|
||||||
ccUsers: ccUsers.value,
|
ccUsers: ccUsers.value,
|
||||||
operationLogs: operationLogs.value,
|
operationLogs: operationLogs.value,
|
||||||
@ -475,32 +574,32 @@ const saveChanges = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 文件预览
|
// 文件预览
|
||||||
const previewFile = (file) => {
|
const previewFile = (file: FileInfo) => {
|
||||||
// 实现文件预览逻辑
|
// 实现文件预览逻辑
|
||||||
console.log("预览文件:", file);
|
console.log("预览文件:", file);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 文件下载
|
// 文件下载
|
||||||
const downloadFile = (file) => {
|
const downloadFile = (file: FileInfo) => {
|
||||||
// 实现文件下载逻辑
|
// 实现文件下载逻辑
|
||||||
console.log("下载文件:", file);
|
console.log("下载文件:", file);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 格式化时间
|
// 格式化时间
|
||||||
const formatTime = (time) => {
|
const formatTime = (time: any) => {
|
||||||
return dayjs(time).format("YYYY-MM-DD HH:mm:ss");
|
return dayjs(time).format("YYYY-MM-DD HH:mm:ss");
|
||||||
};
|
};
|
||||||
|
|
||||||
// 格式化文件大小
|
// 格式化文件大小
|
||||||
const formatFileSize = (size) => {
|
const formatFileSize = (size: any) => {
|
||||||
if (size < 1024) return size + "B";
|
if (size < 1024) return size + "B";
|
||||||
if (size < 1024 * 1024) return (size / 1024).toFixed(2) + "KB";
|
if (size < 1024 * 1024) return (size / 1024).toFixed(2) + "KB";
|
||||||
return (size / (1024 * 1024)).toFixed(2) + "MB";
|
return (size / (1024 * 1024)).toFixed(2) + "MB";
|
||||||
};
|
};
|
||||||
|
|
||||||
// 获取状态样式类
|
// 获取状态样式类
|
||||||
const getStatusClass = (status) => {
|
const getStatusClass = (status: any) => {
|
||||||
const statusMap = {
|
const statusMap: Record<string, string> = {
|
||||||
draft: "status-draft",
|
draft: "status-draft",
|
||||||
pending: "status-pending",
|
pending: "status-pending",
|
||||||
approved: "status-approved",
|
approved: "status-approved",
|
||||||
@ -510,8 +609,8 @@ const getStatusClass = (status) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 获取状态文本
|
// 获取状态文本
|
||||||
const getStatusText = (status) => {
|
const getStatusText = (status: any) => {
|
||||||
const statusMap = {
|
const statusMap: Record<string, string> = {
|
||||||
draft: "草稿",
|
draft: "草稿",
|
||||||
pending: "待审批",
|
pending: "待审批",
|
||||||
approved: "已通过",
|
approved: "已通过",
|
||||||
@ -521,8 +620,8 @@ const getStatusText = (status) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 获取审批人状态样式类
|
// 获取审批人状态样式类
|
||||||
const getApproverStatusClass = (status) => {
|
const getApproverStatusClass = (status: any) => {
|
||||||
const statusMap = {
|
const statusMap: Record<string, string> = {
|
||||||
pending: "status-pending",
|
pending: "status-pending",
|
||||||
approved: "status-approved",
|
approved: "status-approved",
|
||||||
rejected: "status-rejected",
|
rejected: "status-rejected",
|
||||||
@ -532,8 +631,8 @@ const getApproverStatusClass = (status) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 获取审批人状态文本
|
// 获取审批人状态文本
|
||||||
const getApproverStatusText = (status) => {
|
const getApproverStatusText = (status: any) => {
|
||||||
const statusMap = {
|
const statusMap: Record<string, string> = {
|
||||||
pending: "待审批",
|
pending: "待审批",
|
||||||
approved: "已同意",
|
approved: "已同意",
|
||||||
rejected: "已驳回",
|
rejected: "已驳回",
|
||||||
@ -543,8 +642,8 @@ const getApproverStatusText = (status) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 获取抄送人状态样式类
|
// 获取抄送人状态样式类
|
||||||
const getCCStatusClass = (status) => {
|
const getCCStatusClass = (status: any) => {
|
||||||
const statusMap = {
|
const statusMap: Record<string, string> = {
|
||||||
unread: "status-unread",
|
unread: "status-unread",
|
||||||
read: "status-read",
|
read: "status-read",
|
||||||
};
|
};
|
||||||
@ -552,55 +651,182 @@ const getCCStatusClass = (status) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 获取抄送人状态文本
|
// 获取抄送人状态文本
|
||||||
const getCCStatusText = (status) => {
|
const getCCStatusText = (status: any) => {
|
||||||
const statusMap = {
|
const statusMap: Record<string, string> = {
|
||||||
unread: "未读",
|
unread: "未读",
|
||||||
read: "已读",
|
read: "已读",
|
||||||
};
|
};
|
||||||
return statusMap[status] || "未知";
|
return statusMap[status] || "未知";
|
||||||
};
|
};
|
||||||
|
|
||||||
// 模拟数据用于开发测试(当API未实现时使用)
|
// 获取紧急程度样式类
|
||||||
const mockGwDetail = {
|
const getUrgencyClass = (level: string) => {
|
||||||
id: "1",
|
const levelMap: Record<string, string> = {
|
||||||
title: "关于2024年教学工作计划的通知",
|
normal: "urgency-normal",
|
||||||
gwNo: "GW2024001",
|
high: "urgency-high",
|
||||||
gwType: "通知",
|
urgent: "urgency-urgent",
|
||||||
status: "pending",
|
"普通": "urgency-normal", // 添加中文值映射
|
||||||
createdBy: "张三",
|
"高": "urgency-high", // 添加中文值映射
|
||||||
createdTime: new Date(),
|
"紧急": "urgency-urgent", // 添加中文值映射
|
||||||
files: [
|
};
|
||||||
{ name: "教学工作计划.pdf", size: 1024000, url: "file1.pdf" },
|
return levelMap[level] || "urgency-default";
|
||||||
{ name: "附件清单.xlsx", size: 512000, url: "file2.xlsx" },
|
};
|
||||||
],
|
|
||||||
approvers: [
|
// 获取紧急程度文本
|
||||||
{ id: "1", userName: "李四", deptName: "教务处", order: 1, status: "approved" },
|
const getUrgencyText = (level: string) => {
|
||||||
{ id: "2", userName: "王五", deptName: "学生处", order: 2, status: "pending" },
|
const levelMap: Record<string, string> = {
|
||||||
],
|
normal: "普通",
|
||||||
ccUsers: [
|
high: "高",
|
||||||
{ id: "3", userName: "赵六", deptName: "人事处", status: "read" },
|
urgent: "紧急",
|
||||||
],
|
"普通": "普通", // 添加中文值映射
|
||||||
operationLogs: [
|
"高": "高", // 添加中文值映射
|
||||||
{
|
"紧急": "紧急", // 添加中文值映射
|
||||||
id: "1",
|
};
|
||||||
operatorName: "张三",
|
return levelMap[level] || "未知";
|
||||||
operationType: "创建公文",
|
};
|
||||||
operationContent: "创建公文:关于2024年教学工作计划的通知",
|
|
||||||
operationTime: new Date(),
|
// 获取创建人名称
|
||||||
},
|
const getCreatorName = (tjrId: string) => {
|
||||||
],
|
if (!tjrId) return "未知";
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 尝试从多种缓存中获取用户信息,参考gwAdd.vue的实现
|
||||||
|
const teacherCache = uni.getStorageSync('teacherCache');
|
||||||
|
const globalTeacherData = uni.getStorageSync('globalTeacherData');
|
||||||
|
const localData = uni.getStorageSync('data');
|
||||||
|
|
||||||
|
// 方式1: 从teacherCache获取
|
||||||
|
if (teacherCache && teacherCache[tjrId]) {
|
||||||
|
return teacherCache[tjrId].jsxm || tjrId;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 方式2: 从globalTeacherData获取
|
||||||
|
if (globalTeacherData && globalTeacherData.length > 0) {
|
||||||
|
const teacher = globalTeacherData.find((t: any) => t.id === tjrId);
|
||||||
|
if (teacher && teacher.jsxm) {
|
||||||
|
return teacher.jsxm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 方式3: 从data缓存中的allJs获取(参考gwAdd.vue)
|
||||||
|
if (localData && localData.allJs && localData.allJs.result) {
|
||||||
|
const allTeachers = localData.allJs.result;
|
||||||
|
const teacher = allTeachers.find((t: any) => t.id === tjrId);
|
||||||
|
if (teacher && teacher.jsxm) {
|
||||||
|
return teacher.jsxm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果缓存中没有找到,返回ID
|
||||||
|
return `用户${tjrId}`;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("获取创建人信息失败:", error);
|
||||||
|
return `用户${tjrId}`;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// 获取页面参数
|
console.log("=== onMounted 开始执行 ===");
|
||||||
|
|
||||||
|
// 尝试多种方式获取页面参数
|
||||||
|
let pageId = "";
|
||||||
|
|
||||||
|
// 方式1: 通过 getCurrentPages() 获取
|
||||||
const pages = getCurrentPages();
|
const pages = getCurrentPages();
|
||||||
const currentPage = pages[pages.length - 1];
|
console.log("getCurrentPages() 结果:", pages);
|
||||||
const options = currentPage.options || currentPage.$page?.options || {};
|
|
||||||
gwId.value = options.id || "";
|
if (pages.length > 0) {
|
||||||
|
const currentPage = pages[pages.length - 1];
|
||||||
|
console.log("当前页面对象:", currentPage);
|
||||||
|
|
||||||
|
// 尝试不同的属性获取参数
|
||||||
|
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 || "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 方式2: 如果方式1没有获取到,尝试从URL解析
|
||||||
|
if (!pageId) {
|
||||||
|
console.log("尝试从URL解析参数");
|
||||||
|
try {
|
||||||
|
// 获取当前页面URL
|
||||||
|
const currentUrl = window.location.href;
|
||||||
|
console.log("当前页面URL:", currentUrl);
|
||||||
|
|
||||||
|
// 在uni-app H5环境中,参数通常在hash部分
|
||||||
|
const hash = window.location.hash;
|
||||||
|
console.log("页面hash:", hash);
|
||||||
|
|
||||||
|
if (hash && hash.includes('?')) {
|
||||||
|
// 从hash中提取查询参数
|
||||||
|
const queryString = hash.split('?')[1];
|
||||||
|
console.log("查询参数字符串:", queryString);
|
||||||
|
|
||||||
|
// 解析查询参数
|
||||||
|
const urlParams = new URLSearchParams(queryString);
|
||||||
|
pageId = urlParams.get('id') || "";
|
||||||
|
console.log("从hash解析到的id:", pageId);
|
||||||
|
} else {
|
||||||
|
// 尝试从search部分解析(备用方案)
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
pageId = urlParams.get('id') || "";
|
||||||
|
console.log("从search解析到的id:", pageId);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("URL解析失败:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 方式3: 如果前两种方式都没有获取到,尝试从路由参数获取
|
||||||
|
if (!pageId) {
|
||||||
|
console.log("尝试从路由参数获取");
|
||||||
|
try {
|
||||||
|
// 获取当前页面的完整路径
|
||||||
|
const currentPath = window.location.pathname;
|
||||||
|
console.log("当前页面路径:", currentPath);
|
||||||
|
|
||||||
|
// 从路径中提取参数(如果路径包含参数)
|
||||||
|
const pathMatch = currentPath.match(/\/gwFlow\/([^/?]+)/);
|
||||||
|
if (pathMatch) {
|
||||||
|
pageId = pathMatch[1];
|
||||||
|
console.log("从路径提取的id:", pageId);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("路径解析失败:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置gwId
|
||||||
|
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>
|
||||||
|
|
||||||
@ -628,17 +854,23 @@ onMounted(() => {
|
|||||||
|
|
||||||
.info-item {
|
.info-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 15px;
|
||||||
|
|
||||||
.label {
|
.label {
|
||||||
width: 80px;
|
width: 80px;
|
||||||
color: #666;
|
color: #666;
|
||||||
font-weight: 500;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.value {
|
.value {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
color: #333;
|
color: #333;
|
||||||
|
font-size: 14px;
|
||||||
|
|
||||||
|
&.title-bold {
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -653,6 +885,16 @@ onMounted(() => {
|
|||||||
&.status-rejected { background: #fff2f0; color: #ff4d4f; }
|
&.status-rejected { background: #fff2f0; color: #ff4d4f; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.urgency-tag {
|
||||||
|
padding: 2px 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
|
||||||
|
&.urgency-normal { background: #f0f0f0; color: #666; }
|
||||||
|
&.urgency-high { background: #fff7e6; color: #fa8c16; }
|
||||||
|
&.urgency-urgent { background: #fff2f0; color: #ff4d4f; }
|
||||||
|
}
|
||||||
|
|
||||||
.file-item {
|
.file-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@ -193,12 +193,16 @@ const goToDetail = (item: GwListItem) => {
|
|||||||
|
|
||||||
// 编辑公文
|
// 编辑公文
|
||||||
const editGw = (item: GwListItem) => {
|
const editGw = (item: GwListItem) => {
|
||||||
|
console.log('编辑公文,ID:', item.id, '标题:', item.title);
|
||||||
const url = `/pages/view/routine/gwlz/gwAdd?id=${item.id}&mode=edit`;
|
const url = `/pages/view/routine/gwlz/gwAdd?id=${item.id}&mode=edit`;
|
||||||
|
|
||||||
// 先存储编辑参数到本地存储,确保页面跳转后能获取到
|
// 先存储编辑参数到本地存储,确保页面跳转后能获取到
|
||||||
uni.setStorageSync('gwEditMode', 'edit');
|
uni.setStorageSync('gwEditMode', 'edit');
|
||||||
uni.setStorageSync('gwEditId', item.id);
|
uni.setStorageSync('gwEditId', item.id);
|
||||||
|
|
||||||
|
console.log('存储编辑参数到本地存储:', { mode: 'edit', id: item.id });
|
||||||
|
console.log('跳转到编辑页面:', url);
|
||||||
|
|
||||||
navigateTo(url);
|
navigateTo(url);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -235,6 +239,14 @@ const deleteGw = (item: GwListItem) => {
|
|||||||
|
|
||||||
// 新建公文
|
// 新建公文
|
||||||
const createNewGw = () => {
|
const createNewGw = () => {
|
||||||
|
console.log('新建公文');
|
||||||
|
|
||||||
|
// 清除之前的编辑参数
|
||||||
|
uni.removeStorageSync('gwEditMode');
|
||||||
|
uni.removeStorageSync('gwEditId');
|
||||||
|
|
||||||
|
console.log('清除编辑参数,准备新建模式');
|
||||||
|
|
||||||
navigateTo("/pages/view/routine/gwlz/gwAdd");
|
navigateTo("/pages/view/routine/gwlz/gwAdd");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user