|
|
@@ -59,7 +59,7 @@
|
|
|
|
|
|
// API接口导入
|
|
|
import { addForecast, updateForecast, getForecastDetail } from '@/api/forecast'
|
|
|
-import { addSalesForecastMain, updateSalesForecastMain, getSalesForecastSummaryByMonth, exportSalesForecastTemplate, exportSalesForecastSummaryByYearMonth } from '@/api/forecast/forecast-summary'
|
|
|
+import { addSalesForecastMain, updateSalesForecastMain, getSalesForecastSummaryByMonth, exportSalesForecastTemplate, exportSalesForecastSummaryByYearMonth, importSalesForecastSummaryById } from '@/api/forecast/forecast-summary'
|
|
|
import { getUserLinkGoods } from '@/api/order/sales-order'
|
|
|
|
|
|
// 常量和枚举导入
|
|
|
@@ -216,6 +216,8 @@ export default {
|
|
|
templateLoading: false,
|
|
|
/** 数据下载加载状态 */
|
|
|
dataExportLoading: false,
|
|
|
+ /** 导入加载状态 */
|
|
|
+ importLoading: false,
|
|
|
|
|
|
/** 客户选项列表
|
|
|
* @type {Array<CustomerOption>}
|
|
|
@@ -1360,6 +1362,74 @@ export default {
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
+ * 点击导入按钮
|
|
|
+ * @returns {void}
|
|
|
+ * @this {ForecastFormMixinComponent & Vue}
|
|
|
+ */
|
|
|
+ handleImportClick() {
|
|
|
+ if (!this.isEdit || !this.formData.id) {
|
|
|
+ this.$message && this.$message.warning('当前记录未保存,无法导入')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const input = this.$refs && this.$refs.importInput
|
|
|
+ if (input && input.click) {
|
|
|
+ input.value = ''
|
|
|
+ input.click()
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理导入文件选择
|
|
|
+ * @param {Event} event
|
|
|
+ * @returns {Promise<void>}
|
|
|
+ * @this {ForecastFormMixinComponent & Vue}
|
|
|
+ */
|
|
|
+ async handleImportFile(event) {
|
|
|
+ const target = event && event.target
|
|
|
+ const file = target && target.files ? target.files[0] : null
|
|
|
+ if (!file) return
|
|
|
+ if (!this.formData.id) {
|
|
|
+ this.$message && this.$message.warning('未获取到当前记录ID')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ this.importLoading = true
|
|
|
+ const res = await importSalesForecastSummaryById(this.formData.id, file)
|
|
|
+ const list = res && res.data && res.data.data ? res.data.data : []
|
|
|
+ if (!Array.isArray(list)) {
|
|
|
+ this.$message && this.$message.warning('导入数据格式异常')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ this.stockTableData = list.map(item => ({
|
|
|
+ id: item.id ? safeBigInt(item.id) : undefined,
|
|
|
+ goodsId: item.itemId ? safeBigInt(item.itemId) : undefined,
|
|
|
+ code: item.itemCode || '',
|
|
|
+ cname: item.itemName || '',
|
|
|
+ brandId: item.brandId ? safeBigInt(item.brandId) : undefined,
|
|
|
+ brandCode: item.brandCode || '',
|
|
|
+ brandName: item.brandName || '',
|
|
|
+ typeNo: item.specs || '',
|
|
|
+ productDescription: item.pattern || '',
|
|
|
+ brandItem: item.pattern || '',
|
|
|
+ storeInventory: undefined,
|
|
|
+ forecastQuantity: Number(item.forecastQuantity || 0)
|
|
|
+ }))
|
|
|
+
|
|
|
+ this.selectedRowKeys = []
|
|
|
+ this.updateStockSelectOptions && this.updateStockSelectOptions()
|
|
|
+ this.normalizePageAfterMutations && this.normalizePageAfterMutations()
|
|
|
+ this.$message && this.$message.success('导入成功')
|
|
|
+ } catch (e) {
|
|
|
+ console.error('导入失败:', e)
|
|
|
+ this.$message && this.$message.error('导入失败,请稍后重试')
|
|
|
+ } finally {
|
|
|
+ this.importLoading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
* 下载销售预测数据(按年月)
|
|
|
* @returns {Promise<void>}
|
|
|
* @this {ForecastFormMixinComponent & Vue}
|