提交代码

This commit is contained in:
zlwu committed 2025-08-08 03:59:16 +08:00
1 parent d9f760fe1c
commit 01588bf87d
484 files changed
+7228 -104711

No files matched your search

+93
View File
@@ -0,0 +1,93 @@
import { get, post, put, del, uploadFile, downloadFile } from '@/common/request.js'
import type { LeaveForm, LeaveTypeConfig, StudentInfo } from '@/types/leave'
import type { ApiResponse } from '@/common/request'
// 请假相关API
export const leaveApi = {
// 获取请假类型列表
getLeaveTypeList: (params?: any) => {
return get<LeaveTypeConfig[]>('/xgLeaveTypeConfig/xgLeaveTypeConfig/list', params)
},
// 获取学生信息
getStudentInfo: (studentId: string | number) => {
return get<StudentInfo>(`/studentMsg/studentMsg/${studentId}`)
},
// 获取当前用户学生信息
getCurrentUserStudentInfo: () => {
return get<StudentInfo>('/studentMsg/studentMsg/currentUserInfo')
},
// 获取请假信息
getLeaveInfo: (id: string | number) => {
return get<LeaveForm>(`/workflow/studentLeave/studentLeave/${id}`)
},
// 新增请假申请
addLeave: (data: LeaveForm) => {
return post<LeaveForm>('/workflow/studentLeave/studentLeave', data)
},
// 更新请假申请
updateLeave: (data: LeaveForm) => {
return put<LeaveForm>('/workflow/studentLeave/studentLeave', data)
},
// 删除请假申请
deleteLeave: (id: string | number) => {
return del(`/workflow/studentLeave/studentLeave/${id}`)
},
// 获取班主任ID
getClassTeacherId: (studentId: string | number) => {
return get<number>(`/studentMsg/studentMsg/classTeacherId/${studentId}`)
},
// 获取学院请假审批人
getCollegeLeaveApprovers: (studentId: string | number) => {
return get<number[]>(`/studentMsg/studentMsg/collegeLeaveApprovers/${studentId}`)
},
// 启动工作流
startWorkflow: (data: {
businessId: string | number
flowCode: string
variables: Record<string, any>
}) => {
return post<{ taskId: string }>('/workflow/task/start', data)
},
// 完成任务
completeTask: (data: {
taskId: string
opinion: string
result: 'approve' | 'reject'
rejectReason?: string
variables?: Record<string, any>
}) => {
return post('/workflow/task/complete', data)
},
// 获取审批记录
getApprovalRecords: (businessId: string | number) => {
return get(`/workflow/task/approvalRecords/${businessId}`)
},
// 获取附件信息
getAttachmentInfo: (ossIds: string) => {
return get(`/resource/oss/listByIds/${ossIds}`)
},
// 上传文件
uploadFile: (filePath: string, bizType: string = 'student_leave_attachment') => {
return uploadFile('/resource/oss/upload', filePath, { bizType })
},
// 下载文件
downloadFile: (ossId: string) => {
return downloadFile(`/resource/oss/download/${ossId}`)
}
}
export default leaveApi
+64
View File
@@ -0,0 +1,64 @@
// request.js 的 TypeScript 声明文件
export interface ApiResponse<T = any> {
code: number
msg: string
data: T
rows?: T[]
total?: number
}
export interface RequestOptions {
url: string
method?: 'GET' | 'POST' | 'PUT' | 'DELETE'
data?: any
header?: Record<string, any>
timeout?: number
clientId?: string
}
export interface LoginData {
username: string
password: string
tenantId?: string
clientId?: string
grantType?: string
}
export interface UploadResponse {
code: number
msg: string
data: {
url: string
ossId: string
fileName: string
}
}
export interface DownloadResponse {
statusCode: number
tempFilePath: string
errMsg: string
}
// 主要导出函数
export function request(options: RequestOptions): Promise<ApiResponse>
// 便捷请求方法
export function get<T = any>(url: string, data?: any, header?: Record<string, any>): Promise<ApiResponse<T>>
export function post<T = any>(url: string, data?: any, header?: Record<string, any>): Promise<ApiResponse<T>>
export function put<T = any>(url: string, data?: any, header?: Record<string, any>): Promise<ApiResponse<T>>
export function del<T = any>(url: string, data?: any, header?: Record<string, any>): Promise<ApiResponse<T>>
// 文件操作方法
export function uploadFile(url: string, filePath: string, formData?: Record<string, any>): Promise<UploadResponse>
export function downloadFile(url: string): Promise<DownloadResponse>
export function download(url: string, params: any, fileName: string): Promise<any>
// API对象
export const api: {
login: (data: LoginData) => Promise<ApiResponse>
getUserInfo: () => Promise<ApiResponse>
getTenantList: (isToken?: boolean) => Promise<ApiResponse>
logout: () => Promise<ApiResponse>
}
+141 -3
View File
@@ -89,6 +89,7 @@ export const request = (options) => {
method: options.method || 'GET',
data: options.data || {},
timeout: options.timeout || REQUEST_CONFIG.timeout,
responseType: options.responseType || 'text', // 支持responseType参数
header: {
'Content-Type': 'application/json',
authorization: token,
@@ -200,8 +201,12 @@ export const request = (options) => {
hasEncryptHeader: !!res.header[ENCRYPT_CONFIG.ENCRYPT_HEADER],
});
// 解密处理
if (REQUEST_CONFIG.encryptEnabled && res.header[ENCRYPT_CONFIG.ENCRYPT_HEADER]) {
// 解密处理 - 只对JSON响应进行解密
if (
REQUEST_CONFIG.encryptEnabled &&
res.header[ENCRYPT_CONFIG.ENCRYPT_HEADER] &&
config.responseType === 'text'
) {
try {
console.log('🔓 开始响应解密处理...');
@@ -236,6 +241,12 @@ export const request = (options) => {
// 处理响应
if (res.statusCode === 200) {
// 对于arraybuffer类型的响应,直接返回数据
if (config.responseType === 'arraybuffer') {
resolve(res.data);
return;
}
// 检查业务状态码
if (res.data && res.data.code !== undefined) {
if (res.data.code === 200) {
@@ -356,6 +367,132 @@ export const api = {
}),
};
// 便捷请求方法封装
export const get = (url, data, header) => {
return request({
url,
method: 'GET',
data,
header,
});
};
export const post = (url, data, header) => {
return request({
url,
method: 'POST',
data,
header,
});
};
export const put = (url, data, header) => {
return request({
url,
method: 'PUT',
data,
header,
});
};
export const del = (url, data, header) => {
return request({
url,
method: 'DELETE',
data,
header,
});
};
// 文件上传方法
export const uploadFile = (url, filePath, formData) => {
return new Promise((resolve, reject) => {
const token = getToken();
const clientid = uni.getStorageSync('clientid') || REQUEST_CONFIG.clientId;
// 构建完整URL - 在开发环境下使用localhost:8080
let fullUrl;
if (REQUEST_CONFIG.baseURL.startsWith('/')) {
// 开发环境,baseURL是'/api',需要使用完整的localhost URL
fullUrl = `http://localhost:8080${url}`;
} else {
// 生产环境,直接拼接
fullUrl = REQUEST_CONFIG.baseURL + url;
}
console.log('🚀 上传文件URL:', fullUrl);
console.log('🗂️ 文件路径:', filePath);
console.log('📊 表单数据:', formData);
const headers = {
// 移除Content-Type设置,让uni.uploadFile自动处理
authorization: token,
clientid: clientid,
};
uni.uploadFile({
url: fullUrl,
filePath,
name: 'file',
formData,
header: headers,
success: (res) => {
console.log('✅ 上传成功响应:', res);
try {
const data = JSON.parse(res.data);
resolve(data);
} catch (error) {
console.error('❌ 解析响应数据失败:', error);
reject(new Error('解析响应数据失败'));
}
},
fail: (err) => {
console.error('❌ 上传失败:', err);
reject(new Error(err.errMsg || '上传失败'));
},
});
});
};
// 文件下载方法
export const downloadFile = (url) => {
return new Promise((resolve, reject) => {
const token = getToken();
const clientid = uni.getStorageSync('clientid') || REQUEST_CONFIG.clientId;
console.log('REQUEST_CONFIG.baseURL:', REQUEST_CONFIG.baseURL);
// 构建完整URL - 在开发环境下使用localhost:8080
let fullUrl;
if (REQUEST_CONFIG.baseURL.startsWith('/')) {
// 开发环境,baseURL是'/api',需要使用完整的localhost URL
fullUrl = `http://localhost:8080${url}`;
} else {
// 生产环境,直接拼接
fullUrl = REQUEST_CONFIG.baseURL + url;
}
console.log('📥 下载文件URL:', fullUrl);
const headers = {
authorization: token,
clientid: clientid,
};
uni.downloadFile({
url: fullUrl,
header: headers,
success: (res) => {
console.log('✅ 下载成功:', res);
resolve(res);
},
fail: (err) => {
console.error('❌ 下载失败:', err);
reject(new Error(err.errMsg || '下载失败'));
},
});
});
};
// 通用下载方法
export const download = (url, params, fileName) => {
// 显示加载提示
@@ -376,12 +513,12 @@ export const download = (url, params, fileName) => {
})
.then((resp) => {
// 处理下载响应
// 注意:uni-app中文件下载需要特殊处理
console.log('文件下载完成:', fileName);
uni.hideLoading();
// 这里需要根据平台进行不同的文件保存处理
// 具体实现可能需要平台特定的代码
return resp;
})
.catch((error) => {
console.error('下载失败:', error);
@@ -390,5 +527,6 @@ export const download = (url, params, fileName) => {
title: '下载文件出现错误,请联系管理员!',
icon: 'none',
});
throw error;
});
};
@@ -0,0 +1,110 @@
<template>
<view class="approval-button-container">
<!-- 审批状态 -->
<view v-if="status === 'waiting'" class="button-group">
<u-button type="success" @click="handleApproval" class="action-button">审批</u-button>
<u-button type="info" @click="handleApprovalRecord" class="action-button">
查看记录
</u-button>
</view>
<!-- 默认状态 -->
<view v-else class="button-group">
<u-button
type="info"
:loading="buttonLoading"
@click="handleSubmit('draft')"
class="action-button"
>
暂存
</u-button>
<u-button
type="primary"
:loading="buttonLoading"
@click="handleSubmit('submit')"
class="action-button"
>
提交
</u-button>
</view>
</view>
</template>
<script>
export default {
name: 'ApprovalButton',
props: {
id: {
type: [String, Number],
default: '',
},
status: {
type: String,
default: 'draft',
},
pageType: {
type: String,
default: '',
},
taskId: {
type: String,
default: '',
},
buttonLoading: {
type: Boolean,
default: false,
},
},
methods: {
// 提交表单
handleSubmit(status) {
this.$emit('submitForm', status);
},
// 审批操作
handleApproval() {
this.$emit('approvalVerifyOpen');
},
// 查看审批记录
handleApprovalRecord() {
this.$emit('handleApprovalRecord');
},
},
};
</script>
<style scoped>
.approval-button-container {
padding: 20rpx;
background: #fff;
border-radius: 12rpx;
margin-bottom: 20rpx;
}
.button-group {
display: flex;
gap: 20rpx;
flex-wrap: wrap;
}
.action-button {
flex: 1;
min-width: 200rpx;
height: 80rpx;
border-radius: 40rpx;
font-size: 28rpx;
font-weight: 500;
}
/* 响应式布局 */
@media (max-width: 750rpx) {
.button-group {
flex-direction: column;
}
.action-button {
width: 100%;
}
}
</style>
@@ -0,0 +1,291 @@
<template>
<u-popup
v-model="visible"
mode="center"
width="90%"
height="70%"
border-radius="12"
@close="handleClose"
>
<view class="approval-record-container">
<view class="header">
<text class="title">审批记录</text>
<u-icon name="close" size="24" @click="handleClose" />
</view>
<view class="content">
<u-loading-page v-if="loading" />
<view v-else-if="recordList.length === 0" class="empty">
<u-icon name="info-circle" size="48" color="#ccc" />
<text class="empty-text">暂无审批记录</text>
</view>
<scroll-view v-else scroll-y class="record-list">
<view v-for="(record, index) in recordList" :key="index" class="record-item">
<view class="record-header">
<view class="approver-info">
<u-avatar
:src="record.avatar || '/static/images/default-avatar.png'"
size="60"
/>
<view class="approver-details">
<text class="approver-name">
{{ record.approverName || '未知' }}
</text>
<text class="approver-role">
{{ record.roleName || '未知角色' }}
</text>
</view>
</view>
<view :class="['status-badge', getStatusClass(record.result)]">
{{ getStatusText(record.result) }}
</view>
</view>
<view v-if="record.comment" class="comment">
<text class="comment-label">审批意见:</text>
<text class="comment-text">{{ record.comment }}</text>
</view>
<view class="record-footer">
<text class="time">{{ formatTime(record.createTime) }}</text>
</view>
</view>
</scroll-view>
</view>
</view>
</u-popup>
</template>
<script>
import { request } from '@/common/request.js';
export default {
name: 'ApprovalRecord',
data() {
return {
visible: false,
loading: false,
recordList: [],
currentBusinessId: '',
};
},
methods: {
// 打开弹窗
async init(businessId) {
this.currentBusinessId = businessId.toString();
this.visible = true;
await this.loadApprovalRecords();
},
// 关闭弹窗
handleClose() {
this.visible = false;
this.recordList = [];
},
// 加载审批记录
async loadApprovalRecords() {
if (!this.currentBusinessId) return;
try {
this.loading = true;
const response = await request({
url: `/workflow/task/approvalRecords/${this.currentBusinessId}`,
method: 'GET',
});
if (response.code === 200) {
this.recordList = response.data || [];
} else {
uni.showToast({
title: response.msg || '获取审批记录失败',
icon: 'none',
});
}
} catch (error) {
console.error('获取审批记录失败:', error);
uni.showToast({
title: '获取审批记录失败',
icon: 'none',
});
} finally {
this.loading = false;
}
},
// 获取状态样式类
getStatusClass(result) {
switch (result) {
case 'approve':
return 'status-approve';
case 'reject':
return 'status-reject';
default:
return 'status-pending';
}
},
// 获取状态文本
getStatusText(result) {
switch (result) {
case 'approve':
return '同意';
case 'reject':
return '拒绝';
default:
return '待审批';
}
},
// 格式化时间
formatTime(time) {
if (!time) return '-';
return new Date(time).toLocaleString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
});
},
},
};
</script>
<style scoped>
.approval-record-container {
height: 100%;
display: flex;
flex-direction: column;
background: #fff;
border-radius: 12rpx;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 30rpx;
border-bottom: 1rpx solid #f0f0f0;
}
.title {
font-size: 32rpx;
font-weight: 600;
color: #333;
}
.content {
flex: 1;
position: relative;
}
.empty {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
padding: 60rpx;
}
.empty-text {
margin-top: 20rpx;
font-size: 28rpx;
color: #999;
}
.record-list {
height: 100%;
padding: 20rpx;
}
.record-item {
background: #f8f9fa;
border-radius: 12rpx;
padding: 24rpx;
margin-bottom: 20rpx;
}
.record-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16rpx;
}
.approver-info {
display: flex;
align-items: center;
gap: 16rpx;
}
.approver-details {
display: flex;
flex-direction: column;
gap: 4rpx;
}
.approver-name {
font-size: 28rpx;
font-weight: 500;
color: #333;
}
.approver-role {
font-size: 24rpx;
color: #666;
}
.status-badge {
padding: 8rpx 16rpx;
border-radius: 20rpx;
font-size: 24rpx;
font-weight: 500;
}
.status-approve {
background: #e8f5e8;
color: #52c41a;
}
.status-reject {
background: #fff2f0;
color: #ff4d4f;
}
.status-pending {
background: #fff7e6;
color: #fa8c16;
}
.comment {
margin-bottom: 16rpx;
padding: 16rpx;
background: #fff;
border-radius: 8rpx;
}
.comment-label {
font-size: 26rpx;
color: #666;
margin-right: 8rpx;
}
.comment-text {
font-size: 26rpx;
color: #333;
line-height: 1.5;
}
.record-footer {
display: flex;
justify-content: flex-end;
}
.time {
font-size: 24rpx;
color: #999;
}
</style>
@@ -0,0 +1,261 @@
<template>
<u-popup
v-model="visible"
mode="center"
width="90%"
height="80%"
border-radius="12"
@close="handleClose"
>
<view class="submit-verify-container">
<view class="header">
<text class="title">审批操作</text>
<u-icon name="close" size="24" @click="handleClose" />
</view>
<view class="content">
<view class="form-item">
<text class="label">审批结果</text>
<u-radio-group v-model="formData.result" @change="handleResultChange">
<u-radio label="approve" name="approve" class="radio-item">
<text class="radio-text">同意</text>
</u-radio>
<u-radio label="reject" name="reject" class="radio-item">
<text class="radio-text">拒绝</text>
</u-radio>
</u-radio-group>
</view>
<view class="form-item">
<text class="label">审批意见</text>
<u-textarea
v-model="formData.opinion"
placeholder="请输入审批意见"
:maxlength="500"
height="120"
count
/>
</view>
<view v-if="formData.result === 'reject'" class="form-item">
<text class="label">拒绝原因</text>
<u-textarea
v-model="formData.rejectReason"
placeholder="请输入拒绝原因"
:maxlength="200"
height="100"
count
/>
</view>
</view>
<view class="footer">
<u-button type="info" @click="handleClose" class="cancel-btn">取消</u-button>
<u-button
type="primary"
:loading="submitLoading"
@click="handleSubmit"
class="submit-btn"
>
提交
</u-button>
</view>
</view>
</u-popup>
</template>
<script>
import { request } from '@/common/request.js';
export default {
name: 'SubmitVerify',
props: {
taskVariables: {
type: Object,
default: () => ({}),
},
},
data() {
return {
visible: false,
submitLoading: false,
currentTaskId: '',
formData: {
opinion: '',
result: 'approve',
rejectReason: '',
},
};
},
methods: {
// 打开弹窗
openDialog(taskId) {
this.currentTaskId = taskId;
this.visible = true;
// 重置表单
this.formData.opinion = '';
this.formData.result = 'approve';
this.formData.rejectReason = '';
},
// 关闭弹窗
handleClose() {
this.visible = false;
this.submitLoading = false;
},
// 审批结果变化
handleResultChange(value) {
this.formData.result = value;
if (value === 'approve') {
this.formData.rejectReason = '';
}
},
// 提交审批
async handleSubmit() {
if (!this.formData.opinion.trim()) {
uni.showToast({
title: '请输入审批意见',
icon: 'none',
});
return;
}
if (this.formData.result === 'reject' && !this.formData.rejectReason.trim()) {
uni.showToast({
title: '请输入拒绝原因',
icon: 'none',
});
return;
}
try {
this.submitLoading = true;
// 构建提交数据
const submitData = {
taskId: this.currentTaskId,
opinion: this.formData.opinion,
result: this.formData.result,
rejectReason: this.formData.rejectReason,
variables: this.taskVariables,
};
// 调用审批API
const response = await request({
url: '/workflow/task/complete',
method: 'POST',
data: submitData,
});
if (response.code === 200) {
uni.showToast({
title: '审批成功',
icon: 'success',
});
this.handleClose();
this.$emit('submit-callback');
} else {
uni.showToast({
title: response.msg || '审批失败',
icon: 'none',
});
}
} catch (error) {
console.error('审批失败:', error);
uni.showToast({
title: '审批失败',
icon: 'none',
});
} finally {
this.submitLoading = false;
}
},
},
};
</script>
<style scoped>
.submit-verify-container {
height: 100%;
display: flex;
flex-direction: column;
background: #fff;
border-radius: 12rpx;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 30rpx;
border-bottom: 1rpx solid #f0f0f0;
}
.title {
font-size: 32rpx;
font-weight: 600;
color: #333;
}
.content {
flex: 1;
padding: 30rpx;
overflow-y: auto;
}
.form-item {
margin-bottom: 30rpx;
}
.label {
display: block;
font-size: 28rpx;
font-weight: 500;
color: #333;
margin-bottom: 16rpx;
}
.radio-group {
display: flex;
gap: 40rpx;
}
.radio-item {
display: flex;
align-items: center;
gap: 8rpx;
}
.radio-text {
font-size: 28rpx;
color: #333;
}
.footer {
display: flex;
gap: 20rpx;
padding: 30rpx;
border-top: 1rpx solid #f0f0f0;
}
.cancel-btn,
.submit-btn {
flex: 1;
height: 80rpx;
border-radius: 40rpx;
font-size: 28rpx;
font-weight: 500;
}
.cancel-btn {
background: #f5f5f5;
color: #666;
}
.submit-btn {
background: #2979ff;
color: #fff;
}
</style>
+35 -6
View File
@@ -3,14 +3,17 @@
<view class="tree-item" :class="{ active: selectedId === node.id }" @click="handleSelect">
<view class="tree-item-content">
<view class="tree-item-left">
<u-icon
<view
v-if="node.children && node.children.length > 0"
:name="expanded ? 'arrow-down' : 'arrow-right'"
size="16"
color="#666"
class="expand-icon-wrapper"
@click.stop="toggleExpand"
style="margin-right: 8px"
></u-icon>
>
<u-icon
:name="expanded ? 'arrow-down' : 'arrow-right'"
size="16"
color="#666"
></u-icon>
</view>
<text class="tree-item-text">{{ node.label }}</text>
</view>
</view>
@@ -23,6 +26,7 @@
:key="child.id"
:node="child"
:selected-id="selectedId"
:default-expanded="defaultExpanded"
@select="handleChildSelect"
></tree-node>
</view>
@@ -41,12 +45,22 @@ export default {
type: String,
default: '',
},
defaultExpanded: {
type: Boolean,
default: false,
},
},
data() {
return {
expanded: false,
};
},
mounted() {
// 如果设置了默认展开,则展开当前节点
if (this.defaultExpanded) {
this.expanded = true;
}
},
methods: {
handleSelect() {
this.$emit('select', this.node);
@@ -95,6 +109,21 @@ export default {
flex: 1;
}
.expand-icon-wrapper {
display: flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
margin-right: 8px;
border-radius: 4px;
transition: background-color 0.2s;
}
.expand-icon-wrapper:active {
background-color: #e6f7ff;
}
.tree-item-text {
font-size: 14px;
color: #333;
+8
View File
@@ -48,6 +48,14 @@
"navigationBarBackgroundColor": "#5d87ff",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/xg/xsjcxx/xsqj/leaveEdit/index",
"style": {
"navigationBarTitleText": "请假申请",
"navigationBarBackgroundColor": "#5d87ff",
"navigationBarTextStyle": "white"
}
}
],
"globalStyle": {
+10 -3
View File
@@ -451,6 +451,7 @@ import GridLayout from '@/components/GridLayout.vue';
import { userManager, userState } from '@/utils/user';
import { api } from '@/common/request';
import { hasPermi, permissionMixin } from '@/utils/permission';
import RouterManager from '@/utils/router';
export default {
name: 'HomePage',
@@ -632,9 +633,15 @@ export default {
// 服务点击处理
handleServiceClick(service) {
uni.showToast({
title: `打开${service.title}`,
icon: 'none',
// 使用路由管理工具进行跳转
RouterManager.navigateToService(service.title, {
onSuccess: () => {
console.log(`✅ 成功跳转到服务: ${service.title}`);
},
onCreatePage: (serviceName, route) => {
// 可以在这里添加页面创建逻辑
console.log(`📝 创建页面: ${serviceName} -> ${route}`);
},
});
},
+80 -59
View File
@@ -4,7 +4,7 @@
<view class="header">
<text class="title">我发起的流程</text>
<view class="header-actions">
<u-icon name="list" size="20" color="#666" @click="toggleCategory"></u-icon>
<u-icon name="list" size="24" color="#666" @click="toggleCategory"></u-icon>
</view>
</view>
@@ -77,32 +77,43 @@
</view>
<view class="quick-actions">
<view class="quick-btn view-btn" @click="handleView(item)">
<u-icon name="eye" size="18" color="#007aff"></u-icon>
<view class="quick-btn" @click="handleView(item)">
<u-icon name="eye" size="20" color="#666"></u-icon>
<text class="btn-text">查看</text>
</view>
<view
v-if="canEdit(item)"
class="quick-btn edit-btn"
class="quick-btn"
@click="handleEdit(item)"
>
<u-icon name="edit-pen" size="18" color="#52c41a"></u-icon>
<u-icon name="edit-pen" size="20" color="#666"></u-icon>
<text class="btn-text">编辑</text>
</view>
<view
v-if="item.flowStatus === 'waiting'"
class="quick-btn cancel-btn"
class="quick-btn"
@click="handleCancel(item)"
>
<u-icon name="undo" size="18" color="#faad14"></u-icon>
<text
class="iconfont icon-chexiao"
style="
font-size: 20px;
color: #faad14;
background-color: transparent;
"
></text>
<text class="btn-text" style="color: #faad14">撤销</text>
</view>
<view
v-if="canDelete(item)"
class="quick-btn delete-btn"
class="quick-btn"
@click="handleDelete(item)"
>
<u-icon name="close" size="18" color="#ff4d4f"></u-icon>
<u-icon name="close" size="20" color="#ff4d4f"></u-icon>
<text class="btn-text" style="color: #ff4d4f">删除</text>
</view>
</view>
</view>
@@ -125,7 +136,7 @@
<u-popup
:show="showCategory"
mode="right"
width="380px"
width="500px"
:safe-area-inset-bottom="false"
:safe-area-inset-top="false"
@close="showCategory = false"
@@ -136,7 +147,7 @@
<text class="popup-title">选择分类</text>
<u-icon
name="close"
size="24"
size="26"
color="#666"
@click="showCategory = false"
></u-icon>
@@ -168,6 +179,7 @@
:key="item.id"
:node="item"
:selected-id="selectedCategory && selectedCategory.id"
:default-expanded="true"
@select="selectCategory"
></tree-node>
</view>
@@ -365,13 +377,53 @@ export default {
},
handleView(item) {
this.routerJump({
businessId: item.businessId,
taskId: item.id,
type: 'view',
formCustom: item.formCustom,
formPath: item.formPath,
});
// 动态跳转到formPath对应的路径,携带businessId和flowStatus参数
if (item.formPath) {
// 确保路径以pages开头
let fullPath = item.formPath;
// 统一处理路径:去掉开头的/,然后添加pages前缀
if (!fullPath.startsWith('pages/')) {
// 如果以/开头,先去掉/
if (fullPath.startsWith('/')) {
fullPath = fullPath.substring(1);
}
// 添加pages前缀
fullPath = `pages/${fullPath}`;
}
const url = `/${fullPath}?id=${item.businessId}&type=${item.flowStatus}`;
// 添加调试信息
console.log('原始formPath:', item.formPath);
console.log('处理后的fullPath:', fullPath);
console.log('最终跳转URL:', url);
// 使用navigateTo进行跳转
uni.navigateTo({
url: url,
fail: (err) => {
console.error('页面跳转失败:', err);
// 如果跳转失败,使用原有的routerJump方法作为备选
this.routerJump({
businessId: item.businessId,
taskId: item.id,
type: 'view',
formCustom: item.formCustom,
formPath: item.formPath,
});
},
});
} else {
// 如果没有formPath,使用原有的routerJump方法作为备选
this.routerJump({
businessId: item.businessId,
taskId: item.id,
type: 'view',
formCustom: item.formCustom,
formPath: item.formPath,
});
}
},
async handleDelete(item) {
@@ -642,59 +694,28 @@ export default {
.quick-actions {
display: flex;
gap: 8px;
gap: 16px;
align-items: center;
}
.quick-btn {
width: 36px;
height: 36px;
border-radius: 18px;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s ease;
border: 1px solid transparent;
padding: 8px;
gap: 4px;
}
.btn-text {
font-size: 12px;
color: #666;
margin-left: 2px;
}
.quick-btn:active {
transform: scale(0.9);
}
.quick-btn.view-btn {
background: linear-gradient(135deg, #e6f7ff 0%, #bae7ff 100%);
border-color: #91d5ff;
}
.quick-btn.view-btn:active {
background: linear-gradient(135deg, #bae7ff 0%, #91d5ff 100%);
}
.quick-btn.edit-btn {
background: linear-gradient(135deg, #f6ffed 0%, #d9f7be 100%);
border-color: #b7eb8f;
}
.quick-btn.edit-btn:active {
background: linear-gradient(135deg, #d9f7be 0%, #b7eb8f 100%);
}
.quick-btn.cancel-btn {
background: linear-gradient(135deg, #fffbe6 0%, #fff1b8 100%);
border-color: #ffe58f;
}
.quick-btn.cancel-btn:active {
background: linear-gradient(135deg, #fff1b8 0%, #ffd666 100%);
}
.quick-btn.delete-btn {
background: linear-gradient(135deg, #fff2f0 0%, #ffe2e0 100%);
border-color: #ffccc7;
}
.quick-btn.delete-btn:active {
background: linear-gradient(135deg, #ffe2e0 0%, #ffccc7 100%);
opacity: 0.7;
}
.pagination {
@@ -0,0 +1,215 @@
# 移动端请假表单组件
## 功能概述
移动端请假表单是基于web端请假表单功能开发的移动端版本,提供了完整的请假申请、审批、记录查看等功能。
## 文件结构
```
mobile/src/pages/xg/leave/
├── index.vue # 主页面组件
└── README.md # 说明文档
mobile/src/components/Process/
├── approvalButton.vue # 审批按钮组件
├── submitVerify.vue # 提交验证组件
└── approvalRecord.vue # 审批记录组件
mobile/src/common/
├── request.js # 统一请求工具类(包含加密、认证等功能)
└── request.d.ts # TypeScript声明文件
mobile/src/types/
└── leave.ts # 类型定义
mobile/src/api/
└── leave.ts # API接口
```
## 请求工具整合说明
### 🔄 请求工具重构(2025-01-27)
**背景**: 之前存在两套请求工具(`utils/request.ts` 和 `common/request.js`),造成重复封装。
**解决方案**:
- ✅ 将 `utils/request.ts` 中的便捷方法融合到 `common/request.js` 中
- ✅ 删除重复的 `utils/request.ts` 文件
- ✅ 创建 `common/request.d.ts` TypeScript声明文件
- ✅ 更新所有API文件使用统一的请求工具
### 📦 统一的请求工具特性
#### `common/request.js` 包含功能:
- 🔐 **AES+RSA双重加密** - 登录和敏感数据传输
- 🎫 **Token认证管理** - 自动处理认证和401跳转
- 🚫 **防重复提交** - 防止用户重复操作
- 📤 **便捷请求方法** - `get()`, `post()`, `put()`, `del()`
- 📁 **文件操作** - `uploadFile()`, `downloadFile()`
- 🔄 **统一错误处理** - 网络错误和业务错误处理
#### 新增的便捷方法:
```javascript
// GET请求
export const get = (url, data, header) => { ... }
// POST请求
export const post = (url, data, header) => { ... }
// PUT请求
export const put = (url, data, header) => { ... }
// DELETE请求
export const del = (url, data, header) => { ... }
// 文件上传
export const uploadFile = (url, filePath, formData) => { ... }
// 文件下载
export const downloadFile = (url) => { ... }
```
## 功能特性
### 1. 学生信息展示
- 自动获取并显示当前登录学生的基本信息
- 包括姓名、学号、班级、专业、学院等信息
### 2. 请假信息填写
- 请假类型选择(支持多种请假类型)
- 时间选择(开始时间、结束时间)
- 自动计算请假时长
- 是否离校选择
- 紧急联系人信息
- 请假原因填写
### 3. 附件上传
- 支持多种文件格式(图片、视频、PDF、Word等)
- 文件大小限制(10MB)
- 文件数量限制(最多15个)
- 文件预览和删除功能
### 4. 工作流审批
- 暂存功能(保存草稿)
- 提交审批(启动工作流)
- 审批处理(同意/拒绝)
- 审批记录查看
### 5. 移动端适配
- 响应式布局设计
- 触摸友好的交互
- 适配不同屏幕尺寸
- 优化的表单体验
## 页面参数
页面接受以下参数:
- `type`: 页面类型(add-新增,edit-编辑,view-查看)
- `id`: 请假申请ID(编辑或查看时使用)
- `taskId`: 任务ID(审批时使用)
## 使用示例
### 新增请假申请
```javascript
uni.navigateTo({
url: '/pages/xg/leave/index?type=add'
})
```
### 编辑请假申请
```javascript
uni.navigateTo({
url: '/pages/xg/leave/index?type=edit&id=123'
})
```
### 查看请假申请
```javascript
uni.navigateTo({
url: '/pages/xg/leave/index?type=view&id=123'
})
```
### 审批任务
```javascript
uni.navigateTo({
url: '/pages/xg/leave/index?type=approval&taskId=456'
})
```
## API接口
### 请假相关接口
- `GET /xgLeaveTypeConfig/xgLeaveTypeConfig/list` - 获取请假类型列表
- `GET /studentMsg/studentMsg/currentUserInfo` - 获取当前用户学生信息
- `GET /workflow/studentLeave/studentLeave/{id}` - 获取请假信息
- `POST /workflow/studentLeave/studentLeave` - 新增请假申请
- `PUT /workflow/studentLeave/studentLeave` - 更新请假申请
### 工作流相关接口
- `POST /workflow/task/start` - 启动工作流
- `POST /workflow/task/complete` - 完成任务
- `GET /workflow/task/approvalRecords/{businessId}` - 获取审批记录
### 文件相关接口
- `POST /resource/oss/upload` - 上传文件
- `GET /resource/oss/listByIds/{ossIds}` - 获取附件信息
- `GET /resource/oss/download/{ossId}` - 下载文件
## 组件说明
### ApprovalButton 组件
- 根据当前状态显示不同的操作按钮
- 支持暂存、提交、审批、查看记录等操作
- 自动处理按钮状态和加载状态
### SubmitVerify 组件
- 提供审批意见填写界面
- 支持同意/拒绝选择
- 拒绝时可填写拒绝原因
### ApprovalRecord 组件
- 显示完整的审批记录列表
- 包含审批人、审批意见、审批时间等信息
- 支持不同审批状态的样式区分
## 注意事项
1. **权限控制**: 确保用户有相应的操作权限
2. **网络请求**: 所有API请求都使用统一的 `common/request.js` 工具
3. **文件上传**: 注意文件大小和格式限制
4. **数据验证**: 表单提交前会进行数据验证
5. **错误处理**: 网络错误和业务错误都有相应的提示
## 开发说明
### 技术栈
- Vue 2.6.14 + JavaScript
- uni-app 框架
- uview-ui 2.0.38 UI组件库
### 开发规范
- 使用JavaScript进行开发
- 遵循Vue 2 Options API规范
- 统一的错误处理和用户提示
- 响应式设计,适配多种设备
### 请求工具使用
```javascript
// 导入便捷方法
import { get, post, put, del, uploadFile, downloadFile } from '@/common/request.js'
// 使用示例
const response = await get('/api/data', { page: 1 })
const result = await post('/api/save', { name: 'test' })
const fileResult = await uploadFile('/api/upload', filePath, { type: 'image' })
```
### 扩展功能
- 可以根据需要添加更多的请假类型
- 支持自定义审批流程
- 可以集成更多的文件预览功能
- 支持离线数据缓存
File diff suppressed because it is too large. Load diff
+5
View File
@@ -21,4 +21,9 @@
/* 关闭圆圈图标 */
.icon-close-circle {
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z'/%3E%3C/svg%3E");
}
/* 撤销图标 */
.icon-chexiao {
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23faad14'%3E%3Cpath d='M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z'/%3E%3C/svg%3E");
}
+49
View File
@@ -0,0 +1,49 @@
// 全局类型声明
declare const uni: any
// uni-app API 类型声明
declare namespace UniApp {
interface RequestOptions {
url: string
method?: 'GET' | 'POST' | 'PUT' | 'DELETE'
data?: any
header?: Record<string, string>
success?: (res: any) => void
fail?: (err: any) => void
complete?: () => void
}
interface RequestResponse {
statusCode: number
data: any
header: Record<string, string>
}
interface ShowToastOptions {
title: string
icon?: 'success' | 'loading' | 'none'
duration?: number
mask?: boolean
}
interface GetStorageSyncOptions {
key: string
}
}
// 扩展全局对象
declare global {
const uni: {
request(options: UniApp.RequestOptions): Promise<UniApp.RequestResponse>
showToast(options: UniApp.ShowToastOptions): void
getStorageSync(key: string): any
setStorageSync(key: string, data: any): void
removeStorageSync(key: string): void
navigateTo(options: { url: string }): void
redirectTo(options: { url: string }): void
navigateBack(options?: { delta?: number }): void
showModal(options: { title: string; content: string; success?: (res: any) => void }): void
chooseFile(options: { count?: number; type?: string; success?: (res: any) => void }): void
uploadFile(options: { url: string; filePath: string; name: string; formData?: any; success?: (res: any) => void }): void
}
}
+109
View File
@@ -0,0 +1,109 @@
// 请假表单数据类型
export interface LeaveForm {
id?: string | number
studentId: string
studentName: string
studentNo: string
classId: string
className: string
majorId: string
majorName: string
collegeId: string
collegeName: string
leaveTypeCode: string
leaveTypeName: string
startTime: string
endTime: string
leaveDuration: string
isLeaveSchool: string
needCancel: string
emergencyContact: string
emergencyPhone: string
leaveReason: string
leaveLocation: string
attachmentOssIds: string
approvalStatus: string
approvalOpinion: string
approvalTime: string
approvalBy: string
approvalByName: string
cancelStatus: string
cancelTime: string
cancelLocation: string
status: string
}
// 请假类型配置
export interface LeaveTypeConfig {
id: string | number
leaveTypeCode: string
leaveTypeName: string
isEnabled: string
needCancelForNonLeave: string
canApplyInAdvance: string
maxApplyDuration: number
createBy: number
createTime: string
updateBy: number
updateTime: string
}
// 学生信息
export interface StudentInfo {
id: string | number
name: string
studentNo: string
classId: string
className: string
majorId: string
majorName: string
collegeId: string
collegeName: string
}
// 附件信息
export interface AttachmentInfo {
uid: string
name: string
url?: string
ossId?: string
status: 'ready' | 'uploading' | 'success' | 'error'
size?: number
path?: string
}
// 审批记录
export interface ApprovalRecord {
id: string | number
businessId: string | number
taskId: string
approverId: string | number
approverName: string
roleName: string
opinion: string
rejectReason?: string
result: 'approve' | 'reject' | 'pending'
approvalTime: string
createTime: string
}
// 工作流任务
export interface WorkflowTask {
taskId: string
businessId: string | number
flowCode: string
taskName: string
assignee: string
createTime: string
dueDate?: string
}
// 页面参数
export interface PageParams {
type?: string
id?: string | number
taskId?: string
}
// API响应类型 - 从 request.d.ts 导入
export type { ApiResponse } from '@/common/request'
+725
View File
@@ -0,0 +1,725 @@
/**
* 页面模板生成器
* 支持动态创建标准页面模板
*/
/**
* 页面模板生成器类
*/
class PageGenerator {
/**
* 生成标准列表页面模板
* @param {string} serviceName - 服务名称
* @param {string} route - 路由路径
* @param {object} options - 选项
*/
static generateListPage(serviceName, route, options = {}) {
const template = `<template>
<view class="page-container">
<!-- 页面头部 -->
<view class="page-header">
<view class="header-content">
<text class="page-title">${serviceName}</text>
<view class="header-actions">
<u-button
v-if="hasPermi(['${this.getPermissionKey(serviceName)}:add'])"
type="primary"
size="small"
@click="handleAdd"
>
<u-icon name="plus" size="16" />
新增
</u-button>
</view>
</view>
</view>
<!-- 搜索区域 -->
<view class="search-section">
<u-form :model="searchForm" ref="searchFormRef">
<u-form-item label="关键词">
<u-input
v-model="searchForm.keyword"
placeholder="请输入关键词"
clearable
/>
</u-form-item>
<u-form-item>
<u-button type="primary" @click="handleSearch">搜索</u-button>
<u-button @click="handleReset">重置</u-button>
</u-form-item>
</u-form>
</view>
<!-- 数据列表 -->
<view class="list-section">
<u-list
:data="dataList"
:loading="loading"
:empty="dataList.length === 0"
@loadmore="handleLoadMore"
>
<template #item="{ item, index }">
<view class="list-item" @click="handleItemClick(item)">
<view class="item-content">
<text class="item-title">{{ item.title || item.name }}</text>
<text class="item-desc">{{ item.description || item.remark }}</text>
</view>
<view class="item-actions">
<u-button
v-if="hasPermi(['${this.getPermissionKey(serviceName)}:edit'])"
type="primary"
size="mini"
@click.stop="handleEdit(item)"
>
编辑
</u-button>
<u-button
v-if="hasPermi(['${this.getPermissionKey(serviceName)}:remove'])"
type="error"
size="mini"
@click.stop="handleDelete(item)"
>
删除
</u-button>
</view>
</view>
</template>
</u-list>
</view>
<!-- 分页组件 -->
<view class="pagination-section" v-if="total > 0">
<u-pagination
:total="total"
:current="currentPage"
:page-size="pageSize"
@change="handlePageChange"
/>
</view>
</view>
</template>
<script>
import { hasPermi, permissionMixin } from '@/utils/permission';
import { api } from '@/common/request';
export default {
name: '${this.getComponentName(serviceName)}',
mixins: [permissionMixin],
data() {
return {
// 搜索表单
searchForm: {
keyword: '',
status: '',
dateRange: []
},
// 列表数据
dataList: [],
loading: false,
// 分页参数
currentPage: 1,
pageSize: 10,
total: 0,
// 权限标识
permissionKey: '${this.getPermissionKey(serviceName)}'
};
},
onLoad() {
this.loadData();
},
methods: {
// 权限检查
hasPermi(permissions) {
return hasPermi(permissions);
},
// 加载数据
async loadData() {
try {
this.loading = true;
const params = {
pageNum: this.currentPage,
pageSize: this.pageSize,
...this.searchForm
};
// 这里需要根据实际API调整
const response = await api.get('/${this.getApiPath(serviceName)}/list', { params });
if (response.code === 200) {
this.dataList = response.rows || [];
this.total = response.total || 0;
} else {
uni.showToast({
title: response.msg || '加载失败',
icon: 'none'
});
}
} catch (error) {
console.error('加载数据失败:', error);
uni.showToast({
title: '网络错误',
icon: 'none'
});
} finally {
this.loading = false;
}
},
// 搜索
handleSearch() {
this.currentPage = 1;
this.loadData();
},
// 重置
handleReset() {
this.searchForm = {
keyword: '',
status: '',
dateRange: []
};
this.currentPage = 1;
this.loadData();
},
// 新增
handleAdd() {
uni.navigateTo({
url: '/pages/${this.getFormPath(serviceName)}/add'
});
},
// 编辑
handleEdit(item) {
uni.navigateTo({
url: \`/pages/${this.getFormPath(serviceName)}/edit?id=\${item.id}\`
});
},
// 删除
async handleDelete(item) {
try {
const confirmed = await this.showConfirm('确认删除', \`确定删除"\${item.title || item.name}"吗?\`);
if (!confirmed) return;
const response = await api.delete(\`/${this.getApiPath(serviceName)}/\${item.id}\`);
if (response.code === 200) {
uni.showToast({
title: '删除成功',
icon: 'success'
});
this.loadData();
} else {
uni.showToast({
title: response.msg || '删除失败',
icon: 'none'
});
}
} catch (error) {
console.error('删除失败:', error);
uni.showToast({
title: '网络错误',
icon: 'none'
});
}
},
// 点击列表项
handleItemClick(item) {
uni.navigateTo({
url: \`/pages/${this.getFormPath(serviceName)}/detail?id=\${item.id}\`
});
},
// 加载更多
handleLoadMore() {
if (this.dataList.length < this.total) {
this.currentPage++;
this.loadData();
}
},
// 分页变化
handlePageChange(page) {
this.currentPage = page;
this.loadData();
},
// 确认对话框
showConfirm(title, content) {
return new Promise((resolve) => {
uni.showModal({
title,
content,
success: (res) => {
resolve(res.confirm);
},
fail: () => {
resolve(false);
}
});
});
}
}
};
</script>
<style lang="scss" scoped>
.page-container {
min-height: 100vh;
background-color: #f5f5f5;
display: flex;
flex-direction: column;
}
.page-header {
background: linear-gradient(135deg, #007aff, #0051d9);
padding: calc(var(--status-bar-height) + 12px) 16px 16px;
color: #ffffff;
}
.header-content {
display: flex;
justify-content: space-between;
align-items: center;
}
.page-title {
font-size: 20px;
font-weight: 600;
}
.search-section {
background-color: #ffffff;
margin: 16px;
padding: 16px;
border-radius: 12px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.list-section {
flex: 1;
margin: 0 16px;
}
.list-item {
background-color: #ffffff;
margin-bottom: 12px;
padding: 16px;
border-radius: 12px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
display: flex;
justify-content: space-between;
align-items: center;
}
.item-content {
flex: 1;
}
.item-title {
font-size: 16px;
font-weight: 600;
color: #333333;
margin-bottom: 4px;
display: block;
}
.item-desc {
font-size: 14px;
color: #666666;
display: block;
}
.item-actions {
display: flex;
gap: 8px;
}
.pagination-section {
background-color: #ffffff;
margin: 16px;
padding: 16px;
border-radius: 12px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
display: flex;
justify-content: center;
}
</style>`;
return template;
}
/**
* 生成表单页面模板
* @param {string} serviceName - 服务名称
* @param {string} route - 路由路径
* @param {object} options - 选项
*/
static generateFormPage(serviceName, route, options = {}) {
const template = `<template>
<view class="page-container">
<!-- 页面头部 -->
<view class="page-header">
<view class="header-content">
<u-button
type="text"
@click="handleBack"
class="back-btn"
>
<u-icon name="arrow-left" size="20" color="#ffffff" />
</u-button>
<text class="page-title">{{ isEdit ? '编辑' : '新增' }}${serviceName}</text>
<view class="header-actions">
<u-button
type="primary"
size="small"
@click="handleSave"
:loading="saving"
>
保存
</u-button>
</view>
</view>
</view>
<!-- 表单内容 -->
<view class="form-section">
<u-form
:model="formData"
:rules="formRules"
ref="formRef"
label-width="100px"
>
<u-form-item label="名称" prop="name">
<u-input
v-model="formData.name"
placeholder="请输入名称"
clearable
/>
</u-form-item>
<u-form-item label="描述" prop="description">
<u-textarea
v-model="formData.description"
placeholder="请输入描述"
:maxlength="200"
show-count
/>
</u-form-item>
<u-form-item label="状态" prop="status">
<u-radio-group v-model="formData.status">
<u-radio label="启用" value="1" />
<u-radio label="禁用" value="0" />
</u-radio-group>
</u-form-item>
<u-form-item label="排序" prop="sort">
<u-number-box
v-model="formData.sort"
:min="0"
:max="999"
/>
</u-form-item>
</u-form>
</view>
</view>
</template>
<script>
import { api } from '@/common/request';
export default {
name: '${this.getComponentName(serviceName)}Form',
data() {
return {
// 表单数据
formData: {
id: null,
name: '',
description: '',
status: '1',
sort: 0
},
// 表单验证规则
formRules: {
name: [
{ required: true, message: '请输入名称', trigger: 'blur' }
],
status: [
{ required: true, message: '请选择状态', trigger: 'change' }
]
},
// 页面状态
isEdit: false,
saving: false,
// API路径
apiPath: '${this.getApiPath(serviceName)}'
};
},
onLoad(options) {
if (options.id) {
this.isEdit = true;
this.formData.id = options.id;
this.loadData();
}
},
methods: {
// 加载数据
async loadData() {
try {
const response = await api.get(\`/\${this.apiPath}/\${this.formData.id}\`);
if (response.code === 200) {
this.formData = { ...this.formData, ...response.data };
} else {
uni.showToast({
title: response.msg || '加载失败',
icon: 'none'
});
}
} catch (error) {
console.error('加载数据失败:', error);
uni.showToast({
title: '网络错误',
icon: 'none'
});
}
},
// 保存
async handleSave() {
try {
// 表单验证
const valid = await this.$refs.formRef.validate();
if (!valid) return;
this.saving = true;
const url = this.isEdit
? \`/\${this.apiPath}/\${this.formData.id}\`
: \`/\${this.apiPath}\`;
const method = this.isEdit ? 'put' : 'post';
const response = await api[method](url, this.formData);
if (response.code === 200) {
uni.showToast({
title: this.isEdit ? '更新成功' : '创建成功',
icon: 'success'
});
// 返回上一页
setTimeout(() => {
this.handleBack();
}, 1500);
} else {
uni.showToast({
title: response.msg || '保存失败',
icon: 'none'
});
}
} catch (error) {
console.error('保存失败:', error);
uni.showToast({
title: '网络错误',
icon: 'none'
});
} finally {
this.saving = false;
}
},
// 返回
handleBack() {
uni.navigateBack();
}
}
};
</script>
<style lang="scss" scoped>
.page-container {
min-height: 100vh;
background-color: #f5f5f5;
display: flex;
flex-direction: column;
}
.page-header {
background: linear-gradient(135deg, #007aff, #0051d9);
padding: calc(var(--status-bar-height) + 12px) 16px 16px;
color: #ffffff;
}
.header-content {
display: flex;
justify-content: space-between;
align-items: center;
}
.back-btn {
padding: 0;
margin: 0;
background: transparent;
}
.page-title {
font-size: 20px;
font-weight: 600;
}
.form-section {
flex: 1;
background-color: #ffffff;
margin: 16px;
padding: 16px;
border-radius: 12px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
</style>`;
return template;
}
/**
* 获取权限标识
* @param {string} serviceName - 服务名称
*/
static getPermissionKey(serviceName) {
const permissionMap = {
学生信息: 'student:info',
宿舍管理: 'student:dorm',
学生请假: 'student:leave',
心理健康: 'student:psychology',
社团管理: 'student:club',
心理咨询: 'student:counsel',
物业报修: 'logistics:repair',
场地预约: 'logistics:venue',
报告厅预约: 'logistics:hall',
满意度调查: 'logistics:survey',
食堂管理: 'logistics:canteen',
物业管理: 'logistics:property',
学生管理: 'recruitment:student',
毕业生信息: 'recruitment:graduate',
就业信息: 'recruitment:job',
员工管理: 'hr:staff',
出国申请: 'hr:abroad',
培训管理: 'hr:training',
预算管理: 'finance:budget',
费用报销: 'finance:expense',
发票管理: 'finance:invoice',
用户管理: 'system:user',
角色管理: 'system:role',
菜单管理: 'system:menu',
部门管理: 'system:dept',
参数设置: 'system:config',
在线用户: 'monitor:online',
};
return permissionMap[serviceName] || 'system:default';
}
/**
* 获取组件名称
* @param {string} serviceName - 服务名称
*/
static getComponentName(serviceName) {
return serviceName.replace(/\s+/g, '');
}
/**
* 获取API路径
* @param {string} serviceName - 服务名称
*/
static getApiPath(serviceName) {
const apiMap = {
学生信息: 'student/info',
宿舍管理: 'student/dorm',
学生请假: 'student/leave',
心理健康: 'student/psychology',
社团管理: 'student/club',
心理咨询: 'student/counsel',
物业报修: 'logistics/repair',
场地预约: 'logistics/venue',
报告厅预约: 'logistics/hall',
满意度调查: 'logistics/survey',
食堂管理: 'logistics/canteen',
物业管理: 'logistics/property',
学生管理: 'recruitment/student',
毕业生信息: 'recruitment/graduate',
就业信息: 'recruitment/job',
员工管理: 'hr/staff',
出国申请: 'hr/abroad',
培训管理: 'hr/training',
预算管理: 'finance/budget',
费用报销: 'finance/expense',
发票管理: 'finance/invoice',
用户管理: 'system/user',
角色管理: 'system/role',
菜单管理: 'system/menu',
部门管理: 'system/dept',
参数设置: 'system/config',
在线用户: 'monitor/online',
};
return apiMap[serviceName] || 'system/default';
}
/**
* 获取表单路径
* @param {string} serviceName - 服务名称
*/
static getFormPath(serviceName) {
const pathMap = {
学生信息: 'student/info',
宿舍管理: 'student/dorm',
学生请假: 'student/leave',
心理健康: 'student/psychology',
社团管理: 'student/club',
心理咨询: 'student/counsel',
物业报修: 'logistics/repair',
场地预约: 'logistics/venue',
报告厅预约: 'logistics/hall',
满意度调查: 'logistics/survey',
食堂管理: 'logistics/canteen',
物业管理: 'logistics/property',
学生管理: 'recruitment/student',
毕业生信息: 'recruitment/graduate',
就业信息: 'recruitment/job',
员工管理: 'hr/staff',
出国申请: 'hr/abroad',
培训管理: 'hr/training',
预算管理: 'finance/budget',
费用报销: 'finance/expense',
发票管理: 'finance/invoice',
用户管理: 'system/user',
角色管理: 'system/role',
菜单管理: 'system/menu',
部门管理: 'system/dept',
参数设置: 'system/config',
在线用户: 'monitor/online',
};
return pathMap[serviceName] || 'system/default';
}
}
export default PageGenerator;
+238
View File
@@ -0,0 +1,238 @@
/**
* 路由管理工具类
* 支持动态路由跳转,无需在pages.json中预先配置
*/
// 服务路由映射配置
const SERVICE_ROUTES = {
// 学工管理
'student:info': '/pages/student/info/index',
'student:dorm': '/pages/student/dorm/index',
'student:leave': '/pages/student/leave/index',
'student:psychology': '/pages/student/psychology/index',
'student:club': '/pages/student/club/index',
'student:counsel': '/pages/student/counsel/index',
// 后勤管理
'logistics:repair': '/pages/logistics/repair/index',
'logistics:venue': '/pages/logistics/venue/index',
'logistics:hall': '/pages/logistics/hall/index',
'logistics:survey': '/pages/logistics/survey/index',
'logistics:canteen': '/pages/logistics/canteen/index',
'logistics:property': '/pages/logistics/property/index',
// 招生就业
'recruitment:student': '/pages/recruitment/student/index',
'recruitment:graduate': '/pages/recruitment/graduate/index',
'recruitment:job': '/pages/recruitment/job/index',
// 人事管理
'hr:staff': '/pages/hr/staff/index',
'hr:abroad': '/pages/hr/abroad/index',
'hr:training': '/pages/hr/training/index',
// 财务管理
'finance:budget': '/pages/finance/budget/index',
'finance:expense': '/pages/finance/expense/index',
'finance:invoice': '/pages/finance/invoice/index',
// 系统管理
'system:user': '/pages/system/user/index',
'system:role': '/pages/system/role/index',
'system:menu': '/pages/system/menu/index',
'system:dept': '/pages/system/dept/index',
'system:config': '/pages/system/config/index',
'monitor:online': '/pages/monitor/online/index',
};
// 服务名称映射
const SERVICE_NAMES = {
学生信息: 'student:info',
宿舍管理: 'student:dorm',
学生请假: 'student:leave',
心理健康: 'student:psychology',
社团管理: 'student:club',
心理咨询: 'student:counsel',
物业报修: 'logistics:repair',
场地预约: 'logistics:venue',
报告厅预约: 'logistics:hall',
满意度调查: 'logistics:survey',
食堂管理: 'logistics:canteen',
物业管理: 'logistics:property',
学生管理: 'recruitment:student',
毕业生信息: 'recruitment:graduate',
就业信息: 'recruitment:job',
员工管理: 'hr:staff',
出国申请: 'hr:abroad',
培训管理: 'hr:training',
预算管理: 'finance:budget',
费用报销: 'finance:expense',
发票管理: 'finance:invoice',
用户管理: 'system:user',
角色管理: 'system:role',
菜单管理: 'system:menu',
部门管理: 'system:dept',
参数设置: 'system:config',
在线用户: 'monitor:online',
};
/**
* 路由管理类
*/
class RouterManager {
/**
* 根据服务名称跳转到对应页面
* @param {string} serviceName - 服务名称
* @param {object} options - 跳转选项
*/
static navigateToService(serviceName, options = {}) {
const serviceKey = SERVICE_NAMES[serviceName];
if (!serviceKey) {
this.showServiceNotConfigured(serviceName);
return;
}
const route = SERVICE_ROUTES[serviceKey];
if (!route) {
this.showServiceNotConfigured(serviceName);
return;
}
// 构建完整URL(支持参数传递)
let url = route;
if (options.params) {
const queryString = Object.keys(options.params)
.map((key) => `${key}=${encodeURIComponent(options.params[key])}`)
.join('&');
url += `?${queryString}`;
}
// 执行跳转
uni.navigateTo({
url,
success: () => {
console.log(`✅ 成功跳转到: ${url}`);
if (options.onSuccess) {
options.onSuccess();
}
},
fail: (error) => {
console.warn(`⚠️ 页面跳转失败: ${url}`, error);
this.handlePageNotExist(serviceName, route, options);
},
});
}
/**
* 处理页面不存在的情况
* @param {string} serviceName - 服务名称
* @param {string} route - 路由路径
* @param {object} options - 选项
*/
static handlePageNotExist(serviceName, route, options = {}) {
uni.showModal({
title: '页面不存在',
content: `${serviceName}页面尚未创建,是否创建该页面?`,
confirmText: '创建页面',
cancelText: '取消',
success: (res) => {
if (res.confirm) {
this.createPageTemplate(serviceName, route, options);
} else {
this.showServiceNotImplemented(serviceName);
}
},
});
}
/**
* 创建页面模板
* @param {string} serviceName - 服务名称
* @param {string} route - 路由路径
* @param {object} options - 选项
*/
static createPageTemplate(serviceName, route, options = {}) {
// 这里可以实现页面创建逻辑
// 1. 调用后端API创建页面文件
// 2. 跳转到页面创建向导
// 3. 生成标准页面模板
console.log(`📝 需要创建页面: ${route} - ${serviceName}`);
// 临时提示
uni.showToast({
title: '页面创建功能开发中',
icon: 'none',
duration: 2000,
});
// 可以在这里添加实际的页面创建逻辑
if (options.onCreatePage) {
options.onCreatePage(serviceName, route);
}
}
/**
* 显示服务未配置提示
* @param {string} serviceName - 服务名称
*/
static showServiceNotConfigured(serviceName) {
uni.showToast({
title: `服务未配置: ${serviceName}`,
icon: 'none',
duration: 2000,
});
}
/**
* 显示服务未实现提示
* @param {string} serviceName - 服务名称
*/
static showServiceNotImplemented(serviceName) {
uni.showToast({
title: `功能开发中: ${serviceName}`,
icon: 'none',
duration: 2000,
});
}
/**
* 检查页面是否存在
* @param {string} route - 路由路径
* @returns {Promise<boolean>}
*/
static async checkPageExists(route) {
return new Promise((resolve) => {
// 尝试跳转但不实际跳转,用于检查页面是否存在
uni.navigateTo({
url: route,
success: () => {
// 立即返回,避免实际跳转
uni.navigateBack();
resolve(true);
},
fail: () => {
resolve(false);
},
});
});
}
/**
* 获取所有可用的服务路由
* @returns {object}
*/
static getAvailableRoutes() {
return { ...SERVICE_ROUTES };
}
/**
* 获取服务名称映射
* @returns {object}
*/
static getServiceNames() {
return { ...SERVICE_NAMES };
}
}
export default RouterManager;
+1 -1
View File
@@ -35,7 +35,7 @@ export const userManager = {
// 部门信息
deptId: user.deptId,
deptName: user.dept?.deptName || '',
deptName: user?.deptName || '',
// 状态信息
status: user.status,