|
@@ -71,7 +71,7 @@ import {
|
|
|
} from '@/constants/forecast'
|
|
|
|
|
|
// 远程搜索API
|
|
|
-import { getCustomerList, getItemList } from '@/api/common'
|
|
|
+import { getCustomerList, getItemList, getCustomerInfo } from '@/api/common'
|
|
|
|
|
|
// 表单配置导入
|
|
|
import { getFormOption } from './form-option'
|
|
@@ -305,6 +305,11 @@ export default {
|
|
|
if (!this.isEdit && !this.formData.forecastCode) {
|
|
|
this.generateForecastCode()
|
|
|
}
|
|
|
+
|
|
|
+ // 新增模式下,自动获取并填充客户信息
|
|
|
+ if (!this.isEdit) {
|
|
|
+ this.loadCurrentCustomerInfo()
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
},
|
|
@@ -578,6 +583,26 @@ export default {
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
+ * 加载当前登录客户信息并填充表单
|
|
|
+ * @returns {Promise<void>}
|
|
|
+ */
|
|
|
+ async loadCurrentCustomerInfo() {
|
|
|
+ try {
|
|
|
+ const response = await getCustomerInfo()
|
|
|
+ const ok = response && response.data && response.data.success
|
|
|
+ const data = ok ? response.data.data : null
|
|
|
+ if (ok && data) {
|
|
|
+ // 根据接口common.d.ts中的CustomerInfoData结构进行赋值
|
|
|
+ this.formData.customerId = data.Customer_ID ? Number(data.Customer_ID) : null
|
|
|
+ this.formData.customerCode = data.Customer_CODE || ''
|
|
|
+ this.formData.customerName = data.Customer_NAME || ''
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.error('获取客户信息失败:', e)
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
* 加载单个物料选项(用于编辑时显示)
|
|
|
* @param {string|number} itemId - 物料ID
|
|
|
* @param {string} itemName - 物料名称
|