cc1-form 1.0.3 → 1.0.4
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 +273 -267
- package/dist/cc1-form.umd.cjs +1 -1
- package/dist/components/TCurd/com/form/column.vue.d.ts +28 -6
- package/package.json +1 -1
package/dist/cc1-form.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(y,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):(y=typeof globalThis<"u"?globalThis:y||self,e(y.cc1Form={},y.Vue,y.ElementPlus))})(this,(function(y,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 m=Date.now();if(!this.tipMessages[c]||m-this.tipMessages[c]>this.tipMessagesGap){this.tipMessages[c]=m;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,m=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="+m+", 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 m=document.getElementById(c.id);const h=await b.loadModule("html2canvas");try{h(m,{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)}});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)}}class V{static customComponent={};static findOptions=(c,d)=>{const i=c.column.find(h=>h.key===d),m=h=>h.replace(/-([a-z])/g,(s,t)=>t.toUpperCase());if(i)return i.options[m(i.type)]};static setOptionsData=(c,d,i)=>{const m=V.findOptions(c,d);m&&(m.data=i)};static form={openBefore:{parentId:(c,d,i,m)=>{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),V.setOptionsData(m,"parentId",[{_id:"0",title:"根",children:i}])}}}}class C{static getIdFun=()=>StrUtil.uuid();static setId=(c,d,i)=>{d[c]||(d[c]=[]),d[c].forEach(m=>{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),m[h.value]===void 0&&(m[h.value]=s)}),m._id||(m._id=C.getIdFun())})};static add=(c,d,i,m)=>{const h=JSONUtil.cp(i);C.setId(c,d,i),d[c].push(h.reduce((s,t)=>{let r=t.default??"";return t.type==="number"&&(r=t.default??0),t.type==="boolean"&&(r=t.default??!1),t.type==="time"&&(r=t.default??new Date),s[t.value]=r,s},{_id:C.getIdFun()})),m?.(d)};static remove=(c,d,i,m)=>{d[c]=d[c].filter(h=>h._id!==i._id),m?.(d)};static getNoIdData=(c,d)=>{const i=JSONUtil.cp(c);return i.forEach(m=>{m._id&&delete m._id,d&&m[d]&&C.getNoIdData(m[d],d)}),i}}const F={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(f,{emit:c}){const d=f,i=e.reactive({show:!1,add:(h,s,t)=>{C.add(h,s,t,()=>{m("change")})},remove:(h,s,t)=>{C.remove(h,s,t,()=>{m("change")})}});e.onMounted(()=>{C.setId(d.field,d.row,d.itemFields),i.show=!0});const m=c;return(h,s)=>{const t=e.resolveComponent("el-button"),r=e.resolveComponent("el-input");return i.show?(e.openBlock(),e.createElementBlock("div",F,[e.renderSlot(h.$slots,"list-start",{row:f.row}),e.createElementVNode("div",null,[e.createVNode(t,{link:"",type:"primary",onClick:s[0]||(s[0]=a=>i.add(f.field,f.row,f.itemFields))},{default:e.withCtx(()=>[...s[2]||(s[2]=[e.createTextVNode("添加",-1)])]),_:1})]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.row[f.field],a=>(e.openBlock(),e.createElementBlock("div",$,[e.renderSlot(h.$slots,"item-start",{item:a,row:f.row}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.itemFields,l=>(e.openBlock(),e.createBlock(r,{modelValue:a[l.value],"onUpdate:modelValue":o=>a[l.value]=o,style:e.normalizeStyle({width:f.inputWidth}),class:e.normalizeClass(f.inputClass),placeholder:l[f.label]||l[f.value],onChange:s[1]||(s[1]=o=>m("change"))},null,8,["modelValue","onUpdate:modelValue","style","class","placeholder"]))),256)),e.renderSlot(h.$slots,"item-end",{item:a,row:f.row}),e.createVNode(t,{link:"",type:"danger",onClick:l=>i.remove(f.field,f.row,a)},{default:e.withCtx(()=>[...s[3]||(s[3]=[e.createTextVNode("删除",-1)])]),_:1},8,["onClick"])]))),256)),e.renderSlot(h.$slots,"list-end",{row:f.row})])):e.createCommentVNode("",!0)}}}),T={class:"row curd-row"},N=e.defineComponent({__name:"column",props:{option:{default:{}}},setup(f,{expose:c}){const d=b.isFun,i=b.EDialog,m=e.ref(),h=f,s=e.reactive({rules:{},show:!1,showContent:!1,loading:!1,type:i.Insert,form:{},formDefault:{},formColumn:[],getDisabled:t=>t.disabled?.[s.type===i.Insert?"create":"update"],initColumnForm:()=>{const t=h.option;s.formColumn=[];const r=[],a=h.option.form?.maxSpan||12,l=h.option.form?.defaultSpan||a;let o=[];const n=u=>{if(s.formDefault[u.key]=u.value,u.isForm){u.form=u.form||{span:l},u.form.span=u.form.span??l;let w=u.form.span,k=o.reduce((B,E)=>B+E.span,w);const g=o.length;o.push({item:u,span:w}),(g===1&&o[0].span===0||k>=a||w===0&&g>1)&&(r.push(o),o=[]),u.rules&&(s.rules[u.key]=u.rules)}};t.column.forEach(u=>{u.isForm=!0,n(u)}),o.length>0&&r.push(o),s.formColumn=r}});return s.initColumnForm(),c({ref:m,conf:s}),(t,r)=>(e.openBlock(),e.createBlock(e.unref(p.ElForm),{ref_key:"ruleFormRef",ref:m,model:s.form,rules:s.rules},{default:e.withCtx(()=>[s.showContent?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(s.formColumn,a=>(e.openBlock(),e.createElementBlock("div",T,[e.renderSlot(t.$slots,"form-start",{row:s.form}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a,l=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.unref(d)(l.item.show?.form,s.form)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(l.item.form.span>0?`col-${l.item.form.span}`:"col")},[e.createVNode(e.unref(p.ElFormItem),{label:l.item.label,prop:l.item.key,"label-width":l.item.form?.labelWidth||"100px"},{default:e.withCtx(()=>[e.renderSlot(t.$slots,"form-"+l.item.key+"-start",{row:s.form,item:l.item}),e.renderSlot(t.$slots,"form-"+l.item.key,{row:s.form,item:l.item},()=>[l.item.type==="input"?(e.openBlock(),e.createBlock(e.unref(p.ElInput),e.mergeProps({key:0,modelValue:s.form[l.item.key],"onUpdate:modelValue":o=>s.form[l.item.key]=o},{ref_for:!0},l.item.options?.input,e.toHandlers(l.item.options?.input?.on),{disabled:s.getDisabled(l.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):l.item.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSwitch),e.mergeProps({key:1,modelValue:s.form[l.item.key],"onUpdate:modelValue":o=>s.form[l.item.key]=o},{ref_for:!0},l.item.options?.switch,e.toHandlers(l.item.options?.switch?.on||{}),{disabled:s.getDisabled(l.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):l.item.type==="select"?(e.openBlock(),e.createBlock(e.unref(p.ElSelect),e.mergeProps({key:2,modelValue:s.form[l.item.key],"onUpdate:modelValue":o=>s.form[l.item.key]=o},{ref_for:!0},l.item.options?.select,e.toHandlers(l.item.options?.select?.on||{}),{disabled:s.getDisabled(l.item),style:{width:"100%"}}),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.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"])):l.item.type==="list"?(e.openBlock(),e.createBlock(x,e.mergeProps({key:3,row:s.form,field:l.item.key},{ref_for:!0},l.item.options?.list,e.toHandlers(l.item.options?.list?.on||{}),{disabled:s.getDisabled(l.item),style:{width:"100%"}}),null,16,["row","field","disabled"])):l.item.type==="tree-select"?(e.openBlock(),e.createBlock(e.unref(p.ElTreeSelect),e.mergeProps({key:4,modelValue:s.form[l.item.key],"onUpdate:modelValue":o=>s.form[l.item.key]=o},{ref_for:!0},l.item.options?.treeSelect,e.toHandlers(l.item.options?.treeSelect?.on||{}),{disabled:s.getDisabled(l.item),style:{width:"100%"}}),null,16,["modelValue","onUpdate:modelValue","disabled"])):l.item.type==="datetime"?(e.openBlock(),e.createBlock(e.unref(p.ElDatePicker),e.mergeProps({key:5,modelValue:s.form[l.item.key],"onUpdate:modelValue":o=>s.form[l.item.key]=o},{ref_for:!0},l.item.options?.datetime,e.toHandlers(l.item.options?.datetime?.on||{}),{disabled:s.getDisabled(l.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.unref(V).customComponent[l.item.type]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(V).customComponent[l.item.type]),e.mergeProps({key:6,modelValue:s.form[l.item.key],"onUpdate:modelValue":o=>s.form[l.item.key]=o},{ref_for:!0},l.item.options?.[l.item.type],e.toHandlers(l.item.options?.[l.item.type]?.on||{}),{disabled:s.getDisabled(l.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.createCommentVNode("",!0)]),e.renderSlot(t.$slots,"form-"+l.item.key+"-end",{row:s.form,item:l.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 m=await b.loadModule("xlsx"),h=c.map(r=>{const a={};return d.forEach(l=>{a[l.label]=r[l.key]}),a}),s=m.utils.json_to_sheet(h),t=m.utils.book_new();m.utils.book_append_sheet(t,s,"Sheet1"),i?typeof i=="function"&&(i=i()):i=`导出数据_${new Date().Format("yyyy-MM-dd")}_${new Date().getTime()}`,m.writeFile(t,`${i}.xlsx`)}}const O={class:"dialog-footer"},I=e.defineComponent({__name:"switchConfirm",setup(f,{expose:c}){const d=e.ref(!1),i=e.ref("确认修改"),m=e.ref("确认要修改状态吗?");let h=null,s=null;const t=l=>(l?.title&&(i.value=l.title),l?.content&&(m.value=l.content),d.value=!0,new Promise((o,n)=>{h=o,s=n})),r=()=>{d.value=!1,h?.(!0),h=null,s=null},a=()=>{d.value=!1,s?.(new Error("用户取消操作")),h=null,s=null};return c({open:t}),(l,o)=>(e.openBlock(),e.createBlock(e.unref(p.ElDialog),{modelValue:d.value,"onUpdate:modelValue":o[0]||(o[0]=n=>d.value=n),title:i.value,"close-on-click-modal":!1,width:"400px"},{footer:e.withCtx(()=>[e.createElementVNode("span",O,[e.createVNode(e.unref(p.ElButton),{onClick:a},{default:e.withCtx(()=>[...o[1]||(o[1]=[e.createTextVNode("取消",-1)])]),_:1}),e.createVNode(e.unref(p.ElButton),{type:"primary",onClick:r},{default:e.withCtx(()=>[...o[2]||(o[2]=[e.createTextVNode("确认",-1)])]),_:1})])]),default:e.withCtx(()=>[e.createElementVNode("div",null,e.toDisplayString(m.value),1)]),_:1},8,["modelValue","title"]))}}),L={class:"col relative cc1-form-box"},j={class:"absolute row fit",style:{overflow:"hidden"}},z={class:"col column"},M={key:0,class:"relative curd-search"},R={class:"mb-20 flex justify-between items-center"},_={class:"flex items-center",style:{gap:"10px"}},H={key:0},W={key:1},A={key:2},J={class:"export-btn"},K={class:"flex items-center",style:{gap:"10px"}},q={class:"col fit-width relative"},G={class:"absolute column fit"},X={class:"row justify-end mt-20 mb-20"},Q={class:"row curd-row"},Y={class:"row form-item-content",style:{width:"100%"}},Z={class:"col"},P={class:"dialog-footer"},v={class:"dialog-footer"},D=e.defineComponent({__name:"index",props:{option:{default:{}}},setup(f,{expose:c}){const d=b.EDialog,i=f,m=e.ref(),h=e.ref(),s=b.isFun,t=e.reactive({search:{column:{list:[]},form:{},formDefault:{},getFormData:()=>{let r={};i.option.column.forEach(l=>{(typeof l.show?.search=="function"?l.show?.search(t.search.form):l.show?.search)&&(r[l.key]=t.search.form[l.key])});const a=i.option.search?.before?.(r);return a&&(r=a),r},reset:()=>{const r=t.search.formDefault;Object.keys(r).forEach(a=>{i.option.search?.resetMode==="default"?r[a]=t.search.formDefault[a]:r[a]=void 0}),t.search.form=JSONUtil.cp(r),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:(r,a)=>{},all:()=>{if(t.table.expand.isExpand)t.table.expand.rowKeys=[];else{const r=a=>{let l=[];return a.forEach(o=>{l.push(o._id),o.children&&o.children.length>0&&(l=l.concat(r(o.children)))}),l};t.table.expand.rowKeys=r(t.table.data)}t.table.expand.isExpand=!t.table.expand.isExpand}},column:{list:[],show:{listSource:[],list:[]}},getList:async()=>{t.table.loading=!0;const r=i.option.api.list,a=await r({size:t.page.size,num:t.page.num,...t.search.getFormData(),final(n,u,w){t.table.loading=!1}}),l=a.data||{list:a};let o=Array.isArray(l.list)?l.list:l;t.table.data=i.option.data?await i.option.data(o):o,t.page.total=l.total||0},selection:{list:[],change:r=>{t.table.selection.list=r}},exportFun:{start:async r=>{let a=await t.table.exportFun[r](),l=i.option.column;const o=JSONUtil.cp({data:a,columns:l}),n=i.option.tools?.export||{};n.before&&n.before(o),S.exportToExcel(o.data,o.columns,n.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 r=i.option.api.list,{data:a}=await r({size:999999,num:1,final(l,o,n){t.table.loading=!1}});return a.list}},export:r=>{t.table.exportFun.start(r)}},update:{title:"",rules:{},show:!1,showContent:!1,loading:!1,type:d.Insert,form:{},formDefault:{},formColumn:[],getDisabled:r=>r.disabled?.[t.update.type===d.Insert?"create":"update"],edit:{data:{},getApiData:r=>{if(i.option.form?.editAll)return r;let a={_id:t.update.edit.data._id};return Object.keys(t.update.edit.data).forEach(l=>{r[l]!==t.update.edit.data[l]&&(a[l]=r[l])}),a}},open:(r,a)=>{t.update.showContent||FunUtil.throttle(async()=>{t.update.type=r;const l=r===d.Insert;t.update.edit.data=a,t.update.title=l?"新增":"编辑",t.update.form=JSONUtil.cp(l?t.update.formDefault:a),await i.option.form?.openBefore?.(a,t.update),t.update.show=!0,t.update.showContent=!0,i.option.form?.openAfter?.(a,t.update)})},submit:()=>{FunUtil.throttle(async()=>{await h.value?.validate(async(l,o)=>new Promise((n,u)=>{l||(b.fail("请检查表单数据"),u(!1)),n()})),t.update.loading=!0;const r=t.update.type===d.Insert?i.option.api.create:i.option.api.update;let a=JSONUtil.cp(t.update.form);delete a.children,await i.option.form?.submitBefore?.(a,t.update),Object.keys(a).forEach(l=>{if(typeof a[l]=="string"&&a[l].indexOf("T")>-1){const o=new Date(a[l]).getTime();!isNaN(o)&&o>new Date("1971-01-01").getTime()&&(a[l]=o)}}),await r({...a,final(l,o,n){t.update.loading=!1}}),t.update.close(),await t.table.getList(),i.option.form?.submitAfter?.(a,t.update)})},close:()=>{t.update.show=!1,setTimeout(()=>{t.update.showContent=!1},350)}},remove:{title:"确认删除",show:!1,items:[],loading:!1,close:()=>{t.remove.show=!1},open:r=>{if(r.length===0){b.fail("请选择要删除的数据");return}t.remove.items=r,t.remove.show=!0},submit:()=>{FunUtil.throttle(async()=>{t.table.loading=!0;const r=i.option.api.delete;await r({_id:t.remove.items.map(a=>a._id),final(a,l,o){t.table.loading=!1}}),b.success("操作成功"),t.table.data.length<=1&&t.page.num>1&&(t.page.num-=1),t.remove.close(),await t.table.getList()})}},init:()=>{t.initCurdConfig(),t.initColumnOptions(),t.initColumnForm()},initCurdConfig:()=>{const a={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}},l=i.option;Object.keys(a).forEach(o=>{l[o]=ObjectUtil.deepMerge(a[o],l[o]||{})})},initColumnOptions:()=>{const r=i.option,a=l=>{const n={options:{switch:{activeValue:!0,activeLabel:"开启",inactiveValue:!1,inactiveLabel:"关闭",tableBeforeChange:async(w,k)=>{const g=l.options?.switch;try{return await m.value?.open({title:"确认修改",content:`确认要${k[w]===g.activeValue?g.inactiveLabel:g.activeLabel}吗?`}),t.table.loading=!0,await i.option.api.update({_id:k._id,[w]:k[w]===g.activeValue?g.inactiveValue:g.activeValue,final(B,E,U){t.table.loading=!1}}),b.success("操作成功"),t.table.getList(),!0}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=l;Object.keys(n).forEach(w=>{u[w]=ObjectUtil.deepMerge(n[w],u[w]||{})})};r.column.forEach(a),r.table?.column?.forEach(a)},initColumnForm:()=>{const r=i.option;t.update.formColumn=[],t.table.column.show={list:[],listSource:[]};const a=[],l=i.option.form?.maxSpan||12,o=i.option.form?.defaultSpan||l/2;let n=[];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 g=k.form.span,B=n.reduce((U,te)=>U+te.span,g);const E=n.length;n.push({item:k,span:g}),(E===1&&n[0].span===0||B>=l||g===0&&E>1)&&(a.push(n),n=[]),k.rules&&(t.update.rules[k.key]=k.rules)}};r.column.forEach(k=>{k.isForm=!0,u(k)}),i.option.table?.column?.forEach(k=>{k.isForm=!1,u(k)}),t.search.column.list=r.column.concat(r.table?.column||[]),t.table.column.list=t.search.column.list.filter(k=>k.table?.table),t.search.column.list.sort((k,g)=>k.sort?.search-g.sort?.search),t.table.column.list.sort((k,g)=>k.sort?.table-g.sort?.table),n.length>0&&a.push(n),t.update.formColumn=a;const w=i.option.search?.formDefault;w&&Object.keys(w).forEach(k=>{t.search.formDefault[k]=w[k]}),r.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}),(r,a)=>{const l=e.resolveDirective("loading");return e.openBlock(),e.createElementBlock("div",L,[e.createElementVNode("div",j,[e.renderSlot(r.$slots,"box-left"),e.createElementVNode("div",z,[f.option.search?.show!==!1?(e.openBlock(),e.createElementBlock("div",M,[e.createVNode(e.unref(p.ElForm),{model:t.search.form,inline:""},{default:e.withCtx(()=>[e.renderSlot(r.$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:o.label},{default:e.withCtx(()=>[e.renderSlot(r.$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":n=>t.search.form[o.key]=n,placeholder:`请输入${o.label}`,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":n=>t.search.form[o.key]=n,placeholder:`请选择${o.label}`,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":n=>t.search.form[o.key]=n,placeholder:`请选择${o.label}`,clearable:"",disabled:o.disabled?.search},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options?.select?.data,n=>(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:n.value,label:n.label,value:n.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","placeholder","disabled"])):e.createCommentVNode("",!0)])]),_:2},1032,["label"])):e.createCommentVNode("",!0)],64))),128)),e.renderSlot(r.$slots,"search-center",{row:t.search.form}),e.createVNode(e.unref(p.ElFormItem),null,{default:e.withCtx(()=>[f.option.tools?.search?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:0,type:"primary",onClick:t.search.submit},{default:e.withCtx(()=>[...a[7]||(a[7]=[e.createTextVNode(" 搜索 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),f.option.tools?.reset?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:1,onClick:t.search.reset},{default:e.withCtx(()=>[...a[8]||(a[8]=[e.createTextVNode("重置",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0)]),_:1}),e.renderSlot(r.$slots,"search-end",{row:t.search.form})]),_:3},8,["model"])])):e.createCommentVNode("",!0),e.createElementVNode("div",R,[e.createElementVNode("div",_,[e.unref(s)(f.option.tools?.add)?(e.openBlock(),e.createElementBlock("div",H,[e.createVNode(e.unref(p.ElButton),{type:"primary",onClick:a[0]||(a[0]=o=>t.update.open(e.unref(d).Insert))},{default:e.withCtx(()=>[...a[9]||(a[9]=[e.createTextVNode("新增",-1)])]),_:1})])):e.createCommentVNode("",!0),f.option.table?.selectable&&e.unref(s)(f.option.tools?.delete)?(e.openBlock(),e.createElementBlock("div",W,[e.createVNode(e.unref(p.ElButton),{type:"danger",onClick:a[1]||(a[1]=o=>t.remove.open(t.table.selection.list))},{default:e.withCtx(()=>[...a[10]||(a[10]=[e.createTextVNode(" 删除 ",-1)])]),_:1})])):e.createCommentVNode("",!0),f.option.tools?.expand?(e.openBlock(),e.createElementBlock("div",A,[e.createVNode(e.unref(p.ElButton),{type:"warning",onClick:a[2]||(a[2]=o=>t.table.expand.all())},{default:e.withCtx(()=>[...a[11]||(a[11]=[e.createTextVNode("展开/收缩",-1)])]),_:1})])):e.createCommentVNode("",!0),f.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(()=>[...a[13]||(a[13]=[e.createTextVNode("导出选中",-1)])]),_:1}),e.createVNode(e.unref(p.ElDropdownItem),{command:"page"},{default:e.withCtx(()=>[...a[14]||(a[14]=[e.createTextVNode("导出本页",-1)])]),_:1}),e.createVNode(e.unref(p.ElDropdownItem),{command:"all"},{default:e.withCtx(()=>[...a[15]||(a[15]=[e.createTextVNode("导出全部",-1)])]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createElementVNode("div",J,[e.createVNode(e.unref(p.ElButton),{type:"warning"},{default:e.withCtx(()=>[...a[12]||(a[12]=[e.createTextVNode("导出",-1)])]),_:1})])]),_:1},8,["onCommand"])):e.createCommentVNode("",!0),e.renderSlot(r.$slots,"tools-left")]),e.createElementVNode("div",K,[e.renderSlot(r.$slots,"tools-right")])]),e.createElementVNode("div",q,[e.createElementVNode("div",G,[e.withDirectives((e.openBlock(),e.createBlock(e.unref(p.ElTable),e.mergeProps({data:t.table.data},f.option.table,{onSelectionChange:t.table.selection.change,"expand-row-keys":t.table.expand.rowKeys,onExpandChange:t.table.expand.change}),{default:e.withCtx(()=>[f.option.table?.selectable&&e.unref(s)(f.option.tools?.delete)?(e.openBlock(),e.createBlock(e.unref(p.ElTableColumn),{key:0,type:"selection",selectable:typeof f.option.table?.selectable=="function"?f.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:n})=>[e.renderSlot(r.$slots,"table-"+o.key,{row:n,item:o},()=>[o.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSwitch),e.mergeProps({key:0,modelValue:n[o.key],"onUpdate:modelValue":u=>n[o.key]=u,"before-change":()=>o.options?.switch?.tableBeforeChange?.(o.key,n)},{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(n[o.key]),1)],64))])]),_:2},1040,["prop","label"])):e.createCommentVNode("",!0)],64))),128)),e.unref(s)(f.option.tools?.add)||e.unref(s)(f.option.tools?.update)||e.unref(s)(f.option.tools?.delete)||r.$slots["table-op-left"]||r.$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(r.$slots,"table-op-left",{row:o}),e.unref(s)(f.option.tools?.add,o)?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:0,link:"",type:"primary",onClick:n=>t.update.open(e.unref(d).Insert,o)},{default:e.withCtx(()=>[...a[16]||(a[16]=[e.createTextVNode(" 新增 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),e.unref(s)(f.option.tools?.update,o)?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:1,link:"",type:"warning",onClick:n=>t.update.open(e.unref(d).Update,o)},{default:e.withCtx(()=>[...a[17]||(a[17]=[e.createTextVNode(" 编辑 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),e.unref(s)(f.option.tools?.delete,o)?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:2,link:"",type:"danger",onClick:n=>t.remove.open([o])},{default:e.withCtx(()=>[...a[18]||(a[18]=[e.createTextVNode(" 删除 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),e.renderSlot(r.$slots,"table-op-right",{row:o})]),_:3})):e.createCommentVNode("",!0)]),_:3},16,["data","onSelectionChange","expand-row-keys","onExpandChange"])),[[l,t.table.loading]])])]),e.createElementVNode("div",X,[t.page.total>t.page.size?(e.openBlock(),e.createBlock(e.unref(p.ElPagination),{key:0,"current-page":t.page.num,"onUpdate:currentPage":a[3]||(a[3]=o=>t.page.num=o),"page-size":t.page.size,"onUpdate:pageSize":a[4]||(a[4]=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(r.$slots,"box-right")]),e.createVNode(e.unref(p.ElDialog),e.mergeProps({modelValue:t.update.show,"onUpdate:modelValue":a[5]||(a[5]=o=>t.update.show=o),title:t.update.title,"close-on-click-modal":!1,"before-close":t.update.close},f.option.dialog),{footer:e.withCtx(()=>[e.createElementVNode("span",P,[e.createVNode(e.unref(p.ElButton),{onClick:t.update.close},{default:e.withCtx(()=>[...a[19]||(a[19]=[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(()=>[...a[20]||(a[20]=[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("div",Q,[e.renderSlot(r.$slots,"form-start",{row:t.update.form}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o,n=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.unref(s)(n.item.show?.form,t.update.form)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(n.item.form.span>0?`col-${n.item.form.span}`:"col")},[e.createVNode(e.unref(p.ElFormItem),{label:n.item.label,prop:n.item.key,"label-width":n.item.form?.labelWidth||"100px"},{default:e.withCtx(()=>[e.createElementVNode("div",Y,[e.renderSlot(r.$slots,"form-"+n.item.key+"-start",{row:t.update.form,item:n.item}),e.createElementVNode("div",Z,[e.renderSlot(r.$slots,"form-"+n.item.key,{row:t.update.form,item:n.item},()=>[n.item.type==="input"?(e.openBlock(),e.createBlock(e.unref(p.ElInput),e.mergeProps({key:0,modelValue:t.update.form[n.item.key],"onUpdate:modelValue":u=>t.update.form[n.item.key]=u},{ref_for:!0},n.item.options?.input,e.toHandlers(n.item.options?.input?.on||{}),{disabled:t.update.getDisabled(n.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):n.item.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSwitch),e.mergeProps({key:1,modelValue:t.update.form[n.item.key],"onUpdate:modelValue":u=>t.update.form[n.item.key]=u},{ref_for:!0},n.item.options?.switch,{disabled:t.update.getDisabled(n.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):n.item.type==="select"?(e.openBlock(),e.createBlock(e.unref(p.ElSelect),e.mergeProps({key:2,modelValue:t.update.form[n.item.key],"onUpdate:modelValue":u=>t.update.form[n.item.key]=u},{ref_for:!0},n.item.options?.select,e.toHandlers(n.item.options?.select?.on||{}),{disabled:t.update.getDisabled(n.item),style:{width:"100%"}}),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.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"])):n.item.type==="list"?(e.openBlock(),e.createBlock(x,e.mergeProps({key:3,row:t.update.form,field:n.item.key},{ref_for:!0},n.item.options?.list,e.toHandlers(n.item.options?.list?.on||{}),{disabled:t.update.getDisabled(n.item),style:{width:"100%"}}),null,16,["row","field","disabled"])):n.item.type==="tree-select"?(e.openBlock(),e.createBlock(e.unref(p.ElTreeSelect),e.mergeProps({key:4,modelValue:t.update.form[n.item.key],"onUpdate:modelValue":u=>t.update.form[n.item.key]=u},{ref_for:!0},n.item.options?.treeSelect,e.toHandlers(n.item.options?.treeSelect?.on||{}),{disabled:t.update.getDisabled(n.item),style:{width:"100%"}}),null,16,["modelValue","onUpdate:modelValue","disabled"])):n.item.type==="datetime"?(e.openBlock(),e.createBlock(e.unref(p.ElDatePicker),e.mergeProps({key:5,modelValue:t.update.form[n.item.key],"onUpdate:modelValue":u=>t.update.form[n.item.key]=u},{ref_for:!0},n.item.options?.datetime,e.toHandlers(n.item.options?.datetime?.on||{}),{disabled:t.update.getDisabled(n.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.unref(V).customComponent[n.item.type]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(V).customComponent[n.item.type]),e.mergeProps({key:6,modelValue:t.update.form[n.item.key],"onUpdate:modelValue":u=>t.update.form[n.item.key]=u},{ref_for:!0},n.item.options?.[n.item.type],e.toHandlers(n.item.options?.[n.item.type]?.on||{}),{disabled:t.update.getDisabled(n.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.createCommentVNode("",!0)])]),e.renderSlot(r.$slots,"form-"+n.item.key+"-end",{row:t.update.form,item:n.item})])]),_:2},1032,["label","prop","label-width"])],2)):e.createCommentVNode("",!0)],64))),256)),e.renderSlot(r.$slots,"form-end",{row:t.update.form})]))),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":a[6]||(a[6]=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(()=>[...a[21]||(a[21]=[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(()=>[...a[22]||(a[22]=[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:m},null,512)])}}}),ee=(f,c)=>{if(f.component("TCurd",D),f.component("TFormList",x),f.component("TColumn",N),c?.customComponent){V.customComponent=c.customComponent;for(const d in c.customComponent)f.component(d,c.customComponent[d])}};y.ArrUtil=C,y.ExcelUtil=S,y.TColumn=N,y.TCurd=D,y.TForm=V,y.TFormList=x,y.TSys=b,y.install=ee,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(y,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):(y=typeof globalThis<"u"?globalThis:y||self,e(y.cc1Form={},y.Vue,y.ElementPlus))})(this,(function(y,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 m=Date.now();if(!this.tipMessages[c]||m-this.tipMessages[c]>this.tipMessagesGap){this.tipMessages[c]=m;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,m=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="+m+", 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 m=document.getElementById(c.id);const h=await b.loadModule("html2canvas");try{h(m,{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(r){let t=r.toDataURL("image/png");d(t)})}catch(r){i(r)}});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)}}class V{static customComponent={};static findOptions=(c,d)=>{const i=c.column.find(h=>h.key===d),m=h=>h.replace(/-([a-z])/g,(r,t)=>t.toUpperCase());if(i)return i.options[m(i.type)]};static setOptionsData=(c,d,i)=>{const m=V.findOptions(c,d);m&&(m.data=i)};static form={openBefore:{parentId:(c,d,i,m)=>{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),V.setOptionsData(m,"parentId",[{_id:"0",title:"根",children:i}])}}}}class C{static getIdFun=()=>StrUtil.uuid();static setId=(c,d,i)=>{d[c]||(d[c]=[]),d[c].forEach(m=>{i.forEach(h=>{let r=h.default??"";h.type==="number"&&(r=h.default??0),h.type==="boolean"&&(r=h.default??!1),h.type==="time"&&(r=h.default??new Date),m[h.value]===void 0&&(m[h.value]=r)}),m._id||(m._id=C.getIdFun())})};static add=(c,d,i,m)=>{const h=JSONUtil.cp(i);C.setId(c,d,i),d[c].push(h.reduce((r,t)=>{let s=t.default??"";return t.type==="number"&&(s=t.default??0),t.type==="boolean"&&(s=t.default??!1),t.type==="time"&&(s=t.default??new Date),r[t.value]=s,r},{_id:C.getIdFun()})),m?.(d)};static remove=(c,d,i,m)=>{d[c]=d[c].filter(h=>h._id!==i._id),m?.(d)};static getNoIdData=(c,d)=>{const i=JSONUtil.cp(c);return i.forEach(m=>{m._id&&delete m._id,d&&m[d]&&C.getNoIdData(m[d],d)}),i}}const F={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(f,{emit:c}){const d=f,i=e.reactive({show:!1,add:(h,r,t)=>{C.add(h,r,t,()=>{m("change")})},remove:(h,r,t)=>{C.remove(h,r,t,()=>{m("change")})}});e.onMounted(()=>{C.setId(d.field,d.row,d.itemFields),i.show=!0});const m=c;return(h,r)=>{const t=e.resolveComponent("el-button"),s=e.resolveComponent("el-input");return i.show?(e.openBlock(),e.createElementBlock("div",F,[e.renderSlot(h.$slots,"list-start",{row:f.row}),e.createElementVNode("div",null,[e.createVNode(t,{link:"",type:"primary",onClick:r[0]||(r[0]=a=>i.add(f.field,f.row,f.itemFields))},{default:e.withCtx(()=>[...r[2]||(r[2]=[e.createTextVNode("添加",-1)])]),_:1})]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.row[f.field],a=>(e.openBlock(),e.createElementBlock("div",$,[e.renderSlot(h.$slots,"item-start",{item:a,row:f.row}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.itemFields,l=>(e.openBlock(),e.createBlock(s,{modelValue:a[l.value],"onUpdate:modelValue":o=>a[l.value]=o,style:e.normalizeStyle({width:f.inputWidth}),class:e.normalizeClass(f.inputClass),placeholder:l[f.label]||l[f.value],onChange:r[1]||(r[1]=o=>m("change"))},null,8,["modelValue","onUpdate:modelValue","style","class","placeholder"]))),256)),e.renderSlot(h.$slots,"item-end",{item:a,row:f.row}),e.createVNode(t,{link:"",type:"danger",onClick:l=>i.remove(f.field,f.row,a)},{default:e.withCtx(()=>[...r[3]||(r[3]=[e.createTextVNode("删除",-1)])]),_:1},8,["onClick"])]))),256)),e.renderSlot(h.$slots,"list-end",{row:f.row})])):e.createCommentVNode("",!0)}}}),T={class:"row curd-row"},N=e.defineComponent({__name:"column",props:{option:{default:{}},type:{default:""}},setup(f,{expose:c}){const d=b.isFun,i=b.EDialog,m=e.ref(),h=f,r=e.reactive({rules:{},show:!0,form:{},formDefault:{},formColumn:[],getDisabled:t=>t.disabled?.[(h.type||i.Insert)===i.Insert?"create":"update"],initColumnForm:()=>{const t=h.option;r.formColumn=[];const s=[],a=h.option.form?.maxSpan||12,l=h.option.form?.defaultSpan||a;let o=[];const n=u=>{if(r.formDefault[u.key]=u.value,u.isForm){u.form=u.form||{span:l},u.form.span=u.form.span??l;let w=u.form.span,k=o.reduce((B,E)=>B+E.span,w);const g=o.length;o.push({item:u,span:w}),(g===1&&o[0].span===0||k>=a||w===0&&g>1)&&(s.push(o),o=[]),u.rules&&(r.rules[u.key]=u.rules)}};t.column.forEach(u=>{u.isForm=!0,n(u)}),o.length>0&&s.push(o),r.formColumn=s},init:async()=>{r.show=!1,await e.nextTick(),r.initColumnForm(),r.show=!0}});return r.initColumnForm(),c({ref:m,conf:r}),(t,s)=>(e.openBlock(),e.createBlock(e.unref(p.ElForm),{ref_key:"ruleFormRef",ref:m,model:r.form,rules:r.rules},{default:e.withCtx(()=>[r.show?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(r.formColumn,a=>(e.openBlock(),e.createElementBlock("div",T,[e.renderSlot(t.$slots,"form-start",{row:r.form}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a,l=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.unref(d)(l.item.show?.form,r.form)??!0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(l.item.form.span>0?`col-${l.item.form.span}`:"col")},[e.createVNode(e.unref(p.ElFormItem),{label:l.item.label,prop:l.item.key,"label-width":l.item.form?.labelWidth||"100px"},{default:e.withCtx(()=>[e.renderSlot(t.$slots,"form-"+l.item.key+"-start",{row:r.form,item:l.item}),e.renderSlot(t.$slots,"form-"+l.item.key,{row:r.form,item:l.item},()=>[l.item.type==="input"?(e.openBlock(),e.createBlock(e.unref(p.ElInput),e.mergeProps({key:0,modelValue:r.form[l.item.key],"onUpdate:modelValue":o=>r.form[l.item.key]=o},{ref_for:!0},l.item.options?.input,e.toHandlers(l.item.options?.input?.on),{disabled:r.getDisabled(l.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):l.item.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSwitch),e.mergeProps({key:1,modelValue:r.form[l.item.key],"onUpdate:modelValue":o=>r.form[l.item.key]=o},{ref_for:!0},l.item.options?.switch,e.toHandlers(l.item.options?.switch?.on||{}),{disabled:r.getDisabled(l.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):l.item.type==="select"?(e.openBlock(),e.createBlock(e.unref(p.ElSelect),e.mergeProps({key:2,modelValue:r.form[l.item.key],"onUpdate:modelValue":o=>r.form[l.item.key]=o},{ref_for:!0},l.item.options?.select,e.toHandlers(l.item.options?.select?.on||{}),{disabled:r.getDisabled(l.item),style:{width:"100%"}}),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.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"])):l.item.type==="list"?(e.openBlock(),e.createBlock(x,e.mergeProps({key:3,row:r.form,field:l.item.key},{ref_for:!0},l.item.options?.list,e.toHandlers(l.item.options?.list?.on||{}),{disabled:r.getDisabled(l.item),style:{width:"100%"}}),null,16,["row","field","disabled"])):l.item.type==="tree-select"?(e.openBlock(),e.createBlock(e.unref(p.ElTreeSelect),e.mergeProps({key:4,modelValue:r.form[l.item.key],"onUpdate:modelValue":o=>r.form[l.item.key]=o},{ref_for:!0},l.item.options?.treeSelect,e.toHandlers(l.item.options?.treeSelect?.on||{}),{disabled:r.getDisabled(l.item),style:{width:"100%"}}),null,16,["modelValue","onUpdate:modelValue","disabled"])):l.item.type==="datetime"?(e.openBlock(),e.createBlock(e.unref(p.ElDatePicker),e.mergeProps({key:5,modelValue:r.form[l.item.key],"onUpdate:modelValue":o=>r.form[l.item.key]=o},{ref_for:!0},l.item.options?.datetime,e.toHandlers(l.item.options?.datetime?.on||{}),{disabled:r.getDisabled(l.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.unref(V).customComponent[l.item.type]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(V).customComponent[l.item.type]),e.mergeProps({key:6,modelValue:r.form[l.item.key],"onUpdate:modelValue":o=>r.form[l.item.key]=o},{ref_for:!0},l.item.options?.[l.item.type],e.toHandlers(l.item.options?.[l.item.type]?.on||{}),{disabled:r.getDisabled(l.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.createCommentVNode("",!0)]),e.renderSlot(t.$slots,"form-"+l.item.key+"-end",{row:r.form,item:l.item})]),_:2},1032,["label","prop","label-width"])],2)):e.createCommentVNode("",!0)],64))),256)),e.renderSlot(t.$slots,"form-end",{row:r.form})]))),256)):e.createCommentVNode("",!0)]),_:3},8,["model","rules"]))}});class S{static exportToExcel=async(c,d,i)=>{const m=await b.loadModule("xlsx"),h=c.map(s=>{const a={};return d.forEach(l=>{a[l.label]=s[l.key]}),a}),r=m.utils.json_to_sheet(h),t=m.utils.book_new();m.utils.book_append_sheet(t,r,"Sheet1"),i?typeof i=="function"&&(i=i()):i=`导出数据_${new Date().Format("yyyy-MM-dd")}_${new Date().getTime()}`,m.writeFile(t,`${i}.xlsx`)}}const O={class:"dialog-footer"},I=e.defineComponent({__name:"switchConfirm",setup(f,{expose:c}){const d=e.ref(!1),i=e.ref("确认修改"),m=e.ref("确认要修改状态吗?");let h=null,r=null;const t=l=>(l?.title&&(i.value=l.title),l?.content&&(m.value=l.content),d.value=!0,new Promise((o,n)=>{h=o,r=n})),s=()=>{d.value=!1,h?.(!0),h=null,r=null},a=()=>{d.value=!1,r?.(new Error("用户取消操作")),h=null,r=null};return c({open:t}),(l,o)=>(e.openBlock(),e.createBlock(e.unref(p.ElDialog),{modelValue:d.value,"onUpdate:modelValue":o[0]||(o[0]=n=>d.value=n),title:i.value,"close-on-click-modal":!1,width:"400px"},{footer:e.withCtx(()=>[e.createElementVNode("span",O,[e.createVNode(e.unref(p.ElButton),{onClick:a},{default:e.withCtx(()=>[...o[1]||(o[1]=[e.createTextVNode("取消",-1)])]),_:1}),e.createVNode(e.unref(p.ElButton),{type:"primary",onClick:s},{default:e.withCtx(()=>[...o[2]||(o[2]=[e.createTextVNode("确认",-1)])]),_:1})])]),default:e.withCtx(()=>[e.createElementVNode("div",null,e.toDisplayString(m.value),1)]),_:1},8,["modelValue","title"]))}}),L={class:"col relative cc1-form-box"},j={class:"absolute row fit",style:{overflow:"hidden"}},z={class:"col column"},M={key:0,class:"relative curd-search"},R={class:"mb-20 flex justify-between items-center"},_={class:"flex items-center",style:{gap:"10px"}},H={key:0},W={key:1},A={key:2},J={class:"export-btn"},K={class:"flex items-center",style:{gap:"10px"}},q={class:"col fit-width relative"},G={class:"absolute column fit"},X={class:"row justify-end mt-20 mb-20"},Q={class:"row curd-row"},Y={class:"row form-item-content",style:{width:"100%"}},Z={class:"col"},P={class:"dialog-footer"},v={class:"dialog-footer"},D=e.defineComponent({__name:"index",props:{option:{default:{}}},setup(f,{expose:c}){const d=b.EDialog,i=f,m=e.ref(),h=e.ref(),r=b.isFun,t=e.reactive({search:{column:{list:[]},form:{},formDefault:{},getFormData:()=>{let s={};i.option.column.forEach(l=>{(typeof l.show?.search=="function"?l.show?.search(t.search.form):l.show?.search)&&(s[l.key]=t.search.form[l.key])});const a=i.option.search?.before?.(s);return a&&(s=a),s},reset:()=>{const s=t.search.formDefault;Object.keys(s).forEach(a=>{i.option.search?.resetMode==="default"?s[a]=t.search.formDefault[a]:s[a]=void 0}),t.search.form=JSONUtil.cp(s),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:(s,a)=>{},all:()=>{if(t.table.expand.isExpand)t.table.expand.rowKeys=[];else{const s=a=>{let l=[];return a.forEach(o=>{l.push(o._id),o.children&&o.children.length>0&&(l=l.concat(s(o.children)))}),l};t.table.expand.rowKeys=s(t.table.data)}t.table.expand.isExpand=!t.table.expand.isExpand}},column:{list:[],show:{listSource:[],list:[]}},getList:async()=>{t.table.loading=!0;const s=i.option.api.list,a=await s({size:t.page.size,num:t.page.num,...t.search.getFormData(),final(n,u,w){t.table.loading=!1}}),l=a.data||{list:a};let o=Array.isArray(l.list)?l.list:l;t.table.data=i.option.data?await i.option.data(o):o,t.page.total=l.total||0},selection:{list:[],change:s=>{t.table.selection.list=s}},exportFun:{start:async s=>{let a=await t.table.exportFun[s](),l=i.option.column;const o=JSONUtil.cp({data:a,columns:l}),n=i.option.tools?.export||{};n.before&&n.before(o),S.exportToExcel(o.data,o.columns,n.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 s=i.option.api.list,{data:a}=await s({size:999999,num:1,final(l,o,n){t.table.loading=!1}});return a.list}},export:s=>{t.table.exportFun.start(s)}},update:{title:"",rules:{},show:!1,showContent:!1,loading:!1,type:d.Insert,form:{},formDefault:{},formColumn:[],getDisabled:s=>s.disabled?.[t.update.type===d.Insert?"create":"update"],edit:{data:{},getApiData:s=>{if(i.option.form?.editAll)return s;let a={_id:t.update.edit.data._id};return Object.keys(t.update.edit.data).forEach(l=>{s[l]!==t.update.edit.data[l]&&(a[l]=s[l])}),a}},open:(s,a)=>{t.update.showContent||FunUtil.throttle(async()=>{t.update.type=s;const l=s===d.Insert;t.update.edit.data=a,t.update.title=l?"新增":"编辑",t.update.form=JSONUtil.cp(l?t.update.formDefault:a),await i.option.form?.openBefore?.(a,t.update),t.update.show=!0,t.update.showContent=!0,i.option.form?.openAfter?.(a,t.update)})},submit:()=>{FunUtil.throttle(async()=>{await h.value?.validate(async(l,o)=>new Promise((n,u)=>{l||(b.fail("请检查表单数据"),u(!1)),n()})),t.update.loading=!0;const s=t.update.type===d.Insert?i.option.api.create:i.option.api.update;let a=JSONUtil.cp(t.update.form);delete a.children,await i.option.form?.submitBefore?.(a,t.update),Object.keys(a).forEach(l=>{if(typeof a[l]=="string"&&a[l].indexOf("T")>-1){const o=new Date(a[l]).getTime();!isNaN(o)&&o>new Date("1971-01-01").getTime()&&(a[l]=o)}}),await s({...a,final(l,o,n){t.update.loading=!1}}),t.update.close(),await t.table.getList(),i.option.form?.submitAfter?.(a,t.update)})},close:()=>{t.update.show=!1,setTimeout(()=>{t.update.showContent=!1},350)}},remove:{title:"确认删除",show:!1,items:[],loading:!1,close:()=>{t.remove.show=!1},open:s=>{if(s.length===0){b.fail("请选择要删除的数据");return}t.remove.items=s,t.remove.show=!0},submit:()=>{FunUtil.throttle(async()=>{t.table.loading=!0;const s=i.option.api.delete;await s({_id:t.remove.items.map(a=>a._id),final(a,l,o){t.table.loading=!1}}),b.success("操作成功"),t.table.data.length<=1&&t.page.num>1&&(t.page.num-=1),t.remove.close(),await t.table.getList()})}},init:()=>{t.initCurdConfig(),t.initColumnOptions(),t.initColumnForm()},initCurdConfig:()=>{const a={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}},l=i.option;Object.keys(a).forEach(o=>{l[o]=ObjectUtil.deepMerge(a[o],l[o]||{})})},initColumnOptions:()=>{const s=i.option,a=l=>{const n={options:{switch:{activeValue:!0,activeLabel:"开启",inactiveValue:!1,inactiveLabel:"关闭",tableBeforeChange:async(w,k)=>{const g=l.options?.switch;try{return await m.value?.open({title:"确认修改",content:`确认要${k[w]===g.activeValue?g.inactiveLabel:g.activeLabel}吗?`}),t.table.loading=!0,await i.option.api.update({_id:k._id,[w]:k[w]===g.activeValue?g.inactiveValue:g.activeValue,final(B,E,U){t.table.loading=!1}}),b.success("操作成功"),t.table.getList(),!0}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=l;Object.keys(n).forEach(w=>{u[w]=ObjectUtil.deepMerge(n[w],u[w]||{})})};s.column.forEach(a),s.table?.column?.forEach(a)},initColumnForm:()=>{const s=i.option;t.update.formColumn=[],t.table.column.show={list:[],listSource:[]};const a=[],l=i.option.form?.maxSpan||12,o=i.option.form?.defaultSpan||l/2;let n=[];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 g=k.form.span,B=n.reduce((U,te)=>U+te.span,g);const E=n.length;n.push({item:k,span:g}),(E===1&&n[0].span===0||B>=l||g===0&&E>1)&&(a.push(n),n=[]),k.rules&&(t.update.rules[k.key]=k.rules)}};s.column.forEach(k=>{k.isForm=!0,u(k)}),i.option.table?.column?.forEach(k=>{k.isForm=!1,u(k)}),t.search.column.list=s.column.concat(s.table?.column||[]),t.table.column.list=t.search.column.list.filter(k=>k.table?.table),t.search.column.list.sort((k,g)=>k.sort?.search-g.sort?.search),t.table.column.list.sort((k,g)=>k.sort?.table-g.sort?.table),n.length>0&&a.push(n),t.update.formColumn=a;const w=i.option.search?.formDefault;w&&Object.keys(w).forEach(k=>{t.search.formDefault[k]=w[k]}),s.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}),(s,a)=>{const l=e.resolveDirective("loading");return e.openBlock(),e.createElementBlock("div",L,[e.createElementVNode("div",j,[e.renderSlot(s.$slots,"box-left"),e.createElementVNode("div",z,[f.option.search?.show!==!1?(e.openBlock(),e.createElementBlock("div",M,[e.createVNode(e.unref(p.ElForm),{model:t.search.form,inline:""},{default:e.withCtx(()=>[e.renderSlot(s.$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:o.label},{default:e.withCtx(()=>[e.renderSlot(s.$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":n=>t.search.form[o.key]=n,placeholder:`请输入${o.label}`,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":n=>t.search.form[o.key]=n,placeholder:`请选择${o.label}`,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":n=>t.search.form[o.key]=n,placeholder:`请选择${o.label}`,clearable:"",disabled:o.disabled?.search},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options?.select?.data,n=>(e.openBlock(),e.createBlock(e.unref(p.ElOption),{key:n.value,label:n.label,value:n.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","placeholder","disabled"])):e.createCommentVNode("",!0)])]),_:2},1032,["label"])):e.createCommentVNode("",!0)],64))),128)),e.renderSlot(s.$slots,"search-center",{row:t.search.form}),e.createVNode(e.unref(p.ElFormItem),null,{default:e.withCtx(()=>[f.option.tools?.search?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:0,type:"primary",onClick:t.search.submit},{default:e.withCtx(()=>[...a[7]||(a[7]=[e.createTextVNode(" 搜索 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),f.option.tools?.reset?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:1,onClick:t.search.reset},{default:e.withCtx(()=>[...a[8]||(a[8]=[e.createTextVNode("重置",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0)]),_:1}),e.renderSlot(s.$slots,"search-end",{row:t.search.form})]),_:3},8,["model"])])):e.createCommentVNode("",!0),e.createElementVNode("div",R,[e.createElementVNode("div",_,[e.unref(r)(f.option.tools?.add)?(e.openBlock(),e.createElementBlock("div",H,[e.createVNode(e.unref(p.ElButton),{type:"primary",onClick:a[0]||(a[0]=o=>t.update.open(e.unref(d).Insert))},{default:e.withCtx(()=>[...a[9]||(a[9]=[e.createTextVNode("新增",-1)])]),_:1})])):e.createCommentVNode("",!0),f.option.table?.selectable&&e.unref(r)(f.option.tools?.delete)?(e.openBlock(),e.createElementBlock("div",W,[e.createVNode(e.unref(p.ElButton),{type:"danger",onClick:a[1]||(a[1]=o=>t.remove.open(t.table.selection.list))},{default:e.withCtx(()=>[...a[10]||(a[10]=[e.createTextVNode(" 删除 ",-1)])]),_:1})])):e.createCommentVNode("",!0),f.option.tools?.expand?(e.openBlock(),e.createElementBlock("div",A,[e.createVNode(e.unref(p.ElButton),{type:"warning",onClick:a[2]||(a[2]=o=>t.table.expand.all())},{default:e.withCtx(()=>[...a[11]||(a[11]=[e.createTextVNode("展开/收缩",-1)])]),_:1})])):e.createCommentVNode("",!0),f.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(()=>[...a[13]||(a[13]=[e.createTextVNode("导出选中",-1)])]),_:1}),e.createVNode(e.unref(p.ElDropdownItem),{command:"page"},{default:e.withCtx(()=>[...a[14]||(a[14]=[e.createTextVNode("导出本页",-1)])]),_:1}),e.createVNode(e.unref(p.ElDropdownItem),{command:"all"},{default:e.withCtx(()=>[...a[15]||(a[15]=[e.createTextVNode("导出全部",-1)])]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createElementVNode("div",J,[e.createVNode(e.unref(p.ElButton),{type:"warning"},{default:e.withCtx(()=>[...a[12]||(a[12]=[e.createTextVNode("导出",-1)])]),_:1})])]),_:1},8,["onCommand"])):e.createCommentVNode("",!0),e.renderSlot(s.$slots,"tools-left")]),e.createElementVNode("div",K,[e.renderSlot(s.$slots,"tools-right")])]),e.createElementVNode("div",q,[e.createElementVNode("div",G,[e.withDirectives((e.openBlock(),e.createBlock(e.unref(p.ElTable),e.mergeProps({data:t.table.data},f.option.table,{onSelectionChange:t.table.selection.change,"expand-row-keys":t.table.expand.rowKeys,onExpandChange:t.table.expand.change}),{default:e.withCtx(()=>[f.option.table?.selectable&&e.unref(r)(f.option.tools?.delete)?(e.openBlock(),e.createBlock(e.unref(p.ElTableColumn),{key:0,type:"selection",selectable:typeof f.option.table?.selectable=="function"?f.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:n})=>[e.renderSlot(s.$slots,"table-"+o.key,{row:n,item:o},()=>[o.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSwitch),e.mergeProps({key:0,modelValue:n[o.key],"onUpdate:modelValue":u=>n[o.key]=u,"before-change":()=>o.options?.switch?.tableBeforeChange?.(o.key,n)},{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(n[o.key]),1)],64))])]),_:2},1040,["prop","label"])):e.createCommentVNode("",!0)],64))),128)),e.unref(r)(f.option.tools?.add)||e.unref(r)(f.option.tools?.update)||e.unref(r)(f.option.tools?.delete)||s.$slots["table-op-left"]||s.$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(s.$slots,"table-op-left",{row:o}),e.unref(r)(f.option.tools?.add,o)?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:0,link:"",type:"primary",onClick:n=>t.update.open(e.unref(d).Insert,o)},{default:e.withCtx(()=>[...a[16]||(a[16]=[e.createTextVNode(" 新增 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),e.unref(r)(f.option.tools?.update,o)?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:1,link:"",type:"warning",onClick:n=>t.update.open(e.unref(d).Update,o)},{default:e.withCtx(()=>[...a[17]||(a[17]=[e.createTextVNode(" 编辑 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),e.unref(r)(f.option.tools?.delete,o)?(e.openBlock(),e.createBlock(e.unref(p.ElButton),{key:2,link:"",type:"danger",onClick:n=>t.remove.open([o])},{default:e.withCtx(()=>[...a[18]||(a[18]=[e.createTextVNode(" 删除 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),e.renderSlot(s.$slots,"table-op-right",{row:o})]),_:3})):e.createCommentVNode("",!0)]),_:3},16,["data","onSelectionChange","expand-row-keys","onExpandChange"])),[[l,t.table.loading]])])]),e.createElementVNode("div",X,[t.page.total>t.page.size?(e.openBlock(),e.createBlock(e.unref(p.ElPagination),{key:0,"current-page":t.page.num,"onUpdate:currentPage":a[3]||(a[3]=o=>t.page.num=o),"page-size":t.page.size,"onUpdate:pageSize":a[4]||(a[4]=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(s.$slots,"box-right")]),e.createVNode(e.unref(p.ElDialog),e.mergeProps({modelValue:t.update.show,"onUpdate:modelValue":a[5]||(a[5]=o=>t.update.show=o),title:t.update.title,"close-on-click-modal":!1,"before-close":t.update.close},f.option.dialog),{footer:e.withCtx(()=>[e.createElementVNode("span",P,[e.createVNode(e.unref(p.ElButton),{onClick:t.update.close},{default:e.withCtx(()=>[...a[19]||(a[19]=[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(()=>[...a[20]||(a[20]=[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("div",Q,[e.renderSlot(s.$slots,"form-start",{row:t.update.form}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o,n=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.unref(r)(n.item.show?.form,t.update.form)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(n.item.form.span>0?`col-${n.item.form.span}`:"col")},[e.createVNode(e.unref(p.ElFormItem),{label:n.item.label,prop:n.item.key,"label-width":n.item.form?.labelWidth||"100px"},{default:e.withCtx(()=>[e.createElementVNode("div",Y,[e.renderSlot(s.$slots,"form-"+n.item.key+"-start",{row:t.update.form,item:n.item}),e.createElementVNode("div",Z,[e.renderSlot(s.$slots,"form-"+n.item.key,{row:t.update.form,item:n.item},()=>[n.item.type==="input"?(e.openBlock(),e.createBlock(e.unref(p.ElInput),e.mergeProps({key:0,modelValue:t.update.form[n.item.key],"onUpdate:modelValue":u=>t.update.form[n.item.key]=u},{ref_for:!0},n.item.options?.input,e.toHandlers(n.item.options?.input?.on||{}),{disabled:t.update.getDisabled(n.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):n.item.type==="switch"?(e.openBlock(),e.createBlock(e.unref(p.ElSwitch),e.mergeProps({key:1,modelValue:t.update.form[n.item.key],"onUpdate:modelValue":u=>t.update.form[n.item.key]=u},{ref_for:!0},n.item.options?.switch,{disabled:t.update.getDisabled(n.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):n.item.type==="select"?(e.openBlock(),e.createBlock(e.unref(p.ElSelect),e.mergeProps({key:2,modelValue:t.update.form[n.item.key],"onUpdate:modelValue":u=>t.update.form[n.item.key]=u},{ref_for:!0},n.item.options?.select,e.toHandlers(n.item.options?.select?.on||{}),{disabled:t.update.getDisabled(n.item),style:{width:"100%"}}),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.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"])):n.item.type==="list"?(e.openBlock(),e.createBlock(x,e.mergeProps({key:3,row:t.update.form,field:n.item.key},{ref_for:!0},n.item.options?.list,e.toHandlers(n.item.options?.list?.on||{}),{disabled:t.update.getDisabled(n.item),style:{width:"100%"}}),null,16,["row","field","disabled"])):n.item.type==="tree-select"?(e.openBlock(),e.createBlock(e.unref(p.ElTreeSelect),e.mergeProps({key:4,modelValue:t.update.form[n.item.key],"onUpdate:modelValue":u=>t.update.form[n.item.key]=u},{ref_for:!0},n.item.options?.treeSelect,e.toHandlers(n.item.options?.treeSelect?.on||{}),{disabled:t.update.getDisabled(n.item),style:{width:"100%"}}),null,16,["modelValue","onUpdate:modelValue","disabled"])):n.item.type==="datetime"?(e.openBlock(),e.createBlock(e.unref(p.ElDatePicker),e.mergeProps({key:5,modelValue:t.update.form[n.item.key],"onUpdate:modelValue":u=>t.update.form[n.item.key]=u},{ref_for:!0},n.item.options?.datetime,e.toHandlers(n.item.options?.datetime?.on||{}),{disabled:t.update.getDisabled(n.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.unref(V).customComponent[n.item.type]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(V).customComponent[n.item.type]),e.mergeProps({key:6,modelValue:t.update.form[n.item.key],"onUpdate:modelValue":u=>t.update.form[n.item.key]=u},{ref_for:!0},n.item.options?.[n.item.type],e.toHandlers(n.item.options?.[n.item.type]?.on||{}),{disabled:t.update.getDisabled(n.item)}),null,16,["modelValue","onUpdate:modelValue","disabled"])):e.createCommentVNode("",!0)])]),e.renderSlot(s.$slots,"form-"+n.item.key+"-end",{row:t.update.form,item:n.item})])]),_:2},1032,["label","prop","label-width"])],2)):e.createCommentVNode("",!0)],64))),256)),e.renderSlot(s.$slots,"form-end",{row:t.update.form})]))),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":a[6]||(a[6]=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(()=>[...a[21]||(a[21]=[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(()=>[...a[22]||(a[22]=[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:m},null,512)])}}}),ee=(f,c)=>{if(f.component("TCurd",D),f.component("TFormList",x),f.component("TColumn",N),c?.customComponent){V.customComponent=c.customComponent;for(const d in c.customComponent)f.component(d,c.customComponent[d])}};y.ArrUtil=C,y.ExcelUtil=S,y.TColumn=N,y.TCurd=D,y.TForm=V,y.TFormList=x,y.TSys=b,y.install=ee,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -7,9 +7,6 @@ declare const ruleFormRef: import("vue").Ref<FormInstance | undefined, FormInsta
|
|
|
7
7
|
declare const conf: {
|
|
8
8
|
rules: any;
|
|
9
9
|
show: boolean;
|
|
10
|
-
showContent: boolean;
|
|
11
|
-
loading: boolean;
|
|
12
|
-
type: any;
|
|
13
10
|
form: any;
|
|
14
11
|
formDefault: any;
|
|
15
12
|
formColumn: {
|
|
@@ -78,6 +75,7 @@ declare const conf: {
|
|
|
78
75
|
}[][];
|
|
79
76
|
getDisabled: (item: CurdConfigColumn) => boolean | undefined;
|
|
80
77
|
initColumnForm: () => void;
|
|
78
|
+
init: () => Promise<void>;
|
|
81
79
|
};
|
|
82
80
|
declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
|
|
83
81
|
declare var __VLS_7: {
|
|
@@ -298,6 +296,12 @@ declare const __VLS_self: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
298
296
|
column: CurdConfigColumn[];
|
|
299
297
|
};
|
|
300
298
|
};
|
|
299
|
+
/**
|
|
300
|
+
* 类型
|
|
301
|
+
*/
|
|
302
|
+
type: {
|
|
303
|
+
default: string;
|
|
304
|
+
};
|
|
301
305
|
}>, {
|
|
302
306
|
TForm: typeof TForm;
|
|
303
307
|
FormList: typeof FormList;
|
|
@@ -325,7 +329,14 @@ declare const __VLS_self: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
325
329
|
column: CurdConfigColumn[];
|
|
326
330
|
};
|
|
327
331
|
};
|
|
332
|
+
/**
|
|
333
|
+
* 类型
|
|
334
|
+
*/
|
|
335
|
+
type: {
|
|
336
|
+
default: string;
|
|
337
|
+
};
|
|
328
338
|
}>> & Readonly<{}>, {
|
|
339
|
+
type: string;
|
|
329
340
|
option: {
|
|
330
341
|
form?: {
|
|
331
342
|
maxSpan?: number;
|
|
@@ -347,14 +358,17 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
|
|
|
347
358
|
column: CurdConfigColumn[];
|
|
348
359
|
};
|
|
349
360
|
};
|
|
361
|
+
/**
|
|
362
|
+
* 类型
|
|
363
|
+
*/
|
|
364
|
+
type: {
|
|
365
|
+
default: string;
|
|
366
|
+
};
|
|
350
367
|
}>, {
|
|
351
368
|
ref: import("vue").Ref<FormInstance | undefined, FormInstance | undefined>;
|
|
352
369
|
conf: {
|
|
353
370
|
rules: any;
|
|
354
371
|
show: boolean;
|
|
355
|
-
showContent: boolean;
|
|
356
|
-
loading: boolean;
|
|
357
|
-
type: any;
|
|
358
372
|
form: any;
|
|
359
373
|
formDefault: any;
|
|
360
374
|
formColumn: {
|
|
@@ -423,6 +437,7 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
|
|
|
423
437
|
}[][];
|
|
424
438
|
getDisabled: (item: CurdConfigColumn) => boolean | undefined;
|
|
425
439
|
initColumnForm: () => void;
|
|
440
|
+
init: () => Promise<void>;
|
|
426
441
|
};
|
|
427
442
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
428
443
|
/**
|
|
@@ -437,7 +452,14 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
|
|
|
437
452
|
column: CurdConfigColumn[];
|
|
438
453
|
};
|
|
439
454
|
};
|
|
455
|
+
/**
|
|
456
|
+
* 类型
|
|
457
|
+
*/
|
|
458
|
+
type: {
|
|
459
|
+
default: string;
|
|
460
|
+
};
|
|
440
461
|
}>> & Readonly<{}>, {
|
|
462
|
+
type: string;
|
|
441
463
|
option: {
|
|
442
464
|
form?: {
|
|
443
465
|
maxSpan?: number;
|