@form-create/arco-design
Version:
arco-design动态表单|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 k
1,765 lines (1,580 loc) • 188 kB
JavaScript
/*!
* @form-create/arco-design v3.1.29
* (c) 2018-2024 xaboy
* Github https://github.com/xaboy/form-create
* Released under the MIT License.
*/
import { defineComponent, toRef, createVNode, resolveComponent, mergeProps as mergeProps$1, openBlock, createElementBlock, createElementVNode, isVNode, nextTick, markRaw, watch, Fragment, reactive, getCurrentInstance, provide, inject, toRefs, onMounted, onBeforeUnmount, onUpdated, 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$7 = 'fcRadio';
var Radio = defineComponent({
name: NAME$7,
inheritAttrs: false,
props: {
formCreateInject: Object,
modelValue: {
type: [String, Number, Boolean],
"default": ''
}
},
emits: ['update:modelValue', 'fc.el'],
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;
return createVNode(resolveComponent("ARadioGroup"), mergeProps$1(this.$attrs, {
"modelValue": this.value,
"onUpdate:modelValue": this.onInput,
"ref": "el"
}), _objectSpread2({
"default": function _default() {
return [_this.options().map(function (opt, index) {
return createVNode(resolveComponent("ARadio"), mergeProps$1(opt, {
"key": '' + index + '-' + opt.value
}), {
"default": function _default() {
return [opt.label || opt.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'])));
},
mounted: function mounted() {
this.$emit('fc.el', this.$refs.el);
}
});
var NAME$6 = 'fcCheckbox';
var Checkbox = defineComponent({
name: NAME$6,
inheritAttrs: false,
props: {
formCreateInject: Object,
modelValue: {
type: Array,
"default": function _default() {
return [];
}
}
},
emits: ['update:modelValue', 'fc.el'],
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;
return createVNode(resolveComponent("ACheckboxGroup"), mergeProps$1(this.$attrs, {
"modelValue": this.value,
"onUpdate:modelValue": this.onInput,
"ref": "el"
}), _objectSpread2({
"default": function _default() {
return [_this.options().map(function (opt, index) {
return createVNode(resolveComponent("ACheckbox"), mergeProps$1(opt, {
"key": '' + index + '-' + opt.value
}), {
"default": function _default() {
return [opt.label || opt.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'])));
},
mounted: function mounted() {
this.$emit('fc.el', this.$refs.el);
}
});
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-cover{background:rgba(0,0,0,.6);bottom:0;left:0;opacity:0;position:absolute;right:0;top:0;transition:opacity .3s}._fc-frame ._fc-upload-cover ._fc-frame-icon{color:#fff;font-size:16px;margin:0 2px}._fc-frame ._fc-files:hover ._fc-upload-cover{opacity:1}._fc-frame .ant-upload{display:block}._fc-frame ._fc-frame-icon,._fc-frame ._fc-upload-btn{cursor:pointer}._fc-frame._fc-disabled ._fc-frame-icon,._fc-frame._fc-disabled ._fc-upload-btn{color:#999;cursor:not-allowed!important}._fc-files,._fc-frame ._fc-upload-btn{background:#fff;border:1px solid #c0ccda;border-radius:4px;box-shadow:2px 2px 5px rgba(0,0,0,.1);box-sizing:border-box;display:inline-block;height:80px;line-height:80px;margin-right:8px;overflow:hidden;position:relative;text-align:center;width:80px}._fc-frame ._fc-upload-cover svg{color:#fff;cursor:pointer;font-size:20px;margin:0 2px}";
styleInject(css_248z$2);
var script$5 = {
name: 'IconFolder'
};
var _hoisted_1$5 = {
viewBox: "0 0 48 48",
fill: "none",
xmlns: "http://www.w3.org/2000/svg",
stroke: "currentColor",
"class": "arco-icon arco-icon-folder",
"stroke-width": "4",
"stroke-linecap": "butt",
"stroke-linejoin": "miter"
};
var _hoisted_2$5 = /*#__PURE__*/createElementVNode("path", {
d: "M6 13h18l-2.527-3.557a1.077 1.077 0 0 0-.88-.443H7.06C6.474 9 6 9.448 6 10v3Zm0 0h33.882c1.17 0 2.118.895 2.118 2v21c0 1.105-.948 3-2.118 3H8.118C6.948 39 6 38.105 6 37V13Z"
}, 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: 'IconDelete'
};
var _hoisted_1$4 = {
viewBox: "0 0 48 48",
fill: "none",
xmlns: "http://www.w3.org/2000/svg",
stroke: "currentColor",
"class": "arco-icon arco-icon-delete",
"stroke-width": "4",
"stroke-linecap": "butt",
"stroke-linejoin": "miter"
};
var _hoisted_2$4 = /*#__PURE__*/createElementVNode("path", {
d: "M5 11h5.5m0 0v29a1 1 0 0 0 1 1h25a1 1 0 0 0 1-1V11m-27 0H16m21.5 0H43m-5.5 0H32m-16 0V7h16v4m-16 0h16M20 18v15m8-15v15"
}, 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;
var script$3 = {
name: 'IconCloseCircle'
};
var _hoisted_1$3 = {
viewBox: "0 0 48 48",
fill: "none",
xmlns: "http://www.w3.org/2000/svg",
stroke: "currentColor",
"class": "arco-icon arco-icon-close-circle",
"stroke-width": "4",
"stroke-linecap": "butt",
"stroke-linejoin": "miter"
};
var _hoisted_2$3 = /*#__PURE__*/createElementVNode("path", {
d: "m17.643 17.643 6.364 6.364m0 0 6.364 6.364m-6.364-6.364 6.364-6.364m-6.364 6.364-6.364 6.364M42 24c0 9.941-8.059 18-18 18S6 33.941 6 24 14.059 6 24 6s18 8.059 18 18Z"
}, 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;
var script$2 = {
name: 'IconEye'
};
var _hoisted_1$2 = {
viewBox: "0 0 48 48",
fill: "none",
xmlns: "http://www.w3.org/2000/svg",
stroke: "currentColor",
"class": "arco-icon arco-icon-eye",
"stroke-width": "4",
"stroke-linecap": "butt",
"stroke-linejoin": "miter"
};
var _hoisted_2$2 = /*#__PURE__*/createElementVNode("path", {
"clip-rule": "evenodd",
d: "M24 37c6.627 0 12.627-4.333 18-13-5.373-8.667-11.373-13-18-13-6.627 0-12.627 4.333-18 13 5.373 8.667 11.373 13 18 13Z"
}, null, -1);
var _hoisted_3$2 = /*#__PURE__*/createElementVNode("path", {
d: "M29 24a5 5 0 1 1-10 0 5 5 0 0 1 10 0Z"
}, null, -1);
var _hoisted_4 = [_hoisted_2$2, _hoisted_3$2];
function render$2(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("svg", _hoisted_1$2, _hoisted_4);
}
script$2.render = render$2;
var script$1 = {
name: 'IconFile'
};
var _hoisted_1$1 = {
viewBox: "0 0 48 48",
fill: "none",
xmlns: "http://www.w3.org/2000/svg",
stroke: "currentColor",
"class": "arco-icon arco-icon-file",
"stroke-width": "4",
"stroke-linecap": "butt",
"stroke-linejoin": "miter"
};
var _hoisted_2$1 = /*#__PURE__*/createElementVNode("path", {
d: "M16 21h16m-16 8h10m11 13H11a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h21l7 7v27a2 2 0 0 1-2 2Z"
}, null, -1);
var _hoisted_3$1 = [_hoisted_2$1];
function render$1(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("svg", _hoisted_1$1, _hoisted_3$1);
}
script$1.render = render$1;
function _isSlot(s) {
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
}
var NAME$5 = 'fcFrame';
var Frame = defineComponent({
name: NAME$5,
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": 'icon-folder'
},
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": 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: {
IconFolder: script$5,
IconEye: script$2
},
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.closeModal(true);
},
closeModal: function closeModal(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;
},
showModal: function showModal() {
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;
var Type = resolveComponent(this.icon);
var slots = {
append: function append() {
return createVNode(Type, {
"class": "_fc-frame-icon",
"onClick": _this.showModal
}, null);
}
};
if (this.fileList.length && !this.disabled) {
slots.suffix = function () {
return createVNode(script$3, {
"class": "_fc-frame-icon",
"onClick": function onClick() {
_this.fileList = [];
_this.input();
}
}, null);
};
}
return createVNode(resolveComponent("AInput"), {
"readonly": true,
"modelValue": this.fileList.map(function (v) {
return _this.getSrc(v);
}).toString(),
"key": 1
}, slots);
},
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-eye' : this.handleIcon);
return createVNode(Type, {
"onClick": function onClick() {
return _this2.handleClick(val);
},
"key": '5' + index
}, null);
},
makeRemoveIcon: function makeRemoveIcon(val, index) {
var _this3 = this;
return createVNode(script$4, {
"onClick": function onClick() {
return _this3.handleRemove(val);
},
"key": '6' + index
}, null);
},
makeFiles: function makeFiles() {
var _this4 = this;
return this.makeGroup(this.fileList.map(function (src, index) {
return _this4.makeItem(index, [createVNode(script$1, {
"onClick": function onClick() {
return _this4.handleClick(src);
}
}, 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.showModal();
},
"key": 7
}, [createVNode(Type, {
"class": "_fc-frame-icon"
}, 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.closeModal();
},
set: function set(field, value) {
_this7.valid(field);
if (!_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;
var node = [];
if (!footer) return node;
if (closeBtn) node.push(createVNode(resolveComponent("AButton"), {
"onClick": function onClick() {
return _this8.onCancel() !== false && _this8.closeModal(true);
}
}, _isSlot(closeBtnText) ? closeBtnText : {
"default": function _default() {
return [closeBtnText];
}
}));
if (okBtn) node.push(createVNode(resolveComponent("AButton"), {
"type": "primary",
"onClick": function onClick() {
return _this8.onOk() !== false && _this8.closeModal();
}
}, _isSlot(okBtnText) ? okBtnText : {
"default": function _default() {
return [okBtnText];
}
}));
return node;
}
},
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': true,
'_fc-disabled': this.disabled
}
}, [Node, createVNode(resolveComponent("aModal"), {
"mask": this.previewMask,
"title": modalTitle,
"visible": this.previewVisible,
"onCancel": function onCancel() {
return _this9.previewVisible = false;
},
"footer": null
}, {
"default": function _default() {
return [createVNode("img", {
"style": "width: 100%",
"src": _this9.previewImage
}, null)];
}
}), createVNode(resolveComponent("aModal"), mergeProps$1(_objectSpread2({
width: width,
title: title
}, this.modal), {
"visible": this.frameVisible,
"onCancel": function onCancel() {
return _this9.closeModal(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 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);
}
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 copy$1(obj) {
if (_typeof(obj) !== 'object' || obj === null) return obj;
return obj instanceof Array ? _toConsumableArray(obj) : _objectSpread2({}, obj);
}
var css_248z$1 = "._fc-group{display:flex;flex-direction:column;justify-content:center;min-height:38px;width:100%}._fc-group-disabled ._fc-group-add,._fc-group-disabled ._fc-group-btn{cursor:not-allowed}._fc-group-handle{background-color:#fff;border:1px dashed #d9d9d9;border-radius:15px;bottom:-15px;display:flex;flex-direction:row;padding:3px 8px;position:absolute;right:30px}._fc-group-btn{cursor:pointer}._fc-group-idx{align-items:center;background:#eee;border-radius:15px;bottom:-15px;display:flex;font-weight:700;height:30px;justify-content:center;left:10px;position:absolute;width:30px}._fc-group-handle ._fc-group-btn+._fc-group-btn{margin-left:7px}._fc-group-container{border:1px dashed #d9d9d9;border-radius:5px;display:flex;flex-direction:column;margin:5px 5px 25px;padding:20px 20px 25px;position:relative}._fc-group-arrow{height:20px;position:relative;width:20px}._fc-group-arrow:before{border-left:2px solid #999;border-top:2px solid #999;content:\"\";height:9px;left:5px;position:absolute;top:8px;transform:rotate(45deg);width:9px}._fc-group-arrow._fc-group-down{transform:rotate(180deg)}._fc-group-plus-minus{cursor:pointer;height:20px;position:relative;width:20px}._fc-group-plus-minus:after,._fc-group-plus-minus:before{background-color:#409eff;content:\"\";height:2px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:60%}._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{border:1px solid rgba(64,158,255,.5);border-radius:15px;cursor:pointer;height:25px;width:25px}._fc-group-add._fc-group-plus-minus:after,._fc-group-add._fc-group-plus-minus:before{width:50%}";
styleInject(css_248z$1);
var NAME$4 = 'fcGroup';
var Group = defineComponent({
name: NAME$4,
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,
sortBtn: {
type: Boolean,
"default": true
},
disabled: {
type: Boolean,
"default": false
},
syncDisabled: {
type: Boolean,
"default": true
},
onBeforeRemove: {
type: Function,
"default": function _default() {}
},
onBeforeAdd: {
type: Function,
"default": function _default() {}
},
formCreateInject: Object,
parse: Function
},
data: function data() {
return {
len: 0,
cacheRule: {},
cacheValue: {},
sort: [],
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.sort),
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 = this.sort;
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.parse && this.parse({
rule: rule,
options: options,
index: this.sort.length
});
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;
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(i) {
if (this.disabled || false === this.onBeforeAdd(this.modelValue)) {
return;
}
var value = _toConsumableArray(this.modelValue);
value.push(this.defaultValue ? deepCopy(this.defaultValue) : this.field ? null : {});
this.input(value);
},
del: function del(index, key) {
if (this.disabled || false === this.onBeforeRemove(this.modelValue, index)) {
return;
}
this.removeRule(key, true);
var value = _toConsumableArray(this.modelValue);
value.splice(index, 1);
this.input(value);
},
addIcon: function addIcon(key) {
return createVNode("div", {
"class": "_fc-group-btn _fc-group-plus-minus",
"onClick": this.add
}, null);
},
delIcon: function delIcon(index, key) {
var _this7 = this;
return createVNode("div", {
"class": "_fc-group-btn _fc-group-plus-minus _fc-group-minus",
"onClick": function onClick() {
return _this7.del(index, key);
}
}, null);
},
sortUpIcon: function sortUpIcon(index) {
var _this8 = this;
return createVNode("div", {
"class": "_fc-group-btn _fc-group-arrow _fc-group-up",
"onClick": function onClick() {
return _this8.changeSort(index, -1);
}
}, null);
},
sortDownIcon: function sortDownIcon(index) {
var _this9 = this;
return createVNode("div", {
"class": "_fc-group-btn _fc-group-arrow _fc-group-down",
"onClick": function onClick() {
return _this9.changeSort(index, 1);
}
}, null);
},
changeSort: function changeSort(index, sort) {
var a = this.sort[index];
this.sort[index] = this.sort[index + sort];
this.sort[index + sort] = a;
this.formData(0);
},
makeIcon: function makeIcon(total, index, key) {
var _this10 = this;
if (this.$slots.button) {
return this.$slots.button({
total: total,
index: index,
vm: this,
key: key,
del: function del() {
return _this10.del(index, key);
},
add: this.add
});
}
var btn = [];
if ((!this.max || total < this.max) && total === index + 1) {
btn.push(this.addIcon(key));
}
if (total > this.min) {
btn.push(this.delIcon(index, key));
}
if (this.sortBtn && index) {
btn.push(this.sortUpIcon(index));
}
if (this.sortBtn && index !== total - 1) {
btn.push(this.sortDownIcon(index));
}
return btn;
},
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.addRule(i);
}
}
},
created: function created() {
var _this11 = this;
watch(function () {
return _objectSpread2({}, _this11.cacheRule);
}, function (n) {
_this11.sort = Object.keys(n);
}, {
immediate: true
});
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 _this12 = this;
var keys = this.sort;
var button = this.button;
var Type = this.form;
var disabled = this.disabled;
var children = keys.length === 0 ? this.$slots["default"] ? this.$slots["default"]({
vm: this,
add: this.add
}) : createVNode("div", {
"key": 'a_def',
"class": "_fc-group-plus-minus _fc-group-add fc-clock",
"onClick": this.add
}, null) : keys.map(function (key, index) {
var _this12$cacheRule$key = _this12.cacheRule[key],
rule = _this12$cacheRule$key.rule,
options = _this12$cacheRule$key.options;
var btn = button && !disabled ? _this12.makeIcon(keys.length, index, key) : [];
return createVNode("div", {
"class": "_fc-group-container",
"key": key
}, [createVNode(Type, mergeProps$1({
"key": key
}, {
'onUpdate:modelValue': function onUpdateModelValue(formData) {
return _this12.formData(key, formData);
},
'onEmit-event': function onEmitEvent(name) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return _this12.emitEvent(name, args, index, key);
},
'onUpdate:api': function onUpdateApi($f) {
return _this12.add$f(index, key, $f);
},
inFor: true,
modelValue: _this12.field ? _defineProperty({}, _this12.field, _this12._value(_this12.modelValue[index])) : _this12.modelValue[index],
rule: rule,
option: options,
extendOption: true
}), null), createVNode("div", {
"class": "_fc-group-idx"
}, [index + 1]), btn.length ? createVNode("div", {
"class": "_fc-group-handle fc-clock"
}, [btn]) : null]);
});
return createVNode("div", {
"key": 'con',
"class": '_fc-group ' + (disabled ? '_fc-group-disabled' : '')
}, [children]);
}
});
var parseFile = function parseFile(file, uid) {
return {
url: file,
name: getFileName(file),
status: 'done',
uid: uid + 1
};
},
getFileName = function getFileName(file) {
return ('' + file).split('/').pop();
},
parseUpload = function parseUpload(file) {
return {
url: file.url,
file: file
};
};
var NAME$3 = 'fcUpload';
var Upload = defineComponent({
name: NAME$3,
inheritAttrs: false,
formCreateParser: {
toFormValue: function toFormValue(value) {
return toArray(value);
},
toValue: function toValue(formValue, ctx) {
return ctx.prop.props.limit === 1 ? formValue[0] || '' : formValue;
}
},
props: {
modelValue: {
type: Array,
"default": function _default() {
return [];
}
},
onSuccess: {
type: Function,
required: true
},
onPreview: Function,
modalTitle: String,
previewMask: undefined
},
emits: ['update:modelValue', 'success', 'fc.el'],
data: function data() {
return {
previewImage: '',
previewVisible: false,
uploadList: this.modelValue.map(parseFile).map(parseUpload)
};
},
watch: {
modelValue: function modelValue(n) {
this.uploadList = n.map(parseFile).map(parseUpload);
}
},
methods: {
handleChange: function handleChange(file) {
this.onSuccess.apply(this, arguments);
var list = this.uploadList;
if (file.url) list.push({
url: file.url,
file: file
});
this.input(list);
},
input: function input(n) {
this.$emit('update:modelValue', n.map(function (v) {
return v.url;
}));
},
inputRemove: function inputRemove(n) {
if (n.length < this.uploadList.length) {
this.input(n);
}
},
handlePreview: function handlePreview(file) {
if (this.onPreview) {
this.onPreview.apply(this, arguments);
} else {
this.previewImage = file.url;
this.previewVisible = true;
}
}
},
render: function render() {
var _this = this;
return createVNode(Fragment, null, [createVNode(resolveComponent("AUpload"), mergeProps$1({
"list-type": 'picture-card'
}, this.$attrs, {
"onPreview": this.handlePreview,
"onSuccess": this.handleChange,
"ref": "upload",
"fileList": this.uploadList,
"onUpdate:fileList": this.inputRemove
}), this.$slots), createVNode(resolveComponent("aModal"), {
"mask": this.previewMask,
"title": this.modalTitle,
"visible": this.previewVisible,
"onCancel": function onCancel() {
return _this.previewVisible = false;
},
"footer": null
}, {
"default": function _default() {
return [createVNode("img", {
"style": "width: 100%",
"src": _this.previewImage
}, null)];
}
})]);
},
mounted: function mounted() {
this.$emit('fc.el', this.$refs.upload);
}
});
var NAME$2 = 'fcSubForm';
var Sub = defineComponent({
name: NAME$2,
props: {
rule: Array,
options: {
type: Object,
"default": function _default() {
return reactive({
submitBtn: false,
resetBtn: false
});
}
},
modelValue: {
type: Object,
"default": function _default() {
return {};
}
},
disabled: {
type: Boolean,
"default": false
},
syncDisabled: {
type: Boolean,
"default": true
},
formCreateInject: Object
},
data: function data() {
return {
cacheValue: {},
subApi: {},
form: markRaw(this.formCreateInject.form.$form())
};
},
emits: ['fc:subform', 'update:modelValue', 'change', 'itemMounted'],
watch: {
disabled: function disabled(n) {
this.syncDisabled && this.subApi.disabled(n);
},
modelValue: function modelValue(n) {
this.setValue(n);
}
},
methods: {
formData: function formData(value) {
this.cacheValue = JSON.stringify(value);
this.$emit('update:modelValue', value);
this.$emit('change', value);
},
setValue: function setValue(value) {
var str = JSON.stringify(value);
if (this.cacheValue === str) {
return;
}
this.cacheValue = str;
this.subApi.coverValue(value || {});
},
add$f: function add$f(api) {
var _this = this;
this.subApi = api;
nextTick(function () {
_this.syncDisabled && api.disabled(_this.disabled);
_this.$emit('itemMounted', api);
});
}
},
render: function render() {
var Type = this.form;
return createVNode(Type, {
"onUpdate:modelValue": this.formData,
"modelValue": this.modelValue,
"onEmit-event": this.$emit,
"onUpdate:api": this.add$f,
"rule": this.rule,
"option": this.options,
"extendOption": true
}, null);
}
});
var script = {
name: 'IconInfoCircle'
};
var _hoisted_1 = {
viewBox: "0 0 48 48",
fill: "none",
xmlns: "http://www.w3.org/2000/svg",
stroke: "currentColor",
"class": "arco-icon arco-icon-info-circle",
"stroke-width": "4",
"stroke-linecap": "butt",
"stroke-linejoin": "miter"
};
var _hoisted_2 = /*#__PURE__*/createElementVNode("path", {
d: "M24 20v14m0-16v-4m18 10c0 9.941-8.059 18-18 18S6 33.941 6 24 14.059 6 24 6s18 8.059 18 18Z"
}, null, -1);
var _hoisted_3 = [_hoisted_2];
function render(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("svg", _hoisted_1, _hoisted_3);
}
script.render = render;
var components = [Upload, Sub, Group, Radio, Checkbox, Fram