From 27c8277d717b34b55f3ea967027b53b067f77df3 Mon Sep 17 00:00:00 2001
From: xiaoyi <908147524@qq.com>
Date: 星期四, 20 八月 2026 16:58:49 +0800
Subject: [PATCH] feat 功能变更

---
 src/views/wls/stocktaking/task/index.vue |   63 +++++++++++++++++++++++++++++++
 1 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/src/views/wls/stocktaking/task/index.vue b/src/views/wls/stocktaking/task/index.vue
index 4ffefe8..c38699d 100644
--- a/src/views/wls/stocktaking/task/index.vue
+++ b/src/views/wls/stocktaking/task/index.vue
@@ -2,6 +2,8 @@
 import type { VxeTableGridOptions } from '#/adapter/vxe-table';
 import type { MesWmStockTakingTaskApi } from '#/api/mes/wm/stocktaking/task';
 
+import { ref } from 'vue';
+
 import { Page, useVbenModal } from '@vben/common-ui';
 import { MesWmStockTakingTaskStatusEnum } from '@vben/constants';
 import { downloadFileFromBlobPart } from '@vben/utils';
@@ -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