tntd 1.3.50 → 1.3.54

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.
Files changed (44) hide show
  1. package/components/Layout/Avatar.js +6 -3
  2. package/components/Layout/GlobalNavigation/NavigationPopup.js +6 -4
  3. package/components/Layout/GlobalNavigation/index.js +2 -1
  4. package/components/Layout/HeaderActions.js +1 -0
  5. package/components/Layout/README.md +2 -1
  6. package/components/Layout/createActions.js +10 -2
  7. package/components/Layout/index.js +10 -1
  8. package/components/Layout/utils.js +2 -2
  9. package/components/Page/Box.js +3 -3
  10. package/components/Page/README.md +17 -5
  11. package/components/Page/index.js +3 -3
  12. package/components/Page/index.less +31 -7
  13. package/components/QueryForm/index.js +12 -8
  14. package/components/QueryListScene/List.js +2 -1
  15. package/components/locale.js +60 -0
  16. package/lib/BlockHeader/README.md +83 -0
  17. package/lib/BlockHeader/fonts/OswaldLight.ttf +0 -0
  18. package/lib/BlockHeader/index.js +42 -0
  19. package/lib/BlockHeader/index.less +141 -0
  20. package/lib/Layout/Avatar.js +11 -3
  21. package/lib/Layout/GlobalNavigation/NavigationPopup.js +7 -4
  22. package/lib/Layout/GlobalNavigation/index.js +2 -1
  23. package/lib/Layout/README.md +2 -1
  24. package/lib/Layout/createActions.js +14 -1
  25. package/lib/Layout/index.js +19 -5
  26. package/lib/Layout/paaslayout/index.less +75 -0
  27. package/lib/Layout/utils.js +2 -2
  28. package/lib/Page/Box.js +4 -3
  29. package/lib/Page/README.md +17 -5
  30. package/lib/Page/demo.js +302 -0
  31. package/lib/Page/index.js +3 -3
  32. package/lib/Page/index.less +31 -7
  33. package/lib/QueryForm/index.js +14 -11
  34. package/lib/QueryListScene/Field/SelectInput.js +107 -0
  35. package/lib/QueryListScene/Field/fieldsMap.js +37 -0
  36. package/lib/QueryListScene/Field/index.js +75 -0
  37. package/lib/QueryListScene/Field/select.js +100 -0
  38. package/lib/QueryListScene/List.js +3 -1
  39. package/lib/QueryListScene/QueryForm/index.js +419 -0
  40. package/lib/QueryListScene/QueryForm/index.less +127 -0
  41. package/lib/locale.js +75 -0
  42. package/package.json +1 -1
  43. package/lib/Layout/EnterpriseLayout/Header.js +0 -113
  44. package/lib/Layout/EnterpriseLayout/HeaderActions.js +0 -104
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ require("antd/lib/select/style");
11
+
12
+ var _select = _interopRequireDefault(require("antd/lib/select"));
13
+
14
+ var _react = _interopRequireWildcard(require("react"));
15
+
16
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
17
+
18
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
+
22
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
23
+
24
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
25
+
26
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
27
+
28
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
29
+
30
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
31
+
32
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
33
+
34
+ function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
35
+
36
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
37
+
38
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
39
+
40
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
41
+
42
+ var Option = _select["default"].Option;
43
+
44
+ var _default = function _default(props) {
45
+ var options = props.options,
46
+ params = props.params,
47
+ _props$queryKey = props.queryKey,
48
+ queryKey = _props$queryKey === void 0 ? 'name' : _props$queryKey,
49
+ _props$fieldNames = props.fieldNames,
50
+ fieldNames = _props$fieldNames === void 0 ? {
51
+ label: 'label',
52
+ value: 'value'
53
+ } : _props$fieldNames,
54
+ loadData = props.loadData,
55
+ rest = _objectWithoutProperties(props, ["options", "params", "queryKey", "fieldNames", "loadData"]);
56
+
57
+ var _useState = (0, _react.useState)(options || []),
58
+ _useState2 = _slicedToArray(_useState, 2),
59
+ items = _useState2[0],
60
+ setItems = _useState2[1];
61
+
62
+ var _useState3 = (0, _react.useState)(''),
63
+ _useState4 = _slicedToArray(_useState3, 2),
64
+ query = _useState4[0],
65
+ setQuery = _useState4[1];
66
+
67
+ var onSearch = function onSearch(val) {
68
+ setQuery(val);
69
+ };
70
+
71
+ if (loadData) {
72
+ (0, _react.useEffect)(function () {
73
+ loadData(_objectSpread(_defineProperty({}, queryKey, query), params || {})).then(function (items) {
74
+ setItems(items);
75
+ });
76
+ }, [params, query]);
77
+ }
78
+
79
+ (0, _react.useEffect)(function () {
80
+ setItems(options || []);
81
+ }, [options]);
82
+ return _react["default"].createElement(_select["default"], _extends({
83
+ allowClear: true,
84
+ showSearch: true,
85
+ optionFilterProp: "children",
86
+ onSearch: onSearch
87
+ }, rest), items.map(function (item) {
88
+ var labelKey = (fieldNames == null ? void 0 : fieldNames.label) || 'label';
89
+ var valueKey = (fieldNames == null ? void 0 : fieldNames.value) || 'value';
90
+ var value = item instanceof Object ? item[valueKey] : item;
91
+ var label = item instanceof Object ? item[labelKey] : item;
92
+ var optionProps = item instanceof Object ? item : {};
93
+ return _react["default"].createElement(Option, _extends({}, optionProps, {
94
+ key: value,
95
+ value: value
96
+ }), label);
97
+ }));
98
+ };
99
+
100
+ exports["default"] = _default;
@@ -19,6 +19,8 @@ var _lodash = require("lodash");
19
19
 
20
20
  var _Table = _interopRequireDefault(require("../Table"));
21
21
 
22
+ var _locale = require("../locale");
23
+
22
24
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
23
25
 
24
26
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -289,7 +291,7 @@ function (_React$PureComponent) {
289
291
  showQuickJumper: true,
290
292
  showSizeChanger: true,
291
293
  showTotal: function showTotal(total) {
292
- return "\u5171".concat(total, "\u6761\u8BB0\u5F55");
294
+ return (0, _locale.getText)('totalRecords', (0, _locale.getLanguage)(), total);
293
295
  }
294
296
  }, pagination || {});
295
297
 
@@ -0,0 +1,419 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ require("antd/lib/drawer/style");
9
+
10
+ var _drawer = _interopRequireDefault(require("antd/lib/drawer"));
11
+
12
+ require("antd/lib/badge/style");
13
+
14
+ var _badge = _interopRequireDefault(require("antd/lib/badge"));
15
+
16
+ require("antd/lib/button/style");
17
+
18
+ var _button = _interopRequireDefault(require("antd/lib/button"));
19
+
20
+ require("antd/lib/form/style");
21
+
22
+ var _form = _interopRequireDefault(require("antd/lib/form"));
23
+
24
+ var _react = _interopRequireWildcard(require("react"));
25
+
26
+ var _classnames3 = _interopRequireDefault(require("classnames"));
27
+
28
+ var _lodash = require("lodash");
29
+
30
+ require("./index.less");
31
+
32
+ var _dec, _class, _temp;
33
+
34
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
35
+
36
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
37
+
38
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
39
+
40
+ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
41
+
42
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
43
+
44
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
45
+
46
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
47
+
48
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
49
+
50
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
51
+
52
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
53
+
54
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
55
+
56
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
57
+
58
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
59
+
60
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
61
+
62
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
63
+
64
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
65
+
66
+ var clsPrefix = "tnt-querylistscene-queryform";
67
+ var QueryForm = (_dec = _form["default"].create(), _dec(_class = (_temp =
68
+ /*#__PURE__*/
69
+ function (_React$Component) {
70
+ _inherits(QueryForm, _React$Component);
71
+
72
+ function QueryForm(props) {
73
+ var _this;
74
+
75
+ _classCallCheck(this, QueryForm);
76
+
77
+ _this = _possibleConstructorReturn(this, _getPrototypeOf(QueryForm).call(this, props));
78
+ _this.onWindowResize = (0, _lodash.debounce)(function () {
79
+ var current = _this.fieldsRef.current;
80
+
81
+ if (current) {
82
+ setTimeout(function () {
83
+ _this.setState({
84
+ showMore: _this.isFieldsWidthOverflow()
85
+ });
86
+ }, 25);
87
+ }
88
+ }, 50);
89
+
90
+ _this.onSubmit = function () {
91
+ var _this$props = _this.props,
92
+ form = _this$props.form,
93
+ onSubmit = _this$props.onSubmit,
94
+ actions = _this$props.actions;
95
+ var values = form.getFieldsValue();
96
+
97
+ var params = _objectSpread({}, values, {
98
+ current: 1
99
+ });
100
+
101
+ actions.setData('formData', values);
102
+ onSubmit && onSubmit(params);
103
+ actions.emit('search', params);
104
+ };
105
+
106
+ _this.onReset = function () {
107
+ var _this$props2 = _this.props,
108
+ form = _this$props2.form,
109
+ onReset = _this$props2.onReset;
110
+ form.resetFields();
111
+ var values = form.getFieldsValue();
112
+ onReset && onReset(values);
113
+
114
+ _this.updateDrawerFieldsValueCount(values);
115
+
116
+ _this.onSubmit();
117
+ };
118
+
119
+ _this.onToggleExpand = function () {
120
+ _this.setState({
121
+ expanded: !_this.state.expanded
122
+ });
123
+ };
124
+
125
+ _this.onShowDrawer = function () {
126
+ _this.setState({
127
+ drawerVisible: true
128
+ });
129
+ };
130
+
131
+ _this.onFieldChange = function (name, value) {
132
+ var _this$props3 = _this.props,
133
+ form = _this$props3.form,
134
+ onChange = _this$props3.onChange,
135
+ actions = _this$props3.actions;
136
+ var values = form.getFieldsValue();
137
+
138
+ var newValues = _objectSpread({}, values, _defineProperty({}, name, value));
139
+
140
+ var changedInfo = {
141
+ name: name,
142
+ value: value,
143
+ preValue: values[name]
144
+ };
145
+
146
+ for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
147
+ rest[_key - 2] = arguments[_key];
148
+ }
149
+
150
+ onChange && onChange.apply(void 0, [newValues, changedInfo].concat(rest));
151
+ actions.setData('formData', newValues);
152
+ actions.emit('formChange', newValues, changedInfo);
153
+
154
+ _this.updateDrawerFieldsValueCount(newValues);
155
+ };
156
+
157
+ _this.updateDrawerFieldsValueCount = function (values) {
158
+ var _this$props4 = _this.props,
159
+ form = _this$props4.form,
160
+ showFieldCount = _this$props4.showFieldCount,
161
+ children = _this$props4.children;
162
+
163
+ if (showFieldCount) {
164
+ values = values || form.getFieldsValue();
165
+
166
+ _this.setState({
167
+ drawerFieldsValueCount: children.reduce(function (acc, cur, index) {
168
+ if (index >= showFieldCount && values[(0, _lodash.get)(cur, 'props.name')]) {
169
+ acc++;
170
+ }
171
+
172
+ return acc;
173
+ }, 0)
174
+ });
175
+ }
176
+ };
177
+
178
+ _this.setFormData = function (data, needSearch) {
179
+ var _this$props5 = _this.props,
180
+ form = _this$props5.form,
181
+ actions = _this$props5.actions;
182
+ form.setFieldsValue(data);
183
+ actions.setData('formData', data);
184
+ needSearch && _this.onSubmit();
185
+ };
186
+
187
+ _this.resetFormData = function (needSearch) {
188
+ var _this$props6 = _this.props,
189
+ form = _this$props6.form,
190
+ actions = _this$props6.actions;
191
+ form.resetFieldsValue();
192
+ actions.setData('formData', data);
193
+ needSearch && _this.onSubmit();
194
+ };
195
+
196
+ var _props$showExpand = props.showExpand,
197
+ showExpand = _props$showExpand === void 0 ? true : _props$showExpand,
198
+ renderActions = props.renderActions;
199
+ _this.state = {
200
+ showMore: false,
201
+ expanded: !showExpand || renderActions ? true : false,
202
+ drawerVisible: false,
203
+ drawerFieldsValueCount: 0
204
+ };
205
+ _this.fieldsRef = (0, _react.createRef)();
206
+ _this.formBoxRef = (0, _react.createRef)();
207
+ props.actions.on('setFormData', _this.setFormData);
208
+ props.actions.on('resetFormData', _this.resetFormData);
209
+ props.actions.on('fieldChange', _this.onFieldChange);
210
+ return _this;
211
+ }
212
+
213
+ _createClass(QueryForm, [{
214
+ key: "render",
215
+ value: function render() {
216
+ var _this2 = this;
217
+
218
+ var _this$props7 = this.props,
219
+ title = _this$props7.title,
220
+ children = _this$props7.children,
221
+ _this$props7$classNam = _this$props7.className,
222
+ className = _this$props7$classNam === void 0 ? '' : _this$props7$classNam,
223
+ form = _this$props7.form,
224
+ actions = _this$props7.actions,
225
+ _this$props7$initialV = _this$props7.initialValues,
226
+ initialValues = _this$props7$initialV === void 0 ? {} : _this$props7$initialV,
227
+ renderActions = _this$props7.renderActions,
228
+ _this$props7$showSear = _this$props7.showSearch,
229
+ showSearch = _this$props7$showSear === void 0 ? true : _this$props7$showSear,
230
+ _this$props7$showRese = _this$props7.showReset,
231
+ showReset = _this$props7$showRese === void 0 ? true : _this$props7$showRese,
232
+ showFieldCount = _this$props7.showFieldCount,
233
+ _this$props7$drawerPr = _this$props7.drawerProps,
234
+ drawerProps = _this$props7$drawerPr === void 0 ? {} : _this$props7$drawerPr,
235
+ size = _this$props7.size; // 前期拼写错误,导致需要兼容错误的api
236
+
237
+ var extraActions = this.props.extraActions || this.props.extralActions;
238
+ var _this$state = this.state,
239
+ expanded = _this$state.expanded,
240
+ showMore = _this$state.showMore,
241
+ drawerVisible = _this$state.drawerVisible,
242
+ drawerFieldsValueCount = _this$state.drawerFieldsValueCount;
243
+
244
+ var renderFormActions = renderActions || function () {
245
+ return _react["default"].createElement(_react.Fragment, null, showSearch && _react["default"].createElement(_button["default"], {
246
+ type: "primary",
247
+ onClick: _this2.onSubmit
248
+ }, "\u641C\u7D22"), showReset && _react["default"].createElement(_button["default"], {
249
+ onClick: _this2.onReset
250
+ }, "\u91CD\u7F6E"), showMore && !showFieldCount && _react["default"].createElement(_button["default"], {
251
+ className: "expand-link",
252
+ type: "link",
253
+ onClick: _this2.onToggleExpand
254
+ }, expanded ? '收起' : '展开'), showFieldCount && _react["default"].createElement(_badge["default"], {
255
+ count: drawerFieldsValueCount
256
+ }, _react["default"].createElement(_button["default"], {
257
+ icon: "filter",
258
+ onClick: _this2.onShowDrawer
259
+ }, "\u66F4\u591A\u8FC7\u6EE4")), _react["default"].Children.map(children, function (child) {
260
+ return child && (0, _lodash.get)(child, 'props.align') === 'right' && _react["default"].cloneElement(child, {
261
+ form: form
262
+ });
263
+ }));
264
+ };
265
+
266
+ return _react["default"].createElement("div", {
267
+ ref: this.formBoxRef,
268
+ className: (0, _classnames3["default"])(clsPrefix, _defineProperty({}, className, className))
269
+ }, title && _react["default"].createElement("span", {
270
+ className: "".concat(clsPrefix, "-title")
271
+ }, title), _react["default"].createElement(_form["default"], {
272
+ layout: "inline",
273
+ className: (0, _classnames3["default"])({
274
+ expanded: !showMore || expanded,
275
+ showMore: showMore
276
+ })
277
+ }, _react["default"].createElement("div", {
278
+ ref: this.fieldsRef
279
+ }, _react["default"].Children.map(children, function (child, index) {
280
+ return child && (0, _lodash.get)(child, 'props.align') !== 'right' && (!showFieldCount || showFieldCount > index) && _react["default"].cloneElement(child, {
281
+ form: form,
282
+ actions: actions,
283
+ initialValue: initialValues[child.props.name]
284
+ });
285
+ })), _react["default"].createElement("div", {
286
+ className: "query-form-actions"
287
+ }, renderFormActions()), showFieldCount && _react["default"].createElement(_drawer["default"], _extends({
288
+ title: "\u66F4\u591A\u8FC7\u6EE4",
289
+ visible: drawerVisible,
290
+ onClose: function onClose() {
291
+ return _this2.setState({
292
+ drawerVisible: false
293
+ });
294
+ },
295
+ width: 300,
296
+ size: size,
297
+ getContainer: false
298
+ }, drawerProps, {
299
+ className: (0, _classnames3["default"])("".concat(clsPrefix, "-drawer"), _defineProperty({
300
+ 'large-size': size === 'large'
301
+ }, className, className))
302
+ }), _react["default"].Children.map(children, function (child, index) {
303
+ return child && index >= showFieldCount && _react["default"].cloneElement(child, {
304
+ form: form,
305
+ actions: actions,
306
+ initialValue: initialValues[child.props.name]
307
+ });
308
+ }), _react["default"].createElement(_button["default"], {
309
+ type: "primary",
310
+ onClick: this.onSubmit
311
+ }, "\u641C\u7D22"), _react["default"].createElement(_button["default"], {
312
+ onClick: this.onReset
313
+ }, "\u6E05\u7A7A"))), extraActions && _react["default"].createElement("div", {
314
+ className: "".concat(clsPrefix, "-extra")
315
+ }, extraActions));
316
+ }
317
+ }, {
318
+ key: "isFieldsWidthOverflow",
319
+ value: function isFieldsWidthOverflow() {
320
+ var current = this.fieldsRef.current;
321
+
322
+ if (current) {
323
+ return current.offsetWidth < [].reduce.call(current.children, function (acc, cur) {
324
+ var marginArray = window.getComputedStyle(cur).margin.split(' ').map(function (str) {
325
+ return parseInt(str, 10);
326
+ });
327
+ acc += cur.offsetWidth + marginArray[1];
328
+ return acc;
329
+ }, 0);
330
+ }
331
+
332
+ return false;
333
+ }
334
+ }, {
335
+ key: "updateFieldHeight",
336
+ value: function updateFieldHeight() {
337
+ var _formBoxRef$current, _formBoxRef$current2, _fieldsRef$current;
338
+
339
+ var formBoxRef = this.formBoxRef,
340
+ fieldsRef = this.fieldsRef;
341
+
342
+ var getFieldHeight = function getFieldHeight() {
343
+ var _current$children;
344
+
345
+ var current = fieldsRef.current;
346
+ var height = "32px";
347
+
348
+ if (current && ((_current$children = current.children) == null ? void 0 : _current$children[0])) {
349
+ height = window.getComputedStyle(current.children[0]).height;
350
+ }
351
+
352
+ return height;
353
+ };
354
+
355
+ var queryFormActionsDom = formBoxRef == null ? void 0 : (_formBoxRef$current = formBoxRef.current) == null ? void 0 : _formBoxRef$current.querySelector('.query-form-actions');
356
+ var queryFormExtraDom = formBoxRef == null ? void 0 : (_formBoxRef$current2 = formBoxRef.current) == null ? void 0 : _formBoxRef$current2.querySelector(".".concat(clsPrefix, "-extra"));
357
+ var formItemsDomList = fieldsRef == null ? void 0 : (_fieldsRef$current = fieldsRef.current) == null ? void 0 : _fieldsRef$current.querySelectorAll('.ant-form-item-control');
358
+ var fieldHeight = getFieldHeight();
359
+ fieldsRef.current.style.height = fieldHeight;
360
+ [queryFormActionsDom, queryFormExtraDom].forEach(function (item) {
361
+ item && Object.assign(item.style, {
362
+ height: fieldHeight,
363
+ lineHeight: fieldHeight
364
+ });
365
+ });
366
+ [].forEach.call(formItemsDomList, function (item) {
367
+ item.style.lineHeight = fieldHeight;
368
+ });
369
+ }
370
+ }, {
371
+ key: "componentDidMount",
372
+ value: function componentDidMount() {
373
+ var current = this.fieldsRef.current;
374
+ var _this$props8 = this.props,
375
+ actions = _this$props8.actions,
376
+ qlsProps = _this$props8.qlsProps,
377
+ form = _this$props8.form,
378
+ showFieldCount = _this$props8.showFieldCount,
379
+ _this$props8$showExpa = _this$props8.showExpand,
380
+ showExpand = _this$props8$showExpa === void 0 ? true : _this$props8$showExpa,
381
+ renderActions = _this$props8.renderActions;
382
+
383
+ if (qlsProps.memory) {
384
+ form.setFieldsValue(_objectSpread({}, form.getFieldsValue(), {}, actions.getFormData()));
385
+ }
386
+
387
+ actions.setData('formData', form.getFieldsValue());
388
+ this.updateFieldHeight(); // 未设置第一行显示数量且禁止了展开操作 或 自定义了操作区域,则不需要处理展开计算逻辑
389
+
390
+ if (!showFieldCount && !showExpand || renderActions) {
391
+ return;
392
+ }
393
+
394
+ if (!showFieldCount) {
395
+ if (current && this.isFieldsWidthOverflow()) {
396
+ this.setState({
397
+ showMore: true
398
+ });
399
+ }
400
+
401
+ window.addEventListener('resize', this.onWindowResize);
402
+ } else {
403
+ this.updateDrawerFieldsValueCount();
404
+ }
405
+ }
406
+ }, {
407
+ key: "componentWillUnmount",
408
+ value: function componentWillUnmount() {
409
+ var actions = this.props.actions;
410
+ actions.removeListener('setFormData', this.setFormData);
411
+ actions.removeListener('fieldChange', this.onFieldChange);
412
+ window.removeEventListener('resize', this.onWindowResize);
413
+ }
414
+ }]);
415
+
416
+ return QueryForm;
417
+ }(_react["default"].Component), _temp)) || _class);
418
+ exports["default"] = QueryForm;
419
+ ;
@@ -0,0 +1,127 @@
1
+ .tnt-querylistscene-queryform {
2
+ display: flex;
3
+
4
+ &-title {
5
+ display: inline-block;
6
+ font-size: 14px;
7
+ font-weight: bold;
8
+ line-height: 32px;
9
+ }
10
+
11
+ &-extra {
12
+ line-height: 32px;
13
+ margin-left: 12px;
14
+ & > * {
15
+ margin-left: 8px;
16
+ }
17
+ }
18
+
19
+ .query-form-actions {
20
+ align-items: center;
21
+ display: inline-block;
22
+ height: 32px;
23
+ line-height: 32px;
24
+ & > .expand-link {
25
+ padding: 0;
26
+ }
27
+ & > *:not(:last-child) {
28
+ margin-right: 10px;
29
+ }
30
+ }
31
+
32
+ .ant-form {
33
+ display: inline-block;
34
+ margin-bottom: 12px;
35
+ display: flex;
36
+ flex: 1;
37
+
38
+ & > div:nth-child(1) {
39
+ height: 32px;
40
+ overflow: hidden;
41
+ .ant-form-item-label {
42
+ label {
43
+ bottom: 4px;
44
+ }
45
+ }
46
+ }
47
+
48
+ &.expanded {
49
+ & > div:nth-child(1) {
50
+ height: auto !important;
51
+ }
52
+ }
53
+
54
+ &.showMore {
55
+ & > div:nth-child(1) {
56
+ .ant-form-item {
57
+ margin-bottom: 12px;
58
+ }
59
+ }
60
+ }
61
+
62
+ & > div:nth-child(2) {
63
+ display: flex;
64
+ }
65
+
66
+ &.ant-form-inline .ant-form-item {
67
+ margin-right: 10px;
68
+ }
69
+
70
+ .ant-form-item-control {
71
+ min-width: 160px;
72
+ line-height: unset;
73
+ .ant-calendar-picker-input {
74
+ padding: 0 11px;
75
+ }
76
+ .ant-form-item-children {
77
+ & > .ant-input,
78
+ & > .ant-input-affix-wrapper {
79
+ width: 160px;
80
+ }
81
+ }
82
+ }
83
+ }
84
+
85
+ &-drawer {
86
+ margin-top: 50px;
87
+ &.large-size {
88
+ margin-top: 60px;
89
+ }
90
+
91
+ &.ant-drawer.ant-drawer-open {
92
+ .ant-drawer-mask {
93
+ opacity: 0;
94
+ background: unset;
95
+ }
96
+ }
97
+ .ant-drawer-body {
98
+ .ant-form-item {
99
+ display: block;
100
+ margin-right: 0;
101
+ margin-bottom: 20px;
102
+ }
103
+ .ant-form-item-label {
104
+ display: block;
105
+ text-align: left;
106
+ line-height: 22px;
107
+ margin-bottom: 10px;
108
+ }
109
+ .ant-form-item-control-wrapper,
110
+ .ant-form-item-control,
111
+ .ant-calendar-picker,
112
+ .ant-input {
113
+ min-width: 100%;
114
+ width: 100%;
115
+ }
116
+
117
+ & > .ant-btn {
118
+ display: block;
119
+ width: 100%;
120
+ margin-bottom: 10px;
121
+ &.ant-btn-primary {
122
+ margin-top: 20px;
123
+ }
124
+ }
125
+ }
126
+ }
127
+ }