@hw-component/form 0.0.4-beta-v6 → 0.0.4-beta-v7

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.
@@ -9,8 +9,8 @@ import _toConsumableArray from '@babel/runtime-corejs3/helpers/toConsumableArray
9
9
  import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
10
10
  import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
11
11
  import _Promise from '@babel/runtime-corejs3/core-js/promise';
12
- import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
13
12
  import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
13
+ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
14
14
  import _Reflect$deleteProperty from '@babel/runtime-corejs3/core-js/reflect/delete-property';
15
15
  import _concatInstanceProperty from '@babel/runtime-corejs3/core-js/instance/concat';
16
16
  import _mapInstanceProperty from '@babel/runtime-corejs3/core-js/instance/map';
@@ -26,12 +26,12 @@ var useHForm = (function () {
26
26
  return useMemo(function () {
27
27
  var formatSourceData = {};
28
28
  var dispatchSourceData = {};
29
- var initDispatch = [];
29
+ var initDispatch = {};
30
30
  var cacheValues = {};
31
31
  var isLoading = false;
32
32
  var norAddItemDispatch = function norAddItemDispatch(name, manual, fn) {
33
- if (manual === false) {
34
- initDispatch.push(fn);
33
+ if (manual === false && name) {
34
+ initDispatch[name] = fn;
35
35
  }
36
36
  if (!name) {
37
37
  return {
@@ -54,8 +54,9 @@ var useHForm = (function () {
54
54
  newValue = this.formatValues(cacheValues);
55
55
  form.setFieldsValue(newValue);
56
56
  }
57
- _forEachInstanceProperty(initDispatch).call(initDispatch, function (fn) {
58
- fn({
57
+ var initKeys = _Object$keys(initDispatch);
58
+ _forEachInstanceProperty(initKeys).call(initKeys, function (key) {
59
+ initDispatch[key]({
59
60
  changedValues: newValue,
60
61
  oldValues: newValue
61
62
  });
@@ -136,6 +137,9 @@ var useHForm = (function () {
136
137
  } else {
137
138
  defaultFn.push(fn);
138
139
  }
140
+ if (manual === false && name) {
141
+ initDispatch[name] = fn;
142
+ }
139
143
  dispatchSourceData[key] = {
140
144
  keysFn: keysFn,
141
145
  defaultFn: defaultFn
package/es/Form/index.js CHANGED
@@ -44,6 +44,7 @@ var HForm = (function (_ref) {
44
44
  }),
45
45
  newConfigData = _useInitConfigData.newConfigData,
46
46
  dispatchSourceData = _useInitConfigData.dispatchSourceData;
47
+ console.log(dispatchSourceData, "dispatchSourceData");
47
48
  var _useInfoReq = useInfoReq({
48
49
  initialValues: initialValues,
49
50
  request: request,
@@ -12,8 +12,8 @@ var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArr
12
12
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
13
13
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
14
14
  var _Promise = require('@babel/runtime-corejs3/core-js/promise');
15
- var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/for-each');
16
15
  var _Object$keys = require('@babel/runtime-corejs3/core-js/object/keys');
16
+ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/for-each');
17
17
  var _Reflect$deleteProperty = require('@babel/runtime-corejs3/core-js/reflect/delete-property');
18
18
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/concat');
19
19
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/map');
@@ -29,12 +29,12 @@ var useHForm = (function () {
29
29
  return React.useMemo(function () {
30
30
  var formatSourceData = {};
31
31
  var dispatchSourceData = {};
32
- var initDispatch = [];
32
+ var initDispatch = {};
33
33
  var cacheValues = {};
34
34
  var isLoading = false;
35
35
  var norAddItemDispatch = function norAddItemDispatch(name, manual, fn) {
36
- if (manual === false) {
37
- initDispatch.push(fn);
36
+ if (manual === false && name) {
37
+ initDispatch[name] = fn;
38
38
  }
39
39
  if (!name) {
40
40
  return {
@@ -57,8 +57,9 @@ var useHForm = (function () {
57
57
  newValue = this.formatValues(cacheValues);
58
58
  form.setFieldsValue(newValue);
59
59
  }
60
- _forEachInstanceProperty(initDispatch).call(initDispatch, function (fn) {
61
- fn({
60
+ var initKeys = _Object$keys(initDispatch);
61
+ _forEachInstanceProperty(initKeys).call(initKeys, function (key) {
62
+ initDispatch[key]({
62
63
  changedValues: newValue,
63
64
  oldValues: newValue
64
65
  });
@@ -139,6 +140,9 @@ var useHForm = (function () {
139
140
  } else {
140
141
  defaultFn.push(fn);
141
142
  }
143
+ if (manual === false && name) {
144
+ initDispatch[name] = fn;
145
+ }
142
146
  dispatchSourceData[key] = {
143
147
  keysFn: keysFn,
144
148
  defaultFn: defaultFn
package/lib/Form/index.js CHANGED
@@ -47,6 +47,7 @@ var HForm = (function (_ref) {
47
47
  }),
48
48
  newConfigData = _useInitConfigData.newConfigData,
49
49
  dispatchSourceData = _useInitConfigData.dispatchSourceData;
50
+ console.log(dispatchSourceData, "dispatchSourceData");
50
51
  var _useInfoReq = index.useInfoReq({
51
52
  initialValues: initialValues,
52
53
  request: request,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "0.0.4-beta-v6",
3
+ "version": "0.0.4-beta-v7",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,12 +13,12 @@ export default () => {
13
13
  return useMemo<HFormInstance>(() => {
14
14
  const formatSourceData: Record<string, FormatItemModal> = {};
15
15
  let dispatchSourceData: Record<string, DispatchItemData> = {};
16
- const initDispatch: argsFn[] = [];
16
+ const initDispatch: Record<string, argsFn> = {};
17
17
  let cacheValues: Record<string, any> = {};
18
18
  let isLoading = false;
19
19
  const norAddItemDispatch = (name, manual, fn) => {
20
- if (manual === false) {
21
- initDispatch.push(fn);
20
+ if (manual === false&&name) {
21
+ initDispatch[name]=fn;
22
22
  }
23
23
  if (!name) {
24
24
  return {
@@ -43,8 +43,9 @@ export default () => {
43
43
  newValue = this.formatValues(cacheValues);
44
44
  form.setFieldsValue(newValue);
45
45
  }
46
- initDispatch.forEach((fn) => {
47
- fn({ changedValues: newValue, oldValues: newValue });
46
+ const initKeys=Object.keys(initDispatch);
47
+ initKeys.forEach((key) => {
48
+ initDispatch[key]({ changedValues: newValue, oldValues: newValue });
48
49
  });
49
50
  isLoading = true;
50
51
  },
@@ -110,6 +111,9 @@ export default () => {
110
111
  } else {
111
112
  defaultFn.push(fn);
112
113
  }
114
+ if (manual===false&&name){
115
+ initDispatch[name]=fn;
116
+ }
113
117
  dispatchSourceData[key] = {
114
118
  keysFn,
115
119
  defaultFn,
@@ -26,6 +26,7 @@ export default ({
26
26
  configData,
27
27
  form: hForm,
28
28
  });
29
+ console.log(dispatchSourceData,"dispatchSourceData")
29
30
  const { subControl, infoControl } = useInfoReq({
30
31
  initialValues,
31
32
  request,
@@ -96,6 +96,25 @@ const data = [
96
96
  type: "urlUpload",
97
97
  rules: [{ required: true }],
98
98
  },
99
+ {
100
+ label: "下拉框",
101
+ name: "select",
102
+ type: "select",
103
+ dispatch: {
104
+ fnKey: "reload",
105
+ dependencies: ["selectInput", "sz"],
106
+ manual: false,
107
+ },
108
+ itemProps: {
109
+ request: (params = {}, values) => {
110
+ console.log(values, "paramsparamsparams");
111
+ const { label = "123", value = 1 } = params;
112
+ return Promise.resolve([{ label, value }]);
113
+ },
114
+ showSearch: true,
115
+ },
116
+ rules: [{ required: true }],
117
+ },
99
118
  ];
100
119
  let num = 0;
101
120
  export default () => {