cmvr-wms/ruoyi-ui-vue3/tests/ui/assistant-draft-review.html
lixiaolong efd8492386 refactor(assistant): 优化报价预览组件的数据处理逻辑
- 为quoteFields中的id字段添加只读属性配置
- 添加newPrice和newAmount计算函数统一处理价格显示逻辑
- 重构模板中的价格和金额显示,使用新的计算函数替代内联表达式
- 更新测试用例以验证恢复处理后的状态显示正确性
2026-10-20 16:06:03 +08:00

27 lines
4.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html><html lang="zh-CN"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>助手确认单范围调整 · 隔离 UI 测试</title><div id="app"></div>
<script type="module">
import {createApp,ref} from 'vue/dist/vue.esm-bundler.js'
import {createPinia} from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import Draft from '../../src/components/BusinessAssistant/AssistantDraft.vue'
import {assistantApplyDraftChanges} from '../../src/utils/assistant-draft-edit.js'
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:'采购明细',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:'模拟匹配成功'}]},
{_rowId:'quote-24',id:{keyword:'水冷一体管',spec:'白色带线1.5米'},finalUnitPrice:29.2,_sourceRow:24,_sourceText:'报价第24项:水冷一体管;4×29.2',_errors:['采购明细未匹配,请选择已有记录'],_quotePreview:[{line:24,name:'水冷一体管',quantity:4,previousPrice:null,unitPrice:29.2,newAmount:null,sourceText:'报价第24项:水冷一体管;4×29.2',notice:'未匹配采购记录,不会新增或修改',error:'采购明细未匹配,请选择已有记录'}]}]
:[{_rowId:'item-1',materialName:'模拟水泵',quantity:2},{_rowId:'item-24',materialName:'模拟待补充物品',quantity:4,_sourceRow:24,_errors:['请补充单位']}]
draft.value={id:value==='quote'?1:2,action:value==='quote'?'purchase.correctPrice':'purchase.create',label:value==='quote'?'更正采购报价':'导入采购确认',status:'WAIT_CONFIRM',ready:false,version:1,fields:value==='quote'?quoteFields:purchaseFields,results:[]}
}
function change(event){rows.value=assistantApplyDraftChanges(rows.value,event,{action:draft.value.action,fields:draft.value.fields,draft:draft.value});message.value='待重新校验,未执行业务'}
function remove(ids){const result=assistantExcludeDraftRows(rows.value,ids,{draft:draft.value,action});if(result.error){message.value=result.error;return}rows.value=result.rows;excluded.value.push(...result.removed);message.value='只调整本次范围,未执行业务'}
function restore(id){const entry=excluded.value.find(item=>item.row._rowId===id);rows.value=assistantRestoreDraftRow(rows.value,entry,{draft:draft.value,action});excluded.value=excluded.value.filter(item=>item!==entry);message.value='已恢复,需重新校验'}
function preview(){if(mode.value==='quote')rows.value=rows.value.map(row=>row.skipCorrection?{...row,_errors:[],_quotePreview:row._quotePreview.map(q=>({...q,skipped:true,error:null}))}:row);message.value='仅模拟校验:'+rows.value.length+' 项保留,'+rows.value.filter(r=>r.skipCorrection).length+' 项明确跳过;未执行业务'}
reset('quote');return{mode,rows,excluded,draft,message,action,change,remove,restore,preview,reset}
},template:`<main><h2>确认单范围调整 · 隔离 UI 测试</h2><p>全部为模拟数据,不调用业务接口,不写数据库。</p><nav><button @click="reset('quote')">报价核对场景</button><button @click="reset('purchase')">导入采购场景</button></nav><Draft :draft="draft" :action="action" :rows="rows" :excluded-rows="excluded" @change="change" @remove="remove" @restore="restore"/><footer><span role="status">{{message}}</span><button @click="preview">校验预览(模拟)</button></footer></main>`}).use(createPinia()).use(ElementPlus).mount('#app')
</script><style>body{font:14px/1.6 system-ui;background:#f5f7fb;color:#303840;margin:0}main{width:650px;max-width:calc(100vw - 32px);margin:20px auto}nav,footer{display:flex;gap:12px;align-items:center;flex-wrap:wrap;margin:12px 0}button{cursor:pointer}nav>button,footer>button{padding:8px 14px;background:#fff;border:1px solid #d5dce8;border-radius:5px;color:#2873bb}footer{background:#fff;padding:12px;border:1px solid #e0e5ed}footer span{flex:1;font-size:12px}</style></html>