import { Page, expect } from '@playwright/test'; /** * 手术计费页面对象模型 * 覆盖:手术计费、耗材签发、防重复提交 */ export class SurgeryBillingPage { readonly page: Page; readonly surgeryList = page.locator('el-table, .el-table'); readonly generateBtn = page.locator('button:has-text("生成"), button:has-text("生成收费项")'); readonly addBtn = page.locator('button:has-text("新增")'); readonly saveBtn = page.locator('button:has-text("保存"), button:has-text("提交")'); readonly signBtn = page.locator('button:has-text("签发")'); readonly successMessage = page.locator('.el-message--success'); readonly errorMessage = page.locator('.el-message--error'); constructor(page: Page) { this.page = page; } async goto() { await this.page.goto('/operatingroom'); await this.page.waitForLoadState('networkidle'); } async generateCharges() { await this.generateBtn.click(); await this.page.waitForLoadState('networkidle'); } async rapidClickGenerate(times: number = 5) { for (let i = 0; i < times; i++) { await this.generateBtn.click().catch(() => {}); } await this.page.waitForLoadState('networkidle'); } async getDialogCount(): Promise { return await this.page.locator('.el-dialog, .el-message-box').count(); } async expectNoLocationIdError() { await expect(this.page.locator('text=发放库房为空')).toHaveCount(0, { timeout: 5000 }); } async expectSaveSuccess() { await expect(this.successMessage).toBeVisible({ timeout: 10000 }); } }