@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-es.js
CHANGED
|
@@ -634,16 +634,25 @@ function mergeDeep(target) {
|
|
|
634
634
|
}
|
|
635
635
|
if (!sources.length) return target;
|
|
636
636
|
var source = sources.shift();
|
|
637
|
-
if (
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
637
|
+
if (source === undefined) {
|
|
638
|
+
return target;
|
|
639
|
+
}
|
|
640
|
+
Object.entries(source).forEach(function (_ref) {
|
|
641
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
642
|
+
key = _ref2[0],
|
|
643
|
+
value = _ref2[1];
|
|
644
|
+
var targetValue = target[key];
|
|
645
|
+
if (isObj(value)) {
|
|
646
|
+
if (!(key in target)) {
|
|
647
|
+
target[key] = {};
|
|
648
|
+
} else if (!isObj(targetValue)) {
|
|
649
|
+
target[key] = {};
|
|
644
650
|
}
|
|
651
|
+
mergeDeep(target[key], value);
|
|
652
|
+
} else {
|
|
653
|
+
target[key] = value;
|
|
645
654
|
}
|
|
646
|
-
}
|
|
655
|
+
});
|
|
647
656
|
return mergeDeep.apply(void 0, [target].concat(sources));
|
|
648
657
|
}
|
|
649
658
|
function isArguments(object) {
|
|
@@ -836,7 +845,6 @@ var Registry = /*#__PURE__*/function () {
|
|
|
836
845
|
key = _ref2[0],
|
|
837
846
|
value = _ref2[1];
|
|
838
847
|
if (_this[props].has(key)) {
|
|
839
|
-
console.warn('repeat key', key);
|
|
840
848
|
return;
|
|
841
849
|
}
|
|
842
850
|
_this[props].set(key, value);
|
|
@@ -1535,6 +1543,10 @@ var props$1 = {
|
|
|
1535
1543
|
type: Boolean,
|
|
1536
1544
|
default: false
|
|
1537
1545
|
},
|
|
1546
|
+
disabled: {
|
|
1547
|
+
type: Boolean,
|
|
1548
|
+
default: false
|
|
1549
|
+
},
|
|
1538
1550
|
readonlyMode: {
|
|
1539
1551
|
type: String,
|
|
1540
1552
|
default: 'value',
|
|
@@ -1661,7 +1673,6 @@ var SchemaField = Vue.extend({
|
|
|
1661
1673
|
}
|
|
1662
1674
|
});
|
|
1663
1675
|
|
|
1664
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
1665
1676
|
// 组件对外暴露的上下文
|
|
1666
1677
|
var getContext = function getContext(instance) {
|
|
1667
1678
|
var context = instance.context,
|
|
@@ -1669,7 +1680,8 @@ var getContext = function getContext(instance) {
|
|
|
1669
1680
|
validate = instance.validate,
|
|
1670
1681
|
schema = instance.schema,
|
|
1671
1682
|
rootData = instance.rootData,
|
|
1672
|
-
widgetNode = instance.widgetNode
|
|
1683
|
+
widgetNode = instance.widgetNode,
|
|
1684
|
+
getValue = instance.getValue;
|
|
1673
1685
|
return {
|
|
1674
1686
|
$self: instance,
|
|
1675
1687
|
$context: context,
|
|
@@ -1678,11 +1690,33 @@ var getContext = function getContext(instance) {
|
|
|
1678
1690
|
$loadDataSource: loadDataSource,
|
|
1679
1691
|
$validate: validate,
|
|
1680
1692
|
$rootData: rootData,
|
|
1681
|
-
$widgetNode: widgetNode
|
|
1693
|
+
$widgetNode: widgetNode,
|
|
1694
|
+
$getValue: getValue,
|
|
1695
|
+
$getCookie: function $getCookie(name) {
|
|
1696
|
+
var cookies = document.cookie.split(';');
|
|
1697
|
+
var _iterator = _createForOfIteratorHelper(cookies),
|
|
1698
|
+
_step;
|
|
1699
|
+
try {
|
|
1700
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1701
|
+
var cookie = _step.value;
|
|
1702
|
+
var _cookie$trim$split = cookie.trim().split('='),
|
|
1703
|
+
_cookie$trim$split2 = _slicedToArray(_cookie$trim$split, 2),
|
|
1704
|
+
key = _cookie$trim$split2[0],
|
|
1705
|
+
value = _cookie$trim$split2[1];
|
|
1706
|
+
if (key === name) return decodeURIComponent(value);
|
|
1707
|
+
}
|
|
1708
|
+
} catch (err) {
|
|
1709
|
+
_iterator.e(err);
|
|
1710
|
+
} finally {
|
|
1711
|
+
_iterator.f();
|
|
1712
|
+
}
|
|
1713
|
+
return null;
|
|
1714
|
+
}
|
|
1682
1715
|
};
|
|
1683
1716
|
};
|
|
1684
1717
|
var executeExpression = function executeExpression(expression, instance) {
|
|
1685
1718
|
var $dep = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
1719
|
+
var $args = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1686
1720
|
var _getContext = getContext(instance),
|
|
1687
1721
|
$self = _getContext.$self,
|
|
1688
1722
|
$context = _getContext.$context,
|
|
@@ -1691,7 +1725,9 @@ var executeExpression = function executeExpression(expression, instance) {
|
|
|
1691
1725
|
$loadDataSource = _getContext.$loadDataSource,
|
|
1692
1726
|
$validate = _getContext.$validate,
|
|
1693
1727
|
$rootData = _getContext.$rootData,
|
|
1694
|
-
$widgetNode = _getContext.$widgetNode
|
|
1728
|
+
$widgetNode = _getContext.$widgetNode,
|
|
1729
|
+
$getValue = _getContext.$getValue,
|
|
1730
|
+
$getCookie = _getContext.$getCookie;
|
|
1695
1731
|
var context = {
|
|
1696
1732
|
$self: $self,
|
|
1697
1733
|
$context: $context,
|
|
@@ -1701,8 +1737,12 @@ var executeExpression = function executeExpression(expression, instance) {
|
|
|
1701
1737
|
$validate: $validate,
|
|
1702
1738
|
$rootData: $rootData,
|
|
1703
1739
|
$widgetNode: $widgetNode,
|
|
1704
|
-
$dep: $dep
|
|
1740
|
+
$dep: $dep,
|
|
1741
|
+
$getValue: $getValue,
|
|
1742
|
+
$getCookie: $getCookie,
|
|
1743
|
+
$args: $args
|
|
1705
1744
|
};
|
|
1745
|
+
if (['boolean', 'number'].includes(_typeof(expression))) return expression;
|
|
1706
1746
|
if (typeof expression === 'string') {
|
|
1707
1747
|
if (!/^{{.+}}$/.test(expression.trim())) return expression; // 没有上下文时直接返回
|
|
1708
1748
|
var expStr = expression.trim().replace(/(^{{)|(}}$)/g, '') // 去掉{{ }}
|
|
@@ -1718,6 +1758,9 @@ var executeExpression = function executeExpression(expression, instance) {
|
|
|
1718
1758
|
_ref.$rootData;
|
|
1719
1759
|
_ref.$widgetNode;
|
|
1720
1760
|
_ref.$dep;
|
|
1761
|
+
_ref.$getValue;
|
|
1762
|
+
_ref.$getCookie;
|
|
1763
|
+
_ref.$args;
|
|
1721
1764
|
try {
|
|
1722
1765
|
// eslint-disable-next-line no-eval
|
|
1723
1766
|
return innerFuncs.includes(expStr) ? eval("".concat(expStr, "()")) : eval(expStr);
|
|
@@ -1738,197 +1781,6 @@ var isExpression = function isExpression(expression) {
|
|
|
1738
1781
|
return typeof expression === 'string' && /{{.*}}/.test(expression);
|
|
1739
1782
|
};
|
|
1740
1783
|
|
|
1741
|
-
var WidgetNode = /*#__PURE__*/function () {
|
|
1742
|
-
function WidgetNode(config) {
|
|
1743
|
-
_classCallCheck(this, WidgetNode);
|
|
1744
|
-
this.id = void 0;
|
|
1745
|
-
this.instance = void 0;
|
|
1746
|
-
this.parent = void 0;
|
|
1747
|
-
this.type = void 0;
|
|
1748
|
-
this.index = void 0;
|
|
1749
|
-
// todo
|
|
1750
|
-
this.children = void 0;
|
|
1751
|
-
var id = config.id,
|
|
1752
|
-
instance = config.instance,
|
|
1753
|
-
parent = config.parent,
|
|
1754
|
-
index = config.index,
|
|
1755
|
-
type = config.type,
|
|
1756
|
-
_config$children = config.children,
|
|
1757
|
-
children = _config$children === void 0 ? [] : _config$children;
|
|
1758
|
-
this.id = id;
|
|
1759
|
-
this.type = type;
|
|
1760
|
-
this.index = index;
|
|
1761
|
-
this.instance = instance;
|
|
1762
|
-
this.parent = parent;
|
|
1763
|
-
this.children = children;
|
|
1764
|
-
}
|
|
1765
|
-
// 当前node的值
|
|
1766
|
-
return _createClass(WidgetNode, [{
|
|
1767
|
-
key: "value",
|
|
1768
|
-
get: function get() {
|
|
1769
|
-
var _this$instance;
|
|
1770
|
-
return (_this$instance = this.instance) === null || _this$instance === void 0 ? void 0 : _this$instance.value;
|
|
1771
|
-
}
|
|
1772
|
-
// 是否含有可见子节点
|
|
1773
|
-
}, {
|
|
1774
|
-
key: "isChildrenVisible",
|
|
1775
|
-
get: function get() {
|
|
1776
|
-
if (this.type === 'node') {
|
|
1777
|
-
var _this$instance2;
|
|
1778
|
-
return (_this$instance2 = this.instance) === null || _this$instance2 === void 0 ? void 0 : _this$instance2.state.visible;
|
|
1779
|
-
}
|
|
1780
|
-
return this.children.some(function (child) {
|
|
1781
|
-
return child.isChildrenVisible;
|
|
1782
|
-
});
|
|
1783
|
-
}
|
|
1784
|
-
/**
|
|
1785
|
-
* 获取 parents
|
|
1786
|
-
*/
|
|
1787
|
-
}, {
|
|
1788
|
-
key: "parents",
|
|
1789
|
-
get: function get() {
|
|
1790
|
-
if (!this.parent) {
|
|
1791
|
-
return [];
|
|
1792
|
-
}
|
|
1793
|
-
return [].concat(_toConsumableArray(this.parent.parents), [this.parent]);
|
|
1794
|
-
}
|
|
1795
|
-
// 第一个子节点
|
|
1796
|
-
}, {
|
|
1797
|
-
key: "firstChild",
|
|
1798
|
-
get: function get() {
|
|
1799
|
-
return this.children[0] || null;
|
|
1800
|
-
}
|
|
1801
|
-
// 最后一个子节点
|
|
1802
|
-
}, {
|
|
1803
|
-
key: "lastChild",
|
|
1804
|
-
get: function get() {
|
|
1805
|
-
return this.children[this.children.length - 1] || null;
|
|
1806
|
-
}
|
|
1807
|
-
// 指定属性下的同胞节点
|
|
1808
|
-
}, {
|
|
1809
|
-
key: "getSibling",
|
|
1810
|
-
value: function getSibling(lastProp) {
|
|
1811
|
-
var _this$parent;
|
|
1812
|
-
var reg = new RegExp("".concat(Path.getPathLastProp(this.id) || '', "$"));
|
|
1813
|
-
var id = this.id.replace(reg, lastProp);
|
|
1814
|
-
return (_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.children.find(function (node) {
|
|
1815
|
-
return node.id === id;
|
|
1816
|
-
});
|
|
1817
|
-
}
|
|
1818
|
-
// 获取所以同胞节点(不含自己)
|
|
1819
|
-
}, {
|
|
1820
|
-
key: "getSiblings",
|
|
1821
|
-
value: function getSiblings() {
|
|
1822
|
-
var _this$parent2,
|
|
1823
|
-
_this = this;
|
|
1824
|
-
return ((_this$parent2 = this.parent) === null || _this$parent2 === void 0 ? void 0 : _this$parent2.children.filter(function (node) {
|
|
1825
|
-
return node.instance !== _this.instance;
|
|
1826
|
-
})) || [];
|
|
1827
|
-
}
|
|
1828
|
-
/**
|
|
1829
|
-
* 是否是叶子节点
|
|
1830
|
-
*/
|
|
1831
|
-
}, {
|
|
1832
|
-
key: "isLeaf",
|
|
1833
|
-
get: function get() {
|
|
1834
|
-
return !this.children.length;
|
|
1835
|
-
}
|
|
1836
|
-
}, {
|
|
1837
|
-
key: "appendChild",
|
|
1838
|
-
value: function appendChild(node) {
|
|
1839
|
-
var _this$children;
|
|
1840
|
-
var nodes = Array.isArray(node) ? node : [node];
|
|
1841
|
-
var offset = node.index !== undefined ? node.index : this.children.length;
|
|
1842
|
-
(_this$children = this.children).splice.apply(_this$children, [offset, 0].concat(_toConsumableArray(nodes)));
|
|
1843
|
-
this.children.slice(offset).forEach(function (node, index) {
|
|
1844
|
-
node.index = offset + index;
|
|
1845
|
-
});
|
|
1846
|
-
return nodes;
|
|
1847
|
-
}
|
|
1848
|
-
}, {
|
|
1849
|
-
key: "removeChild",
|
|
1850
|
-
value: function removeChild(node) {
|
|
1851
|
-
var _this2 = this;
|
|
1852
|
-
var nodes = Array.isArray(node) ? node : [node];
|
|
1853
|
-
var removedChildIndex = [];
|
|
1854
|
-
nodes.forEach(function (node) {
|
|
1855
|
-
var index = node.index;
|
|
1856
|
-
removedChildIndex.push(index);
|
|
1857
|
-
_this2.children.splice(index, 1);
|
|
1858
|
-
});
|
|
1859
|
-
var minIndex = Math.min.apply(Math, removedChildIndex);
|
|
1860
|
-
this.children.slice(minIndex).forEach(function (node, index) {
|
|
1861
|
-
node.index = minIndex + index;
|
|
1862
|
-
});
|
|
1863
|
-
return nodes;
|
|
1864
|
-
}
|
|
1865
|
-
}]);
|
|
1866
|
-
}();
|
|
1867
|
-
var WidgetTree = /*#__PURE__*/function () {
|
|
1868
|
-
function WidgetTree() {
|
|
1869
|
-
_classCallCheck(this, WidgetTree);
|
|
1870
|
-
this.widgetMap = {};
|
|
1871
|
-
}
|
|
1872
|
-
return _createClass(WidgetTree, [{
|
|
1873
|
-
key: "addWidgetNode",
|
|
1874
|
-
value: function addWidgetNode(path, instance, type, index) {
|
|
1875
|
-
if (path === '') {
|
|
1876
|
-
// 根节点
|
|
1877
|
-
var node = new WidgetNode({
|
|
1878
|
-
id: '',
|
|
1879
|
-
type: type,
|
|
1880
|
-
index: index,
|
|
1881
|
-
parent: null,
|
|
1882
|
-
instance: instance,
|
|
1883
|
-
children: []
|
|
1884
|
-
});
|
|
1885
|
-
this.widgetMap[path] = node;
|
|
1886
|
-
} else {
|
|
1887
|
-
// 普通节点
|
|
1888
|
-
var parentId = Path.getParentPath(path);
|
|
1889
|
-
var parentNode = this.widgetMap[parentId];
|
|
1890
|
-
var _node = new WidgetNode({
|
|
1891
|
-
id: (instance === null || instance === void 0 ? void 0 : instance.path) || path,
|
|
1892
|
-
type: type,
|
|
1893
|
-
index: index,
|
|
1894
|
-
parent: parentNode,
|
|
1895
|
-
instance: instance,
|
|
1896
|
-
children: []
|
|
1897
|
-
});
|
|
1898
|
-
if (!parentNode) {
|
|
1899
|
-
console.warn('Unexpected parent id, please check widget node', _node);
|
|
1900
|
-
} else {
|
|
1901
|
-
parentNode.appendChild(_node);
|
|
1902
|
-
}
|
|
1903
|
-
this.widgetMap[path] = _node;
|
|
1904
|
-
}
|
|
1905
|
-
}
|
|
1906
|
-
}, {
|
|
1907
|
-
key: "removeWidgetNode",
|
|
1908
|
-
value: function removeWidgetNode(path, instance) {
|
|
1909
|
-
var node = this.widgetMap[path];
|
|
1910
|
-
if (node) {
|
|
1911
|
-
if (node.parent) {
|
|
1912
|
-
var children = node.parent.children;
|
|
1913
|
-
var index = children.findIndex(function (item) {
|
|
1914
|
-
return item.instance === instance;
|
|
1915
|
-
});
|
|
1916
|
-
if (index > -1) {
|
|
1917
|
-
children.splice(index, 1);
|
|
1918
|
-
children.slice(index).forEach(function (node, i) {
|
|
1919
|
-
node.index = index + i;
|
|
1920
|
-
});
|
|
1921
|
-
}
|
|
1922
|
-
}
|
|
1923
|
-
if (node.instance === instance) {
|
|
1924
|
-
delete this.widgetMap[path];
|
|
1925
|
-
}
|
|
1926
|
-
}
|
|
1927
|
-
}
|
|
1928
|
-
}]);
|
|
1929
|
-
}();
|
|
1930
|
-
var widgetTree = new WidgetTree();
|
|
1931
|
-
|
|
1932
1784
|
var reactionsMap = {};
|
|
1933
1785
|
var subscribe = function subscribe(path, typeName, fn) {
|
|
1934
1786
|
if (!reactionsMap[path]) {
|
|
@@ -1960,7 +1812,7 @@ var subscribe = function subscribe(path, typeName, fn) {
|
|
|
1960
1812
|
* @param reaction 传入的reacion配置
|
|
1961
1813
|
* @returns viod
|
|
1962
1814
|
*/
|
|
1963
|
-
var resolveReaction = function resolveReaction(crtInsPath, targetPath, reaction) {
|
|
1815
|
+
var resolveReaction = function resolveReaction(crtInsPath, targetPath, reaction, widgetTree) {
|
|
1964
1816
|
return function () {
|
|
1965
1817
|
var _ref = widgetTree.widgetMap[crtInsPath] || {},
|
|
1966
1818
|
crtInstance = _ref.instance; // 当前组件实例,用来条件表达式判断
|
|
@@ -2005,6 +1857,7 @@ var parsePath = function parsePath(path, instance) {
|
|
|
2005
1857
|
};
|
|
2006
1858
|
var reactionRegister = function reactionRegister(path) {
|
|
2007
1859
|
var reactions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
1860
|
+
var widgetTree = arguments.length > 2 ? arguments[2] : undefined;
|
|
2008
1861
|
var _ref3 = widgetTree.widgetMap[path] || {},
|
|
2009
1862
|
instance = _ref3.instance;
|
|
2010
1863
|
if (reactions && Array.isArray(reactions)) {
|
|
@@ -2016,13 +1869,13 @@ var reactionRegister = function reactionRegister(path) {
|
|
|
2016
1869
|
subscribePaths.forEach(function (p) {
|
|
2017
1870
|
var sourcePathItem = parsePath(p, instance);
|
|
2018
1871
|
if (typeof reaction.lifetime === 'string') {
|
|
2019
|
-
subscribe(sourcePathItem, "lifetime/".concat(reaction.lifetime), resolveReaction(path, targePath, reaction));
|
|
1872
|
+
subscribe(sourcePathItem, "lifetime/".concat(reaction.lifetime), resolveReaction(path, targePath, reaction, widgetTree));
|
|
2020
1873
|
}
|
|
2021
1874
|
if (typeof reaction.effect === 'string') {
|
|
2022
|
-
subscribe(sourcePathItem, "effect/".concat(reaction.effect), resolveReaction(path, targePath, reaction));
|
|
1875
|
+
subscribe(sourcePathItem, "effect/".concat(reaction.effect), resolveReaction(path, targePath, reaction, widgetTree));
|
|
2023
1876
|
}
|
|
2024
1877
|
if (!reaction.lifetime && !reaction.effect) {
|
|
2025
|
-
subscribe(sourcePathItem, 'valChange', resolveReaction(path, targePath, reaction));
|
|
1878
|
+
subscribe(sourcePathItem, 'valChange', resolveReaction(path, targePath, reaction, widgetTree));
|
|
2026
1879
|
}
|
|
2027
1880
|
});
|
|
2028
1881
|
});
|
|
@@ -9756,7 +9609,7 @@ var validate = function validate(rule, instance) {
|
|
|
9756
9609
|
};
|
|
9757
9610
|
};
|
|
9758
9611
|
// 设置表单项校验状态
|
|
9759
|
-
var setWidgetErrorTips = function setWidgetErrorTips(path, isError, errorMsg) {
|
|
9612
|
+
var setWidgetErrorTips = function setWidgetErrorTips(path, isError, errorMsg, widgetTree) {
|
|
9760
9613
|
var formItem = widgetTree.widgetMap[path];
|
|
9761
9614
|
var instance = formItem.instance;
|
|
9762
9615
|
if (formItem.type === 'node') {
|
|
@@ -9789,7 +9642,7 @@ var setWidgetErrorTips = function setWidgetErrorTips(path, isError, errorMsg) {
|
|
|
9789
9642
|
* 校验单个表单项
|
|
9790
9643
|
* @param path 字段路径
|
|
9791
9644
|
*/
|
|
9792
|
-
var validateFormItem = function validateFormItem(path) {
|
|
9645
|
+
var validateFormItem = function validateFormItem(path, widgetTree) {
|
|
9793
9646
|
var _instance$schema;
|
|
9794
9647
|
// TODO 校验逻辑梳理
|
|
9795
9648
|
var formItem = widgetTree.widgetMap[path];
|
|
@@ -9829,7 +9682,7 @@ var validateFormItem = function validateFormItem(path) {
|
|
|
9829
9682
|
var errorsText = ajv.errorsText(schemaValidate.errors, {
|
|
9830
9683
|
separator: '\n'
|
|
9831
9684
|
});
|
|
9832
|
-
setWidgetErrorTips(path, true, errorsText);
|
|
9685
|
+
setWidgetErrorTips(path, true, errorsText, widgetTree);
|
|
9833
9686
|
return {
|
|
9834
9687
|
result: false,
|
|
9835
9688
|
message: errorsText,
|
|
@@ -9858,7 +9711,7 @@ var validateFormItem = function validateFormItem(path) {
|
|
|
9858
9711
|
_iterator.f();
|
|
9859
9712
|
}
|
|
9860
9713
|
if (isError) {
|
|
9861
|
-
setWidgetErrorTips(path, true, errorMsg);
|
|
9714
|
+
setWidgetErrorTips(path, true, errorMsg, widgetTree);
|
|
9862
9715
|
return {
|
|
9863
9716
|
result: false,
|
|
9864
9717
|
message: errorMsg,
|
|
@@ -9874,24 +9727,24 @@ var validateFormItem = function validateFormItem(path) {
|
|
|
9874
9727
|
/**
|
|
9875
9728
|
* 校验整个表单
|
|
9876
9729
|
*/
|
|
9877
|
-
var validateForm = function validateForm() {
|
|
9730
|
+
var validateForm = function validateForm(widgetTree) {
|
|
9878
9731
|
var isValid = true;
|
|
9879
9732
|
Object.keys(widgetTree.widgetMap).forEach(function (path) {
|
|
9880
9733
|
var _validateFormItem;
|
|
9881
|
-
if (!((_validateFormItem = validateFormItem(path)) !== null && _validateFormItem !== void 0 && _validateFormItem.result)) isValid = false;
|
|
9734
|
+
if (!((_validateFormItem = validateFormItem(path, widgetTree)) !== null && _validateFormItem !== void 0 && _validateFormItem.result)) isValid = false;
|
|
9882
9735
|
});
|
|
9883
9736
|
return isValid;
|
|
9884
9737
|
};
|
|
9885
9738
|
/**
|
|
9886
9739
|
* 校验表单(抛出具体错误信息)
|
|
9887
9740
|
*/
|
|
9888
|
-
var validateFormWithResult = function validateFormWithResult() {
|
|
9741
|
+
var validateFormWithResult = function validateFormWithResult(widgetTree) {
|
|
9889
9742
|
return new Promise(function (resolve, reject) {
|
|
9890
9743
|
var result = Object.keys(widgetTree.widgetMap).filter(function (path) {
|
|
9891
9744
|
var _widgetTree$widgetMap;
|
|
9892
9745
|
return ((_widgetTree$widgetMap = widgetTree.widgetMap[path]) === null || _widgetTree$widgetMap === void 0 ? void 0 : _widgetTree$widgetMap.type) === 'node';
|
|
9893
9746
|
}).reduce(function (pre, path) {
|
|
9894
|
-
var validateResult = validateFormItem(path);
|
|
9747
|
+
var validateResult = validateFormItem(path, widgetTree);
|
|
9895
9748
|
if (!(validateResult !== null && validateResult !== void 0 && validateResult.result)) {
|
|
9896
9749
|
pre.push(validateResult);
|
|
9897
9750
|
}
|
|
@@ -9934,8 +9787,8 @@ var validateSchema = /*#__PURE__*/function () {
|
|
|
9934
9787
|
* 触发校验
|
|
9935
9788
|
* @param path 字段路径
|
|
9936
9789
|
*/
|
|
9937
|
-
var dispatchValidate = function dispatchValidate(path) {
|
|
9938
|
-
return validateFormItem(path);
|
|
9790
|
+
var dispatchValidate = function dispatchValidate(path, widgetTree) {
|
|
9791
|
+
return validateFormItem(path, widgetTree);
|
|
9939
9792
|
};
|
|
9940
9793
|
|
|
9941
9794
|
// 事件订阅器
|
|
@@ -10025,6 +9878,7 @@ var _excluded$4 = ["url", "params"],
|
|
|
10025
9878
|
var Widget = Vue.extend({
|
|
10026
9879
|
name: 'Widget',
|
|
10027
9880
|
props: props,
|
|
9881
|
+
inject: ['widgetTree'],
|
|
10028
9882
|
data: function data() {
|
|
10029
9883
|
return {
|
|
10030
9884
|
loading: false,
|
|
@@ -10043,10 +9897,10 @@ var Widget = Vue.extend({
|
|
|
10043
9897
|
},
|
|
10044
9898
|
computed: {
|
|
10045
9899
|
widgetMap: function widgetMap() {
|
|
10046
|
-
return widgetTree.widgetMap;
|
|
9900
|
+
return this.widgetTree.widgetMap;
|
|
10047
9901
|
},
|
|
10048
9902
|
widgetNode: function widgetNode() {
|
|
10049
|
-
return widgetTree.widgetMap[this.path];
|
|
9903
|
+
return this.widgetTree.widgetMap[this.path];
|
|
10050
9904
|
},
|
|
10051
9905
|
parent: function parent() {
|
|
10052
9906
|
var _this$widgetNode;
|
|
@@ -10064,7 +9918,7 @@ var Widget = Vue.extend({
|
|
|
10064
9918
|
if (!deepEquals(newValue, oldValue)) {
|
|
10065
9919
|
setTimeout(function () {
|
|
10066
9920
|
reactionDispatch(_this.path, 'valChange');
|
|
10067
|
-
dispatchValidate(_this.path);
|
|
9921
|
+
dispatchValidate(_this.path, _this.widgetTree);
|
|
10068
9922
|
}, 0);
|
|
10069
9923
|
}
|
|
10070
9924
|
}
|
|
@@ -10096,17 +9950,17 @@ var Widget = Vue.extend({
|
|
|
10096
9950
|
}
|
|
10097
9951
|
});
|
|
10098
9952
|
// 注册widget TreeNode
|
|
10099
|
-
widgetTree.addWidgetNode(this.path, this, 'node');
|
|
9953
|
+
this.widgetTree.addWidgetNode(this.path, this, 'node');
|
|
10100
9954
|
},
|
|
10101
9955
|
mounted: function mounted() {
|
|
10102
9956
|
// 注册联动
|
|
10103
|
-
reactionRegister(this.path, this.widgetSchema['ui:reactions']);
|
|
9957
|
+
reactionRegister(this.path, this.widgetSchema['ui:reactions'], this.widgetTree);
|
|
10104
9958
|
// 首次联动
|
|
10105
9959
|
reactionDispatch(this.path, 'valChange');
|
|
10106
9960
|
reactionDispatch(this.path, 'lifetime/init');
|
|
10107
9961
|
},
|
|
10108
9962
|
beforeDestroy: function beforeDestroy() {
|
|
10109
|
-
widgetTree.removeWidgetNode(this.path, this);
|
|
9963
|
+
this.widgetTree.removeWidgetNode(this.path, this);
|
|
10110
9964
|
reactionUnRegister(this.path);
|
|
10111
9965
|
},
|
|
10112
9966
|
methods: {
|
|
@@ -10225,7 +10079,14 @@ var Widget = Vue.extend({
|
|
|
10225
10079
|
}
|
|
10226
10080
|
},
|
|
10227
10081
|
render: function render(h) {
|
|
10228
|
-
var _events$callbacks,
|
|
10082
|
+
var _events$callbacks,
|
|
10083
|
+
_this$$scopedSlots$de,
|
|
10084
|
+
_this$$scopedSlots$de2,
|
|
10085
|
+
_this$$scopedSlots,
|
|
10086
|
+
_this5 = this,
|
|
10087
|
+
_this$widgetSchema$ui5,
|
|
10088
|
+
_this$$scopedSlots$su,
|
|
10089
|
+
_this$$scopedSlots2;
|
|
10229
10090
|
var _Schema$getUiComponen = Schema.getUiComponent(this.widgetSchema),
|
|
10230
10091
|
name = _Schema$getUiComponen.name,
|
|
10231
10092
|
uiVnodeData = _objectWithoutProperties(_Schema$getUiComponen, _excluded2);
|
|
@@ -10255,6 +10116,7 @@ var Widget = Vue.extend({
|
|
|
10255
10116
|
path: self.path,
|
|
10256
10117
|
value: value
|
|
10257
10118
|
});
|
|
10119
|
+
reactionDispatch(self.path, 'effect/update');
|
|
10258
10120
|
}]),
|
|
10259
10121
|
click: function click() {
|
|
10260
10122
|
reactionDispatch(self.path, 'effect/click');
|
|
@@ -10274,7 +10136,10 @@ var Widget = Vue.extend({
|
|
|
10274
10136
|
// 渲染删除按钮(用于数组类型widget删除)
|
|
10275
10137
|
var renderDelete = function renderDelete() {
|
|
10276
10138
|
return h('span', {
|
|
10277
|
-
class: ['bk-schema-form-group-delete'
|
|
10139
|
+
class: ['bk-schema-form-group-delete', {
|
|
10140
|
+
disabled: _this5.disabled,
|
|
10141
|
+
readonly: _this5.readonly
|
|
10142
|
+
}],
|
|
10278
10143
|
style: {
|
|
10279
10144
|
right: '0px',
|
|
10280
10145
|
top: '0px'
|
|
@@ -10395,10 +10260,12 @@ var NumberField = Vue.extend({
|
|
|
10395
10260
|
|
|
10396
10261
|
var messages = {
|
|
10397
10262
|
'zh-CN': {
|
|
10398
|
-
add: '添加'
|
|
10263
|
+
add: '添加',
|
|
10264
|
+
required: '必填项'
|
|
10399
10265
|
},
|
|
10400
10266
|
'en-US': {
|
|
10401
|
-
add: 'Add'
|
|
10267
|
+
add: 'Add',
|
|
10268
|
+
required: 'Required'
|
|
10402
10269
|
}
|
|
10403
10270
|
};
|
|
10404
10271
|
function locale(item) {
|
|
@@ -10437,6 +10304,7 @@ var ArrayWidget = Vue.extend({
|
|
|
10437
10304
|
},
|
|
10438
10305
|
// 添加item
|
|
10439
10306
|
handleAddItem: function handleAddItem() {
|
|
10307
|
+
if (this.disabled || this.readonly) return;
|
|
10440
10308
|
var data = Schema.getSchemaDefaultValue(this.schema.items);
|
|
10441
10309
|
var value = JSON.parse(JSON.stringify(this.value || []));
|
|
10442
10310
|
value.push(data);
|
|
@@ -10447,6 +10315,7 @@ var ArrayWidget = Vue.extend({
|
|
|
10447
10315
|
},
|
|
10448
10316
|
// 删除item
|
|
10449
10317
|
handleDeleteItem: function handleDeleteItem(path) {
|
|
10318
|
+
if (this.disabled || this.readonly) return;
|
|
10450
10319
|
var index = Number(Path.getPathLastProp(path));
|
|
10451
10320
|
var value = JSON.parse(JSON.stringify(this.value || []));
|
|
10452
10321
|
value.splice(index, 1);
|
|
@@ -10457,7 +10326,13 @@ var ArrayWidget = Vue.extend({
|
|
|
10457
10326
|
}
|
|
10458
10327
|
},
|
|
10459
10328
|
render: function render(h) {
|
|
10460
|
-
var _this = this
|
|
10329
|
+
var _this = this,
|
|
10330
|
+
_self$value,
|
|
10331
|
+
_this$schema,
|
|
10332
|
+
_this$schema$uiProps,
|
|
10333
|
+
_this$schema2,
|
|
10334
|
+
_this$schema3,
|
|
10335
|
+
_this$schema3$uiProp;
|
|
10461
10336
|
var self = this;
|
|
10462
10337
|
var arrVnodeList = (Array.isArray(this.value) ? this.value : []).map(function (_, index) {
|
|
10463
10338
|
var curPath = Path.getCurPath(_this.path, index);
|
|
@@ -10481,18 +10356,24 @@ var ArrayWidget = Vue.extend({
|
|
|
10481
10356
|
var _Schema$getGroupWrap = Schema.getGroupWrap(this.schema),
|
|
10482
10357
|
name = _Schema$getGroupWrap.name,
|
|
10483
10358
|
vnode = _objectWithoutProperties(_Schema$getGroupWrap, _excluded$2);
|
|
10359
|
+
var error = ((_self$value = self.value) === null || _self$value === void 0 ? void 0 : _self$value.length) === 0 && self.required;
|
|
10484
10360
|
return h(name, mergeDeep({
|
|
10485
10361
|
props: _objectSpread2(_objectSpread2({}, this.$props), {}, {
|
|
10486
10362
|
layout: {},
|
|
10487
10363
|
showTitle: true // 数组类型默认展示分组title
|
|
10488
10364
|
}),
|
|
10489
10365
|
style: _objectSpread2({}, this.layout.item || {})
|
|
10490
|
-
}, vnode), [].concat(_toConsumableArray(arrVnodeList), [h(registry.getBaseWidget('form-item'), {
|
|
10366
|
+
}, vnode), [].concat(_toConsumableArray(arrVnodeList), [!this.readonly ? h(registry.getBaseWidget('form-item'), {
|
|
10491
10367
|
class: {
|
|
10492
10368
|
'bk-schema-form-item-auto-height': true
|
|
10493
10369
|
}
|
|
10494
10370
|
}, [h('span', {
|
|
10495
|
-
class: ['bk-schema-form-group-add'
|
|
10371
|
+
class: ['bk-schema-form-group-add', {
|
|
10372
|
+
'error': error
|
|
10373
|
+
}, (_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, {
|
|
10374
|
+
disabled: this.disabled,
|
|
10375
|
+
readonly: this.readonly
|
|
10376
|
+
}],
|
|
10496
10377
|
on: {
|
|
10497
10378
|
click: function click() {
|
|
10498
10379
|
self.handleAddItem();
|
|
@@ -10500,7 +10381,9 @@ var ArrayWidget = Vue.extend({
|
|
|
10500
10381
|
}
|
|
10501
10382
|
}, [h('i', {
|
|
10502
10383
|
class: ['bk-icon icon-plus-circle-shape mr5']
|
|
10503
|
-
}), locale('add')
|
|
10384
|
+
}), "".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', {
|
|
10385
|
+
class: ['bk-schema-form-item__error-tips']
|
|
10386
|
+
}, [locale('required')])]) : null]));
|
|
10504
10387
|
}
|
|
10505
10388
|
});
|
|
10506
10389
|
|
|
@@ -10911,6 +10794,7 @@ var getRowDefaultData = function getRowDefaultData() {
|
|
|
10911
10794
|
var TableWidget = Vue.extend({
|
|
10912
10795
|
name: 'TableWidget',
|
|
10913
10796
|
props: props,
|
|
10797
|
+
inject: ['widgetTree'],
|
|
10914
10798
|
watch: {
|
|
10915
10799
|
value: {
|
|
10916
10800
|
immediate: true,
|
|
@@ -10920,9 +10804,9 @@ var TableWidget = Vue.extend({
|
|
|
10920
10804
|
(_this$value = this.value) === null || _this$value === void 0 ? void 0 : _this$value.forEach(function (_, index) {
|
|
10921
10805
|
var path = "".concat(_this.path, ".").concat(index);
|
|
10922
10806
|
// 销毁上一次的缓存
|
|
10923
|
-
widgetTree.removeWidgetNode(path, null);
|
|
10807
|
+
_this.widgetTree.removeWidgetNode(path, null);
|
|
10924
10808
|
// 重新当前行的父节点
|
|
10925
|
-
widgetTree.addWidgetNode(path, null, 'group');
|
|
10809
|
+
_this.widgetTree.addWidgetNode(path, null, 'group');
|
|
10926
10810
|
});
|
|
10927
10811
|
}
|
|
10928
10812
|
}
|
|
@@ -10969,7 +10853,19 @@ var TableWidget = Vue.extend({
|
|
|
10969
10853
|
}
|
|
10970
10854
|
var uiOptions = Schema.getUiOptions(schema);
|
|
10971
10855
|
var getTableColumn = function getTableColumn() {
|
|
10972
|
-
|
|
10856
|
+
// 表格列排序优先取 ui:order 属性里配置的顺序
|
|
10857
|
+
var colKeys = Object.keys(properties);
|
|
10858
|
+
var orders = (schemaItems === null || schemaItems === void 0 ? void 0 : schemaItems['ui:order']) || [];
|
|
10859
|
+
var orderMap = new Map();
|
|
10860
|
+
orders.forEach(function (key, index) {
|
|
10861
|
+
orderMap.set(key, index);
|
|
10862
|
+
});
|
|
10863
|
+
colKeys.sort(function (a, b) {
|
|
10864
|
+
var orderA = orderMap.has(a) ? orderMap.get(a) : Infinity;
|
|
10865
|
+
var orderB = orderMap.has(b) ? orderMap.get(b) : Infinity;
|
|
10866
|
+
return orderA - orderB;
|
|
10867
|
+
});
|
|
10868
|
+
var VNodeList = colKeys.map(function (key) {
|
|
10973
10869
|
var _colField$uiProps, _colField$uiProps2;
|
|
10974
10870
|
var colField = properties[key];
|
|
10975
10871
|
// 仅支持基础数据类型的属性配置,render-header、sort-method、formatter等Function类型的属性不属于json支持的数据类型,配置将不会生效
|
|
@@ -11091,6 +10987,7 @@ var TableWidget = Vue.extend({
|
|
|
11091
10987
|
|
|
11092
10988
|
var FieldGroupWrap = Vue.extend({
|
|
11093
10989
|
name: 'FieldGroupWrap',
|
|
10990
|
+
inject: ['widgetTree'],
|
|
11094
10991
|
props: _objectSpread2(_objectSpread2({}, props), {}, {
|
|
11095
10992
|
// 组类型
|
|
11096
10993
|
type: {
|
|
@@ -11117,6 +11014,10 @@ var FieldGroupWrap = Vue.extend({
|
|
|
11117
11014
|
hideEmptyRow: {
|
|
11118
11015
|
type: Boolean,
|
|
11119
11016
|
default: false
|
|
11017
|
+
},
|
|
11018
|
+
description: {
|
|
11019
|
+
type: String,
|
|
11020
|
+
default: ''
|
|
11120
11021
|
}
|
|
11121
11022
|
}),
|
|
11122
11023
|
data: function data() {
|
|
@@ -11130,14 +11031,14 @@ var FieldGroupWrap = Vue.extend({
|
|
|
11130
11031
|
},
|
|
11131
11032
|
created: function created() {
|
|
11132
11033
|
// 注册widget TreeNode
|
|
11133
|
-
widgetTree.addWidgetNode(this.path, this, 'group');
|
|
11034
|
+
this.widgetTree.addWidgetNode(this.path, this, 'group');
|
|
11134
11035
|
},
|
|
11135
11036
|
mounted: function mounted() {
|
|
11136
11037
|
// 更新样式
|
|
11137
11038
|
this.$forceUpdate();
|
|
11138
11039
|
},
|
|
11139
11040
|
beforeDestroy: function beforeDestroy() {
|
|
11140
|
-
widgetTree.removeWidgetNode(this.path, this);
|
|
11041
|
+
this.widgetTree.removeWidgetNode(this.path, this);
|
|
11141
11042
|
},
|
|
11142
11043
|
methods: {
|
|
11143
11044
|
setState: function setState(key, value) {
|
|
@@ -11160,9 +11061,9 @@ var FieldGroupWrap = Vue.extend({
|
|
|
11160
11061
|
render: function render(h) {
|
|
11161
11062
|
var _this$layout,
|
|
11162
11063
|
_this$layout2,
|
|
11064
|
+
_this = this,
|
|
11163
11065
|
_this$schema,
|
|
11164
|
-
_this$layout3
|
|
11165
|
-
_this = this;
|
|
11066
|
+
_this$layout3;
|
|
11166
11067
|
var schemaFormStyle = _objectSpread2({
|
|
11167
11068
|
position: 'relative',
|
|
11168
11069
|
border: this.border ? '1px solid #dcdee5' : 'none',
|
|
@@ -11175,7 +11076,10 @@ var FieldGroupWrap = Vue.extend({
|
|
|
11175
11076
|
var self = this;
|
|
11176
11077
|
var renderDelete = function renderDelete() {
|
|
11177
11078
|
return h('span', {
|
|
11178
|
-
class: ['bk-schema-form-group-delete'
|
|
11079
|
+
class: ['bk-schema-form-group-delete', {
|
|
11080
|
+
disabled: _this.disabled,
|
|
11081
|
+
readonly: _this.readonly
|
|
11082
|
+
}],
|
|
11179
11083
|
style: {
|
|
11180
11084
|
right: '10px',
|
|
11181
11085
|
top: '10px'
|
|
@@ -11202,7 +11106,14 @@ var FieldGroupWrap = Vue.extend({
|
|
|
11202
11106
|
}],
|
|
11203
11107
|
"style": schemaFormStyle
|
|
11204
11108
|
}, [title && this.showTitle ? h("span", {
|
|
11205
|
-
"
|
|
11109
|
+
"directives": [{
|
|
11110
|
+
name: "bk-tooltips",
|
|
11111
|
+
value: this.description
|
|
11112
|
+
}],
|
|
11113
|
+
"class": ['bk-schema-form-group-title', this.type, {
|
|
11114
|
+
'group-has-desc': !!this.description,
|
|
11115
|
+
'is-required': this.required
|
|
11116
|
+
}]
|
|
11206
11117
|
}, [title, hasError ? h("span", {
|
|
11207
11118
|
"class": "bk-schema-form-group__error-tips"
|
|
11208
11119
|
}, [h("span", {
|
|
@@ -11210,7 +11121,7 @@ var FieldGroupWrap = Vue.extend({
|
|
|
11210
11121
|
}, [groupErrorTipsContent])]) : null]) : null, h("div", {
|
|
11211
11122
|
"style": groupContentStyle,
|
|
11212
11123
|
"class": "bk-schema-form-group-content"
|
|
11213
|
-
}, [this.$slots.default]), this.removeable && renderDelete()]);
|
|
11124
|
+
}, [this.$slots.default]), this.removeable && !this.readonly && renderDelete()]);
|
|
11214
11125
|
}
|
|
11215
11126
|
});
|
|
11216
11127
|
|
|
@@ -11233,12 +11144,12 @@ var KeyValueArrayWidget = Vue.extend({
|
|
|
11233
11144
|
},
|
|
11234
11145
|
methods: {
|
|
11235
11146
|
handleAddItem: function handleAddItem() {
|
|
11236
|
-
if (this.disabled) return;
|
|
11147
|
+
if (this.disabled || this.readonly) return;
|
|
11237
11148
|
var data = Schema.getSchemaDefaultValue(this.schema.items);
|
|
11238
11149
|
this.$emit('input', [].concat(_toConsumableArray(this.value), [data]));
|
|
11239
11150
|
},
|
|
11240
11151
|
handleRemoveItem: function handleRemoveItem(index) {
|
|
11241
|
-
if (this.disabled) return;
|
|
11152
|
+
if (this.disabled || this.readonly) return;
|
|
11242
11153
|
var value = JSON.parse(JSON.stringify(this.value));
|
|
11243
11154
|
value.splice(index, 1);
|
|
11244
11155
|
this.$emit('input', value);
|
|
@@ -11261,7 +11172,7 @@ var KeyValueArrayWidget = Vue.extend({
|
|
|
11261
11172
|
_this$value2;
|
|
11262
11173
|
var labelBtnStyle = {
|
|
11263
11174
|
'font-size': '16px',
|
|
11264
|
-
color: '#979ba5',
|
|
11175
|
+
color: this.disabled ? '#c4c6cc' : '#979ba5',
|
|
11265
11176
|
cursor: this.disabled ? 'not-allowed' : 'pointer',
|
|
11266
11177
|
display: 'inline-block'
|
|
11267
11178
|
};
|
|
@@ -11440,10 +11351,7 @@ var CollapseGroupWidget = Vue.extend({
|
|
|
11440
11351
|
props: _objectSpread2(_objectSpread2({}, props), {}, {
|
|
11441
11352
|
type: {
|
|
11442
11353
|
type: String,
|
|
11443
|
-
default: 'default',
|
|
11444
|
-
validator: function validator(value) {
|
|
11445
|
-
return ['default', 'normal', 'card'].includes(value);
|
|
11446
|
-
}
|
|
11354
|
+
default: 'default' // 'default', 'normal', 'card'
|
|
11447
11355
|
},
|
|
11448
11356
|
showTitle: {
|
|
11449
11357
|
type: Boolean,
|
|
@@ -11462,6 +11370,10 @@ var CollapseGroupWidget = Vue.extend({
|
|
|
11462
11370
|
verifiable: {
|
|
11463
11371
|
type: Boolean,
|
|
11464
11372
|
default: false
|
|
11373
|
+
},
|
|
11374
|
+
collapseStyle: {
|
|
11375
|
+
type: String,
|
|
11376
|
+
default: 'normal' // normal: 修改后的样式参看BCS,default: 组件样式
|
|
11465
11377
|
}
|
|
11466
11378
|
}),
|
|
11467
11379
|
data: function data() {
|
|
@@ -11472,7 +11384,6 @@ var CollapseGroupWidget = Vue.extend({
|
|
|
11472
11384
|
render: function render(h) {
|
|
11473
11385
|
var _this$schema,
|
|
11474
11386
|
_this = this;
|
|
11475
|
-
var collapseStyle = {};
|
|
11476
11387
|
var collapseTitleStyle = {
|
|
11477
11388
|
background: '#f5f7fa',
|
|
11478
11389
|
'border-radius': '2px',
|
|
@@ -11505,9 +11416,9 @@ var CollapseGroupWidget = Vue.extend({
|
|
|
11505
11416
|
hideArrow: true,
|
|
11506
11417
|
name: key
|
|
11507
11418
|
},
|
|
11508
|
-
class: ['mb15']
|
|
11419
|
+
class: _this.collapseStyle === 'normal' ? ['mb15'] : []
|
|
11509
11420
|
}, [h('div', {
|
|
11510
|
-
style: collapseTitleStyle
|
|
11421
|
+
style: _this.collapseStyle === 'normal' ? collapseTitleStyle : {}
|
|
11511
11422
|
}, [h('i', {
|
|
11512
11423
|
class: ['bk-icon icon-down-shape mr5'],
|
|
11513
11424
|
style: _objectSpread2(_objectSpread2({}, collapseIconStyle), {}, {
|
|
@@ -11531,7 +11442,7 @@ var CollapseGroupWidget = Vue.extend({
|
|
|
11531
11442
|
return h(FieldGroupWrap, {
|
|
11532
11443
|
props: _objectSpread2({}, groupWrapProps)
|
|
11533
11444
|
}, [h(registry.getBaseWidget('collapse'), {
|
|
11534
|
-
|
|
11445
|
+
class: this.collapseStyle,
|
|
11535
11446
|
props: {
|
|
11536
11447
|
value: this.activeName
|
|
11537
11448
|
},
|
|
@@ -11640,6 +11551,114 @@ var InputWidget = Vue.extend({
|
|
|
11640
11551
|
}
|
|
11641
11552
|
});
|
|
11642
11553
|
|
|
11554
|
+
var UploadWidget = Vue.extend({
|
|
11555
|
+
name: 'UploadWidget',
|
|
11556
|
+
props: {
|
|
11557
|
+
value: {
|
|
11558
|
+
type: Array,
|
|
11559
|
+
default: function _default() {
|
|
11560
|
+
return [];
|
|
11561
|
+
}
|
|
11562
|
+
},
|
|
11563
|
+
isUploadSuccessed: {
|
|
11564
|
+
type: String
|
|
11565
|
+
},
|
|
11566
|
+
responseHandler: {
|
|
11567
|
+
type: String
|
|
11568
|
+
}
|
|
11569
|
+
},
|
|
11570
|
+
methods: {
|
|
11571
|
+
request: function request(options) {
|
|
11572
|
+
var _this = this;
|
|
11573
|
+
var xhr = new XMLHttpRequest();
|
|
11574
|
+
options.fileObj.xhr = xhr;
|
|
11575
|
+
var formData = new FormData();
|
|
11576
|
+
options.data.forEach(function (item) {
|
|
11577
|
+
formData.append(item.name, executeExpression(item.value, _this.$parent.$parent));
|
|
11578
|
+
});
|
|
11579
|
+
formData.append(options.fileName, options.fileObj.origin);
|
|
11580
|
+
xhr.onreadystatechange = function () {
|
|
11581
|
+
if (xhr.readyState === 4) {
|
|
11582
|
+
var reponseText = _this.parseResponse(xhr.responseText || xhr.response);
|
|
11583
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
11584
|
+
options.fileObj.progress = 100 + '%';
|
|
11585
|
+
options.fileObj.errorMsg = reponseText.message || '上传失败';
|
|
11586
|
+
options.onError(options.fileObj, options.fileList, xhr.response);
|
|
11587
|
+
} else {
|
|
11588
|
+
options.onSuccess(reponseText, options.fileObj);
|
|
11589
|
+
}
|
|
11590
|
+
options.onDone(options.fileObj);
|
|
11591
|
+
}
|
|
11592
|
+
};
|
|
11593
|
+
xhr.upload.addEventListener('progress', options.onProgress, false);
|
|
11594
|
+
xhr.withCredentials = options.withCredentials;
|
|
11595
|
+
xhr.open(options.method, options.url, true);
|
|
11596
|
+
if (options.header) {
|
|
11597
|
+
if (Array.isArray(options.header)) {
|
|
11598
|
+
options.header.forEach(function (head) {
|
|
11599
|
+
var headerKey = head.name;
|
|
11600
|
+
var headerVal = executeExpression(head.value, _this.$parent.$parent);
|
|
11601
|
+
xhr.setRequestHeader(headerKey, headerVal);
|
|
11602
|
+
});
|
|
11603
|
+
} else {
|
|
11604
|
+
var headerKey = options.header.name;
|
|
11605
|
+
var headerVal = executeExpression(options.header.value, this.$parent.$parent);
|
|
11606
|
+
xhr.setRequestHeader(headerKey, headerVal);
|
|
11607
|
+
}
|
|
11608
|
+
}
|
|
11609
|
+
xhr.send(formData);
|
|
11610
|
+
return {
|
|
11611
|
+
abort: function abort() {
|
|
11612
|
+
xhr.abort();
|
|
11613
|
+
}
|
|
11614
|
+
};
|
|
11615
|
+
},
|
|
11616
|
+
parseResponse: function parseResponse(response) {
|
|
11617
|
+
if (!response) {
|
|
11618
|
+
return response || {};
|
|
11619
|
+
}
|
|
11620
|
+
try {
|
|
11621
|
+
return JSON.parse(response);
|
|
11622
|
+
} catch (error) {
|
|
11623
|
+
return response || {};
|
|
11624
|
+
}
|
|
11625
|
+
},
|
|
11626
|
+
handleResCode: function handleResCode(res) {
|
|
11627
|
+
var successed = true;
|
|
11628
|
+
if (this.isUploadSuccessed) {
|
|
11629
|
+
successed = executeExpression(this.isUploadSuccessed, this.$parent.$parent, [], {
|
|
11630
|
+
response: res
|
|
11631
|
+
});
|
|
11632
|
+
}
|
|
11633
|
+
if (!successed) return;
|
|
11634
|
+
if (this.responseHandler) {
|
|
11635
|
+
var files = executeExpression(this.responseHandler, this.$parent.$parent, [], {
|
|
11636
|
+
response: res
|
|
11637
|
+
});
|
|
11638
|
+
this.$emit('input', files);
|
|
11639
|
+
}
|
|
11640
|
+
return true;
|
|
11641
|
+
},
|
|
11642
|
+
handleSuccess: function handleSuccess(file, fileList) {
|
|
11643
|
+
if (!this.responseHandler) {
|
|
11644
|
+
this.$emit('input', fileList);
|
|
11645
|
+
}
|
|
11646
|
+
}
|
|
11647
|
+
},
|
|
11648
|
+
render: function render(h) {
|
|
11649
|
+
return h(registry.getBaseWidget('upload'), {
|
|
11650
|
+
props: _objectSpread2({
|
|
11651
|
+
customRequest: this.request,
|
|
11652
|
+
files: this.value,
|
|
11653
|
+
handleResCode: this.handleResCode
|
|
11654
|
+
}, this.$attrs),
|
|
11655
|
+
on: {
|
|
11656
|
+
'on-success': this.handleSuccess
|
|
11657
|
+
}
|
|
11658
|
+
});
|
|
11659
|
+
}
|
|
11660
|
+
});
|
|
11661
|
+
|
|
11643
11662
|
function styleInject(css, ref) {
|
|
11644
11663
|
if ( ref === void 0 ) ref = {};
|
|
11645
11664
|
var insertAt = ref.insertAt;
|
|
@@ -11670,6 +11689,197 @@ function styleInject(css, ref) {
|
|
|
11670
11689
|
var css_248z = "";
|
|
11671
11690
|
styleInject(css_248z);
|
|
11672
11691
|
|
|
11692
|
+
var WidgetNode = /*#__PURE__*/function () {
|
|
11693
|
+
function WidgetNode(config) {
|
|
11694
|
+
_classCallCheck(this, WidgetNode);
|
|
11695
|
+
this.id = void 0;
|
|
11696
|
+
this.instance = void 0;
|
|
11697
|
+
this.parent = void 0;
|
|
11698
|
+
this.type = void 0;
|
|
11699
|
+
this.index = void 0;
|
|
11700
|
+
// todo
|
|
11701
|
+
this.children = void 0;
|
|
11702
|
+
var id = config.id,
|
|
11703
|
+
instance = config.instance,
|
|
11704
|
+
parent = config.parent,
|
|
11705
|
+
index = config.index,
|
|
11706
|
+
type = config.type,
|
|
11707
|
+
_config$children = config.children,
|
|
11708
|
+
children = _config$children === void 0 ? [] : _config$children;
|
|
11709
|
+
this.id = id;
|
|
11710
|
+
this.type = type;
|
|
11711
|
+
this.index = index;
|
|
11712
|
+
this.instance = instance;
|
|
11713
|
+
this.parent = parent;
|
|
11714
|
+
this.children = children;
|
|
11715
|
+
}
|
|
11716
|
+
// 当前node的值
|
|
11717
|
+
return _createClass(WidgetNode, [{
|
|
11718
|
+
key: "value",
|
|
11719
|
+
get: function get() {
|
|
11720
|
+
var _this$instance;
|
|
11721
|
+
return (_this$instance = this.instance) === null || _this$instance === void 0 ? void 0 : _this$instance.value;
|
|
11722
|
+
}
|
|
11723
|
+
// 是否含有可见子节点
|
|
11724
|
+
}, {
|
|
11725
|
+
key: "isChildrenVisible",
|
|
11726
|
+
get: function get() {
|
|
11727
|
+
if (this.type === 'node') {
|
|
11728
|
+
var _this$instance2;
|
|
11729
|
+
return (_this$instance2 = this.instance) === null || _this$instance2 === void 0 ? void 0 : _this$instance2.state.visible;
|
|
11730
|
+
}
|
|
11731
|
+
return this.children.some(function (child) {
|
|
11732
|
+
return child.isChildrenVisible;
|
|
11733
|
+
});
|
|
11734
|
+
}
|
|
11735
|
+
/**
|
|
11736
|
+
* 获取 parents
|
|
11737
|
+
*/
|
|
11738
|
+
}, {
|
|
11739
|
+
key: "parents",
|
|
11740
|
+
get: function get() {
|
|
11741
|
+
if (!this.parent) {
|
|
11742
|
+
return [];
|
|
11743
|
+
}
|
|
11744
|
+
return [].concat(_toConsumableArray(this.parent.parents), [this.parent]);
|
|
11745
|
+
}
|
|
11746
|
+
// 第一个子节点
|
|
11747
|
+
}, {
|
|
11748
|
+
key: "firstChild",
|
|
11749
|
+
get: function get() {
|
|
11750
|
+
return this.children[0] || null;
|
|
11751
|
+
}
|
|
11752
|
+
// 最后一个子节点
|
|
11753
|
+
}, {
|
|
11754
|
+
key: "lastChild",
|
|
11755
|
+
get: function get() {
|
|
11756
|
+
return this.children[this.children.length - 1] || null;
|
|
11757
|
+
}
|
|
11758
|
+
// 指定属性下的同胞节点
|
|
11759
|
+
}, {
|
|
11760
|
+
key: "getSibling",
|
|
11761
|
+
value: function getSibling(lastProp) {
|
|
11762
|
+
var _this$parent;
|
|
11763
|
+
var reg = new RegExp("".concat(Path.getPathLastProp(this.id) || '', "$"));
|
|
11764
|
+
var id = this.id.replace(reg, lastProp);
|
|
11765
|
+
return (_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.children.find(function (node) {
|
|
11766
|
+
return node.id === id;
|
|
11767
|
+
});
|
|
11768
|
+
}
|
|
11769
|
+
// 获取所以同胞节点(不含自己)
|
|
11770
|
+
}, {
|
|
11771
|
+
key: "getSiblings",
|
|
11772
|
+
value: function getSiblings() {
|
|
11773
|
+
var _this$parent2,
|
|
11774
|
+
_this = this;
|
|
11775
|
+
return ((_this$parent2 = this.parent) === null || _this$parent2 === void 0 ? void 0 : _this$parent2.children.filter(function (node) {
|
|
11776
|
+
return node.instance !== _this.instance;
|
|
11777
|
+
})) || [];
|
|
11778
|
+
}
|
|
11779
|
+
/**
|
|
11780
|
+
* 是否是叶子节点
|
|
11781
|
+
*/
|
|
11782
|
+
}, {
|
|
11783
|
+
key: "isLeaf",
|
|
11784
|
+
get: function get() {
|
|
11785
|
+
return !this.children.length;
|
|
11786
|
+
}
|
|
11787
|
+
}, {
|
|
11788
|
+
key: "appendChild",
|
|
11789
|
+
value: function appendChild(node) {
|
|
11790
|
+
var _this$children;
|
|
11791
|
+
var nodes = Array.isArray(node) ? node : [node];
|
|
11792
|
+
var offset = node.index !== undefined ? node.index : this.children.length;
|
|
11793
|
+
(_this$children = this.children).splice.apply(_this$children, [offset, 0].concat(_toConsumableArray(nodes)));
|
|
11794
|
+
this.children.slice(offset).forEach(function (node, index) {
|
|
11795
|
+
node.index = offset + index;
|
|
11796
|
+
});
|
|
11797
|
+
return nodes;
|
|
11798
|
+
}
|
|
11799
|
+
}, {
|
|
11800
|
+
key: "removeChild",
|
|
11801
|
+
value: function removeChild(node) {
|
|
11802
|
+
var _this2 = this;
|
|
11803
|
+
var nodes = Array.isArray(node) ? node : [node];
|
|
11804
|
+
var removedChildIndex = [];
|
|
11805
|
+
nodes.forEach(function (node) {
|
|
11806
|
+
var index = node.index;
|
|
11807
|
+
removedChildIndex.push(index);
|
|
11808
|
+
_this2.children.splice(index, 1);
|
|
11809
|
+
});
|
|
11810
|
+
var minIndex = Math.min.apply(Math, removedChildIndex);
|
|
11811
|
+
this.children.slice(minIndex).forEach(function (node, index) {
|
|
11812
|
+
node.index = minIndex + index;
|
|
11813
|
+
});
|
|
11814
|
+
return nodes;
|
|
11815
|
+
}
|
|
11816
|
+
}]);
|
|
11817
|
+
}();
|
|
11818
|
+
var WidgetTree = /*#__PURE__*/function () {
|
|
11819
|
+
function WidgetTree() {
|
|
11820
|
+
_classCallCheck(this, WidgetTree);
|
|
11821
|
+
this.widgetMap = {};
|
|
11822
|
+
}
|
|
11823
|
+
return _createClass(WidgetTree, [{
|
|
11824
|
+
key: "addWidgetNode",
|
|
11825
|
+
value: function addWidgetNode(path, instance, type, index) {
|
|
11826
|
+
if (path === '') {
|
|
11827
|
+
// 根节点
|
|
11828
|
+
var node = new WidgetNode({
|
|
11829
|
+
id: '',
|
|
11830
|
+
type: type,
|
|
11831
|
+
index: index,
|
|
11832
|
+
parent: null,
|
|
11833
|
+
instance: instance,
|
|
11834
|
+
children: []
|
|
11835
|
+
});
|
|
11836
|
+
this.widgetMap[path] = node;
|
|
11837
|
+
} else {
|
|
11838
|
+
// 普通节点
|
|
11839
|
+
var parentId = Path.getParentPath(path);
|
|
11840
|
+
var parentNode = this.widgetMap[parentId];
|
|
11841
|
+
var _node = new WidgetNode({
|
|
11842
|
+
id: (instance === null || instance === void 0 ? void 0 : instance.path) || path,
|
|
11843
|
+
type: type,
|
|
11844
|
+
index: index,
|
|
11845
|
+
parent: parentNode,
|
|
11846
|
+
instance: instance,
|
|
11847
|
+
children: []
|
|
11848
|
+
});
|
|
11849
|
+
if (!parentNode) {
|
|
11850
|
+
console.warn('Unexpected parent id, please check widget node', _node);
|
|
11851
|
+
} else {
|
|
11852
|
+
parentNode.appendChild(_node);
|
|
11853
|
+
}
|
|
11854
|
+
this.widgetMap[path] = _node;
|
|
11855
|
+
}
|
|
11856
|
+
}
|
|
11857
|
+
}, {
|
|
11858
|
+
key: "removeWidgetNode",
|
|
11859
|
+
value: function removeWidgetNode(path, instance) {
|
|
11860
|
+
var node = this.widgetMap[path];
|
|
11861
|
+
if (node) {
|
|
11862
|
+
if (node.parent) {
|
|
11863
|
+
var children = node.parent.children;
|
|
11864
|
+
var index = children.findIndex(function (item) {
|
|
11865
|
+
return item.instance === instance;
|
|
11866
|
+
});
|
|
11867
|
+
if (index > -1) {
|
|
11868
|
+
children.splice(index, 1);
|
|
11869
|
+
children.slice(index).forEach(function (node, i) {
|
|
11870
|
+
node.index = index + i;
|
|
11871
|
+
});
|
|
11872
|
+
}
|
|
11873
|
+
}
|
|
11874
|
+
if (node.instance === instance) {
|
|
11875
|
+
delete this.widgetMap[path];
|
|
11876
|
+
}
|
|
11877
|
+
}
|
|
11878
|
+
}
|
|
11879
|
+
}]);
|
|
11880
|
+
}();
|
|
11881
|
+
// export default new WidgetTree();
|
|
11882
|
+
|
|
11673
11883
|
var defaultOptions = {
|
|
11674
11884
|
namespace: 'bk',
|
|
11675
11885
|
components: {
|
|
@@ -11685,7 +11895,8 @@ var defaultOptions = {
|
|
|
11685
11895
|
switcher: SwitcherWidget,
|
|
11686
11896
|
color: ColorWidget,
|
|
11687
11897
|
bfInput: InputWidget,
|
|
11688
|
-
input: 'bk-input'
|
|
11898
|
+
input: 'bk-input',
|
|
11899
|
+
bfUpload: UploadWidget
|
|
11689
11900
|
},
|
|
11690
11901
|
fields: {
|
|
11691
11902
|
object: ObjectField,
|
|
@@ -11717,7 +11928,8 @@ function createForm() {
|
|
|
11717
11928
|
data: function data() {
|
|
11718
11929
|
return {
|
|
11719
11930
|
rootData: {},
|
|
11720
|
-
formKey: 'bk-ui-form'
|
|
11931
|
+
formKey: 'bk-ui-form',
|
|
11932
|
+
widgetTree: new WidgetTree()
|
|
11721
11933
|
};
|
|
11722
11934
|
},
|
|
11723
11935
|
watch: {
|
|
@@ -11742,8 +11954,11 @@ function createForm() {
|
|
|
11742
11954
|
registryGlobalRules(value);
|
|
11743
11955
|
}
|
|
11744
11956
|
},
|
|
11745
|
-
value:
|
|
11746
|
-
|
|
11957
|
+
value: {
|
|
11958
|
+
handler: function handler() {
|
|
11959
|
+
this.initFormData();
|
|
11960
|
+
},
|
|
11961
|
+
deep: true
|
|
11747
11962
|
}
|
|
11748
11963
|
},
|
|
11749
11964
|
beforeCreate: function beforeCreate() {
|
|
@@ -11765,9 +11980,15 @@ function createForm() {
|
|
|
11765
11980
|
this.$emit('change', newValue, oldValue);
|
|
11766
11981
|
}
|
|
11767
11982
|
},
|
|
11768
|
-
validateForm: validateForm
|
|
11769
|
-
|
|
11770
|
-
|
|
11983
|
+
validateForm: function validateForm$1() {
|
|
11984
|
+
return validateForm(this.widgetTree);
|
|
11985
|
+
},
|
|
11986
|
+
validateFormItem: function validateFormItem$1(path) {
|
|
11987
|
+
return validateFormItem(path, this.widgetTree);
|
|
11988
|
+
},
|
|
11989
|
+
validate: function validate() {
|
|
11990
|
+
return validateFormWithResult(this.widgetTree);
|
|
11991
|
+
},
|
|
11771
11992
|
validateSchema: validateSchema
|
|
11772
11993
|
},
|
|
11773
11994
|
render: function render(h) {
|
|
@@ -11810,6 +12031,11 @@ function createForm() {
|
|
|
11810
12031
|
}
|
|
11811
12032
|
}
|
|
11812
12033
|
})]);
|
|
12034
|
+
},
|
|
12035
|
+
provide: function provide() {
|
|
12036
|
+
return {
|
|
12037
|
+
widgetTree: this.widgetTree
|
|
12038
|
+
};
|
|
11813
12039
|
}
|
|
11814
12040
|
});
|
|
11815
12041
|
}
|