@form-create/element-ui 3.2.7 → 3.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
1
  /*!
2
- * @form-create/element-ui v3.2.7
2
+ * @form-create/element-ui v3.2.9
3
3
  * (c) 2018-2024 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
6
6
  */
7
- import { defineComponent, toRef, ref, watch, createVNode, resolveComponent, mergeProps as mergeProps$1, openBlock, createElementBlock, createElementVNode, isVNode, nextTick, createTextVNode, markRaw, reactive, getCurrentInstance, provide, inject, toRefs, onBeforeMount, onMounted, onBeforeUnmount, onUpdated, computed, withDirectives, resolveDirective, createApp, h } from 'vue';
7
+ import { defineComponent, toRef, ref, watch, createVNode, resolveComponent, mergeProps as mergeProps$1, openBlock, createElementBlock, createElementVNode, isVNode, nextTick, createTextVNode, markRaw, reactive, getCurrentInstance, provide, inject, toRefs, onBeforeMount, watchEffect, onMounted, onBeforeUnmount, onUpdated, computed, withDirectives, resolveDirective, createApp, h } from 'vue';
8
8
 
9
9
  function ownKeys(object, enumerableOnly) {
10
10
  var keys = Object.keys(object);
@@ -277,11 +277,12 @@ var Checkbox = defineComponent({
277
277
  }
278
278
 
279
279
  return createVNode(Type, {
280
- "value": customValue.value,
281
- "label": customValue.value
280
+ "value": customValue.value || undefined,
281
+ "label": customValue.value || undefined
282
282
  }, {
283
283
  "default": function _default() {
284
284
  return [createVNode(resolveComponent("ElInput"), {
285
+ "size": "small",
285
286
  "modelValue": customValue.value,
286
287
  "onUpdate:modelValue": updateCustomValue
287
288
  }, null)];
@@ -1064,11 +1065,13 @@ var Radio = defineComponent({
1064
1065
  }
1065
1066
 
1066
1067
  return createVNode(Type, {
1067
- "value": customValue.value,
1068
- "label": customValue.value
1068
+ "checked": false,
1069
+ "value": customValue.value || undefined,
1070
+ "label": customValue.value || undefined
1069
1071
  }, {
1070
1072
  "default": function _default() {
1071
1073
  return [createVNode(resolveComponent("ElInput"), {
1074
+ "size": "small",
1072
1075
  "modelValue": customValue.value,
1073
1076
  "onUpdate:modelValue": updateCustomValue
1074
1077
  }, null)];
@@ -1283,7 +1286,7 @@ var Tree = defineComponent({
1283
1286
  return createVNode(resolveComponent("ElTree"), mergeProps$1(this.$attrs, {
1284
1287
  "ref": "tree",
1285
1288
  "onCheck": this.updateValue,
1286
- "onNode-click": this.updateValue
1289
+ "onNodeClick": this.updateValue
1287
1290
  }), this.$slots);
1288
1291
  },
1289
1292
  mounted: function mounted() {
@@ -1411,7 +1414,7 @@ var Upload = defineComponent({
1411
1414
  }, [createVNode(resolveComponent("ElUpload"), mergeProps$1({
1412
1415
  "key": len
1413
1416
  }, this.$attrs, {
1414
- "list-type": this.listType || 'picture-card',
1417
+ "listType": this.listType || 'picture-card',
1415
1418
  "class": {
1416
1419
  '_fc-exceed': this.$attrs.limit ? this.$attrs.limit <= len : false
1417
1420
  },
@@ -1821,13 +1824,18 @@ var Group = defineComponent({
1821
1824
  }, null);
1822
1825
  },
1823
1826
  changeSort: function changeSort(index, sort) {
1827
+ var _this10 = this;
1828
+
1824
1829
  var a = this.sort[index];
1825
1830
  this.sort[index] = this.sort[index + sort];
1826
1831
  this.sort[index + sort] = a;
1832
+ this.formCreateInject.subForm(this.sort.map(function (k) {
1833
+ return _this10.cacheRule[k].$f;
1834
+ }));
1827
1835
  this.formData(0);
1828
1836
  },
1829
1837
  makeIcon: function makeIcon(total, index, key) {
1830
- var _this10 = this;
1838
+ var _this11 = this;
1831
1839
 
1832
1840
  if (this.$slots.button) {
1833
1841
  return this.$slots.button({
@@ -1836,7 +1844,7 @@ var Group = defineComponent({
1836
1844
  vm: this,
1837
1845
  key: key,
1838
1846
  del: function del() {
1839
- return _this10.del(index, key);
1847
+ return _this11.del(index, key);
1840
1848
  },
1841
1849
  add: this.add
1842
1850
  });
@@ -1872,12 +1880,12 @@ var Group = defineComponent({
1872
1880
  }
1873
1881
  },
1874
1882
  created: function created() {
1875
- var _this11 = this;
1883
+ var _this12 = this;
1876
1884
 
1877
1885
  watch(function () {
1878
- return _objectSpread2({}, _this11.cacheRule);
1886
+ return _objectSpread2({}, _this12.cacheRule);
1879
1887
  }, function (n) {
1880
- _this11.sort = Object.keys(n);
1888
+ _this12.sort = Object.keys(n);
1881
1889
  }, {
1882
1890
  immediate: true
1883
1891
  });
@@ -1892,7 +1900,7 @@ var Group = defineComponent({
1892
1900
  }
1893
1901
  },
1894
1902
  render: function render() {
1895
- var _this12 = this;
1903
+ var _this13 = this;
1896
1904
 
1897
1905
  var keys = this.sort;
1898
1906
  var button = this.button;
@@ -1906,10 +1914,10 @@ var Group = defineComponent({
1906
1914
  "class": "_fc-group-plus-minus _fc-group-add fc-clock",
1907
1915
  "onClick": this.add
1908
1916
  }, null) : keys.map(function (key, index) {
1909
- var _this12$cacheRule$key = _this12.cacheRule[key],
1910
- rule = _this12$cacheRule$key.rule,
1911
- options = _this12$cacheRule$key.options;
1912
- var btn = button && !disabled ? _this12.makeIcon(keys.length, index, key) : [];
1917
+ var _this13$cacheRule$key = _this13.cacheRule[key],
1918
+ rule = _this13$cacheRule$key.rule,
1919
+ options = _this13$cacheRule$key.options;
1920
+ var btn = button && !disabled ? _this13.makeIcon(keys.length, index, key) : [];
1913
1921
  return createVNode("div", {
1914
1922
  "class": "_fc-group-container",
1915
1923
  "key": key
@@ -1918,20 +1926,20 @@ var Group = defineComponent({
1918
1926
  }, {
1919
1927
  disabled: disabled,
1920
1928
  'onUpdate:modelValue': function onUpdateModelValue(formData) {
1921
- return _this12.formData(key, formData);
1929
+ return _this13.formData(key, formData);
1922
1930
  },
1923
1931
  'onEmit-event': function onEmitEvent(name) {
1924
1932
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1925
1933
  args[_key - 1] = arguments[_key];
1926
1934
  }
1927
1935
 
1928
- return _this12.emitEvent(name, args, index, key);
1936
+ return _this13.emitEvent(name, args, index, key);
1929
1937
  },
1930
1938
  'onUpdate:api': function onUpdateApi($f) {
1931
- return _this12.add$f(index, key, $f);
1939
+ return _this13.add$f(index, key, $f);
1932
1940
  },
1933
1941
  inFor: true,
1934
- modelValue: _this12.field ? _defineProperty({}, _this12.field, _this12._value(_this12.modelValue[index])) : _this12.modelValue[index],
1942
+ modelValue: _this13.field ? _defineProperty({}, _this13.field, _this13._value(_this13.modelValue[index])) : _this13.modelValue[index],
1935
1943
  rule: rule,
1936
1944
  option: options,
1937
1945
  extendOption: true
@@ -2080,7 +2088,7 @@ function upper(str) {
2080
2088
  return str.replace(str[0], str[0].toLocaleUpperCase());
2081
2089
  }
2082
2090
 
2083
- var getRuleInject = function getRuleInject(vm, parent) {
2091
+ var _getGroupInject = function getGroupInject(vm, parent) {
2084
2092
  if (!vm || vm === parent) {
2085
2093
  return;
2086
2094
  }
@@ -2090,7 +2098,7 @@ var getRuleInject = function getRuleInject(vm, parent) {
2090
2098
  }
2091
2099
 
2092
2100
  if (vm.parent) {
2093
- return getRuleInject(vm.parent, parent);
2101
+ return _getGroupInject(vm.parent, parent);
2094
2102
  }
2095
2103
  };
2096
2104
 
@@ -2141,6 +2149,15 @@ function $FormCreate(FormCreate, components, directives) {
2141
2149
  var vm = getCurrentInstance();
2142
2150
  provide('parentFC', vm);
2143
2151
  var parent = inject('parentFC', null);
2152
+ var top = parent;
2153
+
2154
+ if (parent) {
2155
+ while (top.setupState.parent) {
2156
+ top = top.setupState.parent;
2157
+ }
2158
+ } else {
2159
+ top = vm;
2160
+ }
2144
2161
 
2145
2162
  var _toRefs = toRefs(props),
2146
2163
  rule = _toRefs.rule,
@@ -2162,7 +2179,7 @@ function $FormCreate(FormCreate, components, directives) {
2162
2179
 
2163
2180
  var addSubForm = function addSubForm() {
2164
2181
  if (parent) {
2165
- var _inject = getRuleInject(vm, parent);
2182
+ var _inject = _getGroupInject(vm, parent);
2166
2183
 
2167
2184
  if (_inject) {
2168
2185
  var sub;
@@ -2180,7 +2197,7 @@ function $FormCreate(FormCreate, components, directives) {
2180
2197
  };
2181
2198
 
2182
2199
  var rmSubForm = function rmSubForm() {
2183
- var inject = getRuleInject(vm, parent);
2200
+ var inject = _getGroupInject(vm, parent);
2184
2201
 
2185
2202
  if (inject) {
2186
2203
  if (isMore) {
@@ -2198,33 +2215,36 @@ function $FormCreate(FormCreate, components, directives) {
2198
2215
 
2199
2216
  var styleEl = null;
2200
2217
  onBeforeMount(function () {
2201
- var content = '';
2202
- var globalClass = props.option && props.option.globalClass || {};
2203
- Object.keys(globalClass).forEach(function (k) {
2204
- var subCss = '';
2205
- globalClass[k].style && Object.keys(globalClass[k].style).forEach(function (key) {
2206
- subCss += toLine(key) + ':' + globalClass[k].style[key] + ';';
2218
+ watchEffect(function () {
2219
+ var content = '';
2220
+ var globalClass = props.option && props.option.globalClass || {};
2221
+ Object.keys(globalClass).forEach(function (k) {
2222
+ var subCss = '';
2223
+ globalClass[k].style && Object.keys(globalClass[k].style).forEach(function (key) {
2224
+ subCss += toLine(key) + ':' + globalClass[k].style[key] + ';';
2225
+ });
2226
+
2227
+ if (globalClass[k].content) {
2228
+ subCss += globalClass[k].content + ';';
2229
+ }
2230
+
2231
+ if (subCss) {
2232
+ content += ".".concat(k, "{").concat(subCss, "}");
2233
+ }
2207
2234
  });
2208
2235
 
2209
- if (globalClass[k].content) {
2210
- subCss += globalClass[k].content + ';';
2236
+ if (props.option && props.option.style) {
2237
+ content += props.option.style;
2211
2238
  }
2212
2239
 
2213
- if (subCss) {
2214
- content += ".".concat(k, "{").concat(subCss, "}");
2240
+ if (!styleEl) {
2241
+ styleEl = document.createElement('style');
2242
+ styleEl.type = 'text/css';
2243
+ document.head.appendChild(styleEl);
2215
2244
  }
2216
- });
2217
-
2218
- if (props.option && props.option.style) {
2219
- content += props.option.style;
2220
- }
2221
2245
 
2222
- if (content) {
2223
- styleEl = document.createElement('style');
2224
- styleEl.type = 'text/css';
2225
- styleEl.innerHTML = content;
2226
- document.head.appendChild(styleEl);
2227
- }
2246
+ styleEl.innerHTML = content || '';
2247
+ });
2228
2248
  });
2229
2249
  var emit$topForm = debounce(function () {
2230
2250
  fc.bus.$emit('$loadData.$topForm');
@@ -2270,6 +2290,7 @@ function $FormCreate(FormCreate, components, directives) {
2270
2290
  if (fc.$handle.isBreakWatch() || n.length === data.renderRule.length && n.every(function (v) {
2271
2291
  return data.renderRule.indexOf(v) > -1;
2272
2292
  })) return;
2293
+ fc.$handle.updateAppendData();
2273
2294
  fc.$handle.reloadRule(rule.value);
2274
2295
  vm.setupState.renderRule();
2275
2296
  });
@@ -2295,12 +2316,14 @@ function $FormCreate(FormCreate, components, directives) {
2295
2316
  fapi.setValue(n || {});
2296
2317
  }
2297
2318
  }, {
2298
- deep: true
2319
+ deep: true,
2320
+ flush: 'post'
2299
2321
  });
2300
2322
  watch(function () {
2301
2323
  return props.index;
2302
2324
  }, function () {
2303
2325
  fapi.coverValue({});
2326
+ fc.$handle.updateAppendData();
2304
2327
  nextTick(function () {
2305
2328
  nextTick(function () {
2306
2329
  fapi.clearValidateState();
@@ -2312,8 +2335,12 @@ function $FormCreate(FormCreate, components, directives) {
2312
2335
  return _objectSpread2(_objectSpread2({
2313
2336
  fc: markRaw(fc),
2314
2337
  parent: parent ? markRaw(parent) : parent,
2338
+ top: markRaw(top),
2315
2339
  fapi: markRaw(fapi)
2316
2340
  }, toRefs(data)), {}, {
2341
+ getGroupInject: function getGroupInject() {
2342
+ return _getGroupInject(vm, parent);
2343
+ },
2317
2344
  refresh: function refresh() {
2318
2345
  ++data.unique;
2319
2346
  },
@@ -2419,7 +2446,7 @@ var mergeFn = function mergeFn(fn1, fn2) {
2419
2446
 
2420
2447
  var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key', 'slotUpdate', 'computed', 'preview', 'component', 'cache', 'modelEmit'];
2421
2448
  var arrayAttrs = ['validate', 'children', 'control'];
2422
- var normalAttrs = ['effect'];
2449
+ var normalAttrs = ['effect', 'deep'];
2423
2450
  function attrs() {
2424
2451
  return [].concat(keyAttrs, _toConsumableArray(normalMerge), _toConsumableArray(toArrayMerge), _toConsumableArray(functionalMerge), arrayAttrs, normalAttrs);
2425
2452
  }
@@ -2435,6 +2462,16 @@ function logError(e) {
2435
2462
  console.error(e);
2436
2463
  }
2437
2464
 
2465
+ function toCase(str) {
2466
+ var to = str.replace(/(-[a-z])/g, function (v) {
2467
+ return v.replace('-', '').toLocaleUpperCase();
2468
+ });
2469
+ return lower(to);
2470
+ }
2471
+ function lower(str) {
2472
+ return str.replace(str[0], str[0].toLowerCase());
2473
+ }
2474
+
2438
2475
  var PREFIX = '[[FORM-CREATE-PREFIX-';
2439
2476
  var SUFFIX = '-FORM-CREATE-SUFFIX]]';
2440
2477
  var $T = '$FN:';
@@ -2662,6 +2699,10 @@ function toProps(rule) {
2662
2699
  var prop = _objectSpread2({}, rule.props || {});
2663
2700
 
2664
2701
  Object.keys(rule.on || {}).forEach(function (k) {
2702
+ if (k.indexOf('-') > 0) {
2703
+ k = toCase(k);
2704
+ }
2705
+
2665
2706
  var name = "on".concat(upper(k));
2666
2707
 
2667
2708
  if (Array.isArray(prop[name])) {
@@ -3005,6 +3046,31 @@ function Api(h) {
3005
3046
  return allSubForm();
3006
3047
  },
3007
3048
 
3049
+ get siblings() {
3050
+ var inject = h.vm.setupState.getGroupInject();
3051
+
3052
+ if (inject) {
3053
+ var subForm = inject.getSubForm();
3054
+
3055
+ if (Array.isArray(subForm)) {
3056
+ return _toConsumableArray(subForm);
3057
+ }
3058
+ }
3059
+
3060
+ return undefined;
3061
+ },
3062
+
3063
+ get index() {
3064
+ var siblings = api.siblings;
3065
+
3066
+ if (siblings) {
3067
+ var idx = siblings.indexOf(api);
3068
+ return idx > -1 ? idx : undefined;
3069
+ }
3070
+
3071
+ return undefined;
3072
+ },
3073
+
3008
3074
  formData: function formData(fields) {
3009
3075
  return tidyFields(fields).reduce(function (initial, id) {
3010
3076
  var ctx = h.getFieldCtx(id);
@@ -3320,10 +3386,13 @@ function Api(h) {
3320
3386
  ctx.rule.value = copy(ctx.defaultValue);
3321
3387
  });
3322
3388
  });
3389
+ nextTick(function () {
3390
+ api.clearValidateState();
3391
+ });
3323
3392
  },
3324
3393
  method: function method(id, name) {
3325
3394
  var el = api.el(id);
3326
- if (!el || !el[name]) throw new Error(format('err', "".concat(name, "\u65B9\u6CD5\u4E0D\u5B58\u5728")));
3395
+ if (!el || !el[name]) throw new Error(format('err', "".concat(name, " \u65B9\u6CD5\u4E0D\u5B58\u5728")));
3327
3396
  return function () {
3328
3397
  return el[name].apply(el, arguments);
3329
3398
  };
@@ -3388,6 +3457,11 @@ function Api(h) {
3388
3457
  findRules(ctx ? ctx.loadChildrenPending() : rule.children);
3389
3458
  return rules;
3390
3459
  },
3460
+ getParentRule: function getParentRule(id) {
3461
+ var flag = _typeof(id) === 'object';
3462
+ var ctx = flag ? byCtx(id) : h.getCtx(id);
3463
+ return ctx.parent.rule;
3464
+ },
3391
3465
  getParentSubRule: function getParentSubRule(id) {
3392
3466
  var flag = _typeof(id) === 'object';
3393
3467
  var ctx = flag ? byCtx(id) : h.getCtx(id);
@@ -3496,8 +3570,8 @@ function Api(h) {
3496
3570
  getData: function getData(id, def) {
3497
3571
  return h.fc.getLoadData(id, def);
3498
3572
  },
3499
- setData: function setData(id, data) {
3500
- return h.fc.setData(id, data);
3573
+ setData: function setData(id, data, isGlobal) {
3574
+ return h.fc.setData(id, data, isGlobal);
3501
3575
  },
3502
3576
  refreshData: function refreshData(id) {
3503
3577
  return h.fc.refreshData(id);
@@ -3570,16 +3644,6 @@ function useCache(Render) {
3570
3644
  });
3571
3645
  }
3572
3646
 
3573
- function toCase(str) {
3574
- var to = str.replace(/(-[a-z])/g, function (v) {
3575
- return v.replace('-', '').toLocaleUpperCase();
3576
- });
3577
- return lower(to);
3578
- }
3579
- function lower(str) {
3580
- return str.replace(str[0], str[0].toLowerCase());
3581
- }
3582
-
3583
3647
  function toString(val) {
3584
3648
  return val == null ? '' : _typeof(val) === 'object' ? JSON.stringify(val, null, 2) : String(val);
3585
3649
  }
@@ -3738,7 +3802,7 @@ function useRender$1(Render) {
3738
3802
  this.setOptions(ctx);
3739
3803
  this.ctxProp(ctx);
3740
3804
  var prop = ctx.prop;
3741
- prop.preview = !!(prop.preview != null ? prop.preview : this.vm.props.preview !== undefined ? this.vm.props.preview : this.options.preview || false);
3805
+ prop.preview = !!(prop.preview != null ? prop.preview : this.$handle.preview);
3742
3806
  prop.props.formCreateInject = this.injectProp(ctx);
3743
3807
  var cacheFlag = prop.cache !== false;
3744
3808
  var preview = prop.preview;
@@ -3891,7 +3955,10 @@ function useRender$1(Render) {
3891
3955
  id: ctx.id,
3892
3956
  field: ctx.field,
3893
3957
  rule: ctx.rule,
3894
- input: ctx.input
3958
+ input: ctx.input,
3959
+ updateValue: function updateValue(data) {
3960
+ _this6.$handle.onUpdateValue(ctx, data);
3961
+ }
3895
3962
  };
3896
3963
  }
3897
3964
 
@@ -5024,11 +5091,23 @@ function useLoader(Handler) {
5024
5091
  }
5025
5092
  });
5026
5093
  });
5027
- hideLst.length && nextTick(function () {
5028
- hideLst.forEach(function (v) {
5029
- return v();
5030
- });
5031
- });
5094
+
5095
+ if (hideLst.length) {
5096
+ if (this.loading) {
5097
+ hideLst.length && this.bus.$once('load-end', function () {
5098
+ hideLst.forEach(function (v) {
5099
+ return v();
5100
+ });
5101
+ });
5102
+ } else {
5103
+ hideLst.length && nextTick(function () {
5104
+ hideLst.forEach(function (v) {
5105
+ return v();
5106
+ });
5107
+ });
5108
+ }
5109
+ }
5110
+
5032
5111
  this.vm.emit('control', ctx.origin, this.api);
5033
5112
  this.effect(ctx, 'control');
5034
5113
  return flag;
@@ -5207,7 +5286,10 @@ function useInput(Handler) {
5207
5286
  this.syncValue();
5208
5287
  },
5209
5288
  appendValue: function appendValue(rule) {
5210
- if (!rule.field || !hasProperty(this.appendData, rule.field)) return;
5289
+ if ((!rule.field || !hasProperty(this.appendData, rule.field)) && !this.options.forceCoverValue) {
5290
+ return;
5291
+ }
5292
+
5211
5293
  rule.value = this.appendData[rule.field];
5212
5294
  delete this.appendData[rule.field];
5213
5295
  },
@@ -5494,121 +5576,135 @@ function useContext(Handler) {
5494
5576
  }
5495
5577
 
5496
5578
  this.bus.$once('load-end', function () {
5497
- var computed = ctx.rule.computed;
5579
+ var computedRule = ctx.rule.computed;
5498
5580
 
5499
- if (!computed) {
5581
+ if (!computedRule) {
5500
5582
  return;
5501
5583
  }
5502
5584
 
5503
- if (_typeof(computed) !== 'object') {
5504
- computed = {
5505
- value: computed
5585
+ if (_typeof(computedRule) !== 'object') {
5586
+ computedRule = {
5587
+ value: computedRule
5506
5588
  };
5507
5589
  }
5508
5590
 
5509
- Object.keys(computed).forEach(function (k) {
5510
- ctx.watch.push(watch(function () {
5511
- var item = computed[k];
5591
+ Object.keys(computedRule).forEach(function (k) {
5592
+ var computedValue = computed(function () {
5593
+ var item = computedRule[k];
5512
5594
  if (!item) return undefined;
5513
- var fn;
5595
+ return _this.compute(ctx, item);
5596
+ });
5514
5597
 
5515
- if (_typeof(item) === 'object') {
5516
- var group = ctx.getParentGroup();
5598
+ var callback = function callback(n) {
5599
+ if (k === 'value') {
5600
+ _this.onInput(ctx, n);
5601
+ } else if (k[0] === '$') {
5602
+ _this.api.setEffect(ctx.id, k, n);
5603
+ } else {
5604
+ deepSet(ctx.rule, k, n);
5605
+ }
5606
+ };
5517
5607
 
5518
- var checkCondition = function checkCondition(item) {
5519
- item = Array.isArray(item) ? {
5520
- mode: 'AND',
5521
- group: item
5522
- } : item;
5608
+ if (k === 'value' ? [undefined, null, ''].indexOf(ctx.rule.value) > -1 : computedValue.value !== deepGet(ctx.rule, k)) {
5609
+ callback(computedValue.value);
5610
+ }
5523
5611
 
5524
- if (!is.trueArray(item.group)) {
5525
- return true;
5526
- }
5612
+ ctx.watch.push(watch(computedValue, function (n) {
5613
+ setTimeout(function () {
5614
+ callback(n);
5615
+ });
5616
+ }));
5617
+ });
5618
+ });
5619
+ this.watchEffect(ctx);
5620
+ },
5621
+ compute: function compute(ctx, item) {
5622
+ var _this2 = this;
5527
5623
 
5528
- var or = item.mode === 'OR';
5529
- var valid = true;
5624
+ var fn;
5530
5625
 
5531
- for (var i = 0; i < item.group.length; i++) {
5532
- var one = item.group[i];
5533
- var flag = void 0;
5626
+ if (_typeof(item) === 'object') {
5627
+ var group = ctx.getParentGroup();
5534
5628
 
5535
- if (one.mode) {
5536
- flag = checkCondition(one);
5537
- } else if (!condition[one.condition]) {
5538
- flag = false;
5539
- } else {
5540
- flag = new Function('_$', '_$val', '$form', '_group', "with($form){with(this){with(_group){ return _$['".concat(one.condition, "'](").concat(one.field, ", ").concat(one.compare ? one.compare : '_$val', "); }}}")).call(_this.api.form, condition, one.value, _this.api.top.form, group ? _this.subRuleData[group.id] || {} : {});
5541
- }
5629
+ var checkCondition = function checkCondition(item) {
5630
+ item = Array.isArray(item) ? {
5631
+ mode: 'AND',
5632
+ group: item
5633
+ } : item;
5542
5634
 
5543
- if (or && flag) {
5544
- return true;
5545
- }
5635
+ if (!is.trueArray(item.group)) {
5636
+ return true;
5637
+ }
5546
5638
 
5547
- if (!or) {
5548
- valid = valid && flag;
5549
- }
5550
- }
5639
+ var or = item.mode === 'OR';
5640
+ var valid = true;
5551
5641
 
5552
- return or ? false : valid;
5553
- };
5642
+ for (var i = 0; i < item.group.length; i++) {
5643
+ var one = item.group[i];
5644
+ var flag = void 0;
5554
5645
 
5555
- return checkCondition(item);
5556
- } else if (is.Function(item)) {
5557
- fn = function fn() {
5558
- return item(_this.api.form, _this.api);
5559
- };
5646
+ if (one.mode) {
5647
+ flag = checkCondition(one);
5648
+ } else if (!condition[one.condition]) {
5649
+ flag = false;
5560
5650
  } else {
5561
- var _group = ctx.getParentGroup();
5651
+ flag = new Function('$condition', '$val', '$form', '$group', "with($form){with(this){with($group){ return $condition['".concat(one.condition, "'](").concat(one.field, ", ").concat(one.compare ? one.compare : '$val', "); }}}")).call(_this2.api.form, condition, one.value, _this2.api.top.form, group ? _this2.subRuleData[group.id] || {} : {});
5652
+ }
5562
5653
 
5563
- fn = function fn() {
5564
- return new Function('_formulas', '$form', '_group', '$rule', '$api', "with($form){with(this){with(_group){with(_formulas){ return ".concat(item, " }}}}")).call(_this.api.form, _this.fc.formulas, _this.api.top.form, _group ? _this.subRuleData[_group.id] || {} : {}, ctx.rule, _this.api);
5565
- };
5654
+ if (or && flag) {
5655
+ return true;
5566
5656
  }
5567
5657
 
5568
- return invoke(fn, undefined);
5569
- }, function (n) {
5570
- setTimeout(function () {
5571
- if (k === 'value') {
5572
- _this.onInput(ctx, n);
5573
- } else if (k[0] === '$') {
5574
- _this.api.setEffect(ctx.id, k, n);
5575
- } else {
5576
- deepSet(ctx.rule, k, n);
5577
- }
5578
- });
5579
- }, {
5580
- immediate: k === 'value' ? [undefined, null, ''].indexOf(ctx.rule.value) > -1 : true
5581
- }));
5582
- });
5583
- });
5584
- this.watchEffect(ctx);
5658
+ if (!or) {
5659
+ valid = valid && flag;
5660
+ }
5661
+ }
5662
+
5663
+ return or ? false : valid;
5664
+ };
5665
+
5666
+ var val = checkCondition(item);
5667
+ return item.invert === true ? !val : val;
5668
+ } else if (is.Function(item)) {
5669
+ fn = function fn() {
5670
+ return item(_this2.api.form, _this2.api);
5671
+ };
5672
+ } else {
5673
+ var _group = ctx.getParentGroup();
5674
+
5675
+ fn = function fn() {
5676
+ return new Function('$formulas', '$form', '$group', '$rule', '$api', "with($form){with(this){with($group){with($formulas){ return ".concat(item, " }}}}")).call(_this2.api.form, _this2.fc.formulas, _this2.api.top.form, _group ? _this2.subRuleData[_group.id] || {} : {}, ctx.rule, _this2.api);
5677
+ };
5678
+ }
5679
+
5680
+ return invoke(fn, undefined);
5585
5681
  },
5586
5682
  updateChildren: function updateChildren(ctx, n, o) {
5587
- var _this2 = this;
5683
+ var _this3 = this;
5588
5684
 
5589
5685
  this.deferSyncValue(function () {
5590
5686
  o && o.forEach(function (child) {
5591
5687
  if ((n || []).indexOf(child) === -1 && child && !is.String(child) && child.__fc__ && child.__fc__.parent === ctx) {
5592
- _this2.rmCtx(child.__fc__);
5688
+ _this3.rmCtx(child.__fc__);
5593
5689
  }
5594
5690
  });
5595
5691
 
5596
5692
  if (is.trueArray(n)) {
5597
- _this2.loadChildren(n, ctx);
5693
+ _this3.loadChildren(n, ctx);
5598
5694
 
5599
- _this2.bus.$emit('update', _this2.api);
5695
+ _this3.bus.$emit('update', _this3.api);
5600
5696
  }
5601
5697
  });
5602
5698
  },
5603
5699
  rmSub: function rmSub(sub) {
5604
- var _this3 = this;
5700
+ var _this4 = this;
5605
5701
 
5606
5702
  is.trueArray(sub) && sub.forEach(function (r) {
5607
- r && r.__fc__ && _this3.rmCtx(r.__fc__);
5703
+ r && r.__fc__ && _this4.rmCtx(r.__fc__);
5608
5704
  });
5609
5705
  },
5610
5706
  rmCtx: function rmCtx(ctx) {
5611
- var _this4 = this;
5707
+ var _this5 = this;
5612
5708
 
5613
5709
  if (ctx.deleted) return;
5614
5710
  var id = ctx.id,
@@ -5637,19 +5733,19 @@ function useContext(Handler) {
5637
5733
  }
5638
5734
 
5639
5735
  this.deferSyncValue(function () {
5640
- if (!_this4.reloading) {
5736
+ if (!_this5.reloading) {
5641
5737
  if (ctx.parser.loadChildren !== false) {
5642
5738
  var children = ctx.getPending('children', ctx.rule.children);
5643
5739
 
5644
5740
  if (is.trueArray(children)) {
5645
5741
  children.forEach(function (h) {
5646
- return h.__fc__ && _this4.rmCtx(h.__fc__);
5742
+ return h.__fc__ && _this5.rmCtx(h.__fc__);
5647
5743
  });
5648
5744
  }
5649
5745
  }
5650
5746
 
5651
- if (ctx.root === _this4.rules) {
5652
- _this4.vm.setupState.renderRule();
5747
+ if (ctx.root === _this5.rules) {
5748
+ _this5.vm.setupState.renderRule();
5653
5749
  }
5654
5750
  }
5655
5751
  }, input);
@@ -5886,6 +5982,9 @@ function Handler(fc) {
5886
5982
  },
5887
5983
  bus: function bus() {
5888
5984
  return fc.bus;
5985
+ },
5986
+ preview: function preview() {
5987
+ return fc.vm.props.preview != null ? fc.vm.props.preview : this.options.preview || false;
5889
5988
  }
5890
5989
  });
5891
5990
  extend(this, {
@@ -5933,7 +6032,7 @@ extend(Handler.prototype, {
5933
6032
  });
5934
6033
  },
5935
6034
  init: function init() {
5936
- this.appendData = _objectSpread2(_objectSpread2(_objectSpread2({}, this.options.formData || {}), this.fc.vm.props.modelValue || {}), this.appendData);
6035
+ this.updateAppendData();
5937
6036
  this.useProvider();
5938
6037
  this.usePage();
5939
6038
  this.loadRule();
@@ -5942,6 +6041,9 @@ extend(Handler.prototype, {
5942
6041
 
5943
6042
  this.lifecycle('created');
5944
6043
  },
6044
+ updateAppendData: function updateAppendData() {
6045
+ this.appendData = _objectSpread2(_objectSpread2(_objectSpread2({}, this.options.formData || {}), this.fc.vm.props.modelValue || {}), this.appendData);
6046
+ },
5945
6047
  isBreakWatch: function isBreakWatch() {
5946
6048
  return this.loading || this.noWatchFn || this.reloading;
5947
6049
  },
@@ -6222,13 +6324,21 @@ var loadData = function loadData(fc) {
6222
6324
  var componentValidate = {
6223
6325
  name: 'componentValidate',
6224
6326
  load: function load(attr, rule, api) {
6225
- var method = attr.getValue();
6327
+ var options = attr.getValue();
6226
6328
 
6227
- if (!method) {
6329
+ if (!options || options.method === false) {
6228
6330
  attr.clearProp();
6229
6331
  api.clearValidateState([rule.field]);
6230
6332
  } else {
6231
- attr.getProp().validate = [{
6333
+ if (!is.Object(options)) {
6334
+ options = {
6335
+ method: options
6336
+ };
6337
+ }
6338
+
6339
+ var method = options.method;
6340
+ delete options.method;
6341
+ attr.getProp().validate = [_objectSpread2(_objectSpread2({}, options), {}, {
6232
6342
  validator: function validator() {
6233
6343
  var ctx = byCtx(rule);
6234
6344
 
@@ -6237,14 +6347,14 @@ var componentValidate = {
6237
6347
  args[_key] = arguments[_key];
6238
6348
  }
6239
6349
 
6240
- return api.exec.apply(api, [ctx.id, method === true ? 'formCreateValidate' : method].concat(args, [{
6350
+ return api.exec.apply(api, [ctx.id, is.String(method) ? method : 'formCreateValidate'].concat(args, [{
6241
6351
  attr: attr,
6242
6352
  rule: rule,
6243
6353
  api: api
6244
6354
  }]));
6245
6355
  }
6246
6356
  }
6247
- }];
6357
+ })];
6248
6358
  }
6249
6359
  },
6250
6360
  watch: function watch() {
@@ -6575,7 +6685,7 @@ function FormCreateFactory(config) {
6575
6685
 
6576
6686
  function register() {
6577
6687
  var data = nameProp.apply(void 0, arguments);
6578
- if (data.id && data.prop) providers[data.id] = _objectSpread2(_objectSpread2({}, data.prop), {}, {
6688
+ if (data.id && data.prop) providers[data.id] = is.Function(data.prop) ? data.prop : _objectSpread2(_objectSpread2({}, data.prop), {}, {
6579
6689
  name: data.id
6580
6690
  });
6581
6691
  }
@@ -6721,8 +6831,8 @@ function FormCreateFactory(config) {
6721
6831
  }
6722
6832
  }
6723
6833
 
6724
- function setData(id, data) {
6725
- loadData[id] = data;
6834
+ function _setData(id, data) {
6835
+ deepSet(loadData, id, data);
6726
6836
  refreshData(id);
6727
6837
  }
6728
6838
 
@@ -6738,7 +6848,8 @@ function FormCreateFactory(config) {
6738
6848
  };
6739
6849
 
6740
6850
  callback._driver = true;
6741
- setData(id, callback);
6851
+
6852
+ _setData(id, callback);
6742
6853
  }
6743
6854
 
6744
6855
  function getData(id, def) {
@@ -6799,8 +6910,6 @@ function FormCreateFactory(config) {
6799
6910
  },
6800
6911
  drivers: drivers,
6801
6912
  renderDriver: null,
6802
- setData: setData,
6803
- getData: getData,
6804
6913
  refreshData: refreshData,
6805
6914
  loadData: loadData,
6806
6915
  CreateNode: CreateNode,
@@ -6808,7 +6917,8 @@ function FormCreateFactory(config) {
6808
6917
  unwatch: [],
6809
6918
  options: ref({}),
6810
6919
  extendApiFn: extendApiFn,
6811
- fetchCache: new WeakMap()
6920
+ fetchCache: new WeakMap(),
6921
+ tmpData: {}
6812
6922
  });
6813
6923
  listener.forEach(function (item) {
6814
6924
  _this.bus.$on(item.name, item.callback);
@@ -6983,6 +7093,8 @@ function FormCreateFactory(config) {
6983
7093
  unwatch();
6984
7094
 
6985
7095
  _this5.bus.$emit('$loadData.$var.' + key);
7096
+
7097
+ return val;
6986
7098
  }
6987
7099
 
6988
7100
  val = invoke(function () {
@@ -6994,6 +7106,14 @@ function FormCreateFactory(config) {
6994
7106
  }
6995
7107
  }
6996
7108
  },
7109
+ setData: function setData(id, data, isGlobal) {
7110
+ if (!isGlobal) {
7111
+ deepSet(this.vm.setupState.top.setupState.fc.tmpData, id, data);
7112
+ this.bus.$emit('$loadData.' + id);
7113
+ } else {
7114
+ _setData(id, data);
7115
+ }
7116
+ },
6997
7117
  getLoadData: function getLoadData(id, def) {
6998
7118
  var val = null;
6999
7119
 
@@ -7014,11 +7134,12 @@ function FormCreateFactory(config) {
7014
7134
  val = this.globalVarDriver(split.join('.'));
7015
7135
  split = [];
7016
7136
  } else {
7017
- val = getData(id, def);
7137
+ var tmpData = this.vm.setupState.top.setupState.fc.tmpData;
7138
+ val = hasProperty(tmpData, key) ? deepGet(tmpData, id) : getData(key);
7018
7139
  split = [];
7019
7140
  }
7020
7141
 
7021
- if (split.length) {
7142
+ if (val && split.length) {
7022
7143
  val = deepGet(val, split);
7023
7144
  }
7024
7145
  }
@@ -7154,6 +7275,7 @@ function FormCreateFactory(config) {
7154
7275
  listener.forEach(function (item) {
7155
7276
  _this7.bus.$off(item.name, item.callback);
7156
7277
  });
7278
+ this.tmpData = {};
7157
7279
  this.unwatch.forEach(function (fn) {
7158
7280
  return fn();
7159
7281
  });
@@ -7176,7 +7298,7 @@ function FormCreateFactory(config) {
7176
7298
  extendApi: extendApi,
7177
7299
  getData: getData,
7178
7300
  setDataDriver: setDataDriver,
7179
- setData: setData,
7301
+ setData: _setData,
7180
7302
  removeData: removeData,
7181
7303
  refreshData: refreshData,
7182
7304
  maker: maker,
@@ -7594,7 +7716,7 @@ var manager = {
7594
7716
  e.preventDefault();
7595
7717
  }
7596
7718
  },
7597
- "class": [form.className, form["class"], 'form-create', this.options.preview ? 'is-preview' : ''],
7719
+ "class": [form.className, form["class"], 'form-create', this.$handle.preview ? 'is-preview' : ''],
7598
7720
  style: form.style,
7599
7721
  type: 'form'
7600
7722
  };
@@ -7614,7 +7736,7 @@ var manager = {
7614
7736
  render: function render(children) {
7615
7737
  var _this2 = this;
7616
7738
 
7617
- if (children.slotLen() && !this.options.preview) {
7739
+ if (children.slotLen() && !this.$handle.preview) {
7618
7740
  children.setSlot(undefined, function () {
7619
7741
  return _this2.makeFormBtn();
7620
7742
  });
@@ -7628,11 +7750,12 @@ var manager = {
7628
7750
  var rule = ctx.prop;
7629
7751
  var uni = "".concat(this.key).concat(ctx.key);
7630
7752
  var col = rule.col;
7631
- var isTitle = this.isTitle(rule);
7753
+ var isTitle = this.isTitle(rule) && rule.wrap.title !== false;
7632
7754
  var labelWidth = !col.labelWidth && !isTitle ? 0 : col.labelWidth;
7633
7755
  var _this$rule$props = this.rule.props,
7634
7756
  inline = _this$rule$props.inline,
7635
7757
  _col = _this$rule$props.col;
7758
+ delete rule.wrap.title;
7636
7759
  var item = isFalse(rule.wrap.show) ? children : this.$r(mergeProps([rule.wrap, {
7637
7760
  props: _objectSpread2(_objectSpread2({
7638
7761
  labelWidth: labelWidth === void 0 ? labelWidth : toString(labelWidth),
@@ -8156,7 +8279,7 @@ function install(FormCreate) {
8156
8279
  function elmFormCreate() {
8157
8280
  return FormCreateFactory({
8158
8281
  ui: 'element-ui',
8159
- version: '3.2.7',
8282
+ version: '3.2.9',
8160
8283
  manager: manager,
8161
8284
  extendApi: extendApi,
8162
8285
  install: install,