|
@@ -1,4 +1,5 @@
|
|
import { getForecastList, updateForecast } from '@/api/forecast'
|
|
import { getForecastList, updateForecast } from '@/api/forecast'
|
|
|
|
+import { approveForecastSummary } from '@/api/forecast/forecast-summary'
|
|
import { mapGetters } from 'vuex'
|
|
import { mapGetters } from 'vuex'
|
|
import {
|
|
import {
|
|
APPROVAL_STATUS,
|
|
APPROVAL_STATUS,
|
|
@@ -74,16 +75,12 @@ export default {
|
|
dialogClickModal: false,
|
|
dialogClickModal: false,
|
|
menu: true,
|
|
menu: true,
|
|
menuWidth: 280,
|
|
menuWidth: 280,
|
|
|
|
+ // 行展开配置,展示子表明细
|
|
|
|
+ expand: true,
|
|
|
|
+ expandRowKeys: [],
|
|
|
|
+ defaultExpandAll: false,
|
|
column: [
|
|
column: [
|
|
{
|
|
{
|
|
- label: '预测编码',
|
|
|
|
- prop: 'forecastCode',
|
|
|
|
- search: true,
|
|
|
|
- searchSpan: 6,
|
|
|
|
- width: 150,
|
|
|
|
- overHidden: true
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
label: '年份',
|
|
label: '年份',
|
|
prop: 'year',
|
|
prop: 'year',
|
|
type: 'year',
|
|
type: 'year',
|
|
@@ -115,67 +112,22 @@ export default {
|
|
width: 100
|
|
width: 100
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- label: '客户名称',
|
|
|
|
- prop: 'customerName',
|
|
|
|
- search: true,
|
|
|
|
- searchSpan: 6,
|
|
|
|
- width: 180,
|
|
|
|
- overHidden: true
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
label: '客户编码',
|
|
label: '客户编码',
|
|
prop: 'customerCode',
|
|
prop: 'customerCode',
|
|
- search: false,
|
|
|
|
- width: 150,
|
|
|
|
- overHidden: true
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: '品牌名称',
|
|
|
|
- prop: 'brandName',
|
|
|
|
- search: false,
|
|
|
|
- width: 120,
|
|
|
|
- overHidden: true
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: '物料名称',
|
|
|
|
- prop: 'itemName',
|
|
|
|
- search: false,
|
|
|
|
- width: 200,
|
|
|
|
- overHidden: true
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: '物料编码',
|
|
|
|
- prop: 'itemCode',
|
|
|
|
- search: false,
|
|
|
|
|
|
+ search: true,
|
|
|
|
+ searchSpan: 6,
|
|
width: 150,
|
|
width: 150,
|
|
overHidden: true
|
|
overHidden: true
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- label: '规格',
|
|
|
|
- prop: 'specs',
|
|
|
|
- search: false,
|
|
|
|
- width: 150,
|
|
|
|
|
|
+ label: '客户名称',
|
|
|
|
+ prop: 'customerName',
|
|
|
|
+ search: true,
|
|
|
|
+ searchSpan: 6,
|
|
|
|
+ width: 180,
|
|
overHidden: true
|
|
overHidden: true
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- label: '预测数量',
|
|
|
|
- prop: 'forecastQuantity',
|
|
|
|
- type: 'number',
|
|
|
|
- precision: 4,
|
|
|
|
- search: false,
|
|
|
|
- width: 120,
|
|
|
|
- align: 'right'
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: '当前库存',
|
|
|
|
- prop: 'currentInventory',
|
|
|
|
- type: 'number',
|
|
|
|
- precision: 4,
|
|
|
|
- search: false,
|
|
|
|
- width: 120,
|
|
|
|
- align: 'right'
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
label: '审批状态',
|
|
label: '审批状态',
|
|
prop: 'approvalStatus',
|
|
prop: 'approvalStatus',
|
|
type: 'select',
|
|
type: 'select',
|
|
@@ -209,6 +161,31 @@ export default {
|
|
overHidden: true
|
|
overHidden: true
|
|
}
|
|
}
|
|
]
|
|
]
|
|
|
|
+ },
|
|
|
|
+ // 子表(展开区)配置,展示明细列表
|
|
|
|
+ childOption: {
|
|
|
|
+ height: 'auto',
|
|
|
|
+ calcHeight: 0,
|
|
|
|
+ tip: false,
|
|
|
|
+ searchShow: false,
|
|
|
|
+ border: true,
|
|
|
|
+ index: true,
|
|
|
|
+ viewBtn: false,
|
|
|
|
+ editBtn: false,
|
|
|
|
+ delBtn: false,
|
|
|
|
+ addBtn: false,
|
|
|
|
+ selection: false,
|
|
|
|
+ menu: true,
|
|
|
|
+ menuWidth: 160,
|
|
|
|
+ expand: false,
|
|
|
|
+ column: [
|
|
|
|
+ { label: '商品编码', prop: 'itemCode', minWidth: 120 },
|
|
|
|
+ { label: '商品名称', prop: 'itemName', minWidth: 180, overHidden: true },
|
|
|
|
+ { label: '规格型号', prop: 'specs', minWidth: 140, overHidden: true },
|
|
|
|
+ { label: '花型/图案', prop: 'pattern', minWidth: 120, overHidden: true },
|
|
|
|
+ { label: '品牌名称', prop: 'brandName', minWidth: 120, overHidden: true },
|
|
|
|
+ { label: '预测数量', prop: 'forecastQuantity', minWidth: 120, align: 'right', slot: true }
|
|
|
|
+ ]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -270,7 +247,7 @@ export default {
|
|
/**
|
|
/**
|
|
* 判断是否可以审批通过
|
|
* 判断是否可以审批通过
|
|
* @this {Vue & ForecastAuditComponent}
|
|
* @this {Vue & ForecastAuditComponent}
|
|
- * @param {ForecastRecord} row - 数据行对象
|
|
|
|
|
|
+ * @param {ForecastRecord | {approvalStatus: number}} row - 数据行对象
|
|
* @returns {boolean} 是否可以审批通过
|
|
* @returns {boolean} 是否可以审批通过
|
|
*/
|
|
*/
|
|
canApprove(row) {
|
|
canApprove(row) {
|
|
@@ -280,7 +257,7 @@ export default {
|
|
/**
|
|
/**
|
|
* 判断是否可以审批拒绝
|
|
* 判断是否可以审批拒绝
|
|
* @this {Vue & ForecastAuditComponent}
|
|
* @this {Vue & ForecastAuditComponent}
|
|
- * @param {ForecastRecord} row - 数据行对象
|
|
|
|
|
|
+ * @param {ForecastRecord | {approvalStatus: number}} row - 数据行对象
|
|
* @returns {boolean} 是否可以审批拒绝
|
|
* @returns {boolean} 是否可以审批拒绝
|
|
*/
|
|
*/
|
|
canReject(row) {
|
|
canReject(row) {
|
|
@@ -310,7 +287,7 @@ export default {
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 审批通过记录
|
|
|
|
|
|
+ * 审批通过记录(主表)
|
|
* @this {Vue & ForecastAuditComponent}
|
|
* @this {Vue & ForecastAuditComponent}
|
|
* @param {ForecastRecord} row - 数据行对象
|
|
* @param {ForecastRecord} row - 数据行对象
|
|
* @param {number} index - 行索引
|
|
* @param {number} index - 行索引
|
|
@@ -329,7 +306,7 @@ export default {
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 审批拒绝记录
|
|
|
|
|
|
+ * 审批拒绝记录(主表)
|
|
* @this {Vue & ForecastAuditComponent}
|
|
* @this {Vue & ForecastAuditComponent}
|
|
* @param {ForecastRecord} row - 数据行对象
|
|
* @param {ForecastRecord} row - 数据行对象
|
|
* @param {number} index - 行索引
|
|
* @param {number} index - 行索引
|
|
@@ -348,6 +325,58 @@ export default {
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 子表明细审批通过
|
|
|
|
+ * @param {{ id: string|number, approvalStatus: number }} sub - 子项记录
|
|
|
|
+ */
|
|
|
|
+ approveChildRecord(sub) {
|
|
|
|
+ this.$confirm('确认通过此明细吗?', '审批确认', {
|
|
|
|
+ confirmButtonText: '确定',
|
|
|
|
+ cancelButtonText: '取消',
|
|
|
|
+ type: 'success'
|
|
|
|
+ }).then(() => {
|
|
|
|
+ this.submitChildApproval(sub, true)
|
|
|
|
+ }).catch(() => {})
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 子表明细审批拒绝
|
|
|
|
+ * @param {{ id: string|number, approvalStatus: number }} sub - 子项记录
|
|
|
|
+ */
|
|
|
|
+ rejectChildRecord(sub) {
|
|
|
|
+ this.$confirm('确认拒绝此明细吗?', '审批确认', {
|
|
|
|
+ confirmButtonText: '确定',
|
|
|
|
+ cancelButtonText: '取消',
|
|
|
|
+ type: 'warning'
|
|
|
|
+ }).then(() => {
|
|
|
|
+ this.submitChildApproval(sub, false)
|
|
|
|
+ }).catch(() => {})
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 执行子表明细审批
|
|
|
|
+ * @param {{ id: string|number }} sub - 子项记录
|
|
|
|
+ * @param {boolean} isApprove - 是否通过
|
|
|
|
+ */
|
|
|
|
+ submitChildApproval(sub, isApprove) {
|
|
|
|
+ this.submitting = true
|
|
|
|
+ const payload = {
|
|
|
|
+ id: sub.id,
|
|
|
|
+ approvalStatus: isApprove ? APPROVAL_STATUS.APPROVED : APPROVAL_STATUS.REJECTED
|
|
|
|
+ }
|
|
|
|
+ approveForecastSummary(payload)
|
|
|
|
+ .then(() => {
|
|
|
|
+ this.$message.success('明细审批成功')
|
|
|
|
+ this.onLoad(this.page, this.query)
|
|
|
|
+ })
|
|
|
|
+ .catch(() => {
|
|
|
|
+ this.$message.error('明细审批失败')
|
|
|
|
+ })
|
|
|
|
+ .finally(() => {
|
|
|
|
+ this.submitting = false
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 从详情页面审批通过
|
|
* 从详情页面审批通过
|
|
* @this {Vue & ForecastAuditComponent}
|
|
* @this {Vue & ForecastAuditComponent}
|
|
* @returns {void}
|
|
* @returns {void}
|
|
@@ -384,7 +413,7 @@ export default {
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 执行审批操作
|
|
|
|
|
|
+ * 执行审批操作(主表)
|
|
* @this {Vue & ForecastAuditComponent}
|
|
* @this {Vue & ForecastAuditComponent}
|
|
* @param {ForecastRecord} record - 要审批的记录
|
|
* @param {ForecastRecord} record - 要审批的记录
|
|
* @param {boolean} isApprove - 是否为通过审批
|
|
* @param {boolean} isApprove - 是否为通过审批
|
|
@@ -399,7 +428,7 @@ export default {
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 提交审批
|
|
|
|
|
|
+ * 提交审批(主表)
|
|
* @this {Vue & ForecastAuditComponent}
|
|
* @this {Vue & ForecastAuditComponent}
|
|
* @returns {void}
|
|
* @returns {void}
|
|
*/
|
|
*/
|
|
@@ -469,60 +498,36 @@ export default {
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 加载数据
|
|
|
|
|
|
+ * 加载数据(使用销售预测主表分页 main-list)
|
|
* @this {Vue & ForecastAuditComponent}
|
|
* @this {Vue & ForecastAuditComponent}
|
|
- * @param {PageConfig} page - 分页参数
|
|
|
|
- * @param {Record<string, any>} [params={}] - 查询参数
|
|
|
|
- * @returns {Promise<void>}
|
|
|
|
- * @throws {Error} 当数据加载失败时抛出错误
|
|
|
|
*/
|
|
*/
|
|
async onLoad(page, params = {}) {
|
|
async onLoad(page, params = {}) {
|
|
try {
|
|
try {
|
|
this.loading = true
|
|
this.loading = true
|
|
|
|
|
|
const queryParams = {
|
|
const queryParams = {
|
|
- ...params,
|
|
|
|
- // 只显示需要审核的数据(可以根据业务需求调整)
|
|
|
|
- // approvalStatus: APPROVAL_STATUS.PENDING
|
|
|
|
|
|
+ year: params.year ?? this.query.year,
|
|
|
|
+ month: params.month ?? this.query.month,
|
|
|
|
+ customerName: params.customerName ?? this.query.customerName
|
|
}
|
|
}
|
|
|
|
|
|
- const res = await getForecastList(page.currentPage, page.pageSize, queryParams)
|
|
|
|
-
|
|
|
|
- if (res.data && res.data.success) {
|
|
|
|
- const { records, total } = res.data.data
|
|
|
|
- this.data = records || []
|
|
|
|
- this.page.total = total || 0
|
|
|
|
- } else {
|
|
|
|
- throw new Error(res.data?.msg || '获取数据失败')
|
|
|
|
- }
|
|
|
|
|
|
+ // 调用主表分页接口
|
|
|
|
+ const res = await getForecastList({
|
|
|
|
+ current: page.currentPage,
|
|
|
|
+ size: page.pageSize,
|
|
|
|
+ ...queryParams
|
|
|
|
+ })
|
|
|
|
+ const { records = [], total = 0, current = 1, size = 10 } = (res.data && res.data.data) || {}
|
|
|
|
+ this.data = records
|
|
|
|
+ this.page.total = total
|
|
|
|
+ this.page.currentPage = current
|
|
|
|
+ this.page.pageSize = size
|
|
} catch (error) {
|
|
} catch (error) {
|
|
- console.error('加载数据失败:', error)
|
|
|
|
- this.$message.error(error.message || '加载数据失败')
|
|
|
|
- this.data = []
|
|
|
|
- this.page.total = 0
|
|
|
|
|
|
+ // eslint-disable-next-line no-console
|
|
|
|
+ console.error('加载列表失败', error)
|
|
} finally {
|
|
} finally {
|
|
this.loading = false
|
|
this.loading = false
|
|
}
|
|
}
|
|
- },
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 页码变化
|
|
|
|
- * @this {Vue & ForecastAuditComponent}
|
|
|
|
- * @param {number} currentPage - 当前页码
|
|
|
|
- * @returns {void}
|
|
|
|
- */
|
|
|
|
- currentChange(currentPage) {
|
|
|
|
- this.page.currentPage = currentPage
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 页大小变化
|
|
|
|
- * @this {Vue & ForecastAuditComponent}
|
|
|
|
- * @param {number} pageSize - 页大小
|
|
|
|
- * @returns {void}
|
|
|
|
- */
|
|
|
|
- sizeChange(pageSize) {
|
|
|
|
- this.page.pageSize = pageSize
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|