chenlu
2025-11-28 189add7a28d273861f9e54c81fb0330da4327ca0
north-glass-erp/northglass-erp/src/views/pp/replenish/SelectReplenish.vue
@@ -190,6 +190,10 @@
        'code':'cancelReview'
      }
    ],
    slots: {
      tools: 'toolbar_buttons',
      buttons:'buttons'
    },
    /*import: false,
    export: true,
    print: true,*/
@@ -362,8 +366,53 @@
  reserve:true
}
const exportEvent = () => {
  const $table = xGrid.value
  if ($table) {
    $table.exportData({
      filename: 'order_export',
      sheetName: 'Sheet1',
      type: 'xlsx'
    })
  }
}
function exportExcel(url, fileName,date) {
  gridOptions.loading = true
  if(date===null){
    ElMessage.warning(t('report.pleaseSelectADateFirst'))
    return
  }
  const date1 = new Date(date[0]);
  const date2 = new Date(date[1]);
  const timeDiff = Math.abs(date2.getTime() - date1.getTime());
  const daysDiff = timeDiff / (1000 * 3600 * 24);
  if(Math.floor(daysDiff)>180){
    ElMessage.warning(t('report.theFilteringTimeForExportCannotExceed180Days'))
    return
  }
  let dataMp = ref({
    date: date,
  })
  request.post(url,date,{responseType :'blob'}).then(res => {
    const blob = new Blob([res])
    if ('download' in document.createElement('a')) { // 非IE下载
      const elink = document.createElement('a')
      elink.download = `${fileName}.xlsx`
      elink.style.display = 'none'
      elink.href = URL.createObjectURL(blob)
      document.body.appendChild(elink)
      elink.click()
      URL.revokeObjectURL(elink.href) // 释放URL 对象
      document.body.removeChild(elink)
      gridOptions.loading = false
    } else { // IE10+下载
      navigator.msSaveBlob(blob, fileName)
    }
  })
}
</script>
<template>
@@ -444,7 +493,18 @@
          >
          </vxe-pager>
        </template>
        <template #toolbar_buttons>
          <vxe-button icon="vxe-icon-download" circle
                      style="margin-right: 0.5rem"
                      @click="exportEvent" />
          <vxe-button icon="vxe-icon-cloud-download" style="margin-right: 0.5rem"
                      circle
                      @click="exportExcel('/Replenish/exportReplenish',
                                          t('replenish.patchManagement'),
                                          selectDate)" />
        </template>
      </vxe-grid>
    </div>