|
|
@@ -59,7 +59,7 @@
|
|
|
|
|
|
// API接口导入
|
|
|
import { addForecast, updateForecast, getForecastDetail } from '@/api/forecast'
|
|
|
-import { addSalesForecastMain, updateSalesForecastMain, getSalesForecastSummaryByMonth } from '@/api/forecast/forecast-summary'
|
|
|
+import { addSalesForecastMain, updateSalesForecastMain, getSalesForecastSummaryByMonth, exportSalesForecastTemplate } from '@/api/forecast/forecast-summary'
|
|
|
import { getUserLinkGoods } from '@/api/order/sales-order'
|
|
|
|
|
|
// 常量和枚举导入
|
|
|
@@ -212,6 +212,9 @@ export default {
|
|
|
/** 表单加载状态 */
|
|
|
formLoading: false,
|
|
|
|
|
|
+ /** 模板下载加载状态 */
|
|
|
+ templateLoading: false,
|
|
|
+
|
|
|
/** 客户选项列表
|
|
|
* @type {Array<CustomerOption>}
|
|
|
*/
|
|
|
@@ -1317,6 +1320,44 @@ export default {
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
+ * 下载销售预测模板
|
|
|
+ * @returns {Promise<void>}
|
|
|
+ * @this {ForecastFormMixinComponent & Vue}
|
|
|
+ */
|
|
|
+ async handleDownloadTemplate() {
|
|
|
+ try {
|
|
|
+ this.templateLoading = true
|
|
|
+
|
|
|
+ const res = await exportSalesForecastTemplate()
|
|
|
+
|
|
|
+ // 处理文件名:优先取响应头,其次回退默认名
|
|
|
+ const disposition = res?.headers?.['content-disposition'] || res?.headers?.['Content-Disposition']
|
|
|
+ let filename = '销售预测模板.xlsx'
|
|
|
+ if (disposition) {
|
|
|
+ const utf8Match = /filename\*=UTF-8''([^;\n]+)/i.exec(disposition)
|
|
|
+ const plainMatch = /filename="?([^;\n"]+)"?/i.exec(disposition)
|
|
|
+ const raw = utf8Match ? decodeURIComponent(utf8Match[1]) : (plainMatch ? plainMatch[1] : '')
|
|
|
+ if (raw) filename = raw
|
|
|
+ }
|
|
|
+
|
|
|
+ const blob = new Blob([res.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
|
|
|
+ const url = window.URL.createObjectURL(blob)
|
|
|
+ const a = document.createElement('a')
|
|
|
+ a.href = url
|
|
|
+ a.download = filename
|
|
|
+ document.body.appendChild(a)
|
|
|
+ a.click()
|
|
|
+ document.body.removeChild(a)
|
|
|
+ window.URL.revokeObjectURL(url)
|
|
|
+ } catch (e) {
|
|
|
+ console.error('下载模板失败:', e)
|
|
|
+ this.$message && this.$message.error('下载模板失败,请稍后重试')
|
|
|
+ } finally {
|
|
|
+ this.templateLoading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
* 导入所选物料到下方表格
|
|
|
* @description 仅在点击"导入物料"按钮后,将选择的物料行添加到表格,默认预测数量为 1
|
|
|
* @returns {void}
|
|
|
@@ -1381,7 +1422,7 @@ export default {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- await this.$confirm('确认删除该物料吗?删除后可重新通过上方选择器导入。', '提示', {
|
|
|
+ await this.$confirm('确认删除该物料吗?', '提示', {
|
|
|
type: 'warning',
|
|
|
confirmButtonText: '删除',
|
|
|
cancelButtonText: '取消'
|
|
|
@@ -1504,7 +1545,7 @@ export default {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- await this.$confirm('确认删除已选中的物料吗?删除后可重新通过上方选择器导入。', '提示', {
|
|
|
+ await this.$confirm('确认删除已选中的物料吗?', '提示', {
|
|
|
type: 'warning',
|
|
|
confirmButtonText: '删除',
|
|
|
cancelButtonText: '取消'
|
|
|
@@ -1734,4 +1775,3 @@ export default {
|
|
|
},
|
|
|
}
|
|
|
}
|
|
|
-
|