@form-create/element-ui 3.1.29 → 3.1.31

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,5 +1,5 @@
1
1
  /*!
2
- * @form-create/element-ui v3.1.29
2
+ * @form-create/element-ui v3.1.31
3
3
  * (c) 2018-2024 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -261,7 +261,7 @@
261
261
  delete props.value;
262
262
  delete props.label;
263
263
  return vue.createVNode(Type, vue.mergeProps(props, {
264
- "label": value,
264
+ "label": label,
265
265
  "value": value,
266
266
  "key": name + index + '-' + value
267
267
  }), {
@@ -1008,7 +1008,7 @@
1008
1008
  delete props.value;
1009
1009
  delete props.label;
1010
1010
  return vue.createVNode(Type, vue.mergeProps(props, {
1011
- "label": value,
1011
+ "label": label,
1012
1012
  "value": value,
1013
1013
  "key": name + index + '-' + value
1014
1014
  }), {
@@ -1967,6 +1967,142 @@
1967
1967
 
1968
1968
  var components = [Checkbox, Frame, Radio, Select, Tree, Upload, Group, Sub, script];
1969
1969
 
1970
+ function toString(val) {
1971
+ return val == null ? '' : _typeof(val) === 'object' ? JSON.stringify(val, null, 2) : String(val);
1972
+ }
1973
+
1974
+ function toLine(name) {
1975
+ var line = name.replace(/([A-Z])/g, '-$1').toLocaleLowerCase();
1976
+ if (line.indexOf('-') === 0) line = line.substr(1);
1977
+ return line;
1978
+ }
1979
+ function upper(str) {
1980
+ return str.replace(str[0], str[0].toLocaleUpperCase());
1981
+ }
1982
+
1983
+ function format(type, msg, rule) {
1984
+ return "[form-create ".concat(type, "]: ").concat(msg) + (rule ? '\n\nrule: ' + JSON.stringify(rule.getRule ? rule.getRule() : rule) : '');
1985
+ }
1986
+ function err(msg, rule) {
1987
+ console.error(format('err', msg, rule));
1988
+ }
1989
+ function logError(e) {
1990
+ err(e.toString());
1991
+ console.error(e);
1992
+ }
1993
+
1994
+ var PREFIX = '[[FORM-CREATE-PREFIX-';
1995
+ var SUFFIX = '-FORM-CREATE-SUFFIX]]';
1996
+ var $T = '$FN:';
1997
+ var $TX = '$FNX:';
1998
+ var $ON = '$GLOBAL:';
1999
+ var FUNCTION = 'function';
2000
+ function toJson(obj, space) {
2001
+ return JSON.stringify(deepExtend(Array.isArray(obj) ? [] : {}, obj, true), function (key, val) {
2002
+ if (val && val._isVue === true) return undefined;
2003
+
2004
+ if (_typeof(val) !== FUNCTION) {
2005
+ return val;
2006
+ }
2007
+
2008
+ if (val.__json) {
2009
+ return val.__json;
2010
+ }
2011
+
2012
+ if (val.__origin) val = val.__origin;
2013
+ if (val.__emit) return undefined;
2014
+ return PREFIX + val + SUFFIX;
2015
+ }, space);
2016
+ }
2017
+
2018
+ function makeFn(fn) {
2019
+ return new Function('return ' + fn)();
2020
+ }
2021
+
2022
+ function parseFn(fn, mode) {
2023
+ if (fn && is.String(fn) && fn.length > 4) {
2024
+ var v = fn.trim();
2025
+ var flag = false;
2026
+
2027
+ try {
2028
+ if (v.indexOf(SUFFIX) > 0 && v.indexOf(PREFIX) === 0) {
2029
+ v = v.replace(SUFFIX, '').replace(PREFIX, '');
2030
+ flag = true;
2031
+ } else if (v.indexOf($T) === 0) {
2032
+ v = v.replace($T, '');
2033
+ flag = true;
2034
+ } else if (v.indexOf($ON) === 0) {
2035
+ var name = v.replace($ON, '');
2036
+
2037
+ v = function v() {
2038
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2039
+ args[_key] = arguments[_key];
2040
+ }
2041
+
2042
+ var callback = args[0].api.getGlobalEvent(name);
2043
+
2044
+ if (callback) {
2045
+ return callback.call.apply(callback, [this].concat(args));
2046
+ }
2047
+
2048
+ return undefined;
2049
+ };
2050
+
2051
+ v.__json = fn;
2052
+ v.__inject = true;
2053
+ return v;
2054
+ } else if (v.indexOf($TX) === 0) {
2055
+ v = makeFn('function($inject){' + v.replace($TX, '') + '}');
2056
+ v.__json = fn;
2057
+ v.__inject = true;
2058
+ return v;
2059
+ } else if (!mode && v.indexOf(FUNCTION) === 0 && v !== FUNCTION) {
2060
+ flag = true;
2061
+ }
2062
+
2063
+ if (!flag) return fn;
2064
+ var val = makeFn(v.indexOf(FUNCTION) === -1 && v.indexOf('(') !== 0 ? FUNCTION + ' ' + v : v);
2065
+ val.__json = fn;
2066
+ return val;
2067
+ } catch (e) {
2068
+ err("\u89E3\u6790\u5931\u8D25:".concat(v, "\n\nerr: ").concat(e));
2069
+ return undefined;
2070
+ }
2071
+ }
2072
+
2073
+ return fn;
2074
+ }
2075
+ function parseJson(json, mode) {
2076
+ return JSON.parse(json, function (k, v) {
2077
+ if (is.Undef(v) || !v.indexOf) return v;
2078
+ return parseFn(v, mode);
2079
+ });
2080
+ }
2081
+
2082
+ var id$2 = 0;
2083
+ function uniqueId() {
2084
+ var num = 370 + ++id$2;
2085
+ return 'F' + Math.random().toString(36).substr(3, 3) + Number("".concat(Date.now())).toString(36) + num.toString(36) + 'c';
2086
+ }
2087
+
2088
+ function deepSet(data, idx, val) {
2089
+ var _data = data,
2090
+ to;
2091
+ (idx || '').split('.').forEach(function (v) {
2092
+ if (to) {
2093
+ if (!_data[to] || _typeof(_data[to]) != 'object') {
2094
+ _data[to] = {};
2095
+ }
2096
+
2097
+ _data = _data[to];
2098
+ }
2099
+
2100
+ to = v;
2101
+ });
2102
+ _data[to] = val;
2103
+ return _data;
2104
+ }
2105
+
1970
2106
  var NAME$1 = 'FormCreate';
1971
2107
 
1972
2108
  var getRuleInject = function getRuleInject(vm, parent) {
@@ -2004,7 +2140,10 @@
2004
2140
  },
2005
2141
  extendOption: Boolean,
2006
2142
  modelValue: Object,
2007
- disabled: Boolean,
2143
+ disabled: {
2144
+ type: Boolean,
2145
+ "default": undefined
2146
+ },
2008
2147
  api: Object,
2009
2148
  name: String,
2010
2149
  subForm: {
@@ -2013,7 +2152,7 @@
2013
2152
  },
2014
2153
  inFor: Boolean
2015
2154
  },
2016
- emits: ['update:api', 'update:modelValue', 'mounted', 'submit', 'change', 'emit-event', 'control', 'remove-rule', 'remove-field', 'sync', 'reload', 'repeat-field', 'update', 'validate-field-fail', 'validate-fail'],
2155
+ emits: ['update:api', 'update:modelValue', 'mounted', 'submit', 'change', 'emit-event', 'control', 'remove-rule', 'remove-field', 'sync', 'reload', 'repeat-field', 'update', 'validate-field-fail', 'validate-fail', 'created'],
2017
2156
  render: function render() {
2018
2157
  return this.fc.render();
2019
2158
  },
@@ -2076,10 +2215,37 @@
2076
2215
  }
2077
2216
  };
2078
2217
 
2218
+ var styleEl = null;
2219
+ vue.onBeforeMount(function () {
2220
+ var content = '';
2221
+ var globalClass = props.option && props.option.globalClass || {};
2222
+ Object.keys(globalClass).forEach(function (k) {
2223
+ var subCss = '';
2224
+ globalClass[k].style && Object.keys(globalClass[k].style).forEach(function (key) {
2225
+ subCss += toLine(key) + ':' + globalClass[k].style[key] + ';';
2226
+ });
2227
+
2228
+ if (globalClass[k].content) {
2229
+ subCss += globalClass[k].content + ';';
2230
+ }
2231
+
2232
+ if (subCss) {
2233
+ content += ".".concat(k, "{").concat(subCss, "}");
2234
+ }
2235
+ });
2236
+
2237
+ if (content) {
2238
+ styleEl = document.createElement('style');
2239
+ styleEl.type = 'text/css';
2240
+ styleEl.innerHTML = content;
2241
+ document.head.appendChild(styleEl);
2242
+ }
2243
+ });
2079
2244
  vue.onMounted(function () {
2080
2245
  fc.mounted();
2081
2246
  });
2082
2247
  vue.onBeforeUnmount(function () {
2248
+ styleEl && document.head.removeChild(styleEl);
2083
2249
  rmSubForm();
2084
2250
  data.destroyed = true;
2085
2251
  fc.unmount();
@@ -2109,17 +2275,17 @@
2109
2275
  }, {
2110
2276
  deep: true
2111
2277
  });
2278
+ vue.watch(function () {
2279
+ return props.disabled;
2280
+ }, function () {
2281
+ fapi.refresh();
2282
+ });
2112
2283
  vue.watch(modelValue, function (n) {
2113
2284
  if (JSON.stringify(n || {}) === data.updateValue) return;
2114
2285
  fapi.config.forceCoverValue ? fapi.coverValue(n || {}) : fapi.setValue(n || {});
2115
2286
  }, {
2116
2287
  deep: true
2117
2288
  });
2118
- vue.watch(function () {
2119
- return props.disabled;
2120
- }, function (n) {
2121
- fapi.disabled(!!n);
2122
- });
2123
2289
  return _objectSpread2(_objectSpread2({
2124
2290
  fc: vue.markRaw(fc),
2125
2291
  parent: parent ? vue.markRaw(parent) : parent,
@@ -2133,16 +2299,21 @@
2133
2299
  },
2134
2300
  updateValue: function updateValue(value) {
2135
2301
  if (data.destroyed) return;
2136
- data.updateValue = JSON.stringify(value);
2302
+ var json = JSON.stringify(value);
2303
+
2304
+ if (data.updateValue === json) {
2305
+ return;
2306
+ }
2307
+
2308
+ data.updateValue = json;
2137
2309
  vm.emit('update:modelValue', value);
2138
2310
  }
2139
2311
  });
2140
2312
  },
2141
2313
  created: function created() {
2142
2314
  var vm = vue.getCurrentInstance();
2143
- vm.setupState.fc.init();
2144
2315
  vm.emit('update:api', vm.setupState.fapi);
2145
- vm.props.disabled && vm.setupState.fapi.disabled(true);
2316
+ vm.setupState.fc.init();
2146
2317
  }
2147
2318
  });
2148
2319
  }
@@ -2223,114 +2394,6 @@
2223
2394
  return [].concat(keyAttrs, _toConsumableArray(normalMerge), _toConsumableArray(toArrayMerge), _toConsumableArray(functionalMerge), arrayAttrs, normalAttrs);
2224
2395
  }
2225
2396
 
2226
- function format(type, msg, rule) {
2227
- return "[form-create ".concat(type, "]: ").concat(msg) + (rule ? '\n\nrule: ' + JSON.stringify(rule.getRule ? rule.getRule() : rule) : '');
2228
- }
2229
- function err(msg, rule) {
2230
- console.error(format('err', msg, rule));
2231
- }
2232
- function logError(e) {
2233
- err(e.toString());
2234
- console.error(e);
2235
- }
2236
-
2237
- function toLine(name) {
2238
- var line = name.replace(/([A-Z])/g, '-$1').toLocaleLowerCase();
2239
- if (line.indexOf('-') === 0) line = line.substr(1);
2240
- return line;
2241
- }
2242
- function upper(str) {
2243
- return str.replace(str[0], str[0].toLocaleUpperCase());
2244
- }
2245
-
2246
- var PREFIX = '[[FORM-CREATE-PREFIX-';
2247
- var SUFFIX = '-FORM-CREATE-SUFFIX]]';
2248
- var $T = '$FN:';
2249
- var $TX = '$FNX:';
2250
- var $ON = '$GLOBAL:';
2251
- var FUNCTION = 'function';
2252
- function toJson(obj, space) {
2253
- return JSON.stringify(deepExtend([], obj, true), function (key, val) {
2254
- if (val && val._isVue === true) return undefined;
2255
-
2256
- if (_typeof(val) !== FUNCTION) {
2257
- return val;
2258
- }
2259
-
2260
- if (val.__json) {
2261
- return val.__json;
2262
- }
2263
-
2264
- if (val.__origin) val = val.__origin;
2265
- if (val.__emit) return undefined;
2266
- return PREFIX + val + SUFFIX;
2267
- }, space);
2268
- }
2269
-
2270
- function makeFn(fn) {
2271
- return new Function('return ' + fn)();
2272
- }
2273
-
2274
- function parseFn(fn, mode) {
2275
- if (fn && is.String(fn) && fn.length > 4) {
2276
- var v = fn.trim();
2277
- var flag = false;
2278
-
2279
- try {
2280
- if (v.indexOf(SUFFIX) > 0 && v.indexOf(PREFIX) === 0) {
2281
- v = v.replace(SUFFIX, '').replace(PREFIX, '');
2282
- flag = true;
2283
- } else if (v.indexOf($T) === 0) {
2284
- v = v.replace($T, '');
2285
- flag = true;
2286
- } else if (v.indexOf($ON) === 0) {
2287
- var name = v.replace($ON, '');
2288
-
2289
- v = function v() {
2290
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2291
- args[_key] = arguments[_key];
2292
- }
2293
-
2294
- var callback = args[0].api.getGlobalEvent(name);
2295
-
2296
- if (callback) {
2297
- return callback.call.apply(callback, [this].concat(args));
2298
- }
2299
-
2300
- return undefined;
2301
- };
2302
-
2303
- v.__json = fn;
2304
- v.__inject = true;
2305
- return v;
2306
- } else if (v.indexOf($TX) === 0) {
2307
- v = makeFn('function($inject){' + v.replace($TX, '') + '}');
2308
- v.__json = fn;
2309
- v.__inject = true;
2310
- return v;
2311
- } else if (!mode && v.indexOf(FUNCTION) === 0 && v !== FUNCTION) {
2312
- flag = true;
2313
- }
2314
-
2315
- if (!flag) return fn;
2316
- var val = makeFn(v.indexOf(FUNCTION) === -1 && v.indexOf('(') !== 0 ? FUNCTION + ' ' + v : v);
2317
- val.__json = fn;
2318
- return val;
2319
- } catch (e) {
2320
- err("\u89E3\u6790\u5931\u8D25:".concat(v, "\n\nerr: ").concat(e));
2321
- return undefined;
2322
- }
2323
- }
2324
-
2325
- return fn;
2326
- }
2327
- function parseJson(json, mode) {
2328
- return JSON.parse(json, function (k, v) {
2329
- if (is.Undef(v) || !v.indexOf) return v;
2330
- return parseFn(v, mode);
2331
- });
2332
- }
2333
-
2334
2397
  function enumerable(value, writable) {
2335
2398
  return {
2336
2399
  value: value,
@@ -2980,6 +3043,23 @@
2980
3043
  return origin ? ctx.origin : ctx.rule;
2981
3044
  }
2982
3045
  },
3046
+ getRenderRule: function getRenderRule(id) {
3047
+ var ctx = h.getCtx(id);
3048
+
3049
+ if (ctx) {
3050
+ return ctx.prop;
3051
+ }
3052
+ },
3053
+ getRefRule: function getRefRule(id) {
3054
+ var ctxs = h.getCtxs(id);
3055
+
3056
+ if (ctxs) {
3057
+ var rules = ctxs.map(function (ctx) {
3058
+ return ctx.rule;
3059
+ });
3060
+ return rules.length === 1 ? rules[0] : rules;
3061
+ }
3062
+ },
2983
3063
  setEffect: function setEffect(id, attr, value) {
2984
3064
  var ctx = h.getCtx(id);
2985
3065
 
@@ -3142,7 +3222,7 @@
3142
3222
  }
3143
3223
 
3144
3224
  if (config.type === 'fetch') {
3145
- asyncFetch(config).then(function (res) {
3225
+ api.fetch(config).then(function (res) {
3146
3226
  resolve({
3147
3227
  res: res,
3148
3228
  config: config
@@ -3173,12 +3253,21 @@
3173
3253
 
3174
3254
  (_h$vm = h.vm).emit.apply(_h$vm, [name].concat(args));
3175
3255
  },
3256
+ bus: h.bus,
3257
+ fetch: function fetch(opt) {
3258
+ h.options.beforeFetch && invoke(function () {
3259
+ return h.options.beforeFetch(opt, {
3260
+ api: api
3261
+ });
3262
+ });
3263
+ return asyncFetch(opt);
3264
+ },
3176
3265
  helper: {
3177
3266
  tidyFields: tidyFields,
3178
3267
  props: props
3179
3268
  }
3180
3269
  };
3181
- ['on', 'once', 'off', 'set'].forEach(function (n) {
3270
+ ['on', 'once', 'off'].forEach(function (n) {
3182
3271
  api[n] = function () {
3183
3272
  var _h$bus;
3184
3273
 
@@ -3200,6 +3289,10 @@
3200
3289
  }
3201
3290
 
3202
3291
  if (!this.cache[ctx.id]) {
3292
+ if (ctx.parent) {
3293
+ this.clearCache(ctx.parent);
3294
+ }
3295
+
3203
3296
  return;
3204
3297
  }
3205
3298
 
@@ -3207,6 +3300,10 @@
3207
3300
  this.$handle.refresh();
3208
3301
  }
3209
3302
 
3303
+ if (this.cache[ctx.id].parent) {
3304
+ this.clearCache(this.cache[ctx.id].parent);
3305
+ }
3306
+
3210
3307
  this.cache[ctx.id] = null;
3211
3308
  },
3212
3309
  clearCacheAll: function clearCacheAll() {
@@ -3243,34 +3340,6 @@
3243
3340
  return str.replace(str[0], str[0].toLowerCase());
3244
3341
  }
3245
3342
 
3246
- function toString(val) {
3247
- return val == null ? '' : _typeof(val) === 'object' ? JSON.stringify(val, null, 2) : String(val);
3248
- }
3249
-
3250
- var id$2 = 0;
3251
- function uniqueId() {
3252
- var num = 370 + ++id$2;
3253
- return 'F' + Math.random().toString(36).substr(3, 3) + Number("".concat(Date.now())).toString(36) + num.toString(36) + 'c';
3254
- }
3255
-
3256
- function deepSet(data, idx, val) {
3257
- var _data = data,
3258
- to;
3259
- (idx || '').split('.').forEach(function (v) {
3260
- if (to) {
3261
- if (!_data[to] || _typeof(_data[to]) != 'object') {
3262
- _data[to] = {};
3263
- }
3264
-
3265
- _data = _data[to];
3266
- }
3267
-
3268
- to = v;
3269
- });
3270
- _data[to] = val;
3271
- return _data;
3272
- }
3273
-
3274
3343
  function useRender$1(Render) {
3275
3344
  extend(Render.prototype, {
3276
3345
  initRender: function initRender() {
@@ -3472,8 +3541,8 @@
3472
3541
  }
3473
3542
  }
3474
3543
 
3475
- cacheFlag && !Object.keys(children).length && _this4.setCache(ctx, function () {
3476
- return _vn;
3544
+ cacheFlag && _this4.setCache(ctx, function () {
3545
+ return _this4.stable(_vn);
3477
3546
  }, parent);
3478
3547
  return _vn;
3479
3548
  };
@@ -3506,12 +3575,25 @@
3506
3575
  if (Array.isArray(vn.props["class"])) {
3507
3576
  vn.props["class"].push('fc-none');
3508
3577
  } else {
3509
- vn.props["class"] = [vn.props["class"], 'fc-none'];
3578
+ vn.props["class"] = vn.props["class"] ? [vn.props["class"], 'fc-none'] : 'fc-none';
3510
3579
  }
3511
3580
 
3512
3581
  return vn;
3513
3582
  }
3514
3583
  },
3584
+ stable: function stable(vn) {
3585
+ var _this5 = this;
3586
+
3587
+ var list = Array.isArray(vn) ? vn : [vn];
3588
+ list.forEach(function (v) {
3589
+ if (v && v.__v_isVNode && v.children && _typeof(v.children) === 'object') {
3590
+ v.children.$stable = true;
3591
+
3592
+ _this5.stable(v.children);
3593
+ }
3594
+ });
3595
+ return vn;
3596
+ },
3515
3597
  getModelField: function getModelField(ctx) {
3516
3598
  return ctx.rule.modelField || ctx.parser.modelField || this.fc.modelFields[this.vNode.aliasMap[ctx.type]] || this.fc.modelFields[ctx.type] || this.fc.modelFields[ctx.originType] || 'modelValue';
3517
3599
  },
@@ -3519,7 +3601,7 @@
3519
3601
  return ctx.type === 'fragment' || ctx.type === 'template';
3520
3602
  },
3521
3603
  injectProp: function injectProp(ctx) {
3522
- var _this5 = this;
3604
+ var _this6 = this;
3523
3605
 
3524
3606
  var state = this.vm.setupState;
3525
3607
 
@@ -3528,10 +3610,10 @@
3528
3610
  api: this.$handle.api,
3529
3611
  form: this.fc.create,
3530
3612
  subForm: function subForm(_subForm) {
3531
- _this5.$handle.addSubForm(ctx, _subForm);
3613
+ _this6.$handle.addSubForm(ctx, _subForm);
3532
3614
  },
3533
3615
  getSubForm: function getSubForm() {
3534
- return _this5.$handle.subForm[ctx.id];
3616
+ return _this6.$handle.subForm[ctx.id];
3535
3617
  },
3536
3618
  options: [],
3537
3619
  children: [],
@@ -3551,14 +3633,14 @@
3551
3633
  });
3552
3634
  return inject;
3553
3635
  },
3554
- ctxProp: function ctxProp(ctx, custom) {
3555
- var _this6 = this;
3636
+ ctxProp: function ctxProp(ctx) {
3637
+ var _this7 = this;
3556
3638
 
3557
3639
  var ref = ctx.ref,
3558
3640
  key = ctx.key,
3559
3641
  rule = ctx.rule;
3560
- this.$manager.mergeProp(ctx, custom);
3561
- ctx.parser.mergeProp(ctx, custom);
3642
+ this.$manager.mergeProp(ctx);
3643
+ ctx.parser.mergeProp(ctx);
3562
3644
  var props = [{
3563
3645
  ref: ref,
3564
3646
  key: rule.key || "".concat(key, "fc"),
@@ -3567,7 +3649,7 @@
3567
3649
  vnodeMounted: function vnodeMounted(vn) {
3568
3650
  vn.el.__rule__ = ctx.rule;
3569
3651
 
3570
- _this6.onMounted(ctx, vn.el);
3652
+ _this7.onMounted(ctx, vn.el);
3571
3653
  },
3572
3654
  'fc.el': function fcEl(el) {
3573
3655
  ctx.exportEl = el;
@@ -3579,17 +3661,21 @@
3579
3661
  }
3580
3662
  }];
3581
3663
 
3582
- if (!custom && ctx.input) {
3664
+ if (ctx.input) {
3665
+ if (this.vm.props.disabled !== undefined) {
3666
+ ctx.prop.props.disabled = !!this.vm.props.disabled;
3667
+ }
3668
+
3583
3669
  var field = this.getModelField(ctx);
3584
3670
  var model = {
3585
3671
  callback: function callback(value) {
3586
- _this6.onInput(ctx, value);
3672
+ _this7.onInput(ctx, value);
3587
3673
  },
3588
3674
  value: this.$handle.getFormData(ctx)
3589
3675
  };
3590
3676
  props.push({
3591
3677
  on: _objectSpread2(_defineProperty({}, "update:".concat(field), model.callback), ctx.prop.modelEmit ? _defineProperty({}, ctx.prop.modelEmit, function () {
3592
- return _this6.onEmitInput(ctx);
3678
+ return _this7.onEmitInput(ctx);
3593
3679
  }) : {}),
3594
3680
  props: _defineProperty({}, field, model.value)
3595
3681
  });
@@ -3616,7 +3702,7 @@
3616
3702
  this.$handle.setValue(ctx, ctx.parser.toValue(ctx.modelValue, ctx), ctx.modelValue);
3617
3703
  },
3618
3704
  renderChildren: function renderChildren(children, ctx) {
3619
- var _this7 = this;
3705
+ var _this8 = this;
3620
3706
 
3621
3707
  if (!is.trueArray(children)) return {};
3622
3708
  var slotBag = makeSlotBag();
@@ -3625,14 +3711,14 @@
3625
3711
  if (is.String(child)) return slotBag.setSlot(null, child);
3626
3712
 
3627
3713
  if (child.__fc__) {
3628
- return _this7.renderSlot(slotBag, child.__fc__, ctx);
3714
+ return _this8.renderSlot(slotBag, child.__fc__, ctx);
3629
3715
  }
3630
3716
 
3631
3717
  if (child.type) {
3632
3718
  vue.nextTick(function () {
3633
- _this7.$handle.loadChildren(children, ctx);
3719
+ _this8.$handle.loadChildren(children, ctx);
3634
3720
 
3635
- _this7.$handle.refresh();
3721
+ _this8.$handle.refresh();
3636
3722
  });
3637
3723
  }
3638
3724
  });
@@ -3646,7 +3732,7 @@
3646
3732
  return this.vNode.make(lower(ctx.originType), prop, children);
3647
3733
  },
3648
3734
  renderRule: function renderRule(rule, children, origin) {
3649
- var _this8 = this;
3735
+ var _this9 = this;
3650
3736
 
3651
3737
  if (!rule) return undefined;
3652
3738
  if (is.String(rule)) return rule;
@@ -3670,7 +3756,7 @@
3670
3756
  if (is.trueArray(rule.children)) {
3671
3757
  rule.children.forEach(function (v) {
3672
3758
  v && slotBag.setSlot(v === null || v === void 0 ? void 0 : v.slot, function () {
3673
- return _this8.renderRule(v);
3759
+ return _this9.renderRule(v);
3674
3760
  });
3675
3761
  });
3676
3762
  }
@@ -3751,23 +3837,27 @@
3751
3837
  var emit = rule.emit || [];
3752
3838
 
3753
3839
  if (is.trueArray(emit)) {
3754
- var emitKey = emitPrefix || field || name;
3755
-
3756
- if (emitKey) {
3757
- emit.forEach(function (eventName) {
3758
- if (!eventName) return;
3759
- var eventInject;
3760
-
3761
- if (is.Object(eventName)) {
3762
- eventInject = eventName.inject;
3763
- eventName = eventName.name;
3764
- }
3840
+ emit.forEach(function (eventName) {
3841
+ if (!eventName) return;
3842
+ var eventInject;
3843
+ var emitKey = emitPrefix || field || name;
3844
+
3845
+ if (is.Object(eventName)) {
3846
+ eventInject = eventName.inject;
3847
+ eventName = eventName.name;
3848
+ emitKey = eventName.prefix || emitKey;
3849
+ }
3765
3850
 
3851
+ if (emitKey) {
3766
3852
  var fieldKey = toLine("".concat(emitKey, "-").concat(eventName));
3767
3853
 
3768
3854
  var fn = function fn() {
3769
3855
  var _this2$vm, _this2$vm2, _this2$bus;
3770
3856
 
3857
+ if (_this2.vm.emitsOptions) {
3858
+ _this2.vm.emitsOptions[fieldKey] = null;
3859
+ }
3860
+
3771
3861
  for (var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++) {
3772
3862
  arg[_key] = arguments[_key];
3773
3863
  }
@@ -3788,8 +3878,8 @@
3788
3878
 
3789
3879
  event[eventName] = is.Undef(_inject) ? fn : _this2.inject(rule, fn, _inject);
3790
3880
  }
3791
- });
3792
- }
3881
+ }
3882
+ });
3793
3883
  }
3794
3884
 
3795
3885
  ctx.computed.on = event;
@@ -4104,6 +4194,20 @@
4104
4194
  initNone: function initNone() {
4105
4195
  this.none = !(is.Undef(this.prop.display) || !!this.prop.display);
4106
4196
  },
4197
+ injectValidate: function injectValidate() {
4198
+ var _this4 = this;
4199
+
4200
+ return toArray(this.prop.validate).map(function (item) {
4201
+ return _objectSpread2(_objectSpread2({}, item), {}, {
4202
+ inject: {
4203
+ id: _this4.id,
4204
+ field: _this4.field,
4205
+ rule: _this4.rule,
4206
+ api: _this4.$handle.api
4207
+ }
4208
+ });
4209
+ });
4210
+ },
4107
4211
  check: function check(handle) {
4108
4212
  return this.vm === handle.vm;
4109
4213
  },
@@ -4160,15 +4264,15 @@
4160
4264
  this.ctrlRule = [];
4161
4265
  },
4162
4266
  rm: function rm() {
4163
- var _this4 = this;
4267
+ var _this5 = this;
4164
4268
 
4165
4269
  var _rm = function _rm() {
4166
- var index = _this4.root.indexOf(_this4.origin);
4270
+ var index = _this5.root.indexOf(_this5.origin);
4167
4271
 
4168
4272
  if (index > -1) {
4169
- _this4.root.splice(index, 1);
4273
+ _this5.root.splice(index, 1);
4170
4274
 
4171
- _this4.$handle && _this4.$handle.refresh();
4275
+ _this5.$handle && _this5.$handle.refresh();
4172
4276
  }
4173
4277
  };
4174
4278
 
@@ -4179,17 +4283,17 @@
4179
4283
  }
4180
4284
 
4181
4285
  this.$handle.noWatch(function () {
4182
- _this4.$handle.deferSyncValue(function () {
4183
- _this4.rmCtrl();
4286
+ _this5.$handle.deferSyncValue(function () {
4287
+ _this5.rmCtrl();
4184
4288
 
4185
4289
  _rm();
4186
4290
 
4187
- _this4.$handle.rmCtx(_this4);
4291
+ _this5.$handle.rmCtx(_this5);
4188
4292
 
4189
- extend(_this4, {
4293
+ extend(_this5, {
4190
4294
  root: []
4191
4295
  });
4192
- }, _this4.input);
4296
+ }, _this5.input);
4193
4297
  });
4194
4298
  },
4195
4299
  update: function update(handle, init) {
@@ -4729,6 +4833,11 @@
4729
4833
  this.valueChange(ctx, value);
4730
4834
  this.vm.emit('change', ctx.field, value, ctx.origin, this.api, setFlag || false);
4731
4835
  this.effect(ctx, 'value');
4836
+ this.emitEvent('change', ctx.field, value, {
4837
+ rule: ctx.origin,
4838
+ api: this.api,
4839
+ setFlag: setFlag || false
4840
+ });
4732
4841
  },
4733
4842
  onInput: function onInput(ctx, value) {
4734
4843
  var val;
@@ -4820,13 +4929,14 @@
4820
4929
  isQuote: function isQuote(ctx, value) {
4821
4930
  return (is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
4822
4931
  },
4823
- refreshUpdate: function refreshUpdate(ctx, val, origin) {
4932
+ refreshUpdate: function refreshUpdate(ctx, val, origin, field) {
4824
4933
  var _this2 = this;
4825
4934
 
4826
4935
  if (is.Function(ctx.rule.update)) {
4827
4936
  var state = invoke(function () {
4828
4937
  return ctx.rule.update(val, ctx.origin, _this2.api, {
4829
- origin: origin || 'change'
4938
+ origin: origin || 'change',
4939
+ linkField: field
4830
4940
  });
4831
4941
  });
4832
4942
  if (state === undefined) return;
@@ -4837,7 +4947,7 @@
4837
4947
  this.refreshRule(ctx, val);
4838
4948
  this.bus.$emit('change-' + ctx.field, val);
4839
4949
  },
4840
- refreshRule: function refreshRule(ctx, val, origin) {
4950
+ refreshRule: function refreshRule(ctx, val, origin, field) {
4841
4951
  if (this.refreshControl(ctx)) {
4842
4952
  this.$render.clearCacheAll();
4843
4953
  this.loadRule();
@@ -4845,7 +4955,7 @@
4845
4955
  this.refresh();
4846
4956
  }
4847
4957
 
4848
- this.refreshUpdate(ctx, val, origin);
4958
+ this.refreshUpdate(ctx, val, origin, field);
4849
4959
  },
4850
4960
  appendLink: function appendLink(ctx) {
4851
4961
  var _this3 = this;
@@ -4853,7 +4963,7 @@
4853
4963
  var link = ctx.rule.link;
4854
4964
  is.trueArray(link) && link.forEach(function (field) {
4855
4965
  var fn = function fn() {
4856
- return _this3.refreshRule(ctx, ctx.rule.value, 'link');
4966
+ return _this3.refreshRule(ctx, ctx.rule.value, 'link', field);
4857
4967
  };
4858
4968
 
4859
4969
  _this3.bus.$on('change-' + field, fn);
@@ -5002,7 +5112,11 @@
5002
5112
  if (key === 'props' && ctx.input) {
5003
5113
  _this.setFormData(ctx, ctx.parser.toFormValue(ctx.rule.value, ctx));
5004
5114
  }
5005
- } else if (key === 'emit') _this.parseEmit(ctx);else if (['prefix', 'suffix'].indexOf(key) > -1) n && _this.loadFn(n, ctx.rule);else if (key === 'type') {
5115
+ } else if (key === 'emit') {
5116
+ _this.parseEmit(ctx);
5117
+ } else if (key === 'hidden' && Boolean(n) !== Boolean(o)) {
5118
+ _this.$render.clearCacheAll();
5119
+ } else if (['prefix', 'suffix'].indexOf(key) > -1) n && _this.loadFn(n, ctx.rule);else if (key === 'type') {
5006
5120
  ctx.updateType();
5007
5121
 
5008
5122
  _this.bindParser(ctx);
@@ -5040,47 +5154,55 @@
5040
5154
  _this.setValue(ctx, val.value, formValue, true);
5041
5155
  }
5042
5156
  }));
5043
- this.bus.$once('load-end', function () {
5044
- var computed = ctx.rule.computed;
5157
+ }
5045
5158
 
5046
- if (!computed) {
5047
- return;
5048
- }
5159
+ this.bus.$once('load-end', function () {
5160
+ var computed = ctx.rule.computed;
5049
5161
 
5050
- if (_typeof(computed) !== 'object') {
5051
- computed = {
5052
- value: computed
5053
- };
5054
- }
5162
+ if (!computed) {
5163
+ return;
5164
+ }
5055
5165
 
5056
- Object.keys(computed).forEach(function (k) {
5057
- ctx.watch.push(vue.watch(function () {
5058
- var item = computed[k];
5059
- if (!item) return undefined;
5060
- var fn;
5166
+ if (_typeof(computed) !== 'object') {
5167
+ computed = {
5168
+ value: computed
5169
+ };
5170
+ }
5061
5171
 
5062
- if (is.Function(item)) {
5063
- fn = function fn() {
5064
- return item(_this.api.form, _this.api);
5065
- };
5066
- } else {
5067
- var group = ctx.getParentGroup();
5172
+ Object.keys(computed).forEach(function (k) {
5173
+ ctx.watch.push(vue.watch(function () {
5174
+ var item = computed[k];
5175
+ if (!item) return undefined;
5176
+ var fn;
5068
5177
 
5069
- fn = function fn() {
5070
- return new Function('formulas', 'top', 'group', "with(top){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] || {} : {});
5071
- };
5072
- }
5178
+ if (is.Function(item)) {
5179
+ fn = function fn() {
5180
+ return item(_this.api.form, _this.api);
5181
+ };
5182
+ } else {
5183
+ var group = ctx.getParentGroup();
5073
5184
 
5074
- return invoke(fn, undefined);
5075
- }, function (n) {
5076
- deepSet(ctx.rule, k, n);
5077
- }, {
5078
- immediate: true
5079
- }));
5080
- });
5081
- });
5082
- }
5185
+ fn = function fn() {
5186
+ return new Function('formulas', 'top', 'group', '$rule', '$api', "with(top){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);
5187
+ };
5188
+ }
5083
5189
 
5190
+ return invoke(fn, undefined);
5191
+ }, function (n) {
5192
+ setTimeout(function () {
5193
+ if (k === 'value') {
5194
+ _this.onInput(ctx, n);
5195
+ } else if (k[0] === '$') {
5196
+ _this.api.setEffect(ctx.id, k, n);
5197
+ } else {
5198
+ deepSet(ctx.rule, k, n);
5199
+ }
5200
+ });
5201
+ }, {
5202
+ immediate: true
5203
+ }));
5204
+ });
5205
+ });
5084
5206
  this.watchEffect(ctx);
5085
5207
  },
5086
5208
  updateChildren: function updateChildren(ctx, n, o) {
@@ -5187,13 +5309,26 @@
5187
5309
  }
5188
5310
  },
5189
5311
  lifecycle: function lifecycle(name) {
5190
- var _this2 = this;
5191
-
5192
- var fn = this.options[name];
5193
- is.Function(fn) && invoke(function () {
5194
- return fn(_this2.api);
5195
- });
5196
5312
  this.vm.emit(name, this.api);
5313
+ this.emitEvent(name, this.api);
5314
+ },
5315
+ emitEvent: function emitEvent(name) {
5316
+ var _this$bus;
5317
+
5318
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
5319
+ args[_key - 1] = arguments[_key];
5320
+ }
5321
+
5322
+ var _fn = this.options[name] || this.options[toCase('on-' + name)];
5323
+
5324
+ if (_fn) {
5325
+ var fn = parseFn(_fn);
5326
+ is.Function(fn) && invoke(function () {
5327
+ return fn.apply(void 0, args);
5328
+ });
5329
+ }
5330
+
5331
+ (_this$bus = this.bus).$emit.apply(_this$bus, [name].concat(args));
5197
5332
  }
5198
5333
  });
5199
5334
  }
@@ -5420,6 +5555,8 @@
5420
5555
  this.loadRule();
5421
5556
 
5422
5557
  this.$manager.__init();
5558
+
5559
+ this.lifecycle('created');
5423
5560
  },
5424
5561
  isBreakWatch: function isBreakWatch() {
5425
5562
  return this.loading || this.noWatchFn || this.reloading;
@@ -6174,7 +6311,7 @@
6174
6311
  },
6175
6312
  mergeOptions: function mergeOptions(target, opt, parent) {
6176
6313
  opt = deepCopy(opt);
6177
- parent && ['page', 'onSubmit', 'mounted', 'reload', 'formData', 'el'].forEach(function (n) {
6314
+ parent && ['page', 'onSubmit', 'mounted', 'reload', 'formData', 'el', 'globalClass'].forEach(function (n) {
6178
6315
  delete opt[n];
6179
6316
  });
6180
6317
 
@@ -6562,8 +6699,8 @@
6562
6699
  var form = _this.form();
6563
6700
 
6564
6701
  if (form) {
6565
- form.validateField(field, function (res) {
6566
- res ? reject(res) : resolve(null);
6702
+ form.validateField(field, function (res, err) {
6703
+ err ? reject(err) : resolve(res);
6567
6704
  });
6568
6705
  } else {
6569
6706
  resolve();
@@ -6667,7 +6804,7 @@
6667
6804
  label: isTitle ? rule.title.title : undefined
6668
6805
  }, tidyRule(rule.wrap || {})), {}, {
6669
6806
  prop: ctx.id,
6670
- rules: rule.validate
6807
+ rules: ctx.injectValidate()
6671
6808
  }),
6672
6809
  "class": rule.className,
6673
6810
  key: "".concat(uni, "fi"),
@@ -6929,7 +7066,7 @@
6929
7066
  return maker;
6930
7067
  }
6931
7068
 
6932
- var css_248z = ".form-create .form-create .el-form-item{margin-bottom:22px}.form-create{width:100%}.form-create .fc-none,.form-create.is-preview .fc-clock{display:none!important}";
7069
+ var css_248z = ".form-create .form-create .el-form-item{margin-bottom:22px}.form-create{width:100%}.form-create .fc-none,.form-create.is-preview .fc-clock{display:none!important}.form-create.is-preview .el-form-item.is-required>.el-form-item__label-wrap>.el-form-item__label:before,.form-create.is-preview .el-form-item.is-required>.el-form-item__label:before{content:\"\"!important}";
6933
7070
  styleInject(css_248z);
6934
7071
 
6935
7072
  function tidyBtnProp(btn, def) {
@@ -7112,6 +7249,7 @@
7112
7249
 
7113
7250
  if (val.required === false) {
7114
7251
  inject.clearProp();
7252
+ api.clearValidateState([rule.field]);
7115
7253
  } else {
7116
7254
  var validate = _objectSpread2({
7117
7255
  required: true,
@@ -7182,7 +7320,7 @@
7182
7320
  function elmFormCreate() {
7183
7321
  return FormCreateFactory({
7184
7322
  ui: 'element-ui',
7185
- version: '3.1.29',
7323
+ version: '3.1.31',
7186
7324
  manager: manager,
7187
7325
  extendApi: extendApi,
7188
7326
  install: install,