@form-create/element-ui
Version:
element-ui动态表单|form-create is a form generation component that can generate dynamic rendering, data collection, verification and submission functions through JSON. Supports 5 UI frameworks, and supports the generation of any Vue components. Built-in 20 ki
1,771 lines (1,571 loc) • 179 kB
JavaScript
/*!
* @form-create/element-ui v3.1.16
* (c) 2018-2022 xaboy
* Github https://github.com/xaboy/form-create
* Released under the MIT License.
*/
import { defineComponent, toRef, resolveComponent, createVNode, mergeProps as mergeProps$1, openBlock, createElementBlock, createElementVNode, isVNode, nextTick, Fragment, markRaw, reactive, getCurrentInstance, provide, inject, toRefs, onMounted, onBeforeUnmount, onUpdated, watch, computed, withDirectives, resolveDirective, createApp, h, ref } from 'vue';
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) {
symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
}
keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
function _typeof(obj) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
return true;
} catch (e) {
return false;
}
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
} else if (call !== void 0) {
throw new TypeError("Derived constructors may only return object or undefined");
}
return _assertThisInitialized(self);
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived),
result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function getSlot(slots, exclude) {
return Object.keys(slots).reduce(function (lst, name) {
if (!exclude || exclude.indexOf(name) === -1) {
lst.push(slots[name]);
}
return lst;
}, []);
}
var NAME$9 = 'fcCheckbox';
var Checkbox = defineComponent({
name: NAME$9,
inheritAttrs: false,
props: {
formCreateInject: Object,
modelValue: {
type: Array,
"default": function _default() {
return [];
}
},
type: String
},
emits: ['update:modelValue'],
setup: function setup(props, _) {
var options = toRef(props.formCreateInject, 'options', []);
var value = toRef(props, 'modelValue');
var _options = function _options() {
return Array.isArray(options.value) ? options.value : [];
};
return {
options: _options,
value: value,
onInput: function onInput(n) {
_.emit('update:modelValue', n);
}
};
},
render: function render() {
var _this$$slots$default,
_this$$slots,
_this = this;
var name = this.type === 'button' ? 'ElCheckboxButton' : 'ElCheckbox';
var Type = resolveComponent(name);
return createVNode(resolveComponent("ElCheckboxGroup"), mergeProps$1(this.$attrs, {
"modelValue": this.value,
"onUpdate:modelValue": this.onInput
}), _objectSpread2({
"default": function _default() {
return [_this.options().map(function (opt, index) {
var props = _objectSpread2({}, opt);
var value = props.value;
delete props.value;
return createVNode(Type, mergeProps$1(props, {
"label": value,
"key": name + index + '-' + opt.value
}), {
"default": function _default() {
return [props.label || props.value || ''];
}
});
}), (_this$$slots$default = (_this$$slots = _this.$slots)["default"]) === null || _this$$slots$default === void 0 ? void 0 : _this$$slots$default.call(_this$$slots)];
}
}, getSlot(this.$slots, ['default'])));
}
});
function toArray(value) {
return Array.isArray(value) ? value : [null, undefined, ''].indexOf(value) > -1 ? [] : [value];
}
// https://github.com/developit/mitt
function Mitt(all) {
all = all || new Map();
var mitt = {
$on: function $on(type, handler) {
var handlers = all.get(type);
var added = handlers && handlers.push(handler);
if (!added) {
all.set(type, [handler]);
}
},
$once: function $once(type, handler) {
handler._once = true;
mitt.$on(type, handler);
},
$off: function $off(type, handler) {
var handlers = all.get(type);
if (handlers) {
handlers.splice(handlers.indexOf(handler) >>> 0, 1);
}
},
$emit: function $emit(type) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
(all.get(type) || []).slice().map(function (handler) {
if (handler._once) {
mitt.$off(type, handler);
delete handler._once;
}
handler.apply(void 0, args);
});
(all.get('*') || []).slice().map(function (handler) {
handler(type, args);
});
}
};
return mitt;
}
function styleInject(css, ref) {
if ( ref === void 0 ) ref = {};
var insertAt = ref.insertAt;
if (!css || typeof document === 'undefined') { return; }
var head = document.head || document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.type = 'text/css';
if (insertAt === 'top') {
if (head.firstChild) {
head.insertBefore(style, head.firstChild);
} else {
head.appendChild(style);
}
} else {
head.appendChild(style);
}
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
}
var css_248z$2 = "._fc-frame ._fc-files img{display:inline-block;height:100%;vertical-align:top;width:100%}._fc-frame ._fc-upload-btn{border:1px dashed #c0ccda;cursor:pointer}._fc-frame ._fc-upload-cover{background:rgba(0,0,0,.6);bottom:0;left:0;opacity:0;position:absolute;right:0;top:0;-webkit-transition:opacity .3s;-o-transition:opacity .3s;transition:opacity .3s}._fc-frame ._fc-upload-cover i{color:#fff;cursor:pointer;font-size:20px;margin:0 2px}._fc-frame ._fc-files:hover ._fc-upload-cover{opacity:1}._fc-frame .el-upload{display:block}._fc-frame ._fc-upload-icon{cursor:pointer}._fc-files,._fc-frame ._fc-upload-btn{background:#fff;border:1px solid #c0ccda;border-radius:4px;-webkit-box-shadow:2px 2px 5px rgba(0,0,0,.1);box-shadow:2px 2px 5px rgba(0,0,0,.1);-webkit-box-sizing:border-box;box-sizing:border-box;display:inline-block;height:58px;line-height:58px;margin-right:4px;overflow:hidden;position:relative;text-align:center;width:58px}";
styleInject(css_248z$2);
var script$8 = {
name: 'IconCircleClose'
};
var _hoisted_1$8 = {
"class": "icon",
viewBox: "0 0 1024 1024",
xmlns: "http://www.w3.org/2000/svg"
};
var _hoisted_2$8 = /*#__PURE__*/createElementVNode("path", {
fill: "currentColor",
d: "M466.752 512l-90.496-90.496a32 32 0 0145.248-45.248L512 466.752l90.496-90.496a32 32 0 1145.248 45.248L557.248 512l90.496 90.496a32 32 0 11-45.248 45.248L512 557.248l-90.496 90.496a32 32 0 01-45.248-45.248L466.752 512z"
}, null, -1);
var _hoisted_3$8 = /*#__PURE__*/createElementVNode("path", {
fill: "currentColor",
d: "M512 896a384 384 0 100-768 384 384 0 000 768zm0 64a448 448 0 110-896 448 448 0 010 896z"
}, null, -1);
var _hoisted_4$2 = [_hoisted_2$8, _hoisted_3$8];
function render$8(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("svg", _hoisted_1$8, _hoisted_4$2);
}
script$8.render = render$8;
var script$7 = {
name: 'IconDocument'
};
var _hoisted_1$7 = {
"class": "icon",
viewBox: "0 0 1024 1024",
xmlns: "http://www.w3.org/2000/svg"
};
var _hoisted_2$7 = /*#__PURE__*/createElementVNode("path", {
fill: "currentColor",
d: "M832 384H576V128H192v768h640V384zm-26.496-64L640 154.496V320h165.504zM160 64h480l256 256v608a32 32 0 01-32 32H160a32 32 0 01-32-32V96a32 32 0 0132-32zm160 448h384v64H320v-64zm0-192h160v64H320v-64zm0 384h384v64H320v-64z"
}, null, -1);
var _hoisted_3$7 = [_hoisted_2$7];
function render$7(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("svg", _hoisted_1$7, _hoisted_3$7);
}
script$7.render = render$7;
var script$6 = {
name: 'IconDelete'
};
var _hoisted_1$6 = {
"class": "icon",
viewBox: "0 0 1024 1024",
xmlns: "http://www.w3.org/2000/svg"
};
var _hoisted_2$6 = /*#__PURE__*/createElementVNode("path", {
fill: "currentColor",
d: "M160 256H96a32 32 0 010-64h256V95.936a32 32 0 0132-32h256a32 32 0 0132 32V192h256a32 32 0 110 64h-64v672a32 32 0 01-32 32H192a32 32 0 01-32-32V256zm448-64v-64H416v64h192zM224 896h576V256H224v640zm192-128a32 32 0 01-32-32V416a32 32 0 0164 0v320a32 32 0 01-32 32zm192 0a32 32 0 01-32-32V416a32 32 0 0164 0v320a32 32 0 01-32 32z"
}, null, -1);
var _hoisted_3$6 = [_hoisted_2$6];
function render$6(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("svg", _hoisted_1$6, _hoisted_3$6);
}
script$6.render = render$6;
var script$5 = {
name: 'IconView'
};
var _hoisted_1$5 = {
"class": "icon",
viewBox: "0 0 1024 1024",
xmlns: "http://www.w3.org/2000/svg"
};
var _hoisted_2$5 = /*#__PURE__*/createElementVNode("path", {
fill: "currentColor",
d: "M512 160c320 0 512 352 512 352S832 864 512 864 0 512 0 512s192-352 512-352zm0 64c-225.28 0-384.128 208.064-436.8 288 52.608 79.872 211.456 288 436.8 288 225.28 0 384.128-208.064 436.8-288-52.608-79.872-211.456-288-436.8-288zm0 64a224 224 0 110 448 224 224 0 010-448zm0 64a160.192 160.192 0 00-160 160c0 88.192 71.744 160 160 160s160-71.808 160-160-71.744-160-160-160z"
}, null, -1);
var _hoisted_3$5 = [_hoisted_2$5];
function render$5(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("svg", _hoisted_1$5, _hoisted_3$5);
}
script$5.render = render$5;
var script$4 = {
name: 'IconFolderOpened'
};
var _hoisted_1$4 = {
"class": "icon",
viewBox: "0 0 1024 1024",
xmlns: "http://www.w3.org/2000/svg"
};
var _hoisted_2$4 = /*#__PURE__*/createElementVNode("path", {
fill: "currentColor",
d: "M878.08 448H241.92l-96 384h636.16l96-384zM832 384v-64H485.76L357.504 192H128v448l57.92-231.744A32 32 0 01216.96 384H832zm-24.96 512H96a32 32 0 01-32-32V160a32 32 0 0132-32h287.872l128.384 128H864a32 32 0 0132 32v96h23.04a32 32 0 0131.04 39.744l-112 448A32 32 0 01807.04 896z"
}, null, -1);
var _hoisted_3$4 = [_hoisted_2$4];
function render$4(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("svg", _hoisted_1$4, _hoisted_3$4);
}
script$4.render = render$4;
function _isSlot$1(s) {
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
}
var NAME$8 = 'fcFrame';
var Frame = defineComponent({
name: NAME$8,
props: {
type: {
type: String,
"default": 'input'
},
field: String,
helper: {
type: Boolean,
"default": true
},
disabled: {
type: Boolean,
"default": false
},
src: {
type: String,
required: true
},
icon: {
type: String,
"default": 'IconFolderOpened'
},
width: {
type: String,
"default": '500px'
},
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": undefined
},
title: String,
allowRemove: {
type: Boolean,
"default": true
},
onOpen: {
type: Function,
"default": function _default() {}
},
onOk: {
type: Function,
"default": function _default() {}
},
onCancel: {
type: Function,
"default": function _default() {}
},
onLoad: {
type: Function,
"default": function _default() {}
},
onBeforeRemove: {
type: Function,
"default": function _default() {}
},
onRemove: {
type: Function,
"default": function _default() {}
},
onHandle: Function,
modal: {
type: Object,
"default": function _default() {
return {};
}
},
srcKey: [String, Number],
modelValue: [Array, String, Number, Object],
previewMask: undefined,
footer: {
type: Boolean,
"default": true
},
reload: {
type: Boolean,
"default": true
},
closeBtn: {
type: Boolean,
"default": true
},
okBtn: {
type: Boolean,
"default": true
},
formCreateInject: Object
},
emits: ['update:modelValue', 'change'],
components: {
IconFolderOpened: script$4,
IconView: script$5
},
data: function data() {
return {
fileList: toArray(this.modelValue),
previewVisible: false,
frameVisible: false,
previewImage: '',
bus: new Mitt()
};
},
watch: {
modelValue: function modelValue(n) {
this.fileList = toArray(n);
}
},
methods: {
close: function close() {
this.closeModel(true);
},
closeModel: function closeModel(close) {
this.bus.$emit(close ? '$close' : '$ok');
if (this.reload) {
this.bus.$off('$ok');
this.bus.$off('$close');
}
this.frameVisible = false;
},
handleCancel: function handleCancel() {
this.previewVisible = false;
},
showModel: function showModel() {
if (this.disabled || false === this.onOpen()) {
return;
}
this.frameVisible = true;
},
input: function input() {
var n = this.fileList;
var val = this.maxLength === 1 ? n[0] || '' : n;
this.$emit('update:modelValue', val);
this.$emit('change', val);
},
makeInput: function makeInput() {
var _this = this;
return createVNode(resolveComponent("ElInput"), mergeProps$1({
type: 'text',
modelValue: this.fileList.map(function (v) {
return _this.getSrc(v);
}).toString(),
readonly: true
}, {
"key": 1
}), {
append: function append() {
return createVNode(resolveComponent("ElButton"), {
"icon": resolveComponent(_this.icon),
"onClick": function onClick() {
return _this.showModel();
}
}, null);
},
suffix: function suffix() {
return _this.fileList.length ? createVNode(resolveComponent("ElIcon"), {
"class": "el-input__icon _fc-upload-icon",
"onClick": function onClick() {
_this.fileList = [];
_this.input();
}
}, {
"default": function _default() {
return [createVNode(script$8, null, null)];
}
}) : null;
}
});
},
makeGroup: function makeGroup(children) {
if (!this.maxLength || this.fileList.length < this.maxLength) {
children.push(this.makeBtn());
}
return createVNode("div", {
"key": 2
}, [children]);
},
makeItem: function makeItem(index, children) {
return createVNode("div", {
"class": "_fc-files",
"key": '3' + index
}, [children]);
},
valid: function valid(f) {
var field = this.formCreateInject.field || this.field;
if (field && f !== field) {
throw new Error('[frame]无效的字段值');
}
},
makeIcons: function makeIcons(val, index) {
if (this.handleIcon !== false || this.allowRemove === true) {
var icons = [];
if (this.type !== 'file' && this.handleIcon !== false || this.type === 'file' && this.handleIcon) {
icons.push(this.makeHandleIcon(val, index));
}
if (this.allowRemove) {
icons.push(this.makeRemoveIcon(val, index));
}
return createVNode("div", {
"class": "_fc-upload-cover",
"key": 4
}, [icons]);
}
},
makeHandleIcon: function makeHandleIcon(val, index) {
var _this2 = this;
var Type = resolveComponent(this.handleIcon === true || this.handleIcon === undefined ? 'icon-view' : this.handleIcon);
return createVNode(resolveComponent("ElIcon"), {
"onClick": function onClick() {
return _this2.handleClick(val);
},
"key": '5' + index
}, {
"default": function _default() {
return [createVNode(Type, null, null)];
}
});
},
makeRemoveIcon: function makeRemoveIcon(val, index) {
var _this3 = this;
return createVNode(resolveComponent("ElIcon"), {
"onClick": function onClick() {
return _this3.handleRemove(val);
},
"key": '6' + index
}, {
"default": function _default() {
return [createVNode(script$6, null, null)];
}
});
},
makeFiles: function makeFiles() {
var _this4 = this;
return this.makeGroup(this.fileList.map(function (src, index) {
return _this4.makeItem(index, [createVNode(resolveComponent("ElIcon"), {
"onClick": function onClick() {
return _this4.handleClick(src);
}
}, {
"default": function _default() {
return [createVNode(script$7, null, null)];
}
}), _this4.makeIcons(src, index)]);
}));
},
makeImages: function makeImages() {
var _this5 = this;
return this.makeGroup(this.fileList.map(function (src, index) {
return _this5.makeItem(index, [createVNode("img", {
"src": _this5.getSrc(src)
}, null), _this5.makeIcons(src, index)]);
}));
},
makeBtn: function makeBtn() {
var _this6 = this;
var Type = resolveComponent(this.icon);
return createVNode("div", {
"class": "_fc-upload-btn",
"onClick": function onClick() {
return _this6.showModel();
},
"key": 7
}, [createVNode(resolveComponent("ElIcon"), null, {
"default": function _default() {
return [createVNode(Type, null, null)];
}
})]);
},
handleClick: function handleClick(src) {
if (this.onHandle) {
return this.onHandle(src);
} else {
this.previewImage = this.getSrc(src);
this.previewVisible = true;
}
},
handleRemove: function handleRemove(src) {
if (this.disabled) {
return;
}
if (false !== this.onBeforeRemove(src)) {
this.fileList.splice(this.fileList.indexOf(src), 1);
this.input();
this.onRemove(src);
}
},
getSrc: function getSrc(src) {
return !this.srcKey ? src : src[this.srcKey];
},
frameLoad: function frameLoad(iframe) {
var _this7 = this;
this.onLoad(iframe);
try {
if (this.helper === true) {
iframe['form_create_helper'] = {
api: this.formCreateInject.api,
close: function close(field) {
_this7.valid(field);
_this7.closeModel();
},
set: function set(field, value) {
_this7.valid(field);
!_this7.disabled && _this7.$emit('update:modelValue', value);
},
get: function get(field) {
_this7.valid(field);
return _this7.modelValue;
},
onOk: function onOk(fn) {
return _this7.bus.$on('$ok', fn);
},
onClose: function onClose(fn) {
return _this7.bus.$on('$close', fn);
}
};
}
} catch (e) {
console.error(e);
}
},
makeFooter: function makeFooter() {
var _this8 = this;
var _this$$props = this.$props,
okBtnText = _this$$props.okBtnText,
closeBtnText = _this$$props.closeBtnText,
closeBtn = _this$$props.closeBtn,
okBtn = _this$$props.okBtn,
footer = _this$$props.footer;
if (!footer) {
return;
}
return createVNode("div", null, [closeBtn ? createVNode(resolveComponent("ElButton"), {
"onClick": function onClick() {
return _this8.onCancel() !== false && (_this8.frameVisible = false);
}
}, _isSlot$1(closeBtnText) ? closeBtnText : {
"default": function _default() {
return [closeBtnText];
}
}) : null, okBtn ? createVNode(resolveComponent("ElButton"), {
"type": "primary",
"onClick": function onClick() {
return _this8.onOk() !== false && _this8.closeModel();
}
}, _isSlot$1(okBtnText) ? okBtnText : {
"default": function _default() {
return [okBtnText];
}
}) : null]);
}
},
render: function render() {
var _this9 = this;
var type = this.type;
var node;
if (type === 'input') {
node = this.makeInput();
} else if (type === 'image') {
node = this.makeImages();
} else {
node = this.makeFiles();
}
var _this$$props2 = this.$props,
_this$$props2$width = _this$$props2.width,
width = _this$$props2$width === void 0 ? '30%' : _this$$props2$width,
height = _this$$props2.height,
src = _this$$props2.src,
title = _this$$props2.title,
modalTitle = _this$$props2.modalTitle;
nextTick(function () {
if (_this9.$refs.frame) {
_this9.frameLoad(_this9.$refs.frame.contentWindow || {});
}
});
return createVNode("div", {
"class": "_fc-frame"
}, [node, createVNode(resolveComponent("ElDialog"), {
"appendToBody": true,
"modal": this.previewMask,
"title": modalTitle,
"modelValue": this.previewVisible,
"onClose": this.handleCancel
}, {
"default": function _default() {
return [createVNode("img", {
"style": "width: 100%",
"src": _this9.previewImage
}, null)];
}
}), createVNode(resolveComponent("ElDialog"), mergeProps$1({
"appendToBody": true
}, _objectSpread2({
width: width,
title: title
}, this.modal), {
"modelValue": this.frameVisible,
"onClose": function onClose() {
return _this9.closeModel(true);
}
}), {
"default": function _default() {
return [_this9.frameVisible || !_this9.reload ? createVNode("iframe", {
"ref": "frame",
"src": src,
"frameBorder": "0",
"style": {
height: height,
'border': '0 none',
'width': '100%'
}
}, null) : null];
},
footer: function footer() {
return _this9.makeFooter();
}
})]);
},
beforeMount: function beforeMount() {
var _this$formCreateInjec = this.formCreateInject,
name = _this$formCreateInjec.name,
field = _this$formCreateInjec.field,
api = _this$formCreateInjec.api;
name && api.on('fc:closeModal:' + name, this.close);
field && api.on('fc:closeModal:' + field, this.close);
},
beforeUnmount: function beforeUnmount() {
var _this$formCreateInjec2 = this.formCreateInject,
name = _this$formCreateInjec2.name,
field = _this$formCreateInjec2.field,
api = _this$formCreateInjec2.api;
name && api.off('fc:closeModal:' + name, this.close);
field && api.off('fc:closeModal:' + field, this.close);
}
});
var NAME$7 = 'fcRadio';
var Radio = defineComponent({
name: NAME$7,
inheritAttrs: false,
props: {
formCreateInject: Object,
modelValue: {
type: [String, Number, Boolean],
"default": ''
},
type: String
},
emits: ['update:modelValue'],
setup: function setup(props, _) {
var options = toRef(props.formCreateInject, 'options', []);
var value = toRef(props, 'modelValue');
var _options = function _options() {
return Array.isArray(options.value) ? options.value : [];
};
return {
options: _options,
value: value,
onInput: function onInput(n) {
_.emit('update:modelValue', n);
}
};
},
render: function render() {
var _this$$slots$default,
_this$$slots,
_this = this;
var name = this.type === 'button' ? 'ElRadioButton' : 'ElRadio';
var Type = resolveComponent(name);
return createVNode(resolveComponent("ElRadioGroup"), mergeProps$1(this.$attrs, {
"modelValue": this.value,
"onUpdate:modelValue": this.onInput
}), _objectSpread2({
"default": function _default() {
return [_this.options().map(function (opt, index) {
var props = _objectSpread2({}, opt);
var value = props.value;
delete props.value;
return createVNode(Type, mergeProps$1(props, {
"label": value,
"key": name + index + '-' + opt.value
}), {
"default": function _default() {
return [props.label || props.value || ''];
}
});
}), (_this$$slots$default = (_this$$slots = _this.$slots)["default"]) === null || _this$$slots$default === void 0 ? void 0 : _this$$slots$default.call(_this$$slots)];
}
}, getSlot(this.$slots, ['default'])));
}
});
var NAME$6 = 'fcSelect';
var Select = defineComponent({
name: NAME$6,
inheritAttrs: false,
props: {
formCreateInject: Object,
modelValue: {
type: [Array, String, Number, Boolean, Object],
"default": undefined
},
type: String
},
emits: ['update:modelValue'],
setup: function setup(props) {
var options = toRef(props.formCreateInject, 'options', []);
var value = toRef(props, 'modelValue');
var _options = function _options() {
return Array.isArray(options.value) ? options.value : [];
};
return {
options: _options,
value: value
};
},
render: function render() {
var _this = this,
_this$$slots$default,
_this$$slots;
return createVNode(resolveComponent("ElSelect"), mergeProps$1(this.$attrs, {
"modelValue": this.value,
"onUpdate:modelValue": function onUpdateModelValue(v) {
return _this.$emit('update:modelValue', v);
}
}), _objectSpread2({
"default": function _default() {
return [_this.options().map(function (props, index) {
return createVNode(resolveComponent("ElOption"), mergeProps$1(props, {
"key": '' + index + '-' + props.value
}), null);
}), (_this$$slots$default = (_this$$slots = _this.$slots)["default"]) === null || _this$$slots$default === void 0 ? void 0 : _this$$slots$default.call(_this$$slots)];
}
}, getSlot(this.$slots, ['default'])));
}
});
var NAME$5 = 'fcTree';
var Tree = defineComponent({
name: NAME$5,
inheritAttrs: false,
formCreateParser: {
mergeProp: function mergeProp(ctx) {
var props = ctx.prop.props;
if (!props.nodeKey) props.nodeKey = 'id';
if (!props.props) props.props = {
label: 'title'
};
}
},
props: {
type: String,
modelValue: {
type: [Array, String, Number],
"default": function _default() {
return [];
}
}
},
emits: ['update:modelValue'],
watch: {
modelValue: function modelValue() {
this.setValue();
}
},
methods: {
updateValue: function updateValue() {
if (!this.$refs.tree) return;
var value;
if (this.type === 'selected') {
value = this.$refs.tree.getCurrentKey();
} else {
value = this.$refs.tree.getCheckedKeys();
}
this.$emit('update:modelValue', value);
},
setValue: function setValue() {
if (!this.$refs.tree) return;
var type = this.type;
if (type === 'selected') {
this.$refs.tree.setCurrentKey(this.modelValue);
} else {
this.$refs.tree.setCheckedKeys(toArray(this.modelValue));
}
}
},
render: function render() {
return createVNode(resolveComponent("ElTree"), mergeProps$1(this.$attrs, {
"ref": "tree",
"onCheck": this.updateValue,
"onNode-click": this.updateValue
}), this.$slots);
},
mounted: function mounted() {
this.setValue();
}
});
var css_248z$1 = "._fc-exceed .el-upload{display:none}";
styleInject(css_248z$1);
var script$3 = {
name: 'IconUpload'
};
var _hoisted_1$3 = {
"class": "icon",
viewBox: "0 0 1024 1024",
xmlns: "http://www.w3.org/2000/svg"
};
var _hoisted_2$3 = /*#__PURE__*/createElementVNode("path", {
fill: "currentColor",
d: "M160 832h704a32 32 0 110 64H160a32 32 0 110-64zm384-578.304V704h-64V247.296L237.248 490.048 192 444.8 508.8 128l316.8 316.8-45.312 45.248L544 253.696z"
}, null, -1);
var _hoisted_3$3 = [_hoisted_2$3];
function render$3(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("svg", _hoisted_1$3, _hoisted_3$3);
}
script$3.render = render$3;
function parseFile(file, i) {
return {
url: file,
name: getFileName(file),
uid: i
};
}
function getFileName(file) {
return ('' + file).split('/').pop();
}
var NAME$4 = 'fcUpload';
var Upload = defineComponent({
name: NAME$4,
inheritAttrs: false,
props: {
previewMask: undefined,
modalTitle: String,
modelValue: [Array, String]
},
emits: ['update:modelValue', 'change', 'remove'],
data: function data() {
return {
previewVisible: false,
previewImage: '',
fileList: []
};
},
created: function created() {
this.fileList = toArray(this.modelValue).map(parseFile);
},
watch: {
modelValue: function modelValue(n) {
this.fileList = toArray(n).map(parseFile);
},
limit: function limit(n, o) {
if (o === 1 || n === 1) {
this.update();
}
}
},
methods: {
handlePreview: function handlePreview(file) {
if (this.onPreview) {
this.onPreview.apply(this, arguments);
} else {
this.previewImage = file.url;
this.previewVisible = true;
}
},
update: function update(fileList) {
var files = fileList.map(function (file) {
return file.url;
}).filter(function (url) {
return url !== undefined;
});
this.$emit('update:modelValue', this.limit === 1 ? files[0] || '' : files);
},
handleCancel: function handleCancel() {
this.previewVisible = false;
},
handleChange: function handleChange(file, fileList) {
this.$emit.apply(this, ['change'].concat(Array.prototype.slice.call(arguments)));
if (file.status === 'success') {
this.update(fileList);
}
},
handleRemove: function handleRemove(file, fileList) {
this.$emit.apply(this, ['remove'].concat(Array.prototype.slice.call(arguments)));
this.update(fileList);
}
},
render: function render() {
var _this$$slots$default,
_this$$slots,
_this = this;
var len = toArray(this.modelValue).length;
return createVNode(Fragment, null, [createVNode(resolveComponent("ElUpload"), mergeProps$1({
"key": len,
"list-type": "picture-card"
}, this.$attrs, {
"class": {
'_fc-exceed': this.$attrs.limit ? this.$attrs.limit <= len : false
},
"onPreview": this.handlePreview,
"onChange": this.handleChange,
"onRemove": this.handleRemove,
"fileList": this.fileList
}), _objectSpread2({
"default": function _default() {
return [((_this$$slots$default = (_this$$slots = _this.$slots)["default"]) === null || _this$$slots$default === void 0 ? void 0 : _this$$slots$default.call(_this$$slots)) || createVNode(resolveComponent("ElIcon"), null, {
"default": function _default() {
return [createVNode(script$3, null, null)];
}
})];
}
}, getSlot(this.$slots, ['default']))), createVNode(resolveComponent("ElDialog"), {
"appendToBody": true,
"modal": this.previewMask,
"title": this.modalTitle,
"modelValue": this.previewVisible,
"onClose": this.handleCancel
}, {
"default": function _default() {
return [createVNode("img", {
"style": "width: 100%",
"src": _this.previewImage
}, null)];
}
})]);
}
});
var is = {
type: function type(arg, _type) {
return Object.prototype.toString.call(arg) === '[object ' + _type + ']';
},
Undef: function Undef(v) {
return v === undefined || v === null;
},
Element: function Element(arg) {
return _typeof(arg) === 'object' && arg !== null && arg.nodeType === 1 && !is.Object(arg);
},
trueArray: function trueArray(data) {
return Array.isArray(data) && data.length > 0;
},
Function: function Function(v) {
var type = this.getType(v);
return type === 'Function' || type === 'AsyncFunction';
},
getType: function getType(v) {
var str = Object.prototype.toString.call(v);
return /^\[object (.*)\]$/.exec(str)[1];
},
empty: function empty(value) {
if (value === undefined || value === null) {
return true;
}
if (Array.isArray(value) && Array.isArray(value) && !value.length) {
return true;
}
return typeof value === 'string' && !value;
}
};
['Date', 'Object', 'String', 'Boolean', 'Array', 'Number'].forEach(function (t) {
is[t] = function (arg) {
return is.type(arg, t);
};
});
function hasProperty(rule, k) {
return {}.hasOwnProperty.call(rule, k);
}
var script$2 = {
name: 'IconCirclePlus'
};
var _hoisted_1$2 = {
"class": "icon",
viewBox: "0 0 1024 1024",
xmlns: "http://www.w3.org/2000/svg"
};
var _hoisted_2$2 = /*#__PURE__*/createElementVNode("path", {
fill: "currentColor",
d: "M352 480h320a32 32 0 110 64H352a32 32 0 010-64z"
}, null, -1);
var _hoisted_3$2 = /*#__PURE__*/createElementVNode("path", {
fill: "currentColor",
d: "M480 672V352a32 32 0 1164 0v320a32 32 0 01-64 0z"
}, null, -1);
var _hoisted_4$1 = /*#__PURE__*/createElementVNode("path", {
fill: "currentColor",
d: "M512 896a384 384 0 100-768 384 384 0 000 768zm0 64a448 448 0 110-896 448 448 0 010 896z"
}, null, -1);
var _hoisted_5 = [_hoisted_2$2, _hoisted_3$2, _hoisted_4$1];
function render$2(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("svg", _hoisted_1$2, _hoisted_5);
}
script$2.render = render$2;
var script$1 = {
name: 'IconRemove'
};
var _hoisted_1$1 = {
"class": "icon",
viewBox: "0 0 1024 1024",
xmlns: "http://www.w3.org/2000/svg"
};
var _hoisted_2$1 = /*#__PURE__*/createElementVNode("path", {
fill: "currentColor",
d: "M352 480h320a32 32 0 110 64H352a32 32 0 010-64z"
}, null, -1);
var _hoisted_3$1 = /*#__PURE__*/createElementVNode("path", {
fill: "currentColor",
d: "M512 896a384 384 0 100-768 384 384 0 000 768zm0 64a448 448 0 110-896 448 448 0 010 896z"
}, null, -1);
var _hoisted_4 = [_hoisted_2$1, _hoisted_3$1];
function render$1(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("svg", _hoisted_1$1, _hoisted_4);
}
script$1.render = render$1;
function $set(target, field, value) {
target[field] = value;
}
function $del(target, field) {
delete target[field];
}
function deepExtend(origin) {
var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var mode = arguments.length > 2 ? arguments[2] : undefined;
var isArr = false;
for (var key in target) {
if (Object.prototype.hasOwnProperty.call(target, key)) {
var clone = target[key];
if ((isArr = Array.isArray(clone)) || is.Object(clone)) {
var nst = origin[key] === undefined;
if (isArr) {
isArr = false;
nst && $set(origin, key, []);
} else if (clone._clone && mode !== undefined) {
if (mode) {
clone = clone.getRule();
nst && $set(origin, key, {});
} else {
$set(origin, key, clone._clone());
continue;
}
} else {
nst && $set(origin, key, {});
}
origin[key] = deepExtend(origin[key], clone, mode);
} else {
$set(origin, key, clone);
if (!is.Undef(clone)) {
if (!is.Undef(clone.__json)) {
origin[key].__json = clone.__json;
}
if (!is.Undef(clone.__origin)) {
origin[key].__origin = clone.__origin;
}
}
}
}
}
return mode !== undefined && Array.isArray(origin) ? origin.filter(function (v) {
return !v || !v.__ctrl;
}) : origin;
}
function deepCopy(value) {
return deepExtend({}, {
value: value
}).value;
}
var _extends = Object.assign || function (a) {
for (var b, c = 1; c < arguments.length; c++) {
for (var d in b = arguments[c], b) {
Object.prototype.hasOwnProperty.call(b, d) && $set(a, d, b[d]);
}
}
return a;
};
function extend() {
return _extends.apply(this, arguments);
}
function _isSlot(s) {
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
}
var NAME$3 = 'fcGroup';
var Group = defineComponent({
name: NAME$3,
props: {
field: String,
rule: Array,
expand: Number,
options: Object,
button: {
type: Boolean,
"default": true
},
max: {
type: Number,
"default": 0
},
min: {
type: Number,
"default": 0
},
modelValue: {
type: Array,
"default": function _default() {
return [];
}
},
defaultValue: Object,
disabled: {
type: Boolean,
"default": false
},
syncDisabled: {
type: Boolean,
"default": true
},
fontSize: {
type: Number,
"default": 28
},
onBeforeRemove: {
type: Function,
"default": function _default() {}
},
onBeforeAdd: {
type: Function,
"default": function _default() {}
},
formCreateInject: Object
},
data: function data() {
return {
len: 0,
cacheRule: {},
cacheValue: {},
form: markRaw(this.formCreateInject.form.$form())
};
},
emits: ['update:modelValue', 'change', 'itemMounted', 'remove', 'add'],
watch: {
rule: {
handler: function handler(n, o) {
var _this = this;
Object.keys(this.cacheRule).forEach(function (v) {
var item = _this.cacheRule[v];
if (item.$f) {
var val = item.$f.formData();
if (n === o) {
item.$f.deferSyncValue(function () {
deepExtend(item.rule, n);
item.$f.setValue(val);
}, true);
} else {
var _val = item.$f.formData();
item.$f.once('reloading', function () {
item.$f.setValue(_val);
});
item.rule = deepCopy(n);
}
}
});
},
deep: true
},
disabled: function disabled(n) {
if (this.syncDisabled) {
var lst = this.cacheRule;
Object.keys(lst).forEach(function (k) {
lst[k].$f.disabled(n);
});
}
},
expand: function expand(n) {
var d = n - this.modelValue.length;
if (d > 0) {
this.expandRule(d);
}
},
modelValue: {
handler: function handler(n) {
var _this2 = this;
n = n || [];
var keys = Object.keys(this.cacheRule),
total = keys.length,
len = total - n.length;
if (len < 0) {
for (var i = len; i < 0; i++) {
this.addRule(n.length + i, true);
}
for (var _i = 0; _i < total; _i++) {
this.setValue(keys[_i], n[_i]);
}
} else {
if (len > 0) {
for (var _i2 = 0; _i2 < len; _i2++) {
this.removeRule(keys[total - _i2 - 1]);
}
}
n.forEach(function (val, i) {
_this2.setValue(keys[i], n[i]);
});
}
},
deep: true
}
},
methods: {
_value: function _value(v) {
return v && hasProperty(v, this.field) ? v[this.field] : v;
},
cache: function cache(k, val) {
this.cacheValue[k] = JSON.stringify(val);
},
input: function input(value) {
this.$emit('update:modelValue', value);
this.$emit('change', value);
},
formData: function formData(key, _formData) {
var _this3 = this;
var cacheRule = this.cacheRule;
var keys = Object.keys(cacheRule);
if (keys.filter(function (k) {
return cacheRule[k].$f;
}).length !== keys.length) {
return;
}
var value = keys.map(function (k) {
var data = key === k ? _formData : _objectSpread2({}, _this3.cacheRule[k].$f.form);
var value = _this3.field ? data[_this3.field] || null : data;
_this3.cache(k, value);
return value;
});
this.input(value);
},
setValue: function setValue(key, value) {
var field = this.field;
if (field) {
value = _defineProperty({}, field, this._value(value));
}
if (this.cacheValue[key] === JSON.stringify(field ? value[field] : value)) {
return;
}
this.cache(key, value);
},
addRule: function addRule(i, emit) {
var _this4 = this;
var rule = this.formCreateInject.form.copyRules(this.rule || []);
var options = this.options ? _objectSpread2({}, this.options) : {
submitBtn: false,
resetBtn: false
};
if (this.defaultValue) {
if (!options.formData) options.formData = {};
var defVal = deepCopy(this.defaultValue);
extend(options.formData, this.field ? _defineProperty({}, this.field, defVal) : defVal);
}
this.cacheRule[++this.len] = {
rule: rule,
options: options
};
if (emit) {
nextTick(function () {
return _this4.$emit('add', rule, Object.keys(_this4.cacheRule).length - 1);
});
}
},
add$f: function add$f(i, key, $f) {
var _this5 = this;
this.cacheRule[key].$f = $f;
this.formData(key, $f.formData());
nextTick(function () {
if (_this5.syncDisabled) {
$f.disabled(_this5.disabled);
}
_this5.$emit('itemMounted', $f, Object.keys(_this5.cacheRule).indexOf(key));
});
},
removeRule: function removeRule(key, emit) {
var _this6 = this;
var index = Object.keys(this.cacheRule).indexOf(key);
delete this.cacheRule[key];
delete this.cacheValue[key];
if (emit) {
nextTick(function () {
return _this6.$emit('remove', index);
});
}
},
add: function add() {
if (this.disabled || false === this.onBeforeAdd(this.modelValue)) {
return;
}
this.modelValue.push(this.field ? null : {});
this.$emit('update:modelValue', this.modelValue);
},
del: function del(index, key) {
if (this.disabled || false === this.onBeforeRemove(this.modelValue, index)) {
return;
}
this.removeRule(key, true);
this.modelValue.splice(index, 1);
this.input(this.modelValue);
},
addIcon: function addIcon(key) {
return createVNode(resolveComponent("ElIcon"), {
"key": "a".concat(key),
"style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer', ";"),
"onClick": this.add
}, {
"default": function _default() {
return [createVNode(script$2, null, null)];
}
});
},
delIcon: function delIcon(index, key) {
var _this7 = this;
return createVNode(resolveComponent("ElIcon"), {
"key": "d".concat(key),
"class": "el-icon-remove-outline",
"style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer;color:#606266', ";"),
"onClick": function onClick() {
return _this7.del(index, key);
}
}, {
"default": function _default() {
return [createVNode(script$1, null, null)];
}
});
},
makeIcon: function makeIcon(total, index, key) {
var _this8 = this;
if (this.$slots.button) {
return this.$slots.button({
total: total,
index: index,
vm: this,
key: key,
del: function del() {
return _this8.del(index, key);
},
add: this.add
});
}
if (index === 0) {
return [this.max !== 0 && total >= this.max ? null : this.addIcon(key), this.min === 0 || total > this.min ? this.delIcon(index, key) : null];
}
if (index >= this.min) {
return this.delIcon(index, key);
}
},
emitEvent: function emitEvent(name, args, index, key) {
this.$emit.apply(this, [name].concat(_toConsumableArray(args), [this.cacheRule[key].$f, index]));
},
expandRule: function expandRule(n) {
for (var i = 0; i < n; i++) {
this.modelValue.push(this.field ? null : {});
}
}
},
created: function created() {
var d = (this.expand || 0) - this.modelValue.length;
for (var i = 0; i < this.modelValue.length; i++) {
this.addRule(i);
}
if (d > 0) {
this.expandRule(d);
}
},
render: function render() {
var _this9 = this;
var keys = Object.keys(this.cacheRule);
var button = this.button;
var Type = this.form;
return keys.length === 0 ? this.$slots["default"] ? this.$slots["default"]({
vm: this,
add: this.add
}) : createVNode(resolveComponent("ElIcon"), {
"key": 1,
"style": "font-size:".concat(this.fontSize, "px;vertical-align:middle;color:").co