From fdd3687e392462822226fd4e0ffc20c92a1caaba Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期一, 02 十一月 2026 16:08:30 +0800
Subject: [PATCH] refactor(app): 移除页面附件上传功能
---
src/pages/hrm/HrmAttachmentField.vue | 47 +++++++----------------------------------------
1 files changed, 7 insertions(+), 40 deletions(-)
diff --git a/src/pages/hrm/HrmAttachmentField.vue b/src/pages/hrm/HrmAttachmentField.vue
index a76f26d..8880048 100644
--- a/src/pages/hrm/HrmAttachmentField.vue
+++ b/src/pages/hrm/HrmAttachmentField.vue
@@ -1,63 +1,30 @@
<script setup lang="ts">
-import { ref } from "vue";
-import { chooseHrmFiles, uploadHrmFile, type HrmAttachment } from "../../api/hrm";
-
-const props = withDefaults(defineProps<{
+import type { HrmAttachment } from "../../api/hrm";
+withDefaults(defineProps<{
modelValue?: number[];
files?: HrmAttachment[];
token?: string | null;
readonly?: boolean;
}>(), { modelValue: () => [], files: () => [], token: null, readonly: false });
-const emit = defineEmits<{
+defineEmits<{
"update:modelValue": [value: number[]];
"update:files": [value: HrmAttachment[]];
}>();
-const uploading = ref(false);
-
-async function addFiles() {
- if (!props.token || uploading.value || props.readonly) return;
- const remaining = 10 - props.modelValue.length;
- if (remaining <= 0) return uni.showToast({ title: "鏈�澶氫笂浼� 10 涓檮浠�", icon: "none" });
- try {
- const picked = await chooseHrmFiles(remaining);
- if (!picked.length) return;
- uploading.value = true;
- const ids = [...props.modelValue];
- const files = [...props.files];
- for (const item of picked) {
- const uploaded = await uploadHrmFile(props.token, item.path);
- ids.push(uploaded.id);
- files.push({ ...uploaded, name: uploaded.name || item.name });
- }
- emit("update:modelValue", ids);
- emit("update:files", files);
- } catch (error) {
- const message = error instanceof Error ? error.message : "闄勪欢涓婁紶澶辫触";
- if (!String(message).includes("cancel")) uni.showToast({ title: message, icon: "none" });
- } finally {
- uploading.value = false;
- }
-}
-
-function remove(index: number) {
- emit("update:modelValue", props.modelValue.filter((_, itemIndex) => itemIndex !== index));
- emit("update:files", props.files.filter((_, itemIndex) => itemIndex !== index));
-}
</script>
<template>
- <view class="attachment-field">
+ <view v-if="files.length" class="attachment-field">
<view class="attachment-head">
<text>闄勪欢</text>
- <button v-if="!readonly" :loading="uploading" :disabled="uploading||modelValue.length>=10" @click="addFiles">娣诲姞闄勪欢</button>
+
</view>
<view v-if="files.length" class="attachment-list">
<view v-for="(file,index) in files" :key="file.id" class="attachment-item">
<text>{{ file.name || `闄勪欢 ${index + 1}` }}</text>
- <text v-if="!readonly" class="remove" @click="remove(index)">鍒犻櫎</text>
+
</view>
</view>
- <text v-else class="empty">鏆傛棤闄勪欢</text>
+
</view>
</template>
--
Gitblit v1.9.3