- 新增 user.check 功能用于核对人员是否已有系统账号 - 在 assistant-table-layout.js 中为用户表格添加 checkedIdentity 和 matchResult 字段 - 优化 AssistantConversationService 中的任务记忆和澄清流程 - 支持对草稿特定行进行修改,无需重新填写整张表 - 限制 user.check 操作最大查询数量为 100 条记录 - 实现中断任务恢复机制,保持原始请求上下文 - 添加针对多行数据选择性修改的目标行标识支持
38 lines
3.5 KiB
JavaScript
38 lines
3.5 KiB
JavaScript
import {afterEach,expect,it,vi} from 'vitest'
|
|
import {shallowMount} from '@vue/test-utils'
|
|
import {readFileSync} from 'node:fs'
|
|
import {resolve} from 'node:path'
|
|
import {parse} from '@vue/compiler-sfc'
|
|
import Borrow from '../../src/components/ProjectLoans/BatchBorrow.vue'
|
|
import Receipt from '../../src/components/ReceiptDialog/Batch.vue'
|
|
vi.mock('@/utils/request',()=>({default:vi.fn()}))
|
|
vi.mock('@/utils/use-compact-layout',()=>({useCompactLayout:()=>({compact:false})}))
|
|
const mounted=[]
|
|
afterEach(()=>{for(const w of mounted.splice(0))w.unmount()})
|
|
const globals={stubs:{ElDialog:{template:'<div><slot name="header" :titleId="\'test-heading\'"/><slot/><slot name="footer"/></div>'},ElTable:{template:'<div/>'},ElTableColumn:true,ElForm:{template:'<form><slot/></form>'},ElFormItem:{template:'<div><slot/></div>'},ElButton:{props:['disabled'],template:'<button :disabled="disabled"><slot/></button>'},DialogWorkspace:{template:'<div><slot name="header"/><slot :tableHeight="300"/></div>'}}}
|
|
function render(component,data){const w=shallowMount(component,{data:()=>({visible:true,...data}),global:globals});mounted.push(w);return w}
|
|
it('borrow review separates basic information from all shortcuts and preserves amount and area edits',async()=>{
|
|
const rows=[{key:'a',stockNum:8,quantity:1,toAreaId:2},{key:'b',stockNum:6,quantity:1,toAreaId:2}]
|
|
const w=render(Borrow,{stage:'review',rows,uniformArea:3,areas:[{id:3,areaName:'新库区'}]})
|
|
expect(w.find('.batch-dialog-form').attributes('label-position')).toBe('top')
|
|
expect(w.find('.batch-dialog-form').findAll('button')).toHaveLength(0)
|
|
expect(w.find('.batch-dialog-toolbar__actions').text()).toContain('应用库区')
|
|
const buttons=w.findAll('button');await buttons.find(b=>b.text()==='应用库区').trigger('click');expect(w.vm.rows.map(r=>r.toAreaId)).toEqual([3,3])
|
|
await buttons.find(b=>b.text()==='按可用数量填写').trigger('click');expect(w.vm.rows.map(r=>r.quantity)).toEqual([8,6])
|
|
expect(w.emitted('changed')).toBeUndefined();expect(w.vm.workspaceHeight).toContain('318px')
|
|
await w.setData({rows:[...w.vm.rows,{key:'c',stockNum:9,quantity:1,payload:{key:'frozen'}}]})
|
|
expect(w.findAll('button').some(b=>b.text()==='按可用数量填写')).toBe(false)
|
|
})
|
|
it('receipt shortcuts stay outside the form and keep selection and acceptance rules',async()=>{
|
|
const w=render(Receipt,{mode:'arrival',rows:[{id:1,chosen:true,maximum:8,quantity:0},{id:2,chosen:false,maximum:6,quantity:0},{id:3,chosen:true,maximum:3,quantity:2,arrivalIdCreated:33}]})
|
|
expect(w.find('.batch-dialog-form').attributes('label-position')).toBe('top');expect(w.find('.batch-dialog-form').findAll('button')).toHaveLength(0)
|
|
await w.findAll('button').find(b=>b.text()==='本次全部到齐').trigger('click');expect(w.vm.rows.map(r=>r.quantity)).toEqual([8,0,2])
|
|
expect(w.emitted('changed')).toBeUndefined();await w.setData({mode:'acceptance'});expect(w.findAll('button').some(b=>b.text()==='本次全部到齐')).toBe(false)
|
|
})
|
|
it('all updated batch dialogs opt into shared styles without altering submission controls',()=>{
|
|
for(const file of ['ProjectLoans/BatchBorrow.vue','ProjectLoans/BatchReturn.vue','ReceiptDialog/Batch.vue','ReceiptDialog/PurchaseBulkEdit.vue','Production/BatchActions.vue']){
|
|
const source=readFileSync(resolve(process.cwd(),'src/components',file),'utf8'),sfc=parse(source)
|
|
expect(sfc.errors).toHaveLength(0);expect(source).toContain('class="batch-dialog');expect(source).toContain('batch-dialog-form');expect(source).toContain('label-position="top"');expect(source).toContain(':loading="saving"');expect(source).toContain(':disabled="saving');
|
|
}
|
|
})
|