cc1-form 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cc1-form.js +327 -327
- package/dist/cc1-form.umd.cjs +1 -1
- package/package.json +2 -2
package/dist/cc1-form.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(g,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("element-plus")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus"],e):(g=typeof globalThis<"u"?globalThis:g||self,e(g.cc1Form={},g.Vue,g.ElementPlus))})(this,(function(g,e,p){"use strict";class b{static router;static routes;static getRouterPath=()=>this.router.currentRoute.value.path;static EDialog={Insert:"Insert",Update:"Update",Remove:"Remove"};static isFun=(c,d)=>typeof c=="function"?c(d):c;static getRouterParams=()=>{const c=this.router.currentRoute.value.query||{},d=this.router.currentRoute.value.params||{};return Object.keys(c).length?c:Object.keys(d).length?d:{}};static moduleObj={};static loadModule=async c=>{if(!b.moduleObj[c])throw new Error(`模块${c}未加载,请赋值如:TSys.moduleObj = { ${c}: ()=>import('${c}') }`);const d=await b.moduleObj[c]();return d.default??d};static tipMessages={};static tipMessagesGap=500;static showMessage(c,d,i={}){const f=Date.now();if(!this.tipMessages[c]||f-this.tipMessages[c]>this.tipMessagesGap){this.tipMessages[c]=f;const h=Object.assign({message:c,type:d},i);p.ElMessage(h),setTimeout(()=>{delete this.tipMessages[c]},this.tipMessagesGap)}}static fail=(c,d={})=>{this.showMessage(c,"error",d)};static success=(c,d={})=>{this.showMessage(c,"success",d)};static loadingObj=null;static loadingTimer=null;static loading=(c=!0,d="加载中")=>{Timer.un(this.loadingTimer),this.loadingTimer=Timer.once(()=>{c?this.loadingObj=p.ElLoading.service({lock:!0,text:d,background:"rgba(0, 0, 0, 0.3)"}):this.loadingObj&&(this.loadingObj.close(),this.loadingObj=null)},50)};static openUrl=(c,d=!0)=>{if(d){let i=screen.width/2-500,f=screen.height/2-800/2-30;window.open(c,"_blank","toolbar=no, location=yes, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=1000, height=800, top="+f+", left="+i)}else window.open(c,"DescriptiveWindowName"+StrUtil.getId(),"resizable,scrollbars=yes,status=1,width=1024, height=600, top=0, left=0")};static getImgPic=c=>new Promise(async(d,i)=>{let f=document.getElementById(c.id);const h=await b.loadModule("html2canvas");try{h(f,{logging:!1,allowTaint:!0,scale:window.devicePixelRatio,width:c.windowWidth,height:c.windowHeight,windowWidth:c.windowWidth,windowHeight:c.windowHeight,useCORS:!0,backgroundColor:"#ffffff00"}).then(function(s){let t=s.toDataURL("image/png");d(t)})}catch(s){i(s)}})}class w{static pageField={num:"current",size:"size"};static resultField={list:"records",pages:"pages",num:"current",size:"size",total:"total"};static customComponent={};static findOptions=(c,d)=>{const i=c.column.find(h=>h.key===d),f=h=>h.replace(/-([a-z])/g,(s,t)=>t.toUpperCase());if(i)return i.options[f(i.type)]};static setOptionsData=(c,d,i)=>{const f=w.findOptions(c,d);f&&(f.data=i)};static form={openBefore:{parentId:(c,d,i,f)=>{c?d.type===b.EDialog.Insert?(d.form.parentId=c._id,d.form.sort=c.children.length+1):d.form.parentId=c.parentId.substring(c.parentId.lastIndexOf(",")+1):(d.form.parentId="0",d.form.sort=i.length+1),w.setOptionsData(f,"parentId",[{_id:"0",title:"根",children:i}])}}}}class V{static getIdFun=()=>StrUtil.uuid();static setId=(c,d,i)=>{d[c]||(d[c]=[]),d[c].forEach(f=>{i.forEach(h=>{let s=h.default??"";h.type==="number"&&(s=h.default??0),h.type==="boolean"&&(s=h.default??!1),h.type==="time"&&(s=h.default??new Date),f[h.value]===void 0&&(f[h.value]=s)}),f._id||(f._id=V.getIdFun())})};static add=(c,d,i,f)=>{const h=JSONUtil.cp(i);V.setId(c,d,i),d[c].push(h.reduce((s,t)=>{let n=t.default??"";return t.type==="number"&&(n=t.default??0),t.type==="boolean"&&(n=t.default??!1),t.type==="time"&&(n=t.default??new Date),s[t.value]=n,s},{_id:V.getIdFun()})),f?.(d)};static remove=(c,d,i,f)=>{d[c]=d[c].filter(h=>h._id!==i._id),f?.(d)};static getNoIdData=(c,d)=>{const i=JSONUtil.cp(c);return i.forEach(f=>{f._id&&delete f._id,d&&f[d]&&V.getNoIdData(f[d],d)}),i}}const T={key:0,class:"column",style:{width:"100%",gap:"10px"}},$={class:"row items-center",style:{gap:"10px",width:"100%"}},x=e.defineComponent({__name:"list",props:{row:{default:{}},label:{default:"label"},value:{default:"value"},itemFields:{default:[{label:"label",value:"label"},{label:"value",value:"value"}]},field:{default:"value"},inputWidth:{default:"120px"},inputClass:{default:""}},emits:["change"],setup(m,{emit:c}){const d=m,i=e.reactive({show:!1,add:(h,s,t)=>{V.add(h,s,t,()=>{f("change")})},remove:(h,s,t)=>{V.remove(h,s,t,()=>{f("change")})}});e.onMounted(()=>{V.setId(d.field,d.row,d.itemFields),i.show=!0});const f=c;return(h,s)=>{const t=e.resolveComponent("el-button"),n=e.resolveComponent("el-input");return i.show?(e.openBlock(),e.createElementBlock("div",T,[e.renderSlot(h.$slots,"list-start",{row:m.row}),e.createElementVNode("div",null,[e.createVNode(t,{link:"",type:"primary",onClick:s[0]||(s[0]=l=>i.add(m.field,m.row,m.itemFields))},{default:e.withCtx(()=>[...s[2]||(s[2]=[e.createTextVNode("添加",-1)])]),_:1})]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.row[m.field],l=>(e.openBlock(),e.createElementBlock("div",$,[e.renderSlot(h.$slots,"item-start",{item:l,row:m.row}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.itemFields,a=>(e.openBlock(),e.createBlock(n,{modelValue:l[a.value],"onUpdate:modelValue":o=>l[a.value]=o,style:e.normalizeStyle({width:m.inputWidth}),class:e.normalizeClass(m.inputClass),placeholder:a[m.label]||a[m.value],onChange:s[1]||(s[1]=o=>f("change"))},null,8,["modelValue","onUpdate:modelValue","style","class","placeholder"]))),256)),e.renderSlot(h.$slots,"item-end",{item:l,row:m.row}),e.createVNode(t,{link:"",type:"danger",onClick:a=>i.remove(m.field,m.row,l)},{default:e.withCtx(()=>[...s[3]||(s[3]=[e.createTextVNode("删除",-1)])]),_:1},8,["onClick"])]))),256)),e.renderSlot(h.$slots,"list-end",{row:m.row})])):e.createCommentVNode("",!0)}}}),O={class:"row curd-row"},N=e.defineComponent({__name:"column",props:{option:{default:{}},type:{default:""}},setup(m,{expose:c}){const d=b.isFun,i=b.EDialog,f=e.ref(),h=m,s=e.reactive({rules:{},show:!0,form:{},formDefault:{},formColumn:[],getDisabled:t=>t.disabled?.[(h.type||i.Insert)===i.Insert?"create":"update"],initColumnForm:async()=>{const t=h.option;s.formColumn=[];const n=[],l=h.option.form?.maxSpan||12,a=h.option.form?.defaultSpan||l;let o=[];const r=u=>{if(s.formDefault[u.key]=u.value,u.isForm){u.form=u.form||{span:a},u.form.span=u.form.span??a;let C=u.form.span,k=o.reduce((B,E)=>B+E.span,C);const y=o.length;o.push({item:u,span:C}),(y===1&&o[0].span===0||k>=l||C===0&&y>1)&&(n.push(o),o=[]),u.rules&&(s.rules[u.key]=u.rules)}};t.column.forEach(u=>{u.isForm=!0,r(u)}),o.length>0&&n.push(o),s.formColumn=n,s.form=JSONUtil.cp(s.formDefault)},init:async()=>{s.show=!1,await e.nextTick(),s.initColumnForm()}});return s.initColumnForm(),c({ref:f,conf:s}),(t,n)=>(e.openBlock(),e.createBlock(e.unref(p.ElForm),{ref_key:"ruleFormRef",ref:f,model:s.form,rules:s.rules},{default:e.withCtx(()=>[s.show?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(s.formColumn,l=>(e.openBlock(),e.createElementBlock("div",O,[e.renderSlot(t.$slots,"form-start",{row:s.form}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l,a=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.unref(d)(a.item.show?.form,s.form)??!0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(a.item.form.span>0?`col-${a.item.form.span}`:"col")},[e.createVNode(e.unref(p.ElFormItem),{label:a.item.label,prop:a.item.key,"label-width":a.item.form?.labelWidth||"100px"},{default:e.withCtx(()=>[e.renderSlot(t.$slots,"form-"+a.item.key+"-start",{row:s.form,item:a.item}),e.renderSlot(t.$slots,"form-"+a.item.key,{row:s.form,item:a.item},()=>[a.item.type==="input"?(e.openBlock(),e.createBlock(e.unref(p.ElInput),e.mergeProps({key:0,modelValue:s.form[a.item.key],"onUpdate:modelValue":o=>s.form[a.item.key]=o},{ref_for:!0},a.item.options?.input,e.toHandlers(a.item.options?.input?.on||{}),{disabled:s.getDisabled(a.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):a.item.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSwitch),e.mergeProps({key:1,modelValue:s.form[a.item.key],"onUpdate:modelValue":o=>s.form[a.item.key]=o},{ref_for:!0},a.item.options?.switch,e.toHandlers(a.item.options?.switch?.on||{}),{disabled:s.getDisabled(a.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):a.item.type==="select"?(e.openBlock(),e.createBlock(e.unref(p.ElSelect),e.mergeProps({key:2,modelValue:s.form[a.item.key],"onUpdate:modelValue":o=>s.form[a.item.key]=o},{ref_for:!0},a.item.options?.select,e.toHandlers(a.item.options?.select?.on||{}),{disabled:s.getDisabled(a.item),style:{width:"100%"}}),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.item.options?.select?.data,o=>(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:o.value,label:o.label,value:o.value},null,8,["label","value"]))),128))]),_:2},1040,["modelValue","onUpdate:modelValue","disabled"])):a.item.type==="list"?(e.openBlock(),e.createBlock(x,e.mergeProps({key:3,row:s.form,field:a.item.key},{ref_for:!0},a.item.options?.list,e.toHandlers(a.item.options?.list?.on||{}),{disabled:s.getDisabled(a.item),style:{width:"100%"}}),null,16,["row","field","disabled"])):a.item.type==="tree-select"?(e.openBlock(),e.createBlock(e.unref(p.ElTreeSelect),e.mergeProps({key:4,modelValue:s.form[a.item.key],"onUpdate:modelValue":o=>s.form[a.item.key]=o},{ref_for:!0},a.item.options?.treeSelect,e.toHandlers(a.item.options?.treeSelect?.on||{}),{disabled:s.getDisabled(a.item),style:{width:"100%"}}),null,16,["modelValue","onUpdate:modelValue","disabled"])):a.item.type==="datetime"?(e.openBlock(),e.createBlock(e.unref(p.ElDatePicker),e.mergeProps({key:5,modelValue:s.form[a.item.key],"onUpdate:modelValue":o=>s.form[a.item.key]=o},{ref_for:!0},a.item.options?.datetime,e.toHandlers(a.item.options?.datetime?.on||{}),{disabled:s.getDisabled(a.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.unref(w).customComponent[a.item.type]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(w).customComponent[a.item.type]),e.mergeProps({key:6,modelValue:s.form[a.item.key],"onUpdate:modelValue":o=>s.form[a.item.key]=o},{ref_for:!0},a.item.options?.[a.item.type],e.toHandlers(a.item.options?.[a.item.type]?.on||{}),{disabled:s.getDisabled(a.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.createCommentVNode("",!0)]),e.renderSlot(t.$slots,"form-"+a.item.key+"-end",{row:s.form,item:a.item})]),_:2},1032,["label","prop","label-width"])],2)):e.createCommentVNode("",!0)],64))),256)),e.renderSlot(t.$slots,"form-end",{row:s.form})]))),256)):e.createCommentVNode("",!0)]),_:3},8,["model","rules"]))}});class S{static exportToExcel=async(c,d,i)=>{const f=await b.loadModule("xlsx"),h=c.map(n=>{const l={};return d.forEach(a=>{l[a.label]=n[a.key]}),l}),s=f.utils.json_to_sheet(h),t=f.utils.book_new();f.utils.book_append_sheet(t,s,"Sheet1"),i?typeof i=="function"&&(i=i()):i=`导出数据_${new Date().Format("yyyy-MM-dd")}_${new Date().getTime()}`,f.writeFile(t,`${i}.xlsx`)}}const L={class:"dialog-footer"},I=e.defineComponent({__name:"switchConfirm",setup(m,{expose:c}){const d=e.ref(!1),i=e.ref("确认修改"),f=e.ref("确认要修改状态吗?");let h=null,s=null;const t=a=>(a?.title&&(i.value=a.title),a?.content&&(f.value=a.content),d.value=!0,new Promise((o,r)=>{h=o,s=r})),n=()=>{d.value=!1,h?.(!0),h=null,s=null},l=()=>{d.value=!1,s?.(new Error("用户取消操作")),h=null,s=null};return c({open:t}),(a,o)=>(e.openBlock(),e.createBlock(e.unref(p.ElDialog),{modelValue:d.value,"onUpdate:modelValue":o[0]||(o[0]=r=>d.value=r),title:i.value,"close-on-click-modal":!1,width:"400px"},{footer:e.withCtx(()=>[e.createElementVNode("span",L,[e.createVNode(e.unref(p.ElButton),{onClick:l},{default:e.withCtx(()=>[...o[1]||(o[1]=[e.createTextVNode("取消",-1)])]),_:1}),e.createVNode(e.unref(p.ElButton),{type:"primary",onClick:n},{default:e.withCtx(()=>[...o[2]||(o[2]=[e.createTextVNode("确认",-1)])]),_:1})])]),default:e.withCtx(()=>[e.createElementVNode("div",null,e.toDisplayString(f.value),1)]),_:1},8,["modelValue","title"]))}}),z={class:"col relative cc1-form-box"},j={class:"absolute row fit",style:{overflow:"hidden"}},M={class:"col column"},R={key:0,class:"relative curd-search"},H={class:"mb-10 flex justify-between items-center"},A={class:"flex items-center",style:{gap:"10px"}},J={key:0},_={key:1},W={key:2},K={class:"export-btn"},q={class:"flex items-center",style:{gap:"10px"}},G={class:"col fit-width relative"},X={class:"absolute column fit"},Q={class:"row justify-end mt-10 mb-10"},Y={class:"row form-item-content",style:{width:"100%"}},Z={class:"col"},P={class:"dialog-footer"},v={class:"dialog-footer"},F=e.defineComponent({__name:"index",props:{option:{default:{}}},setup(m,{expose:c}){const d=b.EDialog,i=m,f=e.ref(),h=e.ref(),s=b.isFun,t=e.reactive({search:{column:{list:[]},form:{},formDefault:{},getPlaceholder:(n,l="请输入")=>n.text?.search?.placeholder===void 0?`${l}${n.label}`:n.text?.search?.placeholder,getFormData:()=>{let n={};i.option.column.forEach(a=>{(typeof a.show?.search=="function"?a.show?.search(t.search.form):a.show?.search)&&(n[a.key]=t.search.form[a.key])});const l=i.option.search?.before?.(n);return l&&(n=l),n},reset:()=>{const n=t.search.formDefault;Object.keys(n).forEach(l=>{i.option.search?.resetMode==="default"?n[l]=t.search.formDefault[l]:n[l]=void 0}),t.search.form=JSONUtil.cp(n),t.page.num=1,t.table.getList()},submit:()=>{t.page.num=1,t.table.getList()}},page:{size:i.option.page?.size||10,sizeList:i.option.page?.sizeList||[10,20,50,100],num:1,total:0,layout:i.option.page?.layout||"total, sizes, prev, pager, next, jumper"},table:{loading:!1,data:[],expand:{isExpand:!1,rowKeys:[],change:(n,l)=>{},all:()=>{if(t.table.expand.isExpand)t.table.expand.rowKeys=[];else{const n=l=>{let a=[];return l.forEach(o=>{a.push(o._id),o.children&&o.children.length>0&&(a=a.concat(n(o.children)))}),a};t.table.expand.rowKeys=n(t.table.data)}t.table.expand.isExpand=!t.table.expand.isExpand}},column:{list:[],show:{listSource:[],list:[]}},getList:async()=>{t.table.loading=!0;const n=i.option.api.list;try{const l=await n({[w.pageField.size]:t.page.size,[w.pageField.num]:t.page.num,...t.search.getFormData()}),a=w.resultField,o=l.data||{[a.list]:l};let r=(Array.isArray(o[a.list]),o[a.list]);t.table.data=i.option.data?await i.option.data(r):r,t.page.total=o[a.total]||0}catch(l){console.error(l)}finally{t.table.loading=!1}},selection:{list:[],change:n=>{t.table.selection.list=n}},exportFun:{start:async n=>{let l=await t.table.exportFun[n](),a=i.option.column;const o=JSONUtil.cp({data:l,columns:a}),r=i.option.tools?.export||{};r.before&&r.before(o),S.exportToExcel(o.data,o.columns,r.fileName)},select:()=>{if(t.table.selection.list.length===0)throw b.fail("请选择要导出的数据"),new Error("请选择要导出的数据");return t.table.selection.list},page:()=>{if(t.table.data.length===0)throw b.fail("暂无数据"),new Error("暂无数据");return t.table.data},all:async()=>{t.table.loading=!0;const n=i.option.api.list;try{const{data:l}=await n({[w.pageField.size]:999999,[w.pageField.num]:1});return l[w.resultField.list]}catch(l){console.error(l)}finally{t.table.loading=!1}}},export:n=>{t.table.exportFun.start(n)}},update:{title:"",rules:{},show:!1,showContent:!1,loading:!1,type:d.Insert,form:{},formDefault:{},formColumn:[],getDisabled:n=>n.disabled?.[t.update.type===d.Insert?"create":"update"],edit:{data:{},getApiData:n=>{if(i.option.form?.editAll)return n;let l={_id:t.update.edit.data._id};return Object.keys(t.update.edit.data).forEach(a=>{n[a]!==t.update.edit.data[a]&&(l[a]=n[a])}),l}},open:(n,l)=>{t.update.showContent||FunUtil.throttle(async()=>{t.update.type=n;const a=n===d.Insert;t.update.edit.data=l,t.update.title=a?"新增":"编辑",t.update.form=JSONUtil.cp(a?t.update.formDefault:l),await i.option.form?.openBefore?.(l,t.update),t.update.show=!0,t.update.showContent=!0,i.option.form?.openAfter?.(l,t.update)})},submit:()=>{FunUtil.throttle(async()=>{await h.value?.validate(async(a,o)=>new Promise((r,u)=>{a||(b.fail("请检查表单数据"),u(!1)),r()})),t.update.loading=!0;const n=t.update.type===d.Insert?i.option.api.create:i.option.api.update;let l=JSONUtil.cp(t.update.form);delete l.children,await i.option.form?.submitBefore?.(l,t.update),Object.keys(l).forEach(a=>{if(typeof l[a]=="string"&&l[a].indexOf("T")>-1){const o=new Date(l[a]).getTime();!isNaN(o)&&o>new Date("1971-01-01").getTime()&&(l[a]=o)}});try{await n({...l}),t.update.close(),await t.table.getList(),i.option.form?.submitAfter?.(l,t.update)}catch(a){console.error(a)}finally{t.update.loading=!1}})},close:()=>{t.update.show=!1,setTimeout(()=>{t.update.showContent=!1},350)}},remove:{title:"确认删除",show:!1,items:[],loading:!1,close:()=>{t.remove.show=!1},open:n=>{if(n.length===0){b.fail("请选择要删除的数据");return}t.remove.items=n,t.remove.show=!0},submit:()=>{FunUtil.throttle(async()=>{t.remove.loading=!0;const n=i.option.api.delete;try{await n({_id:t.remove.items.map(l=>l._id),items:t.remove.items}),b.success("操作成功"),t.table.data.length<=1&&t.page.num>1&&(t.page.num-=1),t.remove.close(),await t.table.getList()}catch(l){console.error(l)}finally{t.remove.loading=!1}})}},init:()=>{t.initCurdConfig(),t.initColumnOptions(),t.initColumnForm()},initCurdConfig:()=>{const l={tools:{search:!0,reset:!0,expand:!1,add:o=>o===void 0,update:!0,delete:!0,export:{show:!0}},table:{headerCellClassName:"table-header",rowKey:"_id",emptyText:"暂无数据",highlightCurrentRow:!0}},a=i.option;Object.keys(l).forEach(o=>{a[o]=ObjectUtil.deepMerge(l[o],a[o]||{})})},initColumnOptions:()=>{const n=i.option,l=a=>{const r={options:{switch:{activeValue:!0,activeLabel:"开启",inactiveValue:!1,inactiveLabel:"关闭",tableBeforeChange:async(C,k)=>{const y=a.options?.switch;try{await f.value?.open({title:"确认修改",content:`确认要${k[C]===y.activeValue?y.inactiveLabel:y.activeLabel}吗?`}),t.table.loading=!0;try{return await i.option.api.update({_id:k._id,[C]:k[C]===y.activeValue?y.inactiveValue:y.activeValue,final(B,E,U){t.table.loading=!1}}),t.table.loading=!1,b.success("操作成功"),t.table.getList(),!0}catch(B){return console.error(B),!1}finally{t.table.loading=!1}}catch{return!1}}},treeSelect:{rowKey:"_id",nodeKey:"_id",multiple:!0,renderAfterExpand:!1,showCheckbox:!0,checkStrictly:!0,checkOnClickNode:!0,props:{label:"title",children:"children"}},datetime:{type:"datetime"}},table:{table:!0,minWidth:"100px",align:"center"},show:{table:!0,search:!1,form:!0},sort:{search:0,table:0,form:0}},u=a;Object.keys(r).forEach(C=>{u[C]=ObjectUtil.deepMerge(r[C],u[C]||{})})};n.column.forEach(l),n.table?.column?.forEach(l)},initColumnForm:()=>{const n=i.option;t.update.formColumn=[],t.table.column.show={list:[],listSource:[]};const l=[],a=i.option.form?.maxSpan||12,o=i.option.form?.defaultSpan||a/2;let r=[];const u=k=>{if(t.update.formDefault[k.key]=k.value,k.table.table&&(k.show.table&&t.table.column.show.list.push(k.key),k.table.table&&t.table.column.show.listSource.push(k.key)),k.isForm){k.form=k.form||{span:o},k.form.span=k.form.span??o;let y=k.form.span,B=r.reduce((U,oe)=>U+oe.span,y);const E=r.length;r.push({item:k,span:y}),(E===1&&r[0].span===0||B>=a||y===0&&E>1)&&(l.push(r),r=[]),k.rules&&(t.update.rules[k.key]=k.rules)}};n.column.forEach(k=>{k.isForm=!0,u(k)}),i.option.table?.column?.forEach(k=>{k.isForm=!1,u(k)}),t.search.column.list=n.column.concat(n.table?.column||[]),t.table.column.list=t.search.column.list.filter(k=>k.table?.table),t.search.column.list.sort((k,y)=>k.sort?.search-y.sort?.search),t.table.column.list.sort((k,y)=>k.sort?.table-y.sort?.table),r.length>0&&l.push(r),t.update.formColumn=l;const C=i.option.search?.formDefault;C&&Object.keys(C).forEach(k=>{t.search.formDefault[k]=C[k]}),n.column.forEach(k=>{k.show?.search||(t.search.formDefault[k.key]=void 0)}),t.search.form=JSONUtil.cp(t.search.formDefault)}});return t.init(),e.onMounted(()=>{t.table.getList()}),c({conf:t}),(n,l)=>{const a=e.resolveDirective("loading");return e.openBlock(),e.createElementBlock("div",z,[e.createElementVNode("div",j,[e.renderSlot(n.$slots,"box-left"),e.createElementVNode("div",M,[m.option.search?.show!==!1?(e.openBlock(),e.createElementBlock("div",R,[e.createVNode(e.unref(p.ElForm),{model:t.search.form,inline:""},{default:e.withCtx(()=>[e.renderSlot(n.$slots,"search-start",{row:t.search.form}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.search.column.list,o=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:o.key},[(typeof o.show?.search=="function"?o.show?.search(t.search.form):o.show?.search)?(e.openBlock(),e.createBlock(e.unref(p.ElFormItem),{key:0,label:typeof o.text?.search?.label=="string"?o.text?.search?.label:o.label,class:e.normalizeClass({"hide-label":typeof o.text?.search?.label=="boolean"?!o.text?.search?.label:!1})},{default:e.withCtx(()=>[e.renderSlot(n.$slots,"search-"+o.key,{row:t.search.form},()=>[o.type==="input"?(e.openBlock(),e.createBlock(e.unref(p.ElInput),{key:0,modelValue:t.search.form[o.key],"onUpdate:modelValue":r=>t.search.form[o.key]=r,placeholder:t.search.getPlaceholder(o),clearable:"",disabled:o.disabled?.search},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled"])):o.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSelect),{key:1,modelValue:t.search.form[o.key],"onUpdate:modelValue":r=>t.search.form[o.key]=r,placeholder:t.search.getPlaceholder(o,"请选择"),clearable:"",disabled:o.disabled?.search},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:o.options?.switch?.activeValue,label:o.options?.switch?.activeLabel,value:o.options?.switch?.activeValue},null,8,["label","value"])),(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:o.options?.switch?.inactiveValue,label:o.options?.switch?.inactiveLabel,value:o.options?.switch?.inactiveValue},null,8,["label","value"]))]),_:2},1032,["modelValue","onUpdate:modelValue","placeholder","disabled"])):o.type==="select"?(e.openBlock(),e.createBlock(e.unref(p.ElSelect),{key:2,modelValue:t.search.form[o.key],"onUpdate:modelValue":r=>t.search.form[o.key]=r,placeholder:t.search.getPlaceholder(o,"请选择"),clearable:"",disabled:o.disabled?.search},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options?.select?.data,r=>(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:r.value,label:r.label,value:r.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","placeholder","disabled"])):e.createCommentVNode("",!0)])]),_:2},1032,["label","class"])):e.createCommentVNode("",!0)],64))),128)),e.renderSlot(n.$slots,"search-center",{row:t.search.form}),e.createVNode(e.unref(p.ElFormItem),null,{default:e.withCtx(()=>[m.option.tools?.search?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:0,type:"primary",onClick:t.search.submit},{default:e.withCtx(()=>[...l[8]||(l[8]=[e.createTextVNode(" 搜索 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),m.option.tools?.reset?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:1,onClick:t.search.reset},{default:e.withCtx(()=>[...l[9]||(l[9]=[e.createTextVNode("重置",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0)]),_:1}),e.renderSlot(n.$slots,"search-end",{row:t.search.form})]),_:3},8,["model"])])):e.createCommentVNode("",!0),e.createElementVNode("div",H,[e.createElementVNode("div",A,[e.unref(s)(m.option.tools?.add)?(e.openBlock(),e.createElementBlock("div",J,[e.createVNode(e.unref(p.ElButton),{type:"primary",onClick:l[0]||(l[0]=o=>t.update.open(e.unref(d).Insert))},{default:e.withCtx(()=>[...l[10]||(l[10]=[e.createTextVNode("新增",-1)])]),_:1})])):e.createCommentVNode("",!0),m.option.table?.selectable&&e.unref(s)(m.option.tools?.delete)?(e.openBlock(),e.createElementBlock("div",_,[e.createVNode(e.unref(p.ElButton),{type:"danger",onClick:l[1]||(l[1]=o=>t.remove.open(t.table.selection.list))},{default:e.withCtx(()=>[...l[11]||(l[11]=[e.createTextVNode(" 删除 ",-1)])]),_:1})])):e.createCommentVNode("",!0),m.option.tools?.expand?(e.openBlock(),e.createElementBlock("div",W,[e.createVNode(e.unref(p.ElButton),{type:"warning",onClick:l[2]||(l[2]=o=>t.table.expand.all())},{default:e.withCtx(()=>[...l[12]||(l[12]=[e.createTextVNode("展开/收缩",-1)])]),_:1})])):e.createCommentVNode("",!0),m.option.tools?.export?.show?(e.openBlock(),e.createBlock(e.unref(p.ElDropdown),{key:3,onCommand:t.table.export},{dropdown:e.withCtx(()=>[e.createVNode(e.unref(p.ElDropdownMenu),null,{default:e.withCtx(()=>[e.createVNode(e.unref(p.ElDropdownItem),{command:"select"},{default:e.withCtx(()=>[...l[14]||(l[14]=[e.createTextVNode("导出选中",-1)])]),_:1}),e.createVNode(e.unref(p.ElDropdownItem),{command:"page"},{default:e.withCtx(()=>[...l[15]||(l[15]=[e.createTextVNode("导出本页",-1)])]),_:1}),e.createVNode(e.unref(p.ElDropdownItem),{command:"all"},{default:e.withCtx(()=>[...l[16]||(l[16]=[e.createTextVNode("导出全部",-1)])]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createElementVNode("div",K,[e.createVNode(e.unref(p.ElButton),{type:"warning"},{default:e.withCtx(()=>[...l[13]||(l[13]=[e.createTextVNode("导出",-1)])]),_:1})])]),_:1},8,["onCommand"])):e.createCommentVNode("",!0),e.renderSlot(n.$slots,"tools-left")]),e.createElementVNode("div",q,[e.renderSlot(n.$slots,"tools-right"),m.option.tools?.refresh===void 0||m.option.tools?.refresh?(e.openBlock(),e.createElementBlock("div",{key:0,class:"refresh-btn",onClick:l[3]||(l[3]=(...o)=>t.table.getList&&t.table.getList(...o))},[...l[17]||(l[17]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[e.createElementVNode("path",{fill:"currentColor",d:"M771.776 794.88A384 384 0 0 1 128 512h64a320 320 0 0 0 555.712 216.448H654.72a32 32 0 1 1 0-64h149.056a32 32 0 0 1 32 32v148.928a32 32 0 1 1-64 0v-50.56zM276.288 295.616h92.992a32 32 0 0 1 0 64H220.16a32 32 0 0 1-32-32V178.56a32 32 0 0 1 64 0v50.56A384 384 0 0 1 896.128 512h-64a320 320 0 0 0-555.776-216.384z"})],-1)])])):e.createCommentVNode("",!0)])]),e.createElementVNode("div",G,[e.createElementVNode("div",X,[e.withDirectives((e.openBlock(),e.createBlock(e.unref(p.ElTable),e.mergeProps({data:t.table.data},m.option.table,{onSelectionChange:t.table.selection.change,"expand-row-keys":t.table.expand.rowKeys,onExpandChange:t.table.expand.change}),{default:e.withCtx(()=>[m.option.table?.selectable&&e.unref(s)(m.option.tools?.delete)?(e.openBlock(),e.createBlock(e.unref(p.ElTableColumn),{key:0,type:"selection",selectable:typeof m.option.table?.selectable=="function"?m.option.table?.selectable:void 0,width:"55"},null,8,["selectable"])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.table.column.list,o=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:o.key},[t.table.column.show.list.includes(o.key)?(e.openBlock(),e.createBlock(e.unref(p.ElTableColumn),e.mergeProps({key:0,prop:o.key,label:o.label},{ref_for:!0},o.table),{default:e.withCtx(({row:r})=>[e.renderSlot(n.$slots,"table-"+o.key,{row:r,item:o},()=>[o.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSwitch),e.mergeProps({key:0,modelValue:r[o.key],"onUpdate:modelValue":u=>r[o.key]=u,"before-change":()=>o.options?.switch?.tableBeforeChange?.(o.key,r)},{ref_for:!0},o.options?.switch),null,16,["modelValue","onUpdate:modelValue","before-change"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(r[o.key]),1)],64))])]),_:2},1040,["prop","label"])):e.createCommentVNode("",!0)],64))),128)),e.unref(s)(m.option.tools?.add)||e.unref(s)(m.option.tools?.update)||e.unref(s)(m.option.tools?.delete)||n.$slots["table-op-left"]||n.$slots["table-op-right"]?(e.openBlock(),e.createBlock(e.unref(p.ElTableColumn),{key:1,label:"操作",width:"180",align:"center",fixed:"right"},{default:e.withCtx(({row:o})=>[e.renderSlot(n.$slots,"table-op-left",{row:o}),e.unref(s)(m.option.tools?.add,o)?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:0,link:"",type:"primary",onClick:r=>t.update.open(e.unref(d).Insert,o)},{default:e.withCtx(()=>[...l[18]||(l[18]=[e.createTextVNode(" 新增 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),e.unref(s)(m.option.tools?.update,o)?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:1,link:"",type:"warning",onClick:r=>t.update.open(e.unref(d).Update,o)},{default:e.withCtx(()=>[...l[19]||(l[19]=[e.createTextVNode(" 编辑 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),e.unref(s)(m.option.tools?.delete,o)?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:2,link:"",type:"danger",onClick:r=>t.remove.open([o])},{default:e.withCtx(()=>[...l[20]||(l[20]=[e.createTextVNode(" 删除 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),e.renderSlot(n.$slots,"table-op-right",{row:o})]),_:3})):e.createCommentVNode("",!0)]),_:3},16,["data","onSelectionChange","expand-row-keys","onExpandChange"])),[[a,t.table.loading]])])]),e.createElementVNode("div",Q,[t.page.total>t.page.size?(e.openBlock(),e.createBlock(e.unref(p.ElPagination),{key:0,"current-page":t.page.num,"onUpdate:currentPage":l[4]||(l[4]=o=>t.page.num=o),"page-size":t.page.size,"onUpdate:pageSize":l[5]||(l[5]=o=>t.page.size=o),background:"","page-sizes":t.page.sizeList,"pager-count":7,layout:t.page.layout,total:t.page.total,onSizeChange:t.table.getList,onCurrentChange:t.table.getList},null,8,["current-page","page-size","page-sizes","layout","total","onSizeChange","onCurrentChange"])):e.createCommentVNode("",!0)])]),e.renderSlot(n.$slots,"box-right")]),e.createVNode(e.unref(p.ElDialog),e.mergeProps({modelValue:t.update.show,"onUpdate:modelValue":l[6]||(l[6]=o=>t.update.show=o),title:t.update.title,"close-on-click-modal":!1,"before-close":t.update.close},m.option.dialog),{footer:e.withCtx(()=>[e.createElementVNode("span",P,[e.createVNode(e.unref(p.ElButton),{onClick:t.update.close},{default:e.withCtx(()=>[...l[21]||(l[21]=[e.createTextVNode("关闭",-1)])]),_:1},8,["onClick"]),e.createVNode(e.unref(p.ElButton),{type:"primary",onClick:t.update.submit,loading:t.update.loading},{default:e.withCtx(()=>[...l[22]||(l[22]=[e.createTextVNode(" 提交 ",-1)])]),_:1},8,["onClick","loading"])])]),default:e.withCtx(()=>[e.createVNode(e.unref(p.ElForm),{ref_key:"ruleFormRef",ref:h,model:t.update.form,rules:t.update.rules},{default:e.withCtx(()=>[t.update.showContent?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(t.update.formColumn,o=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.unref(s)(o.map(r=>r.item.show?.form),t.update.form)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["row curd-row",{stripe:m.option.form?.stripe===void 0?!0:m.option.form?.stripe}])},[e.renderSlot(n.$slots,"form-start",{row:t.update.form}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o,r=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.unref(s)(r.item.show?.form,t.update.form)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(r.item.form.span>0?`col-${r.item.form.span}`:"col")},[e.createVNode(e.unref(p.ElFormItem),{class:e.normalizeClass({"hide-label":typeof r.item.text?.form?.label=="boolean"?!r.item.text?.form?.label:!1}),label:typeof r.item.text?.form?.label=="string"?r.item.text?.form?.label:r.item.label,prop:r.item.key,"label-width":r.item.form?.labelWidth||"100px"},{default:e.withCtx(()=>[e.createElementVNode("div",Y,[e.renderSlot(n.$slots,"form-"+r.item.key+"-start",{row:t.update.form,item:r.item}),e.createElementVNode("div",Z,[e.renderSlot(n.$slots,"form-"+r.item.key,{row:t.update.form,item:r.item},()=>[r.item.type==="input"?(e.openBlock(),e.createBlock(e.unref(p.ElInput),e.mergeProps({key:0,modelValue:t.update.form[r.item.key],"onUpdate:modelValue":u=>t.update.form[r.item.key]=u},{ref_for:!0},r.item.options?.input,e.toHandlers(r.item.options?.input?.on||{}),{disabled:t.update.getDisabled(r.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):r.item.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSwitch),e.mergeProps({key:1,modelValue:t.update.form[r.item.key],"onUpdate:modelValue":u=>t.update.form[r.item.key]=u},{ref_for:!0},r.item.options?.switch,{disabled:t.update.getDisabled(r.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):r.item.type==="select"?(e.openBlock(),e.createBlock(e.unref(p.ElSelect),e.mergeProps({key:2,modelValue:t.update.form[r.item.key],"onUpdate:modelValue":u=>t.update.form[r.item.key]=u},{ref_for:!0},r.item.options?.select,e.toHandlers(r.item.options?.select?.on||{}),{disabled:t.update.getDisabled(r.item),style:{width:"100%"}}),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.item.options?.select?.data,u=>(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:u.value,label:u.label,value:u.value},null,8,["label","value"]))),128))]),_:2},1040,["modelValue","onUpdate:modelValue","disabled"])):r.item.type==="list"?(e.openBlock(),e.createBlock(x,e.mergeProps({key:3,row:t.update.form,field:r.item.key},{ref_for:!0},r.item.options?.list,e.toHandlers(r.item.options?.list?.on||{}),{disabled:t.update.getDisabled(r.item),style:{width:"100%"}}),null,16,["row","field","disabled"])):r.item.type==="tree-select"?(e.openBlock(),e.createBlock(e.unref(p.ElTreeSelect),e.mergeProps({key:4,modelValue:t.update.form[r.item.key],"onUpdate:modelValue":u=>t.update.form[r.item.key]=u},{ref_for:!0},r.item.options?.treeSelect,e.toHandlers(r.item.options?.treeSelect?.on||{}),{disabled:t.update.getDisabled(r.item),style:{width:"100%"}}),null,16,["modelValue","onUpdate:modelValue","disabled"])):r.item.type==="datetime"?(e.openBlock(),e.createBlock(e.unref(p.ElDatePicker),e.mergeProps({key:5,modelValue:t.update.form[r.item.key],"onUpdate:modelValue":u=>t.update.form[r.item.key]=u},{ref_for:!0},r.item.options?.datetime,e.toHandlers(r.item.options?.datetime?.on||{}),{disabled:t.update.getDisabled(r.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.unref(w).customComponent[r.item.type]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(w).customComponent[r.item.type]),e.mergeProps({key:6,modelValue:t.update.form[r.item.key],"onUpdate:modelValue":u=>t.update.form[r.item.key]=u},{ref_for:!0},r.item.options?.[r.item.type],e.toHandlers(r.item.options?.[r.item.type]?.on||{}),{disabled:t.update.getDisabled(r.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.createCommentVNode("",!0)])]),e.renderSlot(n.$slots,"form-"+r.item.key+"-end",{row:t.update.form,item:r.item})])]),_:2},1032,["class","label","prop","label-width"])],2)):e.createCommentVNode("",!0)],64))),256)),e.renderSlot(n.$slots,"form-end",{row:t.update.form})],2)):e.createCommentVNode("",!0)],64))),256)):e.createCommentVNode("",!0)]),_:3},8,["model","rules"])]),_:3},16,["modelValue","title","before-close"]),e.createVNode(e.unref(p.ElDialog),{modelValue:t.remove.show,"onUpdate:modelValue":l[7]||(l[7]=o=>t.remove.show=o),title:t.remove.title,"close-on-click-modal":!1},{footer:e.withCtx(()=>[e.createElementVNode("span",v,[e.createVNode(e.unref(p.ElButton),{onClick:t.remove.close},{default:e.withCtx(()=>[...l[23]||(l[23]=[e.createTextVNode("关闭",-1)])]),_:1},8,["onClick"]),e.createVNode(e.unref(p.ElButton),{type:"danger",onClick:t.remove.submit,loading:t.remove.loading},{default:e.withCtx(()=>[...l[24]||(l[24]=[e.createTextVNode(" 确认删除 ",-1)])]),_:1},8,["onClick","loading"])])]),default:e.withCtx(()=>[e.createElementVNode("div",null,"确认要删除【"+e.toDisplayString(t.remove.items.length)+"】条数据吗?",1)]),_:1},8,["modelValue","title"]),e.createVNode(I,{ref_key:"switchConfirmRef",ref:f},null,512)])}}});class ee{static async download(c,d="download.png"){const i=document.createElement("a");i.style.display="none",i.href=c,i.setAttribute("download",d),typeof i.download>"u"&&i.setAttribute("target","_blank"),document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(c)}static exportJSONFile=(c,d)=>{const i=new Blob([JSON.stringify(c)],{type:"application/json"}),f=URL.createObjectURL(i),h=document.createElement("a");h.href=f,h.download=`${d||"config"}.json`,h.click()};static importFile=async c=>new Promise((d,i)=>{const f=document.createElement("input");f.type="file";const h=c?.accept||".json";f.accept=h,f.style.display="none",f.onchange=s=>{const t=s.target.files[0];if(!t){b.fail("未选择文件"),i("未选择文件");return}const n=new FileReader;n.onload=async l=>{const a=h==".json"?JSON.parse(l.target.result):l.target.result;d(a)},n.onerror=()=>{b.fail("文件读取失败"),i("文件读取失败")},n.readAsText(t),document.body.removeChild(f)},document.body.appendChild(f),f.click()})}const D=(m,c)=>{if(m.component("TCurd",F),m.component("TFormList",x),m.component("TColumn",N),c?.customComponent){w.customComponent=c.customComponent;for(const d in c.customComponent)m.component(d,c.customComponent[d])}},te={install:D};g.ArrUtil=V,g.ExcelUtil=S,g.TColumn=N,g.TCurd=F,g.TFile=ee,g.TForm=w,g.TFormList=x,g.TSys=b,g.default=te,g.install=D,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
1
|
+
(function(g,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("element-plus")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus"],e):(g=typeof globalThis<"u"?globalThis:g||self,e(g.cc1Form={},g.Vue,g.ElementPlus))})(this,(function(g,e,p){"use strict";class b{static router;static routes;static getRouterPath=()=>this.router.currentRoute.value.path;static EDialog={Insert:"Insert",Update:"Update",Remove:"Remove"};static isFun=(d,c)=>Array.isArray(d)?d.some(s=>typeof s=="function"?s(c):s):typeof d=="function"?d(c):d;static getRouterParams=()=>{const d=this.router.currentRoute.value.query||{},c=this.router.currentRoute.value.params||{};return Object.keys(d).length?d:Object.keys(c).length?c:{}};static moduleObj={};static loadModule=async d=>{if(!b.moduleObj[d])throw new Error(`模块${d}未加载,请赋值如:TSys.moduleObj = { ${d}: ()=>import('${d}') }`);const c=await b.moduleObj[d]();return c.default??c};static tipMessages={};static tipMessagesGap=500;static showMessage(d,c,s={}){const f=Date.now();if(!this.tipMessages[d]||f-this.tipMessages[d]>this.tipMessagesGap){this.tipMessages[d]=f;const h=Object.assign({message:d,type:c},s);p.ElMessage(h),setTimeout(()=>{delete this.tipMessages[d]},this.tipMessagesGap)}}static fail=(d,c={})=>{this.showMessage(d,"error",c)};static success=(d,c={})=>{this.showMessage(d,"success",c)};static loadingObj=null;static loadingTimer=null;static loading=(d=!0,c="加载中")=>{Timer.un(this.loadingTimer),this.loadingTimer=Timer.once(()=>{d?this.loadingObj=p.ElLoading.service({lock:!0,text:c,background:"rgba(0, 0, 0, 0.3)"}):this.loadingObj&&(this.loadingObj.close(),this.loadingObj=null)},50)};static openUrl=(d,c=!0)=>{if(c){let s=screen.width/2-500,f=screen.height/2-800/2-30;window.open(d,"_blank","toolbar=no, location=yes, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=1000, height=800, top="+f+", left="+s)}else window.open(d,"DescriptiveWindowName"+StrUtil.getId(),"resizable,scrollbars=yes,status=1,width=1024, height=600, top=0, left=0")};static getImgPic=d=>new Promise(async(c,s)=>{let f=document.getElementById(d.id);const h=await b.loadModule("html2canvas");try{h(f,{logging:!1,allowTaint:!0,scale:window.devicePixelRatio,width:d.windowWidth,height:d.windowHeight,windowWidth:d.windowWidth,windowHeight:d.windowHeight,useCORS:!0,backgroundColor:"#ffffff00"}).then(function(i){let t=i.toDataURL("image/png");c(t)})}catch(i){s(i)}})}class w{static pageField={num:"num",size:"size"};static resultField={list:"list",pages:"pages",num:"num",size:"size",total:"total"};static customComponent={};static findOptions=(d,c)=>{const s=d.column.find(h=>h.key===c),f=h=>h.replace(/-([a-z])/g,(i,t)=>t.toUpperCase());if(s)return s.options[f(s.type)]};static setOptionsData=(d,c,s)=>{const f=w.findOptions(d,c);f&&(f.data=s)};static form={openBefore:{parentId:(d,c,s,f)=>{d?c.type===b.EDialog.Insert?(c.form.parentId=d._id,c.form.sort=d.children.length+1):c.form.parentId=d.parentId.substring(d.parentId.lastIndexOf(",")+1):(c.form.parentId="0",c.form.sort=s.length+1),w.setOptionsData(f,"parentId",[{_id:"0",title:"根",children:s}])}}}}class V{static getIdFun=()=>StrUtil.uuid();static setId=(d,c,s)=>{c[d]||(c[d]=[]),c[d].forEach(f=>{s.forEach(h=>{let i=h.default??"";h.type==="number"&&(i=h.default??0),h.type==="boolean"&&(i=h.default??!1),h.type==="time"&&(i=h.default??new Date),f[h.value]===void 0&&(f[h.value]=i)}),f._id||(f._id=V.getIdFun())})};static add=(d,c,s,f)=>{const h=JSONUtil.cp(s);V.setId(d,c,s),c[d].push(h.reduce((i,t)=>{let n=t.default??"";return t.type==="number"&&(n=t.default??0),t.type==="boolean"&&(n=t.default??!1),t.type==="time"&&(n=t.default??new Date),i[t.value]=n,i},{_id:V.getIdFun()})),f?.(c)};static remove=(d,c,s,f)=>{c[d]=c[d].filter(h=>h._id!==s._id),f?.(c)};static getNoIdData=(d,c)=>{const s=JSONUtil.cp(d);return s.forEach(f=>{f._id&&delete f._id,c&&f[c]&&V.getNoIdData(f[c],c)}),s}}const T={key:0,class:"column",style:{width:"100%",gap:"10px"}},$={class:"row items-center",style:{gap:"10px",width:"100%"}},x=e.defineComponent({__name:"list",props:{row:{default:{}},label:{default:"label"},value:{default:"value"},itemFields:{default:[{label:"label",value:"label"},{label:"value",value:"value"}]},field:{default:"value"},inputWidth:{default:"120px"},inputClass:{default:""}},emits:["change"],setup(m,{emit:d}){const c=m,s=e.reactive({show:!1,add:(h,i,t)=>{V.add(h,i,t,()=>{f("change")})},remove:(h,i,t)=>{V.remove(h,i,t,()=>{f("change")})}});e.onMounted(()=>{V.setId(c.field,c.row,c.itemFields),s.show=!0});const f=d;return(h,i)=>{const t=e.resolveComponent("el-button"),n=e.resolveComponent("el-input");return s.show?(e.openBlock(),e.createElementBlock("div",T,[e.renderSlot(h.$slots,"list-start",{row:m.row}),e.createElementVNode("div",null,[e.createVNode(t,{link:"",type:"primary",onClick:i[0]||(i[0]=l=>s.add(m.field,m.row,m.itemFields))},{default:e.withCtx(()=>[...i[2]||(i[2]=[e.createTextVNode("添加",-1)])]),_:1})]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.row[m.field],l=>(e.openBlock(),e.createElementBlock("div",$,[e.renderSlot(h.$slots,"item-start",{item:l,row:m.row}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.itemFields,a=>(e.openBlock(),e.createBlock(n,{modelValue:l[a.value],"onUpdate:modelValue":o=>l[a.value]=o,style:e.normalizeStyle({width:m.inputWidth}),class:e.normalizeClass(m.inputClass),placeholder:a[m.label]||a[m.value],onChange:i[1]||(i[1]=o=>f("change"))},null,8,["modelValue","onUpdate:modelValue","style","class","placeholder"]))),256)),e.renderSlot(h.$slots,"item-end",{item:l,row:m.row}),e.createVNode(t,{link:"",type:"danger",onClick:a=>s.remove(m.field,m.row,l)},{default:e.withCtx(()=>[...i[3]||(i[3]=[e.createTextVNode("删除",-1)])]),_:1},8,["onClick"])]))),256)),e.renderSlot(h.$slots,"list-end",{row:m.row})])):e.createCommentVNode("",!0)}}}),O={class:"row curd-row"},N=e.defineComponent({__name:"column",props:{option:{default:{}},type:{default:""}},setup(m,{expose:d}){const c=b.isFun,s=b.EDialog,f=e.ref(),h=m,i=e.reactive({rules:{},show:!0,form:{},formDefault:{},formColumn:[],getDisabled:t=>t.disabled?.[(h.type||s.Insert)===s.Insert?"create":"update"],initColumnForm:async()=>{const t=h.option;i.formColumn=[];const n=[],l=h.option.form?.maxSpan||12,a=h.option.form?.defaultSpan||l;let o=[];const r=u=>{if(i.formDefault[u.key]=u.value,u.isForm){u.form=u.form||{span:a},u.form.span=u.form.span??a;let C=u.form.span,k=o.reduce((B,E)=>B+E.span,C);const y=o.length;o.push({item:u,span:C}),(y===1&&o[0].span===0||k>=l||C===0&&y>1)&&(n.push(o),o=[]),u.rules&&(i.rules[u.key]=u.rules)}};t.column.forEach(u=>{u.isForm=!0,r(u)}),o.length>0&&n.push(o),i.formColumn=n,i.form=JSONUtil.cp(i.formDefault)},init:async()=>{i.show=!1,await e.nextTick(),i.initColumnForm()}});return i.initColumnForm(),d({ref:f,conf:i}),(t,n)=>(e.openBlock(),e.createBlock(e.unref(p.ElForm),{ref_key:"ruleFormRef",ref:f,model:i.form,rules:i.rules},{default:e.withCtx(()=>[i.show?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(i.formColumn,l=>(e.openBlock(),e.createElementBlock("div",O,[e.renderSlot(t.$slots,"form-start",{row:i.form}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l,a=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.unref(c)(a.item.show?.form,i.form)??!0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(a.item.form.span>0?`col-${a.item.form.span}`:"col")},[e.createVNode(e.unref(p.ElFormItem),{label:a.item.label,prop:a.item.key,"label-width":a.item.form?.labelWidth||"100px"},{default:e.withCtx(()=>[e.renderSlot(t.$slots,"form-"+a.item.key+"-start",{row:i.form,item:a.item}),e.renderSlot(t.$slots,"form-"+a.item.key,{row:i.form,item:a.item},()=>[a.item.type==="input"?(e.openBlock(),e.createBlock(e.unref(p.ElInput),e.mergeProps({key:0,modelValue:i.form[a.item.key],"onUpdate:modelValue":o=>i.form[a.item.key]=o},{ref_for:!0},a.item.options?.input,e.toHandlers(a.item.options?.input?.on||{}),{disabled:i.getDisabled(a.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):a.item.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSwitch),e.mergeProps({key:1,modelValue:i.form[a.item.key],"onUpdate:modelValue":o=>i.form[a.item.key]=o},{ref_for:!0},a.item.options?.switch,e.toHandlers(a.item.options?.switch?.on||{}),{disabled:i.getDisabled(a.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):a.item.type==="select"?(e.openBlock(),e.createBlock(e.unref(p.ElSelect),e.mergeProps({key:2,modelValue:i.form[a.item.key],"onUpdate:modelValue":o=>i.form[a.item.key]=o},{ref_for:!0},a.item.options?.select,e.toHandlers(a.item.options?.select?.on||{}),{disabled:i.getDisabled(a.item),style:{width:"100%"}}),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.item.options?.select?.data,o=>(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:o.value,label:o.label,value:o.value},null,8,["label","value"]))),128))]),_:2},1040,["modelValue","onUpdate:modelValue","disabled"])):a.item.type==="list"?(e.openBlock(),e.createBlock(x,e.mergeProps({key:3,row:i.form,field:a.item.key},{ref_for:!0},a.item.options?.list,e.toHandlers(a.item.options?.list?.on||{}),{disabled:i.getDisabled(a.item),style:{width:"100%"}}),null,16,["row","field","disabled"])):a.item.type==="tree-select"?(e.openBlock(),e.createBlock(e.unref(p.ElTreeSelect),e.mergeProps({key:4,modelValue:i.form[a.item.key],"onUpdate:modelValue":o=>i.form[a.item.key]=o},{ref_for:!0},a.item.options?.treeSelect,e.toHandlers(a.item.options?.treeSelect?.on||{}),{disabled:i.getDisabled(a.item),style:{width:"100%"}}),null,16,["modelValue","onUpdate:modelValue","disabled"])):a.item.type==="datetime"?(e.openBlock(),e.createBlock(e.unref(p.ElDatePicker),e.mergeProps({key:5,modelValue:i.form[a.item.key],"onUpdate:modelValue":o=>i.form[a.item.key]=o},{ref_for:!0},a.item.options?.datetime,e.toHandlers(a.item.options?.datetime?.on||{}),{disabled:i.getDisabled(a.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.unref(w).customComponent[a.item.type]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(w).customComponent[a.item.type]),e.mergeProps({key:6,modelValue:i.form[a.item.key],"onUpdate:modelValue":o=>i.form[a.item.key]=o},{ref_for:!0},a.item.options?.[a.item.type],e.toHandlers(a.item.options?.[a.item.type]?.on||{}),{disabled:i.getDisabled(a.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.createCommentVNode("",!0)]),e.renderSlot(t.$slots,"form-"+a.item.key+"-end",{row:i.form,item:a.item})]),_:2},1032,["label","prop","label-width"])],2)):e.createCommentVNode("",!0)],64))),256)),e.renderSlot(t.$slots,"form-end",{row:i.form})]))),256)):e.createCommentVNode("",!0)]),_:3},8,["model","rules"]))}});class S{static exportToExcel=async(d,c,s)=>{const f=await b.loadModule("xlsx"),h=d.map(n=>{const l={};return c.forEach(a=>{l[a.label]=n[a.key]}),l}),i=f.utils.json_to_sheet(h),t=f.utils.book_new();f.utils.book_append_sheet(t,i,"Sheet1"),s?typeof s=="function"&&(s=s()):s=`导出数据_${new Date().Format("yyyy-MM-dd")}_${new Date().getTime()}`,f.writeFile(t,`${s}.xlsx`)}}const L={class:"dialog-footer"},I=e.defineComponent({__name:"switchConfirm",setup(m,{expose:d}){const c=e.ref(!1),s=e.ref("确认修改"),f=e.ref("确认要修改状态吗?");let h=null,i=null;const t=a=>(a?.title&&(s.value=a.title),a?.content&&(f.value=a.content),c.value=!0,new Promise((o,r)=>{h=o,i=r})),n=()=>{c.value=!1,h?.(!0),h=null,i=null},l=()=>{c.value=!1,i?.(new Error("用户取消操作")),h=null,i=null};return d({open:t}),(a,o)=>(e.openBlock(),e.createBlock(e.unref(p.ElDialog),{modelValue:c.value,"onUpdate:modelValue":o[0]||(o[0]=r=>c.value=r),title:s.value,"close-on-click-modal":!1,width:"400px"},{footer:e.withCtx(()=>[e.createElementVNode("span",L,[e.createVNode(e.unref(p.ElButton),{onClick:l},{default:e.withCtx(()=>[...o[1]||(o[1]=[e.createTextVNode("取消",-1)])]),_:1}),e.createVNode(e.unref(p.ElButton),{type:"primary",onClick:n},{default:e.withCtx(()=>[...o[2]||(o[2]=[e.createTextVNode("确认",-1)])]),_:1})])]),default:e.withCtx(()=>[e.createElementVNode("div",null,e.toDisplayString(f.value),1)]),_:1},8,["modelValue","title"]))}}),z={class:"col relative cc1-form-box"},j={class:"absolute row fit",style:{overflow:"hidden"}},M={class:"col column"},R={key:0,class:"relative curd-search"},H={class:"mb-10 flex justify-between items-center"},A={class:"flex items-center",style:{gap:"10px"}},J={key:0},_={key:1},W={key:2},K={class:"export-btn"},q={class:"flex items-center",style:{gap:"10px"}},G={class:"col fit-width relative"},X={class:"absolute column fit"},Q={class:"row justify-end mt-10 mb-10"},Y={class:"row form-item-content",style:{width:"100%"}},Z={class:"col"},P={class:"dialog-footer"},v={class:"dialog-footer"},F=e.defineComponent({__name:"index",props:{option:{default:{}}},setup(m,{expose:d}){const c=b.EDialog,s=m,f=e.ref(),h=e.ref(),i=b.isFun,t=e.reactive({search:{column:{list:[]},form:{},formDefault:{},getPlaceholder:(n,l="请输入")=>n.text?.search?.placeholder===void 0?`${l}${n.label}`:n.text?.search?.placeholder,getFormData:()=>{let n={};s.option.column.forEach(a=>{(typeof a.show?.search=="function"?a.show?.search(t.search.form):a.show?.search)&&(n[a.key]=t.search.form[a.key])});const l=s.option.search?.before?.(n);return l&&(n=l),n},reset:()=>{const n=t.search.formDefault;Object.keys(n).forEach(l=>{s.option.search?.resetMode==="default"?n[l]=t.search.formDefault[l]:n[l]=void 0}),t.search.form=JSONUtil.cp(n),t.page.num=1,t.table.getList()},submit:()=>{t.page.num=1,t.table.getList()}},page:{size:s.option.page?.size||10,sizeList:s.option.page?.sizeList||[10,20,50,100],num:1,total:0,layout:s.option.page?.layout||"total, sizes, prev, pager, next, jumper"},table:{loading:!1,data:[],expand:{isExpand:!1,rowKeys:[],change:(n,l)=>{},all:()=>{if(t.table.expand.isExpand)t.table.expand.rowKeys=[];else{const n=l=>{let a=[];return l.forEach(o=>{a.push(o._id),o.children&&o.children.length>0&&(a=a.concat(n(o.children)))}),a};t.table.expand.rowKeys=n(t.table.data)}t.table.expand.isExpand=!t.table.expand.isExpand}},column:{list:[],show:{listSource:[],list:[]}},getList:async()=>{t.table.loading=!0;const n=s.option.api.list;try{const l=await n({[w.pageField.size]:t.page.size,[w.pageField.num]:t.page.num,...t.search.getFormData()}),a=w.resultField,o=l.data||{[a.list]:l};let r=(Array.isArray(o[a.list]),o[a.list]);t.table.data=s.option.data?await s.option.data(r):r,t.page.total=o[a.total]||0}catch(l){console.error(l)}finally{t.table.loading=!1}},selection:{list:[],change:n=>{t.table.selection.list=n}},exportFun:{start:async n=>{let l=await t.table.exportFun[n](),a=s.option.column;const o=JSONUtil.cp({data:l,columns:a}),r=s.option.tools?.export||{};r.before&&r.before(o),S.exportToExcel(o.data,o.columns,r.fileName)},select:()=>{if(t.table.selection.list.length===0)throw b.fail("请选择要导出的数据"),new Error("请选择要导出的数据");return t.table.selection.list},page:()=>{if(t.table.data.length===0)throw b.fail("暂无数据"),new Error("暂无数据");return t.table.data},all:async()=>{t.table.loading=!0;const n=s.option.api.list;try{const{data:l}=await n({[w.pageField.size]:999999,[w.pageField.num]:1});return l[w.resultField.list]}catch(l){console.error(l)}finally{t.table.loading=!1}}},export:n=>{t.table.exportFun.start(n)}},update:{title:"",rules:{},show:!1,showContent:!1,loading:!1,type:c.Insert,form:{},formDefault:{},formColumn:[],getDisabled:n=>n.disabled?.[t.update.type===c.Insert?"create":"update"],edit:{data:{},getApiData:n=>{if(s.option.form?.editAll)return n;let l={_id:t.update.edit.data._id};return Object.keys(t.update.edit.data).forEach(a=>{n[a]!==t.update.edit.data[a]&&(l[a]=n[a])}),l}},open:(n,l)=>{t.update.showContent||FunUtil.throttle(async()=>{t.update.type=n;const a=n===c.Insert;t.update.edit.data=l,t.update.title=a?"新增":"编辑",t.update.form=JSONUtil.cp(a?t.update.formDefault:l),await s.option.form?.openBefore?.(l,t.update),t.update.show=!0,t.update.showContent=!0,s.option.form?.openAfter?.(l,t.update)})},submit:()=>{FunUtil.throttle(async()=>{await h.value?.validate(async(a,o)=>new Promise((r,u)=>{a||(b.fail("请检查表单数据"),u(!1)),r()})),t.update.loading=!0;const n=t.update.type===c.Insert?s.option.api.create:s.option.api.update;let l=JSONUtil.cp(t.update.form);delete l.children,await s.option.form?.submitBefore?.(l,t.update),Object.keys(l).forEach(a=>{if(typeof l[a]=="string"&&l[a].indexOf("T")>-1){const o=new Date(l[a]).getTime();!isNaN(o)&&o>new Date("1971-01-01").getTime()&&(l[a]=o)}});try{await n({...l}),t.update.close(),await t.table.getList(),s.option.form?.submitAfter?.(l,t.update)}catch(a){console.error(a)}finally{t.update.loading=!1}})},close:()=>{t.update.show=!1,setTimeout(()=>{t.update.showContent=!1},350)}},remove:{title:"确认删除",show:!1,items:[],loading:!1,close:()=>{t.remove.show=!1},open:n=>{if(n.length===0){b.fail("请选择要删除的数据");return}t.remove.items=n,t.remove.show=!0},submit:()=>{FunUtil.throttle(async()=>{t.remove.loading=!0;const n=s.option.api.delete;try{await n({_id:t.remove.items.map(l=>l._id),items:t.remove.items}),b.success("操作成功"),t.table.data.length<=1&&t.page.num>1&&(t.page.num-=1),t.remove.close(),await t.table.getList()}catch(l){console.error(l)}finally{t.remove.loading=!1}})}},init:()=>{t.initCurdConfig(),t.initColumnOptions(),t.initColumnForm()},initCurdConfig:()=>{const l={tools:{search:!0,reset:!0,expand:!1,add:o=>o===void 0,update:!0,delete:!0,export:{show:!0}},table:{headerCellClassName:"table-header",rowKey:"_id",emptyText:"暂无数据",highlightCurrentRow:!0}},a=s.option;Object.keys(l).forEach(o=>{a[o]=ObjectUtil.deepMerge(l[o],a[o]||{})})},initColumnOptions:()=>{const n=s.option,l=a=>{const r={options:{switch:{activeValue:!0,activeLabel:"开启",inactiveValue:!1,inactiveLabel:"关闭",tableBeforeChange:async(C,k)=>{const y=a.options?.switch;try{await f.value?.open({title:"确认修改",content:`确认要${k[C]===y.activeValue?y.inactiveLabel:y.activeLabel}吗?`}),t.table.loading=!0;try{return await s.option.api.update({_id:k._id,[C]:k[C]===y.activeValue?y.inactiveValue:y.activeValue,final(B,E,U){t.table.loading=!1}}),t.table.loading=!1,b.success("操作成功"),t.table.getList(),!0}catch(B){return console.error(B),!1}finally{t.table.loading=!1}}catch{return!1}}},treeSelect:{rowKey:"_id",nodeKey:"_id",multiple:!0,renderAfterExpand:!1,showCheckbox:!0,checkStrictly:!0,checkOnClickNode:!0,props:{label:"title",children:"children"}},datetime:{type:"datetime"}},table:{table:!0,minWidth:"100px",align:"center"},show:{table:!0,search:!1,form:!0},sort:{search:0,table:0,form:0}},u=a;Object.keys(r).forEach(C=>{u[C]=ObjectUtil.deepMerge(r[C],u[C]||{})})};n.column.forEach(l),n.table?.column?.forEach(l)},initColumnForm:()=>{const n=s.option;t.update.formColumn=[],t.table.column.show={list:[],listSource:[]};const l=[],a=s.option.form?.maxSpan||12,o=s.option.form?.defaultSpan||a/2;let r=[];const u=k=>{if(t.update.formDefault[k.key]=k.value,k.table.table&&(k.show.table&&t.table.column.show.list.push(k.key),k.table.table&&t.table.column.show.listSource.push(k.key)),k.isForm){k.form=k.form||{span:o},k.form.span=k.form.span??o;let y=k.form.span,B=r.reduce((U,oe)=>U+oe.span,y);const E=r.length;r.push({item:k,span:y}),(E===1&&r[0].span===0||B>=a||y===0&&E>1)&&(l.push(r),r=[]),k.rules&&(t.update.rules[k.key]=k.rules)}};n.column.forEach(k=>{k.isForm=!0,u(k)}),s.option.table?.column?.forEach(k=>{k.isForm=!1,u(k)}),t.search.column.list=n.column.concat(n.table?.column||[]),t.table.column.list=t.search.column.list.filter(k=>k.table?.table),t.search.column.list.sort((k,y)=>k.sort?.search-y.sort?.search),t.table.column.list.sort((k,y)=>k.sort?.table-y.sort?.table),r.length>0&&l.push(r),t.update.formColumn=l;const C=s.option.search?.formDefault;C&&Object.keys(C).forEach(k=>{t.search.formDefault[k]=C[k]}),n.column.forEach(k=>{k.show?.search||(t.search.formDefault[k.key]=void 0)}),t.search.form=JSONUtil.cp(t.search.formDefault)}});return t.init(),e.onMounted(()=>{t.table.getList()}),d({conf:t}),(n,l)=>{const a=e.resolveDirective("loading");return e.openBlock(),e.createElementBlock("div",z,[e.createElementVNode("div",j,[e.renderSlot(n.$slots,"box-left"),e.createElementVNode("div",M,[m.option.search?.show!==!1?(e.openBlock(),e.createElementBlock("div",R,[e.createVNode(e.unref(p.ElForm),{model:t.search.form,inline:""},{default:e.withCtx(()=>[e.renderSlot(n.$slots,"search-start",{row:t.search.form}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.search.column.list,o=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:o.key},[(typeof o.show?.search=="function"?o.show?.search(t.search.form):o.show?.search)?(e.openBlock(),e.createBlock(e.unref(p.ElFormItem),{key:0,label:typeof o.text?.search?.label=="string"?o.text?.search?.label:o.label,class:e.normalizeClass({"hide-label":typeof o.text?.search?.label=="boolean"?!o.text?.search?.label:!1})},{default:e.withCtx(()=>[e.renderSlot(n.$slots,"search-"+o.key,{row:t.search.form},()=>[o.type==="input"?(e.openBlock(),e.createBlock(e.unref(p.ElInput),{key:0,modelValue:t.search.form[o.key],"onUpdate:modelValue":r=>t.search.form[o.key]=r,placeholder:t.search.getPlaceholder(o),clearable:"",disabled:o.disabled?.search},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled"])):o.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSelect),{key:1,modelValue:t.search.form[o.key],"onUpdate:modelValue":r=>t.search.form[o.key]=r,placeholder:t.search.getPlaceholder(o,"请选择"),clearable:"",disabled:o.disabled?.search},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:o.options?.switch?.activeValue,label:o.options?.switch?.activeLabel,value:o.options?.switch?.activeValue},null,8,["label","value"])),(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:o.options?.switch?.inactiveValue,label:o.options?.switch?.inactiveLabel,value:o.options?.switch?.inactiveValue},null,8,["label","value"]))]),_:2},1032,["modelValue","onUpdate:modelValue","placeholder","disabled"])):o.type==="select"?(e.openBlock(),e.createBlock(e.unref(p.ElSelect),{key:2,modelValue:t.search.form[o.key],"onUpdate:modelValue":r=>t.search.form[o.key]=r,placeholder:t.search.getPlaceholder(o,"请选择"),clearable:"",disabled:o.disabled?.search},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options?.select?.data,r=>(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:r.value,label:r.label,value:r.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","placeholder","disabled"])):e.createCommentVNode("",!0)])]),_:2},1032,["label","class"])):e.createCommentVNode("",!0)],64))),128)),e.renderSlot(n.$slots,"search-center",{row:t.search.form}),e.createVNode(e.unref(p.ElFormItem),null,{default:e.withCtx(()=>[m.option.tools?.search?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:0,type:"primary",onClick:t.search.submit},{default:e.withCtx(()=>[...l[8]||(l[8]=[e.createTextVNode(" 搜索 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),m.option.tools?.reset?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:1,onClick:t.search.reset},{default:e.withCtx(()=>[...l[9]||(l[9]=[e.createTextVNode("重置",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0)]),_:1}),e.renderSlot(n.$slots,"search-end",{row:t.search.form})]),_:3},8,["model"])])):e.createCommentVNode("",!0),e.createElementVNode("div",H,[e.createElementVNode("div",A,[e.unref(i)(m.option.tools?.add)?(e.openBlock(),e.createElementBlock("div",J,[e.createVNode(e.unref(p.ElButton),{type:"primary",onClick:l[0]||(l[0]=o=>t.update.open(e.unref(c).Insert))},{default:e.withCtx(()=>[...l[10]||(l[10]=[e.createTextVNode("新增",-1)])]),_:1})])):e.createCommentVNode("",!0),m.option.table?.selectable&&e.unref(i)(m.option.tools?.delete)?(e.openBlock(),e.createElementBlock("div",_,[e.createVNode(e.unref(p.ElButton),{type:"danger",onClick:l[1]||(l[1]=o=>t.remove.open(t.table.selection.list))},{default:e.withCtx(()=>[...l[11]||(l[11]=[e.createTextVNode(" 删除 ",-1)])]),_:1})])):e.createCommentVNode("",!0),m.option.tools?.expand?(e.openBlock(),e.createElementBlock("div",W,[e.createVNode(e.unref(p.ElButton),{type:"warning",onClick:l[2]||(l[2]=o=>t.table.expand.all())},{default:e.withCtx(()=>[...l[12]||(l[12]=[e.createTextVNode("展开/收缩",-1)])]),_:1})])):e.createCommentVNode("",!0),m.option.tools?.export?.show?(e.openBlock(),e.createBlock(e.unref(p.ElDropdown),{key:3,onCommand:t.table.export},{dropdown:e.withCtx(()=>[e.createVNode(e.unref(p.ElDropdownMenu),null,{default:e.withCtx(()=>[e.createVNode(e.unref(p.ElDropdownItem),{command:"select"},{default:e.withCtx(()=>[...l[14]||(l[14]=[e.createTextVNode("导出选中",-1)])]),_:1}),e.createVNode(e.unref(p.ElDropdownItem),{command:"page"},{default:e.withCtx(()=>[...l[15]||(l[15]=[e.createTextVNode("导出本页",-1)])]),_:1}),e.createVNode(e.unref(p.ElDropdownItem),{command:"all"},{default:e.withCtx(()=>[...l[16]||(l[16]=[e.createTextVNode("导出全部",-1)])]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createElementVNode("div",K,[e.createVNode(e.unref(p.ElButton),{type:"warning"},{default:e.withCtx(()=>[...l[13]||(l[13]=[e.createTextVNode("导出",-1)])]),_:1})])]),_:1},8,["onCommand"])):e.createCommentVNode("",!0),e.renderSlot(n.$slots,"tools-left")]),e.createElementVNode("div",q,[e.renderSlot(n.$slots,"tools-right"),m.option.tools?.refresh===void 0||m.option.tools?.refresh?(e.openBlock(),e.createElementBlock("div",{key:0,class:"refresh-btn",onClick:l[3]||(l[3]=(...o)=>t.table.getList&&t.table.getList(...o))},[...l[17]||(l[17]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[e.createElementVNode("path",{fill:"currentColor",d:"M771.776 794.88A384 384 0 0 1 128 512h64a320 320 0 0 0 555.712 216.448H654.72a32 32 0 1 1 0-64h149.056a32 32 0 0 1 32 32v148.928a32 32 0 1 1-64 0v-50.56zM276.288 295.616h92.992a32 32 0 0 1 0 64H220.16a32 32 0 0 1-32-32V178.56a32 32 0 0 1 64 0v50.56A384 384 0 0 1 896.128 512h-64a320 320 0 0 0-555.776-216.384z"})],-1)])])):e.createCommentVNode("",!0)])]),e.createElementVNode("div",G,[e.createElementVNode("div",X,[e.withDirectives((e.openBlock(),e.createBlock(e.unref(p.ElTable),e.mergeProps({data:t.table.data},m.option.table,{onSelectionChange:t.table.selection.change,"expand-row-keys":t.table.expand.rowKeys,onExpandChange:t.table.expand.change}),{default:e.withCtx(()=>[m.option.table?.selectable&&e.unref(i)(m.option.tools?.delete)?(e.openBlock(),e.createBlock(e.unref(p.ElTableColumn),{key:0,type:"selection",selectable:typeof m.option.table?.selectable=="function"?m.option.table?.selectable:void 0,width:"55"},null,8,["selectable"])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.table.column.list,o=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:o.key},[t.table.column.show.list.includes(o.key)?(e.openBlock(),e.createBlock(e.unref(p.ElTableColumn),e.mergeProps({key:0,prop:o.key,label:o.label},{ref_for:!0},o.table),{default:e.withCtx(({row:r})=>[e.renderSlot(n.$slots,"table-"+o.key,{row:r,item:o},()=>[o.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSwitch),e.mergeProps({key:0,modelValue:r[o.key],"onUpdate:modelValue":u=>r[o.key]=u,"before-change":()=>o.options?.switch?.tableBeforeChange?.(o.key,r)},{ref_for:!0},o.options?.switch),null,16,["modelValue","onUpdate:modelValue","before-change"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(r[o.key]),1)],64))])]),_:2},1040,["prop","label"])):e.createCommentVNode("",!0)],64))),128)),e.unref(i)(m.option.tools?.add)||e.unref(i)(m.option.tools?.update)||e.unref(i)(m.option.tools?.delete)||n.$slots["table-op-left"]||n.$slots["table-op-right"]?(e.openBlock(),e.createBlock(e.unref(p.ElTableColumn),{key:1,label:"操作",width:"180",align:"center",fixed:"right"},{default:e.withCtx(({row:o})=>[e.renderSlot(n.$slots,"table-op-left",{row:o}),e.unref(i)(m.option.tools?.add,o)?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:0,link:"",type:"primary",onClick:r=>t.update.open(e.unref(c).Insert,o)},{default:e.withCtx(()=>[...l[18]||(l[18]=[e.createTextVNode(" 新增 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),e.unref(i)(m.option.tools?.update,o)?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:1,link:"",type:"warning",onClick:r=>t.update.open(e.unref(c).Update,o)},{default:e.withCtx(()=>[...l[19]||(l[19]=[e.createTextVNode(" 编辑 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),e.unref(i)(m.option.tools?.delete,o)?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:2,link:"",type:"danger",onClick:r=>t.remove.open([o])},{default:e.withCtx(()=>[...l[20]||(l[20]=[e.createTextVNode(" 删除 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),e.renderSlot(n.$slots,"table-op-right",{row:o})]),_:3})):e.createCommentVNode("",!0)]),_:3},16,["data","onSelectionChange","expand-row-keys","onExpandChange"])),[[a,t.table.loading]])])]),e.createElementVNode("div",Q,[t.page.total>t.page.size?(e.openBlock(),e.createBlock(e.unref(p.ElPagination),{key:0,"current-page":t.page.num,"onUpdate:currentPage":l[4]||(l[4]=o=>t.page.num=o),"page-size":t.page.size,"onUpdate:pageSize":l[5]||(l[5]=o=>t.page.size=o),background:"","page-sizes":t.page.sizeList,"pager-count":7,layout:t.page.layout,total:t.page.total,onSizeChange:t.table.getList,onCurrentChange:t.table.getList},null,8,["current-page","page-size","page-sizes","layout","total","onSizeChange","onCurrentChange"])):e.createCommentVNode("",!0)])]),e.renderSlot(n.$slots,"box-right")]),e.createVNode(e.unref(p.ElDialog),e.mergeProps({modelValue:t.update.show,"onUpdate:modelValue":l[6]||(l[6]=o=>t.update.show=o),title:t.update.title,"close-on-click-modal":!1,"before-close":t.update.close},m.option.dialog),{footer:e.withCtx(()=>[e.createElementVNode("span",P,[e.createVNode(e.unref(p.ElButton),{onClick:t.update.close},{default:e.withCtx(()=>[...l[21]||(l[21]=[e.createTextVNode("关闭",-1)])]),_:1},8,["onClick"]),e.createVNode(e.unref(p.ElButton),{type:"primary",onClick:t.update.submit,loading:t.update.loading},{default:e.withCtx(()=>[...l[22]||(l[22]=[e.createTextVNode(" 提交 ",-1)])]),_:1},8,["onClick","loading"])])]),default:e.withCtx(()=>[e.createVNode(e.unref(p.ElForm),{ref_key:"ruleFormRef",ref:h,model:t.update.form,rules:t.update.rules},{default:e.withCtx(()=>[t.update.showContent?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(t.update.formColumn,o=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.unref(i)(o.map(r=>r.item.show?.form),t.update.form)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["row curd-row",{stripe:m.option.form?.stripe===void 0?!0:m.option.form?.stripe}])},[e.renderSlot(n.$slots,"form-start",{row:t.update.form}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o,r=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.unref(i)(r.item.show?.form,t.update.form)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(r.item.form.span>0?`col-${r.item.form.span}`:"col")},[e.createVNode(e.unref(p.ElFormItem),{class:e.normalizeClass({"hide-label":typeof r.item.text?.form?.label=="boolean"?!r.item.text?.form?.label:!1}),label:typeof r.item.text?.form?.label=="string"?r.item.text?.form?.label:r.item.label,prop:r.item.key,"label-width":r.item.form?.labelWidth||"100px"},{default:e.withCtx(()=>[e.createElementVNode("div",Y,[e.renderSlot(n.$slots,"form-"+r.item.key+"-start",{row:t.update.form,item:r.item}),e.createElementVNode("div",Z,[e.renderSlot(n.$slots,"form-"+r.item.key,{row:t.update.form,item:r.item},()=>[r.item.type==="input"?(e.openBlock(),e.createBlock(e.unref(p.ElInput),e.mergeProps({key:0,modelValue:t.update.form[r.item.key],"onUpdate:modelValue":u=>t.update.form[r.item.key]=u},{ref_for:!0},r.item.options?.input,e.toHandlers(r.item.options?.input?.on||{}),{disabled:t.update.getDisabled(r.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):r.item.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSwitch),e.mergeProps({key:1,modelValue:t.update.form[r.item.key],"onUpdate:modelValue":u=>t.update.form[r.item.key]=u},{ref_for:!0},r.item.options?.switch,{disabled:t.update.getDisabled(r.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):r.item.type==="select"?(e.openBlock(),e.createBlock(e.unref(p.ElSelect),e.mergeProps({key:2,modelValue:t.update.form[r.item.key],"onUpdate:modelValue":u=>t.update.form[r.item.key]=u},{ref_for:!0},r.item.options?.select,e.toHandlers(r.item.options?.select?.on||{}),{disabled:t.update.getDisabled(r.item),style:{width:"100%"}}),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.item.options?.select?.data,u=>(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:u.value,label:u.label,value:u.value},null,8,["label","value"]))),128))]),_:2},1040,["modelValue","onUpdate:modelValue","disabled"])):r.item.type==="list"?(e.openBlock(),e.createBlock(x,e.mergeProps({key:3,row:t.update.form,field:r.item.key},{ref_for:!0},r.item.options?.list,e.toHandlers(r.item.options?.list?.on||{}),{disabled:t.update.getDisabled(r.item),style:{width:"100%"}}),null,16,["row","field","disabled"])):r.item.type==="tree-select"?(e.openBlock(),e.createBlock(e.unref(p.ElTreeSelect),e.mergeProps({key:4,modelValue:t.update.form[r.item.key],"onUpdate:modelValue":u=>t.update.form[r.item.key]=u},{ref_for:!0},r.item.options?.treeSelect,e.toHandlers(r.item.options?.treeSelect?.on||{}),{disabled:t.update.getDisabled(r.item),style:{width:"100%"}}),null,16,["modelValue","onUpdate:modelValue","disabled"])):r.item.type==="datetime"?(e.openBlock(),e.createBlock(e.unref(p.ElDatePicker),e.mergeProps({key:5,modelValue:t.update.form[r.item.key],"onUpdate:modelValue":u=>t.update.form[r.item.key]=u},{ref_for:!0},r.item.options?.datetime,e.toHandlers(r.item.options?.datetime?.on||{}),{disabled:t.update.getDisabled(r.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.unref(w).customComponent[r.item.type]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(w).customComponent[r.item.type]),e.mergeProps({key:6,modelValue:t.update.form[r.item.key],"onUpdate:modelValue":u=>t.update.form[r.item.key]=u},{ref_for:!0},r.item.options?.[r.item.type],e.toHandlers(r.item.options?.[r.item.type]?.on||{}),{disabled:t.update.getDisabled(r.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.createCommentVNode("",!0)])]),e.renderSlot(n.$slots,"form-"+r.item.key+"-end",{row:t.update.form,item:r.item})])]),_:2},1032,["class","label","prop","label-width"])],2)):e.createCommentVNode("",!0)],64))),256)),e.renderSlot(n.$slots,"form-end",{row:t.update.form})],2)):e.createCommentVNode("",!0)],64))),256)):e.createCommentVNode("",!0)]),_:3},8,["model","rules"])]),_:3},16,["modelValue","title","before-close"]),e.createVNode(e.unref(p.ElDialog),{modelValue:t.remove.show,"onUpdate:modelValue":l[7]||(l[7]=o=>t.remove.show=o),title:t.remove.title,"close-on-click-modal":!1},{footer:e.withCtx(()=>[e.createElementVNode("span",v,[e.createVNode(e.unref(p.ElButton),{onClick:t.remove.close},{default:e.withCtx(()=>[...l[23]||(l[23]=[e.createTextVNode("关闭",-1)])]),_:1},8,["onClick"]),e.createVNode(e.unref(p.ElButton),{type:"danger",onClick:t.remove.submit,loading:t.remove.loading},{default:e.withCtx(()=>[...l[24]||(l[24]=[e.createTextVNode(" 确认删除 ",-1)])]),_:1},8,["onClick","loading"])])]),default:e.withCtx(()=>[e.createElementVNode("div",null,"确认要删除【"+e.toDisplayString(t.remove.items.length)+"】条数据吗?",1)]),_:1},8,["modelValue","title"]),e.createVNode(I,{ref_key:"switchConfirmRef",ref:f},null,512)])}}});class ee{static async download(d,c="download.png"){const s=document.createElement("a");s.style.display="none",s.href=d,s.setAttribute("download",c),typeof s.download>"u"&&s.setAttribute("target","_blank"),document.body.appendChild(s),s.click(),document.body.removeChild(s),window.URL.revokeObjectURL(d)}static exportJSONFile=(d,c)=>{const s=new Blob([JSON.stringify(d)],{type:"application/json"}),f=URL.createObjectURL(s),h=document.createElement("a");h.href=f,h.download=`${c||"config"}.json`,h.click()};static importFile=async d=>new Promise((c,s)=>{const f=document.createElement("input");f.type="file";const h=d?.accept||".json";f.accept=h,f.style.display="none",f.onchange=i=>{const t=i.target.files[0];if(!t){b.fail("未选择文件"),s("未选择文件");return}const n=new FileReader;n.onload=async l=>{const a=h==".json"?JSON.parse(l.target.result):l.target.result;c(a)},n.onerror=()=>{b.fail("文件读取失败"),s("文件读取失败")},n.readAsText(t),document.body.removeChild(f)},document.body.appendChild(f),f.click()})}const D=(m,d)=>{if(m.component("TCurd",F),m.component("TFormList",x),m.component("TColumn",N),d?.customComponent){w.customComponent=d.customComponent;for(const c in d.customComponent)m.component(c,d.customComponent[c])}},te={install:D};g.ArrUtil=V,g.ExcelUtil=S,g.TColumn=N,g.TCurd=F,g.TFile=ee,g.TForm=w,g.TFormList=x,g.TSys=b,g.default=te,g.install=D,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc1-form",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "我来助你-表单组件库",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"import": "./dist/cc1-form.js",
|
|
23
23
|
"require": "./dist/cc1-form.umd.cjs"
|
|
24
24
|
},
|
|
25
|
-
"./index.css": "./dist/
|
|
25
|
+
"./index.css": "./dist/cc1-form.css"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "npm run build:package && npm run build:types",
|