From 5c243d9d05da668a32b1bc9a4f543ea081488d11 Mon Sep 17 00:00:00 2001
From: xiaoyi <908147524@qq.com>
Date: 星期四, 20 八月 2026 14:08:03 +0800
Subject: [PATCH] feat 功能变更
---
src/views/wls/stocktaking/task/index.vue | 69 +++++++++++++++++++++++++++++++++-
1 files changed, 66 insertions(+), 3 deletions(-)
diff --git a/src/views/wls/stocktaking/task/index.vue b/src/views/wls/stocktaking/task/index.vue
index 472ed33..c38699d 100644
--- a/src/views/wls/stocktaking/task/index.vue
+++ b/src/views/wls/stocktaking/task/index.vue
@@ -2,9 +2,11 @@
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MesWmStockTakingTaskApi } from '#/api/mes/wm/stocktaking/task';
-import { Page, useVbenModal } from '../../../../packages/effects/common-ui/src';
-import { MesWmStockTakingTaskStatusEnum } from '../../../../packages/constants/src';
-import { downloadFileFromBlobPart } from '../../../../packages/utils/src';
+import { ref } from 'vue';
+
+import { Page, useVbenModal } from '@vben/common-ui';
+import { MesWmStockTakingTaskStatusEnum } from '@vben/constants';
+import { downloadFileFromBlobPart } from '@vben/utils';
import { Button, message } from 'ant-design-vue';
@@ -15,6 +17,10 @@
exportStockTaking,
getStockTakingPage,
} from '#/api/mes/wm/stocktaking/task';
+import {
+ importStockTakingQuantity,
+ importStockTakingQuantityTemplate,
+} from '#/api/wls/stocktaking/task/line';
import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data';
@@ -83,6 +89,41 @@
downloadFileFromBlobPart({ fileName: '鐩樼偣浠诲姟.xls', source: data });
}
+/** 涓嬭浇鐩樼偣瀵煎叆妯℃澘 */
+async function handleImportTemplate() {
+ const data = await importStockTakingQuantityTemplate();
+ downloadFileFromBlobPart({ fileName: '鐩樼偣瀹炵洏鏁板鍏ユā鏉�.xls', source: data });
+}
+
+const importFileRef = ref<HTMLInputElement>();
+const importTaskId = ref<number>();
+
+/** 瑙﹀彂瀵煎叆鏂囦欢閫夋嫨 */
+function handleImport(row: MesWmStockTakingTaskApi.StockTakingTask) {
+ importTaskId.value = row.id!;
+ importFileRef.value?.click();
+}
+
+/** 瀵煎叆瀹炵洏鏁版枃浠堕�夋嫨鍚庝笂浼� */
+async function handleImportFileChange(event: Event) {
+ const file = (event.target as HTMLInputElement).files?.[0];
+ if (!file || !importTaskId.value) {
+ return;
+ }
+ const hideLoading = message.loading({ content: '姝e湪瀵煎叆瀹炵洏鏁�...', duration: 0 });
+ try {
+ const result = await importStockTakingQuantity(importTaskId.value, file);
+ message.success(`瀵煎叆瀹屾垚锛氭垚鍔� ${result.successCount ?? 0} 鏉★紝澶辫触 ${result.failureCount ?? 0} 鏉);
+ if (result.failureMessages?.length) {
+ message.warning(result.failureMessages.slice(0, 5).join('锛�'));
+ }
+ handleRefresh();
+ } finally {
+ (event.target as HTMLInputElement).value = '';
+ hideLoading();
+ }
+}
+
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
@@ -137,6 +178,13 @@
auth: ['mes:wm-stock-taking-task:export'],
onClick: handleExport,
},
+ {
+ label: '瀵煎叆妯℃澘',
+ type: 'primary',
+ icon: ACTION_ICON.DOWNLOAD,
+ auth: ['mes:wm-stock-taking-task:query'],
+ onClick: handleImportTemplate,
+ },
]"
/>
</template>
@@ -183,6 +231,14 @@
onClick: handleExecute.bind(null, row),
},
{
+ label: '瀵煎叆瀹炵洏鏁�',
+ type: 'link',
+ icon: ACTION_ICON.UPLOAD,
+ auth: ['mes:wm-stock-taking-task:update'],
+ ifShow: row.status === StatusEnum.APPROVING,
+ onClick: handleImport.bind(null, row),
+ },
+ {
label: '鍙栨秷',
type: 'link',
danger: true,
@@ -197,5 +253,12 @@
/>
</template>
</Grid>
+ <input
+ ref="importFileRef"
+ class="hidden"
+ type="file"
+ accept=".xls,.xlsx"
+ @change="handleImportFileChange"
+ />
</Page>
</template>
--
Gitblit v1.9.3