|
@@ -12,7 +12,7 @@ import {
|
|
|
DEFAULT_FORECAST_FORM
|
|
|
} from '@/constants/forecast'
|
|
|
import { mapGetters } from 'vuex'
|
|
|
-import ForecastFormAvue from '@/components/forecast-form/index.vue'
|
|
|
+import ForecastFormAvue from '@/components/forecast-form/index'
|
|
|
|
|
|
/**
|
|
|
* @typedef {import('@/api/forecast/types').ForecastRecord} ForecastRecord
|
|
@@ -21,6 +21,8 @@ import ForecastFormAvue from '@/components/forecast-form/index.vue'
|
|
|
* @typedef {import('./types').ItemOption} ItemOption
|
|
|
* @typedef {import('./types').PageConfig} PageConfig
|
|
|
* @typedef {import('./types').ForecastComponent} ForecastComponent
|
|
|
+ * @typedef {import('@/api/forecast/types').ForecastForm} ForecastFormModel
|
|
|
+ * @typedef {import('@/api/forecast/types').ForecastRecord} ForecastItem
|
|
|
*/
|
|
|
|
|
|
/**
|
|
@@ -35,9 +37,7 @@ export default {
|
|
|
components: {
|
|
|
ForecastFormAvue
|
|
|
},
|
|
|
- /**
|
|
|
- * @returns {{form: ForecastFormModel, query: Record<string, any>, loading: boolean, submitting: boolean, saveLoading: boolean, dialogVisible: boolean, isEdit: boolean, editVisible: boolean, editMode: string, editTitle: string, currentForecastId: string|number|null, page: {pageSize: number, currentPage: number, total: number}, data: ForecastItem[], customerOptions: CustomerOption[], customerLoading: boolean, itemOptions: ItemOption[], itemLoading: boolean, option: AvueCrudOption, formRules: Record<string, FormItemRule[]>}}
|
|
|
- */
|
|
|
+
|
|
|
data() {
|
|
|
return {
|
|
|
/** @type {ForecastForm} 表单数据 */
|
|
@@ -56,7 +56,7 @@ export default {
|
|
|
isEdit: false,
|
|
|
/** @type {boolean} 表单页面显示状态 */
|
|
|
editVisible: false,
|
|
|
- /** @type {string} 表单模式:'add' | 'edit' | 'view' */
|
|
|
+ /** @type {'add'|'edit'|'view'} 表单模式:'add' | 'edit' | 'view' */
|
|
|
editMode: 'add',
|
|
|
/** @type {string} 表单标题 */
|
|
|
editTitle: '',
|
|
@@ -254,6 +254,7 @@ export default {
|
|
|
|
|
|
/**
|
|
|
* 权限配置
|
|
|
+ * @this {Vue & ForecastComponent}
|
|
|
* @returns {{addBtn: boolean, viewBtn: boolean, delBtn: boolean, editBtn: boolean}} 权限配置对象
|
|
|
*/
|
|
|
permissionList() {
|
|
@@ -271,6 +272,7 @@ export default {
|
|
|
|
|
|
/**
|
|
|
* 弹窗标题
|
|
|
+ * @this {Vue & ForecastComponent}
|
|
|
* @returns {string} 弹窗标题文本
|
|
|
*/
|
|
|
dialogTitle() {
|
|
@@ -278,6 +280,10 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ /**
|
|
|
+ * 组件创建时初始化
|
|
|
+ * @this {Vue & ForecastComponent}
|
|
|
+ */
|
|
|
created() {
|
|
|
this.loadCustomerOptions()
|
|
|
this.loadItemOptions()
|
|
@@ -295,8 +301,9 @@ export default {
|
|
|
const res = await getCustomerList(1, 20)
|
|
|
if (res.data && res.data.success) {
|
|
|
this.customerOptions = res.data.data.records.map(item => ({
|
|
|
- value: item.Customer_ID.toString(),
|
|
|
+ value: parseInt(item.Customer_ID.toString()),
|
|
|
label: item.Customer_NAME,
|
|
|
+ customerId: parseInt(item.Customer_ID.toString()),
|
|
|
customerCode: item.Customer_CODE,
|
|
|
customerName: item.Customer_NAME
|
|
|
}))
|
|
@@ -323,13 +330,18 @@ export default {
|
|
|
|
|
|
try {
|
|
|
this.customerLoading = true
|
|
|
- const res = await getCustomerList(1, 50, {
|
|
|
- Customer_NAME: query
|
|
|
- })
|
|
|
+ /** @type {import('@/api/types/common').CustomerQueryParams} */
|
|
|
+ const params = {
|
|
|
+ customerName: query,
|
|
|
+ current: 1,
|
|
|
+ size: 50
|
|
|
+ }
|
|
|
+ const res = await getCustomerList(1, 50, params)
|
|
|
if (res.data && res.data.success) {
|
|
|
this.customerOptions = res.data.data.records.map(item => ({
|
|
|
- value: item.Customer_ID.toString(),
|
|
|
+ value: parseInt(item.Customer_ID.toString()),
|
|
|
label: item.Customer_NAME,
|
|
|
+ customerId: parseInt(item.Customer_ID.toString()),
|
|
|
customerCode: item.Customer_CODE,
|
|
|
customerName: item.Customer_NAME
|
|
|
}))
|
|
@@ -343,13 +355,14 @@ export default {
|
|
|
|
|
|
/**
|
|
|
* 客户选择变化处理
|
|
|
+ * @this {Vue & ForecastComponent}
|
|
|
* @param {number} customerId - 客户ID
|
|
|
* @returns {void}
|
|
|
*/
|
|
|
handleCustomerChange(customerId) {
|
|
|
const customer = this.customerOptions.find(item => item.value === customerId)
|
|
|
if (customer) {
|
|
|
- this.form.customerId = customer.value.toString()
|
|
|
+ this.form.customerId = customer.value
|
|
|
this.form.customerCode = customer.customerCode
|
|
|
this.form.customerName = customer.customerName
|
|
|
}
|
|
@@ -357,7 +370,7 @@ export default {
|
|
|
|
|
|
/**
|
|
|
* 加载物料选项
|
|
|
- * @this {Vue & {itemLoading: boolean, itemOptions: Array<ItemOption>, $message: any}}
|
|
|
+ * @this {Vue & ForecastComponent}
|
|
|
* @returns {Promise<void>}
|
|
|
*/
|
|
|
async loadItemOptions() {
|
|
@@ -384,7 +397,7 @@ export default {
|
|
|
|
|
|
/**
|
|
|
* 远程搜索物料
|
|
|
- * @this {Vue & {itemLoading: boolean, itemOptions: Array<ItemOption>, loadItemOptions: () => Promise<void>}}
|
|
|
+ * @this {Vue & ForecastComponent}
|
|
|
* @param {string} query - 搜索关键词
|
|
|
* @returns {Promise<void>}
|
|
|
*/
|
|
@@ -418,7 +431,7 @@ export default {
|
|
|
|
|
|
/**
|
|
|
* 物料选择变化处理
|
|
|
- * @this {Vue & {itemOptions: Array<ItemOption>, form: ForecastForm}}
|
|
|
+ * @this {Vue & ForecastComponent}
|
|
|
* @param {number} itemId - 物料ID
|
|
|
* @returns {void}
|
|
|
*/
|
|
@@ -448,11 +461,11 @@ export default {
|
|
|
|
|
|
/**
|
|
|
* 检查是否可以编辑
|
|
|
- * @param {ForecastRecord} row - 行数据
|
|
|
+ * @param {ForecastRecord|ForecastItem} row - 行数据
|
|
|
* @returns {boolean} 是否可以编辑
|
|
|
*/
|
|
|
canEditRow(row) {
|
|
|
- return canEdit(row.approvalStatus)
|
|
|
+ return row.approvalStatus !== undefined ? canEdit(row.approvalStatus) : false
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -564,13 +577,13 @@ export default {
|
|
|
this.editTitle = '新增预测申报'
|
|
|
this.currentForecastId = null
|
|
|
this.editVisible = true
|
|
|
-
|
|
|
+
|
|
|
// 重置表单数据
|
|
|
this.form = { ...DEFAULT_FORECAST_FORM }
|
|
|
-
|
|
|
+
|
|
|
// 生成预测编码
|
|
|
this.generateForecastCode()
|
|
|
-
|
|
|
+
|
|
|
// 保持兼容性
|
|
|
this.isEdit = false
|
|
|
this.dialogVisible = true
|
|
@@ -613,10 +626,10 @@ export default {
|
|
|
this.editTitle = '编辑预测申报'
|
|
|
this.currentForecastId = row.id
|
|
|
this.editVisible = true
|
|
|
-
|
|
|
+
|
|
|
// 设置表单数据
|
|
|
this.form = { ...row }
|
|
|
-
|
|
|
+
|
|
|
// 保持兼容性
|
|
|
this.isEdit = true
|
|
|
this.dialogVisible = true
|
|
@@ -634,7 +647,7 @@ export default {
|
|
|
this.editTitle = ''
|
|
|
this.currentForecastId = null
|
|
|
this.form = { ...DEFAULT_FORECAST_FORM }
|
|
|
-
|
|
|
+
|
|
|
// 保持兼容性
|
|
|
this.dialogVisible = false
|
|
|
this.isEdit = false
|