easy3wui 1.5.85-beta.2 → 1.5.85-beta.3

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.
@@ -62,6 +62,7 @@ var TreeNode = _tree2['default'].TreeNode;
62
62
  * onSearchCallback: 搜索回调函数 非必须 Function 返回值:(arrDataVisible, searchValue, expandedKeys)
63
63
  * bidPureComponent: 绑定组件方法 非必须 Function
64
64
  * intUpdateCount: 数据更新次数 必须 Number
65
+ * selectedKeys: 选中节点key 非必须 Array
65
66
  */
66
67
 
67
68
  var Easy3wTree = function (_Component) {
@@ -83,10 +84,8 @@ var Easy3wTree = function (_Component) {
83
84
  var arrDefaultExpandedKeys = _this.touchGetDEK(arrData);
84
85
  _this.searchRef = _react2['default'].createRef();
85
86
  _this.state = {
86
- // 两数量值,用于彻底更新树,树数据更新,重新渲染,使defaultExpandedKeys生效
87
- treevisible: true, // 显示树
88
- arrDefaultExpandedKeys: arrDefaultExpandedKeys, // 树默认展开节点
89
- arrSearchExpandedKeys: [], // 查询时,树默认展开节点
87
+ // 两数量值,用于彻底更新树,树数据更新
88
+ expandedKeys: arrDefaultExpandedKeys, // 展开的节点
90
89
  arrDataVisible: arrData || [], // 树数据源-显示数据
91
90
  selectedKeys: [] // 选中节点key
92
91
  };
@@ -106,7 +105,9 @@ var Easy3wTree = function (_Component) {
106
105
  // 递归过滤树结构,并设置展开节点的 keys
107
106
 
108
107
  // #endregion
109
- // 节点点击事件
108
+ // 节点点击事件--选择
109
+
110
+ // 节点点击事件--展开
110
111
 
111
112
  // 处理树组织
112
113
 
@@ -117,9 +118,7 @@ var Easy3wTree = function (_Component) {
117
118
  var _state = this.state,
118
119
  arrDataVisible = _state.arrDataVisible,
119
120
  selectedKeys = _state.selectedKeys,
120
- treevisible = _state.treevisible,
121
- arrDefaultExpandedKeys = _state.arrDefaultExpandedKeys,
122
- arrSearchExpandedKeys = _state.arrSearchExpandedKeys;
121
+ expandedKeys = _state.expandedKeys;
123
122
  var _props = this.props,
124
123
  objTreeProps = _props.objTreeProps,
125
124
  objSearchProps = _props.objSearchProps,
@@ -144,18 +143,21 @@ var Easy3wTree = function (_Component) {
144
143
  spinLoading: !(arrData && arrData.length),
145
144
  noStyle: true
146
145
  },
147
- treevisible ? _react2['default'].createElement(
146
+ _react2['default'].createElement(
148
147
  _tree2['default'],
149
148
  (0, _extends3['default'])({
150
- defaultExpandedKeys: arrSearchExpandedKeys && arrSearchExpandedKeys.length > 0 ? arrSearchExpandedKeys : arrDefaultExpandedKeys // 树默认展开节点key Array
151
- , selectedKeys: selectedKeys // 选中节点key Array
149
+ expandedKeys: expandedKeys,
150
+ selectedKeys: selectedKeys // 选中节点key Array
152
151
  , showLine: true,
153
152
  showIcon: true
154
153
  // multiple 多选
155
- , onSelect: this.touchSelect
154
+ , onSelect: this.touchSelect,
155
+ onExpand: function onExpand(keys) {
156
+ return _this2.tuochExpand(keys);
157
+ } // 更新展开的keys
156
158
  }, objTreeProps),
157
159
  this.touchRenderTreeNodes(arrDataVisible)
158
- ) : ''
160
+ )
159
161
  )
160
162
  );
161
163
  };
@@ -171,29 +173,26 @@ Easy3wTree.defaultProps = {
171
173
  },
172
174
  objSearchProps: {
173
175
  searchFlag: true
174
- }
176
+ },
177
+ selectedKeys: []
175
178
  };
176
179
 
177
180
  var _initialiseProps = function _initialiseProps() {
178
181
  var _this3 = this;
179
182
 
180
183
  this.componentDidUpdate = function (prevProps) {
181
- var arrDefaultExpandedKeys = _this3.state.arrDefaultExpandedKeys;
182
184
  var _props2 = _this3.props,
183
185
  intUpdateCount = _props2.intUpdateCount,
184
186
  arrData = _props2.arrData;
185
187
 
186
188
  if (intUpdateCount !== prevProps.intUpdateCount) {
187
- var arrDEKeys = _this3.touchGetDEK(arrData);
189
+ var expandedKeys = _this3.state.expandedKeys;
190
+
191
+ var arrDefaultExpandedKeys = _this3.touchGetDEK(arrData);
188
192
  // eslint-disable-next-line react/no-did-update-set-state
189
193
  _this3.setState({
190
194
  arrDataVisible: arrData || [], // 树数据源-显示数据
191
- arrDefaultExpandedKeys: arrDefaultExpandedKeys && arrDefaultExpandedKeys.length ? arrDefaultExpandedKeys : arrDEKeys, // 树默认展开节点
192
- treevisible: false // 隐藏树
193
- }, function () {
194
- _this3.setState({
195
- treevisible: true // 显示树
196
- });
195
+ expandedKeys: expandedKeys && expandedKeys.length ? expandedKeys : arrDefaultExpandedKeys // 展开的节点
197
196
  });
198
197
  }
199
198
  };
@@ -203,7 +202,8 @@ var _initialiseProps = function _initialiseProps() {
203
202
  if (arrData && arrData.length > 0) {
204
203
  var item = arrData[0];
205
204
  var objTreeProps = _this3.props.objTreeProps;
206
- var keyField = objTreeProps.keyField;
205
+ var _objTreeProps$keyFiel = objTreeProps.keyField,
206
+ keyField = _objTreeProps$keyFiel === undefined ? 'key' : _objTreeProps$keyFiel;
207
207
 
208
208
  arrDefaultExpandedKeys = item[keyField] ? [item[keyField]] : [];
209
209
  }
@@ -250,27 +250,23 @@ var _initialiseProps = function _initialiseProps() {
250
250
  }
251
251
  _this3.setState({
252
252
  arrDataVisible: arrDataVisible, // 树数据源-显示数据
253
- arrSearchExpandedKeys: arrSearchExpandedKeys, // 查询时,树默认展开节点
254
- treevisible: false // 隐藏树
255
- }, function () {
256
- _this3.setState({
257
- treevisible: true // 显示树
258
- });
253
+ expandedKeys: arrSearchExpandedKeys // 查询时,树默认展开节点
259
254
  });
260
255
  };
261
256
 
262
- this.touchFilterTreeData = function (arrAllData, searchValue, expandedKeys) {
263
- var _props$objTreeProps = _this3.props.objTreeProps,
264
- objTreeProps = _props$objTreeProps === undefined ? {} : _props$objTreeProps;
265
- var titleField = objTreeProps.titleField,
266
- keyField = objTreeProps.keyField;
257
+ this.touchFilterTreeData = function (arrAllData, searchValue, searchExpandedKeys) {
258
+ var objTreeProps = _this3.props.objTreeProps;
259
+ var _objTreeProps$titleFi = objTreeProps.titleField,
260
+ titleField = _objTreeProps$titleFi === undefined ? 'title' : _objTreeProps$titleFi,
261
+ _objTreeProps$keyFiel2 = objTreeProps.keyField,
262
+ keyField = _objTreeProps$keyFiel2 === undefined ? 'key' : _objTreeProps$keyFiel2;
267
263
 
268
264
  var filteredData = arrAllData.map(function (item) {
269
265
  // 递归过滤子节点
270
- var children = item.children ? _this3.touchFilterTreeData(item.children, searchValue, expandedKeys) : [];
266
+ var children = item.children ? _this3.touchFilterTreeData(item.children, searchValue, searchExpandedKeys) : [];
271
267
  // 如果节点名字匹配,或者子节点匹配
272
268
  if (item[titleField].includes(searchValue) || children.length > 0) {
273
- expandedKeys.push(item[keyField]); // 记录展开的节点 key
269
+ searchExpandedKeys.push(item[keyField]); // 记录展开的节点 key
274
270
  return (0, _extends3['default'])({}, item, {
275
271
  children: children // 返回匹配的子节点
276
272
  });
@@ -283,8 +279,8 @@ var _initialiseProps = function _initialiseProps() {
283
279
  };
284
280
 
285
281
  this.touchSelect = function (selectedKeys, info) {
286
- var _props$objTreeProps2 = _this3.props.objTreeProps,
287
- objTreeProps = _props$objTreeProps2 === undefined ? {} : _props$objTreeProps2;
282
+ var _props$objTreeProps = _this3.props.objTreeProps,
283
+ objTreeProps = _props$objTreeProps === undefined ? {} : _props$objTreeProps;
288
284
  var onSelectCallback = objTreeProps.onSelectCallback;
289
285
 
290
286
  if (onSelectCallback && typeof onSelectCallback === 'function') {
@@ -295,13 +291,29 @@ var _initialiseProps = function _initialiseProps() {
295
291
  });
296
292
  };
297
293
 
294
+ this.tuochExpand = function (expandedKeys) {
295
+ var _props$objTreeProps2 = _this3.props.objTreeProps,
296
+ objTreeProps = _props$objTreeProps2 === undefined ? {} : _props$objTreeProps2;
297
+ var onExpandCallback = objTreeProps.onExpandCallback;
298
+
299
+ if (onExpandCallback && typeof onExpandCallback === 'function') {
300
+ onExpandCallback(expandedKeys);
301
+ }
302
+ _this3.setState({
303
+ expandedKeys: expandedKeys // 选中节点key Array
304
+ });
305
+ };
306
+
298
307
  this.touchRenderTreeNodes = function (arrDataVisible) {
299
308
  var _props$objTreeProps3 = _this3.props.objTreeProps,
300
309
  objTreeProps = _props$objTreeProps3 === undefined ? {} : _props$objTreeProps3;
301
310
  var touchRenderNode = objTreeProps.touchRenderNode,
302
- titleField = objTreeProps.titleField,
303
- countField = objTreeProps.countField,
304
- keyField = objTreeProps.keyField;
311
+ _objTreeProps$titleFi2 = objTreeProps.titleField,
312
+ titleField = _objTreeProps$titleFi2 === undefined ? 'title' : _objTreeProps$titleFi2,
313
+ _objTreeProps$countFi = objTreeProps.countField,
314
+ countField = _objTreeProps$countFi === undefined ? 'count' : _objTreeProps$countFi,
315
+ _objTreeProps$keyFiel3 = objTreeProps.keyField,
316
+ keyField = _objTreeProps$keyFiel3 === undefined ? 'key' : _objTreeProps$keyFiel3;
305
317
 
306
318
  return arrDataVisible.map(function (item) {
307
319
  var children = item.children;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy3wui",
3
- "version": "1.5.85-beta.2",
3
+ "version": "1.5.85-beta.3",
4
4
  "description": "easy3wui components for react",
5
5
  "keywords": [
6
6
  "react",