feat: 新增现场日历并将四类日历的起止地改为选填,以支持现场派车记录。

This commit is contained in:
wuzilong committed 2026-10-30 11:58:48 +08:00
1 parent 0453e90000
commit cd99b040aa
15 files changed
+172 -31

No files matched your search

@@ -107,8 +107,22 @@ test('同一车辆按创建时间正序,复制时排在一起且每条换行',
])
assert.equal(text.startsWith('2026-10-28'), true)
})
test('表单拒绝空白、无效日期,保留手写起止地', () => {
assert.equal(validateManualDraft({ ...row('1'), origin: ' ' }), '请填写始发地')
test('表单允许起止地留空,仍拒绝无效日期和超长地址', () => {
for (const calendarKind of ['acid', 'alkali', 'other', 'site'] as const) {
for (const addresses of [
{ origin: '', destination: '云栋' },
{ origin: '山峡', destination: '' },
{ origin: ' ', destination: ' ' }
]) {
assert.equal(validateManualDraft({ ...row('1'), calendarKind, ...addresses }), '')
}
}
for (const field of ['origin', 'destination']) {
assert.equal(
validateManualDraft({ ...row('1'), [field]: '地'.repeat(256) }),
'始发地和目的地最多255个字符'
)
}
assert.equal(
validateManualDraft({ ...row('1'), dispatchDate: '2026-02-30' }),
'请选择有效的派车日期'
@@ -118,7 +132,9 @@ test('表单拒绝空白、无效日期,保留手写起止地', () => {
test('数量是可空文本,复制逐条展示,日汇总仍只计车次', () => {
const tons = { ...row('1'), quantity: '32.50' }
const blank = { ...row('2'), quantity: ' ' }
const day = manualCalendarDays([tons, blank], '2026-10').find((item) => item.date === '2026-10-26')!
const day = manualCalendarDays([tons, blank], '2026-10').find(
(item) => item.date === '2026-10-26'
)!
assert.deepEqual(day.products[0], { id: 'p1', name: '液碱', count: 2 })
const text = manualCopyText('2026-10-26', [tons, blank])
assert.match(text, /液碱 32\.50吨 山峡 → 云栋/)
@@ -130,8 +146,5 @@ test('数量是可空文本,复制逐条展示,日汇总仍只计车次', ()
validateManualDraft({ ...row('1'), quantity: '12.345' }),
'数量须为数字,最多两位小数'
)
assert.equal(
validateManualDraft({ ...row('1'), quantity: '1吨' }),
'数量须为数字,最多两位小数'
)
assert.equal(validateManualDraft({ ...row('1'), quantity: '1吨' }), '数量须为数字,最多两位小数')
})
@@ -2,7 +2,13 @@ import assert from 'node:assert/strict'
import { chromium } from 'playwright'
const browser = await chromium.launch({ headless: true, channel: 'chrome' })
try {
for (const mobile of [false, true]) {
for (const { mobile, kind, title } of [
{ mobile: false, kind: 'acid', title: '酸派车日历' },
{ mobile: false, kind: 'alkali', title: '碱派车日历' },
{ mobile: false, kind: 'other', title: '其他日历' },
{ mobile: false, kind: 'site', title: '现场日历' },
{ mobile: true, kind: 'acid', title: '酸派车日历' }
]) {
const context = await browser.newContext({
permissions: ['clipboard-read', 'clipboard-write'],
viewport: mobile ? { width: 375, height: 812 } : { width: 1440, height: 1000 }
@@ -132,6 +138,13 @@ try {
console.log('PAGE', await page.locator('body').innerText(), errors)
throw e
})
if (!mobile) {
assert.deepEqual(
await page.locator('.dispatch-calendar-tabs [role="tab"]').allTextContents(),
['酸派车日历', '碱派车日历', '其他日历', '现场日历', '实际派车信息']
)
}
await page.getByRole('tab', { name: title, exact: true }).click()
if (mobile) {
await page.getByLabel('查看月份', { exact: true }).click()
const popup = page.locator('.mp-calendar-date-picker:visible')
@@ -175,6 +188,15 @@ try {
await editor.getByRole('combobox', { name: '产品名称', exact: true }).click()
await page.getByRole('option', { name: '液碱', exact: true }).click()
}
// 起止地留空也应保存成功,编辑后仍可补填。
await editor.getByRole('button', { name: '保存', exact: true }).click()
await editor.waitFor({ state: 'hidden' })
assert.equal(rows.length, 1)
assert.equal(rows[0].origin, '')
assert.equal(rows[0].destination, '')
assert.equal(rows[0].calendarKind, kind)
await page.locator('[data-testid="manual-record"]').first().click()
await page.getByRole('button', { name: '编辑', exact: true }).click()
await editor.getByPlaceholder('请输入始发地').fill('山峡')
await editor.getByPlaceholder('请输入目的地').fill('云栋')
failSave = true
@@ -184,10 +206,11 @@ try {
await editor.getByRole('button', { name: '保存', exact: true }).click()
await editor.waitFor({ state: 'hidden' })
assert.equal(rows.length, 1)
assert.equal(rows[0].calendarKind, kind)
const card = page.locator('[data-testid="manual-record"]').first()
await card.waitFor()
await page.screenshot({
path: `/tmp/manual-calendar-${mobile ? 'mobile' : 'web'}.png`,
path: `/tmp/manual-calendar-${mobile ? 'mobile' : 'web'}-${kind}.png`,
fullPage: false
})
assert.match(await card.innerText(), /山峡 → 云栋/)
@@ -197,7 +220,7 @@ try {
.click()
assert.match(
await page.evaluate(() => navigator.clipboard.readText()),
/皖H12345.*液碱.*山峡 → 云栋/
/皖H12345.*液碱.*山峡 → 云栋/s
)
await card.click()
@@ -213,7 +236,7 @@ try {
assert.equal(rows.length, 0)
failLoad = true
await page.getByRole('tab', { name: '实际派车信息', exact: true }).click()
await page.getByRole('tab', { name: '酸派车日历', exact: true }).click()
await page.getByRole('tab', { name: title, exact: true }).click()
await page.getByText('派车日历加载失败,请重试', { exact: false }).first().waitFor()
await page.getByRole('button', { name: '重试', exact: true }).click()
await page
@@ -240,10 +263,10 @@ try {
origin: '山峡',
destination: '云栋',
remark: '',
calendarKind: 'acid'
calendarKind: kind
}
]
await page.getByRole('tab', { name: '酸派车日历', exact: true }).click()
await page.getByRole('tab', { name: title, exact: true }).click()
await page.locator('[data-testid="manual-record"]').first().waitFor()
assert.equal(await page.getByRole('button', { name: '新增派车计划', exact: true }).count(), 0)
await page.locator('[data-testid="manual-record"]').first().click()
@@ -251,7 +274,7 @@ try {
assert.equal(await page.getByRole('button', { name: '删除', exact: true }).count(), 0)
assert.deepEqual(errors, [])
await context.close()
console.log(mobile ? 'mobile CRUD passed' : 'web CRUD passed')
console.log(`${mobile ? 'mobile' : 'web'} ${kind} CRUD passed`)
}
} finally {
await browser.close()
+1 -1
View File
@@ -1,6 +1,6 @@
import request, { pickBxData } from '@/utils/http/bx'
export type DispatchCalendarKind = 'acid' | 'alkali' | 'other'
export type DispatchCalendarKind = 'acid' | 'alkali' | 'other' | 'site'
export interface DispatchCalendarBody {
dispatchDate: string
@@ -128,14 +128,12 @@
<van-field
v-model="draft.origin"
label="始发地"
required
maxlength="255"
placeholder="请输入始发地"
/>
<van-field
v-model="draft.destination"
label="目的地"
required
maxlength="255"
placeholder="请输入目的地"
/>
@@ -179,10 +179,10 @@
><template #append>吨</template></el-input
></el-form-item
>
<el-form-item label="始发地" required
<el-form-item label="始发地"
><el-input v-model="draft.origin" maxlength="255" placeholder="请输入始发地"
/></el-form-item>
<el-form-item label="目的地" required
<el-form-item label="目的地"
><el-input v-model="draft.destination" maxlength="255" placeholder="请输入目的地"
/></el-form-item>
<el-form-item label="备注" class="form-col-span-2"
@@ -3,18 +3,21 @@
<div
class="dispatch-calendar-tabs"
:class="{
'manual-calendar-theme': active === 'acid' || active === 'alkali' || active === 'other'
'manual-calendar-theme':
active === 'acid' || active === 'alkali' || active === 'other' || active === 'site'
}"
>
<el-tabs v-model="active">
<el-tab-pane label="酸派车日历" name="acid" />
<el-tab-pane label="碱派车日历" name="alkali" />
<el-tab-pane label="其他日历" name="other" />
<el-tab-pane label="现场日历" name="site" />
<el-tab-pane label="实际派车信息" name="actual" />
</el-tabs>
<ManualCalendar v-if="active === 'acid'" calendar-kind="acid" title="酸派车日历" />
<ManualCalendar v-else-if="active === 'alkali'" calendar-kind="alkali" title="碱派车日历" />
<ManualCalendar v-else-if="active === 'other'" calendar-kind="other" title="其他日历" />
<ManualCalendar v-else-if="active === 'site'" calendar-kind="site" title="现场日历" />
<ActualCalendar v-else />
</div>
</template>
@@ -118,8 +118,6 @@ export function validateManualDraft(body: DispatchCalendarBody): string {
return '请选择有效的派车日期'
if (!body.vehicleId) return '请选择车辆'
if (!body.productId) return '请选择产品'
if (!body.origin.trim()) return '请填写始发地'
if (!body.destination.trim()) return '请填写目的地'
if (body.origin.trim().length > 255 || body.destination.trim().length > 255)
return '始发地和目的地最多255个字符'
if (manualQuantityText(body.quantity) && !QUANTITY_TEXT.test(manualQuantityText(body.quantity)))