UNPKG

@form-create/vant

Version:

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

1,846 lines (1,632 loc) 261 kB
/*! * @form-create/vant v3.2.28 * (c) 2018-2025 xaboy * Github https://github.com/xaboy/form-create * Released under the MIT License. */ import { defineComponent, reactive, markRaw, nextTick, createVNode, ref, toRef, watch, computed, resolveComponent, mergeProps as mergeProps$1, isVNode, openBlock, createElementBlock, createElementVNode, getCurrentInstance, provide, inject, toRefs, onBeforeMount, watchEffect, onMounted, onBeforeUnmount, onUpdated, withDirectives, resolveDirective, createApp, h } from 'vue'; import { showNotify, Field } from 'vant'; var NAME$a = 'fcSubForm'; var Sub = defineComponent({ name: NAME$a, 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: { 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.$emit('itemMounted', api); }); } }, render: function render() { var Type = this.form; return createVNode(Type, { "disabled": this.disabled, "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); } }); 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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } 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 _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } 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 commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; var dayjs_min = {exports: {}}; (function (module, exports) { !function (t, e) { module.exports = e() ; }(commonjsGlobal, function () { var t = 1e3, e = 6e4, n = 36e5, r = "millisecond", i = "second", s = "minute", u = "hour", a = "day", o = "week", c = "month", f = "quarter", h = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function ordinal(t) { var e = ["th", "st", "nd", "rd"], n = t % 100; return "[" + t + (e[(n - 20) % 10] || e[n] || e[0]) + "]"; } }, m = function m(t, e, n) { var r = String(t); return !r || r.length >= e ? t : "" + Array(e + 1 - r.length).join(n) + t; }, v = { s: m, z: function z(t) { var e = -t.utcOffset(), n = Math.abs(e), r = Math.floor(n / 60), i = n % 60; return (e <= 0 ? "+" : "-") + m(r, 2, "0") + ":" + m(i, 2, "0"); }, m: function t(e, n) { if (e.date() < n.date()) return -t(n, e); var r = 12 * (n.year() - e.year()) + (n.month() - e.month()), i = e.clone().add(r, c), s = n - i < 0, u = e.clone().add(r + (s ? -1 : 1), c); return +(-(r + (n - i) / (s ? i - u : u - i)) || 0); }, a: function a(t) { return t < 0 ? Math.ceil(t) || 0 : Math.floor(t); }, p: function p(t) { return { M: c, y: h, w: o, d: a, D: d, h: u, m: s, s: i, ms: r, Q: f }[t] || String(t || "").toLowerCase().replace(/s$/, ""); }, u: function u(t) { return void 0 === t; } }, g = "en", D = {}; D[g] = M; var p = "$isDayjsObject", S = function S(t) { return t instanceof _ || !(!t || !t[p]); }, w = function t(e, n, r) { var i; if (!e) return g; if ("string" == typeof e) { var s = e.toLowerCase(); D[s] && (i = s), n && (D[s] = n, i = s); var u = e.split("-"); if (!i && u.length > 1) return t(u[0]); } else { var a = e.name; D[a] = e, i = a; } return !r && i && (g = i), i || !r && g; }, O = function O(t, e) { if (S(t)) return t.clone(); var n = "object" == _typeof(e) ? e : {}; return n.date = t, n.args = arguments, new _(n); }, b = v; b.l = w, b.i = S, b.w = function (t, e) { return O(t, { locale: e.$L, utc: e.$u, x: e.$x, $offset: e.$offset }); }; var _ = function () { function M(t) { this.$L = w(t.locale, null, !0), this.parse(t), this.$x = this.$x || t.x || {}, this[p] = !0; } var m = M.prototype; return m.parse = function (t) { this.$d = function (t) { var e = t.date, n = t.utc; if (null === e) return new Date(NaN); if (b.u(e)) return new Date(); if (e instanceof Date) return new Date(e); if ("string" == typeof e && !/Z$/i.test(e)) { var r = e.match($); if (r) { var i = r[2] - 1 || 0, s = (r[7] || "0").substring(0, 3); return n ? new Date(Date.UTC(r[1], i, r[3] || 1, r[4] || 0, r[5] || 0, r[6] || 0, s)) : new Date(r[1], i, r[3] || 1, r[4] || 0, r[5] || 0, r[6] || 0, s); } } return new Date(e); }(t), this.init(); }, m.init = function () { var t = this.$d; this.$y = t.getFullYear(), this.$M = t.getMonth(), this.$D = t.getDate(), this.$W = t.getDay(), this.$H = t.getHours(), this.$m = t.getMinutes(), this.$s = t.getSeconds(), this.$ms = t.getMilliseconds(); }, m.$utils = function () { return b; }, m.isValid = function () { return !(this.$d.toString() === l); }, m.isSame = function (t, e) { var n = O(t); return this.startOf(e) <= n && n <= this.endOf(e); }, m.isAfter = function (t, e) { return O(t) < this.startOf(e); }, m.isBefore = function (t, e) { return this.endOf(e) < O(t); }, m.$g = function (t, e, n) { return b.u(t) ? this[e] : this.set(n, t); }, m.unix = function () { return Math.floor(this.valueOf() / 1e3); }, m.valueOf = function () { return this.$d.getTime(); }, m.startOf = function (t, e) { var n = this, r = !!b.u(e) || e, f = b.p(t), l = function l(t, e) { var i = b.w(n.$u ? Date.UTC(n.$y, e, t) : new Date(n.$y, e, t), n); return r ? i : i.endOf(a); }, $ = function $(t, e) { return b.w(n.toDate()[t].apply(n.toDate("s"), (r ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e)), n); }, y = this.$W, M = this.$M, m = this.$D, v = "set" + (this.$u ? "UTC" : ""); switch (f) { case h: return r ? l(1, 0) : l(31, 11); case c: return r ? l(1, M) : l(0, M + 1); case o: var g = this.$locale().weekStart || 0, D = (y < g ? y + 7 : y) - g; return l(r ? m - D : m + (6 - D), M); case a: case d: return $(v + "Hours", 0); case u: return $(v + "Minutes", 1); case s: return $(v + "Seconds", 2); case i: return $(v + "Milliseconds", 3); default: return this.clone(); } }, m.endOf = function (t) { return this.startOf(t, !1); }, m.$set = function (t, e) { var n, o = b.p(t), f = "set" + (this.$u ? "UTC" : ""), l = (n = {}, n[a] = f + "Date", n[d] = f + "Date", n[c] = f + "Month", n[h] = f + "FullYear", n[u] = f + "Hours", n[s] = f + "Minutes", n[i] = f + "Seconds", n[r] = f + "Milliseconds", n)[o], $ = o === a ? this.$D + (e - this.$W) : e; if (o === c || o === h) { var y = this.clone().set(d, 1); y.$d[l]($), y.init(), this.$d = y.set(d, Math.min(this.$D, y.daysInMonth())).$d; } else l && this.$d[l]($); return this.init(), this; }, m.set = function (t, e) { return this.clone().$set(t, e); }, m.get = function (t) { return this[b.p(t)](); }, m.add = function (r, f) { var d, l = this; r = Number(r); var $ = b.p(f), y = function y(t) { var e = O(l); return b.w(e.date(e.date() + Math.round(t * r)), l); }; if ($ === c) return this.set(c, this.$M + r); if ($ === h) return this.set(h, this.$y + r); if ($ === a) return y(1); if ($ === o) return y(7); var M = (d = {}, d[s] = e, d[u] = n, d[i] = t, d)[$] || 1, m = this.$d.getTime() + r * M; return b.w(m, this); }, m.subtract = function (t, e) { return this.add(-1 * t, e); }, m.format = function (t) { var e = this, n = this.$locale(); if (!this.isValid()) return n.invalidDate || l; var r = t || "YYYY-MM-DDTHH:mm:ssZ", i = b.z(this), s = this.$H, u = this.$m, a = this.$M, o = n.weekdays, c = n.months, f = n.meridiem, h = function h(t, n, i, s) { return t && (t[n] || t(e, r)) || i[n].slice(0, s); }, d = function d(t) { return b.s(s % 12 || 12, t, "0"); }, $ = f || function (t, e, n) { var r = t < 12 ? "AM" : "PM"; return n ? r.toLowerCase() : r; }; return r.replace(y, function (t, r) { return r || function (t) { switch (t) { case "YY": return String(e.$y).slice(-2); case "YYYY": return b.s(e.$y, 4, "0"); case "M": return a + 1; case "MM": return b.s(a + 1, 2, "0"); case "MMM": return h(n.monthsShort, a, c, 3); case "MMMM": return h(c, a); case "D": return e.$D; case "DD": return b.s(e.$D, 2, "0"); case "d": return String(e.$W); case "dd": return h(n.weekdaysMin, e.$W, o, 2); case "ddd": return h(n.weekdaysShort, e.$W, o, 3); case "dddd": return o[e.$W]; case "H": return String(s); case "HH": return b.s(s, 2, "0"); case "h": return d(1); case "hh": return d(2); case "a": return $(s, u, !0); case "A": return $(s, u, !1); case "m": return String(u); case "mm": return b.s(u, 2, "0"); case "s": return String(e.$s); case "ss": return b.s(e.$s, 2, "0"); case "SSS": return b.s(e.$ms, 3, "0"); case "Z": return i; } return null; }(t) || i.replace(":", ""); }); }, m.utcOffset = function () { return 15 * -Math.round(this.$d.getTimezoneOffset() / 15); }, m.diff = function (r, d, l) { var $, y = this, M = b.p(d), m = O(r), v = (m.utcOffset() - this.utcOffset()) * e, g = this - m, D = function D() { return b.m(y, m); }; switch (M) { case h: $ = D() / 12; break; case c: $ = D(); break; case f: $ = D() / 3; break; case o: $ = (g - v) / 6048e5; break; case a: $ = (g - v) / 864e5; break; case u: $ = g / n; break; case s: $ = g / e; break; case i: $ = g / t; break; default: $ = g; } return l ? $ : b.a($); }, m.daysInMonth = function () { return this.endOf(c).$D; }, m.$locale = function () { return D[this.$L]; }, m.locale = function (t, e) { if (!t) return this.$L; var n = this.clone(), r = w(t, e, !0); return r && (n.$L = r), n; }, m.clone = function () { return b.w(this.$d, this); }, m.toDate = function () { return new Date(this.valueOf()); }, m.toJSON = function () { return this.isValid() ? this.toISOString() : null; }, m.toISOString = function () { return this.$d.toISOString(); }, m.toString = function () { return this.$d.toUTCString(); }, M; }(), k = _.prototype; return O.prototype = k, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c], ["$y", h], ["$D", d]].forEach(function (t) { k[t[1]] = function (e) { return this.$g(e, t[0], t[1]); }; }), O.extend = function (t, e) { return t.$i || (t(e, _, O), t.$i = !0), O; }, O.locale = w, O.isDayjs = S, O.unix = function (t) { return O(1e3 * t); }, O.en = D[g], O.Ls = D, O.p = {}, O; }); })(dayjs_min); var dayjs = dayjs_min.exports; var NAME$9 = 'fcCalendar'; var Calendar = defineComponent({ name: NAME$9, inheritAttrs: false, props: { placeholder: String, formCreateInject: Object, disabled: Boolean, clearable: Boolean, type: String, modelValue: [String, Array], minDate: [String, Date], maxDate: [String, Date] }, emits: ['update:modelValue', 'change', 'fc.el'], setup: function setup(props, _) { var show = ref(false); var modelValue = toRef(props, 'modelValue'); var formCreateInject = toRef(props, 'formCreateInject'); var inputValue = ref(modelValue.value); watch(function () { return modelValue.value; }, function (n) { inputValue.value = n; }); var formatter = function formatter(date) { return dayjs(date).format('YYYY-MM-DD'); }; var toDate = function toDate(str) { return dayjs(str).toDate(); }; var defaultDate = computed(function () { var value = modelValue.value; if (Array.isArray(value)) { return value.map(toDate); } else if (value) { return toDate(value); } else { return null; } }); var dateRange = computed(function () { return { minDate: props.minDate ? dayjs(props.minDate).toDate() : undefined, maxDate: props.maxDate ? dayjs(props.maxDate).toDate() : undefined }; }); var formatValue = function formatValue(value) { if (Array.isArray(value)) { inputValue.value = value.map(formatter); } else if (value) { inputValue.value = formatter(value); } else { inputValue.value = value; } }; var onInput = function onInput() { _.emit('update:modelValue', inputValue.value); _.emit('change', inputValue.value); }; var strValue = { range: function range() { return inputValue.value.length ? inputValue.value.join(' - ') : ''; }, multiple: function multiple() { return inputValue.value.length ? formCreateInject.value.t('selectedData', { length: inputValue.value.length }) || "\u9009\u62E9\u4E86 ".concat(inputValue.value.length, " \u4E2A\u65E5\u671F") : ''; } }; return { show: show, inputValue: inputValue, defaultDate: defaultDate, dateRange: dateRange, open: function open() { if (props.disabled) { return; } show.value = true; }, confirm: function confirm(value) { formatValue(value); show.value = false; onInput(); }, getStrValue: function getStrValue() { if (inputValue.value) { return hasProperty(strValue, props.type) ? strValue[props.type]() : inputValue.value || ''; } return ''; }, clear: function clear(e) { e.stopPropagation(); var value = Array.isArray(inputValue.value) ? [] : ''; formatValue(value); onInput(); } }; }, render: function render() { var _this = this; var clearIcon = function clearIcon() { return _this.$props.clearable && !is.empty(_this.inputValue) ? createVNode("i", { "class": "van-badge__wrapper van-icon van-icon-clear van-field__clear", "onClick": _this.clear }, null) : undefined; }; return createVNode("div", { "class": "_fc-calendar" }, [createVNode(resolveComponent("van-field"), { "ref": "el", "placeholder": this.placeholder, "readonly": true, "disabled": this.$props.disabled, "onClick": this.open, "model-value": this.getStrValue(), "isLink": true, "border": false }, { 'right-icon': clearIcon }), createVNode(resolveComponent("van-calendar"), mergeProps$1(_objectSpread2(_objectSpread2({}, this.$attrs), this.dateRange), { "show": this.show, "onUpdate:show": function onUpdateShow(v) { return _this.show = v; }, "type": this.type, "onConfirm": this.confirm, "defaultDate": this.defaultDate }), null)]); }, mounted: function mounted() { this.$emit('fc.el', this.$refs.el); } }); var NAME$8 = 'fcCascader'; var Cascader = defineComponent({ name: NAME$8, inheritAttrs: false, props: { placeholder: String, disabled: Boolean, clearable: Boolean, fieldNames: Object, modelValue: [String, Number], options: Array, minDate: [String, Date], maxDate: [String, Date] }, emits: ['update:modelValue', 'fc.el', 'change'], setup: function setup(props, _) { var show = ref(false); var modelValue = toRef(props, 'modelValue'); var options = toRef(props, 'options'); var fieldNames = toRef(props, 'fieldNames', {}); var findOptions = function findOptions(options, value, path) { for (var i = 0; i < options.length; i++) { if (options[i][fieldNames.value.value || 'value'] === value) { return [].concat(_toConsumableArray(path), [options[i]]); } else if (options[i][fieldNames.value.children || 'children']) { var find = findOptions(options[i][fieldNames.value.children || 'children'], value, [].concat(_toConsumableArray(path), [options[i]])); if (find) { return find; } } } }; var updateInputValue = function updateInputValue(n) { if (n == null || n === '') { return ''; } var path = findOptions(options.value, n, []); return path ? path.map(function (option) { return option[fieldNames.value.text || 'text']; }).join(' / ') : n; }; var inputValue = ref(updateInputValue(modelValue.value)); watch(function () { return modelValue.value; }, function (n) { inputValue.value = updateInputValue(n); }); watch(function () { return options.value; }, function () { if (modelValue.value != null && modelValue.value !== '') { inputValue.value = updateInputValue(modelValue.value); } }, { deep: true }); var onInput = function onInput(val) { _.emit('update:modelValue', val); _.emit('change', val); }; return { show: show, inputValue: inputValue, options: options, open: function open() { if (props.disabled) { return; } show.value = true; }, confirm: function confirm(_ref) { var selectedOptions = _ref.selectedOptions, value = _ref.value; inputValue.value = selectedOptions.map(function (option) { return option[fieldNames.value.text || 'text']; }).join(' / '); show.value = false; onInput(value); }, clear: function clear(e) { e.stopPropagation(); inputValue.value = ''; onInput(''); } }; }, render: function render() { var _this = this; var clearIcon = function clearIcon() { return _this.$props.clearable && _this.inputValue ? createVNode("i", { "class": "van-badge__wrapper van-icon van-icon-clear van-field__clear", "onClick": _this.clear }, null) : undefined; }; return createVNode("div", { "class": "_fc-cascader" }, [createVNode(resolveComponent("van-field"), { "ref": "el", "placeholder": this.placeholder, "readonly": true, "disabled": this.$props.disabled, "onClick": this.open, "model-value": this.inputValue, "border": false, "isLink": true }, { 'right-icon': clearIcon }), createVNode(resolveComponent("van-popup"), { "show": this.show, "onUpdate:show": function onUpdateShow(v) { return _this.show = v; }, "round": true, "position": "bottom" }, { "default": function _default() { return [createVNode(resolveComponent("van-cascader"), mergeProps$1(_this.$attrs, { "modelValue": _this.modelValue, "fieldNames": _this.fieldNames, "options": _this.options, "onClose": function onClose() { return _this.show = false; }, "onFinish": _this.confirm }), null)]; } })]); }, mounted: function mounted() { this.$emit('fc.el', this.$refs.el); } }); function _isSlot$1(s) { return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s); } var NAME$7 = 'fcCheckbox'; var Checkbox = defineComponent({ name: NAME$7, inheritAttrs: false, props: { modelValue: Array, options: Array }, emits: ['update:modelValue', 'change'], setup: function setup(props, _) { var modelValue = toRef(props, 'modelValue', []); var options = toRef(props, 'options'); return { options: options, modelValue: modelValue, onInput: function onInput(val) { _.emit('update:modelValue', val); _.emit('change', val); } }; }, render: function render() { var _slot; return createVNode(resolveComponent("van-checkbox-group"), mergeProps$1({ "direction": "horizontal" }, this.$attrs, { "modelValue": Array.isArray(this.modelValue) ? this.modelValue : [], "onUpdate:modelValue": this.onInput }), _isSlot$1(_slot = (this.options || []).map(function (opt) { var tmp = _objectSpread2({}, opt); var text = opt.text, value = opt.value; delete tmp.text; delete tmp.value; return createVNode(resolveComponent("van-checkbox"), mergeProps$1({ "name": value, "shape": "square" }, tmp), { "default": function _default() { return [text || opt.label || value]; } }); })) ? _slot : { "default": function _default() { return [_slot]; } }); } }); var NAME$6 = 'fcSelect'; var Select = defineComponent({ name: NAME$6, inheritAttrs: false, props: { disabled: Boolean, placeholder: String, columnsFieldNames: Object, modelValue: [String, Number], options: Array }, emits: ['update:modelValue', 'fc.el', 'change'], setup: function setup(props, _) { var show = ref(false); var modelValue = toRef(props, 'modelValue'); var options = toRef(props, 'options'); var fieldNames = toRef(props, 'columnsFieldNames', {}); var inputValue = computed(function () { if (modelValue.value == null || modelValue.value === '') { return ''; } for (var i = 0; i < (options.value || []).length; i++) { if (options.value[i][fieldNames.value.value || 'value'] === modelValue.value) { return options.value[i][fieldNames.value.text || 'text']; } } return modelValue.value; }); var onInput = function onInput(val) { _.emit('update:modelValue', val); _.emit('change', val); }; return { show: show, inputValue: inputValue, options: options, open: function open() { if (props.disabled) { return; } show.value = true; }, confirm: function confirm(_ref) { var selectedValues = _ref.selectedValues; onInput(selectedValues[0]); show.value = false; } }; }, render: function render() { var _this = this; return createVNode("div", { "class": "_fc-select" }, [createVNode(resolveComponent("van-field"), { "ref": "el", "placeholder": this.placeholder, "readonly": true, "disabled": this.$props.disabled, "onClick": this.open, "model-value": this.inputValue, "isLink": true }, null), createVNode(resolveComponent("van-popup"), { "show": this.show, "onUpdate:show": function onUpdateShow(v) { return _this.show = v; }, "round": true, "position": "bottom" }, { "default": function _default() { return [createVNode(resolveComponent("van-picker"), mergeProps$1(_this.$attrs, { "modelValue": [_this.modelValue], "columnsFieldNames": _this.columnsFieldNames, "columns": _this.options, "onCancel": function onCancel() { return _this.show = false; }, "onConfirm": _this.confirm }), null)]; } })]); }, mounted: function mounted() { this.$emit('fc.el', this.$refs.el); } }); function toArray(value) { return Array.isArray(value) ? value : [null, undefined, ''].indexOf(value) > -1 ? [] : [value]; } var NAME$5 = 'fcUploader'; function parseFile(file, i) { if (_typeof(file) === 'object') { return file; } return { url: file, is_string: true, name: getFileName(file), uid: i }; } function parseUpload(file) { return _objectSpread2(_objectSpread2({}, file), {}, { file: file, value: file }); } function getFileName(file) { return ('' + file).split('/').pop(); } var Uploader = defineComponent({ name: NAME$5, inheritAttrs: false, props: { formCreateInject: Object, modelValue: [Array, String, Object], afterRead: Function, action: String, headers: Object, method: String, data: Object, uploadName: String, onSuccess: Function, onError: Function, maxCount: Number }, emits: ['update:modelValue', 'delete'], setup: function setup(props, _) { var afterRead = toRef(props, 'afterRead'); var modelValue = toRef(props, 'modelValue', []); var fileList = ref(toArray(modelValue.value).map(parseFile).map(parseUpload)); watch(function () { return modelValue.value; }, function (n) { fileList.value = toArray(n).map(parseFile).map(parseUpload); }); var uploadValue = function uploadValue() { var files = fileList.value.map(function (v) { return v.is_string ? v.url : v.value || v.url; }).filter(function (url) { return url !== undefined; }); _.emit('update:modelValue', props.maxCount === 1 ? files[0] || '' : files); }; return { fileList: fileList, modelValue: modelValue, onDelete: function onDelete(file) { uploadValue(); _.emit('delete', file); }, uploadFile: function uploadFile(file) { var _this = this; file.status = 'uploading'; if (afterRead.value) { return afterRead.value(file); } else { var data = props.data || {}; data[props.uploadName || 'file'] = file.file; props.formCreateInject.api.fetch({ action: props.action, dataType: 'formData', source: 'upload', headers: props.headers || {}, method: props.method || 'post', data: data }).then(function (res) { file.status = 'success'; props.onSuccess && props.onSuccess(res, file); uploadValue(); })["catch"](function (e) { file.status = 'failed'; file.message = _this.formCreateInject.t('uploadFail') || '上传失败'; props.onError && props.onError(e, file); }); } } }; }, render: function render() { var _this2 = this; return createVNode(resolveComponent("van-uploader"), mergeProps$1(this.$attrs, { "model-value": this.fileList, "maxCount": this.maxCount, "onUpdate:model-value": function onUpdateModelValue(v) { return _this2.fileList = v; }, "afterRead": this.uploadFile, "onDelete": this.onDelete }), this.$slots); } }); function _isSlot(s) { return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s); } var NAME$4 = 'fcRadio'; var Radio = defineComponent({ name: NAME$4, inheritAttrs: false, props: { modelValue: [String, Number], options: Array }, emits: ['update:modelValue', 'change'], setup: function setup(props, _) { var modelValue = toRef(props, 'modelValue', []); var options = toRef(props, 'options'); return { options: options, modelValue: modelValue, onInput: function onInput(val) { _.emit('update:modelValue', val); _.emit('change', val); } }; }, render: function render() { var _slot; return createVNode(resolveComponent("van-radio-group"), mergeProps$1({ "direction": "horizontal" }, this.$attrs, { "modelValue": this.modelValue, "onUpdate:modelValue": this.onInput }), _isSlot(_slot = (this.options || []).map(function (opt) { var tmp = _objectSpread2({}, opt); var text = opt.text, value = opt.value; delete tmp.text; delete tmp.value; return createVNode(resolveComponent("van-radio"), mergeProps$1({ "name": value }, tmp), { "default": function _default() { return [text || opt.label || value]; } }); })) ? _slot : { "default": function _default() { return [_slot]; } }); } }); var NAME$3 = 'fcDatePicker'; var DatePicker = defineComponent({ name: NAME$3, inheritAttrs: false, props: { disabled: Boolean, clearable: Boolean, placeholder: String, modelValue: [String, Number], minDate: [String, Date], maxDate: [String, Date] }, emits: ['update:modelValue', 'fc.el', 'change'], setup: function setup(props, _) { var show = ref(false); var modelValue = toRef(props, 'modelValue'); var formValue = computed(function () { if (modelValue.value == null || modelValue.value === '') { return []; } return modelValue.value.split('-'); }); var dateRange = computed(function () { return { minDate: props.minDate ? dayjs(props.minDate).toDate() : undefined, maxDate: props.maxDate ? dayjs(props.maxDate).toDate() : undefined }; }); var onInput = function onInput(val) { _.emit('update:modelValue', val); _.emit('change', val); }; return { show: show, formValue: formValue, dateRange: dateRange, open: function open() { if (props.disabled) { return; } show.value = true; }, confirm: function confirm(_ref) { var selectedValues = _ref.selectedValues; onInput(selectedValues.join('-')); show.value = false; }, clear: function clear(e) { e.stopPropagation(); onInput(''); } }; }, render: function render() { var _this = this; var clearIcon = function clearIcon() { return _this.$props.clearable && _this.modelValue ? createVNode("i", { "class": "van-badge__wrapper van-icon van-icon-clear van-field__clear", "onClick": _this.clear }, null) : undefined; }; return createVNode("div", { "class": "_fc-date-picker" }, [createVNode(resolveComponent("van-field"), { "ref": "el", "placeholder": this.placeholder, "readonly": true, "disabled": this.$props.disabled, "onClick": this.open, "model-value": this.modelValue, "border": false, "isLink": true }, { 'right-icon': clearIcon }), createVNode(resolveComponent("van-popup"), { "show": this.show, "onUpdate:show": function onUpdateShow(v) { return _this.show = v; }, "round": true, "position": "bottom" }, { "default": function _default() { return [createVNode(resolveComponent("van-date-picker"), mergeProps$1({ "columnsType": ['year', 'month', 'day'] }, _objectSpread2(_objectSpread2({}, _this.$attrs), _this.dateRange), { "modelValue": _this.formValue, "onConfirm": _this.confirm, "onCancel": function onCancel() { return _this.show = false; } }), null)]; } })]); }, mounted: function mounted() { this.$emit('fc.el', this.$refs.el); } }); var NAME$2 = 'fcTimePicker'; var TimePicker = defineComponent({ name: NAME$2, inheritAttrs: false, props: { disabled: Boolean, clearable: Boolean, placeholder: String, modelValue: [String, Number] }, emits: ['update:modelValue', 'fc.el', 'change'], setup: function setup(props, _) { var show = ref(false); var modelValue = toRef(props, 'modelValue'); var formValue = computed(function () { if (modelValue.value == null || modelValue.value === '') { return []; } return modelValue.value.split(':'); }); var onInput = function onInput(val) { _.emit('update:modelValue', val); _.emit('change', val); }; return { show: show, formValue: formValue, open: function open() { if (props.disabled) { return; } show.value = true; }, confirm: function confirm(_ref) { var selectedValues = _ref.selectedValues; onInput(selectedValues.join(':')); show.value = false; }, clear: function clear(e) { e.stopPropagation(); onInput(''); } }; }, render: function render() { var _this = this; var clearIcon = function clearIcon() { return _this.$props.clearable && _this.modelValue ? createVNode("i", { "class": "van-badge__wrapper van-icon van-icon-clear van-field__clear", "onClick": _this.clear }, null) : undefined; }; return createVNode("div", { "class": "_fc-time-picker" }, [createVNode(resolveComponent("van-field"), { "ref": "el", "placeholder": this.placeholder, "readonly": true, "disabled": this.$props.disabled, "onClick": this.open, "model-value": this.modelValue, "border": false, "isLink": true }, { 'right-icon': clearIcon }), createVNode(resolveComponent("van-popup"), { "show": this.show, "onUpdate:show": function onUpdateShow(v) { return _this.show = v; }, "round": true, "position": "bottom" }, { "default": function _default() { return [createVNode(resolveComponent("van-time-picker"), mergeProps$1({ "columnsType": ['hour', 'minute'] }, _this.$attrs, { "modelValue": _this.formValue, "onConfirm": _this.confirm, "onCancel": function onCancel() { return _this.show = false; } }), null)]; } })]); }, mounted: function mounted() { this.$emit('fc.el', this.$refs.el); } }); 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 NAME$1 = 'fcGroup'; var Group = defineComponent({ name: NAME$1, 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": false }, disabled: { type: Boolean, "default": undefined }, 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 }, 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 = 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 = th