@form-create/element-ui 3.2.15 → 3.2.17
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.
- package/README.md +32 -13
- package/dist/form-create.esm.js +95 -63
- package/dist/form-create.esm.min.js +3 -3
- package/dist/form-create.js +95 -63
- package/dist/form-create.min.js +3 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -77,19 +77,38 @@
|
|
|
77
77
|
|
|
78
78
|
## 包说明
|
|
79
79
|
|
|
80
|
-
| 包名
|
|
81
|
-
|
|
82
|
-
| @form-create/element-ui [](https://www.npmjs.com/package/@form-create/element-ui)
|
|
83
|
-
| @form-create/ant-design-vue [](https://www.npmjs.com/package/@form-create/ant-design-vue)
|
|
84
|
-
| @form-create/arco-design [](https://www.npmjs.com/package/@form-create/arco-design)
|
|
85
|
-
| @form-create/naive-ui [](https://www.npmjs.com/package/@form-create/naive-ui)
|
|
86
|
-
| @form-create/tdesign [](https://www.npmjs.com/package/@form-create/tdesign)
|
|
87
|
-
| @form-create/iview [](https://www.npmjs.com/package/@form-create/iview)
|
|
88
|
-
| @form-create/view-design [](https://www.npmjs.com/package/@form-create/view-design)
|
|
89
|
-
| @form-create/vant [](https://www.npmjs.com/package/@form-create/vant)
|
|
90
|
-
| @form-create/designer [](https://www.npmjs.com/package/@form-create/designer)
|
|
91
|
-
| @form-create/vant-designer [](https://www.npmjs.com/package/@form-create/designer)
|
|
92
|
-
|
|
80
|
+
| 包名 | 说明 |
|
|
81
|
+
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------|
|
|
82
|
+
| @form-create/element-ui [](https://www.npmjs.com/package/@form-create/element-ui) | [element-plus 版本](http://form-create.com/v3/element-ui/) |
|
|
83
|
+
| @form-create/ant-design-vue [](https://www.npmjs.com/package/@form-create/ant-design-vue) | [ant-design-vue 版本](http://form-create.com/v3/ant-design-vue/) |
|
|
84
|
+
| @form-create/arco-design [](https://www.npmjs.com/package/@form-create/arco-design) | [arco-design 版本](http://form-create.com/v3/arco-design/) |
|
|
85
|
+
| @form-create/naive-ui [](https://www.npmjs.com/package/@form-create/naive-ui) | [naive-ui 版本](http://form-create.com/v3/naive-ui/) |
|
|
86
|
+
| @form-create/tdesign [](https://www.npmjs.com/package/@form-create/tdesign) | [tdesign 版本](http://form-create.com/v3/tdesign/) |
|
|
87
|
+
| @form-create/iview [](https://www.npmjs.com/package/@form-create/iview) | [iview 版本](http://form-create.com/v2/iview/) |
|
|
88
|
+
| @form-create/view-design [](https://www.npmjs.com/package/@form-create/view-design) | [view-design 版本](http://form-create.com/v2/iview/) |
|
|
89
|
+
| @form-create/vant [](https://www.npmjs.com/package/@form-create/vant) | [vant 版本(移动端)](http://form-create.com/v3/vant/) |
|
|
90
|
+
| @form-create/designer [](https://www.npmjs.com/package/@form-create/designer) | [可视化表单设计器](http://form-create.com/v3/designer) |
|
|
91
|
+
| @form-create/vant-designer [](https://www.npmjs.com/package/@form-create/designer) | [移动端表单设计器](http://form-create.com/v3/mobile) |
|
|
92
|
+
|
|
93
|
+
**分支说明**
|
|
94
|
+
|
|
95
|
+
- **latest:** Vue2.0版本分支
|
|
96
|
+
- **super:** Vue2.7版本分支(该版本功能和next分支功能一致)
|
|
97
|
+
- **next:** Vue3.0版本分支
|
|
98
|
+
|
|
99
|
+
例如:
|
|
100
|
+
|
|
101
|
+
安装Vue2版本的@form-create/element-ui
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
npm install @form-create/element-ui
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
安装Vue3版本的@form-create/element-ui
|
|
108
|
+
|
|
109
|
+
```sh
|
|
110
|
+
npm install @form-create/element-ui@next
|
|
111
|
+
```
|
|
93
112
|
|
|
94
113
|
## 示例
|
|
95
114
|
|
package/dist/form-create.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @form-create/element-ui v3.2.
|
|
3
|
-
* (c) 2018-
|
|
2
|
+
* @form-create/element-ui v3.2.17
|
|
3
|
+
* (c) 2018-2025 xaboy
|
|
4
4
|
* Github https://github.com/xaboy/form-create
|
|
5
5
|
* Released under the MIT License.
|
|
6
6
|
*/
|
|
@@ -2878,6 +2878,21 @@ function extractVar(str) {
|
|
|
2878
2878
|
|
|
2879
2879
|
return Object.keys(matches);
|
|
2880
2880
|
}
|
|
2881
|
+
function convertFieldToConditions(field) {
|
|
2882
|
+
var parts = field.split('.');
|
|
2883
|
+
var conditions = [];
|
|
2884
|
+
var currentCondition = '';
|
|
2885
|
+
parts.forEach(function (part, index) {
|
|
2886
|
+
if (index === 0) {
|
|
2887
|
+
currentCondition = part;
|
|
2888
|
+
} else {
|
|
2889
|
+
currentCondition += '.' + part;
|
|
2890
|
+
}
|
|
2891
|
+
|
|
2892
|
+
conditions.push(currentCondition);
|
|
2893
|
+
});
|
|
2894
|
+
return conditions.join(' && ');
|
|
2895
|
+
}
|
|
2881
2896
|
|
|
2882
2897
|
function baseRule() {
|
|
2883
2898
|
return {
|
|
@@ -3670,11 +3685,16 @@ function Api(h) {
|
|
|
3670
3685
|
});
|
|
3671
3686
|
});
|
|
3672
3687
|
},
|
|
3673
|
-
watchFetch: function watchFetch(opt, callback, error) {
|
|
3688
|
+
watchFetch: function watchFetch(opt, callback, error, beforeFetch) {
|
|
3674
3689
|
return h.fc.watchLoadData(function (get, change) {
|
|
3675
3690
|
var _opt = deepCopy(opt);
|
|
3676
3691
|
|
|
3677
3692
|
_opt = h.loadFetchVar(_opt, get);
|
|
3693
|
+
|
|
3694
|
+
if (beforeFetch && beforeFetch(_opt, change) === false) {
|
|
3695
|
+
return;
|
|
3696
|
+
}
|
|
3697
|
+
|
|
3678
3698
|
h.beforeFetch(_opt).then(function () {
|
|
3679
3699
|
return asyncFetch(_opt, h.fc.create.fetch, api).then(function (res) {
|
|
3680
3700
|
invoke(function () {
|
|
@@ -3688,7 +3708,7 @@ function Api(h) {
|
|
|
3688
3708
|
error && error(e);
|
|
3689
3709
|
});
|
|
3690
3710
|
});
|
|
3691
|
-
});
|
|
3711
|
+
}, opt.wait == null ? 1000 : opt.wait);
|
|
3692
3712
|
},
|
|
3693
3713
|
getData: function getData(id, def) {
|
|
3694
3714
|
return h.fc.getLoadData(id, def);
|
|
@@ -4450,24 +4470,16 @@ function useInject(Handler) {
|
|
|
4450
4470
|
return _this4.loadStrVar(str, get);
|
|
4451
4471
|
};
|
|
4452
4472
|
|
|
4453
|
-
options.action = loadVal(options.action);
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
if (options.data) {
|
|
4464
|
-
var _data = {};
|
|
4465
|
-
Object.keys(options.data).forEach(function (k) {
|
|
4466
|
-
_data[loadVal(k)] = loadVal(options.data[k]);
|
|
4467
|
-
});
|
|
4468
|
-
options.data = _data;
|
|
4469
|
-
}
|
|
4470
|
-
|
|
4473
|
+
options.action = loadVal(options.action || '');
|
|
4474
|
+
['headers', 'data', 'query'].forEach(function (key) {
|
|
4475
|
+
if (options[key]) {
|
|
4476
|
+
var data = {};
|
|
4477
|
+
Object.keys(options[key]).forEach(function (k) {
|
|
4478
|
+
data[loadVal(k)] = loadVal(options[key][k]);
|
|
4479
|
+
});
|
|
4480
|
+
options[key] = data;
|
|
4481
|
+
}
|
|
4482
|
+
});
|
|
4471
4483
|
return options;
|
|
4472
4484
|
}
|
|
4473
4485
|
});
|
|
@@ -4905,8 +4917,8 @@ function useLoader(Handler) {
|
|
|
4905
4917
|
var rule = ctx.rule;
|
|
4906
4918
|
is.trueArray(rule.sync) && mergeProps([{
|
|
4907
4919
|
on: rule.sync.reduce(function (pre, prop) {
|
|
4908
|
-
pre["update:".concat(prop)] = function (val) {
|
|
4909
|
-
rule.props[prop] = val;
|
|
4920
|
+
pre[_typeof(prop) === 'object' && prop.event || "update:".concat(prop)] = function (val) {
|
|
4921
|
+
rule.props[_typeof(prop) === 'object' && prop.prop || prop] = val;
|
|
4910
4922
|
|
|
4911
4923
|
_this4.vm.emit('sync', prop, val, rule, _this4.fapi);
|
|
4912
4924
|
};
|
|
@@ -5032,7 +5044,7 @@ function useLoader(Handler) {
|
|
|
5032
5044
|
return;
|
|
5033
5045
|
}
|
|
5034
5046
|
|
|
5035
|
-
rules[index] = _rule = _rule._clone ? _rule._clone() :
|
|
5047
|
+
rules[index] = _rule = _rule._clone ? _rule._clone() : parseJson(toJson(_rule));
|
|
5036
5048
|
ctx = null;
|
|
5037
5049
|
isCopy = true;
|
|
5038
5050
|
}
|
|
@@ -5560,6 +5572,7 @@ var BaseParser = {
|
|
|
5560
5572
|
};
|
|
5561
5573
|
|
|
5562
5574
|
var noneKey = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'slotUpdate', 'computed', 'component', 'cache'];
|
|
5575
|
+
var oldValueTag = Symbol('oldValue');
|
|
5563
5576
|
function useContext(Handler) {
|
|
5564
5577
|
extend(Handler.prototype, {
|
|
5565
5578
|
getCtx: function getCtx(id) {
|
|
@@ -5829,7 +5842,7 @@ function useContext(Handler) {
|
|
|
5829
5842
|
|
|
5830
5843
|
var value = _this.compute(ctx, item);
|
|
5831
5844
|
|
|
5832
|
-
if (item.linkage && value ===
|
|
5845
|
+
if (item.linkage && value === oldValueTag) {
|
|
5833
5846
|
return oldValue;
|
|
5834
5847
|
}
|
|
5835
5848
|
|
|
@@ -5884,10 +5897,22 @@ function useContext(Handler) {
|
|
|
5884
5897
|
var _loop = function _loop(i) {
|
|
5885
5898
|
var one = item.group[i];
|
|
5886
5899
|
var flag = void 0;
|
|
5887
|
-
var field =
|
|
5900
|
+
var field = null;
|
|
5888
5901
|
|
|
5889
5902
|
if (one.variable) {
|
|
5890
5903
|
field = JSON.stringify(_this2.fc.getLoadData(one.variable) || '');
|
|
5904
|
+
} else if (one.field) {
|
|
5905
|
+
field = convertFieldToConditions(one.field || '');
|
|
5906
|
+
} else {
|
|
5907
|
+
return {
|
|
5908
|
+
v: true
|
|
5909
|
+
};
|
|
5910
|
+
}
|
|
5911
|
+
|
|
5912
|
+
var compare = one.compare;
|
|
5913
|
+
|
|
5914
|
+
if (compare) {
|
|
5915
|
+
compare = convertFieldToConditions(compare || '');
|
|
5891
5916
|
}
|
|
5892
5917
|
|
|
5893
5918
|
if (one.mode) {
|
|
@@ -5899,7 +5924,7 @@ function useContext(Handler) {
|
|
|
5899
5924
|
return one.handler(_this2.api, ctx.rule);
|
|
5900
5925
|
});
|
|
5901
5926
|
} else {
|
|
5902
|
-
flag = new Function('$condition', '$val', '$form', '$group', '$rule', "with($form){with(this){with($group){ return $condition['".concat(one.condition, "'](").concat(field, ", ").concat(
|
|
5927
|
+
flag = new Function('$condition', '$val', '$form', '$group', '$rule', "with($form){with(this){with($group){ return $condition['".concat(one.condition, "'](").concat(field, ", ").concat(compare ? compare : '$val', "); }}}")).call(_this2.api.form, condition, one.value, _this2.api.top.form, group ? _this2.subRuleData[group.id] || {} : {}, ctx.rule);
|
|
5903
5928
|
}
|
|
5904
5929
|
|
|
5905
5930
|
if (or && flag) {
|
|
@@ -5928,7 +5953,7 @@ function useContext(Handler) {
|
|
|
5928
5953
|
if (item.linkage) {
|
|
5929
5954
|
return val ? invoke(function () {
|
|
5930
5955
|
return _this2.computeValue(item.linkage, ctx, group);
|
|
5931
|
-
}, undefined) :
|
|
5956
|
+
}, undefined) : oldValueTag;
|
|
5932
5957
|
}
|
|
5933
5958
|
|
|
5934
5959
|
return val;
|
|
@@ -6325,9 +6350,14 @@ function Handler(fc) {
|
|
|
6325
6350
|
this.$manager = new fc.manager(this);
|
|
6326
6351
|
this.$render = new Render(this);
|
|
6327
6352
|
this.api = fc.extendApiFn.reduce(function (api, fn) {
|
|
6328
|
-
|
|
6353
|
+
var extendApi = invoke(function () {
|
|
6329
6354
|
return fn(api, _this);
|
|
6330
|
-
}
|
|
6355
|
+
});
|
|
6356
|
+
|
|
6357
|
+
if (extendApi && extendApi !== api) {
|
|
6358
|
+
extend(api, extendApi);
|
|
6359
|
+
}
|
|
6360
|
+
|
|
6331
6361
|
return api;
|
|
6332
6362
|
}, Api(this));
|
|
6333
6363
|
}
|
|
@@ -6585,6 +6615,8 @@ var loadData = function loadData(fc) {
|
|
|
6585
6615
|
|
|
6586
6616
|
if (attr.template) {
|
|
6587
6617
|
value = fc.$handle.loadStrVar(attr.template, get);
|
|
6618
|
+
} else if (attr.handler && is.Function(attr.handler)) {
|
|
6619
|
+
value = attr.handler(get, rule, api);
|
|
6588
6620
|
} else {
|
|
6589
6621
|
value = get(attr.attr, attr["default"]);
|
|
6590
6622
|
}
|
|
@@ -7030,7 +7062,8 @@ function exportAttrs(attrs) {
|
|
|
7030
7062
|
}
|
|
7031
7063
|
|
|
7032
7064
|
var id = 1;
|
|
7033
|
-
var instance = {};
|
|
7065
|
+
var instance = {};
|
|
7066
|
+
var defValueTag = Symbol('defValue'); //todo 表单嵌套
|
|
7034
7067
|
|
|
7035
7068
|
function FormCreateFactory(config) {
|
|
7036
7069
|
var components = _defineProperty({}, fragment.name, fragment);
|
|
@@ -7253,7 +7286,11 @@ function FormCreateFactory(config) {
|
|
|
7253
7286
|
id = split.shift();
|
|
7254
7287
|
var field = split.join('.');
|
|
7255
7288
|
|
|
7256
|
-
if (hasProperty(loadData, id)) {
|
|
7289
|
+
if (!hasProperty(loadData, id)) {
|
|
7290
|
+
loadData[id] = defValueTag;
|
|
7291
|
+
}
|
|
7292
|
+
|
|
7293
|
+
if (loadData[id] !== defValueTag) {
|
|
7257
7294
|
var val = loadData[id];
|
|
7258
7295
|
|
|
7259
7296
|
if (val && val._driver) {
|
|
@@ -7306,6 +7343,7 @@ function FormCreateFactory(config) {
|
|
|
7306
7343
|
},
|
|
7307
7344
|
drivers: drivers,
|
|
7308
7345
|
renderDriver: null,
|
|
7346
|
+
get: null,
|
|
7309
7347
|
refreshData: refreshData,
|
|
7310
7348
|
loadData: loadData,
|
|
7311
7349
|
CreateNode: CreateNode,
|
|
@@ -7392,10 +7430,6 @@ function FormCreateFactory(config) {
|
|
|
7392
7430
|
t: function t(id, params, get) {
|
|
7393
7431
|
var value = get ? get('$t.' + id) : this.globalLanguageDriver(id);
|
|
7394
7432
|
|
|
7395
|
-
if (value == null && this.vm.appContext.config.globalProperties.$i18n) {
|
|
7396
|
-
return this.vm.appContext.config.globalProperties.$i18n.t(id, params);
|
|
7397
|
-
}
|
|
7398
|
-
|
|
7399
7433
|
if (value == null) {
|
|
7400
7434
|
value = '';
|
|
7401
7435
|
}
|
|
@@ -7503,10 +7537,6 @@ function FormCreateFactory(config) {
|
|
|
7503
7537
|
return locale;
|
|
7504
7538
|
}
|
|
7505
7539
|
|
|
7506
|
-
if (this.vm.appContext.config.globalProperties.$i18n && this.vm.appContext.config.globalProperties.$i18n.locale) {
|
|
7507
|
-
return this.vm.appContext.config.globalProperties.$i18n.locale;
|
|
7508
|
-
}
|
|
7509
|
-
|
|
7510
7540
|
return 'zh-cn';
|
|
7511
7541
|
},
|
|
7512
7542
|
globalLanguageDriver: function globalLanguageDriver(id) {
|
|
@@ -7535,25 +7565,14 @@ function FormCreateFactory(config) {
|
|
|
7535
7565
|
var option = this.options.value.globalVariable && this.options.value.globalVariable[key];
|
|
7536
7566
|
|
|
7537
7567
|
if (option) {
|
|
7538
|
-
var handle = is.Function(option) ? option : option.handle;
|
|
7568
|
+
var handle = is.Function(option) ? option : parseFn(option.handle);
|
|
7539
7569
|
|
|
7540
7570
|
if (handle) {
|
|
7541
|
-
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
_this5.bus.$emit('$loadData.$var.' + key);
|
|
7547
|
-
|
|
7548
|
-
return val;
|
|
7549
|
-
}
|
|
7550
|
-
|
|
7551
|
-
val = invoke(function () {
|
|
7552
|
-
return handle(get, _this5.$handle.api);
|
|
7553
|
-
});
|
|
7554
|
-
});
|
|
7555
|
-
this.unwatch.push(unwatch);
|
|
7556
|
-
return val;
|
|
7571
|
+
return deepGet(invoke(function () {
|
|
7572
|
+
return handle(_this5.get || function () {
|
|
7573
|
+
return _this5.getLoadData.apply(_this5, arguments);
|
|
7574
|
+
}, _this5.$handle.api);
|
|
7575
|
+
}), split);
|
|
7557
7576
|
}
|
|
7558
7577
|
}
|
|
7559
7578
|
},
|
|
@@ -7592,7 +7611,12 @@ function FormCreateFactory(config) {
|
|
|
7592
7611
|
split = [];
|
|
7593
7612
|
} else {
|
|
7594
7613
|
var tmpData = this.vm.setupState.top.setupState.fc.tmpData;
|
|
7595
|
-
|
|
7614
|
+
|
|
7615
|
+
if (!hasProperty(tmpData, key)) {
|
|
7616
|
+
tmpData[key] = defValueTag;
|
|
7617
|
+
}
|
|
7618
|
+
|
|
7619
|
+
val = tmpData[key] !== defValueTag ? deepGet(tmpData, id) : getData(id);
|
|
7596
7620
|
split = [];
|
|
7597
7621
|
}
|
|
7598
7622
|
|
|
@@ -7603,15 +7627,23 @@ function FormCreateFactory(config) {
|
|
|
7603
7627
|
|
|
7604
7628
|
return val == null || val === '' ? def : val;
|
|
7605
7629
|
},
|
|
7606
|
-
watchLoadData: function watchLoadData(fn) {
|
|
7630
|
+
watchLoadData: function watchLoadData(fn, wait) {
|
|
7607
7631
|
var _this6 = this;
|
|
7608
7632
|
|
|
7609
7633
|
var unwatch = {};
|
|
7610
7634
|
|
|
7611
7635
|
var run = function run(flag) {
|
|
7636
|
+
if (!_this6.get) {
|
|
7637
|
+
_this6.get = get;
|
|
7638
|
+
}
|
|
7639
|
+
|
|
7612
7640
|
invoke(function () {
|
|
7613
7641
|
fn(get, flag);
|
|
7614
7642
|
});
|
|
7643
|
+
|
|
7644
|
+
if (_this6.get === get) {
|
|
7645
|
+
_this6.get = undefined;
|
|
7646
|
+
}
|
|
7615
7647
|
};
|
|
7616
7648
|
|
|
7617
7649
|
var get = function get(id, def) {
|
|
@@ -7634,7 +7666,7 @@ function FormCreateFactory(config) {
|
|
|
7634
7666
|
unwatch[id].val = temp;
|
|
7635
7667
|
run(true);
|
|
7636
7668
|
}
|
|
7637
|
-
}, 0);
|
|
7669
|
+
}, wait || 0);
|
|
7638
7670
|
var un = watch(data, function (n) {
|
|
7639
7671
|
callback();
|
|
7640
7672
|
});
|
|
@@ -7694,7 +7726,7 @@ function FormCreateFactory(config) {
|
|
|
7694
7726
|
this.updateOptions(options);
|
|
7695
7727
|
},
|
|
7696
7728
|
mergeOptions: function mergeOptions(target, opt, parent) {
|
|
7697
|
-
opt =
|
|
7729
|
+
opt = _objectSpread2({}, opt || {});
|
|
7698
7730
|
parent && ['page', 'onSubmit', 'onReset', 'onCreated', 'onChange', 'onMounted', 'mounted', 'onReload', 'reload', 'formData', 'el', 'globalClass', 'style'].forEach(function (n) {
|
|
7699
7731
|
delete opt[n];
|
|
7700
7732
|
});
|
|
@@ -8751,7 +8783,7 @@ function install(FormCreate) {
|
|
|
8751
8783
|
function elmFormCreate() {
|
|
8752
8784
|
return FormCreateFactory({
|
|
8753
8785
|
ui: 'element-ui',
|
|
8754
|
-
version: '3.2.
|
|
8786
|
+
version: '3.2.17',
|
|
8755
8787
|
manager: manager,
|
|
8756
8788
|
extendApi: extendApi,
|
|
8757
8789
|
install: install,
|