// Isolated real controls: no login, business requests, saves or production data. import { createApp, nextTick } from 'vue' import { compile } from 'vue/dist/vue.esm-bundler.js' import ElementPlus from 'element-plus' import 'element-plus/dist/index.css' import Cell from '../../src/components/PurchaseSheet/Cell.vue' import Sheet from '../../src/components/PurchaseSheet/index.vue' const names=['activateCell','nameMenu','nameChoices','itemLabel','currentSpec','menu','menuOpen','brands','specs','identityEditor','nameChanged','brandChanged','specChanged','mergeItems'] const methods=Object.fromEntries(names.map(name=>[name,Sheet.methods[name]])) let choices=0 methods.nameChoices=function(row){if(++choices>300)throw new Error('nameChoices render loop: '+choices);return Sheet.methods.nameChoices.call(this,row)} createApp({ components:{Cell}, data:()=>({row:{_key:'draft',materialName:'',materialBrand:'',materialParams:'',finalUnitPrice:null},columns:[{field:'materialName',label:'物品名称'},{field:'materialParams',label:'规格型号'},{field:'materialBrand',label:'品牌'},{field:'finalUnitPrice',label:'报价'}],items:[],nameOptions:null,nameMenuRow:null,nameLoading:false,activeMenu:null,editCell:null,saving:false,searches:0,ticks:0}), computed:{cellOwner(){return this},nameItems(){return this.nameOptions||this.items},isEditing(){return true},sheet(){return {rows:[this.row]}}}, methods:{...methods,cellError(){return ''},editableCell(){return true},readonly(){return false},fieldLocked(){return false},displayCell(row,field){return row[field]||'—'},originalIndex(){return 0},rememberCell(){},paste(){},navigate(){},clearLoan(){},async revealRow(){await nextTick()},async loadName(){},async searchNames(keyword){this.searches++;this.nameLoading=true;await new Promise(resolve=>setTimeout(resolve,80));this.mergeItems([]);this.nameOptions=[];this.nameLoading=false}}, mounted(){this.timer=setInterval(()=>this.ticks++,200)},beforeUnmount(){clearInterval(this.timer)}, render:compile(`

采购单元格回归测试

仅测试输入,不保存业务数据。心跳 {{ticks}} · 搜索 {{searches}} 次

{{c.label}}
{{JSON.stringify(row,null,2)}}
`) }).use(ElementPlus).mount('#app')