diff --git a/src/api/routine/gw.ts b/src/api/routine/gw.ts
index b681484..fb843f3 100644
--- a/src/api/routine/gw.ts
+++ b/src/api/routine/gw.ts
@@ -3,166 +3,115 @@ import { get, post } from "@/utils/request";
// 公文相关API接口
/**
- * 获取公文列表
- * @param params 查询参数
+ * 分页查询公文列表
*/
-export function getGwListApi(params: {
- page: number;
- pageSize: number;
- status?: string;
- keyword?: string;
- gwType?: string;
- urgencyLevel?: string;
- startTime?: string;
- endTime?: string;
-}) {
- return get('/api/gw/list', params);
+export function gwFindPageApi(params: any) {
+ return get('/api/gw/findPage', params);
}
/**
- * 获取公文详情
- * @param id 公文ID
+ * 根据ID查询公文详情
*/
-export function getGwDetailApi(id: string) {
- return get(`/api/gw/detail/${id}`);
+export function gwFindByIdApi(params: any) {
+ return get('/api/gw/findById', params);
}
/**
- * 创建公文
- * @param data 公文数据
+ * 新增/修改公文
*/
-export function createGwApi(data: {
- title: string;
- gwType: string;
- urgencyLevel: string;
- remark?: string;
- files: any[];
- approvers: any[];
- ccUsers: any[];
-}) {
- return post('/api/gw/create', data);
+export function gwSaveApi(params: any) {
+ return post('/api/gw/save', params);
}
/**
- * 更新公文
- * @param id 公文ID
- * @param data 更新数据
+ * 软删除公文
*/
-export function updateGwApi(id: string, data: any) {
- return post(`/api/gw/update/${id}`, data);
-}
-
-/**
- * 删除公文
- * @param id 公文ID
- */
-export function deleteGwApi(id: string) {
- return post(`/api/gw/delete/${id}`, { id });
+export function gwLogicDeleteApi(params: any) {
+ // 将参数拼接到URL中,确保后端能正确接收
+ const queryString = Object.keys(params)
+ .map(key => `${key}=${encodeURIComponent(params[key])}`)
+ .join('&');
+
+ // 尝试POST请求,如果不行可以改为GET请求
+ return post(`/api/gw/logicDelete?${queryString}`, params);
+
+ // 如果POST请求有问题,可以尝试GET请求:
+ // return get(`/api/gw/logicDelete?${queryString}`);
}
/**
* 保存草稿
- * @param data 草稿数据
*/
-export function saveDraftApi(data: any) {
- return post('/api/gw/draft', data);
+export function gwDraftApi(params: any) {
+ return post('/api/gw/draft', params);
}
/**
* 提交公文
- * @param data 提交数据
*/
-export function submitGwApi(data: any) {
- return post('/api/gw/submit', data);
+export function gwSubmitApi(params: any) {
+ return post('/api/gw/submit', params);
}
/**
- * 保存变更
- * @param data 变更数据
+ * 审批公文
*/
-export function saveChangesApi(data: {
- gwId: string;
- approvers: any[];
- ccUsers: any[];
- operationLogs: any[];
-}) {
- return post('/api/gw/changes', data);
+export function gwApproveApi(params: any) {
+ return post('/api/gw/approve', params);
}
/**
- * 搜索用户
- * @param keyword 搜索关键词
+ * 抄送确认
*/
-export function searchUsersApi(keyword: string) {
- return get('/api/user/search', { keyword });
+export function gwCcConfirmApi(params: any) {
+ return post('/api/gw/cc-confirm', params);
}
/**
* 获取审批人列表
- * @param gwId 公文ID
*/
-export function getApproversApi(gwId: string) {
- return get(`/api/gw/approvers/${gwId}`);
+export function gwApproversApi(params: any) {
+ return get('/api/gw/approvers', params);
}
/**
* 获取抄送人列表
- * @param gwId 公文ID
*/
-export function getCCUsersApi(gwId: string) {
- return get(`/api/gw/cc-users/${gwId}`);
+export function gwCcUsersApi(params: any) {
+ return get('/api/gw/cc-users', params);
}
/**
* 获取操作记录
- * @param gwId 公文ID
*/
-export function getOperationLogsApi(gwId: string) {
- return get(`/api/gw/logs/${gwId}`);
-}
-
-/**
- * 文件上传
- * @param file 文件对象
- */
-export function uploadFileApi(file: File) {
- const formData = new FormData();
- formData.append("file", file);
-
- return post('/api/file/upload', formData);
-}
-
-/**
- * 文件删除
- * @param fileId 文件ID
- */
-export function deleteFileApi(fileId: string) {
- return post(`/api/file/delete/${fileId}`, { fileId });
+export function gwLogsApi(params: any) {
+ return get('/api/gw/logs', params);
}
/**
* 获取公文统计信息
*/
-export function getGwStatsApi() {
- return get('/api/gw/stats');
+export function gwStatsApi(params: any) {
+ return get('/api/gw/stats', params);
}
/**
- * 审批公文
- * @param data 审批数据
+ * 文件上传
*/
-export function approveGwApi(data: {
- gwId: string;
- action: "approve" | "reject";
- remark?: string;
-}) {
- return post('/api/gw/approve', data);
+export function fileUploadApi(params: any) {
+ return post('/api/file/upload', params);
}
/**
- * 抄送确认
- * @param gwId 公文ID
+ * 文件删除
*/
-export function confirmCCApi(gwId: string) {
- return post(`/api/gw/cc-confirm/${gwId}`);
+export function fileDeleteApi(params: any) {
+ return post('/api/file/delete', params);
+}
+
+/**
+ * 搜索用户
+ */
+export function userSearchApi(params: any) {
+ return get('/api/user/search', params);
}
diff --git a/src/api/routine/lcglSetApi.ts b/src/api/routine/lcglSetApi.ts
new file mode 100644
index 0000000..8d9357d
--- /dev/null
+++ b/src/api/routine/lcglSetApi.ts
@@ -0,0 +1,112 @@
+import { get, post } from "@/utils/request";
+
+// 流程管理设置相关API接口
+
+/**
+ * 分页查询流程设置
+ * @param params 查询参数
+ */
+export function lcglSetFindPageApi(params: {
+ page: number;
+ pageSize: number;
+ ruleId?: string;
+ ruleName?: string;
+ status?: string;
+ startTime?: string;
+ endTime?: string;
+}) {
+ return get('/api/lcglSet/findPage', params);
+}
+
+/**
+ * 新增/修改流程设置
+ * @param params 流程设置数据
+ */
+export function lcglSetSaveApi(params: {
+ id?: string;
+ ruleId: string;
+ ruleName: string;
+ spId?: string;
+ ccId?: string;
+ status?: string;
+ remark?: string;
+}) {
+ return post('/api/lcglSet/save', params);
+}
+
+/**
+ * 逻辑删除流程设置
+ * @param params 删除参数
+ */
+export function lcglSetLogicDeleteApi(params: { id: string }) {
+ return post('/api/lcglSet/logicDelete', params);
+}
+
+/**
+ * 根据ID查询流程设置详情
+ * @param params 查询参数
+ */
+export function lcglSetFindByIdApi(params: { id: string }) {
+ return get('/api/lcglSet/findById', params);
+}
+
+/**
+ * 查询所有流程设置
+ */
+export function lcglSetFindAllApi() {
+ return get('/api/lcglSet/findAll');
+}
+
+/**
+ * 根据规则ID查询流程设置
+ * @param params 查询参数
+ */
+export function lcglSetFindByRuleIdApi(params: { ruleId: string }) {
+ return get('/api/lcglSet/findByRuleId', params);
+}
+
+/**
+ * 更新流程设置状态
+ * @param params 更新参数
+ */
+export function lcglSetUpdateStatusApi(params: {
+ id: string;
+ status: string;
+}) {
+ return post('/api/lcglSet/updateStatus', params);
+}
+
+/**
+ * 复制流程设置
+ * @param params 复制参数
+ */
+export function lcglSetCopyApi(params: {
+ id: string;
+ newRuleId: string;
+ newRuleName: string;
+}) {
+ return post('/api/lcglSet/copy', params);
+}
+
+/**
+ * 导出流程设置
+ * @param params 导出参数
+ */
+export function lcglSetExportApi(params: {
+ ids?: string[];
+ ruleId?: string;
+ status?: string;
+}) {
+ return post('/api/lcglSet/export', params);
+}
+
+/**
+ * 导入流程设置
+ * @param params 导入参数
+ */
+export function lcglSetImportApi(params: {
+ file: File;
+ overwrite?: boolean;
+}) {
+ return post('/api/lcglSet/import', params);
+}
diff --git a/src/components/BasicForm/components/BasicJsPicker.vue b/src/components/BasicForm/components/BasicJsPicker.vue
new file mode 100644
index 0000000..dfc18ac
--- /dev/null
+++ b/src/components/BasicForm/components/BasicJsPicker.vue
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/components/BasicForm/src/BasicComponent.vue b/src/components/BasicForm/src/BasicComponent.vue
index 30dfa2c..f03ff95 100644
--- a/src/components/BasicForm/src/BasicComponent.vue
+++ b/src/components/BasicForm/src/BasicComponent.vue
@@ -8,6 +8,7 @@
+
diff --git a/src/components/BasicForm/type/useForm.d.ts b/src/components/BasicForm/type/useForm.d.ts
index 851f2af..c8f49df 100644
--- a/src/components/BasicForm/type/useForm.d.ts
+++ b/src/components/BasicForm/type/useForm.d.ts
@@ -17,6 +17,7 @@ type Component =
| 'BasicDateTime'
| 'BasicInput'
| 'BasicPicker'
+ | 'BasicJsPicker'
| 'BasicRate'
| 'BasicSwitch'
| 'BasicUpload'
diff --git a/src/components/BasicJsPicker/Picker.vue b/src/components/BasicJsPicker/Picker.vue
new file mode 100644
index 0000000..829af95
--- /dev/null
+++ b/src/components/BasicJsPicker/Picker.vue
@@ -0,0 +1,387 @@
+
+
+
+
+ {{ getShowSelectedName() }}
+ {{ placeholder }}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/BasicUpload/Upload.vue b/src/components/BasicUpload/Upload.vue
index 64a2cfc..9286e0e 100644
--- a/src/components/BasicUpload/Upload.vue
+++ b/src/components/BasicUpload/Upload.vue
@@ -35,7 +35,14 @@ function deletePic(event: any) {
}
}
-const props = defineProps(['modelValue'])
+// 添加 beforeUpload prop
+const props = defineProps({
+ modelValue: String,
+ beforeUpload: {
+ type: Function,
+ default: null
+ }
+})
watchEffect(() => {
if (props.modelValue) {
@@ -67,6 +74,12 @@ async function afterRead(event: any) {
})
for (let i = 0; i < lists.length; i++) {
+ if (props.beforeUpload && !props.beforeUpload(lists[i])) {
+ // 如果 beforeUpload 返回 false,移除该文件并跳过上传
+ data.fileList.splice(fileListLen + i, 1)
+ continue
+ }
+
showLoading({title: '上传中'})
const res:any = await attachmentUpload(lists[i].url)
const result = res.result
diff --git a/src/pages.json b/src/pages.json
index 1ffcf0f..ab8b9ff 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -179,14 +179,7 @@
}
},
{
- "path": "pages/view/routine/GongWenLiuZhuan/index",
- "style": {
- "navigationBarTitleText": "公文流转",
- "enablePullDownRefresh": false
- }
- },
- {
- "path": "pages/view/routine/GongWenLiuZhuan/detail",
+ "path": "pages/view/routine/gwlz/gwDetail",
"style": {
"navigationBarTitleText": "公文详情",
"enablePullDownRefresh": false
@@ -195,21 +188,21 @@
{
"path": "pages/view/routine/gwlz/gwAdd",
"style": {
- "navigationBarTitleText": "公文列表",
+ "navigationBarTitleText": "公文调整",
"enablePullDownRefresh": false
}
},
{
"path": "pages/view/routine/gwlz/index",
"style": {
- "navigationBarTitleText": "公文接收",
+ "navigationBarTitleText": "公文列表",
"enablePullDownRefresh": false
}
},
{
"path": "pages/view/routine/gwlz/gwFlow",
"style": {
- "navigationBarTitleText": "公文流转",
+ "navigationBarTitleText": "公文审批",
"enablePullDownRefresh": false
}
},
diff --git a/src/pages/base/service/index.vue b/src/pages/base/service/index.vue
index daa9d0f..adc0255 100644
--- a/src/pages/base/service/index.vue
+++ b/src/pages/base/service/index.vue
@@ -344,6 +344,7 @@ const sections = reactive([
permissionKey: "routine-gwlz", // 公文流转权限编码
path: "/pages/view/routine/gwlz/index",
},
+
{
id: "hr3",
icon: "gz",
diff --git a/src/pages/view/routine/gwlz/gwAdd.vue b/src/pages/view/routine/gwlz/gwAdd.vue
index 25d215c..e66d646 100644
--- a/src/pages/view/routine/gwlz/gwAdd.vue
+++ b/src/pages/view/routine/gwlz/gwAdd.vue
@@ -18,103 +18,123 @@ import { useForm } from "@/components/BasicForm/hooks/useForm";
import { findDicTreeByPidApi } from "@/api/system/dic";
import { useDicStore } from "@/store/modules/dic";
import { useUserStore } from "@/store/modules/user";
-import { ref, reactive } from "vue";
+import { gwSaveApi, gwFindByIdApi } from "@/api/routine/gw";
+import { lcglSetFindPageApi } from "@/api/routine/lcglSetApi";
+import { ref, reactive, onMounted, nextTick, watch } from "vue";
+import { onLoad } from "@dcloudio/uni-app";
+import { useCommonStore } from "@/store/modules/common";
const { findByPid } = useDicStore();
const { getJs } = useUserStore();
-// 审批人和抄送人列表
-const approvers = ref([]);
-const ccUsers = ref([]);
-
// 文件列表
-const fileList = ref([]);
+const fileList = ref([]);
-// 文件上传处理
-const handleFileUpload = (file) => {
- fileList.value.push({
- name: file.name,
- size: file.size,
- url: file.url,
- type: file.type,
- });
-};
+// 添加全局变量存储文件名和格式
+const fileName = ref('');
+const fileFormat = ref('');
-// 文件删除处理
-const handleFileDelete = (index) => {
- fileList.value.splice(index, 1);
-};
+// 添加提交人ID全局变量
+const tjrId = ref('');
-// 搜索审批人
-const searchApprovers = async (keyword) => {
+// 添加公文ID全局变量,用于区分新增和编辑
+const gwId = ref('');
+
+// 流程设置数据
+const lcglSetData = ref(null);
+
+// 添加全局变量存储审批规则
+const spRule = ref('');
+
+// 添加标记,防止重复设置默认值
+const hasSetDefaultValues = ref(false);
+
+
+
+// 辅助函数:通过缓存查询教师姓名
+const getTeacherNameFromCache = (teacherId: string): string => {
try {
- // 这里调用搜索API
- const result = await searchUsers(keyword);
- return result;
+ // 尝试从本地存储获取教师信息
+ const teacherCache = uni.getStorageSync('teacherCache');
+ if (teacherCache && teacherCache[teacherId]) {
+ return teacherCache[teacherId].jsxm || teacherId;
+ }
+
+ // 如果没有缓存,尝试从全局教师数据获取
+ const globalTeacherData = uni.getStorageSync('globalTeacherData');
+ if (globalTeacherData && globalTeacherData.length > 0) {
+ const teacher = globalTeacherData.find((t: any) => t.id === teacherId);
+ if (teacher && teacher.jsxm) {
+ return teacher.jsxm;
+ }
+ }
+
+ // 尝试从 data 缓存中获取
+ const teacherData = uni.getStorageSync('data');
+ if (teacherData && teacherData.allJs && teacherData.allJs.result) {
+ const allTeachers = teacherData.allJs.result;
+ const teacher = allTeachers.find((t: any) => t.id === teacherId);
+ if (teacher && teacher.jsxm) {
+ return teacher.jsxm;
+ }
+ }
+
+ return teacherId; // 如果都找不到,返回ID本身
} catch (error) {
- console.error("搜索审批人失败:", error);
- return [];
+ console.error('从缓存获取教师姓名失败:', error);
+ return teacherId;
}
};
-// 添加审批人
-const addApprover = (user) => {
- const order = approvers.value.length + 1;
- approvers.value.push({
- ...user,
- order,
- status: "pending",
- });
-};
-
-// 移除审批人
-const removeApprover = (user) => {
- const index = approvers.value.findIndex(item => item.id === user.id);
- if (index > -1) {
- approvers.value.splice(index, 1);
- // 重新排序
- approvers.value.forEach((item, idx) => {
- item.order = idx + 1;
- });
+// 辅助函数:将教师数组转换为后端期望的格式
+const convertTeacherData = async (teacherArray: any[], fieldName: string) => {
+ if (!teacherArray || !Array.isArray(teacherArray)) {
+ return {};
}
-};
-
-// 搜索抄送人
-const searchCCUsers = async (keyword) => {
- try {
- // 这里调用搜索API
- const result = await searchUsers(keyword);
+
+ // 如果数组元素是字符串ID,直接使用
+ if (typeof teacherArray[0] === 'string' || typeof teacherArray[0] === 'number') {
+ const ids = teacherArray.join(',');
+
+ // 从流程设置数据中获取对应的姓名
+ let names = '';
+ if (lcglSetData.value) {
+ // 构建ID到姓名的映射
+ if (fieldName === 'spId' && lcglSetData.value.spName) {
+ names = lcglSetData.value.spName;
+ } else if (fieldName === 'ccId' && lcglSetData.value.ccName) {
+ names = lcglSetData.value.ccName;
+ } else {
+ // 如果没有现成的姓名,尝试从缓存中查找
+ const nameArray = teacherArray.map((id: string) => {
+ return getTeacherNameFromCache(id);
+ });
+ names = nameArray.join(',');
+ }
+ } else {
+ // 如果流程设置数据不可用,尝试从缓存中查找
+ const nameArray = teacherArray.map((id: string) => {
+ return getTeacherNameFromCache(id);
+ });
+ names = nameArray.join(',');
+ }
+
+ const result = {
+ [fieldName]: ids,
+ [`${fieldName.replace('Id', 'Name')}`]: names
+ };
return result;
- } catch (error) {
- console.error("搜索抄送人失败:", error);
- return [];
}
-};
-
-// 添加抄送人
-const addCCUser = (user) => {
- ccUsers.value.push({
- ...user,
- status: "unread",
- });
-};
-
-// 移除抄送人
-const removeCCUser = (user) => {
- const index = ccUsers.value.findIndex(item => item.id === user.id);
- if (index > -1) {
- ccUsers.value.splice(index, 1);
- }
-};
-
-// 搜索用户通用方法
-const searchUsers = async (keyword) => {
- // 这里应该调用实际的用户搜索API
- // 暂时返回模拟数据
- return [
- { id: "1", userName: "张三", deptName: "教务处" },
- { id: "2", userName: "李四", deptName: "学生处" },
- ];
+
+ // 如果数组元素是对象,按原来的逻辑处理
+ const ids = teacherArray.map((item: any) => item.value || item.id).join(',');
+ const names = teacherArray.map((item: any) => item.label || item.jsxm || item.name).join(',');
+
+ const result = {
+ [fieldName]: ids,
+ [`${fieldName.replace('Id', 'Name')}`]: names
+ };
+ return result;
};
// 表单配置
@@ -130,20 +150,18 @@ const [register, { getValue, setValue, setSchema }] = useForm({
componentProps: {
placeholder: "请输入公文标题",
},
- required: true,
},
{
- field: "gwType",
+ field: "docType",
label: "公文类型",
component: "BasicPicker",
componentProps: {
api: findByPid,
- param: { pid: "GW_TYPE" }, // 公文类型字典
+ param: { pid: "2146632731" }, // 公文类型字典
rangeKey: "dictionaryValue",
savaKey: "dictionaryCode",
placeholder: "请选择公文类型",
},
- required: true,
},
{
field: "urgencyLevel",
@@ -151,120 +169,599 @@ const [register, { getValue, setValue, setSchema }] = useForm({
component: "BasicPicker",
componentProps: {
api: findByPid,
- param: { pid: "URGENCY_LEVEL" }, // 紧急程度字典
+ param: { pid: "2146632735" }, // 紧急程度字典
rangeKey: "dictionaryValue",
savaKey: "dictionaryCode",
placeholder: "请选择紧急程度",
},
- required: true,
},
+ {
+ field: "fileUrl",
+ label: "上传附件",
+ component: "BasicUpload",
+ componentProps: {
+ multiple: false,
+ accept: "*/*",
+ maxCount: 1,
+ disabled: false,
+ limit: 1,
+ beforeUpload: (file: any) => {
+ const fileFullName = file.name || '';
+ const fileExt = fileFullName.split('.').pop() || '';
+ const fileWithoutExt = fileFullName.replace(/\.[^/.]+$/, '');
+
+ // 存储到全局变量中
+ fileName.value = fileWithoutExt;
+ fileFormat.value = fileExt;
+
+ return true;
+ }
+ },
+ },
+ // 注释掉原始文件名和文件格式字段,在提交时通过代码赋值
+ /*
+ // 添加原始文件名字段(隐藏)
+ {
+ field: "fileName",
+ label: "原始文件名",
+ component: "BasicInput",
+ componentProps: {
+ placeholder: "原始文件名",
+ readonly: true,
+ disabled: true,
+ style: "position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0;", // 使用CSS完全隐藏字段
+ },
+ },
+
+ // 添加文件格式字段(隐藏)
+ {
+ field: "fileFormat",
+ label: "文件格式",
+ component: "BasicInput",
+ componentProps: {
+ placeholder: "文件格式",
+ readonly: true,
+ disabled: true,
+ style: "position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0;", // 使用CSS完全隐藏字段
+ },
+ },
+ */
{
field: "remark",
label: "备注",
- component: "BasicTextarea",
+ component: "BasicInput",
componentProps: {
placeholder: "请输入备注信息(可选)",
+ type: "textarea",
rows: 3,
},
},
{
- title: "文件上传",
+ title: "审批设置",
},
{
- field: "files",
- label: "附件",
- component: "BasicUpload",
+ field: "spId",
+ label: "审批人",
+ component: "BasicJsPicker",
+ defaultValue: [],
componentProps: {
- fileList: fileList,
multiple: true,
- accept: "*/*",
- maxCount: 10,
- onUpload: handleFileUpload,
- onDelete: handleFileDelete,
+ placeholder: "请选择审批人",
+ title: "选择审批人",
+ searchPlaceholder: "输入教师姓名搜索",
+ onChange: async (value: any) => {
+ // 手动更新表单值,确保数据回显
+ setValue({ spId: value });
+ }
},
},
{
- title: "审批人设置",
- },
- {
- field: "approverSearch",
- label: "搜索审批人",
- component: "BasicSearch",
+ field: "ccId",
+ label: "抄送人",
+ component: "BasicJsPicker",
+ defaultValue: [],
componentProps: {
- placeholder: "输入姓名或部门搜索",
- onSearch: searchApprovers,
- onSelect: addApprover,
+ multiple: true,
+ placeholder: "请选择抄送人",
+ title: "选择抄送人",
+ searchPlaceholder: "输入教师姓名搜索",
+ onChange: async (value: any) => {
+ // 手动更新表单值,确保数据回显
+ setValue({ ccId: value });
+ }
},
},
{
- field: "approvers",
- label: "已选审批人",
- component: "BasicList",
+ field: "tjrName",
+ label: "提交人",
+ component: "BasicInput",
componentProps: {
- data: approvers,
- renderItem: (item) => ({
- title: item.userName,
- subtitle: `${item.deptName} - 顺序${item.order}`,
- rightIcon: "close",
- onRightIconClick: () => removeApprover(item),
- }),
+ placeholder: "当前用户",
+ readonly: true,
+ disabled: true,
},
},
{
- title: "抄送人设置",
- },
- {
- field: "ccSearch",
- label: "搜索抄送人",
- component: "BasicSearch",
+ field: "tjrtime",
+ label: "提交时间",
+ component: "BasicInput",
componentProps: {
- placeholder: "输入姓名或部门搜索",
- onSearch: searchCCUsers,
- onSelect: addCCUser,
- },
- },
- {
- field: "ccUsers",
- label: "已选抄送人",
- component: "BasicList",
- componentProps: {
- data: ccUsers,
- renderItem: (item) => ({
- title: item.userName,
- subtitle: item.deptName,
- rightIcon: "close",
- onRightIconClick: () => removeCCUser(item),
- }),
+ placeholder: "当前时间",
+ readonly: true,
+ disabled: true,
},
},
+ // 公文状态字段已隐藏,提交时自动设置为A,暂存时自动设置为B
+ // {
+ // field: "gwStatus",
+ // label: "公文状态",
+ // component: "BasicPicker",
+ // componentProps: {
+ // options: [
+ // { label: "暂存", value: "B" },
+ // { label: "提交", value: "A" },
+ // ],
+ // placeholder: "请选择发布状态",
+ // },
+ // required: true,
+ // defaultValue: "A",
+ // },
],
});
+
+
+// 页面加载时获取路由参数
+onLoad((options) => {
+ // 将参数存储到本地存储,确保 onMounted 时能获取到
+ if (options?.mode === 'edit' && options?.id) {
+ uni.setStorageSync('gwEditMode', 'edit');
+ uni.setStorageSync('gwEditId', options.id);
+ } else {
+ // 清除之前的编辑参数
+ uni.removeStorageSync('gwEditMode');
+ uni.removeStorageSync('gwEditId');
+ }
+});
+
+// 预加载教师数据到缓存
+const preloadTeacherData = async () => {
+ try {
+ // 检查缓存是否已存在
+ const existingCache = uni.getStorageSync('globalTeacherData');
+ if (existingCache && existingCache.length > 0) {
+ return;
+ }
+
+ // 从API获取教师数据
+ const teacherStore = useCommonStore();
+ const teacherResult = await teacherStore.getAllJs();
+
+ if (teacherResult && teacherResult.result && teacherResult.result.length > 0) {
+ // 将教师数据存储到缓存
+ uni.setStorageSync('globalTeacherData', teacherResult.result);
+
+ // 构建ID到姓名的映射缓存
+ const teacherCache: Record = {};
+ teacherResult.result.forEach((teacher: any) => {
+ if (teacher.id && teacher.jsxm) {
+ teacherCache[teacher.id] = teacher;
+ }
+ });
+ uni.setStorageSync('teacherCache', teacherCache);
+ }
+
+ // 检查本地存储中的教师数据
+ const localData = uni.getStorageSync('data');
+ if (localData && localData.allJs && localData.allJs.result) {
+ console.log('本地存储中的教师数据:', localData.allJs.result.length, '条记录');
+ // 将本地数据也存储到全局缓存中
+ uni.setStorageSync('globalTeacherData', localData.allJs.result);
+ }
+ } catch (error) {
+ console.error('预加载教师数据失败:', error);
+ }
+};
+
+// 页面加载完成
+onMounted(async () => {
+ // 预加载教师数据到缓存
+ await preloadTeacherData();
+
+ // 尝试多种方式获取路由参数
+ let isEditMode = false;
+ let routeGwId = '';
+
+ // 方式1: 通过 getCurrentPages 获取
+ try {
+ const pages = getCurrentPages();
+ const currentPage = pages[pages.length - 1];
+ const options = (currentPage as any).options;
+
+ if (options?.mode === 'edit' && options?.id) {
+ isEditMode = true;
+ routeGwId = options.id;
+ }
+ } catch (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) {
+ // 编辑模式:获取公文详情并填充表单,同时获取最新的流程设置数据
+ await Promise.all([
+ getGwDetail(routeGwId),
+ getLcglSetData()
+ ]);
+ } else {
+ // 新增模式:获取流程设置数据
+ await getLcglSetData();
+ }
+
+ // 最后设置当前用户信息和时间(确保缓存数据已准备好)
+ await setCurrentUserInfo();
+});
+
+// 注意:ensureTeacherDataCached 函数已移除,BasicJsPicker 组件会自动处理教师数据获取
+
+// 格式化时间为后台期望的格式
+const formatDateTime = (dateTime: string) => {
+ if (!dateTime) return '';
+ const date = new Date(dateTime);
+ const year = date.getFullYear();
+ const month = String(date.getMonth() + 1).padStart(2, '0');
+ const day = String(date.getDate()).padStart(2, '0');
+ const hours = String(date.getHours()).padStart(2, '0');
+ const minutes = String(date.getMinutes()).padStart(2, '0');
+ const seconds = String(date.getSeconds()).padStart(2, '0');
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+};
+
+// 设置当前用户信息和时间
+const setCurrentUserInfo = async () => {
+ try {
+ // 获取当前用户信息
+ const js = getJs;
+
+ if (js && js.id && js.jsxm) {
+ // 设置提交人姓名(用于显示)
+ setValue({
+ tjrName: js.jsxm
+ });
+
+ // 设置提交人ID(用于后端存储)
+ setValue({
+ tjrId: js.id
+ });
+
+ // 同时存储到全局变量中
+ tjrId.value = js.id;
+
+ // 设置提交时间
+ const currentTime = formatDateTime(new Date().toISOString());
+ setValue({
+ tjrtime: currentTime
+ });
+ } else {
+ // 尝试从缓存获取用户信息
+ try {
+ const cachedUserInfo = uni.getStorageSync('userInfo');
+ if (cachedUserInfo && cachedUserInfo.id && cachedUserInfo.jsxm) {
+ // 设置提交人姓名(用于显示)
+ setValue({
+ tjrName: cachedUserInfo.jsxm
+ });
+
+ // 设置提交人ID(用于后端存储)
+ setValue({
+ tjrId: cachedUserInfo.id
+ });
+
+ // 同时存储到全局变量中
+ tjrId.value = cachedUserInfo.id;
+
+ // 设置提交时间
+ const currentTime = formatDateTime(new Date().toISOString());
+ setValue({
+ tjrtime: currentTime
+ });
+ }
+ } catch (cacheError) {
+ console.error('从缓存获取用户信息失败:', cacheError);
+ }
+ }
+
+ // 如果还是没有获取到用户信息,尝试从教师缓存中查找
+ if (!tjrId.value) {
+ try {
+ // 从本地存储获取教师数据
+ const teacherData = uni.getStorageSync('data');
+ if (teacherData && teacherData.allJs && teacherData.allJs.result) {
+ const allTeachers = teacherData.allJs.result;
+ // 取第一个教师作为默认用户(或者可以根据其他逻辑选择)
+ if (allTeachers.length > 0) {
+ const defaultTeacher = allTeachers[0];
+ if (defaultTeacher.id && defaultTeacher.jsxm) {
+ // 设置提交人姓名(用于显示)
+ setValue({
+ tjrName: defaultTeacher.jsxm
+ });
+
+ // 设置提交人ID(用于后端存储)
+ setValue({
+ tjrId: defaultTeacher.id
+ });
+
+ // 同时存储到全局变量中
+ tjrId.value = defaultTeacher.id;
+
+ // 设置提交时间
+ const currentTime = formatDateTime(new Date().toISOString());
+ setValue({
+ tjrtime: currentTime
+ });
+ }
+ }
+ }
+ } catch (teacherError) {
+ console.error('从教师缓存获取用户信息失败:', teacherError);
+ }
+ }
+
+ // 如果已经获取到 tjrId,但提交人姓名为空,尝试从缓存中查找
+ if (tjrId.value) {
+ const currentFormValue = await getValue();
+ if (!currentFormValue.tjrName) {
+ const teacherName = getTeacherNameFromCache(tjrId.value);
+ if (teacherName && teacherName !== tjrId.value) {
+ setValue({
+ tjrName: teacherName
+ });
+ }
+ }
+ }
+
+ } catch (error) {
+ console.error('设置当前用户信息失败:', error);
+ }
+};
+
+// 获取流程设置数据
+const getLcglSetData = async () => {
+ try {
+ const params = {
+ ruleId: 'yfzc_gw',
+ page: 1,
+ pageSize: 1
+ };
+
+ const response = await lcglSetFindPageApi(params);
+
+ if (response && response.rows && response.rows.length > 0) {
+ lcglSetData.value = response.rows[0];
+
+ // 保存审批规则到全局变量
+ // 只有在 spRule 为空时才设置,避免覆盖公文详情中的规则
+ if (lcglSetData.value.spRule && !spRule.value) {
+ spRule.value = lcglSetData.value.spRule;
+ }
+
+ // 等待一段时间确保组件完全初始化
+ await new Promise(resolve => setTimeout(resolve, 200));
+
+ // 如果流程设置有默认审批人,尝试设置默认值
+ if (lcglSetData.value.spId) {
+ const spIdArray = lcglSetData.value.spId.split(',').filter((id: string) => id.trim());
+
+ if (spIdArray.length > 0) {
+ try {
+ setValue({ spId: spIdArray });
+ } catch (error) {
+ console.error('设置审批人默认值失败:', error);
+ }
+ }
+ }
+
+ // 如果流程设置有默认抄送人,尝试设置默认值
+ if (lcglSetData.value.ccId) {
+ const ccIdArray = lcglSetData.value.ccId.split(',').filter((id: string) => id.trim());
+
+ if (ccIdArray.length > 0) {
+ try {
+ setValue({ ccId: ccIdArray });
+ } catch (error) {
+ console.error('设置抄送人默认值失败:', error);
+ }
+ }
+ }
+ }
+ } catch (error) {
+ console.error("获取流程设置失败:", error);
+ }
+};
+
+// 获取公文详情
+const getGwDetail = async (gwId: string) => {
+ try {
+ const response = await gwFindByIdApi({ id: gwId });
+
+ if (response && response.result) {
+ const gwDetail = response.result;
+
+ // 填充表单
+ const formData = {
+ title: gwDetail.title || '',
+ docType: gwDetail.docType || '',
+ urgencyLevel: gwDetail.urgencyLevel || '',
+ fileUrl: gwDetail.fileUrl || '',
+ remark: gwDetail.remark || '',
+ spId: gwDetail.spId ? gwDetail.spId.split(',').filter((id: string) => id.trim()) : [],
+ ccId: gwDetail.ccId ? gwDetail.ccId.split(',').filter((id: string) => id.trim()) : [],
+ tjrName: gwDetail.tjrxm || gwDetail.tjrName || '',
+ tjrtime: gwDetail.tjrtime || '',
+ gwStatus: gwDetail.gwStatus || '',
+ };
+
+ // 逐个设置表单值
+ for (const [key, value] of Object.entries(formData)) {
+ setValue({ [key]: value });
+ }
+
+ // 设置文件名和格式
+ if (gwDetail.fileName) {
+ fileName.value = gwDetail.fileName;
+ }
+ if (gwDetail.fileFormat) {
+ fileFormat.value = gwDetail.fileFormat;
+ }
+
+ // 保存审批规则到全局变量(编辑模式)
+ // 优先使用公文详情中的审批规则,如果没有则使用流程设置中的规则
+ if (gwDetail.spRule) {
+ spRule.value = gwDetail.spRule;
+ }
+ // 注意:如果公文详情中没有 spRule,会在 getLcglSetData 中设置
+
+ // 编辑模式下,确保提交人信息正确设置
+ if (gwDetail.tjrId) {
+ tjrId.value = gwDetail.tjrId;
+
+ // 如果提交人姓名为空,尝试从缓存中查找
+ if (!gwDetail.tjrxm && !gwDetail.tjrName) {
+ try {
+ const teacherData = uni.getStorageSync('data');
+ if (teacherData && teacherData.allJs && teacherData.allJs.result) {
+ const allTeachers = teacherData.allJs.result;
+ const teacher = allTeachers.find((t: any) => t.id === gwDetail.tjrId);
+ if (teacher && teacher.jsxm) {
+ setValue({
+ tjrName: teacher.jsxm
+ });
+ }
+ }
+ } catch (error) {
+ console.error('从缓存查找提交人姓名失败:', error);
+ }
+ }
+ }
+
+ } else {
+ uni.showToast({
+ title: "获取公文详情失败",
+ icon: "error",
+ });
+ navigateTo("/pages/view/routine/gwlz/index");
+ }
+ } catch (error) {
+ console.error("获取公文详情失败:", error);
+ uni.showToast({
+ title: "获取详情失败",
+ icon: "error",
+ });
+ }
+};
+
+// 自动填充流程设置默认值的函数
+const autoFillDefaultValues = async () => {
+ if (!lcglSetData.value || hasSetDefaultValues.value) return;
+
+ try {
+ // 获取当前表单值
+ const currentValue = await getValue();
+
+ // 如果审批人字段为空且有默认值,自动填充
+ if (lcglSetData.value.spId && (!currentValue.spId || currentValue.spId.length === 0)) {
+ const spIdArray = lcglSetData.value.spId.split(',').filter((id: string) => id.trim());
+ if (spIdArray.length > 0) {
+ setValue({ spId: spIdArray });
+ }
+ }
+
+ // 如果抄送人字段为空且有默认值,自动填充
+ if (lcglSetData.value.ccId && (!currentValue.ccId || currentValue.ccId.length === 0)) {
+ const ccIdArray = lcglSetData.value.ccId.split(',').filter((id: string) => id.trim());
+ if (ccIdArray.length > 0) {
+ setValue({ ccId: ccIdArray });
+ }
+ }
+
+ // 标记已经设置过默认值
+ hasSetDefaultValues.value = true;
+ } catch (error) {
+ console.error('自动填充默认值失败:', error);
+ }
+};
+
// 暂存草稿
const saveDraft = async () => {
try {
const value = await getValue();
- if (!validateForm(value)) return;
- const draftData = {
+ // 暂存时只验证必填字段,不验证审批人
+ if (!validateDraftForm(value)) return;
+
+ // 验证文件是否上传
+ if (!value.fileUrl) {
+ uni.showToast({
+ title: "请上传附件",
+ icon: "error",
+ });
+ return;
+ }
+
+ // 处理审批人和抄送人数据,转换为后端期望的格式
+ const processedData = {
...value,
- files: fileList.value,
- approvers: approvers.value,
- ccUsers: ccUsers.value,
- status: "draft",
- createdBy: getJs.id,
- createdTime: new Date(),
+ id: gwId.value, // 添加公文ID,用于后台验证是否修改和新增
+ fileName: fileName.value, // 使用全局变量中存储的文件名
+ fileFormat: fileFormat.value, // 使用全局变量中存储的文件格式
+ tjrId: tjrId.value, // 使用全局变量中存储的提交人ID
+ spRule: spRule.value, // 使用全局变量中存储的审批规则
+ gwStatus: "B", // 暂存状态
+ tjrtime: value.tjrtime || new Date().toISOString(),
};
- // 调用保存草稿API
- await saveDraftApi(draftData);
+ // 转换审批人和抄送人数据,使用辅助函数
+ const spData = await convertTeacherData(value.spId || [], 'spId');
+ const ccData = await convertTeacherData(value.ccId || [], 'ccId');
+
+ Object.assign(processedData, spData);
+ Object.assign(processedData, ccData);
+
+ // 调用保存API(新增或更新)
+ await gwSaveApi(processedData);
uni.showToast({
title: "草稿保存成功",
icon: "success",
});
- navigateTo("/pages/view/routine/gwList");
+ navigateTo("/pages/view/routine/gwlz/index");
} catch (error) {
console.error("保存草稿失败:", error);
uni.showToast({
@@ -278,9 +775,19 @@ const saveDraft = async () => {
const submit = async () => {
try {
const value = await getValue();
+
if (!validateForm(value)) return;
- if (approvers.value.length === 0) {
+ // 验证文件是否上传
+ if (!value.fileUrl) {
+ uni.showToast({
+ title: "请上传附件",
+ icon: "error",
+ });
+ return;
+ }
+
+ if (!value.spId || value.spId.length === 0) {
uni.showToast({
title: "请至少选择一名审批人",
icon: "error",
@@ -288,25 +795,34 @@ const submit = async () => {
return;
}
- const submitData = {
+ // 处理审批人和抄送人数据,转换为后端期望的格式
+ const processedData = {
...value,
- files: fileList.value,
- approvers: approvers.value,
- ccUsers: ccUsers.value,
- status: "pending",
- createdBy: getJs.id,
- createdTime: new Date(),
+ id: gwId.value, // 添加公文ID,用于后台验证是否修改和新增
+ fileName: fileName.value, // 使用全局变量中存储的文件名
+ fileFormat: fileFormat.value, // 使用全局变量中存储的文件格式
+ tjrId: tjrId.value, // 使用全局变量中存储的提交人ID
+ spRule: spRule.value, // 使用全局变量中存储的审批规则
+ gwStatus: "A", // 提交状态
+ tjrtime: value.tjrtime || new Date().toISOString(),
};
- // 调用提交API
- await submitGwApi(submitData);
+ // 转换审批人和抄送人数据,使用辅助函数
+ const spData = await convertTeacherData(value.spId || [], 'spId');
+ const ccData = await convertTeacherData(value.ccId || [], 'ccId');
+
+ Object.assign(processedData, spData);
+ Object.assign(processedData, ccData);
+
+ // 调用保存API(新增或更新)
+ await gwSaveApi(processedData);
uni.showToast({
title: "公文提交成功",
icon: "success",
});
- navigateTo("/pages/view/routine/gwList");
+ navigateTo("/pages/view/routine/gwlz/index");
} catch (error) {
console.error("提交公文失败:", error);
uni.showToast({
@@ -317,7 +833,8 @@ const submit = async () => {
};
// 表单验证
-const validateForm = (value) => {
+const validateForm = (value: any) => {
+ // 验证公文标题
if (!value.title || value.title.trim() === "") {
uni.showToast({
title: "请输入公文标题",
@@ -325,15 +842,17 @@ const validateForm = (value) => {
});
return false;
}
-
- if (!value.gwType) {
+
+ // 验证公文类型
+ if (!value.docType) {
uni.showToast({
title: "请选择公文类型",
icon: "error",
});
return false;
}
-
+
+ // 验证紧急程度
if (!value.urgencyLevel) {
uni.showToast({
title: "请选择紧急程度",
@@ -341,21 +860,78 @@ const validateForm = (value) => {
});
return false;
}
-
+
+ // 验证文件是否上传
+ if (!value.fileUrl) {
+ uni.showToast({
+ title: "请上传附件",
+ icon: "error",
+ });
+ return false;
+ }
+
+ // 验证审批人(提交时必须选择)
+ if (!value.spId || value.spId.length === 0) {
+ uni.showToast({
+ title: "请至少选择一名审批人",
+ icon: "error",
+ });
+ return false;
+ }
+
return true;
};
-// 模拟API调用
-const saveDraftApi = async (data) => {
- // 这里应该调用实际的保存草稿API
- console.log("保存草稿:", data);
- return Promise.resolve();
+// 暂存草稿时的表单验证(不需要验证审批人)
+const validateDraftForm = (value: any) => {
+ // 验证公文标题
+ if (!value.title || value.title.trim() === "") {
+ uni.showToast({
+ title: "请输入公文标题",
+ icon: "error",
+ });
+ return false;
+ }
+
+ // 验证公文类型
+ if (!value.docType) {
+ uni.showToast({
+ title: "请选择公文类型",
+ icon: "error",
+ });
+ return false;
+ }
+
+ // 验证紧急程度
+ if (!value.urgencyLevel) {
+ uni.showToast({
+ title: "请选择紧急程度",
+ icon: "error",
+ });
+ return false;
+ }
+
+ // 验证文件是否上传
+ if (!value.fileUrl) {
+ uni.showToast({
+ title: "请上传附件",
+ icon: "error",
+ });
+ return false;
+ }
+
+ return true;
};
-const submitGwApi = async (data) => {
- // 这里应该调用实际的提交公文API
- console.log("提交公文:", data);
- return Promise.resolve();
+// 调用真实API
+const createGwApi = async (data: any) => {
+ try {
+ const response = await gwSaveApi(data);
+ return response;
+ } catch (error) {
+ console.error("保存公文失败:", error);
+ throw error;
+ }
};
@@ -387,3 +963,5 @@ const submitGwApi = async (data) => {
}
+
+
diff --git a/src/pages/view/routine/gwlz/gwDetail.vue b/src/pages/view/routine/gwlz/gwDetail.vue
new file mode 100644
index 0000000..686e726
--- /dev/null
+++ b/src/pages/view/routine/gwlz/gwDetail.vue
@@ -0,0 +1,210 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/view/routine/gwlz/index.vue b/src/pages/view/routine/gwlz/index.vue
index e7bf84c..e9d2455 100644
--- a/src/pages/view/routine/gwlz/index.vue
+++ b/src/pages/view/routine/gwlz/index.vue
@@ -1,132 +1,124 @@
-
-
-
-
-
-
-
-
-
-
-
- {{ tab.label }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ tab.label }}
+
+
+
-
-
+
-
-
-
-
-
-
-
- 编号:
- {{ item.gwNo }}
-
-
- 类型:
- {{ item.gwType }}
-
-
- 紧急程度:
-
- {{ getUrgencyText(item.urgencyLevel) }}
+
+
+
-
-
-
+
-
-
-
-
-
-
-
-
+