@luck-design-biz/luckda 0.0.1
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.
- package/LICENSE +21 -0
- package/README.md +49 -0
- package/README.zh-CN.md +51 -0
- package/es/components/Builder/index.js +133 -0
- package/es/components/LdAutoForm/index.js +136 -0
- package/es/components/LdCard/index.js +198 -0
- package/es/components/LdCard/model.js +34 -0
- package/es/components/LdCom/index.js +24 -0
- package/es/components/LdFormList/index.js +293 -0
- package/es/components/LdFormList/model.js +24 -0
- package/es/components/LdGrid/index.js +214 -0
- package/es/components/LdGrid/model.js +36 -0
- package/es/components/LdGridForm/index.js +172 -0
- package/es/components/LdGridForm/index.less +7 -0
- package/es/components/LdInfoPanel/index.js +114 -0
- package/es/components/LdPop/index.js +31 -0
- package/es/components/LdTree/index.js +244 -0
- package/es/components/LdTree/index.less +36 -0
- package/es/helper/FromItems.js +267 -0
- package/es/helper/action.js +129 -0
- package/es/helper/form.js +100 -0
- package/es/helper/ldBuilder.js +47 -0
- package/es/helper/ldComBuild.js +38 -0
- package/es/index.js +9 -0
- package/es/services.js +46 -0
- package/es/utils/form.js +214 -0
- package/es/utils/grid.js +194 -0
- package/es/utils/index.js +2 -0
- package/lib/components/Builder/index.js +142 -0
- package/lib/components/LdAutoForm/index.js +145 -0
- package/lib/components/LdCard/index.js +207 -0
- package/lib/components/LdCard/model.js +41 -0
- package/lib/components/LdCom/index.js +35 -0
- package/lib/components/LdFormList/index.js +301 -0
- package/lib/components/LdFormList/model.js +30 -0
- package/lib/components/LdGrid/index.js +223 -0
- package/lib/components/LdGrid/model.js +43 -0
- package/lib/components/LdGridForm/index.js +181 -0
- package/lib/components/LdGridForm/index.less +7 -0
- package/lib/components/LdInfoPanel/index.js +123 -0
- package/lib/components/LdPop/index.js +40 -0
- package/lib/components/LdTree/index.js +253 -0
- package/lib/components/LdTree/index.less +36 -0
- package/lib/helper/FromItems.js +287 -0
- package/lib/helper/action.js +138 -0
- package/lib/helper/form.js +111 -0
- package/lib/helper/ldBuilder.js +56 -0
- package/lib/helper/ldComBuild.js +49 -0
- package/lib/index.js +84 -0
- package/lib/services.js +54 -0
- package/lib/utils/form.js +225 -0
- package/lib/utils/grid.js +203 -0
- package/lib/utils/index.js +27 -0
- package/package.json +92 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
+
var _excluded = ["onBlur"],
|
|
6
|
+
_excluded2 = ["handleValueChange", "config"],
|
|
7
|
+
_excluded3 = ["onBlur"],
|
|
8
|
+
_excluded4 = ["handleValueChange", "config"],
|
|
9
|
+
_excluded5 = ["onBlur"],
|
|
10
|
+
_excluded6 = ["handleValueChange", "config"],
|
|
11
|
+
_excluded7 = ["onChange"],
|
|
12
|
+
_excluded8 = ["handleValueChange", "config"],
|
|
13
|
+
_excluded9 = ["handleValueChange", "onChange"],
|
|
14
|
+
_excluded10 = ["onChange"],
|
|
15
|
+
_excluded11 = ["handleValueChange", "config"],
|
|
16
|
+
_excluded12 = ["renderInfoMode"],
|
|
17
|
+
_excluded13 = ["onChange"],
|
|
18
|
+
_excluded14 = ["handleValueChange", "config"],
|
|
19
|
+
_excluded15 = ["onClose"],
|
|
20
|
+
_excluded16 = ["handleValueChange", "config"],
|
|
21
|
+
_excluded17 = ["onChange"],
|
|
22
|
+
_excluded18 = ["handleValueChange", "config"],
|
|
23
|
+
_excluded19 = ["handleValueChange"],
|
|
24
|
+
_excluded20 = ["handleValueChange", "config"];
|
|
25
|
+
import React, { useState, useEffect } from 'react';
|
|
26
|
+
import { getDvaApp } from 'umi';
|
|
27
|
+
import { BasicFormItem } from 'luck-design';
|
|
28
|
+
import { TreeSelector, RegionFormItem } from '@luck-design-biz/base';
|
|
29
|
+
import { DatadicDropDown, UserSelectDropDown as UserItem } from '@luck-design-biz/base/sys/dropdown';
|
|
30
|
+
export var getNumberItem = function getNumberItem() {
|
|
31
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
32
|
+
handleValueChange = _ref.handleValueChange,
|
|
33
|
+
_ref$config = _ref.config;
|
|
34
|
+
_ref$config = _ref$config === void 0 ? {} : _ref$config;
|
|
35
|
+
var _onBlur = _ref$config.onBlur,
|
|
36
|
+
_config = _objectWithoutProperties(_ref$config, _excluded),
|
|
37
|
+
props = _objectWithoutProperties(_ref, _excluded2);
|
|
38
|
+
return /*#__PURE__*/React.createElement(BasicFormItem, _extends({}, props, {
|
|
39
|
+
type: "input",
|
|
40
|
+
config: _objectSpread(_objectSpread({}, _config), {}, {
|
|
41
|
+
type: 'number',
|
|
42
|
+
onBlur: function onBlur(e) {
|
|
43
|
+
handleValueChange && handleValueChange(e.target.value);
|
|
44
|
+
_onBlur && _onBlur(e);
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
}));
|
|
48
|
+
};
|
|
49
|
+
export var getStringItem = function getStringItem(_ref2) {
|
|
50
|
+
var handleValueChange = _ref2.handleValueChange,
|
|
51
|
+
_ref2$config = _ref2.config;
|
|
52
|
+
_ref2$config = _ref2$config === void 0 ? {} : _ref2$config;
|
|
53
|
+
var _onBlur2 = _ref2$config.onBlur,
|
|
54
|
+
_config = _objectWithoutProperties(_ref2$config, _excluded3),
|
|
55
|
+
props = _objectWithoutProperties(_ref2, _excluded4);
|
|
56
|
+
return /*#__PURE__*/React.createElement(BasicFormItem, _extends({}, props, {
|
|
57
|
+
config: _objectSpread(_objectSpread({}, _config), {}, {
|
|
58
|
+
onBlur: function onBlur(e) {
|
|
59
|
+
handleValueChange && handleValueChange(e.target.value);
|
|
60
|
+
_onBlur2 && _onBlur2(e);
|
|
61
|
+
}
|
|
62
|
+
}),
|
|
63
|
+
type: "input"
|
|
64
|
+
}));
|
|
65
|
+
};
|
|
66
|
+
export var getTextareaItem = function getTextareaItem() {
|
|
67
|
+
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
68
|
+
handleValueChange = _ref3.handleValueChange,
|
|
69
|
+
_ref3$config = _ref3.config;
|
|
70
|
+
_ref3$config = _ref3$config === void 0 ? {} : _ref3$config;
|
|
71
|
+
var _onBlur3 = _ref3$config.onBlur,
|
|
72
|
+
_config = _objectWithoutProperties(_ref3$config, _excluded5),
|
|
73
|
+
props = _objectWithoutProperties(_ref3, _excluded6);
|
|
74
|
+
return /*#__PURE__*/React.createElement(BasicFormItem, _extends({}, props, {
|
|
75
|
+
type: "input",
|
|
76
|
+
config: _objectSpread(_objectSpread({}, _config), {}, {
|
|
77
|
+
type: 'textArea',
|
|
78
|
+
onBlur: function onBlur(e) {
|
|
79
|
+
handleValueChange && handleValueChange(e.target.value);
|
|
80
|
+
_onBlur3 && _onBlur3(e);
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
}));
|
|
84
|
+
};
|
|
85
|
+
export var getDateItem = function getDateItem() {
|
|
86
|
+
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
87
|
+
handleValueChange = _ref4.handleValueChange,
|
|
88
|
+
_ref4$config = _ref4.config;
|
|
89
|
+
_ref4$config = _ref4$config === void 0 ? {} : _ref4$config;
|
|
90
|
+
var _onChange = _ref4$config.onChange,
|
|
91
|
+
_config = _objectWithoutProperties(_ref4$config, _excluded7),
|
|
92
|
+
props = _objectWithoutProperties(_ref4, _excluded8);
|
|
93
|
+
return /*#__PURE__*/React.createElement(BasicFormItem, _extends({}, props, {
|
|
94
|
+
type: "datePicker",
|
|
95
|
+
config: _objectSpread(_objectSpread({}, _config), {}, {
|
|
96
|
+
type: 'date',
|
|
97
|
+
onChange: function onChange(date, dateString) {
|
|
98
|
+
handleValueChange && handleValueChange(date);
|
|
99
|
+
_onChange && _onChange(date, dateString);
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
}));
|
|
103
|
+
};
|
|
104
|
+
export var getUserItem = function getUserItem(_ref5) {
|
|
105
|
+
var handleValueChange = _ref5.handleValueChange,
|
|
106
|
+
_onChange2 = _ref5.onChange,
|
|
107
|
+
props = _objectWithoutProperties(_ref5, _excluded9);
|
|
108
|
+
return /*#__PURE__*/React.createElement(UserItem, _extends({}, props, {
|
|
109
|
+
onChange: function onChange(value, record) {
|
|
110
|
+
handleValueChange && handleValueChange(value);
|
|
111
|
+
_onChange2 && _onChange2(value, record);
|
|
112
|
+
}
|
|
113
|
+
}));
|
|
114
|
+
};
|
|
115
|
+
export var getSelectItem = function getSelectItem(_ref6) {
|
|
116
|
+
var handleValueChange = _ref6.handleValueChange,
|
|
117
|
+
_ref6$config = _ref6.config;
|
|
118
|
+
_ref6$config = _ref6$config === void 0 ? {} : _ref6$config;
|
|
119
|
+
var _onChange3 = _ref6$config.onChange,
|
|
120
|
+
_config = _objectWithoutProperties(_ref6$config, _excluded10),
|
|
121
|
+
props = _objectWithoutProperties(_ref6, _excluded11);
|
|
122
|
+
var config = _objectSpread(_objectSpread({}, _config), {}, {
|
|
123
|
+
onChange: function onChange(value, e) {
|
|
124
|
+
handleValueChange && handleValueChange(value);
|
|
125
|
+
_onChange3 && _onChange3(value, e);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
if (props.alias) {
|
|
129
|
+
DatadicDropDown.comName = 'DatadicDropDown';
|
|
130
|
+
return /*#__PURE__*/React.createElement(DatadicDropDown, _extends({}, props, {
|
|
131
|
+
config: config
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
return /*#__PURE__*/React.createElement(BasicFormItem, _extends({}, props, {
|
|
135
|
+
type: "select",
|
|
136
|
+
config: config
|
|
137
|
+
}));
|
|
138
|
+
};
|
|
139
|
+
var DictRadioItem = function DictRadioItem(_ref7) {
|
|
140
|
+
var renderInfoMode = _ref7.renderInfoMode,
|
|
141
|
+
props = _objectWithoutProperties(_ref7, _excluded12);
|
|
142
|
+
var _useState = useState([]),
|
|
143
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
144
|
+
options = _useState2[0],
|
|
145
|
+
setOptions = _useState2[1];
|
|
146
|
+
useEffect(function () {
|
|
147
|
+
var _getDvaApp;
|
|
148
|
+
var _getDvaApp$_store = (_getDvaApp = getDvaApp()) === null || _getDvaApp === void 0 ? void 0 : _getDvaApp._store,
|
|
149
|
+
dispatch = _getDvaApp$_store.dispatch;
|
|
150
|
+
dispatch({
|
|
151
|
+
type: 'global/getDatadic',
|
|
152
|
+
payload: {
|
|
153
|
+
snamealias: props.alias
|
|
154
|
+
}
|
|
155
|
+
}).then(function (ret) {
|
|
156
|
+
setOptions(ret);
|
|
157
|
+
});
|
|
158
|
+
}, [props.alias]);
|
|
159
|
+
return renderInfoMode ? renderInfoMode(function (value) {
|
|
160
|
+
var option = options.find(function (item) {
|
|
161
|
+
return item.value === value;
|
|
162
|
+
});
|
|
163
|
+
return /*#__PURE__*/React.createElement("span", null, option === null || option === void 0 ? void 0 : option.label);
|
|
164
|
+
}) : /*#__PURE__*/React.createElement(BasicFormItem, _extends({}, props, {
|
|
165
|
+
config: _objectSpread(_objectSpread({}, props.config), {}, {
|
|
166
|
+
options: options
|
|
167
|
+
}),
|
|
168
|
+
type: "radio"
|
|
169
|
+
}));
|
|
170
|
+
};
|
|
171
|
+
DictRadioItem.displayName = 'BasicFormItem';
|
|
172
|
+
export var getRadioItem = function getRadioItem() {
|
|
173
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
174
|
+
if (props.alias) {
|
|
175
|
+
return /*#__PURE__*/React.createElement(DictRadioItem, props);
|
|
176
|
+
}
|
|
177
|
+
return /*#__PURE__*/React.createElement(BasicFormItem, _extends({}, props, {
|
|
178
|
+
type: "radio"
|
|
179
|
+
}));
|
|
180
|
+
};
|
|
181
|
+
export var getGroupItem = function getGroupItem(_ref8) {
|
|
182
|
+
var handleValueChange = _ref8.handleValueChange,
|
|
183
|
+
_ref8$config = _ref8.config;
|
|
184
|
+
_ref8$config = _ref8$config === void 0 ? {} : _ref8$config;
|
|
185
|
+
var _onChange4 = _ref8$config.onChange,
|
|
186
|
+
_config = _objectWithoutProperties(_ref8$config, _excluded13),
|
|
187
|
+
props = _objectWithoutProperties(_ref8, _excluded14);
|
|
188
|
+
return /*#__PURE__*/React.createElement(TreeSelector, _extends({}, props, {
|
|
189
|
+
api: "/api/base/group/sysGroupTree/noAuthReadJurisTree?sclassKey=".concat(props.sclassKey),
|
|
190
|
+
config: _objectSpread(_objectSpread({}, _config), {}, {
|
|
191
|
+
onChange: function onChange(value, record) {
|
|
192
|
+
handleValueChange && handleValueChange(value);
|
|
193
|
+
_onChange4 && _onChange4(value, record);
|
|
194
|
+
}
|
|
195
|
+
})
|
|
196
|
+
}));
|
|
197
|
+
};
|
|
198
|
+
export var getColorItem = function getColorItem(_ref9) {
|
|
199
|
+
var handleValueChange = _ref9.handleValueChange,
|
|
200
|
+
_ref9$config = _ref9.config;
|
|
201
|
+
_ref9$config = _ref9$config === void 0 ? {} : _ref9$config;
|
|
202
|
+
var _onClose = _ref9$config.onClose,
|
|
203
|
+
_config = _objectWithoutProperties(_ref9$config, _excluded15),
|
|
204
|
+
props = _objectWithoutProperties(_ref9, _excluded16);
|
|
205
|
+
return /*#__PURE__*/React.createElement(BasicFormItem, _extends({
|
|
206
|
+
formOptions: {
|
|
207
|
+
initialValue: '#000000'
|
|
208
|
+
}
|
|
209
|
+
}, props, {
|
|
210
|
+
type: "colorPicker",
|
|
211
|
+
config: _objectSpread(_objectSpread({}, _config), {}, {
|
|
212
|
+
onClose: function onClose(value) {
|
|
213
|
+
handleValueChange && handleValueChange(value.color);
|
|
214
|
+
_onClose && _onClose(value);
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
}));
|
|
218
|
+
};
|
|
219
|
+
export var getSwitchItem = function getSwitchItem(_ref10) {
|
|
220
|
+
var handleValueChange = _ref10.handleValueChange,
|
|
221
|
+
_ref10$config = _ref10.config;
|
|
222
|
+
_ref10$config = _ref10$config === void 0 ? {} : _ref10$config;
|
|
223
|
+
var _onChange5 = _ref10$config.onChange,
|
|
224
|
+
_config = _objectWithoutProperties(_ref10$config, _excluded17),
|
|
225
|
+
props = _objectWithoutProperties(_ref10, _excluded18);
|
|
226
|
+
return /*#__PURE__*/React.createElement(BasicFormItem, _extends({}, props, {
|
|
227
|
+
type: "switch",
|
|
228
|
+
config: _objectSpread(_objectSpread({}, _config), {}, {
|
|
229
|
+
onChange: function onChange(value, event) {
|
|
230
|
+
handleValueChange && handleValueChange(value);
|
|
231
|
+
_onChange5 && _onChange5(value, event);
|
|
232
|
+
}
|
|
233
|
+
})
|
|
234
|
+
}));
|
|
235
|
+
};
|
|
236
|
+
export var getRegionItem = function getRegionItem(_ref11) {
|
|
237
|
+
var handleValueChange = _ref11.handleValueChange,
|
|
238
|
+
props = _objectWithoutProperties(_ref11, _excluded19);
|
|
239
|
+
return /*#__PURE__*/React.createElement(RegionFormItem, _extends({}, props, {
|
|
240
|
+
config: _objectSpread(_objectSpread({
|
|
241
|
+
changeOnSelect: true
|
|
242
|
+
}, props.config), {}, {
|
|
243
|
+
onChange: function onChange(value, info) {
|
|
244
|
+
var _props$config;
|
|
245
|
+
handleValueChange && handleValueChange(value);
|
|
246
|
+
((_props$config = props.config) === null || _props$config === void 0 ? void 0 : _props$config.onChange) && props.config.onChange(value, info);
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
}));
|
|
250
|
+
};
|
|
251
|
+
export var getYearItem = function getYearItem() {
|
|
252
|
+
var _ref12 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
253
|
+
handleValueChange = _ref12.handleValueChange,
|
|
254
|
+
_ref12$config = _ref12.config,
|
|
255
|
+
config = _ref12$config === void 0 ? {} : _ref12$config,
|
|
256
|
+
props = _objectWithoutProperties(_ref12, _excluded20);
|
|
257
|
+
return /*#__PURE__*/React.createElement(BasicFormItem, _extends({}, props, {
|
|
258
|
+
type: "datePicker",
|
|
259
|
+
config: _objectSpread(_objectSpread({}, config), {}, {
|
|
260
|
+
type: 'year',
|
|
261
|
+
onChange: function onChange(date, dateString) {
|
|
262
|
+
handleValueChange && handleValueChange(date);
|
|
263
|
+
(config === null || config === void 0 ? void 0 : config.onChange) && config.onChange(date, dateString);
|
|
264
|
+
}
|
|
265
|
+
})
|
|
266
|
+
}));
|
|
267
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
// 通用方法
|
|
3
|
+
import { Modal } from 'antd';
|
|
4
|
+
import { showPop, formatMessage } from '@luck-design-biz/base/utils';
|
|
5
|
+
import { transform, isArray } from 'lodash';
|
|
6
|
+
import { dataFormat } from '../utils';
|
|
7
|
+
import { defaultComName } from './form';
|
|
8
|
+
import { readBehaviorCall } from '../services';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 提交行为
|
|
12
|
+
* @param action 行为
|
|
13
|
+
* @param data 数据
|
|
14
|
+
* @param parmas 附件设置
|
|
15
|
+
* @param moduleData 当前模块信息
|
|
16
|
+
*/
|
|
17
|
+
export var doAction = function doAction(action) {
|
|
18
|
+
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
19
|
+
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
20
|
+
_ref$showConfirm = _ref.showConfirm,
|
|
21
|
+
showConfirm = _ref$showConfirm === void 0 ? true : _ref$showConfirm,
|
|
22
|
+
callback = _ref.callback;
|
|
23
|
+
var _ref2 = arguments.length > 3 ? arguments[3] : undefined,
|
|
24
|
+
_ref2$actions = _ref2.actions,
|
|
25
|
+
actions = _ref2$actions === void 0 ? {} : _ref2$actions,
|
|
26
|
+
moduleCode = _ref2.moduleCode;
|
|
27
|
+
var actionData = actions[action];
|
|
28
|
+
if (actionData) {
|
|
29
|
+
var makeSure = function makeSure(onOk) {
|
|
30
|
+
Modal.confirm({
|
|
31
|
+
title: "".concat(formatMessage({
|
|
32
|
+
id: 'luckda.operates.message.doAction.sure',
|
|
33
|
+
label: '确定执行'
|
|
34
|
+
})).concat(actionData, "\u5417\uFF1F"),
|
|
35
|
+
okText: formatMessage({
|
|
36
|
+
id: 'app.base.operate.ok'
|
|
37
|
+
}),
|
|
38
|
+
cancelText: formatMessage({
|
|
39
|
+
id: 'app.base.operate.cancel'
|
|
40
|
+
}),
|
|
41
|
+
onOk: onOk
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var handleAction = function handleAction() {
|
|
45
|
+
readBehaviorCall({
|
|
46
|
+
behaviorKey: action,
|
|
47
|
+
moduleCode: moduleCode,
|
|
48
|
+
datasetCode: Object.keys(data).join(',')
|
|
49
|
+
}, data).then(function (_ref3) {
|
|
50
|
+
var code = _ref3.code,
|
|
51
|
+
data = _ref3.data;
|
|
52
|
+
callback && callback(code === 1, data);
|
|
53
|
+
if (code === 1) {
|
|
54
|
+
showPop(formatMessage({
|
|
55
|
+
id: 'app.base.tip.operate.success'
|
|
56
|
+
}), null, 'success');
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
showConfirm ? makeSure(handleAction) : handleAction();
|
|
61
|
+
} else {
|
|
62
|
+
showPop(formatMessage({
|
|
63
|
+
id: 'luckda.operates.message.noAction',
|
|
64
|
+
label: '该模块下缺少此行为'
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
export var onBatchSubmitAction = function onBatchSubmitAction(_ref4, callback) {
|
|
69
|
+
var values = _ref4.values,
|
|
70
|
+
_ref4$formList = _ref4.formList,
|
|
71
|
+
formList = _ref4$formList === void 0 ? [] : _ref4$formList,
|
|
72
|
+
_ref4$dataSets = _ref4.dataSets,
|
|
73
|
+
dataSets = _ref4$dataSets === void 0 ? {} : _ref4$dataSets,
|
|
74
|
+
_ref4$beforeSubmit = _ref4.beforeSubmit,
|
|
75
|
+
beforeSubmit = _ref4$beforeSubmit === void 0 ? function (values) {
|
|
76
|
+
return new Promise(function (resolve) {
|
|
77
|
+
return resolve(values);
|
|
78
|
+
});
|
|
79
|
+
} : _ref4$beforeSubmit,
|
|
80
|
+
doAction = _ref4.doAction,
|
|
81
|
+
action = _ref4.action,
|
|
82
|
+
formData = _ref4.formData;
|
|
83
|
+
var data = transform(formList, function (result, value) {
|
|
84
|
+
var _formData$value$id, _values$value$id;
|
|
85
|
+
if (values[value.id]) {
|
|
86
|
+
var _dataSetKey = value.dataSetKey;
|
|
87
|
+
switch (value.type) {
|
|
88
|
+
case 'auto':
|
|
89
|
+
result[_dataSetKey] = _objectSpread({
|
|
90
|
+
indocno: (_formData$value$id = formData[value.id]) === null || _formData$value$id === void 0 ? void 0 : _formData$value$id.indocno
|
|
91
|
+
}, dataFormat(dataSets[_dataSetKey], (_values$value$id = values[value.id]) === null || _values$value$id === void 0 ? void 0 : _values$value$id.submitData));
|
|
92
|
+
break;
|
|
93
|
+
case 'grid':
|
|
94
|
+
case 'writer':
|
|
95
|
+
var gridColumns = dataSets[_dataSetKey].map(function (col) {
|
|
96
|
+
if ((col.comName || defaultComName[col.property]) === 'radio') return _objectSpread(_objectSpread({}, col), {}, {
|
|
97
|
+
comName: 'select'
|
|
98
|
+
});
|
|
99
|
+
return col;
|
|
100
|
+
});
|
|
101
|
+
var _submitData = {};
|
|
102
|
+
if (isArray(values[value.id])) {
|
|
103
|
+
_submitData = {
|
|
104
|
+
addList: values[value.id].map(function (item) {
|
|
105
|
+
return dataFormat(gridColumns, item);
|
|
106
|
+
})
|
|
107
|
+
};
|
|
108
|
+
} else {
|
|
109
|
+
_submitData = transform(values[value.id], function (_result, _value, _key) {
|
|
110
|
+
_result[_key] = _value.map(function (item) {
|
|
111
|
+
return dataFormat(gridColumns, item);
|
|
112
|
+
});
|
|
113
|
+
}, {});
|
|
114
|
+
}
|
|
115
|
+
result[_dataSetKey] = _submitData;
|
|
116
|
+
break;
|
|
117
|
+
default:
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}, {});
|
|
121
|
+
beforeSubmit(data).then(function (backData) {
|
|
122
|
+
if (backData) {
|
|
123
|
+
doAction(action, backData, {
|
|
124
|
+
showConfirm: false,
|
|
125
|
+
callback: callback
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["extra"];
|
|
4
|
+
import { isNil } from 'lodash';
|
|
5
|
+
import { formatMessage } from '@luck-design-biz/base/utils';
|
|
6
|
+
|
|
7
|
+
// 属性类型=》控件
|
|
8
|
+
export var defaultComName = {
|
|
9
|
+
number: 'number',
|
|
10
|
+
money: 'number',
|
|
11
|
+
decimal: 'number',
|
|
12
|
+
string: 'string',
|
|
13
|
+
text: 'textarea',
|
|
14
|
+
date: 'date',
|
|
15
|
+
user: 'user',
|
|
16
|
+
dict: 'select',
|
|
17
|
+
group: 'group',
|
|
18
|
+
on_off: 'switch',
|
|
19
|
+
code: 'string',
|
|
20
|
+
color: 'color',
|
|
21
|
+
zone: 'region',
|
|
22
|
+
year: 'year'
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 动态表单配置项转译
|
|
27
|
+
* @param {key string} keyStr
|
|
28
|
+
* @param {label string} labelStr
|
|
29
|
+
* @returns [{key,label}]
|
|
30
|
+
*/
|
|
31
|
+
export var splitStrToObj = function splitStrToObj(keyStr, labelStr) {
|
|
32
|
+
var keys = keyStr && keyStr.length > 0 ? keyStr.split(',') : undefined;
|
|
33
|
+
if (keys) {
|
|
34
|
+
var labels = labelStr && labelStr.length > 0 ? labelStr.split(',') : undefined;
|
|
35
|
+
return keys.map(function (val, index) {
|
|
36
|
+
return {
|
|
37
|
+
key: val,
|
|
38
|
+
value: val,
|
|
39
|
+
label: labels && labels[index]
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 动态表单配置项转译
|
|
48
|
+
* @param {动态表单配置项} props
|
|
49
|
+
* @param {自定义动态表单配置项} customProps
|
|
50
|
+
* @returns {name: '',...}
|
|
51
|
+
*/
|
|
52
|
+
export function translator() {
|
|
53
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
54
|
+
extra = _ref.extra,
|
|
55
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
56
|
+
var allConfig = _objectSpread(_objectSpread({}, props), JSON.parse(extra || '{}'));
|
|
57
|
+
var _props = {
|
|
58
|
+
name: allConfig.field,
|
|
59
|
+
label: allConfig.fieldName,
|
|
60
|
+
config: {
|
|
61
|
+
required: !!allConfig.isNotNull,
|
|
62
|
+
disabled: !!allConfig.isReadOnly
|
|
63
|
+
},
|
|
64
|
+
layout: 'block'
|
|
65
|
+
};
|
|
66
|
+
if (!isNil(allConfig['dataFormat'])) _props.dataFormat = allConfig['dataFormat'];
|
|
67
|
+
// if (allConfig.tip) _props.config.placeholder = allConfig.tip;
|
|
68
|
+
// if (allConfig.note) _props.extra = allConfig.note;
|
|
69
|
+
/* *********************************** extra ******************************* */
|
|
70
|
+
if (allConfig['opt_length']) _props.config.length = allConfig['opt_length'];
|
|
71
|
+
if (!isNil(allConfig['opt_number_min'])) _props.config.min = allConfig['opt_number_min'];
|
|
72
|
+
if (!isNil(allConfig['opt_number_max'])) _props.config.max = allConfig['opt_number_max'];
|
|
73
|
+
if (!isNil(allConfig['opt_decimal'])) _props.config.precision = allConfig['opt_decimal'];
|
|
74
|
+
// 兼容部分组件多选移至props
|
|
75
|
+
if (!isNil(allConfig['opt_multiple'])) _props.multiple = !!allConfig['opt_multiple'];
|
|
76
|
+
if (!isNil(allConfig['opt_multiple'])) _props.config.mode = allConfig['opt_multiple'] ? 'multiple' : 'single';
|
|
77
|
+
if (allConfig['opt_dict_key']) _props.alias = allConfig['opt_dict_key'];
|
|
78
|
+
if (allConfig['opt_group_class']) _props.sclassKey = allConfig['opt_group_class'];
|
|
79
|
+
if (allConfig['opt_string_regex']) _props.config.rules = [{
|
|
80
|
+
pattern: allConfig['opt_string_regex'],
|
|
81
|
+
message: formatMessage({
|
|
82
|
+
id: 'luckda.form.fields.regex',
|
|
83
|
+
label: '不满足验证要求'
|
|
84
|
+
})
|
|
85
|
+
}];
|
|
86
|
+
return _props;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 删除自动移操作中的不可覆盖字段
|
|
91
|
+
* @param props
|
|
92
|
+
* @returns {{multiple}|*}
|
|
93
|
+
*/
|
|
94
|
+
export function formatCustomProps(props) {
|
|
95
|
+
var _props$confiig;
|
|
96
|
+
if (props === null || props === void 0 ? void 0 : props.multiple) delete props.multiple;
|
|
97
|
+
if (props === null || props === void 0 ? void 0 : (_props$confiig = props.confiig) === null || _props$confiig === void 0 ? void 0 : _props$confiig.mode) delete props.confiig.mode;
|
|
98
|
+
// alias、sclassKey?
|
|
99
|
+
return props;
|
|
100
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
import { LuckDaContext } from '../components/Builder';
|
|
4
|
+
import { formatMessage } from '@luck-design-biz/base/utils';
|
|
5
|
+
var builder = function builder(wrapped) {
|
|
6
|
+
var LdCom = function LdCom(props) {
|
|
7
|
+
var ldId = props.ldId,
|
|
8
|
+
dataSetKey = props.dataSetKey;
|
|
9
|
+
var _ref = useContext(LuckDaContext) || {},
|
|
10
|
+
resources = _ref.resources,
|
|
11
|
+
actions = _ref.actions,
|
|
12
|
+
_ref$dataSets = _ref.dataSets,
|
|
13
|
+
dataSets = _ref$dataSets === void 0 ? [] : _ref$dataSets,
|
|
14
|
+
_ref$isTree = _ref.isTree,
|
|
15
|
+
isTree = _ref$isTree === void 0 ? [] : _ref$isTree,
|
|
16
|
+
doAction = _ref.doAction,
|
|
17
|
+
moduleCode = _ref.moduleCode; // 读存储的模块信息,包括行为、行为执行方法、数据集
|
|
18
|
+
|
|
19
|
+
if (!ldId) return formatMessage({
|
|
20
|
+
id: 'luckda.paramMiss.ldId',
|
|
21
|
+
label: '配置项缺少组件唯一标识(ldId)'
|
|
22
|
+
});
|
|
23
|
+
if (!dataSetKey) return formatMessage({
|
|
24
|
+
id: 'luckda.paramMiss.dataSetKey',
|
|
25
|
+
label: '缺少数据集(dataSetKey)'
|
|
26
|
+
});
|
|
27
|
+
if (!dataSets[dataSetKey]) return "".concat(formatMessage({
|
|
28
|
+
// 待获取数据源
|
|
29
|
+
id: 'luckda.module.miss',
|
|
30
|
+
label: '该模块下缺少'
|
|
31
|
+
})).concat(dataSetKey).concat(formatMessage({
|
|
32
|
+
id: 'luckda.parmas.dataSet',
|
|
33
|
+
label: '数据集'
|
|
34
|
+
}));
|
|
35
|
+
var wrappedProps = _objectSpread(_objectSpread({}, props), {}, {
|
|
36
|
+
columns: dataSets[dataSetKey],
|
|
37
|
+
isTree: isTree,
|
|
38
|
+
resources: resources,
|
|
39
|
+
actions: actions,
|
|
40
|
+
doAction: doAction,
|
|
41
|
+
moduleCode: moduleCode
|
|
42
|
+
});
|
|
43
|
+
return wrapped(wrappedProps);
|
|
44
|
+
};
|
|
45
|
+
return LdCom;
|
|
46
|
+
};
|
|
47
|
+
export default builder;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { useContext, Fragment } from 'react';
|
|
2
|
+
import { includes, intersectionWith } from 'lodash';
|
|
3
|
+
import { ChildrenUtil } from '@luck-design-biz/base/utils';
|
|
4
|
+
import { LuckDaContext } from '../components/Builder';
|
|
5
|
+
export var getResources = function getResources() {
|
|
6
|
+
var _ref = useContext(LuckDaContext) || {},
|
|
7
|
+
_ref$resources = _ref.resources,
|
|
8
|
+
resources = _ref$resources === void 0 ? [] : _ref$resources;
|
|
9
|
+
return resources;
|
|
10
|
+
};
|
|
11
|
+
export var ldComBuilder = function ldComBuilder(Com) {
|
|
12
|
+
var Component = function Component(props) {
|
|
13
|
+
var _com$props;
|
|
14
|
+
var resources = getResources();
|
|
15
|
+
var com = /*#__PURE__*/React.createElement(Com, props);
|
|
16
|
+
return !(com === null || com === void 0 ? void 0 : (_com$props = com.props) === null || _com$props === void 0 ? void 0 : _com$props.resource) || includes(resources, com.props.resource) ? com : Fragment;
|
|
17
|
+
};
|
|
18
|
+
return Component;
|
|
19
|
+
};
|
|
20
|
+
export var filterOptions = function filterOptions(options) {
|
|
21
|
+
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'resource';
|
|
22
|
+
var resources = getResources();
|
|
23
|
+
return intersectionWith(options, resources, function (arrVal, othVal) {
|
|
24
|
+
return !arrVal[key] || arrVal[key] === othVal;
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
export var deepFilterCom = function deepFilterCom(Com, childMark) {
|
|
28
|
+
var Component = function Component(props) {
|
|
29
|
+
var resources = getResources();
|
|
30
|
+
var com = /*#__PURE__*/React.createElement(Com, props);
|
|
31
|
+
return ChildrenUtil.deepFilter(com, function (child) {
|
|
32
|
+
var _child$props;
|
|
33
|
+
var data = !childMark(child) || !(child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.resource) || includes(resources, child.props.resource);
|
|
34
|
+
return data;
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
return Component;
|
|
38
|
+
};
|
package/es/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as ldModuleBuild } from './components/Builder';
|
|
2
|
+
export { default as LdTree } from './components/LdTree';
|
|
3
|
+
export { default as LdGrid } from './components/LdGrid';
|
|
4
|
+
export { default as LdFormList } from './components/LdFormList';
|
|
5
|
+
export { default as buildLdAutoForm } from './components/LdAutoForm';
|
|
6
|
+
export { default as buildLdGridForm } from './components/LdGridForm';
|
|
7
|
+
export { default as LdInfoPanel } from './components/LdInfoPanel';
|
|
8
|
+
export { default as LdCard } from './components/LdCard';
|
|
9
|
+
export * from './components/LdCom';
|
package/es/services.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import { stringify } from 'querystring';
|
|
4
|
+
import { request } from '@luck-design-biz/base/utils';
|
|
5
|
+
import api from '@/services/ApiConfig';
|
|
6
|
+
export function readModlue(_x) {
|
|
7
|
+
return _readModlue.apply(this, arguments);
|
|
8
|
+
}
|
|
9
|
+
function _readModlue() {
|
|
10
|
+
_readModlue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(get) {
|
|
11
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
12
|
+
while (1) {
|
|
13
|
+
switch (_context.prev = _context.next) {
|
|
14
|
+
case 0:
|
|
15
|
+
return _context.abrupt("return", request("".concat(api.LUCKDA_HOST, "/ui/builder/noAuthFetchModule?").concat(stringify(get))));
|
|
16
|
+
case 1:
|
|
17
|
+
case "end":
|
|
18
|
+
return _context.stop();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}, _callee);
|
|
22
|
+
}));
|
|
23
|
+
return _readModlue.apply(this, arguments);
|
|
24
|
+
}
|
|
25
|
+
export function readBehaviorCall(_x2, _x3) {
|
|
26
|
+
return _readBehaviorCall.apply(this, arguments);
|
|
27
|
+
}
|
|
28
|
+
function _readBehaviorCall() {
|
|
29
|
+
_readBehaviorCall = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(get, post) {
|
|
30
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
31
|
+
while (1) {
|
|
32
|
+
switch (_context2.prev = _context2.next) {
|
|
33
|
+
case 0:
|
|
34
|
+
return _context2.abrupt("return", request("".concat(api.LUCKDA_HOST, "/to/behavior/call?").concat(stringify(get)), {
|
|
35
|
+
method: 'POST',
|
|
36
|
+
body: post
|
|
37
|
+
}));
|
|
38
|
+
case 1:
|
|
39
|
+
case "end":
|
|
40
|
+
return _context2.stop();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}, _callee2);
|
|
44
|
+
}));
|
|
45
|
+
return _readBehaviorCall.apply(this, arguments);
|
|
46
|
+
}
|