From 28c6a76ead9b65a0b5861d70f0838ef2a46f5c45 Mon Sep 17 00:00:00 2001
From: zhou zhou <zozhouo3o@gmail.com>
Date: 星期二, 14 四月 2026 10:58:10 +0800
Subject: [PATCH] #barcode

---
 rsf-design/src/views/basic-info/wh-mat/index.vue |  140 ++++++++++++++++++++++++++++------------------
 1 files changed, 85 insertions(+), 55 deletions(-)

diff --git a/rsf-design/src/views/basic-info/wh-mat/index.vue b/rsf-design/src/views/basic-info/wh-mat/index.vue
index 6d28ea1..ff0043a 100644
--- a/rsf-design/src/views/basic-info/wh-mat/index.vue
+++ b/rsf-design/src/views/basic-info/wh-mat/index.vue
@@ -155,21 +155,18 @@
                 <ElButton :loading="templateDownloading" @click="handleDownloadTemplate" v-ripple>
                   {{ t('pages.basicInfo.whMat.actions.downloadTemplate') }}
                 </ElButton>
-                <ListExportPrint
-                  class="inline-flex"
-                  :preview-visible="previewVisible"
-                  @update:previewVisible="handlePreviewVisibleChange"
-                  :report-title="reportTitle"
-                  :selected-rows="selectedRows"
-                  :query-params="reportQueryParams"
-                  :columns="columns"
-                  :preview-rows="previewRows"
-                  :preview-meta="resolvedPreviewMeta"
-                  :total="pagination.total"
-                  :disabled="loading"
-                  @export="handleExport"
-                  @print="handlePrint"
-                />
+                <ElButton :loading="exporting" :disabled="loading" @click="handleExport" v-ripple>
+                  {{ t('common.actions.export') }}
+                </ElButton>
+                <ElButton
+                  v-auth="'manager:matnrPrintTemplate:list'"
+                  :loading="printLoading"
+                  :disabled="loading || selectedRows.length === 0"
+                  @click="handlePrint()"
+                  v-ripple
+                >
+                  {{ t('common.actions.print') }}
+                </ElButton>
               </ElSpace>
             </template>
           </ArtTableHeader>
@@ -222,6 +219,8 @@
       :loading="detailLoading"
       :detail="detailData"
     />
+
+    <WhMatPrintDialog v-model:visible="printDialogVisible" :rows="printRows" />
   </div>
 </template>
 
@@ -229,7 +228,7 @@
   import { computed, onMounted, reactive, ref } from 'vue'
   import { ElMessage } from 'element-plus'
   import { useI18n } from 'vue-i18n'
-  import ListExportPrint from '@/components/biz/list-export-print/index.vue'
+  import { buildListExportPayload } from '@/components/biz/list-export-print/list-export-print.helpers.js'
   import { useAuth } from '@/hooks/core/useAuth'
   import { useTableColumns } from '@/hooks/core/useTableColumns'
   import { useUserStore } from '@/store/modules/user'
@@ -241,7 +240,6 @@
   import { defaultResponseAdapter } from '@/utils/table/tableUtils'
   import { guardRequestWithMessage } from '@/utils/sys/requestGuard'
   import { useCrudPage } from '@/views/system/common/useCrudPage'
-  import { usePrintExportPage } from '@/views/system/common/usePrintExportPage'
   import {
     fetchBatchUpdateMatnr,
     fetchBindMatnrGroup,
@@ -262,6 +260,7 @@
   import WhMatBindLocDialog from './modules/wh-mat-bind-loc-dialog.vue'
   import WhMatDialog from './modules/wh-mat-dialog.vue'
   import WhMatDetailDrawer from './modules/wh-mat-detail-drawer.vue'
+  import WhMatPrintDialog from './modules/wh-mat-print-dialog.vue'
   import { createWhMatTableColumns } from './whMatTable.columns'
   import {
     WH_MAT_REPORT_STYLE,
@@ -269,8 +268,6 @@
     buildMatnrGroupTreeQueryParams,
     buildMatnrPageQueryParams,
     buildWhMatDialogModel,
-    buildWhMatPrintRows,
-    buildWhMatReportMeta,
     buildWhMatSavePayload,
     createWhMatSearchState,
     getWhMatDynamicFieldKey,
@@ -292,6 +289,7 @@
   const { t } = useI18n()
   const { hasAuth } = useAuth()
   const userStore = useUserStore()
+  const canPrintMatnr = hasAuth('manager:matnrPrintTemplate:list')
 
   const showBatchActionButtons = false
   const loading = ref(false)
@@ -303,10 +301,14 @@
   const bindLocDialogVisible = ref(false)
   const bindLocOptionsLoading = ref(false)
   const importing = ref(false)
+  const exporting = ref(false)
+  const printLoading = ref(false)
+  const printDialogVisible = ref(false)
   const templateDownloading = ref(false)
   const tableData = ref([])
   const groupTreeData = ref([])
   const detailData = ref({})
+  const printRows = ref([])
   const enabledFields = ref([])
   const serialRuleOptions = ref([])
   const areaOptions = ref([])
@@ -643,7 +645,7 @@
       handleViewDetail: openDetailDrawer,
       handleEdit: hasAuth('update') ? openEditDialog : null,
       handleDelete: hasAuth('delete') ? (row) => handleDeleteAction?.(row) : null,
-      handlePrint: (row) => handlePrint({ ids: [row.id] }),
+      handlePrint: canPrintMatnr ? (row) => handlePrint({ ids: [row.id] }) : null,
       canEdit: hasAuth('update'),
       canDelete: hasAuth('delete'),
       t
@@ -1038,41 +1040,6 @@
     }
   }
 
-  const resolvePrintRecords = async (payload) => {
-    if (Array.isArray(payload?.ids) && payload.ids.length > 0) {
-      return defaultResponseAdapter(await fetchGetMatnrMany(payload.ids)).records
-    }
-    return tableData.value
-  }
-
-  const {
-    previewVisible,
-    previewRows,
-    previewMeta,
-    handlePreviewVisibleChange,
-    handleExport,
-    handlePrint
-  } = usePrintExportPage({
-    downloadFileName: 'matnr.xlsx',
-    requestExport: (payload) =>
-      fetchExportMatnrReport(payload, {
-        headers: {
-          Authorization: userStore.accessToken || ''
-        }
-      }),
-    resolvePrintRecords,
-    buildPreviewRows: (records) => buildWhMatPrintRows(records, t),
-    buildPreviewMeta
-  })
-
-  const resolvedPreviewMeta = computed(() =>
-    buildWhMatReportMeta({
-      previewMeta: previewMeta.value,
-      count: previewRows.value.length,
-      orientation: previewMeta.value?.reportStyle?.orientation || WH_MAT_REPORT_STYLE.orientation
-    })
-  )
-
   async function downloadFile(response, fallbackName) {
     if (!response?.ok) {
       throw new Error(
@@ -1169,6 +1136,69 @@
     }
   }
 
+  async function handleExport() {
+    exporting.value = true
+    try {
+      const payload = buildListExportPayload({
+        reportTitle,
+        selectedRows: selectedRows.value,
+        queryParams: reportQueryParams.value,
+        columns,
+        meta: buildPreviewMeta(tableData.value)
+      })
+      const response = await guardRequestWithMessage(
+        fetchExportMatnrReport(payload, {
+          headers: {
+            Authorization: userStore.accessToken || ''
+          }
+        }),
+        null,
+        {
+          timeoutMessage: t('message.exportTimeoutStopped')
+        }
+      )
+      if (!response) {
+        return
+      }
+      await downloadFile(response, 'matnr.xlsx')
+      ElMessage.success(t('crud.messages.exportSuccess'))
+    } catch (error) {
+      ElMessage.error(error?.message || t('crud.messages.exportFailed'))
+    } finally {
+      exporting.value = false
+    }
+  }
+
+  async function handlePrint(payload = {}) {
+    const ids =
+      Array.isArray(payload?.ids) && payload.ids.length > 0 ? payload.ids : getSelectedIds()
+
+    if (!ids.length) {
+      ElMessage.warning(t('pages.basicInfo.whMat.messages.selectAtLeastOne'))
+      return
+    }
+
+    printLoading.value = true
+    try {
+      const records = await guardRequestWithMessage(fetchGetMatnrMany(ids), [], {
+        timeoutMessage: t('message.printTimeoutStopped')
+      })
+      const normalizedRecords = defaultResponseAdapter(records).records
+      if (!normalizedRecords.length) {
+        ElMessage.warning(t('print.noData'))
+        return
+      }
+      printRows.value = normalizedRecords.map((record) =>
+        normalizeMatnrRow(record, t, enabledFields.value)
+      )
+      printDialogVisible.value = true
+    } catch (error) {
+      ElMessage.error(error?.message || t('crud.messages.printFailed'))
+    } finally {
+      printLoading.value = false
+    }
+  }
+
   async function handleDownloadTemplate() {
     templateDownloading.value = true
     try {

--
Gitblit v1.9.1