From fe2d6627b8f1002af7a31b08f6f43bec034d04ee Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期三, 21 十月 2026 18:29:07 +0800
Subject: [PATCH] feat: 完善课题、会员、财务、企微页面并新增资产/用车/采购
---
src/views/finance/reimbursement/modules/form.vue | 85 ++++++++++++++++++++++++++++++++++++++++--
1 files changed, 80 insertions(+), 5 deletions(-)
diff --git a/src/views/finance/reimbursement/modules/form.vue b/src/views/finance/reimbursement/modules/form.vue
index 06fb782..708853a 100644
--- a/src/views/finance/reimbursement/modules/form.vue
+++ b/src/views/finance/reimbursement/modules/form.vue
@@ -1,11 +1,13 @@
<script lang="ts" setup>
import type { FormType } from '../data';
import type { FinanceReimbursementApi } from '#/api/finance/reimbursement';
+import type { SystemStorageApi } from '#/api/system/storage';
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales';
+import { useUserStore } from '@vben/stores';
import { message } from 'ant-design-vue';
import dayjs from 'dayjs';
@@ -21,6 +23,14 @@
import ItemForm from './item-form.vue';
const emit = defineEmits(['success']);
+
+const userStore = useUserStore();
+
+/** 褰撳墠鐧诲綍鐢ㄦ埛 ID锛堢敤浜庢湰浜哄彂璧锋椂鍥炲~鐢宠浜猴級 */
+const currentUserId = computed(() => {
+ const id = Number(userStore.userInfo?.userId);
+ return Number.isFinite(id) && id > 0 ? id : undefined;
+});
const formData = ref<FinanceReimbursementApi.Reimbursement>({
title: '',
@@ -74,6 +84,47 @@
formApi.setValues({ totalAmount }, false);
}
+/**
+ * OCR 璇嗗埆鏃朵笂浼犵殑鍙戠エ鏂囦欢鍚屾鍒般�屽彂绁ㄩ檮浠躲�嶏紝淇濊瘉璇嗗埆杩囩殑鍙戠エ闅忓崟淇濆瓨銆�
+ * 鎸� blobId 鍘婚噸锛岄伩鍏嶅悓涓�寮犲彂绁ㄨ閲嶅璇嗗埆鏃跺嚭鐜伴噸澶嶉檮浠躲��
+ */
+async function handleOcrBlobs(blobs: SystemStorageApi.StorageBlob[]) {
+ if (blobs.length === 0) {
+ return;
+ }
+ const values = await formApi.getValues();
+ const existing = (values.blobIds ?? []) as Array<
+ | number
+ | { id?: number; name?: string; status?: string; uid?: string; url?: string }
+ >;
+ const existingFiles = existing.map((item) =>
+ typeof item === 'number'
+ ? { uid: String(item), status: 'done', id: item }
+ : item,
+ );
+ const existingIds = new Set(
+ existingFiles
+ .map((item) => item.id)
+ .filter((id): id is number => typeof id === 'number'),
+ );
+ const appended = blobs
+ .filter((blob) => !existingIds.has(blob.id))
+ .map((blob) => ({
+ uid: String(blob.id),
+ name: blob.name || blob.originalFilename || '',
+ url: blob.url || blob.previewURL || '',
+ status: 'done',
+ id: blob.id,
+ }));
+ if (appended.length === 0) {
+ return;
+ }
+ await formApi.setValues(
+ { blobIds: [...existingFiles, ...appended] },
+ false,
+ );
+}
+
/** 鍒涘缓鎴栨洿鏂版姤閿�鍗� */
const [Modal, modalApi] = useVbenModal({
async onConfirm() {
@@ -91,12 +142,24 @@
return;
}
- modalApi.lock();
- const data =
- (await formApi.getValues()) as FinanceReimbursementApi.Reimbursement;
+ const data = (await formApi.getValues()) as FinanceReimbursementApi.Reimbursement & {
+ proxyFlag?: boolean;
+ };
+ // 浠d粬浜哄彂璧峰繀椤婚�夋嫨瀹為檯鐢宠浜猴紱鏈汉鍙戣捣鏃朵互褰撳墠鐧诲綍鐢ㄦ埛涓哄噯
+ if (data.proxyFlag) {
+ if (!data.applicantId) {
+ message.error('浠d粬浜哄彂璧锋椂锛岃閫夋嫨瀹為檯鐢宠浜�');
+ return;
+ }
+ } else {
+ data.applicantId = currentUserId.value;
+ }
+ // proxyFlag 浠呯敤浜庡墠绔氦浜掞紝涓嶆彁浜ょ粰鍚庣
+ delete data.proxyFlag;
// 鍙戠エ闄勪欢涓哄叏閲忔浛鎹㈣涔夛細娓呯┖鍏ㄩ儴鍙戠エ鏃跺繀椤绘樉寮忎紶绌烘暟缁勶紝
// 浼� null 鍚庣浼氳涓恒�屼笉鍔ㄩ檮浠躲�嶏紝瀵艰嚧鍒犻櫎鎿嶄綔涓嶇敓鏁�
data.blobIds = data.blobIds ?? [];
+ modalApi.lock();
try {
await (formType.value === 'create'
? createReimbursement(data)
@@ -120,9 +183,14 @@
formApi.updateSchema(useFormSchema(formType.value));
if (!data || !data.id) {
initialItems.value = [];
- // 鏂板缓鏃堕粯璁ょ敵璇锋棩鏈熶负浠婂ぉ
+ // 鏂板缓鏃堕粯璁ゆ湰浜哄彂璧凤細鐢宠浜哄睍绀哄綋鍓嶇櫥褰曠敤鎴凤紝鐢宠鏃ユ湡涓轰粖澶�
await formApi.setValues(
- { applyDate: dayjs().format('YYYY-MM-DD') },
+ {
+ applicantId: currentUserId.value,
+ applicantName: userStore.userInfo?.nickname ?? '',
+ proxyFlag: false,
+ applyDate: dayjs().format('YYYY-MM-DD'),
+ },
false,
);
return;
@@ -140,9 +208,15 @@
status: 'done',
id: item.id,
}));
+ // 瀹為檯鐢宠浜轰笌褰撳墠鐧诲綍鐢ㄦ埛涓嶄竴鑷存椂锛岃涓轰唬浠栦汉鍙戣捣锛屽洖鏄剧敵璇蜂汉閫夋嫨鍣�
+ const isProxy =
+ formType.value === 'edit' &&
+ formData.value.applicantId != null &&
+ formData.value.applicantId !== currentUserId.value;
await formApi.setValues(
{
...formData.value,
+ proxyFlag: isProxy,
// 琛ㄥ崟閲岀殑 items 鍙敤浜庢彁浜わ紝蹇呴』鍓ユ帀琛� id锛堝悗绔�屽厛鍒犲悗澧炪�嶄細涓庤蒋鍒犺涓婚敭鍐茬獊锛�
items: toSubmitItems(formData.value.items),
blobIds,
@@ -170,6 +244,7 @@
:items="initialItems"
:disabled="formType === 'detail'"
class="w-full"
+ @ocr-blobs="handleOcrBlobs"
@update:items="handleUpdateItems"
@update:total-amount="handleUpdateTotalAmount"
/>
--
Gitblit v1.9.3