UNPKG

@form-create/iview

Version:

Iview版本低代码表单|FormCreate 是一个可以通过 JSON 生成具有动态渲染、数据收集、验证和提交功能的低代码表单生成组件。支持6个UI框架,适配移动端,并且支持生成任何 Vue 组件。内置20种常用表单组件和自定义组件,再复杂的表单都可以轻松搞定。

12 lines (11 loc) 86.6 kB
/*! * FormCreate 低代码表单渲染器 * @form-create/iview v2.6.3 * (c) 2018-2024 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 o=document.createElement("style");o.appendChild(document.createTextNode('._fc-frame .fc-upload-btn{border:1px dashed #c0ccda;cursor:pointer}._fc-frame .fc-upload-cover{opacity:0;position:absolute;inset:0;background:#0009;transition:opacity .3s}._fc-frame .fc-upload-cover i{color:#fff;font-size:20px;cursor:pointer;margin:0 2px}._fc-frame .fc-files:hover .fc-upload-cover{opacity:1}._fc-frame .ivu-upload-list{margin-top:0}._fc-frame .fc-files img{width:100%;height:100%;display:inline-block;vertical-align:top}._fc-frame .fc-upload-btn,._fc-frame .fc-files{display:inline-block;width:58px;height:58px;text-align:center;line-height:58px;border:1px solid #c0ccda;border-radius:4px;overflow:hidden;background:#fff;position:relative;box-shadow:2px 2px 5px #0000001a;margin-right:4px;box-sizing:border-box}._fc-upload .fc-upload-btn{border:1px dashed #c0ccda;cursor:pointer}._fc-upload .fc-upload-cover{opacity:0;position:absolute;inset:0;background:#0009;transition:opacity .3s}._fc-upload .fc-upload-cover i{color:#fff;font-size:20px;cursor:pointer;margin:0 2px}._fc-upload .fc-files:hover .fc-upload-cover{opacity:1}._fc-upload .ivu-upload-list{margin-top:0}._fc-upload .fc-files img{width:100%;height:100%;display:inline-block;vertical-align:top}._fc-upload .fc-upload-btn,._fc-upload .fc-files{display:inline-block;width:58px;height:58px;text-align:center;line-height:58px;border:1px solid #c0ccda;border-radius:4px;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:42px;justify-content:center;flex-direction:column}._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;padding:20px 20px 25px;margin:5px 5px 25px;border-radius:5px}._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%}.form-create .form-create .ivu-form-item{margin-bottom:24px}.form-create .form-create .ivu-form-item .ivu-form-item{margin-bottom:0}')),document.head.appendChild(o)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})(); (function(F,b){typeof exports=="object"&&typeof module!="undefined"?b(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],b):(F=typeof globalThis!="undefined"?globalThis:F||self,b(F.formCreate={},F.Vue))})(this,function(F,b){"use strict";var Hr=Object.defineProperty,Jr=Object.defineProperties;var zr=Object.getOwnPropertyDescriptors;var ct=Object.getOwnPropertySymbols;var Gr=Object.prototype.hasOwnProperty,Wr=Object.prototype.propertyIsEnumerable;var dt=(F,b,I)=>b in F?Hr(F,b,{enumerable:!0,configurable:!0,writable:!0,value:I}):F[b]=I,y=(F,b)=>{for(var I in b||(b={}))Gr.call(b,I)&&dt(F,I,b[I]);if(ct)for(var I of ct(b))Wr.call(b,I)&&dt(F,I,b[I]);return F},J=(F,b)=>Jr(F,zr(b));function I(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ne(){return ne=Object.assign?Object.assign.bind():function(t){for(var e,r=1;r<arguments.length;r++)for(var i in e=arguments[r],e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},ne.apply(this,arguments)}var pt=["attrs","props","domProps"],mt=["class","style","directives"],yt=["on","nativeOn"],gt=function(t){return t.reduce(function(e,r){for(var i in r)if(!e[i])e[i]=r[i];else if(pt.indexOf(i)!==-1)e[i]=ne({},e[i],r[i]);else if(mt.indexOf(i)!==-1){var s=e[i]instanceof Array?e[i]:[e[i]],n=r[i]instanceof Array?r[i]:[r[i]];e[i]=[].concat(s,n)}else if(yt.indexOf(i)!==-1)for(var o in r[i])if(e[i][o]){var a=e[i][o]instanceof Array?e[i][o]:[e[i][o]],u=r[i][o]instanceof Array?r[i][o]:[r[i][o]];e[i][o]=[].concat(a,u)}else e[i][o]=r[i][o];else if(i==="hook")for(var l in r[i])e[i][l]=e[i][l]?$t(e[i][l],r[i][l]):r[i][l];else e[i]=r[i];return e},{})},$t=function(t,e){return function(){t&&t.apply(this,arguments),e&&e.apply(this,arguments)}},vt=gt;const _=I(vt);function K(t,e){return Object.keys(t).reduce((r,i)=>((!e||e.indexOf(i)===-1)&&r.push(t[i]),r),[])}const bt={name:"fcCheckbox",props:{formCreateInject:{type:Object,required:!0},value:{type:Array,default:()=>[]}},watch:{"formCreateInject.options":{handler(){this.update()},deep:!0},value(){this.update()}},data(){return{trueValue:[]}},methods:{options(){const t=this.formCreateInject.options;return Array.isArray(t)?t:[]},onInput(t){this.$emit("input",this.options().filter(e=>t.indexOf(e.label)!==-1).map(e=>e.value).filter(e=>e!==void 0))},update(){const t=Array.isArray(this.value)?this.value:[this.value];this.trueValue=this.options().filter(e=>t.indexOf(e.value)!==-1).map(e=>e.label)}},created(){this.update()},render(){const t=arguments[0];return t("CheckboxGroup",_([{},this.formCreateInject.prop,{ref:"el"},{props:{value:this.trueValue}},{on:{input:this.onInput}}]),[this.options().map((e,r)=>{const i=y({},e);return delete i.value,t("Checkbox",_([{},{props:i},{key:""+r+"-"+e.value}]))}),K(this.$slots)])},mounted(){this.$emit("fc.el",this.$refs.el)}};function A(t){return Array.isArray(t)?t:[null,void 0,""].indexOf(t)>-1?[]:[t]}const Ct="fcFrame";function Oe(t){return{name:Ct,props:{formCreateInject:{type:Object,required:!0},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:t.fileUpIcon},width:{type:[Number,String],default:500},height:{type: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:{type:Function,default(e){this.previewImage=this.getSrc(e),this.previewVisible=!0}},modal:{type:Object,default:()=>({})},srcKey:{type:[String,Number]},value:[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}},data(){return{fileList:A(this.value),previewVisible:!1,frameVisible:!1,previewImage:""}},watch:{value(e){this.fileList=A(e)},fileList(e){const r=this.maxLength===1?e[0]||"":e;this.$emit("input",r),this.$emit("change",r)},src(e){this.modalVm&&(this.modalVm.src=e)}},methods:{key(e){return e},closeModel(e){this.$emit(e?"$close":"$ok"),this.reload&&(this.$off("$ok"),this.$off("$close")),this.frameVisible=!1},showModel(){this.disabled||this.onOpen()===!1||(this.frameVisible=!0)},makeInput(){const e=this.$createElement,r={type:"text",value:this.fileList.map(i=>this.getSrc(i)).toString(),icon:this.icon,readonly:!0,clearable:!1};return e("Input",_([{},{props:r},{},{on:{"on-click":()=>this.showModel()}},{key:this.key("input")}]))},makeGroup(e){const r=this.$createElement;return(!this.maxLength||this.fileList.length<this.maxLength)&&e.push(this.makeBtn()),r("div",{key:this.key("group")},[...e])},makeItem(e,r){const i=this.$createElement;return i("div",{class:"fc-files",key:this.key("file"+e)},[...r])},valid(e){const r=this.formCreateInject.field||this.field;if(r&&e!==r)throw new Error("[frame]无效的字段值")},makeIcons(e,r){const i=this.$createElement;if(this.handleIcon!==!1||this.allowRemove===!0){const s=[];return(this.type!=="file"&&this.handleIcon!==!1||this.type==="file"&&this.handleIcon)&&s.push(this.makeHandleIcon(e,r)),this.allowRemove&&s.push(this.makeRemoveIcon(e,r)),i("div",{class:"fc-upload-cover",key:this.key("uc")},[s])}},makeHandleIcon(e,r){const i=this.$createElement;return i("icon",_([{},{props:{type:this.handleIcon===!0||this.handleIcon===void 0?"ios-eye-outline":this.handleIcon}},{on:{click:()=>this.handleClick(e)},key:this.key("hi"+r)}]))},makeRemoveIcon(e,r){const i=this.$createElement;return i("icon",_([{},{props:{type:"ios-trash-outline"}},{on:{click:()=>this.handleRemove(e)},key:this.key("ri"+r)}]))},makeFiles(){const e=this.$createElement;return this.makeGroup(this.fileList.map((r,i)=>this.makeItem(i,[e("icon",_([{},{props:{type:t.fileIcon,size:40}},{on:{click:()=>this.handleClick(r)}}])),this.makeIcons(r,i)])))},makeImages(){const e=this.$createElement;return this.makeGroup(this.fileList.map((r,i)=>this.makeItem(i,[e("img",{attrs:{src:this.getSrc(r)}}),this.makeIcons(r,i)])))},makeBtn(){const e=this.$createElement;return e("div",{class:"fc-upload-btn",on:{click:()=>this.showModel()},key:this.key("btn")},[e("icon",_([{},{props:{type:this.icon,size:20}}]))])},handleClick(e){return this.onHandle(e)},handleRemove(e){this.disabled||this.onBeforeRemove(e)!==!1&&(this.fileList.splice(this.fileList.indexOf(e),1),this.onRemove(e))},getSrc(e){return this.srcKey?e[this.srcKey]:e},frameLoad(e){this.onLoad(e);try{this.helper===!0&&(e.form_create_helper={api:this.formCreateInject.api,close:r=>{this.valid(r),this.closeModel()},set:(r,i)=>{this.valid(r),this.disabled||this.$emit("input",i)},get:r=>(this.valid(r),this.value),onOk:r=>this.$on("$ok",r),onClose:r=>this.$on("$close",r)})}catch(r){console.log(r)}},makeFooter(){const e=this.$createElement,{okBtnText:r,closeBtnText:i,closeBtn:s,okBtn:n,footer:o}=this.$props,a=[];return o&&(s&&a.push(e("Button",{on:{click:()=>this.onCancel()!==!1&&this.closeModel(!0)}},[i])),n&&a.push(e("Button",{attrs:{type:"primary"},on:{click:()=>this.onOk()!==!1&&this.closeModel()}},[r]))),a}},render(){const e=arguments[0],r=this.type;let i;r==="input"?i=this.makeInput():r==="image"?i=this.makeImages():i=this.makeFiles();const{width:s,height:n,src:o,title:a,modalTitle:u}=this.$props;return this.$nextTick(()=>{this.$refs.frame&&this.frameLoad(this.$refs.frame.contentWindow||{})}),e("div",{class:"_fc-frame"},[i,e("Modal",_([{},{props:{mask:this.previewMask,title:u,footerHide:!0}},{model:{value:this.previewVisible,callback:l=>{this.previewVisible=l}}}]),[e("img",{style:"width: 100%",attrs:{src:this.previewImage}})]),e("Modal",_([{},{props:y({width:s,title:a},this.modal)},{on:{"on-cancel":()=>this.closeModel(!0)},model:{value:this.frameVisible,callback:l=>{this.frameVisible=l}}}]),[this.frameVisible||!this.reload?e("iframe",{ref:"frame",attrs:{src:o,frameBorder:"0"},style:{height:n,border:"0 none",width:"100%"}}):null,e("div",{slot:"footer"},[this.makeFooter()])])])},mounted(){this.$on("fc.closeModal",this.closeModal)}}}const ke=Oe({fileIcon:"md-document",fileUpIcon:"ios-folder-open"});ke.v2=Oe({fileIcon:"document-text",fileUpIcon:"folder"});const _t={name:"fcRadio",props:{formCreateInject:{type:Object,required:!0},value:{}},watch:{"formCreateInject.options":{handler(){this.update()},deep:!0},value(){this.update()}},data(){return{trueValue:[]}},methods:{options(){const t=this.formCreateInject.options;return Array.isArray(t)?t:[]},onInput(t){this.$emit("input",this.options().filter(e=>e.label===t).reduce((e,r)=>r.value,""))},update(){this.trueValue=this.options().filter(t=>t.value===this.value).reduce((t,e)=>e.label,"")}},created(){this.update()},render(){const t=arguments[0];return t("RadioGroup",_([{},this.formCreateInject.prop,{},{props:{value:this.trueValue}},{ref:"el",on:{input:this.onInput}}]),[this.options().map((e,r)=>{const i=y({},e);return delete i.value,t("Radio",_([{},{props:i},{key:""+r+"-"+e.value}]))}),K(this.$slots)])},mounted(){this.$emit("fc.el",this.$refs.el)}},h={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&&!h.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=>{h[t]=function(e){return h.type(e,t)}});function O(t,e){return{}.hasOwnProperty.call(t,e)}const Ot={name:"fcSelect",functional:!0,props:{formCreateInject:{type:Object,required:!0}},render(t,e){const r=(n,o)=>{const a=n.slot;return t("Option",_([{},{props:n},{key:""+o+"-"+n.value}]),[a?t("template",{slot:n.slotName||"default"},[h.Function(a)?n.slot(t):a]):null])},i=(n,o)=>t("OptionGroup",{attrs:{label:n.label},key:""+o+"-"+n.label},[h.trueArray(n.options)&&n.options.map((a,u)=>r(a,u))]),s=e.props.formCreateInject.options;return t("Select",_([{},e.data,{ref:"el"}]),[(Array.isArray(s)?s:[]).map((n,o)=>O(n||"","options")?i(n,o):r(n,o)),e.children])},mounted(){this.$emit("fc.el",this.$refs.el)}},kt={name:"fcTree",props:{formCreateInject:{type:Object,required:!0},type:{type:String,default:"checked"},value:{type:[Array,String,Number],default:()=>[]}},data(){return{treeData:[]}},watch:{value(t){this.setStatus(t)}},created(){this.setStatus(this.value)},methods:{setStatus(t){const e=A(t),r=this.formCreateInject.prop.props.data;this.type==="selected"?this.checked(r,e,"selected"):this.checked(r,e,"checked"),this.$forceUpdate()},checked(t,e,r){t.forEach(i=>{this.$set(i,r,e.indexOf(i.id)!==-1),i.children!==void 0&&Array.isArray(i.children)&&this.checked(i.children,e,r)})},onInput(t){this.$emit("input",t.map(e=>e.id))}},render(){const t=arguments[0],e={};return this.type==="selected"?e["on-select-change"]=this.onInput:e["on-check-change"]=this.onInput,t("Tree",_([{},this.formCreateInject.prop,{ref:"tree"},{on:e}]),[K(this.$slots)])},mounted(){this.$emit("fc.el",this.$refs.tree)}};function we(t){return{url:t,name:wt(t)}}function wt(t){return(""+t).split("/").pop()}const Ft="fcUpload";function Fe(t){return{name:Ft,props:{formCreateInject:{type:Object,required:!0},onHandle:{type:Function,default(e){this.previewImage=e.url,this.previewVisible=!0}},uploadType:{type:String,default:"file"},maxLength:{type:Number,default:0},allowRemove:{type:Boolean,default:!0},modalTitle:String,handleIcon:{type:[String,Boolean],default:()=>{}},value:[Array,String]},data(){return{uploadList:[],previewVisible:!1,previewImage:"",cacheFiles:[]}},created(){this.formCreateInject.prop.props.showUploadList===void 0&&(this.formCreateInject.prop.props.showUploadList=!1),this.formCreateInject.prop.props.defaultFileList=A(this.value).map(we)},watch:{value(e){this.$refs.upload.fileList.every(r=>!r.status||r.status==="finished")&&(this.$refs.upload.fileList=A(e).map(we),this.uploadList=this.$refs.upload.fileList)},maxLength(e,r){(r===1||e===1)&&this.update()}},methods:{key(e){return e},isDisabled(){return this.formCreateInject.prop.props.disabled===!0},onRemove(e){this.isDisabled()||this.$refs.upload.handleRemove(e)},handleClick(e){this.onHandle(e)},makeItem(e,r){const i=this.$createElement;return this.uploadType==="image"?i("img",{attrs:{src:e.url},key:this.key("img"+r)}):i("icon",_([{},{props:{type:t.fileIcon,size:40}},{key:this.key("i"+r)}]))},makeRemoveIcon(e,r){const i=this.$createElement;return i("icon",{attrs:{type:"ios-trash-outline"},on:{click:()=>this.onRemove(e)},key:this.key("ri"+r)})},makeHandleIcon(e,r){const i=this.$createElement;return i("icon",{attrs:{type:this.handleIcon===!0||this.handleIcon===void 0?"ios-eye-outline":this.handleIcon},on:{click:()=>this.handleClick(e)},key:this.key("hi"+r)})},makeProgress(e,r){const i=this.$createElement;return i("Progress",_([{},{props:{percent:e.percentage,hideInfo:!0}},{style:"width:90%",key:this.key("pg"+r)}]))},makeIcons(e,r){const i=this.$createElement,s=[];if(this.allowRemove||this.handleIcon!==!1)return(this.uploadType!=="file"&&this.handleIcon!==!1||this.uploadType==="file"&&this.handleIcon)&&s.push(this.makeHandleIcon(e,r)),this.allowRemove&&s.push(this.makeRemoveIcon(e,r)),i("div",{class:"fc-upload-cover"},[s])},makeFiles(){const e=this.$createElement;return this.uploadList.map((r,i)=>this.$scopedSlots.fileList?this.$scopedSlots.fileList({file:r,index:i,vm:this}):e("div",{key:this.key(i),class:"fc-files"},[r.showProgress?this.makeProgress(r,i):[this.makeItem(r,i),this.makeIcons(r,i)]]))},makeUpload(){const e=this.$createElement,r=!this.maxLength||this.maxLength>this.uploadList.length;return e("Upload",_([{},this.formCreateInject.prop,{},{style:{display:"inline-block"},key:this.key("upload"),ref:"upload"}]),[r?e("template",{slot:"default"},[this.$slots.default||e("div",{class:"fc-upload-btn"},[e("icon",_([{},{props:{type:this.uploadType==="file"?"ios-cloud-upload-outline":t.imgUpIcon,size:20}}]))])]):null,K(this.$slots,["default"])])},update(){let e=this.$refs.upload.fileList.map(r=>r.url).filter(r=>r!==void 0);(this.cacheFiles.length!==e.length||!e.length)&&(this.cacheFiles=[...e],this.$emit("input",this.maxLength===1?e[0]||"":e))},handleCancel(){this.previewVisible=!1}},render(){const e=arguments[0];return this.$refs.upload&&(this.formCreateInject.prop.props.showUploadList===void 0&&(this.formCreateInject.prop.props.showUploadList=this.$refs.upload.showUploadList),this.formCreateInject.prop.props.defaultFileList=this.$refs.upload.defaultFileList),e("div",{class:"_fc-upload"},[[this.formCreateInject.prop.props.showUploadList?[]:this.makeFiles(),this.makeUpload()],e("Modal",_([{},{props:{title:this.modalTitle,footerHide:!0}},{model:{value:this.previewVisible,callback:r=>{this.previewVisible=r}}}]),[e("img",{attrs:{alt:"example",src:this.previewImage},style:"width: 100%"})])])},mounted(){this.uploadList=this.$refs.upload.fileList,this.$watch(()=>this.$refs.upload.fileList,()=>{this.update()},{deep:!0}),this.$emit("fc.el",this.$refs.upload)}}}const Ee=Fe({fileIcon:"md-document",imgUpIcon:"md-images"});Ee.v2=Fe({fileIcon:"document-text",imgUpIcon:"image"});function E(t,e,r){b.set(t,e,r)}function L(t,e){b.delete(t,e)}function z(t,e={},r){let i=!1;for(let s in e)if(Object.prototype.hasOwnProperty.call(e,s)){let n=e[s];if((i=Array.isArray(n))||h.Object(n)){let o=t[s]===void 0;if(i)i=!1,o&&E(t,s,[]);else if(n._clone&&r!==void 0)if(r)n=n.getRule(),o&&E(t,s,{});else{E(t,s,n._clone());continue}else o&&E(t,s,{});t[s]=z(t[s],n,r)}else E(t,s,n),h.Undef(n)||(h.Undef(n.__json)||(t[s].__json=n.__json),h.Undef(n.__origin)||(t[s].__origin=n.__origin))}return r!==void 0&&Array.isArray(t)?t.filter(s=>!s||!s.__ctrl):t}function N(t){return z({},{value:t}).value}const Et=Object.assign||function(t){for(let e,r=1;r<arguments.length;r++)for(let i in e=arguments[r],e)Object.prototype.hasOwnProperty.call(e,i)&&E(t,i,e[i]);return t};function p(){return Et.apply(this,arguments)}const St=[bt,_t,Ot,kt,{name:"fcSubForm",props:{rule:Array,options:Object,formCreateInject:{type:Object,required:!0},value:{type:Object,default:()=>({})},disabled:{type:Boolean,default:!1},syncDisabled:{type:Boolean,default:!0}},data(){return{cacheRule:{},cacheValue:{},type:void 0}},watch:{value(t){this.setValue(t)}},methods:{formData(t){this.cacheValue=JSON.stringify(t),this.$emit("input",t),this.$emit("change",t)},setValue(t){const e=JSON.stringify(t);this.cacheValue!==e&&(this.cacheValue=e,this.cacheRule.$f.coverValue(t||{}))},addRule(){const t=this.options?this.options:{submitBtn:!1,resetBtn:!1};t.formData=y({},this.value||{}),this.cacheRule={rule:this.rule,options:t}},add$f(t){this.cacheRule.$f=t,this.$nextTick(()=>{this.$emit("itemMounted",t)})},emitEvent(t,...e){this.$emit(t,...e)}},created(){this.addRule(),this.type=this.formCreateInject.form.$form()},render(){const t=arguments[0],{rule:e,options:r}=this.cacheRule,i=this.type;return t(i,_([{},{on:{"update:value":this.formData,"emit-event":this.emitEvent,input:this.add$f}},{},{props:{rule:e,option:r,disabled:this.disabled,extendOption:!0}}]))}},ke,Ee,{name:"fcGroup",props:{field:String,rule:[Array,Object],rules:Array,expand:Number,options:Object,formCreateInject:{type:Object,required:!0},button:{type:Boolean,default:!0},max:{type:Number,default:0},min:{type:Number,default:0},value:{type:Array,default:()=>[]},sortBtn:{type:Boolean,default:!0},defaultValue:Object,disabled:{type:Boolean,default:!1},syncDisabled:{type:Boolean,default:!0},onBeforeRemove:{type:Function,default:()=>{}},onBeforeAdd:{type:Function,default:()=>{}},parse:Function},data(){return{len:0,cacheRule:{},cacheValue:{},sort:[],type:void 0}},computed:{formRule(){return this.rules?this.rules:this.rule?Array.isArray(this.rule)?this.rule:[this.rule]:[]}},watch:{cacheRule:{handler(t){this.sort=Object.keys(t)},immediate:!0},formRule:{handler(t,e){Object.keys(this.cacheRule).forEach(r=>{const i=this.cacheRule[r];if(i.$f){const s=i.$f.formData();if(t===e)i.$f.deferSyncValue(()=>{z(i.rule,t),i.$f.setValue(s)},!0);else{const n=i.$f.formData();i.$f.once("reloading",()=>{i.$f.setValue(n)}),i.rule=N(t)}}})},deep:!0},expand(t){let e=t-this.value.length;e>0&&this.expandRule(e)},value(t,e){t=t||[];let r=this.sort,i=r.length,s=i-t.length;if(s<0){for(let n=s;n<0;n++)this.addRule(t.length+n);this.sort=Object.keys(this.cacheRule);for(let n=0;n<i;n++)this.setValue(r[n],t[n])}else{if(s>0)for(let n=0;n<s;n++)this.removeRule(r[i-n-1]);this.sort=Object.keys(this.cacheRule),t.forEach((n,o)=>{this.setValue(r[o],t[o])})}}},methods:{_value(t){return t&&O(t,this.field)?t[this.field]:t},cache(t,e){this.cacheValue[t]=JSON.stringify(e)},input(t){this.$emit("input",t),this.$emit("change",t)},formData(t,e){const r=this.cacheRule,i=this.sort;if(i.filter(n=>r[n].$f).length!==i.length)return;const s=i.map(n=>{const o=t===n?e:y({},this.cacheRule[n].$f.form),a=this.field?o[this.field]||null:o;return this.cache(n,a),a});this.input(s)},setValue(t,e){const r=this.field,i=this.cacheRule[t].$f;r&&(e={[r]:this._value(e)}),this.cacheValue[t]!==JSON.stringify(r?e[r]:e)&&(this.cache(t,e),i&&i.coverValue(e||{}))},addRule(t,e){const r=this.formCreateInject.form.copyRules(this.formRule),i=this.options?y({},this.options):{submitBtn:!1,resetBtn:!1};if(this.defaultValue){i.formData||(i.formData={});const s=N(this.defaultValue);p(i.formData,this.field?{[this.field]:s}:s)}this.parse&&this.parse({rule:r,options:i,index:this.sort.length}),this.$set(this.cacheRule,++this.len,{rule:r,options:i}),e&&this.$nextTick(()=>this.$emit("add",r,Object.keys(this.cacheRule).length-1))},add$f(t,e,r){this.cacheRule[e].$f=r,this.$nextTick(()=>{this.$emit("itemMounted",r,Object.keys(this.cacheRule).indexOf(e))})},removeRule(t,e){const r=Object.keys(this.cacheRule).indexOf(t);this.$delete(this.cacheRule,t),this.$delete(this.cacheValue,t),e&&this.$nextTick(()=>this.$emit("remove",r))},add(t){this.disabled||this.onBeforeAdd(this.value)===!1||this.addRule(t,!0)},del(t,e){if(this.disabled||this.onBeforeRemove(this.value,t)===!1)return;this.removeRule(e,!0);const r=[...this.value];r.splice(t,1),this.input(r)},addIcon(t){const e=this.$createElement;return e("div",{class:"_fc-group-btn _fc-group-plus-minus",on:{click:this.add}})},delIcon(t,e){const r=this.$createElement;return r("div",{class:"_fc-group-btn _fc-group-plus-minus _fc-group-minus",on:{click:()=>this.del(t,e)}})},sortUpIcon(t){const e=this.$createElement;return e("div",{class:"_fc-group-btn _fc-group-arrow _fc-group-up",on:{click:()=>this.changeSort(t,-1)}})},sortDownIcon(t){const e=this.$createElement;return e("div",{class:"_fc-group-btn _fc-group-arrow _fc-group-down",on:{click:()=>this.changeSort(t,1)}})},changeSort(t,e){const r=this.sort[t];this.$set(this.sort,t,this.sort[t+e]),this.sort[t+e]=r,this.formData(0)},makeIcon(t,e,r){if(this.$scopedSlots.button)return this.$scopedSlots.button({total:t,index:e,vm:this,key:r,del:()=>this.del(e,r),add:this.add});const i=[];return(!this.max||t<this.max)&&t===e+1&&i.push(this.addIcon(r)),t>this.min&&i.push(this.delIcon(e,r)),this.sortBtn&&e&&i.push(this.sortUpIcon(e)),this.sortBtn&&e!==t-1&&i.push(this.sortDownIcon(e)),i},emitEvent(t,e,r,i){this.$emit(t,...e,this.cacheRule[i].$f,r)},expandRule(t){for(let e=0;e<t;e++)this.value.push(this.field?null:{})}},created(){this.type=this.formCreateInject.form.$form();const t=(this.expand||0)-this.value.length;t>0&&this.expandRule(t);for(let e=0;e<this.value.length;e++)this.addRule(e)},render(){const t=arguments[0],e=this.sort,r=this.button,i=this.type,s=this.disabled,n=e.length===0?this.$scopedSlots.default?this.$scopedSlots.default({vm:this,add:this.add}):t("div",{key:"a_def",class:"_fc-group-plus-minus _fc-group-add",on:{click:this.add}}):e.map((o,a)=>{const{rule:u,options:l}=this.cacheRule[o],c=r&&!s?this.makeIcon(e.length,a,o):[];return t("div",{class:"_fc-group-container",key:o},[t(i,_([{key:o},{on:{"update:value":m=>this.formData(o,m),"emit-event":(m,...v)=>this.emitEvent(m,v,a,o),input:m=>this.add$f(a,o,m)}},{},{props:{disabled:s,inFor:!0,value:this.field?{[this.field]:this._value(this.value[a])}:this.value[a],rule:u,option:l,extendOption:!0}}])),t("div",{class:"_fc-group-idx"},[a+1]),c.length?t("div",{class:"_fc-group-handle"},[c]):null])});return t("div",{key:"con",class:"_fc-group "+(s?"_fc-group-disabled":"")},[n])}}],Se="FormCreate",se=(t,e)=>{if(!(!t||t===e)){if(t.formCreateInject)return t.formCreateInject;if(t.$parent)return se(t.$parent,e)}};function Rt(t,e,r){return{name:Se,componentName:Se,model:{prop:"api"},components:e,directives:r,provide(){return{$pfc:this}},inject:{$pfc:{default:null}},props:{rule:{type:Array,required:!0},option:{type:Object,default:()=>({})},extendOption:Boolean,disabled:{type:Boolean,default:void 0},value:Object,api:Object,name:String,subForm:{type:Boolean,default:!0},inFor:Boolean},data(){return{formData:void 0,destroyed:!1,validate:{},$f:void 0,isShow:!0,unique:1,renderRule:[...this.rule||[]],ctxInject:{},updateValue:JSON.stringify(this.value||{}),isMore:!!this.inFor}},render(){return this.formCreate.render()},methods:{_refresh(){++this.unique},_renderRule(){this.renderRule=[...this.rule||[]]},_updateValue(i){this.destroyed||(this.updateValue=JSON.stringify(i),this.$emit("update:value",i))}},watch:{value:{handler(i){JSON.stringify(i||{})!==this.updateValue&&(this.$f.config.forceCoverValue?this.$f.coverValue(i||{}):this.$f.setValue(i||{}))},deep:!0},option:{handler(){this.formCreate.initOptions(),this.$f.refresh()},deep:!0},rule(i,s){i.length===this.renderRule.length&&i.every(n=>this.renderRule.indexOf(n)>-1)||(this.formCreate.$handle.reloadRule(i),this._renderRule(),i!==s&&this.formCreate.$handle.targetReload())},disabled(){this.$f.refresh()}},beforeCreate(){this.formCreate=new t(this),Object.keys(this.formCreate.prop).forEach(i=>{p(this.$options[i],this.formCreate.prop[i])}),this.$emit("beforeCreate",this.formCreate.api())},created(){const i=this,s=this.formCreate.api(),n=()=>{if(i.$pfc){const a=se(i,i.$pfc);if(a){let u;i.isMore?(u=A(a.getSubForm()),u.push(s)):u=s,a.subForm(u)}}},o=()=>{const a=se(i,i.$pfc);if(a)if(i.isMore){const u=A(a.getSubForm()),l=u.indexOf(s);l>-1&&u.splice(l,1)}else a.subForm()};i.$on("hook:beforeDestroy",()=>{o()}),this.$watch(()=>this.subForm,a=>{a?n():o()},{immediate:!0})}}}const Re=["attrs","props","domProps","scopedSlots"],je=["class","style","directives"],Ie=["on","nativeOn"],T=(t,e={},r={})=>{const i=[...Re,...r.normal||[]],s=[...je,...r.array||[]],n=[...Ie,...r.functional||[]],o=r.props||[];return t.reduce((a,u)=>{for(const l in u)if(a[l])if(o.indexOf(l)>-1)a[l]=T([u[l]],a[l]);else if(i.indexOf(l)>-1)a[l]=y(y({},a[l]),u[l]);else if(s.indexOf(l)>-1){const c=a[l]instanceof Array?a[l]:[a[l]],m=u[l]instanceof Array?u[l]:[u[l]];a[l]=[...c,...m]}else if(n.indexOf(l)>-1)for(const c in u[l])if(a[l][c]){const m=a[l][c]instanceof Array?a[l][c]:[a[l][c]],v=u[l][c]instanceof Array?u[l][c]:[u[l][c]];a[l][c]=[...m,...v]}else a[l][c]=u[l][c];else if(l==="hook")for(let c in u[l])a[l][c]?a[l][c]=jt(a[l][c],u[l][c]):a[l][c]=u[l][c];else a[l]=u[l];else i.indexOf(l)>-1||n.indexOf(l)>-1||o.indexOf(l)>-1?a[l]=y({},u[l]):s.indexOf(l)>-1?a[l]=u[l]instanceof Array?[...u[l]]:typeof u[l]=="object"?y({},u[l]):u[l]:a[l]=u[l];return a},e)},jt=(t,e)=>function(){t&&t.apply(this,arguments),e&&e.apply(this,arguments)},Ae=["type","slot","emitPrefix","value","name","native","hidden","display","inject","options","emit","nativeEmit","link","prefix","suffix","update","sync","optionsTo","key","preview","component","cache"],oe=["validate","children","control"],ae=["effect","deep"];function It(){return[...Ae,...Re,...je,...Ie,...oe,...ae]}function le(t,e,r){return`[form-create ${t}]: ${e}`}function At(t,e){console.warn(le("tip",t))}function ue(t,e){console.error(le("err",t))}function Vt(t){ue(t.toString()),console.error(t)}const fe="[[FORM-CREATE-PREFIX-",he="-FORM-CREATE-SUFFIX]]";function Ve(t,e){return JSON.stringify(z(Array.isArray(t)?[]:{},t,!0),function(r,i){if(!(i&&i._isVue===!0)){if(typeof i!="function")return i;if(i.__json)return i.__json;if(i.__origin&&(i=i.__origin),!i.__emit)return fe+i+he}},e)}function ce(t){return new Function("return "+t)()}function U(t,e){if(t&&h.String(t)&&t.length>4){let r=t.trim(),i=!1;try{if(r.indexOf(he)>0&&r.indexOf(fe)===0)r=r.replace(he,"").replace(fe,""),i=!0;else if(r.indexOf("$FN:")===0)r=r.substring(4),i=!0;else if(r.indexOf("$EXEC:")===0)r=r.substring(6),i=!0;else if(r.indexOf("$GLOBAL:")===0){const n=r.substring(8);return r=function(...o){const a=o[0].api.getGlobalEvent(n);if(a)return a.call(this,...o)},r.__json=t,r.__inject=!0,r}else{if(r.indexOf("$FNX:")===0)return r=ce("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(")&&(i=!0)}if(!i)return t;let s;try{s=ce(r)}catch(n){s=ce("function "+r)}return s.__json=t,s}catch(s){ue(`解析失败:${r} err: ${s}`);return}}return t}function Pt(t,e){return JSON.parse(t,function(r,i){return h.Undef(i)||!i.indexOf?i:U(i,e)})}function de(t,e){return{value:t,enumerable:!1,configurable:!1,writable:!!e}}function pe(t){return Pe([t])[0]}function Pe(t,e){return z([],[...t],e||!1)}function q(t,e){return T(Array.isArray(e)?e:[e],t,{array:oe,normal:ae}),t}function De(t){const e=h.Function(t.getRule)?t.getRule():t;return e.type||(e.type="input"),e}function Dt(t,e){return t?(Object.keys(e||{}).forEach(r=>{e[r]&&(t[r]=q(t[r]||{},e[r]))}),t):e}function Te(t,e){Object.defineProperties(t,Object.keys(e).reduce((r,i)=>(r[i]={get(){return e[i]()}},r),{}))}function x(t){return t.__fc__||(t.__origin__?t.__origin__.__fc__:null)}function R(t,e){try{e=t()}catch(r){Vt(r)}return e}const Be=(t,e)=>typeof t=="string"?String(e):typeof t=="number"?Number(e):e,G={"==":(t,e)=>JSON.stringify(t)===JSON.stringify(Be(t,e)),"!=":(t,e)=>!G["=="](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(Be(t[0],e))>-1},notOn(t,e){return!G.on(t,e)},in(t,e){return e&&e.indexOf&&e.indexOf(t)>-1},notIn(t,e){return!G.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 h.empty(t)},notEmpty(t){return!h.empty(t)},pattern(t,e){return new RegExp(e,"g").test(t)}};function Le(){return{props:{},on:{},options:[],children:[],effect:{},hidden:!1,display:!0,value:void 0}}function S(t,e){return(r,i,s,n={})=>{const o=new me(t,r,i,s,n);return e&&(h.Function(e)?e(o):o.props(e)),o}}function me(t,e,r,i,s){this._data=p(Le(),{type:t,title:e,field:r,value:i,props:s||{}}),this.event=this.on}p(me.prototype,{getRule(){return this._data},setProp(t,e){return E(this._data,t,e),this},_clone(){const t=new this.constructor;return t._data=pe(this._data),t}});function Ne(t){t.forEach(e=>{me.prototype[e]=function(r){return q(this._data,{[e]:arguments.length<2?r:{[r]:arguments[1]}}),this}})}Ne(It());const Me=S("");function Tt(t,e,r){let i=Me("",e);return i._data.type=t,i._data.title=r,i}function Ue(t,e,r,i){let s=Me("",r);return s._data.type="template",s._data.template=t,s._data.title=i,s._data.vm=e,s}function Bt(){return{create:Tt,createTmp:Ue,template:Ue,factory:S}}function Lt(t,e,r){const i=`fail to ${t} ${r.status}'`,s=new Error(i);return s.status=r.status,s.url=t,s}function qe(t){const e=t.responseText||t.response;if(!e)return e;try{return JSON.parse(e)}catch(r){return e}}function He(t){if(typeof XMLHttpRequest=="undefined")return;const e=new XMLHttpRequest,r=t.action;e.onerror=function(o){t.onError(o)},e.onload=function(){if(e.status<200||e.status>=300)return t.onError(Lt(r,t,e),qe(e));t.onSuccess(qe(e))},e.open(t.method||"get",r,!0);let i;t.data&&((t.dataType||"").toLowerCase()!=="json"?(i=new FormData,Object.keys(t.data).map(n=>{i.append(n,t.data[n])})):(i=JSON.stringify(t.data),e.setRequestHeader("content-type","application/json"))),t.withCredentials&&"withCredentials"in e&&(e.withCredentials=!0);const s=t.headers||{};Object.keys(s).forEach(n=>{s[n]!==null&&e.setRequestHeader(n,s[n])}),e.send(i)}function Nt(t){return new Promise((e,r)=>{He(J(y({},t),{onSuccess(i){let s=o=>o;const n=U(t.parse);h.Function(n)?s=n:n&&h.String(n)&&(s=o=>(n.split(".").forEach(a=>{o&&(o=o[a])}),o)),e(s(i))},onError(i){r(i)}}))})}function X(t){return N(t)}function Mt(t){function e(n){return h.Undef(n)?n=t.fields():Array.isArray(n)||(n=[n]),n}function r(n,o,a){e(n).forEach(u=>{t.getCtxs(u).forEach(l=>{E(l.rule,o,a),t.$render.clearCache(l)})})}function i(){const n=t.subForm;return Object.keys(n).reduce((o,a)=>{const u=n[a];return u&&(Array.isArray(u)?o.push(...u):o.push(u)),o},[])}const s={get config(){return t.options},get options(){return t.options},get form(){return t.form},get rule(){return t.rules},get parent(){return t.vm.$pfc&&t.vm.$pfc.$f},get top(){return s.parent?s.parent.top:s},get children(){return i()},formData(n){return e(n).reduce((o,a)=>{const u=t.getFieldCtx(a);return u&&(o[u.field]=X(u.rule.value)),o},t.options.appendValue!==!1?X(t.appendData):{})},getValue(n){const o=t.getFieldCtx(n);if(o)return X(o.rule.value)},coverValue(n){const o=y({},n||{});t.deferSyncValue(()=>{s.fields().forEach(a=>{const u=t.fieldCtx[a];if(u){const l=O(o,a);u.forEach(c=>{c.rule.value=l?o[a]:void 0}),delete o[a]}}),p(t.appendData,o)})},setValue(n){let o=n;arguments.length>=2&&(o={[n]:arguments[1]}),t.deferSyncValue(()=>{Object.keys(o).forEach(a=>{const u=t.fieldCtx[a];if(!u)return t.appendData[a]=o[a];u.forEach(l=>{l.rule.value=o[a]})})})},removeField(n){const o=t.getCtx(n);return t.deferSyncValue(()=>{t.getCtxs(n).forEach(a=>{a.rm()})},!0),o?o.origin:void 0},removeRule(n){const o=n&&x(n);if(o)return o.rm(),o.origin},destroy:()=>{t.vm.$el.parentNode&&t.vm.$el.parentNode.removeChild(t.vm.$el),t.vm.$destroy()},fields:()=>t.fields(),append:(n,o,a)=>{let u=t.sort.length-1,l;const c=t.getCtx(o);c?a?(l=c.rule.children,u=c.rule.children.length-1):(u=c.root.indexOf(c.origin),l=c.root):l=t.rules,l.splice(u+1,0,n)},prepend:(n,o,a)=>{let u=0,l;const c=t.getCtx(o);c?a?l=c.rule.children:(u=c.root.indexOf(c.origin),l=c.root):l=t.rules,l.splice(u,0,n)},hidden(n,o){r(o,"hidden",!!n),t.refresh()},hiddenStatus(n){const o=t.getCtx(n);if(o)return!!o.rule.hidden},display(n,o){r(o,"display",!!n),t.refresh()},displayStatus(n){const o=t.getCtx(n);if(o)return!!o.rule.display},disabled(n,o){e(o).forEach(a=>{t.getCtxs(a).forEach(u=>{u.rule.props&&E(u.rule.props,"disabled",!!n)})}),t.refresh()},all(n){return Object.keys(t.ctxs).map(o=>{const a=t.ctxs[o];return n?a.origin:a.rule})},model(n){return t.fields().reduce((o,a)=>{const u=t.fieldCtx[a][0];return o[a]=n?u.origin:u.rule,o},{})},component(n){return Object.keys(t.nameCtx).reduce((o,a)=>{const u=t.nameCtx[a].map(l=>n?l.origin:l.rule);return o[a]=u.length===1?u[0]:u,o},{})},bind(){return s.form},reload:n=>{t.reloadRule(n)},updateOptions(n){t.fc.updateOptions(n),s.refresh()},onSubmit(n){s.updateOptions({onSubmit:n})},sync:n=>{if(Array.isArray(n)){n.forEach(a=>s.sync(a));return}let o=h.Object(n)?x(n):t.getCtxs(n);o&&(o=Array.isArray(o)?o:[o],o.forEach(a=>{if(!a.deleted){const u=t.subForm[a.id];u&&(Array.isArray(u)?u.forEach(l=>{l.refresh()}):u&&u.refresh()),t.$render.clearCache(a)}}),t.refresh())},refresh:()=>{i().forEach(n=>{n.refresh()}),t.$render.clearCacheAll(),t.refresh()},refreshOptions(){t.$manager.updateOptions(t.options),s.refresh()},hideForm:n=>{E(t.vm,"isShow",!n)},changeStatus:()=>t.changeStatus,clearChangeStatus:()=>{t.changeStatus=!1},updateRule(n,o){t.getCtxs(n).forEach(a=>{p(a.rule,o)})},updateRules(n){Object.keys(n).forEach(o=>{s.updateRule(o,n[o])})},mergeRule:(n,o)=>{t.getCtxs(n).forEach(a=>{q(a.rule,o)})},mergeRules(n){Object.keys(n).forEach(o=>{s.mergeRule(o,n[o])})},getRule:(n,o)=>{const a=t.getCtx(n);if(a)return o?a.origin:a.rule},getRenderRule:n=>{const o=t.getCtx(n);if(o)return o.prop},getRefRule:n=>{const o=t.getCtxs(n);if(o&&o.length){const a=o.map(u=>u.rule);return a.length===1?a[0]:a}},setEffect(n,o,a){const u=t.getCtx(n);u&&o&&(o[0]==="$"&&(o=o.substr(1)),O(u.rule,"$"+o)&&E(u.rule,"$"+o,a),O(u.rule,"effect")||E(u.rule,"effect",{}),E(u.rule.effect,o,a))},clearEffectData(n,o){const a=t.getCtx(n);a&&(o&&o[0]==="$"&&(o=o.substr(1)),a.clearEffectData(o),s.sync(n))},updateValidate(n,o,a){a?s.mergeRule(n,{validate:o}):r(n,"validate",o)},updateValidates(n,o){Object.keys(n).forEach(a=>{s.updateValidate(a,n[a],o)})},refreshValidate(){t.vm.validate={},s.refresh()},resetFields(n){e(n).forEach(o=>{t.getCtxs(o).forEach(a=>{t.$render.clearCache(a),a.rule.value=X(a.defaultValue)})}),t.vm.$nextTick(()=>{s.clearValidateState()}),n==null&&(h.Function(t.options.onReset)&&R(()=>t.options.onReset(s)),t.vm.$emit("reset",s))},method(n,o){const a=s.el(n);if(!a||!a[o])throw new Error(le("err",`${o}方法不存在`));return(...u)=>a[o](...u)},exec(n,o,...a){return R(()=>s.method(n,o)(...a))},toJson(n){return Ve(s.rule,n)},trigger(n,o,...a){const u=s.el(n);u&&u.$emit(o,...a)},el(n){const o=t.getCtx(n);if(o)return o.exportEl||o.el||t.vm.$refs[o.ref]},closeModal:n=>{const o=s.el(n);o&&o.$emit&&o.$emit("close-modal")},getSubForm(n){const o=t.getCtx(n);return o?t.subForm[o.id]:void 0},nextTick(n){t.bus.$once("next-tick",n),t.refresh()},nextRefresh(n){t.nextRefresh(),n&&R(n)},emit(n,...o){t.vm.$emit(n,...o)},deferSyncValue(n,o){t.deferSyncValue(n,o)},fetch(n){return new Promise((o,a)=>{t.beforeFetch(n).then(()=>Nt(n).then(o).catch(a))})},getData(n,o){return t.fc.getData(n,o)},setData(n,o){return t.fc.setData(n,o)},helper:{tidyFields:e,props:r}};return["on","once","off","set","emit"].forEach(n=>{s[n]=function(...o){t.vm[`$${n}`](...o)}}),s.changeValue=s.changeField=s.setValue,s}function Ut(t){p(t.prototype,{initCache(){this.clearCacheAll()},clearCache(e){if(e.rule.cache)return;if(!this.cache[e.id]){e.parent&&this.clearCache(e.parent);return}(this.cache[e.id].use===!0||this.cache[e.id].parent)&&this.$handle.refresh();const r=this.cache[e.id].parent;this.cache[e.id]=null,r&&this.clearCache(r)},clearCacheAll(){this.cache={}},setCache(e,r,i){this.cache[e.id]={vnode:r,use:!1,parent:i,slot:e.rule.slot}},getCache(e){const r=this.cache[e.id];if(r)return r.use=!0,r.vnode}})}function V(t){const e=t.replace(/(-[a-z])/g,function(r){return r.replace("-","").toLocaleUpperCase()});return Je(e)}function Je(t){return t.replace(t[0],t[0].toLowerCase())}function qt(t){return t==null?"":typeof t=="object"?JSON.stringify(t,null,2):String(t)}function Q(t){let e=t.replace(/([A-Z])/g,"-$1").toLocaleLowerCase();return e.indexOf("-")===0&&(e=e.substr(1)),e}let Ht=0;function Z(){const t=370+ ++Ht;return"F"+Math.random().toString(36).substr(3,3)+(+`${Date.now()}`).toString(36)+t.toString(36)+"c"}function Y(t,e,r){let i=t,s;return(e||"").split(".").forEach(n=>{s&&((!i[s]||typeof i[s]!="object")&&(i[s]={}),i=i[s]),s=n}),i[s]=r,i}function Jt(t){p(t.prototype,{initRender(){this.tempList={},this.clearOrgChildren()},initOrgChildren(){const e=this.$handle.ctxs;this.orgChildren=Object.keys(e).reduce((r,i)=>{if(e[i].parser.loadChildren!==!1){const s=e[i].rule.children;r[i]=h.trueArray(s)?[...s]:[]}return r},{})},clearOrgChildren(){this.orgChildren={}},getTypeSlot(e){const r=i=>{if(i){let s;return e.rule.field&&(s=i.$scopedSlots["field-"+Q(e.rule.field)]||i.$scopedSlots["field-"+e.rule.field]),s||(s=i.$scopedSlots["type-"+Q(e.type)]||i.$scopedSlots["type-"+e.type]),s||r(i.$pfc)}};return r(this.vm)},render(){if(!this.vm.isShow)return;this.$h=this.vm.$createElement,this.$manager.beforeRender();let e;const r=()=>this.renderList();return r.renderSlot=i=>this.renderList(i),r.renderName=i=>this.renderId(i),r.renderField=i=>this.renderId(i,"field"),this.vm.$scopedSlots.container?e=[this.vm.$scopedSlots.container(r)]:e=r(),this.$manager.render(e)},renderList(e){return this.sort.map(r=>e?this.renderSlot(this.$handle.ctxs[r],e):this.renderCtx(this.$handle.ctxs[r])).filter(r=>r!==void 0)},makeVm(e){const r=e.vm;if(r){if(h.Function(r))return R(()=>e.vm(this.$handle.getInjectData(e)));if(!r._isVue)return new b(r)}else return new b;return r},mergeGlobal(e){const r=this.$handle.options.global;r&&(e.cacheConfig||(e.cacheConfig=r[e.originType]||r[e.type]||r[e.trueType]||{}),e.prop=q({},[r["*"],e.cacheConfig,e.prop]))},setOptions(e){e.prop.optionsTo&&e.prop.options&&Y(e.prop,e.prop.optionsTo,e.prop.options)},deepSet(e){const r=e.rule.deep;r&&Object.keys(r).sort((i,s)=>i.length<s.length?-1:1).forEach(i=>{Y(e.prop,i,r[i])})},setTempProps(e,r){if(!e.$props)return;const{prop:i}=r,s=Object.keys(e.$props),n=this.injectProp(r),o=Object.keys(n);s.forEach(u=>{O(i.props,u)?e.$props[u]=i.props[u]:o.indexOf(u)>-1&&(e.$props[u]=n[u])});const a=e.$options.model&&e.$options.model.prop||"value";s.indexOf(a)>-1&&(e.$props[a]=i.value)},renderTemp(e){if(!b.compile)return At("当前使用的Vue构建版本不支持compile,无法使用template功能"),[];const r=e.prop,{id:i,key:s}=e;if(!this.tempList[i]){e.el||(e.el=this.makeVm(r),this.vm.$nextTick(()=>e.parser.mounted(e)));let u=e.el;e.input&&u.$on(u.$options.model&&u.$options.model.event||"input",l=>{this.onInput(e,l)}),this.tempList[i]={vm:u,template:b.compile(r.template)}}const{vm:n,template:o}=this.tempList[i];this.setTempProps(n,e);const a=o.render.call(n);return h.Undef(a.data)&&(a.data={}),a.key=s,a.data.ref=e.ref,a.data.key=s,a},parseSide(e,r){return h.Object(e)?q({props:{formCreateInject:r.prop.props.formCreateInject}},e):e},renderSides(e,r,i){const s=r[i?"rule":"prop"];return[this.renderRule(this.parseSide(s.prefix,r)),e,this.renderRule(this.parseSide(s.suffix,r))]},renderSlot(e,r){return e.rule.slot===r?this.renderCtx(e):void 0},renderId(e,r){const i=this.$handle[r==="field"?"fieldCtx":"nameCtx"][e];return i?i.map(s=>this.renderCtx(s,s.parent)):void 0},renderCtx(e,r){if(e.type==="hidden")return;const i=e.rule;if(!this.cache[e.id]||this.cache[e.id].slot!==i.slot){let s,n=i.cache!==!1;const o=e.trueType,a=!(h.Undef(i.display)||i.display);if(o==="template"&&!i.template)s=this.renderSides(this.renderChildren(e),e,!0),a&&this.display(s),s=this.item(e,s);else if(o==="fcFragment")s=this.renderChildren(e);else{e.initProp(),this.mergeGlobal(e),this.$manager.tidyRule(e),this.deepSet(e),this.setOptions(e),this.ctxProp(e);let u=e.prop;u.preview=!!(O(u,"preview")?u.preview:this.options.preview),u.props.formCreateInject=this.injectProp(e);const l=u.preview;if(u.hidden){this.setCache(e,void 0,r);return}if(o==="template"&&u.template)s=this.renderTemp(e),n=!1;else{let c=[];e.parser.renderChildren?c=e.parser.renderChildren(e):e.parser.loadChildren!==!1&&(c=this.renderChildren(e));const m=this.getTypeSlot(e);m?s=m({rule:i,prop:u,preview:l,children:c,api:this.$handle.api,model:u.model||{}}):s=l?e.parser.preview(c,e):e.parser.render(c,e)}s=this.renderSides(s,e),!(!e.input&&h.Undef(u.native))&&u.native!==!0&&(s=this.$manager.makeWrap(e,s)),a&&(s=this.display(s)),s=this.item(e,s)}return n&&this.setCache(e,s,r),s}return this.getCache(e)},display(e){if(Array.isArray(e)){const r=[];return e.forEach(i=>{if(Array.isArray(i))return this.display(i);this.none(i)&&r.push(i)}),r}else return this.none(e)},none(e){if(e&&e.data)return Array.isArray(e.data.style)?e.data.style.push({display:"none"}):h.String(e.data.style)?e.data.style+=";display:none;":e.data.style=[e.data.style,{display:"none"}],e},item(e,r){return this.$h("fcFragment",{slot:e.rule.slot,key:e.key},[r])},injectProp(e){this.vm.ctxInject[e.id]||E(this.vm.ctxInject,e.id,{api:this.$handle.api,form:this.fc.create,subForm:i=>{this.$handle.addSubForm(e,i)},getSubForm:()=>this.$handle.subForm[e.id],options:[],children:[],prop:{},preview:!1,id:e.id,field:e.field,rule:e.rule,input:e.input});const r=this.vm.ctxInject[e.id];return p(r,{preview:e.prop.preview,options:e.prop.options,children:e.rule.children,prop:function(){const i=y({},e.prop);return i.on=i.on?y({},i.on):{},delete i.model,i}()}),r},ctxProp(e){const{ref:r,key:i,rule:s}=e;this.$manager.mergeProp(e),e.parser.mergeProp(e);const n=[{ref:r,key:s.key||`${i}fc`,slot:void 0,on:{"hook:mounted":()=>{this.onMounted(e)},"fc.sub-form":o=>{this.$handle.addSubForm(e,o)},"fc.el":o=>{e.exportEl=o,o&&((o.$el||o).__rule__=e.rule)}}}];return e.input&&(this.vm.$props.disabled===!0&&(e.prop.props.disabled=!0),e.prop.model={value:this.$handle.getFormData(e),callback:o=>{this.onInput(e,o)},expression:`formData.${e.id}`}),T(n,e.prop),e.prop},onMounted(e){e.el=this.vm.$refs[e.ref],e.el&&((e.el.$el||e.el).__rule__=e.rule),e.parser.mounted(e),this.$handle.effect(e,"mounted")},onInput(e,r){this.$handle.onInput(e,r)},renderChildren(e){const{children:r}=e.rule,i=this.orgChildren[e.id],s=n=>!h.String(n)&&n.__fc__&&!this.$handle.ctxs[n.__fc__.id];return!h.trueArray(r)&&i?(this.$handle.deferSyncValue(()=>{i.forEach(n=>{n&&s(n)&&this.$handle.rmCtx(n.__fc__)})}),this.orgChildren[e.id]=[],[]):(i&&this.$handle.deferSyncValue(()=>{i.forEach(n=>{n&&r.indexOf(n)===-1&&s(n)&&this.$handle.rmCtx(n.__fc__)})}),r.map(n=>{if(n){if(h.String(n))return n;if(n.__fc__)return this.renderCtx(n.__fc__,e);n.type&&this.vm.$nextTick(()=>{this.$handle.loadChildren(r,e),this.$handle.refresh()})}}))},defaultRender(e,r){const i=e.prop;return i.component?this.vNode.makeComponent(i.component,i,r):this.vNode[e.type]?this.vNode[e.type](i,r):this.vNode[e.originType]?this.vNode[e.originType](i,r):this.vNode.make(Je(e.originType),i,r)},renderRule(e,r,i){if(!e)return;if(h.String(e))return e;let s;if(i)s=e.type;else if(s=e.is,e.type){s=V(e.type);const o=this.vNode.aliasMap[s];o&&(s=V(o))}if(!s)return;let n=[[r]];return h.trueArray(e.children)&&n.push(e.children.map(o=>this.renderRule(o))),this.$h(s,y({},e),n)}})}function ye(t){p(this,{$handle:t,fc:t.fc,vm:t.vm,$manager:t.$manager,vNode:new t.fc.CreateNode(t.vm)}),Te(this,{options(){return t.options},sort(){return t.sort}}),this.initCache(),this.initRender()}Ut(ye),Jt(ye);function zt(t){p(t.prototype,{parseInjectEvent(e,r){const i=e.inject||this.options.injectEvent;return this.parseEventLst(e,r,i)},parseEventLst(e,r,i,s){return Object.keys(r).forEach(n=>{const o=this.parseEvent(e,r[n],i,s);o&&(r[n]=o)}),r},parseEvent(e,r,i,s){if(h.Function(r)&&(i!==!1&&!h.Undef(i)||r.__inject))return this.inject(e,r,i);if(!s&&Array.isArray(r)&&r[0]&&(h.String(r[0])||h.Function(r[0])))return this.parseEventLst(e,r,i,!0);if(h.String(r)){const n=U(r);if(n&&r!==n)return n.__inject?this.parseEvent(e,n,i,!0):n}},parseEmit(e,r){let i={},s=e.rule,{emitPrefix:n,field:o,name:a,inject:u}=s,l=s[r?"emit":"nativeEmit"]||[];return h.trueArray(l)&&l.forEach(c=>{if(!c)return;let m,v=n||o||a;if(h.Object(c)&&(m=c.inject,c=c.name,v=c.prefix||v),v){r||(v=`native-${v}`);const k=Q(`${v}-${c}`),g=(...w)=>{this.vm.$emit(k,...w),this.vm.$emit("emit-event",k,...w)};if(g.__emit=!0,!m&&u===!1)i[c]=g;else{let w=m||u||this.options.injectEvent;i[c]=h.Undef(w)?g:this.inject(s,g,w)}}}),e.computed[r?"on":"nativeOn"]=i,i},getInjectData(e,r){const{option:i,rule:s}=this.vm.$options.propsData;return{api:this.api,$f:this.api,rule:s,self:e.__origin__,option:i,inject:r}},inject(e,r,i){if(r.__origin){if(this.watching&&!this.loading)return r;r=r.__origin}const s=this,n=function(...o){const a=s.getInjectData(e,i);return a.args=[...o],o.unshift(a),r.apply(this,o)};return n.__origin=r,n.__json=r.__json,n}})}const ze=["hook:updated","hook:mounted"];function Gt(t){p(t.prototype,{usePage(){const e=this.options.page;if(!e)return;let r=25,i=Wt(this.rules);h.Object(e)&&(e.first&&(r=parseInt(e.first,10)||r),e.limit&&(i=parseInt(e.limit,10)||i)),p(this,{first:r,limit:i,pageEnd:this.rules.length<=r}),this.bus.$on("page-end",()=>this.vm.$emit("page-end",this.api)),this.pageLoad()},pageLoad(){const e=()=>{this.pageEnd?(this.vm.$off(ze,e),this.bus.$emit("page-end")):(this.first+=this.limit,this.pageEnd=this.rules.length<=this.first,this.loadRule(),this.refresh())};this.vm.$on(ze,e)}})}function Wt(t){return t.length<31?31:Math.ceil(t.length/3)}function Kt(t){p(t.prototype,{clearNextTick(){this.nextTick&&clearTimeout(this.nextTick),this.nextTick=null},bindNextTick(e){this.clearNextTick(),this.nextTick=setTimeout(()=>{e(),this