ronds-metadata 1.1.44 → 1.1.46

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.
@@ -5,7 +5,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
5
5
  /*
6
6
  * @Author: your name
7
7
  * @Date: 2021-09-18 14:15:04
8
- * @LastEditTime: 2022-07-06 14:02:17
8
+ * @LastEditTime: 2022-10-12 09:04:56
9
9
  */
10
10
  import { getLocale } from '../../../framework/locale';
11
11
  import moment from 'moment';
@@ -11,6 +11,7 @@ import { JsonMetadataProvider } from '../../framework/metadata';
11
11
  import { MetadataService } from '../../framework/metadata/MetadataService';
12
12
  import useMemoSubject from '../../framework/rxjs-hooks/useMemoSubject';
13
13
  import useObservable from '../../framework/rxjs-hooks/useObservable';
14
+ import moment from 'moment';
14
15
 
15
16
  var MetadataForm = function MetadataForm(props) {
16
17
  var _Form$useForm = _Form.useForm(),
@@ -130,8 +131,16 @@ var MetadataForm = function MetadataForm(props) {
130
131
  return function () {};
131
132
  }, [mySchma]);
132
133
  React.useEffect(function () {
133
- if (initialValues && firstLoadRef.current) {
134
+ if (initialValues && firstLoadRef.current && fields) {
134
135
  try {
136
+ // 处理时间格式
137
+ fields.forEach(function (v, k) {
138
+ var _v$text;
139
+
140
+ if ((v === null || v === void 0 ? void 0 : (_v$text = v.text) === null || _v$text === void 0 ? void 0 : _v$text.type) === 'datePicker' && initialValues[k]) {
141
+ initialValues[k] = moment(initialValues[k], 'YYYY-MM-DD HH:mm:ss');
142
+ }
143
+ });
135
144
  form.setFieldsValue(_objectSpread({}, initialValues));
136
145
  firstLoadRef.current = false;
137
146
  } catch (ex) {
@@ -142,7 +151,35 @@ var MetadataForm = function MetadataForm(props) {
142
151
  }, 500);
143
152
  }
144
153
  }
145
- }, [initialValues]);
154
+ }, [initialValues, fields]);
155
+
156
+ var onMyValuesChange = function onMyValuesChange(value, allValues) {
157
+ var _extra$text;
158
+
159
+ // 处理时间格式
160
+ var key = Object.keys(value);
161
+ var extra = fields.get(key[0]);
162
+
163
+ if ((extra === null || extra === void 0 ? void 0 : (_extra$text = extra.text) === null || _extra$text === void 0 ? void 0 : _extra$text.type) === 'datePicker') {
164
+ value[key[0]] = moment(value[key[0]]).format('YYYY-MM-DD HH:mm:ss');
165
+ allValues[key[0]] = moment(value[key[0]]).format('YYYY-MM-DD HH:mm:ss');
166
+ }
167
+
168
+ onValuesChange && onValuesChange(value, allValues);
169
+ };
170
+
171
+ var onMyFinish = function onMyFinish(values) {
172
+ // 处理时间格式
173
+ fields.forEach(function (v, k) {
174
+ var _v$text2;
175
+
176
+ if ((v === null || v === void 0 ? void 0 : (_v$text2 = v.text) === null || _v$text2 === void 0 ? void 0 : _v$text2.type) === 'datePicker' && values[k]) {
177
+ values[k] = moment(values[k]).format('YYYY-MM-DD HH:mm:ss');
178
+ }
179
+ });
180
+ onFinish && onFinish(values);
181
+ };
182
+
146
183
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MetadataFormContext.Provider, {
147
184
  value: {
148
185
  fields: fields,
@@ -162,8 +199,8 @@ var MetadataForm = function MetadataForm(props) {
162
199
  layout: layout,
163
200
  form: form,
164
201
  name: "control-hooks",
165
- onFinish: onFinish,
166
- onValuesChange: onValuesChange
202
+ onFinish: onMyFinish,
203
+ onValuesChange: onMyValuesChange
167
204
  }, renderForm(mySchma, options, colSpan))));
168
205
  };
169
206
 
@@ -3,7 +3,7 @@
3
3
  // display: flex !important;
4
4
  // }
5
5
  .ant-form-item {
6
- margin: 0;
6
+ margin: 0 !important;
7
7
  }
8
8
  .ant-form-item-label > label .ant-form-item-tooltip {
9
9
  margin-left: 5px;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.1.44",
4
+ "version": "1.1.46",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",