feat: 保存运输证件、报销付款和开发流程的当前实现。
补齐证书齐备、证件折算、移动用证和合同绑定,并带上报销批量发放、付款备注以及个人开发流程升级,便于继续讨论已安排计划的调整规则。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
7325a0aa52
commit
8e9536332a
202 files changed
+19200
-2054
No files matched your search
@@ -6,6 +6,11 @@ import ts from 'typescript'
|
||||
import * as vue from 'vue'
|
||||
import { usePersistedListColumns } from '../src/composables/usePersistedListColumns'
|
||||
import { useServerColumnFilters } from '../src/composables/useServerColumnFilters'
|
||||
import {
|
||||
PL_PLAN_FOLLOW_STATUS_OPTIONS,
|
||||
getPlPlanFollowStatusLabel,
|
||||
getPlPlanFollowStatusTagType
|
||||
} from '../src/utils/pl-display'
|
||||
const flush = async () => {
|
||||
for (let i = 0; i < 30; i++) await Promise.resolve()
|
||||
}
|
||||
@@ -34,7 +39,7 @@ function harness(fixed?: string) {
|
||||
return pending.promise
|
||||
}
|
||||
const api = Object.fromEntries(
|
||||
['listStops', 'getStops', 'saveStops'].map((method) => [
|
||||
['listStops', 'getStops', 'save'].map((method) => [
|
||||
method,
|
||||
(...args: any[]) => queue(method, args)
|
||||
])
|
||||
@@ -55,8 +60,11 @@ function harness(fixed?: string) {
|
||||
useListTableViewportHeight: () => ({ tableHeight: vue.ref(400) }),
|
||||
usePersistedListColumns,
|
||||
useServerColumnFilters,
|
||||
PL_PLAN_FOLLOW_STATUS_OPTIONS,
|
||||
getPlPlanFollowStatusLabel,
|
||||
getPlPlanFollowStatusTagType,
|
||||
legalDocumentApi: api,
|
||||
ElMessage: { success() {}, warning() {} },
|
||||
ElMessage: { success() {}, warning() {}, error() {} },
|
||||
onBeforeUnmount: (fn: () => void) => unmount.push(fn)
|
||||
}
|
||||
const src = ts.createSourceFile(
|
||||
@@ -81,7 +89,7 @@ function harness(fixed?: string) {
|
||||
const state = scope.run(() =>
|
||||
new Function(
|
||||
...Object.keys(env),
|
||||
`${code}; return { rows, details, load, loadDetail, allowed, canUpload, keyword, setFilterState, page, total, expansionStyle, open, save, visible, editing, upload, saving, editorLoading, status, search, statusLabel, reset, visibleColumns }`
|
||||
`${code}; return { rows, details, load, loadDetail, allowed, canUpload, keyword, setFilterState, page, total, expansionStyle, savePlan, onCertDraft, drafts, uploaders, saving, status, search, statusLabel, reset, visibleColumns }`
|
||||
)(...Object.values(env))
|
||||
)
|
||||
return {
|
||||
@@ -106,28 +114,23 @@ test('global and fixed contract preserve server counts and scope every request',
|
||||
await flush()
|
||||
assert.equal(h.calls[0].method, 'listStops')
|
||||
assert.equal(h.calls[0].args[0].contractId, fixed)
|
||||
assert.equal(h.calls[0].args[0].status, 'pending')
|
||||
h.calls[0].resolve({
|
||||
list: [{ id: 'plan', uploadedCount: 1, requiredCount: fixed ? 1 : 3 }],
|
||||
total: 45
|
||||
})
|
||||
await flush()
|
||||
assert.equal(s.rows.value[0].requiredCount, fixed ? 1 : 3)
|
||||
const pending = s.open({ id: 'plan' }, { stopType: 'delivery', stopProductId: 'd2' })
|
||||
assert.equal(h.calls[1].args[1], fixed)
|
||||
h.calls[1].resolve({
|
||||
id: 'plan',
|
||||
items: [
|
||||
{ stopType: 'delivery', stopProductId: 'd2', productId: 'same', legalUseCertUrl: 'a,b' }
|
||||
]
|
||||
})
|
||||
await pending
|
||||
const saving = s.save()
|
||||
assert.deepEqual(h.calls[2].args, [
|
||||
'plan',
|
||||
[{ stopType: 'delivery', stopProductId: 'd2', legalUseCertUrl: 'a,b' }],
|
||||
fixed
|
||||
])
|
||||
h.calls[2].resolve({})
|
||||
s.details.plan = {
|
||||
loading: false,
|
||||
error: false,
|
||||
data: { id: 'plan', planProductIds: ['pp'], legalUseCertUrl: 'a,b', items: [] }
|
||||
}
|
||||
s.drafts.plan = 'a,b'
|
||||
const saving = s.savePlan('plan')
|
||||
assert.equal(h.calls[1].method, 'save')
|
||||
assert.deepEqual(h.calls[1].args, ['plan', [{ id: 'pp', legalUseCertUrl: 'a,b' }]])
|
||||
h.calls[1].resolve({})
|
||||
await saving
|
||||
h.stop()
|
||||
}
|
||||
@@ -139,37 +142,40 @@ test('busy uploads refuse saves and failures preserve draft', async () => {
|
||||
await flush()
|
||||
h.calls[0].resolve({ list: [], total: 0 })
|
||||
await flush()
|
||||
const opened = s.open({ id: 'p' }, { stopType: 'load', stopProductId: 'l' })
|
||||
h.calls[1].resolve({
|
||||
id: 'p',
|
||||
items: [{ stopType: 'load', stopProductId: 'l', legalUseCertUrl: 'original' }]
|
||||
})
|
||||
await opened
|
||||
s.editing.value.legalUseCertUrl = 'draft'
|
||||
s.upload.value = { hasUploading: () => true }
|
||||
await s.save()
|
||||
assert.equal(h.calls.length, 2)
|
||||
s.upload.value = { hasUploading: () => false }
|
||||
const saving = s.save()
|
||||
h.calls[2].reject(Error('failed'))
|
||||
s.details.p = {
|
||||
loading: false,
|
||||
error: false,
|
||||
data: { planProductIds: ['pp'], legalUseCertUrl: 'original' }
|
||||
}
|
||||
s.drafts.p = 'draft'
|
||||
s.uploaders.p = { hasUploading: () => true }
|
||||
await s.savePlan('p')
|
||||
assert.equal(h.calls.length, 1)
|
||||
s.uploaders.p = { hasUploading: () => false }
|
||||
const saving = s.savePlan('p')
|
||||
h.calls[1].reject(Error('failed'))
|
||||
await saving
|
||||
assert.equal(s.editing.value.legalUseCertUrl, 'draft')
|
||||
assert.equal(s.visible.value, true)
|
||||
assert.equal(s.drafts.p, 'draft')
|
||||
assert.equal(s.saving.p, false)
|
||||
h.stop()
|
||||
})
|
||||
for (const change of ['contract', 'tenant', 'close'])
|
||||
test(`old editor response is discarded after ${change}`, async () => {
|
||||
for (const change of ['contract', 'tenant'])
|
||||
test(`old detail is discarded after ${change}`, async () => {
|
||||
const h = harness('one'),
|
||||
s = h.state
|
||||
h.permissions[0].resolve({ all: true })
|
||||
await flush()
|
||||
const old = s.open({ id: 'p' }, { stopType: 'load', stopProductId: 'l' })
|
||||
h.calls[0].resolve({ list: [], total: 0 })
|
||||
await flush()
|
||||
const old = s.loadDetail({ id: 'p' })
|
||||
if (change === 'contract') h.props.contractId = 'two'
|
||||
if (change === 'tenant') h.user.getUserInfo.tenantNo = 'b'
|
||||
if (change === 'close') s.visible.value = false
|
||||
h.calls[1].resolve({ id: 'p', items: [{ stopType: 'load', stopProductId: 'l' }] })
|
||||
h.calls.find((call) => call.method === 'getStops').resolve({
|
||||
legalUseCertUrl: 'stale',
|
||||
planProductIds: ['pp']
|
||||
})
|
||||
await old
|
||||
assert.equal(s.editing.value, undefined)
|
||||
assert.equal(s.drafts.p, undefined)
|
||||
h.stop()
|
||||
})
|
||||
test('search during permission initialization does not cancel it; filters are independent', async () => {
|
||||
@@ -177,12 +183,17 @@ test('search during permission initialization does not cancel it; filters are in
|
||||
s = h.state
|
||||
s.keyword.value = 'word'
|
||||
s.setFilterState('planNo', { text: 'PL' })
|
||||
s.setFilterState('planDate', { from: '2026-11-01', to: '2026-11-04' })
|
||||
s.setFilterState('licensePlate', { text: '鄂A' })
|
||||
await s.load()
|
||||
h.permissions[0].resolve({ all: true })
|
||||
await flush()
|
||||
assert.equal(h.calls.length, 1)
|
||||
assert.equal(h.calls[0].args[0].keyword, 'word')
|
||||
assert.equal(h.calls[0].args[0].planNo, 'PL')
|
||||
assert.equal(h.calls[0].args[0].planDateFrom, '2026-11-01')
|
||||
assert.equal(h.calls[0].args[0].planDateTo, '2026-11-04')
|
||||
assert.equal(h.calls[0].args[0].licensePlate, '鄂A')
|
||||
h.stop()
|
||||
})
|
||||
test('refresh preserves page and total; not_required is not uploaded', async () => {
|
||||
@@ -320,6 +331,9 @@ for (const active of [undefined, false])
|
||||
},
|
||||
usePersistedListColumns,
|
||||
useServerColumnFilters,
|
||||
PL_PLAN_FOLLOW_STATUS_OPTIONS,
|
||||
getPlPlanFollowStatusLabel,
|
||||
getPlPlanFollowStatusTagType,
|
||||
useElementSize: () => ({ width: vue.ref(1000) }),
|
||||
useListTableViewportHeight: () => ({ tableHeight: vue.ref(400) })
|
||||
},
|
||||
@@ -344,36 +358,33 @@ for (const active of [undefined, false])
|
||||
assert.deepEqual(calls, active === false ? [] : ['proof'])
|
||||
app.unmount()
|
||||
})
|
||||
test('closing and reopening rejects old response and finally without clearing new loading', async () => {
|
||||
test('a newer detail load is not cleared when the previous request finishes', async () => {
|
||||
const h = harness(),
|
||||
s = h.state
|
||||
h.permissions[0].resolve({ all: true })
|
||||
await flush()
|
||||
const first = s.open({ id: 'p' }, { stopType: 'load', stopProductId: 'l' })
|
||||
s.visible.value = false
|
||||
const second = s.open({ id: 'p' }, { stopType: 'delivery', stopProductId: 'd' })
|
||||
h.calls[1].resolve({ items: [{ stopType: 'load', stopProductId: 'l' }] })
|
||||
h.calls[0].resolve({ list: [], total: 0 })
|
||||
await flush()
|
||||
const first = s.loadDetail({ id: 'p' })
|
||||
const second = s.loadDetail({ id: 'p' })
|
||||
h.calls[1].resolve({ legalUseCertUrl: 'old', planProductIds: ['old'] })
|
||||
await first
|
||||
assert.equal(s.editorLoading.value, true)
|
||||
assert.equal(s.editing.value, undefined)
|
||||
h.calls[2].resolve({ items: [{ stopType: 'delivery', stopProductId: 'd' }] })
|
||||
h.calls[2].resolve({ legalUseCertUrl: 'new', planProductIds: ['new'] })
|
||||
await second
|
||||
assert.equal(s.editorLoading.value, false)
|
||||
assert.equal(s.editing.value.stopProductId, 'd')
|
||||
assert.equal(s.drafts.p, 'new')
|
||||
assert.deepEqual(s.details.p.data.planProductIds, ['new'])
|
||||
h.stop()
|
||||
})
|
||||
test('historical attachments have a separate readonly field and viewport aligned expansion', () => {
|
||||
test('plan certificate is edited below the segments and the expansion stays aligned', () => {
|
||||
const descriptor = parse(
|
||||
readFileSync(
|
||||
new URL('../src/views/pl/legal-use-document/StopDocuments.vue', import.meta.url),
|
||||
'utf8'
|
||||
)
|
||||
).descriptor
|
||||
assert.match(descriptor.template!.content, /历史计划级资料/)
|
||||
assert.match(
|
||||
descriptor.template!.content,
|
||||
/:model-value="product.legalUseCertUrl \|\| ''"\s+disabled/
|
||||
)
|
||||
assert.match(descriptor.template!.content, /合法使用证明/)
|
||||
assert.doesNotMatch(descriptor.template!.content, /历史计划级资料|维护本段资料/)
|
||||
assert.match(descriptor.template!.content, /v-model="drafts\[row\.id\]"/)
|
||||
assert.match(descriptor.styles[0].content, /text-align: left/)
|
||||
const h = harness()
|
||||
assert.equal(h.state.expansionStyle.value.width, '1120px')
|
||||
@@ -438,40 +449,33 @@ test('view permission loads proof only and prevents upload requests', async () =
|
||||
await flush()
|
||||
assert.equal(s.allowed.value, true)
|
||||
assert.equal(s.canUpload.value, false)
|
||||
await s.open({ id: 'p' }, { stopType: 'load', stopProductId: 'l' })
|
||||
await s.save()
|
||||
await s.savePlan('p')
|
||||
assert.deepEqual(
|
||||
h.calls.map((c) => c.method),
|
||||
['listStops']
|
||||
)
|
||||
h.stop()
|
||||
})
|
||||
test('old save completion cannot close or clear a reopened editor', async () => {
|
||||
test('an older save cannot replace a newer draft', async () => {
|
||||
const h = harness(),
|
||||
s = h.state
|
||||
h.permissions[0].resolve({ all: true })
|
||||
await flush()
|
||||
const opened = s.open({ id: 'p' }, { stopType: 'load', stopProductId: 'l' })
|
||||
h.calls[1].resolve({ items: [{ stopType: 'load', stopProductId: 'l', legalUseCertUrl: 'a' }] })
|
||||
await opened
|
||||
const oldSave = s.save()
|
||||
s.visible.value = false
|
||||
const reopened = s.open({ id: 'p' }, { stopType: 'delivery', stopProductId: 'd' })
|
||||
h.calls[3].resolve({
|
||||
items: [{ stopType: 'delivery', stopProductId: 'd', legalUseCertUrl: 'b' }]
|
||||
})
|
||||
await reopened
|
||||
const newSave = s.save()
|
||||
h.calls[2].resolve({})
|
||||
h.calls[0].resolve({ list: [], total: 0 })
|
||||
await flush()
|
||||
s.details.p = {
|
||||
loading: false,
|
||||
error: false,
|
||||
data: { planProductIds: ['pp'], legalUseCertUrl: 'a' }
|
||||
}
|
||||
s.drafts.p = 'a'
|
||||
const oldSave = s.savePlan('p')
|
||||
s.drafts.p = 'b'
|
||||
h.calls[1].resolve({})
|
||||
await oldSave
|
||||
assert.equal(s.visible.value, true)
|
||||
assert.equal(s.saving.value, true)
|
||||
assert.equal(s.editing.value.stopProductId, 'd')
|
||||
assert.equal(h.calls.length, 5)
|
||||
h.calls[4].reject(Error('retry'))
|
||||
await newSave
|
||||
assert.equal(s.editing.value.legalUseCertUrl, 'b')
|
||||
assert.equal(s.saving.value, false)
|
||||
assert.equal(s.drafts.p, 'b')
|
||||
assert.equal(h.calls.filter((call) => call.method === 'save').length, 1)
|
||||
assert.equal(s.saving.p, false)
|
||||
h.stop()
|
||||
})
|
||||
test('old list and permission responses cannot reauthorize another tenant', async () => {
|
||||
@@ -499,8 +503,7 @@ test('status is a server single filter and combines with the number filter', asy
|
||||
s = h.state
|
||||
h.permissions[0].resolve({ all: true })
|
||||
await flush()
|
||||
s.status.value = 'uploaded'
|
||||
s.search()
|
||||
s.setFilterState('documentStatus', { text: '', selected: ['uploaded'] })
|
||||
assert.equal(h.calls.at(-1).args[0].status, 'uploaded')
|
||||
s.setFilterState('planNo', { text: 'PL' })
|
||||
assert.equal(h.calls.at(-1).args[0].planNo, 'PL')
|
||||
@@ -523,7 +526,6 @@ test('latest refresh wins and hidden column/reset preserve server filter semanti
|
||||
assert.equal(s.rows.value[0].id, 'new')
|
||||
assert.equal(s.total.value, 45)
|
||||
s.keyword.value = 'quick'
|
||||
s.status.value = 'pending'
|
||||
s.page.value = 2
|
||||
s.setFilterState('planNo', { text: 'PL' })
|
||||
assert.equal(s.page.value, 1)
|
||||
@@ -534,12 +536,32 @@ test('latest refresh wins and hidden column/reset preserve server filter semanti
|
||||
assert.equal(h.calls.at(-1).args[0].status, 'pending')
|
||||
s.reset()
|
||||
assert.equal(h.calls.at(-1).args[0].keyword, '')
|
||||
assert.equal(h.calls.at(-1).args[0].status, undefined)
|
||||
assert.equal(h.calls.at(-1).args[0].status, 'pending')
|
||||
h.calls.forEach((c) => c.resolve({ list: [], total: 0 }))
|
||||
await flush()
|
||||
h.stop()
|
||||
})
|
||||
|
||||
test('list certificate column saves the finished attachment without a second click', async () => {
|
||||
const h = harness(),
|
||||
s = h.state
|
||||
h.permissions[0].resolve({ menuCodes: ['pl:legal-use-document:list', 'pl:plan-cert:upload'] })
|
||||
await flush()
|
||||
h.calls[0].resolve({ list: [], total: 0 })
|
||||
await flush()
|
||||
const row = { id: 'plan', legalUseCertUrl: 'old', planProductIds: ['pp'], documentStatus: 'pending' }
|
||||
s.onCertDraft(row, 'old')
|
||||
assert.equal(h.calls.length, 1)
|
||||
s.onCertDraft(row, 'new')
|
||||
assert.equal(h.calls[1].method, 'save')
|
||||
assert.deepEqual(h.calls[1].args, ['plan', [{ id: 'pp', legalUseCertUrl: 'new' }]])
|
||||
h.calls[1].resolve({})
|
||||
await flush()
|
||||
assert.equal(h.calls[2].method, 'listStops')
|
||||
h.calls[2].resolve({ list: [], total: 0 })
|
||||
await flush()
|
||||
h.stop()
|
||||
})
|
||||
test('expanded segment columns prioritize upload state and attachments', () => {
|
||||
const template = parse(
|
||||
readFileSync(
|
||||
@@ -550,18 +572,6 @@ test('expanded segment columns prioritize upload state and attachments', () => {
|
||||
const table = template.slice(template.indexOf('<el-table\n'), template.indexOf('</el-table>'))
|
||||
assert.deepEqual(
|
||||
[...table.matchAll(/<el-table-column\b[^>]*\blabel="([^"]+)"/g)].map((match) => match[1]),
|
||||
[
|
||||
'运输段',
|
||||
'产品',
|
||||
'上传情况',
|
||||
'附件',
|
||||
'合同编号',
|
||||
'本段主体',
|
||||
'规格',
|
||||
'单位',
|
||||
'本段位置',
|
||||
'上传时间',
|
||||
'操作'
|
||||
]
|
||||
['运输段', '产品', '合同编号', '本段主体', '规格', '单位', '本段位置']
|
||||
)
|
||||
})
|
||||
Reference in new issue
Block a user