@blueking/bkui-form 0.0.42 → 0.0.43
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/dist/adapter/vue2/common/FieldGroupWrap.d.ts +4 -3
- package/dist/adapter/vue2/field/ArrayField.d.ts +3 -3
- package/dist/adapter/vue2/field/BooleanField.d.ts +3 -3
- package/dist/adapter/vue2/field/CompositionField.d.ts +3 -3
- package/dist/adapter/vue2/field/NumberField.d.ts +3 -3
- package/dist/adapter/vue2/field/ObjectField.d.ts +1 -1
- package/dist/adapter/vue2/field/SchemaField.d.ts +1 -1
- package/dist/adapter/vue2/field/StringField.d.ts +3 -3
- package/dist/adapter/vue2/widget/ArrayWidget.d.ts +1 -1
- package/dist/adapter/vue2/widget/ButtonWidget.d.ts +1 -1
- package/dist/adapter/vue2/widget/CheckboxWidget.d.ts +1 -1
- package/dist/adapter/vue2/widget/CollapseGroupWidget.d.ts +2 -1
- package/dist/adapter/vue2/widget/ColorPickerWidget.d.ts +1 -1
- package/dist/adapter/vue2/widget/InputWidget.d.ts +1 -1
- package/dist/adapter/vue2/widget/KeyValueArrayWidget.d.ts +3 -3
- package/dist/adapter/vue2/widget/RadioWidget.d.ts +1 -1
- package/dist/adapter/vue2/widget/SelectWidget.d.ts +1 -1
- package/dist/adapter/vue2/widget/SwitchWidget.d.ts +1 -1
- package/dist/adapter/vue2/widget/TabGroupWidget.d.ts +1 -1
- package/dist/adapter/vue2/widget/TableWidget.d.ts +3 -3
- package/dist/adapter/vue2/widget/UploadWidget.d.ts +14 -0
- package/dist/adapter/vue2/widget/Widget.d.ts +1 -1
- package/dist/bkui-form-es-min.js +3 -3
- package/dist/bkui-form-es.js +487 -261
- package/dist/bkui-form-es.js.map +1 -1
- package/dist/bkui-form-umd-min.js +3 -3
- package/dist/bkui-form-umd.js +487 -261
- package/dist/bkui-form-umd.js.map +1 -1
- package/dist/bkui-form.css +58 -3
- package/dist/controller/form-vue2.d.ts +9 -6
- package/dist/controller/props.d.ts +4 -0
- package/dist/core/expression.d.ts +3 -1
- package/dist/core/reaction.d.ts +2 -1
- package/dist/core/validator.d.ts +6 -5
- package/dist/core/widgetTree.d.ts +1 -2
- package/dist/types/bkui-form.d.ts +50 -8
- package/dist/util/index.d.ts +5 -1
- package/package.json +5 -5
package/dist/bkui-form-umd.js
CHANGED
|
@@ -642,16 +642,25 @@
|
|
|
642
642
|
}
|
|
643
643
|
if (!sources.length) return target;
|
|
644
644
|
var source = sources.shift();
|
|
645
|
-
if (
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
645
|
+
if (source === undefined) {
|
|
646
|
+
return target;
|
|
647
|
+
}
|
|
648
|
+
Object.entries(source).forEach(function (_ref) {
|
|
649
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
650
|
+
key = _ref2[0],
|
|
651
|
+
value = _ref2[1];
|
|
652
|
+
var targetValue = target[key];
|
|
653
|
+
if (isObj(value)) {
|
|
654
|
+
if (!(key in target)) {
|
|
655
|
+
target[key] = {};
|
|
656
|
+
} else if (!isObj(targetValue)) {
|
|
657
|
+
target[key] = {};
|
|
652
658
|
}
|
|
659
|
+
mergeDeep(target[key], value);
|
|
660
|
+
} else {
|
|
661
|
+
target[key] = value;
|
|
653
662
|
}
|
|
654
|
-
}
|
|
663
|
+
});
|
|
655
664
|
return mergeDeep.apply(void 0, [target].concat(sources));
|
|
656
665
|
}
|
|
657
666
|
function isArguments(object) {
|
|
@@ -844,7 +853,6 @@
|
|
|
844
853
|
key = _ref2[0],
|
|
845
854
|
value = _ref2[1];
|
|
846
855
|
if (_this[props].has(key)) {
|
|
847
|
-
console.warn('repeat key', key);
|
|
848
856
|
return;
|
|
849
857
|
}
|
|
850
858
|
_this[props].set(key, value);
|
|
@@ -1543,6 +1551,10 @@
|
|
|
1543
1551
|
type: Boolean,
|
|
1544
1552
|
default: false
|
|
1545
1553
|
},
|
|
1554
|
+
disabled: {
|
|
1555
|
+
type: Boolean,
|
|
1556
|
+
default: false
|
|
1557
|
+
},
|
|
1546
1558
|
readonlyMode: {
|
|
1547
1559
|
type: String,
|
|
1548
1560
|
default: 'value',
|
|
@@ -1669,7 +1681,6 @@
|
|
|
1669
1681
|
}
|
|
1670
1682
|
});
|
|
1671
1683
|
|
|
1672
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
1673
1684
|
// 组件对外暴露的上下文
|
|
1674
1685
|
var getContext = function getContext(instance) {
|
|
1675
1686
|
var context = instance.context,
|
|
@@ -1677,7 +1688,8 @@
|
|
|
1677
1688
|
validate = instance.validate,
|
|
1678
1689
|
schema = instance.schema,
|
|
1679
1690
|
rootData = instance.rootData,
|
|
1680
|
-
widgetNode = instance.widgetNode
|
|
1691
|
+
widgetNode = instance.widgetNode,
|
|
1692
|
+
getValue = instance.getValue;
|
|
1681
1693
|
return {
|
|
1682
1694
|
$self: instance,
|
|
1683
1695
|
$context: context,
|
|
@@ -1686,11 +1698,33 @@
|
|
|
1686
1698
|
$loadDataSource: loadDataSource,
|
|
1687
1699
|
$validate: validate,
|
|
1688
1700
|
$rootData: rootData,
|
|
1689
|
-
$widgetNode: widgetNode
|
|
1701
|
+
$widgetNode: widgetNode,
|
|
1702
|
+
$getValue: getValue,
|
|
1703
|
+
$getCookie: function $getCookie(name) {
|
|
1704
|
+
var cookies = document.cookie.split(';');
|
|
1705
|
+
var _iterator = _createForOfIteratorHelper(cookies),
|
|
1706
|
+
_step;
|
|
1707
|
+
try {
|
|
1708
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1709
|
+
var cookie = _step.value;
|
|
1710
|
+
var _cookie$trim$split = cookie.trim().split('='),
|
|
1711
|
+
_cookie$trim$split2 = _slicedToArray(_cookie$trim$split, 2),
|
|
1712
|
+
key = _cookie$trim$split2[0],
|
|
1713
|
+
value = _cookie$trim$split2[1];
|
|
1714
|
+
if (key === name) return decodeURIComponent(value);
|
|
1715
|
+
}
|
|
1716
|
+
} catch (err) {
|
|
1717
|
+
_iterator.e(err);
|
|
1718
|
+
} finally {
|
|
1719
|
+
_iterator.f();
|
|
1720
|
+
}
|
|
1721
|
+
return null;
|
|
1722
|
+
}
|
|
1690
1723
|
};
|
|
1691
1724
|
};
|
|
1692
1725
|
var executeExpression = function executeExpression(expression, instance) {
|
|
1693
1726
|
var $dep = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
1727
|
+
var $args = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1694
1728
|
var _getContext = getContext(instance),
|
|
1695
1729
|
$self = _getContext.$self,
|
|
1696
1730
|
$context = _getContext.$context,
|
|
@@ -1699,7 +1733,9 @@
|
|
|
1699
1733
|
$loadDataSource = _getContext.$loadDataSource,
|
|
1700
1734
|
$validate = _getContext.$validate,
|
|
1701
1735
|
$rootData = _getContext.$rootData,
|
|
1702
|
-
$widgetNode = _getContext.$widgetNode
|
|
1736
|
+
$widgetNode = _getContext.$widgetNode,
|
|
1737
|
+
$getValue = _getContext.$getValue,
|
|
1738
|
+
$getCookie = _getContext.$getCookie;
|
|
1703
1739
|
var context = {
|
|
1704
1740
|
$self: $self,
|
|
1705
1741
|
$context: $context,
|
|
@@ -1709,8 +1745,12 @@
|
|
|
1709
1745
|
$validate: $validate,
|
|
1710
1746
|
$rootData: $rootData,
|
|
1711
1747
|
$widgetNode: $widgetNode,
|
|
1712
|
-
$dep: $dep
|
|
1748
|
+
$dep: $dep,
|
|
1749
|
+
$getValue: $getValue,
|
|
1750
|
+
$getCookie: $getCookie,
|
|
1751
|
+
$args: $args
|
|
1713
1752
|
};
|
|
1753
|
+
if (['boolean', 'number'].includes(_typeof(expression))) return expression;
|
|
1714
1754
|
if (typeof expression === 'string') {
|
|
1715
1755
|
if (!/^{{.+}}$/.test(expression.trim())) return expression; // 没有上下文时直接返回
|
|
1716
1756
|
var expStr = expression.trim().replace(/(^{{)|(}}$)/g, '') // 去掉{{ }}
|
|
@@ -1726,6 +1766,9 @@
|
|
|
1726
1766
|
_ref.$rootData;
|
|
1727
1767
|
_ref.$widgetNode;
|
|
1728
1768
|
_ref.$dep;
|
|
1769
|
+
_ref.$getValue;
|
|
1770
|
+
_ref.$getCookie;
|
|
1771
|
+
_ref.$args;
|
|
1729
1772
|
try {
|
|
1730
1773
|
// eslint-disable-next-line no-eval
|
|
1731
1774
|
return innerFuncs.includes(expStr) ? eval("".concat(expStr, "()")) : eval(expStr);
|
|
@@ -1746,197 +1789,6 @@
|
|
|
1746
1789
|
return typeof expression === 'string' && /{{.*}}/.test(expression);
|
|
1747
1790
|
};
|
|
1748
1791
|
|
|
1749
|
-
var WidgetNode = /*#__PURE__*/function () {
|
|
1750
|
-
function WidgetNode(config) {
|
|
1751
|
-
_classCallCheck(this, WidgetNode);
|
|
1752
|
-
this.id = void 0;
|
|
1753
|
-
this.instance = void 0;
|
|
1754
|
-
this.parent = void 0;
|
|
1755
|
-
this.type = void 0;
|
|
1756
|
-
this.index = void 0;
|
|
1757
|
-
// todo
|
|
1758
|
-
this.children = void 0;
|
|
1759
|
-
var id = config.id,
|
|
1760
|
-
instance = config.instance,
|
|
1761
|
-
parent = config.parent,
|
|
1762
|
-
index = config.index,
|
|
1763
|
-
type = config.type,
|
|
1764
|
-
_config$children = config.children,
|
|
1765
|
-
children = _config$children === void 0 ? [] : _config$children;
|
|
1766
|
-
this.id = id;
|
|
1767
|
-
this.type = type;
|
|
1768
|
-
this.index = index;
|
|
1769
|
-
this.instance = instance;
|
|
1770
|
-
this.parent = parent;
|
|
1771
|
-
this.children = children;
|
|
1772
|
-
}
|
|
1773
|
-
// 当前node的值
|
|
1774
|
-
return _createClass(WidgetNode, [{
|
|
1775
|
-
key: "value",
|
|
1776
|
-
get: function get() {
|
|
1777
|
-
var _this$instance;
|
|
1778
|
-
return (_this$instance = this.instance) === null || _this$instance === void 0 ? void 0 : _this$instance.value;
|
|
1779
|
-
}
|
|
1780
|
-
// 是否含有可见子节点
|
|
1781
|
-
}, {
|
|
1782
|
-
key: "isChildrenVisible",
|
|
1783
|
-
get: function get() {
|
|
1784
|
-
if (this.type === 'node') {
|
|
1785
|
-
var _this$instance2;
|
|
1786
|
-
return (_this$instance2 = this.instance) === null || _this$instance2 === void 0 ? void 0 : _this$instance2.state.visible;
|
|
1787
|
-
}
|
|
1788
|
-
return this.children.some(function (child) {
|
|
1789
|
-
return child.isChildrenVisible;
|
|
1790
|
-
});
|
|
1791
|
-
}
|
|
1792
|
-
/**
|
|
1793
|
-
* 获取 parents
|
|
1794
|
-
*/
|
|
1795
|
-
}, {
|
|
1796
|
-
key: "parents",
|
|
1797
|
-
get: function get() {
|
|
1798
|
-
if (!this.parent) {
|
|
1799
|
-
return [];
|
|
1800
|
-
}
|
|
1801
|
-
return [].concat(_toConsumableArray(this.parent.parents), [this.parent]);
|
|
1802
|
-
}
|
|
1803
|
-
// 第一个子节点
|
|
1804
|
-
}, {
|
|
1805
|
-
key: "firstChild",
|
|
1806
|
-
get: function get() {
|
|
1807
|
-
return this.children[0] || null;
|
|
1808
|
-
}
|
|
1809
|
-
// 最后一个子节点
|
|
1810
|
-
}, {
|
|
1811
|
-
key: "lastChild",
|
|
1812
|
-
get: function get() {
|
|
1813
|
-
return this.children[this.children.length - 1] || null;
|
|
1814
|
-
}
|
|
1815
|
-
// 指定属性下的同胞节点
|
|
1816
|
-
}, {
|
|
1817
|
-
key: "getSibling",
|
|
1818
|
-
value: function getSibling(lastProp) {
|
|
1819
|
-
var _this$parent;
|
|
1820
|
-
var reg = new RegExp("".concat(Path.getPathLastProp(this.id) || '', "$"));
|
|
1821
|
-
var id = this.id.replace(reg, lastProp);
|
|
1822
|
-
return (_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.children.find(function (node) {
|
|
1823
|
-
return node.id === id;
|
|
1824
|
-
});
|
|
1825
|
-
}
|
|
1826
|
-
// 获取所以同胞节点(不含自己)
|
|
1827
|
-
}, {
|
|
1828
|
-
key: "getSiblings",
|
|
1829
|
-
value: function getSiblings() {
|
|
1830
|
-
var _this$parent2,
|
|
1831
|
-
_this = this;
|
|
1832
|
-
return ((_this$parent2 = this.parent) === null || _this$parent2 === void 0 ? void 0 : _this$parent2.children.filter(function (node) {
|
|
1833
|
-
return node.instance !== _this.instance;
|
|
1834
|
-
})) || [];
|
|
1835
|
-
}
|
|
1836
|
-
/**
|
|
1837
|
-
* 是否是叶子节点
|
|
1838
|
-
*/
|
|
1839
|
-
}, {
|
|
1840
|
-
key: "isLeaf",
|
|
1841
|
-
get: function get() {
|
|
1842
|
-
return !this.children.length;
|
|
1843
|
-
}
|
|
1844
|
-
}, {
|
|
1845
|
-
key: "appendChild",
|
|
1846
|
-
value: function appendChild(node) {
|
|
1847
|
-
var _this$children;
|
|
1848
|
-
var nodes = Array.isArray(node) ? node : [node];
|
|
1849
|
-
var offset = node.index !== undefined ? node.index : this.children.length;
|
|
1850
|
-
(_this$children = this.children).splice.apply(_this$children, [offset, 0].concat(_toConsumableArray(nodes)));
|
|
1851
|
-
this.children.slice(offset).forEach(function (node, index) {
|
|
1852
|
-
node.index = offset + index;
|
|
1853
|
-
});
|
|
1854
|
-
return nodes;
|
|
1855
|
-
}
|
|
1856
|
-
}, {
|
|
1857
|
-
key: "removeChild",
|
|
1858
|
-
value: function removeChild(node) {
|
|
1859
|
-
var _this2 = this;
|
|
1860
|
-
var nodes = Array.isArray(node) ? node : [node];
|
|
1861
|
-
var removedChildIndex = [];
|
|
1862
|
-
nodes.forEach(function (node) {
|
|
1863
|
-
var index = node.index;
|
|
1864
|
-
removedChildIndex.push(index);
|
|
1865
|
-
_this2.children.splice(index, 1);
|
|
1866
|
-
});
|
|
1867
|
-
var minIndex = Math.min.apply(Math, removedChildIndex);
|
|
1868
|
-
this.children.slice(minIndex).forEach(function (node, index) {
|
|
1869
|
-
node.index = minIndex + index;
|
|
1870
|
-
});
|
|
1871
|
-
return nodes;
|
|
1872
|
-
}
|
|
1873
|
-
}]);
|
|
1874
|
-
}();
|
|
1875
|
-
var WidgetTree = /*#__PURE__*/function () {
|
|
1876
|
-
function WidgetTree() {
|
|
1877
|
-
_classCallCheck(this, WidgetTree);
|
|
1878
|
-
this.widgetMap = {};
|
|
1879
|
-
}
|
|
1880
|
-
return _createClass(WidgetTree, [{
|
|
1881
|
-
key: "addWidgetNode",
|
|
1882
|
-
value: function addWidgetNode(path, instance, type, index) {
|
|
1883
|
-
if (path === '') {
|
|
1884
|
-
// 根节点
|
|
1885
|
-
var node = new WidgetNode({
|
|
1886
|
-
id: '',
|
|
1887
|
-
type: type,
|
|
1888
|
-
index: index,
|
|
1889
|
-
parent: null,
|
|
1890
|
-
instance: instance,
|
|
1891
|
-
children: []
|
|
1892
|
-
});
|
|
1893
|
-
this.widgetMap[path] = node;
|
|
1894
|
-
} else {
|
|
1895
|
-
// 普通节点
|
|
1896
|
-
var parentId = Path.getParentPath(path);
|
|
1897
|
-
var parentNode = this.widgetMap[parentId];
|
|
1898
|
-
var _node = new WidgetNode({
|
|
1899
|
-
id: (instance === null || instance === void 0 ? void 0 : instance.path) || path,
|
|
1900
|
-
type: type,
|
|
1901
|
-
index: index,
|
|
1902
|
-
parent: parentNode,
|
|
1903
|
-
instance: instance,
|
|
1904
|
-
children: []
|
|
1905
|
-
});
|
|
1906
|
-
if (!parentNode) {
|
|
1907
|
-
console.warn('Unexpected parent id, please check widget node', _node);
|
|
1908
|
-
} else {
|
|
1909
|
-
parentNode.appendChild(_node);
|
|
1910
|
-
}
|
|
1911
|
-
this.widgetMap[path] = _node;
|
|
1912
|
-
}
|
|
1913
|
-
}
|
|
1914
|
-
}, {
|
|
1915
|
-
key: "removeWidgetNode",
|
|
1916
|
-
value: function removeWidgetNode(path, instance) {
|
|
1917
|
-
var node = this.widgetMap[path];
|
|
1918
|
-
if (node) {
|
|
1919
|
-
if (node.parent) {
|
|
1920
|
-
var children = node.parent.children;
|
|
1921
|
-
var index = children.findIndex(function (item) {
|
|
1922
|
-
return item.instance === instance;
|
|
1923
|
-
});
|
|
1924
|
-
if (index > -1) {
|
|
1925
|
-
children.splice(index, 1);
|
|
1926
|
-
children.slice(index).forEach(function (node, i) {
|
|
1927
|
-
node.index = index + i;
|
|
1928
|
-
});
|
|
1929
|
-
}
|
|
1930
|
-
}
|
|
1931
|
-
if (node.instance === instance) {
|
|
1932
|
-
delete this.widgetMap[path];
|
|
1933
|
-
}
|
|
1934
|
-
}
|
|
1935
|
-
}
|
|
1936
|
-
}]);
|
|
1937
|
-
}();
|
|
1938
|
-
var widgetTree = new WidgetTree();
|
|
1939
|
-
|
|
1940
1792
|
var reactionsMap = {};
|
|
1941
1793
|
var subscribe = function subscribe(path, typeName, fn) {
|
|
1942
1794
|
if (!reactionsMap[path]) {
|
|
@@ -1968,7 +1820,7 @@
|
|
|
1968
1820
|
* @param reaction 传入的reacion配置
|
|
1969
1821
|
* @returns viod
|
|
1970
1822
|
*/
|
|
1971
|
-
var resolveReaction = function resolveReaction(crtInsPath, targetPath, reaction) {
|
|
1823
|
+
var resolveReaction = function resolveReaction(crtInsPath, targetPath, reaction, widgetTree) {
|
|
1972
1824
|
return function () {
|
|
1973
1825
|
var _ref = widgetTree.widgetMap[crtInsPath] || {},
|
|
1974
1826
|
crtInstance = _ref.instance; // 当前组件实例,用来条件表达式判断
|
|
@@ -2013,6 +1865,7 @@
|
|
|
2013
1865
|
};
|
|
2014
1866
|
var reactionRegister = function reactionRegister(path) {
|
|
2015
1867
|
var reactions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
1868
|
+
var widgetTree = arguments.length > 2 ? arguments[2] : undefined;
|
|
2016
1869
|
var _ref3 = widgetTree.widgetMap[path] || {},
|
|
2017
1870
|
instance = _ref3.instance;
|
|
2018
1871
|
if (reactions && Array.isArray(reactions)) {
|
|
@@ -2024,13 +1877,13 @@
|
|
|
2024
1877
|
subscribePaths.forEach(function (p) {
|
|
2025
1878
|
var sourcePathItem = parsePath(p, instance);
|
|
2026
1879
|
if (typeof reaction.lifetime === 'string') {
|
|
2027
|
-
subscribe(sourcePathItem, "lifetime/".concat(reaction.lifetime), resolveReaction(path, targePath, reaction));
|
|
1880
|
+
subscribe(sourcePathItem, "lifetime/".concat(reaction.lifetime), resolveReaction(path, targePath, reaction, widgetTree));
|
|
2028
1881
|
}
|
|
2029
1882
|
if (typeof reaction.effect === 'string') {
|
|
2030
|
-
subscribe(sourcePathItem, "effect/".concat(reaction.effect), resolveReaction(path, targePath, reaction));
|
|
1883
|
+
subscribe(sourcePathItem, "effect/".concat(reaction.effect), resolveReaction(path, targePath, reaction, widgetTree));
|
|
2031
1884
|
}
|
|
2032
1885
|
if (!reaction.lifetime && !reaction.effect) {
|
|
2033
|
-
subscribe(sourcePathItem, 'valChange', resolveReaction(path, targePath, reaction));
|
|
1886
|
+
subscribe(sourcePathItem, 'valChange', resolveReaction(path, targePath, reaction, widgetTree));
|
|
2034
1887
|
}
|
|
2035
1888
|
});
|
|
2036
1889
|
});
|
|
@@ -9764,7 +9617,7 @@
|
|
|
9764
9617
|
};
|
|
9765
9618
|
};
|
|
9766
9619
|
// 设置表单项校验状态
|
|
9767
|
-
var setWidgetErrorTips = function setWidgetErrorTips(path, isError, errorMsg) {
|
|
9620
|
+
var setWidgetErrorTips = function setWidgetErrorTips(path, isError, errorMsg, widgetTree) {
|
|
9768
9621
|
var formItem = widgetTree.widgetMap[path];
|
|
9769
9622
|
var instance = formItem.instance;
|
|
9770
9623
|
if (formItem.type === 'node') {
|
|
@@ -9797,7 +9650,7 @@
|
|
|
9797
9650
|
* 校验单个表单项
|
|
9798
9651
|
* @param path 字段路径
|
|
9799
9652
|
*/
|
|
9800
|
-
var validateFormItem = function validateFormItem(path) {
|
|
9653
|
+
var validateFormItem = function validateFormItem(path, widgetTree) {
|
|
9801
9654
|
var _instance$schema;
|
|
9802
9655
|
// TODO 校验逻辑梳理
|
|
9803
9656
|
var formItem = widgetTree.widgetMap[path];
|
|
@@ -9837,7 +9690,7 @@
|
|
|
9837
9690
|
var errorsText = ajv.errorsText(schemaValidate.errors, {
|
|
9838
9691
|
separator: '\n'
|
|
9839
9692
|
});
|
|
9840
|
-
setWidgetErrorTips(path, true, errorsText);
|
|
9693
|
+
setWidgetErrorTips(path, true, errorsText, widgetTree);
|
|
9841
9694
|
return {
|
|
9842
9695
|
result: false,
|
|
9843
9696
|
message: errorsText,
|
|
@@ -9866,7 +9719,7 @@
|
|
|
9866
9719
|
_iterator.f();
|
|
9867
9720
|
}
|
|
9868
9721
|
if (isError) {
|
|
9869
|
-
setWidgetErrorTips(path, true, errorMsg);
|
|
9722
|
+
setWidgetErrorTips(path, true, errorMsg, widgetTree);
|
|
9870
9723
|
return {
|
|
9871
9724
|
result: false,
|
|
9872
9725
|
message: errorMsg,
|
|
@@ -9882,24 +9735,24 @@
|
|
|
9882
9735
|
/**
|
|
9883
9736
|
* 校验整个表单
|
|
9884
9737
|
*/
|
|
9885
|
-
var validateForm = function validateForm() {
|
|
9738
|
+
var validateForm = function validateForm(widgetTree) {
|
|
9886
9739
|
var isValid = true;
|
|
9887
9740
|
Object.keys(widgetTree.widgetMap).forEach(function (path) {
|
|
9888
9741
|
var _validateFormItem;
|
|
9889
|
-
if (!((_validateFormItem = validateFormItem(path)) !== null && _validateFormItem !== void 0 && _validateFormItem.result)) isValid = false;
|
|
9742
|
+
if (!((_validateFormItem = validateFormItem(path, widgetTree)) !== null && _validateFormItem !== void 0 && _validateFormItem.result)) isValid = false;
|
|
9890
9743
|
});
|
|
9891
9744
|
return isValid;
|
|
9892
9745
|
};
|
|
9893
9746
|
/**
|
|
9894
9747
|
* 校验表单(抛出具体错误信息)
|
|
9895
9748
|
*/
|
|
9896
|
-
var validateFormWithResult = function validateFormWithResult() {
|
|
9749
|
+
var validateFormWithResult = function validateFormWithResult(widgetTree) {
|
|
9897
9750
|
return new Promise(function (resolve, reject) {
|
|
9898
9751
|
var result = Object.keys(widgetTree.widgetMap).filter(function (path) {
|
|
9899
9752
|
var _widgetTree$widgetMap;
|
|
9900
9753
|
return ((_widgetTree$widgetMap = widgetTree.widgetMap[path]) === null || _widgetTree$widgetMap === void 0 ? void 0 : _widgetTree$widgetMap.type) === 'node';
|
|
9901
9754
|
}).reduce(function (pre, path) {
|
|
9902
|
-
var validateResult = validateFormItem(path);
|
|
9755
|
+
var validateResult = validateFormItem(path, widgetTree);
|
|
9903
9756
|
if (!(validateResult !== null && validateResult !== void 0 && validateResult.result)) {
|
|
9904
9757
|
pre.push(validateResult);
|
|
9905
9758
|
}
|
|
@@ -9942,8 +9795,8 @@
|
|
|
9942
9795
|
* 触发校验
|
|
9943
9796
|
* @param path 字段路径
|
|
9944
9797
|
*/
|
|
9945
|
-
var dispatchValidate = function dispatchValidate(path) {
|
|
9946
|
-
return validateFormItem(path);
|
|
9798
|
+
var dispatchValidate = function dispatchValidate(path, widgetTree) {
|
|
9799
|
+
return validateFormItem(path, widgetTree);
|
|
9947
9800
|
};
|
|
9948
9801
|
|
|
9949
9802
|
// 事件订阅器
|
|
@@ -10033,6 +9886,7 @@
|
|
|
10033
9886
|
var Widget = Vue__default["default"].extend({
|
|
10034
9887
|
name: 'Widget',
|
|
10035
9888
|
props: props,
|
|
9889
|
+
inject: ['widgetTree'],
|
|
10036
9890
|
data: function data() {
|
|
10037
9891
|
return {
|
|
10038
9892
|
loading: false,
|
|
@@ -10051,10 +9905,10 @@
|
|
|
10051
9905
|
},
|
|
10052
9906
|
computed: {
|
|
10053
9907
|
widgetMap: function widgetMap() {
|
|
10054
|
-
return widgetTree.widgetMap;
|
|
9908
|
+
return this.widgetTree.widgetMap;
|
|
10055
9909
|
},
|
|
10056
9910
|
widgetNode: function widgetNode() {
|
|
10057
|
-
return widgetTree.widgetMap[this.path];
|
|
9911
|
+
return this.widgetTree.widgetMap[this.path];
|
|
10058
9912
|
},
|
|
10059
9913
|
parent: function parent() {
|
|
10060
9914
|
var _this$widgetNode;
|
|
@@ -10072,7 +9926,7 @@
|
|
|
10072
9926
|
if (!deepEquals(newValue, oldValue)) {
|
|
10073
9927
|
setTimeout(function () {
|
|
10074
9928
|
reactionDispatch(_this.path, 'valChange');
|
|
10075
|
-
dispatchValidate(_this.path);
|
|
9929
|
+
dispatchValidate(_this.path, _this.widgetTree);
|
|
10076
9930
|
}, 0);
|
|
10077
9931
|
}
|
|
10078
9932
|
}
|
|
@@ -10104,17 +9958,17 @@
|
|
|
10104
9958
|
}
|
|
10105
9959
|
});
|
|
10106
9960
|
// 注册widget TreeNode
|
|
10107
|
-
widgetTree.addWidgetNode(this.path, this, 'node');
|
|
9961
|
+
this.widgetTree.addWidgetNode(this.path, this, 'node');
|
|
10108
9962
|
},
|
|
10109
9963
|
mounted: function mounted() {
|
|
10110
9964
|
// 注册联动
|
|
10111
|
-
reactionRegister(this.path, this.widgetSchema['ui:reactions']);
|
|
9965
|
+
reactionRegister(this.path, this.widgetSchema['ui:reactions'], this.widgetTree);
|
|
10112
9966
|
// 首次联动
|
|
10113
9967
|
reactionDispatch(this.path, 'valChange');
|
|
10114
9968
|
reactionDispatch(this.path, 'lifetime/init');
|
|
10115
9969
|
},
|
|
10116
9970
|
beforeDestroy: function beforeDestroy() {
|
|
10117
|
-
widgetTree.removeWidgetNode(this.path, this);
|
|
9971
|
+
this.widgetTree.removeWidgetNode(this.path, this);
|
|
10118
9972
|
reactionUnRegister(this.path);
|
|
10119
9973
|
},
|
|
10120
9974
|
methods: {
|
|
@@ -10233,7 +10087,14 @@
|
|
|
10233
10087
|
}
|
|
10234
10088
|
},
|
|
10235
10089
|
render: function render(h) {
|
|
10236
|
-
var _events$callbacks,
|
|
10090
|
+
var _events$callbacks,
|
|
10091
|
+
_this$$scopedSlots$de,
|
|
10092
|
+
_this$$scopedSlots$de2,
|
|
10093
|
+
_this$$scopedSlots,
|
|
10094
|
+
_this5 = this,
|
|
10095
|
+
_this$widgetSchema$ui5,
|
|
10096
|
+
_this$$scopedSlots$su,
|
|
10097
|
+
_this$$scopedSlots2;
|
|
10237
10098
|
var _Schema$getUiComponen = Schema.getUiComponent(this.widgetSchema),
|
|
10238
10099
|
name = _Schema$getUiComponen.name,
|
|
10239
10100
|
uiVnodeData = _objectWithoutProperties(_Schema$getUiComponen, _excluded2);
|
|
@@ -10263,6 +10124,7 @@
|
|
|
10263
10124
|
path: self.path,
|
|
10264
10125
|
value: value
|
|
10265
10126
|
});
|
|
10127
|
+
reactionDispatch(self.path, 'effect/update');
|
|
10266
10128
|
}]),
|
|
10267
10129
|
click: function click() {
|
|
10268
10130
|
reactionDispatch(self.path, 'effect/click');
|
|
@@ -10282,7 +10144,10 @@
|
|
|
10282
10144
|
// 渲染删除按钮(用于数组类型widget删除)
|
|
10283
10145
|
var renderDelete = function renderDelete() {
|
|
10284
10146
|
return h('span', {
|
|
10285
|
-
class: ['bk-schema-form-group-delete'
|
|
10147
|
+
class: ['bk-schema-form-group-delete', {
|
|
10148
|
+
disabled: _this5.disabled,
|
|
10149
|
+
readonly: _this5.readonly
|
|
10150
|
+
}],
|
|
10286
10151
|
style: {
|
|
10287
10152
|
right: '0px',
|
|
10288
10153
|
top: '0px'
|
|
@@ -10403,10 +10268,12 @@
|
|
|
10403
10268
|
|
|
10404
10269
|
var messages = {
|
|
10405
10270
|
'zh-CN': {
|
|
10406
|
-
add: '添加'
|
|
10271
|
+
add: '添加',
|
|
10272
|
+
required: '必填项'
|
|
10407
10273
|
},
|
|
10408
10274
|
'en-US': {
|
|
10409
|
-
add: 'Add'
|
|
10275
|
+
add: 'Add',
|
|
10276
|
+
required: 'Required'
|
|
10410
10277
|
}
|
|
10411
10278
|
};
|
|
10412
10279
|
function locale(item) {
|
|
@@ -10445,6 +10312,7 @@
|
|
|
10445
10312
|
},
|
|
10446
10313
|
// 添加item
|
|
10447
10314
|
handleAddItem: function handleAddItem() {
|
|
10315
|
+
if (this.disabled || this.readonly) return;
|
|
10448
10316
|
var data = Schema.getSchemaDefaultValue(this.schema.items);
|
|
10449
10317
|
var value = JSON.parse(JSON.stringify(this.value || []));
|
|
10450
10318
|
value.push(data);
|
|
@@ -10455,6 +10323,7 @@
|
|
|
10455
10323
|
},
|
|
10456
10324
|
// 删除item
|
|
10457
10325
|
handleDeleteItem: function handleDeleteItem(path) {
|
|
10326
|
+
if (this.disabled || this.readonly) return;
|
|
10458
10327
|
var index = Number(Path.getPathLastProp(path));
|
|
10459
10328
|
var value = JSON.parse(JSON.stringify(this.value || []));
|
|
10460
10329
|
value.splice(index, 1);
|
|
@@ -10465,7 +10334,13 @@
|
|
|
10465
10334
|
}
|
|
10466
10335
|
},
|
|
10467
10336
|
render: function render(h) {
|
|
10468
|
-
var _this = this
|
|
10337
|
+
var _this = this,
|
|
10338
|
+
_self$value,
|
|
10339
|
+
_this$schema,
|
|
10340
|
+
_this$schema$uiProps,
|
|
10341
|
+
_this$schema2,
|
|
10342
|
+
_this$schema3,
|
|
10343
|
+
_this$schema3$uiProp;
|
|
10469
10344
|
var self = this;
|
|
10470
10345
|
var arrVnodeList = (Array.isArray(this.value) ? this.value : []).map(function (_, index) {
|
|
10471
10346
|
var curPath = Path.getCurPath(_this.path, index);
|
|
@@ -10489,18 +10364,24 @@
|
|
|
10489
10364
|
var _Schema$getGroupWrap = Schema.getGroupWrap(this.schema),
|
|
10490
10365
|
name = _Schema$getGroupWrap.name,
|
|
10491
10366
|
vnode = _objectWithoutProperties(_Schema$getGroupWrap, _excluded$2);
|
|
10367
|
+
var error = ((_self$value = self.value) === null || _self$value === void 0 ? void 0 : _self$value.length) === 0 && self.required;
|
|
10492
10368
|
return h(name, mergeDeep({
|
|
10493
10369
|
props: _objectSpread2(_objectSpread2({}, this.$props), {}, {
|
|
10494
10370
|
layout: {},
|
|
10495
10371
|
showTitle: true // 数组类型默认展示分组title
|
|
10496
10372
|
}),
|
|
10497
10373
|
style: _objectSpread2({}, this.layout.item || {})
|
|
10498
|
-
}, vnode), [].concat(_toConsumableArray(arrVnodeList), [h(registry.getBaseWidget('form-item'), {
|
|
10374
|
+
}, vnode), [].concat(_toConsumableArray(arrVnodeList), [!this.readonly ? h(registry.getBaseWidget('form-item'), {
|
|
10499
10375
|
class: {
|
|
10500
10376
|
'bk-schema-form-item-auto-height': true
|
|
10501
10377
|
}
|
|
10502
10378
|
}, [h('span', {
|
|
10503
|
-
class: ['bk-schema-form-group-add'
|
|
10379
|
+
class: ['bk-schema-form-group-add', {
|
|
10380
|
+
'error': error
|
|
10381
|
+
}, (_this$schema = this.schema) === null || _this$schema === void 0 ? void 0 : (_this$schema$uiProps = _this$schema['ui:props']) === null || _this$schema$uiProps === void 0 ? void 0 : _this$schema$uiProps.size, {
|
|
10382
|
+
disabled: this.disabled,
|
|
10383
|
+
readonly: this.readonly
|
|
10384
|
+
}],
|
|
10504
10385
|
on: {
|
|
10505
10386
|
click: function click() {
|
|
10506
10387
|
self.handleAddItem();
|
|
@@ -10508,7 +10389,9 @@
|
|
|
10508
10389
|
}
|
|
10509
10390
|
}, [h('i', {
|
|
10510
10391
|
class: ['bk-icon icon-plus-circle-shape mr5']
|
|
10511
|
-
}), locale('add')
|
|
10392
|
+
}), "".concat(locale('add')).concat(((_this$schema2 = this.schema) === null || _this$schema2 === void 0 ? void 0 : _this$schema2.title) || '')]), error && ((_this$schema3 = this.schema) === null || _this$schema3 === void 0 ? void 0 : (_this$schema3$uiProp = _this$schema3['ui:props']) === null || _this$schema3$uiProp === void 0 ? void 0 : _this$schema3$uiProp.size) === 'large' && h('p', {
|
|
10393
|
+
class: ['bk-schema-form-item__error-tips']
|
|
10394
|
+
}, [locale('required')])]) : null]));
|
|
10512
10395
|
}
|
|
10513
10396
|
});
|
|
10514
10397
|
|
|
@@ -10919,6 +10802,7 @@
|
|
|
10919
10802
|
var TableWidget = Vue__default["default"].extend({
|
|
10920
10803
|
name: 'TableWidget',
|
|
10921
10804
|
props: props,
|
|
10805
|
+
inject: ['widgetTree'],
|
|
10922
10806
|
watch: {
|
|
10923
10807
|
value: {
|
|
10924
10808
|
immediate: true,
|
|
@@ -10928,9 +10812,9 @@
|
|
|
10928
10812
|
(_this$value = this.value) === null || _this$value === void 0 ? void 0 : _this$value.forEach(function (_, index) {
|
|
10929
10813
|
var path = "".concat(_this.path, ".").concat(index);
|
|
10930
10814
|
// 销毁上一次的缓存
|
|
10931
|
-
widgetTree.removeWidgetNode(path, null);
|
|
10815
|
+
_this.widgetTree.removeWidgetNode(path, null);
|
|
10932
10816
|
// 重新当前行的父节点
|
|
10933
|
-
widgetTree.addWidgetNode(path, null, 'group');
|
|
10817
|
+
_this.widgetTree.addWidgetNode(path, null, 'group');
|
|
10934
10818
|
});
|
|
10935
10819
|
}
|
|
10936
10820
|
}
|
|
@@ -10977,7 +10861,19 @@
|
|
|
10977
10861
|
}
|
|
10978
10862
|
var uiOptions = Schema.getUiOptions(schema);
|
|
10979
10863
|
var getTableColumn = function getTableColumn() {
|
|
10980
|
-
|
|
10864
|
+
// 表格列排序优先取 ui:order 属性里配置的顺序
|
|
10865
|
+
var colKeys = Object.keys(properties);
|
|
10866
|
+
var orders = (schemaItems === null || schemaItems === void 0 ? void 0 : schemaItems['ui:order']) || [];
|
|
10867
|
+
var orderMap = new Map();
|
|
10868
|
+
orders.forEach(function (key, index) {
|
|
10869
|
+
orderMap.set(key, index);
|
|
10870
|
+
});
|
|
10871
|
+
colKeys.sort(function (a, b) {
|
|
10872
|
+
var orderA = orderMap.has(a) ? orderMap.get(a) : Infinity;
|
|
10873
|
+
var orderB = orderMap.has(b) ? orderMap.get(b) : Infinity;
|
|
10874
|
+
return orderA - orderB;
|
|
10875
|
+
});
|
|
10876
|
+
var VNodeList = colKeys.map(function (key) {
|
|
10981
10877
|
var _colField$uiProps, _colField$uiProps2;
|
|
10982
10878
|
var colField = properties[key];
|
|
10983
10879
|
// 仅支持基础数据类型的属性配置,render-header、sort-method、formatter等Function类型的属性不属于json支持的数据类型,配置将不会生效
|
|
@@ -11099,6 +10995,7 @@
|
|
|
11099
10995
|
|
|
11100
10996
|
var FieldGroupWrap = Vue__default["default"].extend({
|
|
11101
10997
|
name: 'FieldGroupWrap',
|
|
10998
|
+
inject: ['widgetTree'],
|
|
11102
10999
|
props: _objectSpread2(_objectSpread2({}, props), {}, {
|
|
11103
11000
|
// 组类型
|
|
11104
11001
|
type: {
|
|
@@ -11125,6 +11022,10 @@
|
|
|
11125
11022
|
hideEmptyRow: {
|
|
11126
11023
|
type: Boolean,
|
|
11127
11024
|
default: false
|
|
11025
|
+
},
|
|
11026
|
+
description: {
|
|
11027
|
+
type: String,
|
|
11028
|
+
default: ''
|
|
11128
11029
|
}
|
|
11129
11030
|
}),
|
|
11130
11031
|
data: function data() {
|
|
@@ -11138,14 +11039,14 @@
|
|
|
11138
11039
|
},
|
|
11139
11040
|
created: function created() {
|
|
11140
11041
|
// 注册widget TreeNode
|
|
11141
|
-
widgetTree.addWidgetNode(this.path, this, 'group');
|
|
11042
|
+
this.widgetTree.addWidgetNode(this.path, this, 'group');
|
|
11142
11043
|
},
|
|
11143
11044
|
mounted: function mounted() {
|
|
11144
11045
|
// 更新样式
|
|
11145
11046
|
this.$forceUpdate();
|
|
11146
11047
|
},
|
|
11147
11048
|
beforeDestroy: function beforeDestroy() {
|
|
11148
|
-
widgetTree.removeWidgetNode(this.path, this);
|
|
11049
|
+
this.widgetTree.removeWidgetNode(this.path, this);
|
|
11149
11050
|
},
|
|
11150
11051
|
methods: {
|
|
11151
11052
|
setState: function setState(key, value) {
|
|
@@ -11168,9 +11069,9 @@
|
|
|
11168
11069
|
render: function render(h) {
|
|
11169
11070
|
var _this$layout,
|
|
11170
11071
|
_this$layout2,
|
|
11072
|
+
_this = this,
|
|
11171
11073
|
_this$schema,
|
|
11172
|
-
_this$layout3
|
|
11173
|
-
_this = this;
|
|
11074
|
+
_this$layout3;
|
|
11174
11075
|
var schemaFormStyle = _objectSpread2({
|
|
11175
11076
|
position: 'relative',
|
|
11176
11077
|
border: this.border ? '1px solid #dcdee5' : 'none',
|
|
@@ -11183,7 +11084,10 @@
|
|
|
11183
11084
|
var self = this;
|
|
11184
11085
|
var renderDelete = function renderDelete() {
|
|
11185
11086
|
return h('span', {
|
|
11186
|
-
class: ['bk-schema-form-group-delete'
|
|
11087
|
+
class: ['bk-schema-form-group-delete', {
|
|
11088
|
+
disabled: _this.disabled,
|
|
11089
|
+
readonly: _this.readonly
|
|
11090
|
+
}],
|
|
11187
11091
|
style: {
|
|
11188
11092
|
right: '10px',
|
|
11189
11093
|
top: '10px'
|
|
@@ -11210,7 +11114,14 @@
|
|
|
11210
11114
|
}],
|
|
11211
11115
|
"style": schemaFormStyle
|
|
11212
11116
|
}, [title && this.showTitle ? h("span", {
|
|
11213
|
-
"
|
|
11117
|
+
"directives": [{
|
|
11118
|
+
name: "bk-tooltips",
|
|
11119
|
+
value: this.description
|
|
11120
|
+
}],
|
|
11121
|
+
"class": ['bk-schema-form-group-title', this.type, {
|
|
11122
|
+
'group-has-desc': !!this.description,
|
|
11123
|
+
'is-required': this.required
|
|
11124
|
+
}]
|
|
11214
11125
|
}, [title, hasError ? h("span", {
|
|
11215
11126
|
"class": "bk-schema-form-group__error-tips"
|
|
11216
11127
|
}, [h("span", {
|
|
@@ -11218,7 +11129,7 @@
|
|
|
11218
11129
|
}, [groupErrorTipsContent])]) : null]) : null, h("div", {
|
|
11219
11130
|
"style": groupContentStyle,
|
|
11220
11131
|
"class": "bk-schema-form-group-content"
|
|
11221
|
-
}, [this.$slots.default]), this.removeable && renderDelete()]);
|
|
11132
|
+
}, [this.$slots.default]), this.removeable && !this.readonly && renderDelete()]);
|
|
11222
11133
|
}
|
|
11223
11134
|
});
|
|
11224
11135
|
|
|
@@ -11241,12 +11152,12 @@
|
|
|
11241
11152
|
},
|
|
11242
11153
|
methods: {
|
|
11243
11154
|
handleAddItem: function handleAddItem() {
|
|
11244
|
-
if (this.disabled) return;
|
|
11155
|
+
if (this.disabled || this.readonly) return;
|
|
11245
11156
|
var data = Schema.getSchemaDefaultValue(this.schema.items);
|
|
11246
11157
|
this.$emit('input', [].concat(_toConsumableArray(this.value), [data]));
|
|
11247
11158
|
},
|
|
11248
11159
|
handleRemoveItem: function handleRemoveItem(index) {
|
|
11249
|
-
if (this.disabled) return;
|
|
11160
|
+
if (this.disabled || this.readonly) return;
|
|
11250
11161
|
var value = JSON.parse(JSON.stringify(this.value));
|
|
11251
11162
|
value.splice(index, 1);
|
|
11252
11163
|
this.$emit('input', value);
|
|
@@ -11269,7 +11180,7 @@
|
|
|
11269
11180
|
_this$value2;
|
|
11270
11181
|
var labelBtnStyle = {
|
|
11271
11182
|
'font-size': '16px',
|
|
11272
|
-
color: '#979ba5',
|
|
11183
|
+
color: this.disabled ? '#c4c6cc' : '#979ba5',
|
|
11273
11184
|
cursor: this.disabled ? 'not-allowed' : 'pointer',
|
|
11274
11185
|
display: 'inline-block'
|
|
11275
11186
|
};
|
|
@@ -11448,10 +11359,7 @@
|
|
|
11448
11359
|
props: _objectSpread2(_objectSpread2({}, props), {}, {
|
|
11449
11360
|
type: {
|
|
11450
11361
|
type: String,
|
|
11451
|
-
default: 'default',
|
|
11452
|
-
validator: function validator(value) {
|
|
11453
|
-
return ['default', 'normal', 'card'].includes(value);
|
|
11454
|
-
}
|
|
11362
|
+
default: 'default' // 'default', 'normal', 'card'
|
|
11455
11363
|
},
|
|
11456
11364
|
showTitle: {
|
|
11457
11365
|
type: Boolean,
|
|
@@ -11470,6 +11378,10 @@
|
|
|
11470
11378
|
verifiable: {
|
|
11471
11379
|
type: Boolean,
|
|
11472
11380
|
default: false
|
|
11381
|
+
},
|
|
11382
|
+
collapseStyle: {
|
|
11383
|
+
type: String,
|
|
11384
|
+
default: 'normal' // normal: 修改后的样式参看BCS,default: 组件样式
|
|
11473
11385
|
}
|
|
11474
11386
|
}),
|
|
11475
11387
|
data: function data() {
|
|
@@ -11480,7 +11392,6 @@
|
|
|
11480
11392
|
render: function render(h) {
|
|
11481
11393
|
var _this$schema,
|
|
11482
11394
|
_this = this;
|
|
11483
|
-
var collapseStyle = {};
|
|
11484
11395
|
var collapseTitleStyle = {
|
|
11485
11396
|
background: '#f5f7fa',
|
|
11486
11397
|
'border-radius': '2px',
|
|
@@ -11513,9 +11424,9 @@
|
|
|
11513
11424
|
hideArrow: true,
|
|
11514
11425
|
name: key
|
|
11515
11426
|
},
|
|
11516
|
-
class: ['mb15']
|
|
11427
|
+
class: _this.collapseStyle === 'normal' ? ['mb15'] : []
|
|
11517
11428
|
}, [h('div', {
|
|
11518
|
-
style: collapseTitleStyle
|
|
11429
|
+
style: _this.collapseStyle === 'normal' ? collapseTitleStyle : {}
|
|
11519
11430
|
}, [h('i', {
|
|
11520
11431
|
class: ['bk-icon icon-down-shape mr5'],
|
|
11521
11432
|
style: _objectSpread2(_objectSpread2({}, collapseIconStyle), {}, {
|
|
@@ -11539,7 +11450,7 @@
|
|
|
11539
11450
|
return h(FieldGroupWrap, {
|
|
11540
11451
|
props: _objectSpread2({}, groupWrapProps)
|
|
11541
11452
|
}, [h(registry.getBaseWidget('collapse'), {
|
|
11542
|
-
|
|
11453
|
+
class: this.collapseStyle,
|
|
11543
11454
|
props: {
|
|
11544
11455
|
value: this.activeName
|
|
11545
11456
|
},
|
|
@@ -11648,6 +11559,114 @@
|
|
|
11648
11559
|
}
|
|
11649
11560
|
});
|
|
11650
11561
|
|
|
11562
|
+
var UploadWidget = Vue__default["default"].extend({
|
|
11563
|
+
name: 'UploadWidget',
|
|
11564
|
+
props: {
|
|
11565
|
+
value: {
|
|
11566
|
+
type: Array,
|
|
11567
|
+
default: function _default() {
|
|
11568
|
+
return [];
|
|
11569
|
+
}
|
|
11570
|
+
},
|
|
11571
|
+
isUploadSuccessed: {
|
|
11572
|
+
type: String
|
|
11573
|
+
},
|
|
11574
|
+
responseHandler: {
|
|
11575
|
+
type: String
|
|
11576
|
+
}
|
|
11577
|
+
},
|
|
11578
|
+
methods: {
|
|
11579
|
+
request: function request(options) {
|
|
11580
|
+
var _this = this;
|
|
11581
|
+
var xhr = new XMLHttpRequest();
|
|
11582
|
+
options.fileObj.xhr = xhr;
|
|
11583
|
+
var formData = new FormData();
|
|
11584
|
+
options.data.forEach(function (item) {
|
|
11585
|
+
formData.append(item.name, executeExpression(item.value, _this.$parent.$parent));
|
|
11586
|
+
});
|
|
11587
|
+
formData.append(options.fileName, options.fileObj.origin);
|
|
11588
|
+
xhr.onreadystatechange = function () {
|
|
11589
|
+
if (xhr.readyState === 4) {
|
|
11590
|
+
var reponseText = _this.parseResponse(xhr.responseText || xhr.response);
|
|
11591
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
11592
|
+
options.fileObj.progress = 100 + '%';
|
|
11593
|
+
options.fileObj.errorMsg = reponseText.message || '上传失败';
|
|
11594
|
+
options.onError(options.fileObj, options.fileList, xhr.response);
|
|
11595
|
+
} else {
|
|
11596
|
+
options.onSuccess(reponseText, options.fileObj);
|
|
11597
|
+
}
|
|
11598
|
+
options.onDone(options.fileObj);
|
|
11599
|
+
}
|
|
11600
|
+
};
|
|
11601
|
+
xhr.upload.addEventListener('progress', options.onProgress, false);
|
|
11602
|
+
xhr.withCredentials = options.withCredentials;
|
|
11603
|
+
xhr.open(options.method, options.url, true);
|
|
11604
|
+
if (options.header) {
|
|
11605
|
+
if (Array.isArray(options.header)) {
|
|
11606
|
+
options.header.forEach(function (head) {
|
|
11607
|
+
var headerKey = head.name;
|
|
11608
|
+
var headerVal = executeExpression(head.value, _this.$parent.$parent);
|
|
11609
|
+
xhr.setRequestHeader(headerKey, headerVal);
|
|
11610
|
+
});
|
|
11611
|
+
} else {
|
|
11612
|
+
var headerKey = options.header.name;
|
|
11613
|
+
var headerVal = executeExpression(options.header.value, this.$parent.$parent);
|
|
11614
|
+
xhr.setRequestHeader(headerKey, headerVal);
|
|
11615
|
+
}
|
|
11616
|
+
}
|
|
11617
|
+
xhr.send(formData);
|
|
11618
|
+
return {
|
|
11619
|
+
abort: function abort() {
|
|
11620
|
+
xhr.abort();
|
|
11621
|
+
}
|
|
11622
|
+
};
|
|
11623
|
+
},
|
|
11624
|
+
parseResponse: function parseResponse(response) {
|
|
11625
|
+
if (!response) {
|
|
11626
|
+
return response || {};
|
|
11627
|
+
}
|
|
11628
|
+
try {
|
|
11629
|
+
return JSON.parse(response);
|
|
11630
|
+
} catch (error) {
|
|
11631
|
+
return response || {};
|
|
11632
|
+
}
|
|
11633
|
+
},
|
|
11634
|
+
handleResCode: function handleResCode(res) {
|
|
11635
|
+
var successed = true;
|
|
11636
|
+
if (this.isUploadSuccessed) {
|
|
11637
|
+
successed = executeExpression(this.isUploadSuccessed, this.$parent.$parent, [], {
|
|
11638
|
+
response: res
|
|
11639
|
+
});
|
|
11640
|
+
}
|
|
11641
|
+
if (!successed) return;
|
|
11642
|
+
if (this.responseHandler) {
|
|
11643
|
+
var files = executeExpression(this.responseHandler, this.$parent.$parent, [], {
|
|
11644
|
+
response: res
|
|
11645
|
+
});
|
|
11646
|
+
this.$emit('input', files);
|
|
11647
|
+
}
|
|
11648
|
+
return true;
|
|
11649
|
+
},
|
|
11650
|
+
handleSuccess: function handleSuccess(file, fileList) {
|
|
11651
|
+
if (!this.responseHandler) {
|
|
11652
|
+
this.$emit('input', fileList);
|
|
11653
|
+
}
|
|
11654
|
+
}
|
|
11655
|
+
},
|
|
11656
|
+
render: function render(h) {
|
|
11657
|
+
return h(registry.getBaseWidget('upload'), {
|
|
11658
|
+
props: _objectSpread2({
|
|
11659
|
+
customRequest: this.request,
|
|
11660
|
+
files: this.value,
|
|
11661
|
+
handleResCode: this.handleResCode
|
|
11662
|
+
}, this.$attrs),
|
|
11663
|
+
on: {
|
|
11664
|
+
'on-success': this.handleSuccess
|
|
11665
|
+
}
|
|
11666
|
+
});
|
|
11667
|
+
}
|
|
11668
|
+
});
|
|
11669
|
+
|
|
11651
11670
|
function styleInject(css, ref) {
|
|
11652
11671
|
if ( ref === void 0 ) ref = {};
|
|
11653
11672
|
var insertAt = ref.insertAt;
|
|
@@ -11678,6 +11697,197 @@
|
|
|
11678
11697
|
var css_248z = "";
|
|
11679
11698
|
styleInject(css_248z);
|
|
11680
11699
|
|
|
11700
|
+
var WidgetNode = /*#__PURE__*/function () {
|
|
11701
|
+
function WidgetNode(config) {
|
|
11702
|
+
_classCallCheck(this, WidgetNode);
|
|
11703
|
+
this.id = void 0;
|
|
11704
|
+
this.instance = void 0;
|
|
11705
|
+
this.parent = void 0;
|
|
11706
|
+
this.type = void 0;
|
|
11707
|
+
this.index = void 0;
|
|
11708
|
+
// todo
|
|
11709
|
+
this.children = void 0;
|
|
11710
|
+
var id = config.id,
|
|
11711
|
+
instance = config.instance,
|
|
11712
|
+
parent = config.parent,
|
|
11713
|
+
index = config.index,
|
|
11714
|
+
type = config.type,
|
|
11715
|
+
_config$children = config.children,
|
|
11716
|
+
children = _config$children === void 0 ? [] : _config$children;
|
|
11717
|
+
this.id = id;
|
|
11718
|
+
this.type = type;
|
|
11719
|
+
this.index = index;
|
|
11720
|
+
this.instance = instance;
|
|
11721
|
+
this.parent = parent;
|
|
11722
|
+
this.children = children;
|
|
11723
|
+
}
|
|
11724
|
+
// 当前node的值
|
|
11725
|
+
return _createClass(WidgetNode, [{
|
|
11726
|
+
key: "value",
|
|
11727
|
+
get: function get() {
|
|
11728
|
+
var _this$instance;
|
|
11729
|
+
return (_this$instance = this.instance) === null || _this$instance === void 0 ? void 0 : _this$instance.value;
|
|
11730
|
+
}
|
|
11731
|
+
// 是否含有可见子节点
|
|
11732
|
+
}, {
|
|
11733
|
+
key: "isChildrenVisible",
|
|
11734
|
+
get: function get() {
|
|
11735
|
+
if (this.type === 'node') {
|
|
11736
|
+
var _this$instance2;
|
|
11737
|
+
return (_this$instance2 = this.instance) === null || _this$instance2 === void 0 ? void 0 : _this$instance2.state.visible;
|
|
11738
|
+
}
|
|
11739
|
+
return this.children.some(function (child) {
|
|
11740
|
+
return child.isChildrenVisible;
|
|
11741
|
+
});
|
|
11742
|
+
}
|
|
11743
|
+
/**
|
|
11744
|
+
* 获取 parents
|
|
11745
|
+
*/
|
|
11746
|
+
}, {
|
|
11747
|
+
key: "parents",
|
|
11748
|
+
get: function get() {
|
|
11749
|
+
if (!this.parent) {
|
|
11750
|
+
return [];
|
|
11751
|
+
}
|
|
11752
|
+
return [].concat(_toConsumableArray(this.parent.parents), [this.parent]);
|
|
11753
|
+
}
|
|
11754
|
+
// 第一个子节点
|
|
11755
|
+
}, {
|
|
11756
|
+
key: "firstChild",
|
|
11757
|
+
get: function get() {
|
|
11758
|
+
return this.children[0] || null;
|
|
11759
|
+
}
|
|
11760
|
+
// 最后一个子节点
|
|
11761
|
+
}, {
|
|
11762
|
+
key: "lastChild",
|
|
11763
|
+
get: function get() {
|
|
11764
|
+
return this.children[this.children.length - 1] || null;
|
|
11765
|
+
}
|
|
11766
|
+
// 指定属性下的同胞节点
|
|
11767
|
+
}, {
|
|
11768
|
+
key: "getSibling",
|
|
11769
|
+
value: function getSibling(lastProp) {
|
|
11770
|
+
var _this$parent;
|
|
11771
|
+
var reg = new RegExp("".concat(Path.getPathLastProp(this.id) || '', "$"));
|
|
11772
|
+
var id = this.id.replace(reg, lastProp);
|
|
11773
|
+
return (_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.children.find(function (node) {
|
|
11774
|
+
return node.id === id;
|
|
11775
|
+
});
|
|
11776
|
+
}
|
|
11777
|
+
// 获取所以同胞节点(不含自己)
|
|
11778
|
+
}, {
|
|
11779
|
+
key: "getSiblings",
|
|
11780
|
+
value: function getSiblings() {
|
|
11781
|
+
var _this$parent2,
|
|
11782
|
+
_this = this;
|
|
11783
|
+
return ((_this$parent2 = this.parent) === null || _this$parent2 === void 0 ? void 0 : _this$parent2.children.filter(function (node) {
|
|
11784
|
+
return node.instance !== _this.instance;
|
|
11785
|
+
})) || [];
|
|
11786
|
+
}
|
|
11787
|
+
/**
|
|
11788
|
+
* 是否是叶子节点
|
|
11789
|
+
*/
|
|
11790
|
+
}, {
|
|
11791
|
+
key: "isLeaf",
|
|
11792
|
+
get: function get() {
|
|
11793
|
+
return !this.children.length;
|
|
11794
|
+
}
|
|
11795
|
+
}, {
|
|
11796
|
+
key: "appendChild",
|
|
11797
|
+
value: function appendChild(node) {
|
|
11798
|
+
var _this$children;
|
|
11799
|
+
var nodes = Array.isArray(node) ? node : [node];
|
|
11800
|
+
var offset = node.index !== undefined ? node.index : this.children.length;
|
|
11801
|
+
(_this$children = this.children).splice.apply(_this$children, [offset, 0].concat(_toConsumableArray(nodes)));
|
|
11802
|
+
this.children.slice(offset).forEach(function (node, index) {
|
|
11803
|
+
node.index = offset + index;
|
|
11804
|
+
});
|
|
11805
|
+
return nodes;
|
|
11806
|
+
}
|
|
11807
|
+
}, {
|
|
11808
|
+
key: "removeChild",
|
|
11809
|
+
value: function removeChild(node) {
|
|
11810
|
+
var _this2 = this;
|
|
11811
|
+
var nodes = Array.isArray(node) ? node : [node];
|
|
11812
|
+
var removedChildIndex = [];
|
|
11813
|
+
nodes.forEach(function (node) {
|
|
11814
|
+
var index = node.index;
|
|
11815
|
+
removedChildIndex.push(index);
|
|
11816
|
+
_this2.children.splice(index, 1);
|
|
11817
|
+
});
|
|
11818
|
+
var minIndex = Math.min.apply(Math, removedChildIndex);
|
|
11819
|
+
this.children.slice(minIndex).forEach(function (node, index) {
|
|
11820
|
+
node.index = minIndex + index;
|
|
11821
|
+
});
|
|
11822
|
+
return nodes;
|
|
11823
|
+
}
|
|
11824
|
+
}]);
|
|
11825
|
+
}();
|
|
11826
|
+
var WidgetTree = /*#__PURE__*/function () {
|
|
11827
|
+
function WidgetTree() {
|
|
11828
|
+
_classCallCheck(this, WidgetTree);
|
|
11829
|
+
this.widgetMap = {};
|
|
11830
|
+
}
|
|
11831
|
+
return _createClass(WidgetTree, [{
|
|
11832
|
+
key: "addWidgetNode",
|
|
11833
|
+
value: function addWidgetNode(path, instance, type, index) {
|
|
11834
|
+
if (path === '') {
|
|
11835
|
+
// 根节点
|
|
11836
|
+
var node = new WidgetNode({
|
|
11837
|
+
id: '',
|
|
11838
|
+
type: type,
|
|
11839
|
+
index: index,
|
|
11840
|
+
parent: null,
|
|
11841
|
+
instance: instance,
|
|
11842
|
+
children: []
|
|
11843
|
+
});
|
|
11844
|
+
this.widgetMap[path] = node;
|
|
11845
|
+
} else {
|
|
11846
|
+
// 普通节点
|
|
11847
|
+
var parentId = Path.getParentPath(path);
|
|
11848
|
+
var parentNode = this.widgetMap[parentId];
|
|
11849
|
+
var _node = new WidgetNode({
|
|
11850
|
+
id: (instance === null || instance === void 0 ? void 0 : instance.path) || path,
|
|
11851
|
+
type: type,
|
|
11852
|
+
index: index,
|
|
11853
|
+
parent: parentNode,
|
|
11854
|
+
instance: instance,
|
|
11855
|
+
children: []
|
|
11856
|
+
});
|
|
11857
|
+
if (!parentNode) {
|
|
11858
|
+
console.warn('Unexpected parent id, please check widget node', _node);
|
|
11859
|
+
} else {
|
|
11860
|
+
parentNode.appendChild(_node);
|
|
11861
|
+
}
|
|
11862
|
+
this.widgetMap[path] = _node;
|
|
11863
|
+
}
|
|
11864
|
+
}
|
|
11865
|
+
}, {
|
|
11866
|
+
key: "removeWidgetNode",
|
|
11867
|
+
value: function removeWidgetNode(path, instance) {
|
|
11868
|
+
var node = this.widgetMap[path];
|
|
11869
|
+
if (node) {
|
|
11870
|
+
if (node.parent) {
|
|
11871
|
+
var children = node.parent.children;
|
|
11872
|
+
var index = children.findIndex(function (item) {
|
|
11873
|
+
return item.instance === instance;
|
|
11874
|
+
});
|
|
11875
|
+
if (index > -1) {
|
|
11876
|
+
children.splice(index, 1);
|
|
11877
|
+
children.slice(index).forEach(function (node, i) {
|
|
11878
|
+
node.index = index + i;
|
|
11879
|
+
});
|
|
11880
|
+
}
|
|
11881
|
+
}
|
|
11882
|
+
if (node.instance === instance) {
|
|
11883
|
+
delete this.widgetMap[path];
|
|
11884
|
+
}
|
|
11885
|
+
}
|
|
11886
|
+
}
|
|
11887
|
+
}]);
|
|
11888
|
+
}();
|
|
11889
|
+
// export default new WidgetTree();
|
|
11890
|
+
|
|
11681
11891
|
var defaultOptions = {
|
|
11682
11892
|
namespace: 'bk',
|
|
11683
11893
|
components: {
|
|
@@ -11693,7 +11903,8 @@
|
|
|
11693
11903
|
switcher: SwitcherWidget,
|
|
11694
11904
|
color: ColorWidget,
|
|
11695
11905
|
bfInput: InputWidget,
|
|
11696
|
-
input: 'bk-input'
|
|
11906
|
+
input: 'bk-input',
|
|
11907
|
+
bfUpload: UploadWidget
|
|
11697
11908
|
},
|
|
11698
11909
|
fields: {
|
|
11699
11910
|
object: ObjectField,
|
|
@@ -11725,7 +11936,8 @@
|
|
|
11725
11936
|
data: function data() {
|
|
11726
11937
|
return {
|
|
11727
11938
|
rootData: {},
|
|
11728
|
-
formKey: 'bk-ui-form'
|
|
11939
|
+
formKey: 'bk-ui-form',
|
|
11940
|
+
widgetTree: new WidgetTree()
|
|
11729
11941
|
};
|
|
11730
11942
|
},
|
|
11731
11943
|
watch: {
|
|
@@ -11750,8 +11962,11 @@
|
|
|
11750
11962
|
registryGlobalRules(value);
|
|
11751
11963
|
}
|
|
11752
11964
|
},
|
|
11753
|
-
value:
|
|
11754
|
-
|
|
11965
|
+
value: {
|
|
11966
|
+
handler: function handler() {
|
|
11967
|
+
this.initFormData();
|
|
11968
|
+
},
|
|
11969
|
+
deep: true
|
|
11755
11970
|
}
|
|
11756
11971
|
},
|
|
11757
11972
|
beforeCreate: function beforeCreate() {
|
|
@@ -11773,9 +11988,15 @@
|
|
|
11773
11988
|
this.$emit('change', newValue, oldValue);
|
|
11774
11989
|
}
|
|
11775
11990
|
},
|
|
11776
|
-
validateForm: validateForm
|
|
11777
|
-
|
|
11778
|
-
|
|
11991
|
+
validateForm: function validateForm$1() {
|
|
11992
|
+
return validateForm(this.widgetTree);
|
|
11993
|
+
},
|
|
11994
|
+
validateFormItem: function validateFormItem$1(path) {
|
|
11995
|
+
return validateFormItem(path, this.widgetTree);
|
|
11996
|
+
},
|
|
11997
|
+
validate: function validate() {
|
|
11998
|
+
return validateFormWithResult(this.widgetTree);
|
|
11999
|
+
},
|
|
11779
12000
|
validateSchema: validateSchema
|
|
11780
12001
|
},
|
|
11781
12002
|
render: function render(h) {
|
|
@@ -11818,6 +12039,11 @@
|
|
|
11818
12039
|
}
|
|
11819
12040
|
}
|
|
11820
12041
|
})]);
|
|
12042
|
+
},
|
|
12043
|
+
provide: function provide() {
|
|
12044
|
+
return {
|
|
12045
|
+
widgetTree: this.widgetTree
|
|
12046
|
+
};
|
|
11821
12047
|
}
|
|
11822
12048
|
});
|
|
11823
12049
|
}
|