@form-create/element-ui 3.2.17 → 3.2.18

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.2.17
2
+ * @form-create/element-ui v3.2.18
3
3
  * (c) 2018-2025 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -202,11 +202,11 @@
202
202
  function getSlot(slots, exclude) {
203
203
  return Object.keys(slots).reduce(function (lst, name) {
204
204
  if (!exclude || exclude.indexOf(name) === -1) {
205
- lst.push(slots[name]);
205
+ lst[name] = slots[name];
206
206
  }
207
207
 
208
208
  return lst;
209
- }, []);
209
+ }, {});
210
210
  }
211
211
 
212
212
  function toArray(value) {
@@ -552,10 +552,6 @@
552
552
 
553
553
  script$2.render = render$2;
554
554
 
555
- function _isSlot(s) {
556
- return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
557
- }
558
-
559
555
  var NAME$7 = 'fcFrame';
560
556
  var Frame = vue.defineComponent({
561
557
  name: NAME$7,
@@ -595,11 +591,11 @@
595
591
  },
596
592
  okBtnText: {
597
593
  type: String,
598
- "default": '确定'
594
+ "default": ''
599
595
  },
600
596
  closeBtnText: {
601
597
  type: String,
602
- "default": '关闭'
598
+ "default": ''
603
599
  },
604
600
  modalTitle: String,
605
601
  handleIcon: {
@@ -933,18 +929,18 @@
933
929
  "onClick": function onClick() {
934
930
  return _this8.onCancel() !== false && (_this8.frameVisible = false);
935
931
  }
936
- }, _isSlot(closeBtnText) ? closeBtnText : {
932
+ }, {
937
933
  "default": function _default() {
938
- return [closeBtnText];
934
+ return [closeBtnText || _this8.formCreateInject.t('close') || '关闭'];
939
935
  }
940
936
  }) : null, okBtn ? vue.createVNode(vue.resolveComponent("ElButton"), {
941
937
  "type": "primary",
942
938
  "onClick": function onClick() {
943
939
  return _this8.onOk() !== false && _this8.closeModel();
944
940
  }
945
- }, _isSlot(okBtnText) ? okBtnText : {
941
+ }, {
946
942
  "default": function _default() {
947
- return [okBtnText];
943
+ return [okBtnText || _this8.formCreateInject.t('ok') || '确定'];
948
944
  }
949
945
  }) : null]);
950
946
  }
@@ -1416,8 +1412,10 @@
1416
1412
  props: {
1417
1413
  previewMask: undefined,
1418
1414
  onPreview: Function,
1415
+ httpRequest: Function,
1419
1416
  modalTitle: String,
1420
1417
  listType: String,
1418
+ formCreateInject: Object,
1421
1419
  modelValue: [Array, String, Object]
1422
1420
  },
1423
1421
  emits: ['update:modelValue', 'change', 'remove', 'fc.el'],
@@ -1470,6 +1468,14 @@
1470
1468
  handleRemove: function handleRemove(file, fileList) {
1471
1469
  this.$emit.apply(this, ['remove'].concat(Array.prototype.slice.call(arguments)));
1472
1470
  this.update(fileList);
1471
+ },
1472
+ doHttpRequest: function doHttpRequest(option) {
1473
+ if (this.httpRequest) {
1474
+ return this.httpRequest(option);
1475
+ } else {
1476
+ option.source = 'upload';
1477
+ this.formCreateInject.api.fetch(option);
1478
+ }
1473
1479
  }
1474
1480
  },
1475
1481
  render: function render() {
@@ -1490,6 +1496,7 @@
1490
1496
  "onPreview": this.handlePreview,
1491
1497
  "onChange": this.handleChange,
1492
1498
  "onRemove": this.handleRemove,
1499
+ "httpRequest": this.doHttpRequest,
1493
1500
  "fileList": this.fileList,
1494
1501
  "ref": "upload"
1495
1502
  }), _objectSpread2({
@@ -1502,7 +1509,7 @@
1502
1509
  "type": "primary"
1503
1510
  }, {
1504
1511
  "default": function _default() {
1505
- return [vue.createTextVNode("\u70B9\u51FB\u4E0A\u4F20")];
1512
+ return [_this.formCreateInject.t('clickToUpload') || '点击上传'];
1506
1513
  }
1507
1514
  }))];
1508
1515
  }
@@ -1780,6 +1787,7 @@
1780
1787
  return;
1781
1788
  }
1782
1789
 
1790
+ this.cacheRule[key].$f && this.cacheRule[key].$f.setValue(value);
1783
1791
  this.cache(key, value);
1784
1792
  },
1785
1793
  addRule: function addRule(i, emit) {
@@ -2516,7 +2524,7 @@
2516
2524
 
2517
2525
  var keyAttrs = ['type', 'slot', 'ignore', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key', 'slotUpdate', 'computed', 'preview', 'component', 'cache', 'modelEmit'];
2518
2526
  var arrayAttrs = ['validate', 'children', 'control'];
2519
- var normalAttrs = ['effect', 'deep'];
2527
+ var normalAttrs = ['effect', 'deep', 'renderSlots'];
2520
2528
  function attrs() {
2521
2529
  return [].concat(keyAttrs, _toConsumableArray(normalMerge), _toConsumableArray(toArrayMerge), _toConsumableArray(functionalMerge), arrayAttrs, normalAttrs);
2522
2530
  }
@@ -3003,6 +3011,13 @@
3003
3011
  var xhr = new XMLHttpRequest();
3004
3012
  var action = option.action || '';
3005
3013
 
3014
+ if (xhr.upload && option.onProgress) {
3015
+ xhr.upload.addEventListener('progress', function (evt) {
3016
+ evt.percent = evt.total > 0 ? evt.loaded / evt.total * 100 : 0;
3017
+ option.onProgress(evt);
3018
+ });
3019
+ }
3020
+
3006
3021
  if (option.query) {
3007
3022
  var queryString = new URLSearchParams(option.query).toString();
3008
3023
 
@@ -3028,18 +3043,22 @@
3028
3043
  xhr.open(option.method || 'get', action, true);
3029
3044
  var formData;
3030
3045
 
3031
- if (option.data) {
3032
- if ((option.dataType || '').toLowerCase() !== 'json') {
3046
+ if (option.data || option.file) {
3047
+ if (option.file || (option.dataType || '').toLowerCase() !== 'json') {
3033
3048
  formData = new FormData();
3034
- Object.keys(option.data).map(function (key) {
3049
+ Object.keys(option.data || {}).map(function (key) {
3035
3050
  formData.append(key, option.data[key]);
3036
3051
  });
3037
3052
  } else {
3038
- formData = JSON.stringify(option.data);
3053
+ formData = JSON.stringify(option.data || {});
3039
3054
  xhr.setRequestHeader('content-type', 'application/json');
3040
3055
  }
3041
3056
  }
3042
3057
 
3058
+ if (option.file) {
3059
+ formData.append(option.filename, option.file, option.file.name);
3060
+ }
3061
+
3043
3062
  if (option.withCredentials && 'withCredentials' in xhr) {
3044
3063
  xhr.withCredentials = true;
3045
3064
  }
@@ -3506,7 +3525,11 @@
3506
3525
  });
3507
3526
  });
3508
3527
  vue.nextTick(function () {
3509
- api.clearValidateState();
3528
+ vue.nextTick(function () {
3529
+ vue.nextTick(function () {
3530
+ api.clearValidateState(fields);
3531
+ });
3532
+ });
3510
3533
  });
3511
3534
 
3512
3535
  if (fields == null) {
@@ -3900,7 +3923,7 @@
3900
3923
  if (!this.cacheConfig[ctx.trueType]) {
3901
3924
  this.cacheConfig[ctx.trueType] = vue.computed(function () {
3902
3925
  var g = _this2.$handle.options.global;
3903
- return mergeRule({}, [g['*'], g[ctx.originType] || g[ctx.type] || g[ctx.type] || {}]);
3926
+ return mergeRule({}, [g['*'] || g["default"] || {}, g[ctx.originType] || g[ctx.type] || g[ctx.type] || {}]);
3904
3927
  });
3905
3928
  }
3906
3929
 
@@ -4002,6 +4025,14 @@
4002
4025
  children = _this4.renderChildren(_load, ctx);
4003
4026
  }
4004
4027
 
4028
+ Object.keys(prop.renderSlots || {}).forEach(function (key) {
4029
+ children[key] = function () {
4030
+ var rule = _this4.parseSide(prop.renderSlots[key], ctx);
4031
+
4032
+ return _this4.renderRule(rule);
4033
+ };
4034
+ });
4035
+
4005
4036
  var slot = _this4.getTypeSlot(ctx);
4006
4037
 
4007
4038
  var _vn;
@@ -4123,6 +4154,11 @@
4123
4154
  field: ctx.field,
4124
4155
  rule: ctx.rule,
4125
4156
  input: ctx.input,
4157
+ t: function t() {
4158
+ var _this6$$handle$api;
4159
+
4160
+ return (_this6$$handle$api = _this6.$handle.api).t.apply(_this6$$handle$api, arguments);
4161
+ },
4126
4162
  updateValue: function updateValue(data) {
4127
4163
  _this6.$handle.onUpdateValue(ctx, data);
4128
4164
  }
@@ -4752,7 +4788,9 @@
4752
4788
  parser.init(this);
4753
4789
  },
4754
4790
  initProp: function initProp() {
4755
- var _this3 = this;
4791
+ var _this3 = this,
4792
+ _this$refRule,
4793
+ _this$refRule$__$vali;
4756
4794
 
4757
4795
  var rule = _objectSpread2({}, this.rule);
4758
4796
 
@@ -4761,7 +4799,7 @@
4761
4799
  this.prop = mergeRule({}, [rule].concat(_toConsumableArray(Object.keys(this.payload).map(function (k) {
4762
4800
  return _this3.payload[k];
4763
4801
  })), [this.computed]));
4764
- this.prop.validate = [].concat(_toConsumableArray(this.refRule.__$validate.value || []), _toConsumableArray(this.prop.validate || []));
4802
+ this.prop.validate = [].concat(_toConsumableArray(((_this$refRule = this.refRule) === null || _this$refRule === void 0 ? void 0 : (_this$refRule$__$vali = _this$refRule.__$validate) === null || _this$refRule$__$vali === void 0 ? void 0 : _this$refRule$__$vali.value) || []), _toConsumableArray(this.prop.validate || []));
4765
4803
  },
4766
4804
  initNone: function initNone() {
4767
4805
  this.none = !(is.Undef(this.prop.display) || !!this.prop.display);
@@ -5330,6 +5368,8 @@
5330
5368
  function useInput(Handler) {
5331
5369
  extend(Handler.prototype, {
5332
5370
  setValue: function setValue(ctx, value, formValue, setFlag) {
5371
+ var _this = this;
5372
+
5333
5373
  if (ctx.deleted) return;
5334
5374
  ctx.rule.value = value;
5335
5375
  this.changeStatus = true;
@@ -5348,6 +5388,16 @@
5348
5388
  api: this.api,
5349
5389
  setFlag: setFlag || false
5350
5390
  });
5391
+
5392
+ if (setFlag) {
5393
+ vue.nextTick(function () {
5394
+ vue.nextTick(function () {
5395
+ vue.nextTick(function () {
5396
+ _this.api.clearValidateState(ctx.id);
5397
+ });
5398
+ });
5399
+ });
5400
+ }
5351
5401
  },
5352
5402
  onInput: function onInput(ctx, value) {
5353
5403
  var val;
@@ -5357,24 +5407,24 @@
5357
5407
  }
5358
5408
  },
5359
5409
  onUpdateValue: function onUpdateValue(ctx, data) {
5360
- var _this = this;
5410
+ var _this2 = this;
5361
5411
 
5362
5412
  this.deferSyncValue(function () {
5363
5413
  var group = ctx.getParentGroup();
5364
- var subForm = group ? _this.subRuleData[group.id] : null;
5414
+ var subForm = group ? _this2.subRuleData[group.id] : null;
5365
5415
  var subData = {};
5366
5416
  Object.keys(data || {}).forEach(function (k) {
5367
5417
  if (subForm && hasProperty(subForm, k)) {
5368
5418
  subData[k] = data[k];
5369
- } else if (hasProperty(_this.api.form, k)) {
5370
- _this.api.form[k] = data[k];
5371
- } else if (_this.api.top !== _this.api && hasProperty(_this.api.top.form, k)) {
5372
- _this.api.top.form[k] = data[k];
5419
+ } else if (hasProperty(_this2.api.form, k)) {
5420
+ _this2.api.form[k] = data[k];
5421
+ } else if (_this2.api.top !== _this2.api && hasProperty(_this2.api.top.form, k)) {
5422
+ _this2.api.top.form[k] = data[k];
5373
5423
  }
5374
5424
  });
5375
5425
 
5376
5426
  if (Object.keys(subData).length) {
5377
- _this.api.setChildrenFormData(group.rule, subData);
5427
+ _this2.api.setChildrenFormData(group.rule, subData);
5378
5428
  }
5379
5429
  });
5380
5430
  },
@@ -5409,7 +5459,7 @@
5409
5459
  return this.formData[ctx.id];
5410
5460
  },
5411
5461
  syncForm: function syncForm() {
5412
- var _this2 = this;
5462
+ var _this3 = this;
5413
5463
 
5414
5464
  var data = vue.reactive({});
5415
5465
  var fields = this.fields();
@@ -5418,7 +5468,7 @@
5418
5468
  if (this.options.appendValue !== false) {
5419
5469
  Object.keys(this.appendData).reduce(function (initial, field) {
5420
5470
  if (fields.indexOf(field) === -1) {
5421
- initial[field] = vue.toRef(_this2.appendData, field);
5471
+ initial[field] = vue.toRef(_this3.appendData, field);
5422
5472
  }
5423
5473
 
5424
5474
  return initial;
@@ -5426,11 +5476,11 @@
5426
5476
  }
5427
5477
 
5428
5478
  fields.reduce(function (initial, field) {
5429
- var ctx = (_this2.fieldCtx[field] || []).filter(function (ctx) {
5430
- return !_this2.isIgnore(ctx.rule);
5431
- })[0] || _this2.fieldCtx[field][0];
5479
+ var ctx = (_this3.fieldCtx[field] || []).filter(function (ctx) {
5480
+ return !_this3.isIgnore(ctx.rule);
5481
+ })[0] || _this3.fieldCtx[field][0];
5432
5482
 
5433
- if (_this2.isIgnore(ctx.rule)) {
5483
+ if (_this3.isIgnore(ctx.rule)) {
5434
5484
  ignoreFields.push(field);
5435
5485
  }
5436
5486
 
@@ -5475,7 +5525,7 @@
5475
5525
  }
5476
5526
  },
5477
5527
  syncValue: function syncValue() {
5478
- var _this3 = this;
5528
+ var _this4 = this;
5479
5529
 
5480
5530
  if (this.deferSyncFn) {
5481
5531
  return this.deferSyncFn.sync = true;
@@ -5483,8 +5533,8 @@
5483
5533
 
5484
5534
  var data = {};
5485
5535
  Object.keys(this.form).forEach(function (k) {
5486
- if (_this3.ignoreFields.indexOf(k) === -1) {
5487
- data[k] = _this3.form[k];
5536
+ if (_this4.ignoreFields.indexOf(k) === -1) {
5537
+ data[k] = _this4.form[k];
5488
5538
  }
5489
5539
  });
5490
5540
  this.vm.setupState.updateValue(data);
@@ -5496,11 +5546,11 @@
5496
5546
  return (is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
5497
5547
  },
5498
5548
  refreshUpdate: function refreshUpdate(ctx, val, origin, field) {
5499
- var _this4 = this;
5549
+ var _this5 = this;
5500
5550
 
5501
5551
  if (is.Function(ctx.rule.update)) {
5502
5552
  var state = invoke(function () {
5503
- return ctx.rule.update(val, ctx.origin, _this4.api, {
5553
+ return ctx.rule.update(val, ctx.origin, _this5.api, {
5504
5554
  origin: origin || 'change',
5505
5555
  linkField: field
5506
5556
  });
@@ -5524,18 +5574,18 @@
5524
5574
  this.refreshUpdate(ctx, val, origin, field);
5525
5575
  },
5526
5576
  appendLink: function appendLink(ctx) {
5527
- var _this5 = this;
5577
+ var _this6 = this;
5528
5578
 
5529
5579
  var link = ctx.rule.link;
5530
5580
  is.trueArray(link) && link.forEach(function (field) {
5531
5581
  var fn = function fn() {
5532
- return _this5.refreshRule(ctx, ctx.rule.value, 'link', field);
5582
+ return _this6.refreshRule(ctx, ctx.rule.value, 'link', field);
5533
5583
  };
5534
5584
 
5535
- _this5.bus.$on('change-' + field, fn);
5585
+ _this6.bus.$on('change-' + field, fn);
5536
5586
 
5537
5587
  ctx.linkOn.push(function () {
5538
- return _this5.bus.$off('change-' + field, fn);
5588
+ return _this6.bus.$off('change-' + field, fn);
5539
5589
  });
5540
5590
  });
5541
5591
  },
@@ -6608,7 +6658,7 @@
6608
6658
  var loadData = {
6609
6659
  name: 'loadData',
6610
6660
  _fn: [],
6611
- mounted: function mounted(inject, rule, api) {
6661
+ loaded: function loaded(inject, rule, api) {
6612
6662
  this.deleted(inject);
6613
6663
  var attrs = toArray(inject.getValue());
6614
6664
  var unwatchs = [];
@@ -6925,7 +6975,7 @@
6925
6975
  var fetchAttr = {
6926
6976
  name: 'fetch',
6927
6977
  _fn: [],
6928
- mounted: function mounted() {
6978
+ loaded: function loaded() {
6929
6979
  run.apply(void 0, arguments);
6930
6980
  },
6931
6981
  watch: function watch() {
@@ -7010,6 +7060,20 @@
7010
7060
  return null;
7011
7061
  }
7012
7062
 
7063
+ function getSessionStorage(name) {
7064
+ var value = sessionStorage.getItem(name);
7065
+
7066
+ if (value) {
7067
+ try {
7068
+ return JSON.parse(value);
7069
+ } catch (e) {
7070
+ return value;
7071
+ }
7072
+ }
7073
+
7074
+ return null;
7075
+ }
7076
+
7013
7077
  function baseDriver(driver, name) {
7014
7078
  if (!name) {
7015
7079
  return null;
@@ -7034,6 +7098,9 @@
7034
7098
  function localStorageDriver(name) {
7035
7099
  return baseDriver(getLocalStorage, name);
7036
7100
  }
7101
+ function sessionStorageDriver(name) {
7102
+ return baseDriver(getSessionStorage, name);
7103
+ }
7037
7104
 
7038
7105
  function parseProp(name, id) {
7039
7106
  var prop;
@@ -7856,6 +7923,7 @@
7856
7923
  useStatic(prototype);
7857
7924
  setDataDriver('$cookie', cookieDriver);
7858
7925
  setDataDriver('$localStorage', localStorageDriver);
7926
+ setDataDriver('$sessionStorage', sessionStorageDriver);
7859
7927
  CreateNode.use({
7860
7928
  fragment: 'fcFragment'
7861
7929
  });
@@ -8087,7 +8155,7 @@
8087
8155
  type: 'primary',
8088
8156
  loading: false,
8089
8157
  disabled: false,
8090
- innerText: '提交',
8158
+ innerText: '',
8091
8159
  show: true,
8092
8160
  col: undefined,
8093
8161
  click: undefined
@@ -8096,7 +8164,7 @@
8096
8164
  type: 'default',
8097
8165
  loading: false,
8098
8166
  disabled: false,
8099
- innerText: '重置',
8167
+ innerText: '',
8100
8168
  show: false,
8101
8169
  col: undefined,
8102
8170
  click: undefined
@@ -8283,7 +8351,9 @@
8283
8351
  return !(!title.title && !title["native"] || isFalse(title.show));
8284
8352
  },
8285
8353
  makeInfo: function makeInfo(rule, uni, ctx) {
8286
- var _this5 = this;
8354
+ var _ctx$refRule,
8355
+ _ctx$refRule2,
8356
+ _this5 = this;
8287
8357
 
8288
8358
  var titleProp = _objectSpread2({}, rule.title);
8289
8359
 
@@ -8293,10 +8363,10 @@
8293
8363
  var form = this.options.form;
8294
8364
  var titleSlot = this.getSlot('title');
8295
8365
  var children = [titleSlot ? titleSlot({
8296
- title: ctx.refRule.__$title.value,
8366
+ title: (_ctx$refRule = ctx.refRule) === null || _ctx$refRule === void 0 ? void 0 : _ctx$refRule.__$title.value,
8297
8367
  rule: ctx.rule,
8298
8368
  options: this.options
8299
- }) : ctx.refRule.__$title.value + (form.labelSuffix || form['label-suffix'] || '')];
8369
+ }) : ((_ctx$refRule2 = ctx.refRule) === null || _ctx$refRule2 === void 0 ? void 0 : _ctx$refRule2.__$title.value) + (form.labelSuffix || form['label-suffix'] || '')];
8300
8370
 
8301
8371
  if (!isFalse(infoProp.show) && (infoProp.info || infoProp["native"]) && !isFalse(infoProp.icon)) {
8302
8372
  var prop = {
@@ -8312,7 +8382,9 @@
8312
8382
  var field = 'content';
8313
8383
 
8314
8384
  if (infoProp.info && !hasProperty(prop.props, field)) {
8315
- prop.props[field] = ctx.refRule.__$info.value;
8385
+ var _ctx$refRule3;
8386
+
8387
+ prop.props[field] = (_ctx$refRule3 = ctx.refRule) === null || _ctx$refRule3 === void 0 ? void 0 : _ctx$refRule3.__$info.value;
8316
8388
  }
8317
8389
 
8318
8390
  children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r(mergeProps([infoProp, prop]), _defineProperty({}, titleProp.slot || (isTip ? 'default' : 'reference'), function () {
@@ -8396,7 +8468,7 @@
8396
8468
 
8397
8469
  var resetBtn = _objectSpread2({}, this.options.resetBtn);
8398
8470
 
8399
- var innerText = resetBtn.innerText;
8471
+ var innerText = resetBtn.innerText || this.$handle.api.t('reset') || '重置';
8400
8472
  delete resetBtn.innerText;
8401
8473
  delete resetBtn.click;
8402
8474
  delete resetBtn.col;
@@ -8422,7 +8494,7 @@
8422
8494
 
8423
8495
  var submitBtn = _objectSpread2({}, this.options.submitBtn);
8424
8496
 
8425
- var innerText = submitBtn.innerText;
8497
+ var innerText = submitBtn.innerText || this.$handle.api.t('submit') || '提交';
8426
8498
  delete submitBtn.innerText;
8427
8499
  delete submitBtn.click;
8428
8500
  delete submitBtn.col;
@@ -8718,14 +8790,18 @@
8718
8790
  }
8719
8791
  }, val);
8720
8792
 
8793
+ var title = rule.__fc__.refRule.__$title.value;
8794
+
8721
8795
  if (!validate.message) {
8722
- validate.message = rule.__fc__.refRule.__$title.value + (api.getLocale() === 'en' ? ' is required' : '不能为空');
8796
+ validate.message = api.t('required', {
8797
+ title: title
8798
+ }) || title + (api.getLocale() === 'en' ? ' is required' : '不能为空');
8723
8799
  } else {
8724
8800
  var match = validate.message.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
8725
8801
 
8726
8802
  if (match) {
8727
8803
  validate.message = api.t(match[1], {
8728
- title: rule.__fc__.refRule.__$title.value
8804
+ title: title
8729
8805
  });
8730
8806
  }
8731
8807
  }
@@ -8787,7 +8863,7 @@
8787
8863
  function elmFormCreate() {
8788
8864
  return FormCreateFactory({
8789
8865
  ui: 'element-ui',
8790
- version: '3.2.17',
8866
+ version: '3.2.18',
8791
8867
  manager: manager,
8792
8868
  extendApi: extendApi,
8793
8869
  install: install,