UNPKG

@form-create/tdesign

Version:

TDesign 版本低代码表单 | FormCreate 是一个可以通过 JSON 生成具有动态渲染、数据收集、验证和提交功能的低代码表单生成组件。

14 lines (13 loc) 122 kB
/*! * FormCreate 低代码表单渲染器 * @form-create/tdesign v3.3.0 * (c) 2018-2026 xaboy * Github https://github.com/xaboy/form-create * Site https://form-create.com/ * Released under the MIT License. */ (function(){"use strict";try{if(typeof document!="undefined"){var r=document.createElement("style");r.appendChild(document.createTextNode('._fc-frame ._fc-files img{width:100%;height:100%;display:inline-block;vertical-align:top}._fc-frame ._fc-upload-cover{opacity:0;position:absolute;inset:0;background:#0009;transition:opacity .3s}._fc-frame ._fc-upload-cover ._fc-frame-icon{color:#fff;font-size:20px;margin:0 2px}._fc-frame ._fc-files:hover ._fc-upload-cover{opacity:1}._fc-frame .t-upload{display:block}._fc-frame ._fc-upload-btn,._fc-frame ._fc-frame-icon{cursor:pointer;font-size:20px;width:20px}._fc-frame._fc-disabled ._fc-upload-btn,._fc-frame._fc-disabled ._fc-frame-icon{cursor:not-allowed!important;color:#999}._fc-frame .t-input-adornment__append ._fc-frame-icon{margin:5px 12px 0}._fc-frame ._fc-upload-btn,._fc-files{display:inline-block;width:112px;height:112px;text-align:center;line-height:112px;border:1px solid #c0ccda;overflow:hidden;background:#fff;position:relative;box-shadow:2px 2px 5px #0000001a;margin-right:4px;box-sizing:border-box}._fc-group{display:flex;min-height:38px;justify-content:center;flex-direction:column;width:100%}._fc-group-disabled ._fc-group-btn,._fc-group-disabled ._fc-group-add{cursor:not-allowed}._fc-group-handle{display:flex;flex-direction:row;position:absolute;bottom:-15px;right:30px;border-radius:15px;border:1px dashed #d9d9d9;padding:3px 8px;background-color:#fff}._fc-group-btn{cursor:pointer}._fc-group-idx{position:absolute;bottom:-15px;left:10px;width:30px;height:30px;display:flex;align-items:center;justify-content:center;background:#eee;border-radius:15px;font-weight:700}._fc-group-handle ._fc-group-btn+._fc-group-btn{margin-left:7px}._fc-group-container{position:relative;display:flex;flex-direction:column;border:1px dashed #d9d9d9;border-radius:5px;margin:5px 5px 25px;padding:20px 20px 25px}._fc-group-arrow{position:relative;width:20px;height:20px}._fc-group-arrow:before{content:"";position:absolute;top:8px;left:5px;width:9px;height:9px;border-left:2px solid #999;border-top:2px solid #999}._fc-group-arrow:before{transform:rotate(45deg)}._fc-group-arrow._fc-group-down{transform:rotate(180deg)}._fc-group-plus-minus{width:20px;height:20px;position:relative;cursor:pointer}._fc-group-plus-minus:before,._fc-group-plus-minus:after{content:"";position:absolute;top:50%;left:50%;width:60%;height:2px;background-color:#409eff;transform:translate(-50%,-50%)}._fc-group-plus-minus:before{transform:translate(-50%,-50%) rotate(90deg)}._fc-group-plus-minus._fc-group-minus:before{display:none}._fc-group-plus-minus._fc-group-minus:after{background-color:#f56c6c}._fc-group-add{cursor:pointer;width:25px;height:25px;border:1px solid rgb(64 158 255 / 50%);border-radius:15px}._fc-group-add._fc-group-plus-minus:before,._fc-group-add._fc-group-plus-minus:after{width:50%}._fc-group._fc-group-card{display:flex;flex-direction:column;width:100%;gap:16px}._fc-group._fc-group-card._fc-group-disabled ._fc-group-btn,._fc-group._fc-group-card._fc-group-disabled ._fc-group-add{cursor:not-allowed;opacity:.5}._fc-group._fc-group-card ._fc-group-container{position:relative;background:#fff;border:1px solid #f0f0f0;border-radius:6px;overflow:hidden;display:flex;flex-direction:column;padding:0;margin:0}._fc-group._fc-group-card ._fc-group-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px 12px;border-bottom:1px solid #f0f0f0;background:#fafafa}._fc-group._fc-group-card ._fc-group-idx{display:flex;align-items:center;justify-content:center;width:24px;height:24px;background:#f0f0f0;color:#666;border-radius:6px;font-size:12px;font-weight:500;margin-right:12px;flex-shrink:0;position:static;border:1px solid #e0e0e0}._fc-group._fc-group-card ._fc-group-title{flex:1;font-size:14px;font-weight:500;color:#000000d9;line-height:1.5715}._fc-group._fc-group-card ._fc-group-handle{display:flex;align-items:center;gap:4px;margin-left:12px;flex-shrink:0;position:static;bottom:auto;right:auto;border-radius:0;border:none;padding:0;background-color:transparent;flex-direction:row}._fc-group._fc-group-card ._fc-group-btn{cursor:pointer;display:flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:4px;border:1px solid #d9d9d9;background:#fff;color:#00000073;position:relative}._fc-group._fc-group-card ._fc-group-btn:hover{color:#1890ff;border-color:#1890ff;background:#f0f8ff}._fc-group._fc-group-card ._fc-group-btn:active{color:#096dd9;border-color:#096dd9}._fc-group._fc-group-card ._fc-group-arrow{position:relative}._fc-group._fc-group-card ._fc-group-arrow:before{content:"";position:absolute;top:50%;left:50%;width:5px;height:5px;border-left:1px solid currentColor;border-top:1px solid currentColor;transform:translate(-50%,-50%) rotate(45deg)}._fc-group._fc-group-card ._fc-group-arrow._fc-group-down{transform:rotate(180deg)}._fc-group._fc-group-card ._fc-group-sort{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;height:24px}._fc-group._fc-group-card ._fc-group-sort:before,._fc-group._fc-group-card ._fc-group-sort:after{content:"";position:absolute;left:50%;width:4px;height:4px;border-left:1px solid currentColor;border-top:1px solid currentColor;transform:translate(-50%)}._fc-group._fc-group-card ._fc-group-sort:before{top:6px;transform:translate(-50%) rotate(45deg)}._fc-group._fc-group-card ._fc-group-sort:after{bottom:6px;transform:translate(-50%) rotate(225deg)}._fc-group._fc-group-card ._fc-group-sort-up,._fc-group._fc-group-card ._fc-group-sort-down{position:absolute;left:0;right:0;height:12px;cursor:pointer;z-index:1}._fc-group._fc-group-card ._fc-group-sort-up{top:0}._fc-group._fc-group-card ._fc-group-sort-down{bottom:0}._fc-group._fc-group-card ._fc-group-sort-up:hover,._fc-group._fc-group-card ._fc-group-sort-down:hover{background:#1890ff1a}._fc-group._fc-group-card ._fc-group-plus-minus{position:relative;background:#409eff;border-color:#409eff;color:#fff;width:24px;height:24px}._fc-group._fc-group-card ._fc-group-plus-minus:hover{background:#66b1ff;border-color:#66b1ff;color:#fff}._fc-group._fc-group-card ._fc-group-plus-minus:before,._fc-group._fc-group-card ._fc-group-plus-minus:after{content:"";position:absolute;top:50%;left:50%;width:8px;height:1px;background-color:currentColor;transform:translate(-50%,-50%)}._fc-group._fc-group-card ._fc-group-plus-minus:before{transform:translate(-50%,-50%) rotate(90deg)}._fc-group._fc-group-card ._fc-group-plus-minus._fc-group-minus{background:#f56c6c;border-color:#f56c6c}._fc-group._fc-group-card ._fc-group-plus-minus._fc-group-minus:hover{background:#f78989;border-color:#f78989}._fc-group._fc-group-card ._fc-group-plus-minus._fc-group-minus:before{display:none}._fc-group._fc-group-card ._fc-group-content{padding:20px}._fc-group._fc-group-card ._fc-group-add{cursor:pointer;display:flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:4px;border:1px solid #d9d9d9;background:#fff;color:#00000073;position:relative}._fc-group._fc-group-card ._fc-group-add:hover{color:#409eff;border-color:#409eff;background:#f0f8ff}._fc-group._fc-group-card ._fc-group-add._fc-group-plus-minus{width:24px;height:24px;background:#409eff;border-color:#409eff;color:#fff}._fc-group._fc-group-card ._fc-group-add._fc-group-plus-minus:hover{background:#66b1ff;border-color:#66b1ff;color:#fff}._fc-group._fc-group-card ._fc-group-add._fc-group-plus-minus:before,._fc-group._fc-group-card ._fc-group-add._fc-group-plus-minus:after{content:"";position:absolute;top:50%;left:50%;width:8px;height:1px;background-color:currentColor;transform:translate(-50%,-50%)}._fc-group._fc-group-card ._fc-group-add._fc-group-plus-minus:before{transform:translate(-50%,-50%) rotate(90deg)}._fc-group._fc-group-card ._fc-group-empty{text-align:center;padding:40px 20px;color:#00000073;font-size:14px}@media (max-width: 768px){._fc-group._fc-group-card ._fc-group-container{margin:0 -8px;border-radius:0;border-left:none;border-right:none}._fc-group._fc-group-card ._fc-group-header{padding:12px 16px 8px}._fc-group._fc-group-card ._fc-group-content{padding:16px}._fc-group._fc-group-card ._fc-group-handle{gap:2px}._fc-group._fc-group-card ._fc-group-btn{width:22px;height:22px}}.form-create{width:100%}.form-create .t-tree .t-tree__icon{line-height:inherit}.form-create.t-form:not(.t-form-inline) .t-form__item:last-of-type{margin-bottom:24px}.form-create .form-create .t-is-error .t-input__extra{color:var(--td-error-color)}.form-create .form-create .t-is-warning .t-input__extra{color:var(--td-warning-color)}.form-create.is-preview .fc-clock,.form-create .fc-none,.form-create.is-preview .t-form__label--required>label:before{display:none!important}.fc-form-footer{margin-top:12px}')),document.head.appendChild(r)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})(); (function(P,f){typeof exports=="object"&&typeof module!="undefined"?f(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],f):(P=typeof globalThis!="undefined"?globalThis:P||self,f(P.formCreate={},P.Vue))})(this,function(P,f){"use strict";var In=Object.defineProperty,Nn=Object.defineProperties;var Tn=Object.getOwnPropertyDescriptors;var Tt=Object.getOwnPropertySymbols;var Bn=Object.prototype.hasOwnProperty,Ln=Object.prototype.propertyIsEnumerable;var Bt=(P,f,D)=>f in P?In(P,f,{enumerable:!0,configurable:!0,writable:!0,value:D}):P[f]=D,C=(P,f)=>{for(var D in f||(f={}))Bn.call(f,D)&&Bt(P,D,f[D]);if(Tt)for(var D of Tt(f))Ln.call(f,D)&&Bt(P,D,f[D]);return P},U=(P,f)=>Nn(P,Tn(f));function D(t){return Array.isArray(t)?t:[null,void 0,""].indexOf(t)>-1?[]:[t]}function Xe(t){t=t||new Map;const e={$on(r,n){const s=t.get(r);s&&s.push(n)||t.set(r,[n])},$once(r,n){n._once=!0,e.$on(r,n)},$off(r,n){const s=t.get(r);s&&s.splice(s.indexOf(n)>>>0,1)},$emit(r,...n){(t.get(r)||[]).slice().map(s=>{s._once&&(e.$off(r,s),delete s._once),s(...n)}),(t.get("*")||[]).slice().map(s=>{s(r,n)})}};return e}const $e=(t,e)=>{const r=t.__vccOpts||t;for(const[n,s]of e)r[n]=s;return r},Lt={name:"IconFolder"},Mt={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"};function Ut(t,e,r,n,s,i){return f.openBlock(),f.createElementBlock("svg",Mt,[...e[0]||(e[0]=[f.createElementVNode("path",{d:"M26 20h-2v4h-4v2h4v4h2v-4h4v-2h-4z",fill:"currentColor"},null,-1),f.createElementVNode("path",{d:"M28 8H16l-3.4-3.4c-.4-.4-.9-.6-1.4-.6H4c-1.1 0-2 .9-2 2v20c0 1.1.9 2 2 2h14v-2H4V6h7.2l3.4 3.4l.6.6H28v8h2v-8c0-1.1-.9-2-2-2z",fill:"currentColor"},null,-1)])])}const qt=$e(Lt,[["render",Ut]]),xt=f.defineComponent({name:"IconFile",render(){return f.h("svg",{style:{width:"20px",fontSize:"20px"},viewBox:"0 0 24 24",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},f.h("g",{fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},f.h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),f.h("path",{d:"M17 21H7a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7l5 5v11a2 2 0 0 1-2 2z"})))}}),Ht={name:"DeleteOutlined"},Gt={height:"1em",width:"1em",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"};function zt(t,e,r,n,s,i){return f.openBlock(),f.createElementBlock("svg",Gt,[...e[0]||(e[0]=[f.createElementVNode("path",{d:"M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z",fill:"currentColor"},null,-1)])])}const Jt=$e(Ht,[["render",zt]]),Wt={name:"EyeOutlined"},Kt={height:"1em",width:"1em",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"};function Xt(t,e,r,n,s,i){return f.openBlock(),f.createElementBlock("svg",Kt,[...e[0]||(e[0]=[f.createElementVNode("path",{d:"M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3a60.3 60.3 0 0 0 0 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3c7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766zm-4-430c-97.2 0-176 78.8-176 176s78.8 176 176 176s176-78.8 176-176s-78.8-176-176-176zm0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112s112 50.1 112 112s-50.1 112-112 112z",fill:"currentColor"},null,-1)])])}const Qt=$e(Wt,[["render",Xt]]),Zt=f.defineComponent({name:"fcFrame",props:{type:{type:String,default:"input"},field:String,helper:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},src:{type:String,required:!0},icon:{type:String,default:"icon-folder"},width:{type:[Number,String],default:"500px"},height:{type:[Number,String],default:"370px"},maxLength:{type:Number,default:0},okBtnText:{type:String,default:""},closeBtnText:{type:String,default:""},modalTitle:String,handleIcon:{type:[String,Boolean],default:void 0},title:String,allowRemove:{type:Boolean,default:!0},onOpen:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}},onCancel:{type:Function,default:()=>{}},onLoad:{type:Function,default:()=>{}},onBeforeRemove:{type:Function,default:()=>{}},onRemove:{type:Function,default:()=>{}},onHandle:Function,modal:{type:Object,default:()=>({})},srcKey:[String,Number],modelValue:[Array,String,Number,Object],previewMask:void 0,footer:{type:Boolean,default:!0},reload:{type:Boolean,default:!0},closeBtn:{type:Boolean,default:!0},okBtn:{type:Boolean,default:!0},formCreateInject:Object},emits:["update:modelValue","change"],components:{IconFolder:qt,EyeOutlined:Qt},data(){return{fileList:D(this.modelValue),previewVisible:!1,frameVisible:!1,previewImage:"",bus:new Xe}},watch:{modelValue(t){this.fileList=D(t)}},methods:{key(t){return t},close(){this.closeModal(!0)},closeModal(t){this.bus.$emit(t?"$close":"$ok"),this.reload&&(this.bus.$off("$ok"),this.bus.$off("$close")),this.frameVisible=!1},handleCancel(){this.previewVisible=!1},showModal(){this.disabled||this.onOpen()===!1||(this.frameVisible=!0)},input(){const t=this.fileList,e=this.maxLength===1?t[0]||"":t;this.$emit("update:modelValue",e),this.$emit("change",e)},makeInput(){const t=f.resolveComponent(this.icon);return f.createVNode(f.resolveComponent("t-input-adornment"),{append:()=>f.createVNode(t,{onClick:this.showModal,class:"_fc-frame-icon"},null)},{default:()=>[f.createVNode(f.resolveComponent("TInput"),{readonly:!0,clearable:!this.disabled,showClearIconOnEmpty:!this.disabled,value:this.fileList.map(e=>this.getSrc(e)).toString(),onClear:()=>{this.fileList=[],this.input()},key:1},null)]})},makeGroup(t){return(!this.maxLength||this.fileList.length<this.maxLength)&&t.push(this.makeBtn()),f.createVNode("div",{key:2},[t])},makeItem(t,e){return f.createVNode("div",{class:"_fc-files",key:"3"+t},[e])},valid(t){const e=this.formCreateInject.field||this.field;if(e&&t!==e)throw new Error("[frame]无效的字段值")},makeIcons(t,e){if(this.handleIcon!==!1||this.allowRemove===!0){const r=[];return(this.type!=="file"&&this.handleIcon!==!1||this.type==="file"&&this.handleIcon)&&r.push(this.makeHandleIcon(t,e)),this.allowRemove&&r.push(this.makeRemoveIcon(t,e)),f.createVNode("div",{class:"_fc-upload-cover",key:4},[r])}},makeHandleIcon(t,e){const r=f.resolveComponent(this.handleIcon===!0||this.handleIcon===void 0?"EyeOutlined":this.handleIcon);return f.createVNode(r,{class:"_fc-frame-icon",onClick:()=>this.handleClick(t),key:"5"+e},null)},makeRemoveIcon(t,e){return f.createVNode(Jt,{class:"_fc-frame-icon",onClick:()=>this.handleRemove(t),key:"6"+e},null)},makeFiles(){return this.makeGroup(this.fileList.map((t,e)=>this.makeItem(e,[f.createVNode(xt,{size:"20",onClick:()=>this.handleClick(t)},null),this.makeIcons(t,e)])))},makeImages(){return this.makeGroup(this.fileList.map((t,e)=>this.makeItem(e,[f.createVNode("img",{src:this.getSrc(t)},null),this.makeIcons(t,e)])))},makeBtn(){const t=f.resolveComponent(this.icon);return f.createVNode("div",{class:"_fc-upload-btn",onClick:()=>this.showModal(),key:7},[f.createVNode(t,{class:"_fc-frame-icon"},null)])},handleClick(t){if(this.onHandle)return this.onHandle(t);this.previewImage=this.getSrc(t),this.previewVisible=!0},handleRemove(t){this.disabled||this.onBeforeRemove(t)!==!1&&(this.fileList.splice(this.fileList.indexOf(t),1),this.input(),this.onRemove(t))},getSrc(t){return this.srcKey?t[this.srcKey]:t},frameLoad(t){this.onLoad(t);try{this.helper===!0&&(t.form_create_helper={api:this.formCreateInject.api,close:e=>{this.valid(e),this.closeModal()},set:(e,r)=>{this.valid(e),this.disabled||(this.$emit("update:modelValue",r),this.$emit("change",r))},get:e=>(this.valid(e),this.modelValue),onOk:e=>this.bus.$on("$ok",e),onClose:e=>this.bus.$on("$close",e)})}catch(e){console.error(e)}},makeFooter(){const{okBtnText:t,closeBtnText:e,closeBtn:r,okBtn:n,footer:s}=this.$props,i=[];return s&&(r&&i.push(f.createVNode(f.resolveComponent("TButton"),{onClick:()=>this.onCancel()!==!1&&this.closeModal(!0)},{default:()=>[e||this.formCreateInject.t("close")||"关闭"]})),n&&i.push(f.createVNode(f.resolveComponent("TButton"),{theme:"primary",onClick:()=>this.onOk()!==!1&&this.closeModal()},{default:()=>[t||this.formCreateInject.t("ok")||"确定"]}))),i}},render(){const t=this.type;let e;t==="input"?e=this.makeInput():t==="image"?e=this.makeImages():e=this.makeFiles();const{width:r="30%",height:n,src:s,title:i,modalTitle:o}=this.$props;return f.nextTick(()=>{this.$refs.frame&&this.frameLoad(this.$refs.frame.contentWindow||{})}),f.createVNode("div",{class:{"_fc-frame":!0,"_fc-disabled":this.disabled}},[e,f.createVNode(f.resolveComponent("TDialog"),{mask:this.previewMask,header:o,visible:this.previewVisible,style:"width: 600px;",attach:"body","onUpdate:visible":a=>this.previewVisible=a,footer:!1},{default:()=>[f.createVNode("img",{style:"width: 100%",src:this.previewImage,key:1},null)]}),f.createVNode(f.resolveComponent("TDialog"),f.mergeProps(C({width:r,header:i},this.modal),{visible:this.frameVisible,attach:"body",style:{width:r},onClose:()=>this.frameVisible=!1,onConfirm:()=>this.closeModal(!0),key:2}),{default:()=>[this.frameVisible||!this.reload?f.createVNode("iframe",{ref:"frame",src:s,frameborder:"0",style:{height:n,border:"0 none",width:"100%"}},null):null],action:()=>this.makeFooter()})])},beforeMount(){const{name:t,field:e,api:r}=this.formCreateInject;t&&r.on("fc:closeModal:"+t,this.close),e&&r.on("fc:closeModal:"+e,this.close)},beforeUnmount(){const{name:t,field:e,api:r}=this.formCreateInject;t&&r.off("fc:closeModal:"+t,this.close),e&&r.off("fc:closeModal:"+e,this.close)}}),Yt="fcUpload";function Qe(t,e){return typeof t=="object"?t:{url:t,is_string:!0,name:er(t),status:"success",uid:e}}function Ze(t){return U(C({},t),{file:t,value:t})}function er(t){return(""+t).split("/").pop()}const tr=f.defineComponent({name:Yt,inheritAttrs:!1,formCreateParser:{toFormValue(t){return D(t)},toValue(t,e){return e.prop.props.limit===1?t[0]||"":t}},props:{limit:{type:Number,default:0},formCreateInject:Object,modelValue:{type:[Array,String,Object],default:[]},onSuccess:{type:Function},onRemove:{type:Function},name:String,requestMethod:Function},emits:["update:modelValue","fc.el"],data(){return{uploadList:D(this.modelValue).map(Qe).map(Ze)}},watch:{modelValue(t){this.uploadList=D(t).map(Qe).map(Ze)}},methods:{handleRemove({index:t}){this.uploadList.splice(t,1),this.onRemove&&this.onRemove(...arguments),this.input()},handleSuccess({file:t,fileList:e}){this.uploadList=e,t.status==="success"&&this.onSuccess&&this.onSuccess(...arguments),this.input()},input(){this.$emit("update:modelValue",this.uploadList.map(t=>t.is_string?t.url:t.value||t.url).filter(t=>t!==void 0))},doRequestMethod(t){const e=this.requestMethod;if(e)return e(t);const r=Array.isArray(t)?t[0]:t,n=(r==null?void 0:r.raw)||(r==null?void 0:r.file)||r;return new Promise((s,i)=>{var a;const o={method:((a=this.$attrs)==null?void 0:a.method)||"post",file:n,filename:this.name||"file",source:"upload",onSuccess:l=>s({status:"success",response:l}),onError:l=>i(l)};this.formCreateInject.api.fetch(o)})}},render(){const{uploadList:t,handleSuccess:e,handleRemove:r,$slots:n}=this;return f.createVNode(f.Fragment,null,[f.createVNode(f.resolveComponent("t-upload"),f.mergeProps({max:this.limit,theme:"image",accept:"image/*",modelValue:t,name:this.name},this.$attrs,{requestMethod:this.doRequestMethod,onSuccess:e,onRemove:r,ref:"el"}),n)])},mounted(){this.$emit("fc.el",this.$refs.el)}}),g={type(t,e){return Object.prototype.toString.call(t)==="[object "+e+"]"},Undef(t){return t==null},Element(t){return typeof t=="object"&&t!==null&&t.nodeType===1&&!g.Object(t)},trueArray(t){return Array.isArray(t)&&t.length>0},Function(t){const e=this.getType(t);return e==="Function"||e==="AsyncFunction"},getType(t){const e=Object.prototype.toString.call(t);return/^\[object (.*)\]$/.exec(e)[1]},empty(t){return t==null||Array.isArray(t)&&Array.isArray(t)&&!t.length?!0:typeof t=="string"&&!t}};["Date","Object","String","Boolean","Array","Number"].forEach(t=>{g[t]=function(e){return g.type(e,t)}});function E(t,e){return{}.hasOwnProperty.call(t,e)}function q(t,e,r){t[e]=r}function se(t,e){delete t[e]}function he(t,e={},r){let n=!1;for(let s in e)if(Object.prototype.hasOwnProperty.call(e,s)){let i=e[s];if((n=Array.isArray(i))||g.Object(i)){let o=t[s]===void 0;if(n)n=!1,o&&q(t,s,[]);else if(i._clone&&r!==void 0)if(r)i=i.getRule(),o&&q(t,s,{});else{q(t,s,i._clone());continue}else o&&q(t,s,{});t[s]=he(t[s],i,r)}else q(t,s,i),g.Undef(i)||(g.Undef(i.__json)||(t[s].__json=i.__json),g.Undef(i.__origin)||(t[s].__origin=i.__origin))}return r!==void 0&&Array.isArray(t)?t.filter(s=>!s||!s.__ctrl):t}function G(t){return he({},{value:t}).value}const rr=Object.assign||function(t){for(let e,r=1;r<arguments.length;r++)for(let n in e=arguments[r],e)Object.prototype.hasOwnProperty.call(e,n)&&q(t,n,e[n]);return t};function S(){return rr.apply(this,arguments)}function Ee(t){return typeof t!="object"||t===null?t:t instanceof Array?[...t]:C({},t)}function Y(t,e){var r=null;return function(...n){r!==null&&clearTimeout(r),r=setTimeout(()=>t.call(this,...n),e)}}function Ye(t){return t==null?"":typeof t=="object"?JSON.stringify(t,null,2):String(t)}function nr(t){return t&&typeof t=="object"&&typeof t.then=="function"}function _e(t){return nr(t)?t:Promise.resolve(t)}function pe(t){let e=t.replace(/([A-Z])/g,"-$1").toLocaleLowerCase();return e.indexOf("-")===0&&(e=e.substr(1)),e}function et(t){return t.replace(t[0],t[0].toLocaleUpperCase())}function tt(t,e,r){return`[form-create ${t}]: ${e}`}function De(t,e){console.error(tt("err",t))}function ir(t){De(t.toString()),console.error(t)}const je="[[FORM-CREATE-PREFIX-",Ae="-FORM-CREATE-SUFFIX]]";function me(t,e){return JSON.stringify(he(Array.isArray(t)?[]:{},t,!0),function(r,n){if(!(n&&n._isVue===!0)){if(typeof n!="function")return n;if(n.__json)return n.__json;if(n.__origin&&(n=n.__origin),!n.__emit)return je+n+Ae}},e)}function Pe(t){return new Function("return "+t)()}function z(t,e){if(t&&g.String(t)&&t.length>4){let r=t.trim(),n=!1;try{if(r.indexOf(Ae)>0&&r.indexOf(je)===0)r=r.replace(Ae,"").replace(je,""),n=!0;else if(r.indexOf("$FN:")===0)r=r.substring(4),n=!0;else if(r.indexOf("$EXEC:")===0)r=r.substring(6),n=!0;else if(r.indexOf("$GLOBAL:")===0){const i=r.substring(8);return r=function(...o){const a=o[0].api.getGlobalEvent(i);if(a)return a.call(this,...o)},r.__json=t,r.__inject=!0,r}else{if(r.indexOf("$FNX:")===0)return r=Pe(`function($inject){ `+r.substring(5)+` }`),r.__json=t,r.__inject=!0,r;(!e&&r.indexOf("function ")===0&&r!=="function "||!e&&r.indexOf("function(")===0&&r!=="function(")&&(n=!0)}if(!n)return t;let s;try{s=Pe(r)}catch(i){s=Pe("function "+r)}return s.__json=t,s}catch(s){De(`解析失败:${r} err: ${s}`);return}}return t}function rt(t,e){return JSON.parse(t,function(r,n){return g.Undef(n)||!n.indexOf?n:z(n,e)})}let sr=0;function Ce(){const t=370+ ++sr;return"F"+Math.random().toString(36).substr(3,3)+(+`${Date.now()}`).toString(36)+t.toString(36)+"c"}function ee(t,e,r){let n=t,s;return(e||"").split(".").forEach(i=>{s&&((!n[s]||typeof n[s]!="object")&&(n[s]={}),n=n[s]),s=i}),n[s]=r,n}const or=f.defineComponent({name:"fcGroup",props:{field:String,rule:Array,expand:Number,options:Object,button:{type:Boolean,default:!0},max:{type:Number,default:0},min:{type:Number,default:0},modelValue:{type:Array,default:()=>[]},defaultValue:Object,sortBtn:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},syncDisabled:{type:Boolean,default:!0},title:{type:[String,Function],default:null},type:{type:String,default:"default"},onBeforeRemove:{type:Function,default:()=>{}},onBeforeAdd:{type:Function,default:()=>{}},formCreateInject:Object,parse:Function},data(){return{len:0,cacheRule:{},cacheValue:{},sort:[],form:f.markRaw(this.formCreateInject.form.$form())}},emits:["update:modelValue","change","itemMounted","remove","add"],watch:{rule:{handler(t,e){Object.keys(this.cacheRule).forEach(r=>{const n=this.cacheRule[r];if(n.$f){const s=n.$f.formData();if(t===e)n.$f.deferSyncValue(()=>{he(n.rule,t),n.$f.setValue(s)},!0);else{const i=n.$f.formData();n.$f.once("reloading",()=>{n.$f.setValue(i)}),n.rule=G(t)}}})},deep:!0},expand(t){let e=t-this.modelValue.length;e>0&&this.expandRule(e)},modelValue:{handler(t){t=t||[];let e=this.sort,r=e.length,n=r-t.length;if(n<0){for(let s=n;s<0;s++)this.addRule(t.length+s,!0);for(let s=0;s<r;s++)this.setValue(e[s],t[s])}else{if(n>0)for(let s=0;s<n;s++)this.removeRule(e[r-s-1]);t.forEach((s,i)=>{this.setValue(e[i],t[i])})}},deep:!0}},methods:{_value(t){return t&&E(t,this.field)?t[this.field]:t},cache(t,e){this.cacheValue[t]=JSON.stringify(e)},input(t){this.$emit("update:modelValue",t),this.$emit("change",t)},formData(t,e){const r=this.cacheRule,n=this.sort;if(n.filter(i=>r[i]&&r[i].$f).length!==n.length)return;const s=n.map(i=>{const o=t===i?e:C({},this.cacheRule[i].$f.form),a=this.field?g.Undef(o[this.field])?null:o[this.field]:o;return this.cache(i,a),a});this.input(s)},setValue(t,e){const r=this.field;r&&(e={[r]:this._value(e)}),this.cacheValue[t]!==JSON.stringify(r?e[r]:e)&&(this.cacheRule[t].$f&&this.cacheRule[t].$f.coverValue(e),this.cache(t,e))},addRule(t,e){const r=this.formCreateInject.form.copyRules(this.rule||[]),n=this.options?C({},this.options):{submitBtn:!1,resetBtn:!1};if(this.defaultValue){n.formData||(n.formData={});const s=G(this.defaultValue);S(n.formData,this.field?{[this.field]:s}:s)}this.parse&&this.parse({rule:r,options:n,index:this.sort.length}),this.cacheRule[++this.len]={rule:r,options:n},this.sort=Object.keys(this.cacheRule),e&&f.nextTick(()=>this.$emit("add",r,Object.keys(this.cacheRule).length-1))},add$f(t,e,r){this.cacheRule[e].$f=r,f.nextTick(()=>{this.$emit("itemMounted",r,Object.keys(this.cacheRule).indexOf(e))})},removeRule(t,e){const r=Object.keys(this.cacheRule).indexOf(t);delete this.cacheRule[t],delete this.cacheValue[t],this.sort=Object.keys(this.cacheRule),e&&f.nextTick(()=>this.$emit("remove",r))},add(t){if(this.disabled||this.onBeforeAdd(this.modelValue)===!1)return;const e=[...this.modelValue];e.push(this.defaultValue?G(this.defaultValue):this.field?null:{}),this.input(e)},del(t,e){if(this.disabled)return;const r=()=>{this.removeRule(e,!0);const n=[...this.modelValue];n.splice(t,1),this.input(n)};_e(this.onBeforeRemove(this.modelValue,t)).then(n=>{n!==!1&&r()})},addIcon(t){return f.createVNode("div",{class:"_fc-group-btn _fc-group-plus-minus",onClick:this.add},null)},delIcon(t,e){return f.createVNode("div",{class:"_fc-group-btn _fc-group-plus-minus _fc-group-minus",onClick:()=>this.del(t,e)},null)},sortUpIcon(t){return f.createVNode("div",{class:"_fc-group-btn _fc-group-arrow _fc-group-up",onClick:()=>this.changeSort(t,-1)},null)},sortDownIcon(t){return f.createVNode("div",{class:"_fc-group-btn _fc-group-arrow _fc-group-down",onClick:()=>this.changeSort(t,1)},null)},changeSort(t,e){const r=this.sort[t];this.sort[t]=this.sort[t+e],this.sort[t+e]=r,this.formCreateInject.subForm(this.sort.map(n=>this.cacheRule[n].$f)),this.formData(0)},sortIcon(t,e){const r=t>0,n=t<e-1,s=[];return!r&&!n?s:this.type==="card"&&r&&n?(s.push(f.createVNode("div",{class:"_fc-group-btn _fc-group-sort"},[f.createVNode("div",{class:" _fc-group-sort-up",onClick:()=>this.changeSort(t,-1)},null),f.createVNode("div",{class:" _fc-group-sort-down",onClick:()=>this.changeSort(t,1)},null)])),s):(r&&s.push(this.sortUpIcon(t)),n&&s.push(this.sortDownIcon(t)),s)},makeIcon(t,e,r){if(this.$slots.button)return this.$slots.button({total:t,index:e,vm:this,key:r,del:()=>this.del(e,r),add:this.add});const n=[];if((!this.max||t<this.max)&&t===e+1&&n.push(this.addIcon(r)),t>this.min&&n.push(this.delIcon(e,r)),this.sortBtn){const s=this.sortIcon(e,t);s&&n.push(...s)}return n},expandRule(t){for(let e=0;e<t;e++)this.modelValue.push(this.field?null:{});this.input([...this.modelValue])},getTitle(t,e){return typeof this.title=="function"?this.title(t,this.modelValue[t],e):typeof this.title=="string"?this.title.replace("{index}",t+1):!1}},created(){const t=(this.expand||0)-this.modelValue.length;for(let e=0;e<this.modelValue.length;e++)this.addRule(e);t>0&&this.expandRule(t)},render(){const t=this.sort,e=this.button,r=this.form,n=this.disabled,s=this.type==="card",i=t.length===0?this.$slots.default?this.$slots.default({vm:this,add:this.add}):f.createVNode("div",{key:"a_def",class:"_fc-group-plus-minus _fc-group-add fc-clock",onClick:this.add},null):t.map((o,a)=>{const{rule:l,options:u}=this.cacheRule[o],c=e&&!n?this.makeIcon(t.length,a,o):[],p=this.getTitle(a,o);return s?f.createVNode("div",{class:"_fc-group-container",key:o},[f.createVNode("div",{class:"_fc-group-header"},[p===!1?f.createVNode("div",{class:"_fc-group-idx"},[a+1]):null,p!==!1?f.createVNode("div",{class:"_fc-group-title"},[p]):null,f.createVNode("div",{class:"_fc-group-handle fc-clock"},[c.length?c:null])]),f.createVNode("div",{class:"_fc-group-content"},[f.createVNode(r,f.mergeProps({key:o},{disabled:n,"onUpdate:modelValue":h=>this.formData(o,h),"onUpdate:api":h=>this.add$f(a,o,h),inFor:!0,modelValue:this.field?{[this.field]:this._value(this.modelValue[a])}:this.modelValue[a],rule:l,option:u,extendOption:!0}),null)])]):f.createVNode("div",{class:"_fc-group-container",key:o},[f.createVNode(r,f.mergeProps({key:o},{disabled:n,"onUpdate:modelValue":h=>this.formData(o,h),"onUpdate:api":h=>this.add$f(a,o,h),inFor:!0,modelValue:this.field?{[this.field]:this._value(this.modelValue[a])}:this.modelValue[a],rule:l,option:u,extendOption:!0}),null),f.createVNode("div",{class:"_fc-group-idx"},[a+1]),c.length?f.createVNode("div",{class:"_fc-group-handle fc-clock"},[c]):null])});return f.createVNode("div",{key:"con",class:"_fc-group "+(n?"_fc-group-disabled":"")+(s?" _fc-group-card":"")},[i])}}),ar=f.defineComponent({name:"fcSubForm",props:{rule:Array,options:{type:Object,default:()=>f.reactive({submitBtn:!1,resetBtn:!1})},modelValue:{type:Object,default:()=>({})},disabled:{type:Boolean,default:!1},syncDisabled:{type:Boolean,default:!0},formCreateInject:Object},data(){return{cacheValue:{},subApi:{},form:f.markRaw(this.formCreateInject.form.$form())}},emits:["fc:subform","update:modelValue","change","itemMounted"],watch:{modelValue(t){this.setValue(t)}},methods:{formData(t){this.cacheValue=JSON.stringify(t),this.$emit("update:modelValue",t),this.$emit("change",t)},setValue(t){const e=JSON.stringify(t);this.cacheValue!==e&&(this.cacheValue=e,this.subApi.coverValue(t||{}))},add$f(t){this.subApi=t,f.nextTick(()=>{this.$emit("itemMounted",t)})}},render(){const t=this.form;return f.createVNode(t,{disabled:this.disabled,"onUpdate:modelValue":this.formData,modelValue:this.modelValue,"onUpdate:api":this.add$f,rule:this.rule,option:this.options,extendOption:!0},null)}}),lr={name:"QuestionCircleOutlined"},ur={height:"1em",width:"1em",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"};function cr(t,e,r,n,s,i){return f.openBlock(),f.createElementBlock("svg",ur,[...e[0]||(e[0]=[f.createElementVNode("path",{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z",fill:"currentColor"},null,-1),f.createElementVNode("path",{d:"M623.6 316.7C593.6 290.4 554 276 512 276s-81.6 14.5-111.6 40.7C369.2 344 352 380.7 352 420v7.6c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V420c0-44.1 43.1-80 96-80s96 35.9 96 80c0 31.1-22 59.6-56.1 72.7c-21.2 8.1-39.2 22.3-52.1 40.9c-13.1 19-19.9 41.8-19.9 64.9V620c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8v-22.7a48.3 48.3 0 0 1 30.9-44.8c59-22.7 97.1-74.7 97.1-132.5c.1-39.3-17.1-76-48.3-103.3zM472 732a40 40 0 1 0 80 0a40 40 0 1 0-80 0z",fill:"currentColor"},null,-1)])])}const fr=[Zt,tr,or,ar,$e(lr,[["render",cr]])],nt=["props"],it=["class","style","directives"],st=["on","hook"],X=(t,e={},r={})=>{const n=[...nt,...r.normal||[]],s=[...it,...r.array||[]],i=[...st,...r.functional||[]],o=r.props||[];return t.reduce((a,l)=>{for(const u in l)if(a[u])if(o.indexOf(u)>-1)a[u]=X([l[u]],a[u]);else if(n.indexOf(u)>-1)a[u]=C(C({},a[u]),l[u]);else if(s.indexOf(u)>-1){const c=a[u]instanceof Array?a[u]:[a[u]],p=l[u]instanceof Array?l[u]:[l[u]];a[u]=[...c,...p]}else if(i.indexOf(u)>-1)for(const c in l[u])if(a[u][c]){const p=a[u][c]instanceof Array?a[u][c]:[a[u][c]],h=l[u][c]instanceof Array?l[u][c]:[l[u][c]];a[u][c]=[...p,...h]}else a[u][c]=l[u][c];else if(u==="hook")for(let c in l[u])a[u][c]?a[u][c]=dr(a[u][c],l[u][c]):a[u][c]=l[u][c];else a[u]=l[u];else n.indexOf(u)>-1||i.indexOf(u)>-1||o.indexOf(u)>-1?a[u]=C({},l[u]):s.indexOf(u)>-1?a[u]=l[u]instanceof Array?[...l[u]]:typeof l[u]=="object"?C({},l[u]):l[u]:a[u]=l[u];return a},e)},dr=(t,e)=>function(){t&&t.apply(this,arguments),e&&e.apply(this,arguments)},ot=["type","slot","ignore","emitPrefix","value","name","native","hidden","display","inject","options","emit","link","prefix","suffix","update","sync","optionsTo","key","slotUpdate","computed","preview","component","cache","modelEmit"],Ie=["validate","children","control"],Ne=["effect","deep","renderSlots"];function at(){return[...ot,...nt,...it,...st,...Ie,...Ne]}function B(t){const e=t.replace(/(-[a-z])/g,function(r){return r.replace("-","").toLocaleUpperCase()});return lt(e)}function lt(t){return t.replace(t[0],t[0].toLowerCase())}function Te(t,e){return{value:t,enumerable:!1,configurable:!1,writable:!0}}function ut(t,e){return ct([t],e||!1)[0]}function ct(t,e){return he([],[...t],e||!1)}function Q(t,e){return X(Array.isArray(e)?e:[e],t,{array:Ie,normal:Ne}),t}function ft(t){const e=g.Function(t.getRule)?t.getRule():t;return e.type||(e.type="input"),e}function hr(t,e){return t?(Object.keys(e||{}).forEach(r=>{e[r]&&(t[r]=Q(t[r]||{},e[r]))}),t):e}function dt(t,e){Object.defineProperties(t,Object.keys(e).reduce((r,n)=>(r[n]={get(){return e[n]()}},r),{}))}function J(t){return t.__fc__||(t.__origin__?t.__origin__.__fc__:null)}function F(t,e){try{e=t()}catch(r){ir(r)}return e}function we(){const t={},e=r=>r||"default";return{setSlot(r,n){r=e(r),!(!n||Array.isArray(n)&&n.length)&&(t[r]||(t[r]=[]),t[r].push(n))},getSlot(r,n){r=e(r);const s=[];return(t[r]||[]).forEach(i=>{if(Array.isArray(i))s.push(...i);else if(g.Function(i)){const o=i(...n||[]);Array.isArray(o)?s.push(...o):s.push(o)}else g.Undef(i)||s.push(i)}),s},getSlots(){const r={};return Object.keys(t).forEach(n=>{r[n]=(...s)=>this.getSlot(n,s)}),r},slotLen(r){return r=e(r),t[r]?t[r].length:0},mergeBag(r){if(!r)return this;const n=g.Function(r.getSlots)?r.getSlots():r;return Array.isArray(r)||f.isVNode(r)?this.setSlot(void 0,()=>r):Object.keys(n).forEach(s=>{this.setSlot(s,n[s])}),this}}}function ht(t){const e=C({},t.props||{});return Object.keys(t.on||{}).forEach(r=>{r.indexOf("-")>0&&(r=B(r));const n=`on${et(r)}`;Array.isArray(e[n])?e[n]=[...e[n],t.on[r]]:e[n]?e[n]=[e[n],t.on[r]]:e[n]=t.on[r]}),e.key=t.key,e.ref=t.ref,e.class=t.class,e.id=t.id,e.style=t.style,e.slot&&delete e.slot,e}function Se(t,e){return Object.setPrototypeOf(t,e),t}const pt=(t,e)=>typeof t=="string"?String(e):typeof t=="number"?Number(e):e,oe={"==":(t,e)=>JSON.stringify(t)===JSON.stringify(pt(t,e)),"!=":(t,e)=>!oe["=="](t,e),">":(t,e)=>t>e,">=":(t,e)=>t>=e,"<":(t,e)=>t<e,"<=":(t,e)=>t<=e,on(t,e){return t&&t.indexOf&&t.indexOf(pt(t[0],e))>-1},notOn(t,e){return!oe.on(t,e)},in(t,e){return e&&e.indexOf&&e.indexOf(t)>-1},notIn(t,e){return!oe.in(t,e)},between(t,e){return t>e[0]&&t<e[1]},notBetween(t,e){return t<e[0]||t>e[1]},empty(t){return g.empty(t)},notEmpty(t){return!g.empty(t)},pattern(t,e){return new RegExp(e,"g").test(t)}};function N(t,e){return(Array.isArray(e)?e:(e||"").split(".")).forEach(r=>{t!=null&&(t=t[r])}),t}function pr(t){const e=/{{\s*(.*?)\s*}}/g;let r;const n={};for(;(r=e.exec(t))!==null;)r[1]&&(n[r[1]]=!0);return Object.keys(n)}function mt(t){let e=t.split("."),r=[],n="";return e.forEach((s,i)=>{i===0?n=s:n+="."+s,r.push(n)}),r.join(" && ")}function gt(t){const e=[];let r="",n=0;for(let s=0;s<t.length;s++){const i=t[s];i==="["?(n===0&&r&&(e.push({type:"key",value:r}),r=""),n++,r+=i):i==="]"?(n--,r+=i,n===0&&(e.push({type:"bracket",value:gt(r.slice(1,-1))}),r="")):i==="."&&n===0?r&&(e.push({type:"key",value:r}),r=""):r+=i}return r&&e.push({type:"key",value:r}),e.map(s=>s.type==="key"?{key:s.value}:{children:s.value})}const Ve=(t,e)=>{if(!(!t||t===e)){if(t.props.formCreateInject)return t.props.formCreateInject;if(t.parent)return Ve(t.parent,e)}};function mr(t,e,r){return f.defineComponent({name:"FormCreate"+(t.isMobile?"Mobile":""),components:e,directives:r,props:{rule:{type:Array,required:!0,default:()=>[]},option:{type:Object,default:()=>({})},extendOption:Boolean,driver:[String,Object],modelValue:Object,disabled:{type:Boolean,default:void 0},preview:{type:Boolean,default:void 0},index:[String,Number],api:Object,locale:[String,Object],t:Function,name:String,subForm:{type:Boolean,default:!0},inFor:Boolean},emits:["update:api","update:modelValue","mounted","beforeUnmount","submit","reset","change","emit-event","control","remove-rule","remove-field","sync","reload","repeat-field","update","validate-field-fail","validate-fail","created"],render(){return this.fc.render()},setup(n){const s=f.getCurrentInstance();f.provide("parentFC",s);const i=f.inject("parentFC",null);let o=i;if(i)for(;o.setupState.parent;)o=o.setupState.parent;else o=s;const{rule:a,modelValue:l,subForm:u,inFor:c}=f.toRefs(n),p=f.reactive({ctxInject:{},destroyed:!1,isShow:!0,unique:1,renderRule:[...a.value||[]],updateValue:JSON.stringify(l.value||{})}),h=new t(s),m=h.api(),_=c.value,w=()=>{if(i){const R=Ve(s,i);if(R){let j;_?(j=D(R.getSubForm()),j.push(m)):j=m,R.subForm(j)}}},O=()=>{const R=Ve(s,i);if(R)if(_){const j=D(R.getSubForm()),M=j.indexOf(m);M>-1&&j.splice(M,1)}else R.subForm()};let I=null;f.onBeforeMount(()=>{f.watchEffect(()=>{let R="";const j=n.option&&n.option.globalClass||{};Object.keys(j).forEach(M=>{let de="";j[M].style&&Object.keys(j[M].style).forEach(Oe=>{de+=pe(Oe)+":"+j[M].style[Oe]+";"}),j[M].content&&(de+=j[M].content+";"),de&&(R+=`.${M}{${de}}`)}),n.option&&n.option.style&&(R+=n.option.style),I||(I=document.createElement("style"),I.type="text/css",document.head.appendChild(I)),I.innerHTML=R||""})});const L=Y(()=>{h.bus.$emit("$loadData.$topForm")},100),T=Y(function(){h.bus.$emit("$loadData.$scopeForm")},100),Je=Y(()=>{h.bus.$emit("$loadData.$form")},100),Fe=R=>{h.bus.$emit("change-$form."+R)};return f.onMounted(()=>{i&&(m.top.bus.$on("$loadData.$form",L),m.top.bus.$on("change",Fe)),m!==m.scope&&m.scope.bus.$on("$loadData.$scopeForm",T),h.mounted()}),f.onBeforeUnmount(()=>{i&&(m.top.bus.$off("$loadData.$form",L),m.top.bus.$off("change",Fe)),m!==m.scope&&m.scope.bus.$off("$loadData.$scopeForm",T),O(),p.destroyed=!0,h.unmount(),I&&(I.parentNode||I.parentElement)&&document.head.removeChild(I)}),f.onUpdated(()=>{h.updated()}),w(),f.watch(()=>n.option,()=>{h.initOptions(),m.refresh()},{deep:!0,flush:"sync"}),f.watch(()=>[...a.value],R=>{h.$handle.isBreakWatch()||R.length===p.renderRule.length&&R.every(j=>p.renderRule.indexOf(j)>-1)||(h.$handle.updateAppendData(),h.$handle.reloadRule(a.value),s.setupState.renderRule())}),f.watch(()=>[n.disabled,n.preview],()=>{m.refresh()}),f.watch(l,R=>{me(R||{})!==p.updateValue&&(m.config.forceCoverValue?m.coverValue(R||{}):m.setValue(R||{}))},{deep:!0,flush:"post"}),f.watch(()=>n.index,()=>{m.coverValue({}),h.$handle.updateAppendData(),f.nextTick(()=>{f.nextTick(()=>{m.clearValidateState()})})},{flush:"sync"}),U(C({fc:f.markRaw(h),parent:i&&f.markRaw(i),top:f.markRaw(o),fapi:f.markRaw(m)},f.toRefs(p)),{getGroupInject:()=>Ve(s,i),refresh(){++p.unique},renderRule(){p.renderRule=[...a.value||[]]},updateValue(R){if(p.destroyed)return;const j=me(R);p.updateValue!==j&&(p.updateValue=j,s.emit("update:modelValue",R),f.nextTick(()=>{Je(),i?u.value||T():(L(),T())}))}})},created(){const n=f.getCurrentInstance();n.emit("update:api",n.setupState.fapi),n.setupState.fc.init()}})}function yt(){return{props:{},on:{},options:[],children:[],hidden:!1,display:!0,value:void 0}}function x(t,e){return(r,n,s,i={})=>{const o=new Be(t,r,n,s,i);return e&&(g.Function(e)?e(o):o.props(e)),o}}function Be(t,e,r,n,s){this._data=S(yt(),{type:t,title:e,field:r,value:n,props:s||{}}),this.event=this.on}S(Be.prototype,{getRule(){return this._data},setProp(t,e){return q(this._data,t,e),this},modelField(t){return this._data.modelField=t,this},_clone(){const t=new this.constructor;return t._data=ut(this._data),t}});function bt(t){t.forEach(e=>{Be.prototype[e]=function(r){return Q(this._data,{[e]:arguments.length<2?r:{[r]:arguments[1]}}),this}})}bt(at());const gr=x("");function yr(t,e,r){let n=gr("",e);return n._data.type=t,n._data.title=r,n}function br(){return{create:yr,factory:x}}function $r(t,e,r){const n=`fail to ${t} ${r.status}'`,s=new Error(n);return s.status=r.status,s.url=t,s}function $t(t){const e=t.responseText||t.response;if(!e)return e;try{return JSON.parse(e)}catch(r){return e}}function _t(t){if(typeof XMLHttpRequest=="undefined")return;const e=new XMLHttpRequest;let r=t.action||"";if(e.upload&&t.onProgress&&e.upload.addEventListener("progress",i=>{i.percent=i.total>0?i.loaded/i.total*100:0,t.onProgress(i)}),t.query){const i=g.String(t.query)?t.query:Object.keys(t.query).reduce((a,l)=>(a[l]=t.query[l]===null||t.query[l]===void 0?"":t.query[l],a),{}),o=new URLSearchParams(i).toString();o&&(r.includes("?")?r+=`&${o}`:r+=`?${o}`)}e.onerror=function(o){t.onError(o)},e.onload=function(){if(e.status<200||e.status>=300)return t.onError($r(r,t,e),$t(e));t.onSuccess($t(e))},e.open(t.method||"get",r,!0);let n;(t.data||t.file)&&(t.file||(t.dataType||"").toLowerCase()!=="json"?(n=new FormData,Object.keys(t.data||{}).map(i=>{n.append(i,t.data[i])})):(n=JSON.stringify(t.data||{}),e.setRequestHeader("content-type","application/json"))),t.file&&n.append(t.filename,t.file,t.file.name),t.withCredentials&&"withCredentials"in e&&(e.withCredentials=!0);const s=t.headers||{};Object.keys(s).forEach(i=>{s[i]!=null&&e.setRequestHeader(i,s[i])}),e.send(n)}function Ct(t,e,r){return new Promise((n,s)=>{(e||_t)(U(C({},t),{onSuccess(i){let o=l=>l;const a=z(t.parse);g.Function(a)?o=a:a&&g.String(a)&&(o=l=>N(l,a)),_e(o(i,t.targetRule,r)).then(l=>{n(l)})},onError(i){s(i)}}))})}function ge(t){return G(t)}function _r(t){function e(i){return g.Undef(i)?i=t.fields():Array.isArray(i)||(i=[i]),i}function r(i,o,a){g.Undef(i)?i=Object.keys(C(C({},t.fieldCtx),t.nameCtx)):Array.isArray(i)||(i=[i]),i.forEach(l=>{const u=t.fieldCtx[l]||t.nameCtx[l];u&&u.forEach(c=>{q(c.rule,o,a),t.$render.clearCache(c)})})}function n(){const i=t.subForm;return Object.keys(i).reduce((o,a)=>{const l=i[a];return l&&(Array.isArray(l)?o.push(...l):o.push(l)),o},[])}const s={get isScope(){return t.vm.props.subForm===!1},get isPreview(){return t.preview},get config(){return t.options},set config(i){t.fc.options.value=i},get options(){return t.options},set options(i){t.fc.options.value=i},get form(){return t.form},get rule(){return t.rules},get parent(){return t.vm.setupState.parent&&t.vm.setupState.parent.setupState.fapi},get top(){return s.parent?s.parent.top:s},get scope(){let i=t.vm;for(;i&&i.setupState.fapi;)if(i.props.subForm)i=i.setupState.parent;else return i.setupState.fapi;return s.top},get children(){return n()},get siblings(){const i=t.vm.setupState.getGroupInject();if(i){const o=i.getSubForm();if(Array.isArray(o))return[...o]}},get index(){const i=s.siblings;if(i){const o=i.indexOf(s);return o>-1?o:void 0}},get formulas(){return C({},t.fc.formulas)},formData(i){if(i==null||typeof i=="boolean"){const o={};return Object.keys(t.form).forEach(a=>{(i===!0||t.ignoreFields.indexOf(a)===-1)&&(o[a]=ge(t.form[a]))}),o}else return e(i).reduce((o,a)=>(o[a]=s.getValue(a),o),{})},getValue(i){const o=t.getFieldCtx(i);return o?ge(o.rule.value):t.options.appendValue!==!1&&E(t.appendData,i)?ge(t.appendData[i]):void 0},coverValue(i){const o=C({},i||{});t.deferSyncValue(()=>{t.appendData={},s.fields().forEach(a=>{const l=t.fieldCtx[a];if(l){const u=E(i,a);l.forEach(c=>{c.rule.value=u?i[a]:void 0}),delete o[a]}}),S(t.appendData,o)},!0)},setValue(i){let o=i;arguments.length>=2&&(o={[i]:arguments[1]}),t.deferSyncValue(()=>{Object.keys(o).forEach(a=>{const l=t.fieldCtx[a];if(!l)return t.appendData[a]=o[a];l.forEach(u=>{u.rule.value=o[a]})})},!0)},removeField(i){const o=t.getCtx(i);return t.deferSyncValue(()=>{t.getCtxs(i).forEach(a=>{a.rm()})},!0),o?o.origin:void 0},removeRule(i){const o=i&&J(i);if(o)return o.rm(),o.origin},fields:()=>t.fields(),append:(i,o,a)=>{let l=t.sort.length-1,u;const c=t.getCtx(o);if(c)if(a){if(u=c.getPending("children",c.rule.children),!Array.isArray(u))return;l=c.rule.children.length-1}else l=c.root.indexOf(c.origin),u=c.root;else u=t.rules;u.splice(l+1,0,i)},prepend:(i,o,a)=>{let l=0,u;const c=t.getCtx(o);if(c)if(a){if(u=c.getPending("children",c.rule.children),!Array.isArray(u))return}else l=c.root.indexOf(c.origin),u=c.root;else u=t.rules;u.splice(l,0,i)},hidden(i,o){r(o,"hidden",!!i),t.refresh()},hiddenStatus(i){const o=t.getCtx(i);if(o)return!!o.rule.hidden},display(i,o){r(o,"display",!!i),t.refresh()},displayStatus(i){const o=t.getCtx(i);if(o)return!!o.rule.display},disabled(i,o){e(o).forEach(a=>{t.getCtxs(a).forEach(l=>{q(l.rule.props,"disabled",!!i)})}),t.refresh()},all(i){return Object.keys(t.ctxs).map(o=>{const a=t.ctxs[o];return i?a.origin:a.rule})},model(i){return t.fields().reduce((o,a)=>{const l=t.fieldCtx[a][0];return o[a]=i?l.origin:l.rule,o},{})},component(i){return Object.keys(t.nameCtx).reduce((o,a)=>{const l=t.nameCtx[a].map(u=>i?u.origin:u.rule);return o[a]=l.length===1?l[0]:l,o},{})},bind(){return s.form},reload:i=>{t.reloadRule(i)},updateOptions(i){t.fc.updateOptions(i),s.refresh()},onSubmit(i){s.updateOptions({onSubmit:i})},sync:i=>{if(Array.isArray(i)){i.forEach(a=>s.sync(a));return}let o=g.Object(i)?J(i):t.getCtxs(i);o&&(o=Array.isArray(o)?o:[o],o.forEach(a=>{if(!a.deleted){const l=t.subForm[a.id];l&&(Array.isArray(l)?l.forEach(u=>{u.refresh()}):l&&l.refresh()),t.$render.clearCache(a)}}),t.refresh())},refresh:()=>{n().forEach(i=>{i.refresh()}),t.$render.clearCacheAll(),t.refresh()},refreshOptions(){t.$manager.updateOptions(t.options),s.refresh()},hideForm:i=>{t.vm.setupState.isShow=!i},changeStatus:()=>t.changeStatus,clearChangeStatus:()=>{t.changeStatus=!1},updateRule(i,o){t.getCtxs(i).forEach(a=>{S(a.rule,o)})},updateRules(i){Object.keys(i).forEach(o=>{s.updateRule(o,i[o])})},mergeRule:(i,o)=>{t.getCtxs(i).forEach(a=>{Q(a.rule,o)})},mergeRules(i){Object.keys(i).forEach(o=>{s.mergeRule(o,i[o])})},getRule:(i,o)=>{const a=t.getCtx(i);if(a)return o?a.origin:a.rule},findType(i,o){let a;return Object.keys(t.ctxs).forEach(l=>{const u=t.ctxs[l];u.rule.type===i&&(a=o?u.origin:u.rule)}),a},findTypes(i,o){let a=[];return Object.keys(t.ctxs).forEach(l=>{const u=t.ctxs[l];u.rule.type===i&&a.push(o?u.origin:u.rule)}),a},getRenderRule:i=>{const o=t.getCtx(i);if(o)return o.prop},getRefRule:i=>{const o=t.getCtxs(i);if(o){const a=o.map(l=>l.rule);return a.length===1?a[0]:a}},setEffect(i,o,a){const l=t.getCtx(i);l&&o&&(o[0]==="$"&&(o=o.substr(1)),E(l.rule,"$"+o)&&q(l.rule,"$"+o,a),E(l.rule,"effect")||(l.rule.effect={}),q(l.rule.effect,o,a))},clearEffectData(i,o){const a=t.getCtx(i);a&&(o&&o[0]==="$"&&(o=o.substr(1)),a.clearEffectData(o),s.sync(i))},updateValidate(i,o,a){a?s.mergeRule(i,{validate:o}):r(i,"validate",o)},updateValidates(i,o){Object.keys(i).forEach(a=>{s.updateValidate(a,i[a],o)})},refreshValidate(){s.refresh()},resetFields(i){e(i).forEach(o=>{t.getCtxs(o).forEach(a=>{t.$render.clearCache(a),a.rule.value=ge(a.defaultValue)})}),f.nextTick(()=>{f.nextTick(()=>{f.nextTick(()=>{s.clearValidateState(i)})})}),i==null&&(g.Function(t.options.onReset)&&F(()=>t.options.onReset(s)),t.vm.emit("reset",s))},method(i,o){const a=s.el(i);if(!a||!a[o])throw new Error(tt("err",`${o} 方法不存在`));return(...l)=>a[o](...l)},exec(i,o,...a){return F(()=>s.method(i,o)(...a))},toJson(i){return me(s.rule,i)},trigger(i,o,...a){const l=s.el(i);l&&l.$emit(o,...a)},el(i){const o=t.getCtx(i);if(o)return o.el||t.vm.refs[o.ref]},scrollTo(i,o={block:"center",inline:"nearest",behavior:"smooth"}){const a=s.el(i);if(!a)return;const l=a.$el!==void 0?a.$el:a;if(!l)return;const u=l.nodeType===1?l:l.firstElementChild;u&&typeof u.scrollIntoView=="function"&&u.scrollIntoView(o)},focus(i){const o=s.el(i);if(!o)return;const a=p=>!p||typeof p.focus!="function"?!1:(F(()=>p.focus()),!0);if(a(o))return;const l=o.$el!==void 0?o.$el:o;if(a(l))return;const u=l&&(l.nodeType===1?l:l.firstElementChild);if(a(u)||!u||!u.querySelector)return;const c=u.querySelector('input:not([type=hidden]):not([disabled]),textarea:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])');a(c)},closeModal:i=>{t.bus.$emit("fc:closeModal:"+i)},getSubForm(i){const o=t.getCtx(i);return o?t.subForm[o.id]:void 0},getChildrenRuleList(i){const o=typeof i=="object",a=o?J(i):t.getCtx(i),l=a?a.rule:o?i:s.getRule(i);if(!l)return[];const u=[];return(p=>{p&&