EditCellTable-d1f18747.js 4.62 KB
var m=(e,d,a)=>new Promise((l,r)=>{var p=t=>{try{n(a.next(t))}catch(i){r(i)}},o=t=>{try{n(a.throw(t))}catch(i){r(i)}},n=t=>t.done?l(t.value):Promise.resolve(t.value).then(p,o);n((a=a.apply(e,d)).next())});import{d as u,n as c,a8 as f,_ as C,$ as b,f as h}from"./vue-5a35c3f5.js";import{B as _}from"./BasicTable-7dbd57c0.js";import"./componentMap-4d1c941b.js";import"./TableImg.vue_vue_type_style_index_0_lang-6e828edc.js";import{u as w}from"./useTable-e28259fb.js";import{o as s}from"./select-93eac05e.js";import{d as E}from"./table-2ce11aa8.js";import{t as x}from"./tree-164e6087.js";import{a as I,_ as v}from"./index.js";import{aQ as P}from"./antd-6b087f69.js";import"./BasicForm-53100365.js";import"./FormItem-ffc5ecef.js";import"./helper-95474dfc.js";import"./BasicForm.vue_vue_type_style_index_0_lang-3479a052.js";import"./uniqBy-0cd5a663.js";import"./index-c1c2669a.js";import"./useWindowSizeFn-cc2fb57c.js";import"./useForm-86d11f60.js";import"./RadioButtonGroup-72b65d2e.js";import"./useFormItem-9ea791b8.js";import"./uuid-31b8b5a4.js";import"./merge-4fa735fa.js";import"./onMountedOrActivated-52afb7a7.js";import"./download-3d468407.js";import"./base64Conver-39fc0d26.js";import"./index-1ca3bd8a.js";import"./IconPicker-6bbd557c.js";import"./index-9a895eb5.js";import"./sortable.esm-4ae27e0b.js";const g=[{title:"输入框",dataIndex:"name",edit:!0,editComponentProps:{prefix:"$"},width:200},{title:"默认输入状态",dataIndex:"name7",edit:!0,editable:!0,width:200},{title:"输入框校验",dataIndex:"name1",edit:!0,editRule:!0,width:200},{title:"输入框函数校验",dataIndex:"name2",edit:!0,editRule:e=>m(void 0,null,function*(){return e==="2"?"不能输入该值":""}),width:200},{title:"数字输入框",dataIndex:"id",edit:!0,editRule:!0,editComponent:"InputNumber",width:200,editComponentProps:()=>({max:100,min:0}),editRender:({text:e})=>c(P,{percent:Number(e)})},{title:"下拉框",dataIndex:"name3",edit:!0,editComponent:"Select",editComponentProps:{options:[{label:"Option1",value:"1"},{label:"Option2",value:"2"}]},width:200},{title:"远程下拉",dataIndex:"name4",edit:!0,editComponent:"ApiSelect",editComponentProps:{api:s,resultField:"list",labelField:"name",valueField:"id"},width:200},{title:"远程下拉树",dataIndex:"name8",edit:!0,editComponent:"ApiTreeSelect",editRule:!1,editComponentProps:{api:x,resultField:"list"},width:200},{title:"日期选择",dataIndex:"date",edit:!0,editComponent:"DatePicker",editComponentProps:{valueFormat:"YYYY-MM-DD",format:"YYYY-MM-DD"},width:200},{title:"时间选择",dataIndex:"time",edit:!0,editComponent:"TimePicker",editComponentProps:{valueFormat:"HH:mm",format:"HH:mm"},width:200},{title:"勾选框",dataIndex:"name5",edit:!0,editComponent:"Checkbox",editValueMap:e=>e?"是":"否",width:200},{title:"开关",dataIndex:"name6",edit:!0,editComponent:"Switch",editValueMap:e=>e?"开":"关",width:200},{title:"单选框",dataIndex:"radio1",edit:!0,editComponent:"RadioGroup",editComponentProps:{options:[{label:"选项1",value:"1"},{label:"选项2",value:"2"}]},width:200},{title:"单选按钮框",dataIndex:"radio2",edit:!0,editComponent:"RadioButtonGroup",editComponentProps:{options:[{label:"选项1",value:"1"},{label:"选项2",value:"2"}]},width:200},{title:"远程单选框",dataIndex:"radio3",edit:!0,editComponent:"ApiRadioGroup",editComponentProps:{api:s,resultField:"list",labelField:"name",valueField:"id"},width:200}],T=u({components:{BasicTable:_},setup(){const[e]=w({title:"可编辑单元格示例",api:E,columns:g,showIndexColumn:!1,bordered:!0}),{createMessage:d}=I();function a({record:o,index:n,key:t,value:i}){return console.log(o,n,t,i),!1}function l({value:o,key:n,id:t}){return d.loading({content:`正在模拟保存${n}`,key:"_save_fake_data",duration:0}),new Promise(i=>{setTimeout(()=>{o===""?(d.error({content:"保存失败:不能为空",key:"_save_fake_data",duration:2}),i(!1)):(d.success({content:`记录${t}${n}已保存`,key:"_save_fake_data",duration:2}),i(!0))},2e3)})}function r(le){return m(this,arguments,function*({record:o,index:n,key:t,value:i}){return console.log("单元格数据正在准备提交",{record:o,index:n,key:t,value:i}),yield l({id:o.id,key:t,value:i})})}function p(){console.log("cancel")}return{registerTable:e,handleEditEnd:a,handleEditCancel:p,beforeEditSubmit:r}}}),k={class:"p-4"};function R(e,d,a,l,r,p){const o=f("BasicTable");return C(),b("div",k,[h(o,{onRegister:e.registerTable,onEditEnd:e.handleEditEnd,onEditCancel:e.handleEditCancel,beforeEditSubmit:e.beforeEditSubmit},null,8,["onRegister","onEditEnd","onEditCancel","beforeEditSubmit"])])}const ae=v(T,[["render",R],["__file","E:/allcode/erp/test7901/order-erp-front/src/views/demo/table/EditCellTable.vue"]]);export{ae as default};