@bchr/bchr-front-lib 0.5.8 → 0.5.10
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/lib/base/BaseAppUtils.js +10 -2
- package/lib/base/layout/ActionButton.js +6 -0
- package/lib/base/layout/FormRefInput.js +248 -0
- package/lib/base/layout/GridSelectModal.js +507 -0
- package/lib/base/layout/InputRefAddonBtn.js +300 -0
- package/lib/base/layout/KendoGridCellRenders.js +1170 -0
- package/lib/base/layout/RefInput.js +262 -0
- package/lib/base/utils/TableDataProcessors.js +103 -0
- package/lib/services/KendoGridAPI.js +392 -0
- package/lib/services/http.js +605 -0
- package/package.json +1 -1
- package/src/base/BaseAppUtils.js +10 -1
- package/src/base/layout/ActionButton.js +7 -1
- package/src/base/layout/FormRefInput.js +144 -0
- package/src/base/layout/GridSelectModal.js +329 -0
- package/src/base/layout/InputRefAddonBtn.js +120 -0
- package/src/base/layout/KendoGridCellRenders.js +790 -0
- package/src/base/layout/RefInput.js +148 -0
- package/src/base/utils/TableDataProcessors.js +87 -0
- package/src/services/KendoGridAPI.js +298 -0
- package/src/services/http.js +611 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
11
|
+
|
|
12
|
+
var _http = _interopRequireDefault(require("../../services/http"));
|
|
13
|
+
|
|
14
|
+
var _GridSelectModal = _interopRequireDefault(require("./GridSelectModal"));
|
|
15
|
+
|
|
16
|
+
var _antd = require("antd");
|
|
17
|
+
|
|
18
|
+
var _reactUuid = _interopRequireDefault(require("react-uuid"));
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
|
+
|
|
22
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
function _typeof(obj) { "@babel/helpers - typeof"; 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); }
|
|
27
|
+
|
|
28
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
29
|
+
|
|
30
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
31
|
+
|
|
32
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
33
|
+
|
|
34
|
+
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); } }
|
|
35
|
+
|
|
36
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
37
|
+
|
|
38
|
+
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); }
|
|
39
|
+
|
|
40
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
41
|
+
|
|
42
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
43
|
+
|
|
44
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
45
|
+
|
|
46
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
47
|
+
|
|
48
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
49
|
+
|
|
50
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
51
|
+
|
|
52
|
+
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; }
|
|
53
|
+
|
|
54
|
+
var InputRefAddonBtn = /*#__PURE__*/function (_React$Component) {
|
|
55
|
+
_inherits(InputRefAddonBtn, _React$Component);
|
|
56
|
+
|
|
57
|
+
var _super = _createSuper(InputRefAddonBtn);
|
|
58
|
+
|
|
59
|
+
function InputRefAddonBtn(props) {
|
|
60
|
+
var _this;
|
|
61
|
+
|
|
62
|
+
_classCallCheck(this, InputRefAddonBtn);
|
|
63
|
+
|
|
64
|
+
_this = _super.call(this, props);
|
|
65
|
+
|
|
66
|
+
_defineProperty(_assertThisInitialized(_this), "showRefDialog", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
67
|
+
var _this$props, refCode, isNotData, customRefUIConfig, onBeforeClick, refUIConfig, showGridSelectModal;
|
|
68
|
+
|
|
69
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
70
|
+
while (1) {
|
|
71
|
+
switch (_context2.prev = _context2.next) {
|
|
72
|
+
case 0:
|
|
73
|
+
_this$props = _this.props, refCode = _this$props.refCode, isNotData = _this$props.isNotData, customRefUIConfig = _this$props.customRefUIConfig, onBeforeClick = _this$props.onBeforeClick;
|
|
74
|
+
|
|
75
|
+
if (!_lodash["default"].isFunction(onBeforeClick)) {
|
|
76
|
+
_context2.next = 5;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
onBeforeClick( /*#__PURE__*/function () {
|
|
81
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(beforeCustomGridData) {
|
|
82
|
+
var refUIConfig, showGridSelectModal;
|
|
83
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
84
|
+
while (1) {
|
|
85
|
+
switch (_context.prev = _context.next) {
|
|
86
|
+
case 0:
|
|
87
|
+
_context.prev = 0;
|
|
88
|
+
refUIConfig = _this.state.refUIConfig;
|
|
89
|
+
|
|
90
|
+
if (!(refUIConfig == null)) {
|
|
91
|
+
_context.next = 12;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (!isNotData) {
|
|
96
|
+
_context.next = 7;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
refUIConfig = customRefUIConfig;
|
|
101
|
+
_context.next = 10;
|
|
102
|
+
break;
|
|
103
|
+
|
|
104
|
+
case 7:
|
|
105
|
+
_context.next = 9;
|
|
106
|
+
return _http["default"].getJSON("queryRefUIConfig?ref_code=" + refCode);
|
|
107
|
+
|
|
108
|
+
case 9:
|
|
109
|
+
refUIConfig = _context.sent;
|
|
110
|
+
|
|
111
|
+
case 10:
|
|
112
|
+
if (!(refUIConfig == null)) {
|
|
113
|
+
_context.next = 12;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
throw new Error("参照[refCode=]" + refCode + "未定义.");
|
|
118
|
+
|
|
119
|
+
case 12:
|
|
120
|
+
showGridSelectModal = true;
|
|
121
|
+
|
|
122
|
+
_this.setState({
|
|
123
|
+
refUIConfig: refUIConfig,
|
|
124
|
+
showGridSelectModal: showGridSelectModal,
|
|
125
|
+
beforeCustomGridData: beforeCustomGridData
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
_context.next = 19;
|
|
129
|
+
break;
|
|
130
|
+
|
|
131
|
+
case 16:
|
|
132
|
+
_context.prev = 16;
|
|
133
|
+
_context.t0 = _context["catch"](0);
|
|
134
|
+
|
|
135
|
+
_http["default"].dealAjaxException(_context.t0);
|
|
136
|
+
|
|
137
|
+
case 19:
|
|
138
|
+
case "end":
|
|
139
|
+
return _context.stop();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}, _callee, null, [[0, 16]]);
|
|
143
|
+
}));
|
|
144
|
+
|
|
145
|
+
return function (_x) {
|
|
146
|
+
return _ref2.apply(this, arguments);
|
|
147
|
+
};
|
|
148
|
+
}());
|
|
149
|
+
_context2.next = 24;
|
|
150
|
+
break;
|
|
151
|
+
|
|
152
|
+
case 5:
|
|
153
|
+
_context2.prev = 5;
|
|
154
|
+
refUIConfig = _this.state.refUIConfig;
|
|
155
|
+
|
|
156
|
+
if (!(refUIConfig == null)) {
|
|
157
|
+
_context2.next = 17;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (!isNotData) {
|
|
162
|
+
_context2.next = 12;
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
refUIConfig = customRefUIConfig;
|
|
167
|
+
_context2.next = 15;
|
|
168
|
+
break;
|
|
169
|
+
|
|
170
|
+
case 12:
|
|
171
|
+
_context2.next = 14;
|
|
172
|
+
return _http["default"].getJSON("queryRefUIConfig?ref_code=" + refCode);
|
|
173
|
+
|
|
174
|
+
case 14:
|
|
175
|
+
refUIConfig = _context2.sent;
|
|
176
|
+
|
|
177
|
+
case 15:
|
|
178
|
+
if (!(refUIConfig == null)) {
|
|
179
|
+
_context2.next = 17;
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
throw new Error("参照[refCode=]" + refCode + "未定义.");
|
|
184
|
+
|
|
185
|
+
case 17:
|
|
186
|
+
showGridSelectModal = true;
|
|
187
|
+
|
|
188
|
+
_this.setState({
|
|
189
|
+
refUIConfig: refUIConfig,
|
|
190
|
+
showGridSelectModal: showGridSelectModal
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
_context2.next = 24;
|
|
194
|
+
break;
|
|
195
|
+
|
|
196
|
+
case 21:
|
|
197
|
+
_context2.prev = 21;
|
|
198
|
+
_context2.t0 = _context2["catch"](5);
|
|
199
|
+
|
|
200
|
+
_http["default"].dealAjaxException(_context2.t0);
|
|
201
|
+
|
|
202
|
+
case 24:
|
|
203
|
+
case "end":
|
|
204
|
+
return _context2.stop();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}, _callee2, null, [[5, 21]]);
|
|
208
|
+
})));
|
|
209
|
+
|
|
210
|
+
_defineProperty(_assertThisInitialized(_this), "onOkGridSelectModal", function (selectedData) {
|
|
211
|
+
if (!selectedData || !selectedData.length) {
|
|
212
|
+
var refUIConfig = _this.state.refUIConfig;
|
|
213
|
+
|
|
214
|
+
_antd.message.warning("\u672A\u9009\u62E9".concat(refUIConfig.refTitle || '参照'));
|
|
215
|
+
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
var _this$props2 = _this.props,
|
|
220
|
+
rules = _this$props2.rules,
|
|
221
|
+
multiple = _this$props2.multiple;
|
|
222
|
+
|
|
223
|
+
if (rules && rules.test(multiple ? selectedData : selectedData[0])) {
|
|
224
|
+
_antd.message.warning("".concat(rules.message));
|
|
225
|
+
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
_this.props.onOk(selectedData);
|
|
230
|
+
|
|
231
|
+
_this.setState({
|
|
232
|
+
showGridSelectModal: false
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
_defineProperty(_assertThisInitialized(_this), "closeGridSelectModal", function () {
|
|
237
|
+
_this.setState({
|
|
238
|
+
showGridSelectModal: false
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
var _refCode = props.refCode,
|
|
243
|
+
_isNotData = props.isNotData;
|
|
244
|
+
|
|
245
|
+
if (!_isNotData && (_refCode === null || _refCode === void 0)) {
|
|
246
|
+
throw new Error("Not provide refCode prop.");
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
_this.state = {
|
|
250
|
+
refUIConfig: null,
|
|
251
|
+
showGridSelectModal: false
|
|
252
|
+
};
|
|
253
|
+
return _this;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
_createClass(InputRefAddonBtn, [{
|
|
257
|
+
key: "render",
|
|
258
|
+
value: function render() {
|
|
259
|
+
var _this$props3 = this.props,
|
|
260
|
+
refCode = _this$props3.refCode,
|
|
261
|
+
refDialogWidth = _this$props3.refDialogWidth,
|
|
262
|
+
refDialogHeight = _this$props3.refDialogHeight,
|
|
263
|
+
refDialogClassName = _this$props3.refDialogClassName,
|
|
264
|
+
multiple = _this$props3.multiple,
|
|
265
|
+
isNotData = _this$props3.isNotData,
|
|
266
|
+
customGridData = _this$props3.customGridData,
|
|
267
|
+
isNotIcon = _this$props3.isNotIcon,
|
|
268
|
+
icon = _this$props3.icon,
|
|
269
|
+
btnText = _this$props3.btnText;
|
|
270
|
+
var _this$state = this.state,
|
|
271
|
+
refUIConfig = _this$state.refUIConfig,
|
|
272
|
+
beforeCustomGridData = _this$state.beforeCustomGridData,
|
|
273
|
+
showGridSelectModal = _this$state.showGridSelectModal;
|
|
274
|
+
return /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
275
|
+
className: "form-input-control",
|
|
276
|
+
onClick: this.showRefDialog
|
|
277
|
+
}, !isNotIcon && /*#__PURE__*/_react["default"].createElement("span", {
|
|
278
|
+
className: "iconfont icon-personal-search"
|
|
279
|
+
}), btnText), showGridSelectModal && /*#__PURE__*/_react["default"].createElement(_GridSelectModal["default"], {
|
|
280
|
+
key: "grid_select_modal_".concat((0, _reactUuid["default"])()),
|
|
281
|
+
multiple: multiple,
|
|
282
|
+
isNotData: isNotData,
|
|
283
|
+
customGridData: beforeCustomGridData || customGridData,
|
|
284
|
+
refUIConfig: refUIConfig,
|
|
285
|
+
refCode: refCode,
|
|
286
|
+
onOk: this.onOkGridSelectModal,
|
|
287
|
+
onCancel: this.closeGridSelectModal,
|
|
288
|
+
width: refDialogWidth,
|
|
289
|
+
className: refDialogClassName,
|
|
290
|
+
height: refDialogHeight,
|
|
291
|
+
visible: showGridSelectModal
|
|
292
|
+
}));
|
|
293
|
+
}
|
|
294
|
+
}]);
|
|
295
|
+
|
|
296
|
+
return InputRefAddonBtn;
|
|
297
|
+
}(_react["default"].Component);
|
|
298
|
+
|
|
299
|
+
var _default = InputRefAddonBtn;
|
|
300
|
+
exports["default"] = _default;
|