ronds-metadata 1.1.58 → 1.1.60

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.
@@ -1,6 +1,10 @@
1
1
  import "antd/es/form/style";
2
2
  import _Form from "antd/es/form";
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import "antd/es/radio/style";
5
+ import _Radio from "antd/es/radio";
6
+ import "antd/es/checkbox/style";
7
+ import _Checkbox from "antd/es/checkbox";
4
8
  import "antd/es/select/style";
5
9
  import _Select from "antd/es/select";
6
10
  import "antd/es/space/style";
@@ -22,7 +26,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
22
26
  /*
23
27
  * @Author:wangxian
24
28
  * @Date: 2021-09-18 14:15:04
25
- * @LastEditTime: 2022-11-09 15:59:15
29
+ * @LastEditTime: 2022-11-22 14:42:09
26
30
  */
27
31
  import React from 'react';
28
32
  import { MetadataFormContext, MetadataRefContext } from '../interface';
@@ -31,9 +35,10 @@ import { MetadataService } from '../../../framework/metadata/MetadataService';
31
35
  import { deepClone } from '../../../utils';
32
36
  import { useAsyncMemo } from '../../../framework/hooks/use-async-memo';
33
37
  import { tr } from '../../../framework/locale';
38
+ import useObservable from '@/framework/rxjs-hooks/useObservable';
34
39
 
35
40
  function Index(props) {
36
- var _extraInfo$http5, _extraInfo$http6, _extraInfo$http7, _extraInfo$http8;
41
+ var _extraInfo$http6, _extraInfo$http7, _extraInfo$http8, _extraInfo$http9;
37
42
 
38
43
  var id = props.id,
39
44
  name = props.name,
@@ -54,6 +59,12 @@ function Index(props) {
54
59
  cascaderOption = _React$useState2[0],
55
60
  setCascaderOption = _React$useState2[1];
56
61
 
62
+ var _React$useState3 = React.useState(),
63
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
64
+ watchValue = _React$useState4[0],
65
+ setWatchValue = _React$useState4[1];
66
+
67
+ var watchValueRef = React.useRef();
57
68
  var pageRef = React.useRef(1);
58
69
  var totalRef = React.useRef();
59
70
 
@@ -64,6 +75,22 @@ function Index(props) {
64
75
  });
65
76
  };
66
77
 
78
+ useObservable(function (p) {
79
+ var _extraInfo$http;
80
+
81
+ // 判断是否有 watch的扩展属性
82
+ var _watch = extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$http = extraInfo.http) === null || _extraInfo$http === void 0 ? void 0 : _extraInfo$http.watch;
83
+
84
+ if (_watch) {
85
+ var _value = p.payload[_watch];
86
+
87
+ if (_value) {
88
+ setWatchValue(_value);
89
+ watchValueRef.current = _value;
90
+ formContext.form.setFieldsValue(_defineProperty({}, id, undefined));
91
+ }
92
+ }
93
+ }, [formContext.stream$, extraInfo]);
67
94
  var getEnumDataByUrl = React.useCallback( /*#__PURE__*/function () {
68
95
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(http, pid, page) {
69
96
  var server, _url, res, _res;
@@ -75,16 +102,21 @@ function Index(props) {
75
102
  server = new MetadataService();
76
103
  _url = pid || pid === '' ? http.url.replace('{pid}', pid) : http.url;
77
104
  _url = page ? http.url.replace('{page}', page) : _url;
78
- _context.next = 5;
105
+
106
+ if (watchValueRef.current) {
107
+ _url = _url.replace('{watch}', watchValueRef.current);
108
+ }
109
+
110
+ _context.next = 6;
79
111
  return server.GetEnumDataByUrl(_url);
80
112
 
81
- case 5:
113
+ case 6:
82
114
  res = _context.sent;
83
115
  _res = (res === null || res === void 0 ? void 0 : res.total) ? res === null || res === void 0 ? void 0 : res.list : res;
84
116
  totalRef.current = res === null || res === void 0 ? void 0 : res.total;
85
117
 
86
118
  if (!(_res && _res.length > 0)) {
87
- _context.next = 12;
119
+ _context.next = 13;
88
120
  break;
89
121
  }
90
122
 
@@ -103,11 +135,11 @@ function Index(props) {
103
135
  }
104
136
  }));
105
137
 
106
- case 12:
138
+ case 13:
107
139
  console.warn("".concat(_url, " is not return success result"));
108
140
  return _context.abrupt("return", []);
109
141
 
110
- case 14:
142
+ case 15:
111
143
  case "end":
112
144
  return _context.stop();
113
145
  }
@@ -151,7 +183,7 @@ function Index(props) {
151
183
  return processSelectOptionsData();
152
184
  }, [initEnumValue, myEnum, id]);
153
185
  var httpOptions = useAsyncMemo( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
154
- var _extraInfo$http, _extraInfo$http2, res;
186
+ var _extraInfo$http2, _extraInfo$http3, res;
155
187
 
156
188
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
157
189
  while (1) {
@@ -163,12 +195,12 @@ function Index(props) {
163
195
  }
164
196
 
165
197
  _context2.next = 3;
166
- return getEnumDataByUrl(deepClone(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.http), '', (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$http = extraInfo.http) === null || _extraInfo$http === void 0 ? void 0 : _extraInfo$http.isPagination) && pageRef.current);
198
+ return getEnumDataByUrl(deepClone(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.http), '', (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$http2 = extraInfo.http) === null || _extraInfo$http2 === void 0 ? void 0 : _extraInfo$http2.isPagination) && pageRef.current);
167
199
 
168
200
  case 3:
169
201
  res = _context2.sent;
170
202
 
171
- if (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$http2 = extraInfo.http) === null || _extraInfo$http2 === void 0 ? void 0 : _extraInfo$http2.isCascader) {
203
+ if (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$http3 = extraInfo.http) === null || _extraInfo$http3 === void 0 ? void 0 : _extraInfo$http3.isCascader) {
172
204
  setCascaderOption(_toConsumableArray(res));
173
205
  }
174
206
 
@@ -183,7 +215,7 @@ function Index(props) {
183
215
  }
184
216
  }
185
217
  }, _callee2);
186
- })), [extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.http]);
218
+ })), [extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.http, watchValue]);
187
219
 
188
220
  var loadData = /*#__PURE__*/function () {
189
221
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(selectedOptions) {
@@ -270,6 +302,24 @@ function Index(props) {
270
302
  },
271
303
  allowClear: true
272
304
  });
305
+ } else if (extraInfo.type === 'checkbox') {
306
+ return (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.isMutiple) ? /*#__PURE__*/React.createElement(_Checkbox.Group, {
307
+ style: {
308
+ width: '100%'
309
+ }
310
+ }, (httpOptions && httpOptions.length > 0 ? httpOptions : options).map(function (it) {
311
+ return /*#__PURE__*/React.createElement(_Checkbox, {
312
+ value: it.value
313
+ }, it.label);
314
+ })) : /*#__PURE__*/React.createElement(_Radio.Group, {
315
+ style: {
316
+ width: '100%'
317
+ }
318
+ }, (httpOptions && httpOptions.length > 0 ? httpOptions : options).map(function (it) {
319
+ return /*#__PURE__*/React.createElement(_Radio, {
320
+ value: it.value
321
+ }, it.label);
322
+ }));
273
323
  } else {
274
324
  var _extraInfo$disabled3;
275
325
 
@@ -294,7 +344,7 @@ function Index(props) {
294
344
  };
295
345
 
296
346
  if (isObj && isRefForm && field) {
297
- var _extraInfo$http3, _extraInfo$http4;
347
+ var _extraInfo$http4, _extraInfo$http5;
298
348
 
299
349
  return /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
300
350
  style: {
@@ -309,7 +359,7 @@ function Index(props) {
309
359
  }],
310
360
  help: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help,
311
361
  tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
312
- }), processSelectType((_extraInfo$http3 = extraInfo.http) === null || _extraInfo$http3 === void 0 ? void 0 : _extraInfo$http3.isCascader, (_extraInfo$http4 = extraInfo.http) === null || _extraInfo$http4 === void 0 ? void 0 : _extraInfo$http4.isPagination));
362
+ }), processSelectType((_extraInfo$http4 = extraInfo.http) === null || _extraInfo$http4 === void 0 ? void 0 : _extraInfo$http4.isCascader, (_extraInfo$http5 = extraInfo.http) === null || _extraInfo$http5 === void 0 ? void 0 : _extraInfo$http5.isPagination));
313
363
  }
314
364
 
315
365
  return !field ? /*#__PURE__*/React.createElement(_Form.Item, {
@@ -325,7 +375,7 @@ function Index(props) {
325
375
  }],
326
376
  help: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help,
327
377
  tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
328
- }, processSelectType((_extraInfo$http5 = extraInfo.http) === null || _extraInfo$http5 === void 0 ? void 0 : _extraInfo$http5.isCascader, (_extraInfo$http6 = extraInfo.http) === null || _extraInfo$http6 === void 0 ? void 0 : _extraInfo$http6.isPagination)) : /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
378
+ }, processSelectType((_extraInfo$http6 = extraInfo.http) === null || _extraInfo$http6 === void 0 ? void 0 : _extraInfo$http6.isCascader, (_extraInfo$http7 = extraInfo.http) === null || _extraInfo$http7 === void 0 ? void 0 : _extraInfo$http7.isPagination)) : /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
329
379
  style: {
330
380
  flex: 1,
331
381
  paddingRight: '10px'
@@ -337,7 +387,7 @@ function Index(props) {
337
387
  }],
338
388
  help: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help,
339
389
  tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
340
- }), processSelectType((_extraInfo$http7 = extraInfo.http) === null || _extraInfo$http7 === void 0 ? void 0 : _extraInfo$http7.isCascader, (_extraInfo$http8 = extraInfo.http) === null || _extraInfo$http8 === void 0 ? void 0 : _extraInfo$http8.isPagination));
390
+ }), processSelectType((_extraInfo$http8 = extraInfo.http) === null || _extraInfo$http8 === void 0 ? void 0 : _extraInfo$http8.isCascader, (_extraInfo$http9 = extraInfo.http) === null || _extraInfo$http9 === void 0 ? void 0 : _extraInfo$http9.isPagination));
341
391
  }
342
392
 
343
393
  export default /*#__PURE__*/React.memo(Index);
@@ -183,6 +183,8 @@ var TableArray = function TableArray(props) {
183
183
  var _columns = [];
184
184
 
185
185
  for (var i = 0; i < _properties.length; i++) {
186
+ var _extraInfo$disabled;
187
+
186
188
  var it = _properties[i];
187
189
  var extraInfo = refFieldsRef.current.get(it.id);
188
190
  var obj = {
@@ -190,7 +192,7 @@ var TableArray = function TableArray(props) {
190
192
  key: it.id,
191
193
  dataIndex: it.id,
192
194
  width: processColumnType(it, extraInfo) === 'buttonCell' ? 60 : 100,
193
- editable: true,
195
+ editable: (_extraInfo$disabled = !extraInfo.disabled) !== null && _extraInfo$disabled !== void 0 ? _extraInfo$disabled : true,
194
196
  type: processColumnType(it, extraInfo),
195
197
  enum: it.type === 'enum' ? processEnumData(it, extraInfo) : undefined
196
198
  };
@@ -4,10 +4,10 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
4
  /*
5
5
  * @Author: wangxian
6
6
  * @Date: 2021-09-18 14:15:04
7
- * @LastEditTime: 2022-10-09 17:12:36
7
+ * @LastEditTime: 2022-11-22 14:13:25
8
8
  */
9
9
  import React from 'react';
10
- import { deepClone } from '../../../utils';
10
+ import { deepClone, guid } from '../../../utils';
11
11
  import './index.less';
12
12
  export function withAddOnAfter(WrappedComponent) {
13
13
  return function (props) {
@@ -48,7 +48,7 @@ export function withAddOnAfter(WrappedComponent) {
48
48
  key: "".concat(_name.toString(), "_div"),
49
49
  className: "with-add-on-after"
50
50
  }, /*#__PURE__*/React.createElement(WrappedComponent, _extends({
51
- key: _name.toString()
51
+ key: "".concat(_name.toString(), "_Wrapped_").concat(guid())
52
52
  }, props, {
53
53
  style: {
54
54
  padding: '0px',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.1.58",
4
+ "version": "1.1.60",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",