From c79afe56e2c8a28ef5b61a82ee9000d1c39b33f4 Mon Sep 17 00:00:00 2001
From: zlwu <704541015@qq.com>
Date: Sun, 10 Aug 2025 20:16:20 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
mobile/src/components/FileUpload/index.vue | 181 +++++++++---
.../src/components/Process/approvalButton.vue | 60 +++-
.../src/components/Process/submitVerify.vue | 140 ++++++---
.../src/pages/xg/xsjcxx/xsqj/leave/index.vue | 16 ++
.../pages/xg/xsjcxx/xsqj/leaveEdit/index.vue | 269 ++++++++++++------
5 files changed, 497 insertions(+), 169 deletions(-)
diff --git a/mobile/src/components/FileUpload/index.vue b/mobile/src/components/FileUpload/index.vue
index 29026487..48ed290c 100644
--- a/mobile/src/components/FileUpload/index.vue
+++ b/mobile/src/components/FileUpload/index.vue
@@ -37,7 +37,7 @@
-
下载
-
+ -->
{{ uploadPercent }}%
+
+
+
+
+
+
@@ -89,7 +118,7 @@ import { REQUEST_CONFIG } from '@/common/config.js';
export default {
name: 'FileUpload',
props: {
- modelValue: {
+ value: {
type: [String, Object, Array],
default: () => [],
},
@@ -119,12 +148,16 @@ export default {
default: false,
},
},
+ emits: ['input', 'submit', 'cancel'],
data() {
return {
fileList: [],
uploading: false,
showProgress: false,
uploadPercent: 0,
+ showDeleteConfirm: false,
+ deleteIndex: -1,
+ showClearConfirm: false,
};
},
computed: {
@@ -133,7 +166,7 @@ export default {
},
},
watch: {
- modelValue: {
+ value: {
handler: 'initFileList',
immediate: true,
deep: true,
@@ -149,10 +182,10 @@ export default {
} else if (typeof val === 'string' && val.trim()) {
// 如果是字符串,调用API获取文件详情
try {
+ const ids = val.split(',').filter((id) => id.trim());
const response = await this.request({
- url: '/resource/oss/listByIds',
- method: 'POST',
- data: val.split(',').filter((id) => id.trim()),
+ url: `/resource/oss/listByIds/${encodeURIComponent(ids.join(','))}`,
+ method: 'GET',
});
if (response.code === 200) {
@@ -387,37 +420,54 @@ export default {
},
// 删除文件
- async handleDelete(index) {
+ handleDelete(index) {
+ console.log('handleDelete', index);
+ this.deleteIndex = index;
+ this.showDeleteConfirm = true;
+ },
+
+ // 确认删除
+ async confirmDelete() {
try {
- const result = await this.showConfirm('确定要删除这个文件吗?');
- if (result.confirm) {
- const file = this.fileList[index];
+ const file = this.fileList[this.deleteIndex];
- // 如果有ossId,调用删除API
- if (file.ossId) {
- try {
- await this.request({
- url: `/resource/oss/${file.ossId}`,
- method: 'DELETE',
- });
- } catch (error) {
- console.error('删除文件失败:', error);
- }
+ // 如果有ossId,调用删除API
+ if (file.ossId) {
+ try {
+ await this.request({
+ url: `/resource/oss/${file.ossId}`,
+ method: 'DELETE',
+ });
+ } catch (error) {
+ console.error('删除文件失败:', error);
}
-
- this.fileList.splice(index, 1);
- this.emitChange();
-
- uni.showToast({
- title: '删除成功',
- icon: 'success',
- });
}
+
+ this.fileList.splice(this.deleteIndex, 1);
+ this.emitChange();
+
+ uni.showToast({
+ title: '删除成功',
+ icon: 'success',
+ });
} catch (error) {
console.error('删除文件失败:', error);
+ uni.showToast({
+ title: '删除失败',
+ icon: 'none',
+ });
+ } finally {
+ this.showDeleteConfirm = false;
+ this.deleteIndex = -1;
}
},
+ // 取消删除
+ cancelDelete() {
+ this.showDeleteConfirm = false;
+ this.deleteIndex = -1;
+ },
+
// 获取文件名
getFileName(name) {
if (!name) return '未知文件';
@@ -442,7 +492,8 @@ export default {
// 发出变更事件
emitChange() {
const value = this.listToString(this.fileList);
- this.$emit('update:modelValue', value);
+ console.log('longwu---emitChange', value);
+ this.$emit('input', value);
},
// 转换为字符串
@@ -464,6 +515,59 @@ export default {
});
},
+ // 提交文件
+ handleSubmit() {
+ if (this.fileList.length === 0) {
+ uni.showToast({
+ title: '请先选择文件',
+ icon: 'none',
+ });
+ return;
+ }
+
+ // 发出提交事件,传递文件列表
+ this.$emit('submit', {
+ fileList: this.fileList,
+ ossIds: this.listToString(this.fileList),
+ });
+ },
+
+ // 取消操作
+ handleCancel() {
+ if (this.fileList.length > 0) {
+ this.showClearConfirm = true;
+ } else {
+ this.$emit('cancel');
+ }
+ },
+
+ // 确认清空文件
+ confirmClear() {
+ try {
+ this.fileList = [];
+ this.emitChange();
+ this.$emit('cancel');
+
+ uni.showToast({
+ title: '已清空文件列表',
+ icon: 'success',
+ });
+ } catch (error) {
+ console.error('清空文件失败:', error);
+ uni.showToast({
+ title: '清空文件失败',
+ icon: 'none',
+ });
+ } finally {
+ this.showClearConfirm = false;
+ }
+ },
+
+ // 取消清空文件
+ cancelClear() {
+ this.showClearConfirm = false;
+ },
+
// 请求方法
async request(options) {
const { request } = await import('@/common/request.js');
@@ -475,17 +579,24 @@ export default {
diff --git a/mobile/src/components/Process/submitVerify.vue b/mobile/src/components/Process/submitVerify.vue
index 95a47e24..395e201f 100644
--- a/mobile/src/components/Process/submitVerify.vue
+++ b/mobile/src/components/Process/submitVerify.vue
@@ -1,12 +1,13 @@
{
+ // 临时隐藏主弹窗,避免层级冲突
+ const originalVisible = this.visible;
+ this.visible = false;
+
uni.showModal({
title: '提示',
content,
- success: resolve,
+ success: (res) => {
+ // 恢复主弹窗显示状态
+ this.visible = originalVisible;
+ resolve(res);
+ },
+ fail: () => {
+ // 恢复主弹窗显示状态
+ this.visible = originalVisible;
+ resolve({ confirm: false });
+ },
});
});
},
@@ -1161,22 +1175,45 @@ export default {
background: #fff;
}
-.button-row {
- display: flex;
+.buttons-grid {
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
gap: 20rpx;
- margin-bottom: 20rpx;
-}
-
-.button-row:last-child {
- margin-bottom: 0;
+ width: 100%;
+ direction: rtl;
}
.action-btn {
- flex: 1;
height: 80rpx;
border-radius: 40rpx;
font-size: 28rpx;
font-weight: 500;
+ min-width: 0;
+ direction: ltr;
+}
+
+.submit-btn {
+ background: linear-gradient(
+ 135deg,
+ rgb(0, 81, 217) 0%,
+ rgb(51, 122, 235) 50%,
+ rgb(102, 163, 255) 100%
+ ) !important;
+ color: #fff;
+ border: none;
+}
+
+.submit-btn::after {
+ border: none;
+}
+
+.submit-btn:not([disabled]):active {
+ background: linear-gradient(
+ 135deg,
+ rgb(0, 71, 197) 0%,
+ rgb(41, 112, 225) 50%,
+ rgb(92, 153, 245) 100%
+ ) !important;
}
.back-container,
@@ -1188,7 +1225,30 @@ export default {
border-radius: 12rpx;
}
-.confirm-btn,
+.confirm-btn {
+ background: linear-gradient(
+ 135deg,
+ rgb(0, 81, 217) 0%,
+ rgb(51, 122, 235) 50%,
+ rgb(102, 163, 255) 100%
+ ) !important;
+ color: #fff;
+ border: none;
+}
+
+.confirm-btn::after {
+ border: none;
+}
+
+.confirm-btn:not([disabled]):active {
+ background: linear-gradient(
+ 135deg,
+ rgb(0, 71, 197) 0%,
+ rgb(41, 112, 225) 50%,
+ rgb(92, 153, 245) 100%
+ ) !important;
+}
+
.cancel-btn {
flex: 1;
height: 80rpx;
diff --git a/mobile/src/pages/xg/xsjcxx/xsqj/leave/index.vue b/mobile/src/pages/xg/xsjcxx/xsqj/leave/index.vue
index 8dfe62f4..98bb869f 100644
--- a/mobile/src/pages/xg/xsjcxx/xsqj/leave/index.vue
+++ b/mobile/src/pages/xg/xsjcxx/xsqj/leave/index.vue
@@ -325,7 +325,23 @@ export default {
await this.loadLeaveList();
},
+ mounted() {
+ // 监听刷新事件
+ uni.$on('refreshLeaveList', this.handleRefreshEvent);
+ },
+
+ beforeDestroy() {
+ // 移除事件监听
+ uni.$off('refreshLeaveList', this.handleRefreshEvent);
+ },
+
methods: {
+ // 处理刷新事件
+ handleRefreshEvent() {
+ console.log('🔄 收到刷新事件,正在刷新请假列表...');
+ this.loadLeaveList();
+ },
+
// 返回上一页
goBack() {
uni.navigateBack();
diff --git a/mobile/src/pages/xg/xsjcxx/xsqj/leaveEdit/index.vue b/mobile/src/pages/xg/xsjcxx/xsqj/leaveEdit/index.vue
index 4641d465..099ca5da 100644
--- a/mobile/src/pages/xg/xsjcxx/xsqj/leaveEdit/index.vue
+++ b/mobile/src/pages/xg/xsjcxx/xsqj/leaveEdit/index.vue
@@ -351,7 +351,7 @@
-
+
-
+
-
+