weizong song 6 days ago
parent 4395c4b225
commit 26491ec83e

@ -1084,7 +1084,9 @@ export default {
await this.initFormData()
await this.loadDepartmentSubmissions()
if (this.mode === 'edit' || this.mode === 'view') {
// lead draft
// 0
if (this.shouldLoadExistingSummary()) {
await this.loadExistingSummaryData()
}
},
@ -1096,6 +1098,13 @@ export default {
}
},
methods: {
shouldLoadExistingSummary() {
if (this.mode !== 'edit' && this.mode !== 'view') return false
const submission = this.packageData.submission || this.packageData.lead_submission || {}
return Boolean(submission.summary_started_at || submission.summaryStartedAt)
},
initZIndexManagement() {
//
this.dynamicZIndex = 3000

@ -441,10 +441,18 @@ export default {
return Boolean(submission && (submission.summary_started_at || submission.summaryStartedAt))
},
summaryActionLabel(row) {
getSummaryMode(row) {
const submission = this.getLeadSubmission(row)
const year = row.budget_year || {}
if (year.status !== 'ACTIVE') return 'view'
if (!this.hasStartedLeadSummary(row)) return 'create'
return submission && submission.status === 'draft' ? 'edit' : 'view'
},
summaryActionLabel(row) {
if (!this.hasStartedLeadSummary(row)) return '汇总提交'
return submission && submission.status === 'draft' ? '修改汇总' : '查看汇总'
return this.getSummaryMode(row) === 'edit' ? '修改汇总' : '查看汇总'
},
canAllocate(row) {
@ -473,12 +481,8 @@ export default {
openSummarySubmit(row) {
//
this.currentSummaryPackage = { ...row }
// lead 稿
const submission = this.getLeadSubmission(row)
const isActiveYear = row.budget_year && row.budget_year.status === 'ACTIVE'
this.summaryMode = !isActiveYear
? 'view'
: !this.hasStartedLeadSummary(row) ? 'create' : submission.status === 'draft' ? 'edit' : 'view'
//
this.summaryMode = this.getSummaryMode(row)
this.summarySubmitVisible = true
},

@ -0,0 +1,54 @@
jest.mock('@/api/budget/budgetCollectionYear.js', () => ({}))
jest.mock('@/api/budget/leadDepartment.js', () => ({}))
jest.mock('@/views/budget/collection/components/SplitPackageForm.vue', () => ({}))
jest.mock('@/views/budget/collection/components/ProjectDetailsView.vue', () => ({}))
jest.mock('@/views/budget/collection/components/LeadDepartmentSummaryForm.vue', () => ({}))
jest.mock('@/views/budget/collection/components/BudgetSubmissionForm.vue', () => ({}))
import LeadDepartmentPage from '@/views/budget/collection/leadDepartment.vue'
function createContext() {
const methods = LeadDepartmentPage.methods
const context = {
currentSummaryPackage: null,
summaryMode: null,
summarySubmitVisible: false
}
context.getLeadSubmission = methods.getLeadSubmission.bind(context)
context.hasStartedLeadSummary = methods.hasStartedLeadSummary.bind(context)
context.getSummaryMode = methods.getSummaryMode.bind(context)
return context
}
describe('LeadDepartmentPage summary action', () => {
const draftSummary = {
status: 'draft',
summary_started_at: '2026-08-14 10:00:00'
}
it('opens an active-year draft summary in edit mode when labelled 修改汇总', () => {
const context = createContext()
const row = {
budget_year: { status: 'ACTIVE' },
lead_submission: draftSummary
}
expect(LeadDepartmentPage.methods.summaryActionLabel.call(context, row)).toBe('修改汇总')
LeadDepartmentPage.methods.openSummarySubmit.call(context, row)
expect(context.summaryMode).toBe('edit')
})
it('uses 查看汇总 rather than 修改汇总 when a draft belongs to an inactive year', () => {
const context = createContext()
const row = {
budget_year: { status: 'INACTIVE' },
lead_submission: draftSummary
}
expect(LeadDepartmentPage.methods.summaryActionLabel.call(context, row)).toBe('查看汇总')
LeadDepartmentPage.methods.openSummarySubmit.call(context, row)
expect(context.summaryMode).toBe('view')
})
})

@ -132,4 +132,26 @@ describe('LeadDepartmentSummaryForm automatic aggregation', () => {
fileList: [expect.objectContaining({ fileId: 201 })]
}))
})
it('does not load a pre-created empty draft as an existing summary', () => {
const context = {
mode: 'edit',
packageData: {
submission: { status: 'draft', summary_started_at: null }
}
}
expect(LeadDepartmentSummaryForm.methods.shouldLoadExistingSummary.call(context)).toBe(false)
})
it('loads a genuinely started draft when editing it', () => {
const context = {
mode: 'edit',
packageData: {
submission: { status: 'draft', summary_started_at: '2026-08-14 10:00:00' }
}
}
expect(LeadDepartmentSummaryForm.methods.shouldLoadExistingSummary.call(context)).toBe(true)
})
})

Loading…
Cancel
Save