|
@@ -1,8 +1,29 @@
|
|
|
+// @ts-check
|
|
|
+
|
|
|
/**
|
|
|
* @fileoverview 销售预测表单混入组件
|
|
|
* @description 提供销售预测表单的数据管理、验证规则和业务逻辑的混入组件,支持新增和编辑模式
|
|
|
*/
|
|
|
|
|
|
+/**
|
|
|
+ * 销售预测表单混入组件实例类型定义
|
|
|
+ * @typedef {object} ForecastFormMixinComponent
|
|
|
+ * @property {import('./types').ForecastFormModel} formData - 表单数据
|
|
|
+ * @property {import('./types').FormOption} formOption - 表单配置选项
|
|
|
+ * @property {boolean} saveLoading - 保存加载状态
|
|
|
+ * @property {import('./types').CustomerOption[]} customerOptions - 客户选项列表
|
|
|
+ * @property {import('./types').ItemOption[]} itemOptions - 物料选项列表
|
|
|
+ * @property {number|null} currentInventory - 当前库存数量
|
|
|
+ * @property {import('./types').ApprovalStatusOption[]} approvalStatusOptions - 审批状态选项
|
|
|
+ * @property {import('./types').ForecastFormRules} formRules - 表单验证规则
|
|
|
+ * @property {boolean} visible - 表单可见性
|
|
|
+ * @property {boolean} isEdit - 是否为编辑模式
|
|
|
+ * @property {Object|null} editData - 编辑数据
|
|
|
+ * @property {Object|null} initialFormData - 初始表单数据
|
|
|
+ * @property {string} title - 表单标题
|
|
|
+ * @property {string} forecastId - 预测ID
|
|
|
+ */
|
|
|
+
|
|
|
// API接口导入
|
|
|
import { addForecast, updateForecast, getForecastDetail } from '@/api/forecast'
|
|
|
|
|
@@ -182,6 +203,7 @@ export default {
|
|
|
/**
|
|
|
* 表单标题
|
|
|
* @description 根据编辑模式动态显示表单标题
|
|
|
+ * @this {ForecastFormMixinComponent & Vue}
|
|
|
* @returns {string} 表单标题文本
|
|
|
*/
|
|
|
formTitle() {
|
|
@@ -199,6 +221,7 @@ export default {
|
|
|
watch: {
|
|
|
/**
|
|
|
* 监听表单可见性变化
|
|
|
+ * @this {ForecastFormMixinComponent & Vue}
|
|
|
* @param {boolean} val - 新的可见性值
|
|
|
*/
|
|
|
visible(val) {
|
|
@@ -226,6 +249,7 @@ export default {
|
|
|
|
|
|
/**
|
|
|
* 监听初始表单数据变化
|
|
|
+ * @this {ForecastFormMixinComponent & Vue}
|
|
|
* @param {Object} val - 新的初始表单数据
|
|
|
*/
|
|
|
initialFormData(val) {
|
|
@@ -236,6 +260,7 @@ export default {
|
|
|
|
|
|
/**
|
|
|
* 监听预测ID变化
|
|
|
+ * @this {ForecastFormMixinComponent & Vue}
|
|
|
* @param {string|number} val - 新的预测ID
|
|
|
*/
|
|
|
forecastId: {
|
|
@@ -256,6 +281,7 @@ export default {
|
|
|
/**
|
|
|
* 创建初始表单数据
|
|
|
* @description 创建销售预测表单的初始数据结构
|
|
|
+ * @this {ForecastFormMixinComponent & Vue}
|
|
|
* @returns {Object} 初始化的表单数据对象
|
|
|
* @private
|
|
|
*/
|
|
@@ -266,6 +292,7 @@ export default {
|
|
|
/**
|
|
|
* 清理和格式化表单数据
|
|
|
* @description 对表单数据进行清理和格式化处理
|
|
|
+ * @this {ForecastFormMixinComponent & Vue}
|
|
|
* @param {Object} data - 原始表单数据
|
|
|
* @returns {Object} 清理和格式化后的表单数据
|
|
|
* @private
|
|
@@ -315,6 +342,7 @@ export default {
|
|
|
/**
|
|
|
* 加载销售预测详情
|
|
|
* @description 根据ID加载销售预测详情数据
|
|
|
+ * @this {ForecastFormMixinComponent & Vue}
|
|
|
* @param {string|number} id - 销售预测ID
|
|
|
* @returns {Promise<void>}
|
|
|
* @private
|
|
@@ -356,6 +384,7 @@ export default {
|
|
|
/**
|
|
|
* 加载单个客户选项
|
|
|
* @description 为编辑模式加载特定客户的选项数据
|
|
|
+ * @this {ForecastFormMixinComponent & Vue}
|
|
|
* @param {string|number} customerId - 客户ID
|
|
|
* @param {string} customerName - 客户名称
|
|
|
* @returns {Promise<void>}
|
|
@@ -375,6 +404,7 @@ export default {
|
|
|
/**
|
|
|
* 远程搜索客户
|
|
|
* @description 根据关键字远程搜索客户数据
|
|
|
+ * @this {ForecastFormMixinComponent & Vue}
|
|
|
* @param {string} query - 搜索关键字
|
|
|
* @returns {Promise<void>}
|
|
|
*/
|
|
@@ -410,6 +440,7 @@ export default {
|
|
|
/**
|
|
|
* 加载单个物料选项
|
|
|
* @description 为编辑模式加载特定物料的选项数据
|
|
|
+ * @this {ForecastFormMixinComponent & Vue}
|
|
|
* @param {string|number} itemId - 物料ID
|
|
|
* @param {string} itemName - 物料名称
|
|
|
* @param {string} itemCode - 物料编码
|
|
@@ -439,6 +470,7 @@ export default {
|
|
|
/**
|
|
|
* 远程搜索物料
|
|
|
* @description 根据关键字远程搜索物料数据
|
|
|
+ * @this {ForecastFormMixinComponent & Vue}
|
|
|
* @param {string} query - 搜索关键字
|
|
|
* @returns {Promise<void>}
|
|
|
*/
|
|
@@ -475,6 +507,7 @@ export default {
|
|
|
/**
|
|
|
* 客户选择变化处理
|
|
|
* @description 处理客户选择变化,更新表单中的客户相关字段
|
|
|
+ * @this {ForecastFormMixinComponent & Vue}
|
|
|
* @param {string|number} customerId - 客户ID
|
|
|
* @returns {void}
|
|
|
*/
|
|
@@ -493,6 +526,7 @@ export default {
|
|
|
/**
|
|
|
* 物料选择变化处理
|
|
|
* @description 处理物料选择变化,更新表单中的物料相关字段
|
|
|
+ * @this {ForecastFormMixinComponent & Vue}
|
|
|
* @param {string|number} itemId - 物料ID
|
|
|
* @returns {void}
|
|
|
*/
|
|
@@ -512,6 +546,7 @@ export default {
|
|
|
/**
|
|
|
* 生成预测编码
|
|
|
* @description 自动生成销售预测编码
|
|
|
+ * @this {ForecastFormMixinComponent & Vue}
|
|
|
* @returns {void}
|
|
|
*/
|
|
|
generateForecastCode() {
|
|
@@ -525,6 +560,7 @@ export default {
|
|
|
/**
|
|
|
* 表单提交
|
|
|
* @description 提交表单数据,根据编辑模式调用不同的API
|
|
|
+ * @this {ForecastFormMixinComponent & Vue}
|
|
|
* @returns {Promise<void>}
|
|
|
*/
|
|
|
async submitForm() {
|
|
@@ -568,6 +604,7 @@ export default {
|
|
|
/**
|
|
|
* 准备提交数据
|
|
|
* @description 复制表单数据并进行清理和格式化处理
|
|
|
+ * @this {ForecastFormMixinComponent & Vue}
|
|
|
* @returns {Object} 准备好的提交数据
|
|
|
* @private
|
|
|
*/
|
|
@@ -594,6 +631,7 @@ export default {
|
|
|
/**
|
|
|
* 关闭表单
|
|
|
* @description 关闭表单并重置数据
|
|
|
+ * @this {ForecastFormMixinComponent & Vue}
|
|
|
* @returns {void}
|
|
|
*/
|
|
|
closeForm() {
|