refactor(assistant): 优化报价预览组件的数据处理逻辑
- 为quoteFields中的id字段添加只读属性配置 - 添加newPrice和newAmount计算函数统一处理价格显示逻辑 - 重构模板中的价格和金额显示,使用新的计算函数替代内联表达式 - 更新测试用例以验证恢复处理后的状态显示正确性
This commit is contained in:
parent
5cee6482f8
commit
efd8492386
@ -10,9 +10,9 @@
|
||||
<el-table-column prop="unit" label="单位" width="70"/>
|
||||
<el-table-column prop="quantity" label="采购数量" width="100"/>
|
||||
<el-table-column label="原报价" width="110"><template #default="{ row }">{{ row.previousPrice ?? '未报价' }}</template></el-table-column>
|
||||
<el-table-column label="新报价" width="110"><template #default="{ row }"><span :class="!row.skipped && !row._skipSelected ? 'assistant-quote-new' : ''">{{ row.skipped || row._skipSelected ? (correction ? '本次跳过' : '留空不变') : row.unitPrice }}</span></template></el-table-column>
|
||||
<el-table-column label="新报价" width="110"><template #default="{ row }"><span :class="!row.skipped && !row._skipSelected ? 'assistant-quote-new' : ''">{{ newPrice(row) }}</span></template></el-table-column>
|
||||
<el-table-column v-if="correction" prop="oldAmount" label="原采购金额" width="120"/>
|
||||
<el-table-column v-if="correction" label="新采购金额" width="120"><template #default="{ row }"><strong :class="!row.skipped && !row._skipSelected ? 'assistant-quote-new' : ''">{{ row.skipped || row._skipSelected ? '不修改' : row.newAmount }}</strong></template></el-table-column>
|
||||
<el-table-column v-if="correction" label="新采购金额" width="120"><template #default="{ row }"><strong :class="!row.skipped && !row._skipSelected ? 'assistant-quote-new' : ''">{{ newAmount(row) }}</strong></template></el-table-column>
|
||||
<el-table-column v-if="correction" label="联动影响" min-width="260"><template #default="{ row }">{{ row.notice }}</template></el-table-column>
|
||||
<el-table-column v-if="correction" prop="sourceText" label="报价原文(核对规格及数量)" min-width="300"/>
|
||||
<el-table-column label="核对结果" min-width="200"><template #default="{ row }"><span :class="reviewState(row).error ? 'assistant-quote-error' : ''">{{ correction ? reviewState(row).text : row.error || (row.skipped ? '保留原值,不更正' : '匹配成功,待人工确认') }}</span></template></el-table-column>
|
||||
@ -30,6 +30,8 @@ const page = ref(1), pageRows = computed(() => props.rows.slice((page.value - 1)
|
||||
const correction = computed(() => props.rows.some(row => Object.hasOwn(row, 'newAmount')))
|
||||
const canSkip = computed(() => correction.value && props.rows.some(row => row._canSkip))
|
||||
const reviewState = assistantQuotationReviewState
|
||||
function newPrice(row) { const state = reviewState(row); return correction.value ? state.skipped ? '本次跳过' : state.pending ? '待重新校验' : row.unitPrice : row.skipped ? '留空不变' : row.unitPrice }
|
||||
function newAmount(row) { const state = reviewState(row); return state.skipped ? '不修改' : state.pending ? '待重新校验' : row.newAmount }
|
||||
function toggleSkip(row) { if (props.busy) return; const change = assistantQuotationSkipChange(row); if (change) emit('skip', change) }
|
||||
watch(() => props.rows, () => { page.value = 1 })
|
||||
</script>
|
||||
|
||||
@ -46,6 +46,10 @@ describe('unmatched PDF quotations have a visible escape without deleting source
|
||||
expect(wrapper.find('button[aria-label="第24项恢复处理"]').element.disabled).toBe(true)
|
||||
await wrapper.find('button[aria-label="第24项恢复处理"]').trigger('click')
|
||||
expect(wrapper.emitted('skip')).toBeUndefined()
|
||||
await wrapper.setProps({ busy: false, rows: [{ ...missing()._quotePreview[0], _draftRowId: 'pdf-line-24', _canSkip: true, _skipSelected: false, skipped: true }] })
|
||||
expect(wrapper.text()).toContain('已恢复处理,请重新校验预览')
|
||||
expect(wrapper.text()).not.toContain('本次跳过,不修改采购')
|
||||
expect(wrapper.findAll('.assistant-quote-new').length).toBe(0)
|
||||
} finally { wrapper.unmount() }
|
||||
})
|
||||
it('purchase import drafts expose removal and restoration without editing or deleting business records', async () => {
|
||||
|
||||
@ -9,7 +9,7 @@ import {assistantApplyDraftChanges} from '../../src/utils/assistant-draft-edit.j
|
||||
import {assistantExcludeDraftRows,assistantRestoreDraftRow} from '../../src/utils/assistant-draft-exclusions.js'
|
||||
createApp({components:{Draft},setup(){
|
||||
const mode=ref('quote'),rows=ref([]),excluded=ref([]),draft=ref({}),message=ref(''),action={allowed:true,query:false}
|
||||
const quoteFields=[{key:'id',ref:'purchase',label:'采购明细'},{key:'finalUnitPrice',type:'decimal',label:'新报价'},{key:'skipCorrection',type:'boolean',label:'本项暂不更正'}]
|
||||
const quoteFields=[{key:'id',ref:'purchase',label:'采购明细',readonly:true},{key:'finalUnitPrice',type:'decimal',label:'新报价'},{key:'skipCorrection',type:'boolean',label:'本项暂不更正'}]
|
||||
const purchaseFields=[{key:'materialName',label:'物品名称'},{key:'quantity',label:'数量',type:'decimal'}]
|
||||
function reset(value){mode.value=value;excluded.value=[];message.value='';
|
||||
rows.value=value==='quote'?[{_rowId:'quote-1',id:7,finalUnitPrice:88,_quotePreview:[{line:1,name:'模拟水泵',quantity:2,previousPrice:60,unitPrice:88,newAmount:176,notice:'模拟匹配成功'}]},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user