@form-create/element-ui 3.2.5 → 3.2.7

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.5
2
+ * @form-create/element-ui v3.2.7
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, Fragment, 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, 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);
@@ -1292,7 +1292,7 @@ var Tree = defineComponent({
1292
1292
  }
1293
1293
  });
1294
1294
 
1295
- var css_248z$2 = "._fc-exceed .el-upload{display:none}.el-upload-list.is-disabled .el-upload{cursor:not-allowed!important}";
1295
+ var css_248z$2 = "._fc-upload{width:100%}._fc-exceed .el-upload{display:none}.el-upload-list.is-disabled .el-upload{cursor:not-allowed!important}";
1296
1296
  styleInject(css_248z$2);
1297
1297
 
1298
1298
  var script$1 = {
@@ -1345,6 +1345,7 @@ var Upload = defineComponent({
1345
1345
  previewMask: undefined,
1346
1346
  onPreview: Function,
1347
1347
  modalTitle: String,
1348
+ listType: String,
1348
1349
  modelValue: [Array, String]
1349
1350
  },
1350
1351
  emits: ['update:modelValue', 'change', 'remove', 'fc.el'],
@@ -1368,8 +1369,12 @@ var Upload = defineComponent({
1368
1369
  if (this.onPreview) {
1369
1370
  this.onPreview.apply(this, arguments);
1370
1371
  } else {
1371
- this.previewImage = file.url;
1372
- this.previewVisible = true;
1372
+ if ('text' === this.listType) {
1373
+ window.open(file.url);
1374
+ } else {
1375
+ this.previewImage = file.url;
1376
+ this.previewVisible = true;
1377
+ }
1373
1378
  }
1374
1379
  },
1375
1380
  update: function update(fileList) {
@@ -1401,10 +1406,12 @@ var Upload = defineComponent({
1401
1406
  _this = this;
1402
1407
 
1403
1408
  var len = toArray(this.modelValue).length;
1404
- return createVNode(Fragment, null, [createVNode(resolveComponent("ElUpload"), mergeProps$1({
1405
- "key": len,
1406
- "list-type": "picture-card"
1409
+ return createVNode("div", {
1410
+ "class": "_fc-upload"
1411
+ }, [createVNode(resolveComponent("ElUpload"), mergeProps$1({
1412
+ "key": len
1407
1413
  }, this.$attrs, {
1414
+ "list-type": this.listType || 'picture-card',
1408
1415
  "class": {
1409
1416
  '_fc-exceed': this.$attrs.limit ? this.$attrs.limit <= len : false
1410
1417
  },
@@ -1415,10 +1422,16 @@ var Upload = defineComponent({
1415
1422
  "ref": "upload"
1416
1423
  }), _objectSpread2({
1417
1424
  "default": function _default() {
1418
- return [((_this$$slots$default = (_this$$slots = _this.$slots)["default"]) === null || _this$$slots$default === void 0 ? void 0 : _this$$slots$default.call(_this$$slots)) || createVNode(resolveComponent("ElIcon"), null, {
1425
+ return [(_this$$slots$default = (_this$$slots = _this.$slots)["default"]) !== null && _this$$slots$default !== void 0 && _this$$slots$default.call(_this$$slots) || ['text', 'picture'].indexOf(_this.listType) === -1 ? createVNode(resolveComponent("ElIcon"), null, {
1419
1426
  "default": function _default() {
1420
1427
  return [createVNode(script$1, null, null)];
1421
1428
  }
1429
+ }) : createVNode(resolveComponent("ElButton"), {
1430
+ "type": "primary"
1431
+ }, {
1432
+ "default": function _default() {
1433
+ return [createTextVNode("\u70B9\u51FB\u4E0A\u4F20")];
1434
+ }
1422
1435
  })];
1423
1436
  }
1424
1437
  }, getSlot(this.$slots, ['default']))), createVNode(resolveComponent("ElDialog"), {
@@ -2101,7 +2114,7 @@ function $FormCreate(FormCreate, components, directives) {
2101
2114
  }
2102
2115
  },
2103
2116
  extendOption: Boolean,
2104
- driver: String,
2117
+ driver: [String, Object],
2105
2118
  modelValue: Object,
2106
2119
  disabled: {
2107
2120
  type: Boolean,
@@ -2111,6 +2124,7 @@ function $FormCreate(FormCreate, components, directives) {
2111
2124
  type: Boolean,
2112
2125
  "default": undefined
2113
2126
  },
2127
+ index: [String, Number],
2114
2128
  api: Object,
2115
2129
  name: String,
2116
2130
  subForm: {
@@ -2276,7 +2290,6 @@ function $FormCreate(FormCreate, components, directives) {
2276
2290
  if (JSON.stringify(n || {}) === data.updateValue) return;
2277
2291
 
2278
2292
  if (fapi.config.forceCoverValue) {
2279
- fc.$handle.appendData = {};
2280
2293
  fapi.coverValue(n || {});
2281
2294
  } else {
2282
2295
  fapi.setValue(n || {});
@@ -2284,6 +2297,18 @@ function $FormCreate(FormCreate, components, directives) {
2284
2297
  }, {
2285
2298
  deep: true
2286
2299
  });
2300
+ watch(function () {
2301
+ return props.index;
2302
+ }, function () {
2303
+ fapi.coverValue({});
2304
+ nextTick(function () {
2305
+ nextTick(function () {
2306
+ fapi.clearValidateState();
2307
+ });
2308
+ });
2309
+ }, {
2310
+ flush: 'sync'
2311
+ });
2287
2312
  return _objectSpread2(_objectSpread2({
2288
2313
  fc: markRaw(fc),
2289
2314
  parent: parent ? markRaw(parent) : parent,
@@ -2997,6 +3022,7 @@ function Api(h) {
2997
3022
  var data = _objectSpread2({}, formData || {});
2998
3023
 
2999
3024
  h.deferSyncValue(function () {
3025
+ h.appendData = {};
3000
3026
  api.fields().forEach(function (key) {
3001
3027
  var ctxs = h.fieldCtx[key];
3002
3028
 
@@ -3009,7 +3035,7 @@ function Api(h) {
3009
3035
  }
3010
3036
  });
3011
3037
  extend(h.appendData, data);
3012
- });
3038
+ }, true);
3013
3039
  },
3014
3040
  setValue: function setValue(field) {
3015
3041
  var formData = field;
@@ -3022,7 +3048,7 @@ function Api(h) {
3022
3048
  ctx.rule.value = formData[key];
3023
3049
  });
3024
3050
  });
3025
- });
3051
+ }, true);
3026
3052
  },
3027
3053
  removeField: function removeField(field) {
3028
3054
  var ctx = h.getCtx(field);
@@ -3766,6 +3792,8 @@ function useRender$1(Render) {
3766
3792
  _vn = _this4.renderSides(_vn, ctx);
3767
3793
 
3768
3794
  if (!(!ctx.input && is.Undef(prop["native"])) && prop["native"] !== true) {
3795
+ _this4.fc.targetFormDriver('updateWrap', ctx);
3796
+
3769
3797
  _vn = _this4.$manager.makeWrap(ctx, _vn);
3770
3798
  }
3771
3799
 
@@ -4139,12 +4167,14 @@ function useInject(Handler) {
4139
4167
  return event;
4140
4168
  },
4141
4169
  getInjectData: function getInjectData(self, inject) {
4142
- var _this$vm$props = this.vm.props,
4143
- option = _this$vm$props.option,
4144
- rule = _this$vm$props.rule;
4170
+ var $api = self.__fc__ && self.__fc__.$api;
4171
+ var vm = self.__fc__ && self.__fc__.$handle.vm || this.vm.props;
4172
+ var _vm$props = vm.props,
4173
+ option = _vm$props.option,
4174
+ rule = _vm$props.rule;
4145
4175
  return {
4146
- $f: this.api,
4147
- api: this.api,
4176
+ $f: $api || this.api,
4177
+ api: $api || this.api,
4148
4178
  rule: rule,
4149
4179
  self: self.__origin__,
4150
4180
  option: option,
@@ -4776,6 +4806,11 @@ function useLoader(Handler) {
4776
4806
  return !!(rule.field && _this6.fieldCtx[rule.field] && _this6.fieldCtx[rule.field][0] !== _rule.__fc__);
4777
4807
  };
4778
4808
 
4809
+ _this6.fc.targetFormDriver('loadRule', {
4810
+ rule: rule,
4811
+ api: _this6.api
4812
+ }, _this6.fc);
4813
+
4779
4814
  _this6.ruleEffect(rule, 'init', {
4780
4815
  repeat: isRepeat()
4781
4816
  });
@@ -4821,10 +4856,10 @@ function useLoader(Handler) {
4821
4856
  } else {
4822
4857
  if (ctx.originType !== ctx.rule.type) {
4823
4858
  ctx.updateType();
4824
-
4825
- _this6.bindParser(ctx);
4826
4859
  }
4827
4860
 
4861
+ _this6.bindParser(ctx);
4862
+
4828
4863
  _this6.appendValue(ctx.rule);
4829
4864
 
4830
4865
  if (ctx.parent && ctx.parent !== parent) {
@@ -5194,7 +5229,7 @@ function useInput(Handler) {
5194
5229
  this.deferSyncFn = null;
5195
5230
 
5196
5231
  if (fn.sync) {
5197
- this.syncValue();
5232
+ this.syncForm();
5198
5233
  }
5199
5234
  }
5200
5235
  },
@@ -5652,6 +5687,7 @@ function useLifecycle(Handler) {
5652
5687
  }
5653
5688
  },
5654
5689
  lifecycle: function lifecycle(name) {
5690
+ this.fc.targetFormDriver(name, this.api, this.fc);
5655
5691
  this.vm.emit(name, this.api);
5656
5692
  this.emitEvent(name, this.api);
5657
5693
  },
@@ -6104,17 +6140,10 @@ extend(Manager.prototype, {
6104
6140
  }), opt, this.mergeOptionsRule);
6105
6141
  },
6106
6142
  updateOptions: function updateOptions(options) {
6107
- var _this3 = this;
6108
-
6109
- if (this.$handle.fc.renderDriver && this.$handle.fc.renderDriver.updateOptions) {
6110
- invoke(function () {
6111
- _this3.$handle.fc.renderDriver.updateOptions(options, {
6112
- handle: _this3.$handle,
6113
- api: _this3.$handle.api
6114
- });
6115
- });
6116
- }
6117
-
6143
+ this.$handle.fc.targetFormDriver('updateOptions', options, {
6144
+ handle: this.$handle,
6145
+ api: this.$handle.api
6146
+ });
6118
6147
  this.options = this.mergeOptions([options], this.getDefaultOptions());
6119
6148
  this.update();
6120
6149
  },
@@ -6824,14 +6853,39 @@ function FormCreateFactory(config) {
6824
6853
  }));
6825
6854
  }
6826
6855
 
6827
- var driver = this.vm.setupState.parent ? this.vm.setupState.parent.setupState.fc.renderDriver : this.vm.props.driver;
6828
- this.renderDriver = this.drivers[driver];
6856
+ if (this.vm.props.driver) {
6857
+ this.renderDriver = _typeof(this.vm.props.driver) === 'object' ? this.vm.props.driver : this.drivers[this.vm.props.driver];
6858
+ }
6859
+
6860
+ if (!this.renderDriver && this.vm.setupState.parent) {
6861
+ this.renderDriver = this.vm.setupState.parent.setupState.fc.renderDriver;
6862
+ }
6863
+
6864
+ if (!this.renderDriver) {
6865
+ this.renderDriver = this.drivers["default"];
6866
+ }
6867
+
6829
6868
  this.initOptions();
6830
6869
  this.$handle.init();
6831
6870
  },
6832
- globalDataDriver: function globalDataDriver(id) {
6871
+ targetFormDriver: function targetFormDriver(method) {
6833
6872
  var _this3 = this;
6834
6873
 
6874
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
6875
+ args[_key2 - 1] = arguments[_key2];
6876
+ }
6877
+
6878
+ if (this.renderDriver && this.renderDriver[method]) {
6879
+ return invoke(function () {
6880
+ var _this3$renderDriver;
6881
+
6882
+ return (_this3$renderDriver = _this3.renderDriver)[method].apply(_this3$renderDriver, args);
6883
+ });
6884
+ }
6885
+ },
6886
+ globalDataDriver: function globalDataDriver(id) {
6887
+ var _this4 = this;
6888
+
6835
6889
  var split = id.split('.');
6836
6890
  var key = split.shift();
6837
6891
  var option = this.options.value.globalData && this.options.value.globalData[key];
@@ -6863,28 +6917,28 @@ function FormCreateFactory(config) {
6863
6917
  var reload = debounce(function () {
6864
6918
  unwatch();
6865
6919
 
6866
- var res = _this3.fetchCache.get(option);
6920
+ var res = _this4.fetchCache.get(option);
6867
6921
 
6868
- if (_this3.options.value.globalData && Object.values(_this3.options.value.globalData).indexOf(option) !== -1) {
6922
+ if (_this4.options.value.globalData && Object.values(_this4.options.value.globalData).indexOf(option) !== -1) {
6869
6923
  if (res) {
6870
6924
  res.loading = true;
6871
6925
 
6872
- _this3.fetchCache.set(option, res);
6926
+ _this4.fetchCache.set(option, res);
6873
6927
  }
6874
6928
 
6875
- _this3.bus.$emit('$loadData.$globalData.' + key);
6929
+ _this4.bus.$emit('$loadData.$globalData.' + key);
6876
6930
  } else {
6877
- _this3.fetchCache["delete"](option);
6931
+ _this4.fetchCache["delete"](option);
6878
6932
  }
6879
6933
  }, option.wait || 600);
6880
6934
 
6881
6935
  var _emit = function _emit(data) {
6882
- _this3.fetchCache.set(option, {
6936
+ _this4.fetchCache.set(option, {
6883
6937
  status: true,
6884
6938
  data: data
6885
6939
  });
6886
6940
 
6887
- _this3.bus.$emit('$loadData.$globalData.' + key);
6941
+ _this4.bus.$emit('$loadData.$globalData.' + key);
6888
6942
  };
6889
6943
 
6890
6944
  var callback = function callback(get, change) {
@@ -6897,9 +6951,9 @@ function FormCreateFactory(config) {
6897
6951
  return;
6898
6952
  }
6899
6953
 
6900
- var options = _this3.$handle.loadFetchVar(copy$1(option), get);
6954
+ var options = _this4.$handle.loadFetchVar(copy$1(option), get);
6901
6955
 
6902
- _this3.$handle.api.fetch(options).then(function (res) {
6956
+ _this4.$handle.api.fetch(options).then(function (res) {
6903
6957
  _emit(res);
6904
6958
  })["catch"](function (e) {
6905
6959
  _emit(null);
@@ -6913,7 +6967,7 @@ function FormCreateFactory(config) {
6913
6967
  }
6914
6968
  },
6915
6969
  globalVarDriver: function globalVarDriver(id) {
6916
- var _this4 = this;
6970
+ var _this5 = this;
6917
6971
 
6918
6972
  var split = id.split('.');
6919
6973
  var key = split.shift();
@@ -6928,11 +6982,11 @@ function FormCreateFactory(config) {
6928
6982
  if (change) {
6929
6983
  unwatch();
6930
6984
 
6931
- _this4.bus.$emit('$loadData.$var.' + key);
6985
+ _this5.bus.$emit('$loadData.$var.' + key);
6932
6986
  }
6933
6987
 
6934
6988
  val = invoke(function () {
6935
- return handle(get, _this4.$handle.api);
6989
+ return handle(get, _this5.$handle.api);
6936
6990
  });
6937
6991
  });
6938
6992
  this.unwatch.push(unwatch);
@@ -6972,7 +7026,7 @@ function FormCreateFactory(config) {
6972
7026
  return val == null || val === '' ? def : val;
6973
7027
  },
6974
7028
  watchLoadData: function watchLoadData(fn) {
6975
- var _this5 = this;
7029
+ var _this6 = this;
6976
7030
 
6977
7031
  var unwatch = {};
6978
7032
 
@@ -6987,14 +7041,14 @@ function FormCreateFactory(config) {
6987
7041
  return unwatch[id].val;
6988
7042
  }
6989
7043
 
6990
- var val = _this5.getLoadData(id, def);
7044
+ var val = _this6.getLoadData(id, def);
6991
7045
 
6992
7046
  var split = id.split('.');
6993
7047
  var key = split.shift();
6994
7048
  var key2 = split.shift() || '';
6995
7049
  var callback = debounce(function () {
6996
7050
  if (key !== id) {
6997
- var temp = _this5.getLoadData(id, def);
7051
+ var temp = _this6.getLoadData(id, def);
6998
7052
 
6999
7053
  if (JSON.stringify(temp) !== JSON.stringify(unwatch[id].val)) {
7000
7054
  unwatch[id].val = temp;
@@ -7005,18 +7059,18 @@ function FormCreateFactory(config) {
7005
7059
  }
7006
7060
  }, 0);
7007
7061
 
7008
- _this5.bus.$on('$loadData.' + key, callback);
7062
+ _this6.bus.$on('$loadData.' + key, callback);
7009
7063
 
7010
7064
  if (key2) {
7011
- _this5.bus.$on('$loadData.' + key + '.' + key2, callback);
7065
+ _this6.bus.$on('$loadData.' + key + '.' + key2, callback);
7012
7066
  }
7013
7067
 
7014
7068
  unwatch[id] = {
7015
7069
  fn: function fn() {
7016
- _this5.bus.$off('$loadData.' + key, callback);
7070
+ _this6.bus.$off('$loadData.' + key, callback);
7017
7071
 
7018
7072
  if (key2) {
7019
- _this5.bus.$off('$loadData.' + key + '.' + key2, callback);
7073
+ _this6.bus.$off('$loadData.' + key + '.' + key2, callback);
7020
7074
  }
7021
7075
  },
7022
7076
  val: val
@@ -7086,7 +7140,7 @@ function FormCreateFactory(config) {
7086
7140
  this.$handle.mounted();
7087
7141
  },
7088
7142
  unmount: function unmount() {
7089
- var _this6 = this;
7143
+ var _this7 = this;
7090
7144
 
7091
7145
  if (this.name) {
7092
7146
  if (this.inFor) {
@@ -7098,7 +7152,7 @@ function FormCreateFactory(config) {
7098
7152
  }
7099
7153
 
7100
7154
  listener.forEach(function (item) {
7101
- _this6.bus.$off(item.name, item.callback);
7155
+ _this7.bus.$off(item.name, item.callback);
7102
7156
  });
7103
7157
  this.unwatch.forEach(function (fn) {
7104
7158
  return fn();
@@ -7107,10 +7161,10 @@ function FormCreateFactory(config) {
7107
7161
  this.$handle.reloadRule([]);
7108
7162
  },
7109
7163
  updated: function updated() {
7110
- var _this7 = this;
7164
+ var _this8 = this;
7111
7165
 
7112
7166
  this.$handle.bindNextTick(function () {
7113
- return _this7.bus.$emit('next-tick', _this7.$handle.api);
7167
+ return _this8.bus.$emit('next-tick', _this8.$handle.api);
7114
7168
  });
7115
7169
  }
7116
7170
  });
@@ -8102,7 +8156,7 @@ function install(FormCreate) {
8102
8156
  function elmFormCreate() {
8103
8157
  return FormCreateFactory({
8104
8158
  ui: 'element-ui',
8105
- version: '3.2.5',
8159
+ version: '3.2.7',
8106
8160
  manager: manager,
8107
8161
  extendApi: extendApi,
8108
8162
  install: install,