dlt-for-react 1.0.13 → 1.0.14

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.
@@ -0,0 +1,301 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _extends2 = require("babel-runtime/helpers/extends");
8
+
9
+ var _extends3 = _interopRequireDefault(_extends2);
10
+
11
+ var _objectWithoutProperties2 = require("babel-runtime/helpers/objectWithoutProperties");
12
+
13
+ var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
14
+
15
+ var _toConsumableArray2 = require("babel-runtime/helpers/toConsumableArray");
16
+
17
+ var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
18
+
19
+ var _getPrototypeOf = require("babel-runtime/core-js/object/get-prototype-of");
20
+
21
+ var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
22
+
23
+ var _keys = require("babel-runtime/core-js/object/keys");
24
+
25
+ var _keys2 = _interopRequireDefault(_keys);
26
+
27
+ var _assign = require("babel-runtime/core-js/object/assign");
28
+
29
+ var _assign2 = _interopRequireDefault(_assign);
30
+
31
+ var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
32
+
33
+ var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
34
+
35
+ var _possibleConstructorReturn2 = require("babel-runtime/helpers/possibleConstructorReturn");
36
+
37
+ var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
38
+
39
+ var _createClass2 = require("babel-runtime/helpers/createClass");
40
+
41
+ var _createClass3 = _interopRequireDefault(_createClass2);
42
+
43
+ var _inherits2 = require("babel-runtime/helpers/inherits");
44
+
45
+ var _inherits3 = _interopRequireDefault(_inherits2);
46
+
47
+ var _select = require("antd/lib/select");
48
+
49
+ var _select2 = _interopRequireDefault(_select);
50
+
51
+ require("antd/lib/select/style");
52
+
53
+ var _react = require("react");
54
+
55
+ var _react2 = _interopRequireDefault(_react);
56
+
57
+ var _propTypes = require("prop-types");
58
+
59
+ var _propTypes2 = _interopRequireDefault(_propTypes);
60
+
61
+ var _NHFetch = require("../../utils/NHFetch");
62
+
63
+ var _NHFetch2 = _interopRequireDefault(_NHFetch);
64
+
65
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
66
+
67
+ /**
68
+ * value和label值都是一样的下拉框
69
+ * 支持本地数据、sign,代码标志(DMK_DMBZ)
70
+ * 除了特有属性,其他同antd Select
71
+ */
72
+ var Option = _select2.default.Option; /*
73
+ * @Description: 高级搜索使用的下拉框
74
+ * @Author: zengweijin
75
+ * @Date: 2019-09-11 10:34:17
76
+ * @LastEditors: jiangzhongxin
77
+ * @LastEditTime: 2023-10-25 16:23:11
78
+ */
79
+
80
+ var HighSelect = function (_React$Component) {
81
+ (0, _inherits3.default)(HighSelect, _React$Component);
82
+ (0, _createClass3.default)(HighSelect, null, [{
83
+ key: "getDerivedStateFromProps",
84
+ value: function getDerivedStateFromProps(nextProps) {
85
+ var updateState = {};
86
+ if ("dataSource" in nextProps) {
87
+ var data = nextProps.dataSource;
88
+ (0, _assign2.default)(updateState, { data: data });
89
+ }
90
+
91
+ if ((0, _keys2.default)(updateState).length > 0) {
92
+ return updateState;
93
+ }
94
+
95
+ return null;
96
+ }
97
+ }]);
98
+
99
+ function HighSelect(props) {
100
+ (0, _classCallCheck3.default)(this, HighSelect);
101
+
102
+ var _this = (0, _possibleConstructorReturn3.default)(this, (HighSelect.__proto__ || (0, _getPrototypeOf2.default)(HighSelect)).call(this, props));
103
+
104
+ _this.loadRemoteData = function (sign) {
105
+ var baseUrl = _this.props.baseUrl || "";
106
+ (0, _NHFetch2.default)(baseUrl + "/proData/selectDataList", "GET", {
107
+ sign: sign,
108
+ t: new Date().getTime()
109
+ }).then(function (res) {
110
+ if (res) {
111
+ _this.parseData(res.data);
112
+ }
113
+ });
114
+ };
115
+
116
+ _this.loadLocalData = function () {
117
+ if (_this.props.dataSource) {
118
+ _this.setState({ data: [].concat((0, _toConsumableArray3.default)(_this.props.dataSource)) });
119
+ }
120
+ };
121
+
122
+ _this.parseData = function (data) {
123
+ if (data) {
124
+ _this.setState({ data: [].concat((0, _toConsumableArray3.default)(data)) });
125
+ } else {
126
+ //如果远程数据为空,则尝试加载本地数据源
127
+ _this.loadLocalData();
128
+ }
129
+ };
130
+
131
+ _this.state = {
132
+ data: []
133
+ };
134
+ return _this;
135
+ }
136
+
137
+ (0, _createClass3.default)(HighSelect, [{
138
+ key: "componentDidMount",
139
+ value: function componentDidMount() {
140
+ var sign = this.props.sign;
141
+ //如果是使用数据源标识,则优先加载远程数据
142
+
143
+ if (sign && sign != "") {
144
+ this.loadRemoteData(sign);
145
+ } else {
146
+ //如果没有使用远程数据,则加载本地数据
147
+ this.loadLocalData();
148
+ }
149
+ }
150
+ //加载远程数据
151
+
152
+
153
+ //加载本地数据
154
+
155
+
156
+ //解析数据
157
+
158
+ }, {
159
+ key: "render",
160
+ value: function render() {
161
+ var _props = this.props,
162
+ filterData = _props.filterData,
163
+ otherprops = (0, _objectWithoutProperties3.default)(_props, ["filterData"]);
164
+ var data = this.state.data;
165
+
166
+ var options = [];
167
+
168
+ //如果有过滤条件
169
+ if (filterData) {
170
+ var type = filterData.type,
171
+ _filterData$filterkey = filterData.filterkeys,
172
+ filterkeys = _filterData$filterkey === undefined ? [] : _filterData$filterkey;
173
+
174
+ switch (type) {
175
+ //过滤掉指定key值
176
+ case "remove":
177
+ {
178
+ var newData = data.filter(function (item) {
179
+ if (filterkeys.find(function (key) {
180
+ return (item.VALUE || item.value) == key;
181
+ })) {
182
+ return false;
183
+ } else {
184
+ return true;
185
+ }
186
+ });
187
+ options = newData.map(function (option) {
188
+ return _react2.default.createElement(
189
+ Option,
190
+ {
191
+ key: option.VALUE || option.value,
192
+ value: option.LABEL || option.label
193
+ },
194
+ option.LABEL || option.label
195
+ );
196
+ });
197
+ break;
198
+ }
199
+ //保留指定key值
200
+ case "save":
201
+ {
202
+ var _newData = data.filter(function (item) {
203
+ if (filterkeys.find(function (key) {
204
+ return (item.VALUE || item.value) == key;
205
+ })) {
206
+ return true;
207
+ } else {
208
+ return false;
209
+ }
210
+ });
211
+ options = _newData.map(function (option) {
212
+ return _react2.default.createElement(
213
+ Option,
214
+ {
215
+ key: option.VALUE || option.value,
216
+ value: option.LABEL || option.label
217
+ },
218
+ option.LABEL || option.label
219
+ );
220
+ });
221
+ break;
222
+ }
223
+ //未找到指定过滤类型,则不做过滤
224
+ default:
225
+ {
226
+ options = data.map(function (option) {
227
+ return _react2.default.createElement(
228
+ Option,
229
+ {
230
+ key: option.VALUE || option.value,
231
+ value: option.LABEL || option.label
232
+ },
233
+ option.LABEL || option.label
234
+ );
235
+ });
236
+ break;
237
+ }
238
+ }
239
+ } else {
240
+ options = data.map(function (option) {
241
+ return _react2.default.createElement(
242
+ Option,
243
+ {
244
+ key: option.VALUE || option.value,
245
+ value: option.LABEL || option.label
246
+ },
247
+ option.LABEL || option.label
248
+ );
249
+ });
250
+ }
251
+
252
+ return _react2.default.createElement(
253
+ "div",
254
+ null,
255
+ _react2.default.createElement(
256
+ _select2.default,
257
+ (0, _extends3.default)({}, otherprops, {
258
+ showSearch: true,
259
+ notFoundContent: "无数据",
260
+ filterOption: function filterOption(input, option) {
261
+ return option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0;
262
+ }
263
+ }),
264
+ options
265
+ )
266
+ );
267
+ }
268
+ }]);
269
+ return HighSelect;
270
+ }(_react2.default.Component);
271
+
272
+ //属性默认值
273
+
274
+
275
+ HighSelect.defaultProps = {
276
+ placeholder: "请选择...",
277
+ disabled: false
278
+ };
279
+
280
+ //属性检查
281
+ HighSelect.propTypes = {
282
+ sign: _propTypes2.default.string, //远程数据源标识
283
+ dataSource: _propTypes2.default.arrayOf(_propTypes2.default.shape({
284
+ value: _propTypes2.default.string,
285
+ label: _propTypes2.default.node
286
+ })), //本地数据源
287
+ // style: PropTypes.object, //样式
288
+ // placeholder: PropTypes.string, //下拉提示
289
+ // disabled: PropTypes.bool, //是否禁用
290
+ // defaultValue: PropTypes.oneOf([PropTypes.string,PropTypes.arrayOf(PropTypes.string)]), //默认值
291
+ // value: PropTypes.oneOf([PropTypes.string,PropTypes.arrayOf(PropTypes.string)]), //初始值
292
+ filterData: _propTypes2.default.shape({
293
+ type: _propTypes2.default.oneOf(["remove", "save"]), //是保留还是过滤掉
294
+ filterkeys: _propTypes2.default.array //保留或过滤的key值
295
+ }), //要过滤掉的Key值
296
+ // onSelect: PropTypes.func,//下拉选项选中时回调
297
+ // onChange: PropTypes.func,//下拉框值变化时回调
298
+ baseUrl: _propTypes2.default.string //请求路径的前缀,可通过改参数控制访问的后端服务,如果不设置,则会去访问当前前端服务对应的后端服务,例如:api/sm-bpm-expansion
299
+ };
300
+
301
+ exports.default = HighSelect;