UNPKG

@form-create/iview

Version:

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

1,779 lines (1,778 loc) 124 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)}})(); var yt = Object.defineProperty, gt = Object.defineProperties; var $t = Object.getOwnPropertyDescriptors; var Se = Object.getOwnPropertySymbols; var vt = Object.prototype.hasOwnProperty, bt = Object.prototype.propertyIsEnumerable; var Ee = (t, e, r) => e in t ? yt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, y = (t, e) => { for (var r in e || (e = {})) vt.call(e, r) && Ee(t, r, e[r]); if (Se) for (var r of Se(e)) bt.call(e, r) && Ee(t, r, e[r]); return t; }, q = (t, e) => gt(t, $t(e)); import P from "vue"; function Ct(t) { return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t; } function ae() { return ae = 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; }, ae.apply(this, arguments); } var _t = ["attrs", "props", "domProps"], Ot = ["class", "style", "directives"], kt = ["on", "nativeOn"], wt = function(t) { return t.reduce(function(e, r) { for (var i in r) if (!e[i]) e[i] = r[i]; else if (_t.indexOf(i) !== -1) e[i] = ae({}, e[i], r[i]); else if (Ot.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 (kt.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] ? Ft(e[i][l], r[i][l]) : r[i][l]; else e[i] = r[i]; return e; }, {}); }, Ft = function(t, e) { return function() { t && t.apply(this, arguments), e && e.apply(this, arguments); }; }, St = wt; const C = /* @__PURE__ */ Ct(St); function Y(t, e) { return Object.keys(t).reduce((r, i) => ((!e || e.indexOf(i) === -1) && r.push(t[i]), r), []); } const Et = "fcCheckbox", Rt = { name: Et, 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", C([{}, 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", C([{}, { props: i }, { key: "" + r + "-" + e.value }])); }), Y(this.$slots)]); }, mounted() { this.$emit("fc.el", this.$refs.el); } }; function I(t) { return Array.isArray(t) ? t : [null, void 0, ""].indexOf(t) > -1 ? [] : [t]; } const It = "fcFrame"; function ze(t) { return { name: It, 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: I(this.value), previewVisible: !1, frameVisible: !1, previewImage: "" }; }, watch: { value(e) { this.fileList = I(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", C([{}, { 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", C([{}, { 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", C([{}, { 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", C([{}, { 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", C([{}, { 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", C([{}, { 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", C([{}, { 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 We = ze({ fileIcon: "md-document", fileUpIcon: "ios-folder-open" }); We.v2 = ze({ fileIcon: "document-text", fileUpIcon: "folder" }); const jt = "fcRadio", At = { name: jt, 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", C([{}, 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", C([{}, { props: i }, { key: "" + r + "-" + e.value }])); }), Y(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 k(t, e) { return {}.hasOwnProperty.call(t, e); } const Vt = "fcSelect", Pt = { name: Vt, functional: !0, props: { formCreateInject: { type: Object, required: !0 } }, render(t, e) { const r = (n, o) => { const a = n.slot; return t("Option", C([{}, { 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", C([{}, e.data, { ref: "el" }]), [(Array.isArray(s) ? s : []).map((n, o) => k(n || "", "options") ? i(n, o) : r(n, o)), e.children]); }, mounted() { this.$emit("fc.el", this.$refs.el); } }, Dt = "fcTree", Tt = { name: Dt, 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 = I(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", C([{}, this.formCreateInject.prop, { ref: "tree" }, { on: e }]), [Y(this.$slots)]); }, mounted() { this.$emit("fc.el", this.$refs.tree); } }; function Re(t) { return { url: t, name: Bt(t) }; } function Bt(t) { return ("" + t).split("/").pop(); } const Lt = "fcUpload"; function Ge(t) { return { name: Lt, 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 = I(this.value).map(Re); }, watch: { value(e) { this.$refs.upload.fileList.every((r) => !r.status || r.status === "finished") && (this.$refs.upload.fileList = I(e).map(Re), 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", C([{}, { 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", C([{}, { 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", C([{}, 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", C([{}, { props: { type: this.uploadType === "file" ? "ios-cloud-upload-outline" : t.imgUpIcon, size: 20 } }]))])]) : null, Y(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", C([{}, { 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 Ke = Ge({ fileIcon: "md-document", imgUpIcon: "md-images" }); Ke.v2 = Ge({ fileIcon: "document-text", imgUpIcon: "image" }); function w(t, e, r) { P.set(t, e, r); } function T(t, e) { P.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 && w(t, s, []); else if (n._clone && r !== void 0) if (r) n = n.getRule(), o && w(t, s, {}); else { w(t, s, n._clone()); continue; } else o && w(t, s, {}); t[s] = z(t[s], n, r); } else w(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 B(t) { return z({}, { value: t }).value; } const Nt = 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) && w(t, i, e[i]); return t; }; function p() { return Nt.apply(this, arguments); } const Mt = "fcGroup", Ut = { name: Mt, 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 = B(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 && k(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 = B(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, C([{ 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]); } }, qt = "fcSubForm", Ht = { name: qt, 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, C([{}, { on: { "update:value": this.formData, "emit-event": this.emitEvent, input: this.add$f } }, {}, { props: { rule: e, option: r, disabled: this.disabled, extendOption: !0 } }])); } }, Jt = [ Rt, At, Pt, Tt, Ht, We, Ke, Ut ], Ie = "FormCreate", le = (t, e) => { if (!(!t || t === e)) { if (t.formCreateInject) return t.formCreateInject; if (t.$parent) return le(t.$parent, e); } }; function zt(t, e, r) { return { name: Ie, componentName: Ie, 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 = le(i, i.$pfc); if (a) { let u; i.isMore ? (u = I(a.getSubForm()), u.push(s)) : u = s, a.subForm(u); } } }, o = () => { const a = le(i, i.$pfc); if (a) if (i.isMore) { const u = I(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 xe = ["attrs", "props", "domProps", "scopedSlots"], Xe = ["class", "style", "directives"], Qe = ["on", "nativeOn"], D = (t, e = {}, r = {}) => { const i = [...xe, ...r.normal || []], s = [...Xe, ...r.array || []], n = [...Qe, ...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] = D([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] = Wt(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); }, Wt = (t, e) => function() { t && t.apply(this, arguments), e && e.apply(this, arguments); }, Ze = ["type", "slot", "emitPrefix", "value", "name", "native", "hidden", "display", "inject", "options", "emit", "nativeEmit", "link", "prefix", "suffix", "update", "sync", "optionsTo", "key", "preview", "component", "cache"], pe = ["validate", "children", "control"], me = ["effect", "deep"]; function Gt() { return [...Ze, ...xe, ...Xe, ...Qe, ...pe, ...me]; } function ye(t, e, r) { return `[form-create ${t}]: ${e}`; } function Kt(t, e) { console.warn(ye("tip", t)); } function ge(t, e) { console.error(ye("err", t)); } function xt(t) { ge(t.toString()), console.error(t); } const ue = "[[FORM-CREATE-PREFIX-", fe = "-FORM-CREATE-SUFFIX]]"; function Ye(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 ue + i + fe; } }, e); } function te(t) { return new Function("return " + t)(); } function M(t, e) { if (t && h.String(t) && t.length > 4) { let r = t.trim(), i = !1; try { if (r.indexOf(fe) > 0 && r.indexOf(ue) === 0) r = r.replace(fe, "").replace(ue, ""), 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 = te("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 = te(r); } catch (n) { s = te("function " + r); } return s.__json = t, s; } catch (s) { ge(`解析失败:${r} err: ${s}`); return; } } return t; } function Xt(t, e) { return JSON.parse(t, function(r, i) { return h.Undef(i) || !i.indexOf ? i : M(i, e); }); } function he(t, e) { return { value: t, enumerable: !1, configurable: !1, writable: !!e }; } function $e(t) { return et([t])[0]; } function et(t, e) { return z([], [...t], e || !1); } function U(t, e) { return D(Array.isArray(e) ? e : [e], t, { array: pe, normal: me }), t; } function je(t) { const e = h.Function(t.getRule) ? t.getRule() : t; return e.type || (e.type = "input"), e; } function Qt(t, e) { return t ? (Object.keys(e || {}).forEach((r) => { e[r] && (t[r] = U(t[r] || {}, e[r])); }), t) : e; } function tt(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 E(t, e) { try { e = t(); } catch (r) { xt(r); } return e; } const Ae = (t, e) => typeof t == "string" ? String(e) : typeof t == "number" ? Number(e) : e, J = { "==": (t, e) => JSON.stringify(t) === JSON.stringify(Ae(t, e)), "!=": (t, e) => !J["=="](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(Ae(t[0], e)) > -1; }, notOn(t, e) { return !J.on(t, e); }, in(t, e) { return e && e.indexOf && e.indexOf(t) > -1; }, notIn(t, e) { return !J.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 rt() { return { props: {}, on: {}, options: [], children: [], effect: {}, hidden: !1, display: !0, value: void 0 }; } function F(t, e) { return (r, i, s, n = {}) => { const o = new ve(t, r, i, s, n); return e && (h.Function(e) ? e(o) : o.props(e)), o; }; } function ve(t, e, r, i, s) { this._data = p(rt(), { type: t, title: e, field: r, value: i, props: s || {} }), this.event = this.on; } p(ve.prototype, { getRule() { return this._data; }, setProp(t, e) { return w(this._data, t, e), this; }, _clone() { const t = new this.constructor(); return t._data = $e(this._data), t; } }); function it(t) { t.forEach((e) => { ve.prototype[e] = function(r) { return U(this._data, { [e]: arguments.length < 2 ? r : { [r]: arguments[1] } }), this; }; }); } it(Gt()); const nt = F(""); function Zt(t, e, r) { let i = nt("", e); return i._data.type = t, i._data.title = r, i; } function Ve(t, e, r, i) { let s = nt("", r); return s._data.type = "template", s._data.template = t, s._data.title = i, s._data.vm = e, s; } function Yt() { return { create: Zt, createTmp: Ve, template: Ve, factory: F }; } function er(t, e, r) { const i = `fail to ${t} ${r.status}'`, s = new Error(i); return s.status = r.status, s.url = t, s; } function Pe(t) { const e = t.responseText || t.response; if (!e) return e; try { return JSON.parse(e); } catch (r) { return e; } } function st(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(er(r, t, e), Pe(e)); t.onSuccess(Pe(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 tr(t) { return new Promise((e, r) => { st(q(y({}, t), { onSuccess(i) { let s = (o) => o; const n = M(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 K(t) { return B(t); } function rr(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) => { w(l.rule, o, a), t.$render.clearCache(l); }); }); } function i() { co