ls-pro-common 3.0.4 → 3.0.6

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.
@@ -155,10 +155,12 @@ function ImageSelector(prop) {
155
155
  loadData(searchKey);
156
156
  }, [visible, searchKey]);
157
157
  (0, _react.useEffect)(function () {
158
- var val = formRef.current.getFieldsValue();
158
+ var _formRef$current, _formRef$current$getF;
159
+ var val = (formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : (_formRef$current$getF = _formRef$current.getFieldsValue) === null || _formRef$current$getF === void 0 ? void 0 : _formRef$current$getF.call(_formRef$current)) || {};
159
160
  var url = val === null || val === void 0 ? void 0 : val[name];
160
161
  if (!url) {
161
- url = formRef.current.getFieldValue(name);
162
+ var _formRef$current2, _formRef$current2$get;
163
+ url = formRef === null || formRef === void 0 ? void 0 : (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : (_formRef$current2$get = _formRef$current2.getFieldValue) === null || _formRef$current2$get === void 0 ? void 0 : _formRef$current2$get.call(_formRef$current2, name);
162
164
  }
163
165
  if (url) {
164
166
  var urls = url.toString().split(',');
@@ -184,14 +186,14 @@ function ImageSelector(prop) {
184
186
  (0, _utils.showSuccess)(result.flag.retMsg);
185
187
  // 直接上传
186
188
  if (isDirect) {
187
- var _result$rows$;
189
+ var _result$rows$, _formRef$current3, _formRef$current3$get, _formRef$current4, _formRef$current4$set;
188
190
  var img = showImgApi + '?fileName=' + (result === null || result === void 0 ? void 0 : (_result$rows$ = result.rows[0]) === null || _result$rows$ === void 0 ? void 0 : _result$rows$.newFileId);
189
191
  setImgUrl(img);
190
- var formVal = formRef.current.getFieldsValue();
192
+ var formVal = formRef === null || formRef === void 0 ? void 0 : (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : (_formRef$current3$get = _formRef$current3.getFieldsValue) === null || _formRef$current3$get === void 0 ? void 0 : _formRef$current3$get.call(_formRef$current3);
191
193
  var val = (0, _objectSpread2.default)({}, formVal);
192
194
  //@ts-ignore
193
195
  val[name] = img;
194
- formRef.current.setFieldsValue(val);
196
+ formRef === null || formRef === void 0 ? void 0 : (_formRef$current4 = formRef.current) === null || _formRef$current4 === void 0 ? void 0 : (_formRef$current4$set = _formRef$current4.setFieldsValue) === null || _formRef$current4$set === void 0 ? void 0 : _formRef$current4$set.call(_formRef$current4, val);
195
197
  }
196
198
  } else {
197
199
  var _result$flag2;
@@ -241,7 +243,8 @@ function ImageSelector(prop) {
241
243
  }
242
244
  };
243
245
  var confirmImage = function confirmImage() {
244
- var formVal = formRef.current.getFieldsValue();
246
+ var _formRef$current5, _formRef$current5$get;
247
+ var formVal = formRef === null || formRef === void 0 ? void 0 : (_formRef$current5 = formRef.current) === null || _formRef$current5 === void 0 ? void 0 : (_formRef$current5$get = _formRef$current5.getFieldsValue) === null || _formRef$current5$get === void 0 ? void 0 : _formRef$current5$get.call(_formRef$current5);
245
248
  var val = (0, _objectSpread2.default)({}, formVal);
246
249
  //@ts-ignore
247
250
  val[name] = selectedUrl.join(',');
@@ -251,9 +254,9 @@ function ImageSelector(prop) {
251
254
  };
252
255
  var clearValue = function clearValue(e) {
253
256
  if (!e || !e.target.value) {
254
- var _formRef$current;
257
+ var _formRef$current6, _formRef$current6$get;
255
258
  setImgUrl('');
256
- var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.getFieldsValue();
259
+ var formValue = (formRef === null || formRef === void 0 ? void 0 : (_formRef$current6 = formRef.current) === null || _formRef$current6 === void 0 ? void 0 : (_formRef$current6$get = _formRef$current6.getFieldsValue) === null || _formRef$current6$get === void 0 ? void 0 : _formRef$current6$get.call(_formRef$current6)) || {};
257
260
  formValue[name] = '';
258
261
  formRef.current.setFieldsValue((0, _objectSpread2.default)({}, formValue));
259
262
  }
@@ -61,10 +61,10 @@ var InputMultiLine = /*#__PURE__*/_react.default.forwardRef(function (prop, ref)
61
61
  (0, _react.useEffect)(function () {
62
62
  if (defaultValue) {
63
63
  setText(defaultValue);
64
- } else if (name) {
65
- var _formRef$current;
66
- var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.getFieldsValue();
67
- setText(formValue[name]);
64
+ } else if (name && (formRef === null || formRef === void 0 ? void 0 : formRef.current)) {
65
+ var _formRef$current, _formRef$current$getF;
66
+ var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : (_formRef$current$getF = _formRef$current.getFieldValue) === null || _formRef$current$getF === void 0 ? void 0 : _formRef$current$getF.call(_formRef$current, name);
67
+ setText(formValue);
68
68
  }
69
69
  }, []);
70
70
  // 显示多行输入时,赋值给多行文本框
@@ -75,10 +75,10 @@ var InputMultiLine = /*#__PURE__*/_react.default.forwardRef(function (prop, ref)
75
75
  }, [visible, text]);
76
76
  // 输入框值变化时,赋值给表单项
77
77
  (0, _react.useEffect)(function () {
78
- var _formRef$current2, _formRef$current3;
79
- var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : _formRef$current2.getFieldsValue();
78
+ var _formRef$current2, _formRef$current2$get, _formRef$current3, _formRef$current3$set;
79
+ var formValue = (formRef === null || formRef === void 0 ? void 0 : (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : (_formRef$current2$get = _formRef$current2.getFieldsValue) === null || _formRef$current2$get === void 0 ? void 0 : _formRef$current2$get.call(_formRef$current2)) || {};
80
80
  formValue[name] = text;
81
- (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : _formRef$current3.setFieldsValue((0, _objectSpread2.default)({}, formValue));
81
+ formRef === null || formRef === void 0 ? void 0 : (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : (_formRef$current3$set = _formRef$current3.setFieldsValue) === null || _formRef$current3$set === void 0 ? void 0 : _formRef$current3$set.call(_formRef$current3, (0, _objectSpread2.default)({}, formValue));
82
82
  }, [text]);
83
83
  var lineInput = function lineInput(e) {
84
84
  var line = (e.target.value || '').split('\n').filter(function (o, i) {
@@ -39,6 +39,7 @@ export declare type InputTableProps = ProFormItemProps<InputProps> & {
39
39
  loadOnShow?: boolean;
40
40
  placement?: TooltipPlacement;
41
41
  arrowPointAtCenter?: boolean;
42
+ rowKey?: any;
42
43
  /**@name 选择行事件 */
43
44
  onSelectChange?: (item: any, formRef?: any) => void;
44
45
  /**@name 加载之前事件,param为查询条件对象,可以通过此方法调整 */
@@ -93,6 +94,7 @@ declare const InputTable: React.ForwardRefExoticComponent<{
93
94
  loadOnShow?: boolean | undefined;
94
95
  placement?: TooltipPlacement | undefined;
95
96
  arrowPointAtCenter?: boolean | undefined;
97
+ rowKey?: any;
96
98
  /**@name 选择行事件 */
97
99
  onSelectChange?: ((item: any, formRef?: any) => void) | undefined;
98
100
  /**@name 加载之前事件,param为查询条件对象,可以通过此方法调整 */
@@ -15,6 +15,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
15
15
  require("antd/es/button/style");
16
16
  var _button = _interopRequireDefault(require("antd/es/button"));
17
17
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
18
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
18
19
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
19
20
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
20
21
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
@@ -24,7 +25,7 @@ var _lsProForm = require("ls-pro-form");
24
25
  var _icons = require("@ant-design/icons");
25
26
  var _http = require("../http");
26
27
  var _utils = require("../utils");
27
- var _excluded = ["columns", "url", "textName", "name", "tableConfig", "tableHeight", "tableWidth", "readonly", "multiple", "valueField", "labelWidth", "textField", "onSelectChange", "beforeLoad", "afterLoad", "isV2", "allowClear", "keepSelect", "fieldProps", "searchField", "fillMap", "loadOnShow", "triggerCheck", "getPopupContainer", "placement", "arrowPointAtCenter"],
28
+ var _excluded = ["columns", "url", "textName", "name", "tableConfig", "tableHeight", "tableWidth", "readonly", "multiple", "valueField", "labelWidth", "textField", "onSelectChange", "beforeLoad", "afterLoad", "isV2", "allowClear", "keepSelect", "fieldProps", "searchField", "fillMap", "loadOnShow", "triggerCheck", "getPopupContainer", "placement", "arrowPointAtCenter", "rowKey"],
28
29
  _excluded2 = ["current", "pageSize"];
29
30
  var InputTable = /*#__PURE__*/_react.default.forwardRef(function (prop, ref) {
30
31
  //@ts-ignore
@@ -87,6 +88,7 @@ var InputTable = /*#__PURE__*/_react.default.forwardRef(function (prop, ref) {
87
88
  placement = _prop$placement === void 0 ? 'bottom' : _prop$placement,
88
89
  _prop$arrowPointAtCen = prop.arrowPointAtCenter,
89
90
  arrowPointAtCenter = _prop$arrowPointAtCen === void 0 ? true : _prop$arrowPointAtCen,
91
+ rowKey = prop.rowKey,
90
92
  rest = (0, _objectWithoutProperties2.default)(prop, _excluded);
91
93
  //显示输入框绑定的name,如果不设置textName,设置为$name__text
92
94
  var textNameProp = (0, _react.useMemo)(function () {
@@ -164,20 +166,35 @@ var InputTable = /*#__PURE__*/_react.default.forwardRef(function (prop, ref) {
164
166
  // 初始化数据
165
167
  (0, _react.useEffect)(function () {
166
168
  setTimeout(function () {
167
- var _formRef$current, _formRef$current2;
168
- var txt = formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.getFieldValue(textNameProp);
169
- var val = formRef === null || formRef === void 0 ? void 0 : (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : _formRef$current2.getFieldValue(name);
169
+ var txt = '',
170
+ val = '';
171
+ if (rowKey) {
172
+ try {
173
+ var _formRef$current, _formRef$current$getF, _formRef$current$getF2;
174
+ var row = formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : (_formRef$current$getF = _formRef$current.getFieldsValue) === null || _formRef$current$getF === void 0 ? void 0 : (_formRef$current$getF2 = _formRef$current$getF.call(_formRef$current)) === null || _formRef$current$getF2 === void 0 ? void 0 : _formRef$current$getF2[rowKey];
175
+ txt = row === null || row === void 0 ? void 0 : row[textNameProp];
176
+ val = row === null || row === void 0 ? void 0 : row[name];
177
+ } catch (_unused) {}
178
+ } else {
179
+ var _formRef$current2, _formRef$current2$get, _formRef$current3, _formRef$current3$get;
180
+ txt = formRef === null || formRef === void 0 ? void 0 : (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : (_formRef$current2$get = _formRef$current2.getFieldValue) === null || _formRef$current2$get === void 0 ? void 0 : _formRef$current2$get.call(_formRef$current2, textNameProp);
181
+ val = formRef === null || formRef === void 0 ? void 0 : (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : (_formRef$current3$get = _formRef$current3.getFieldValue) === null || _formRef$current3$get === void 0 ? void 0 : _formRef$current3$get.call(_formRef$current3, name);
182
+ }
170
183
  if (txt) {
171
184
  setText(txt);
172
185
  } else if (val) {
173
186
  setText(val);
174
187
  }
175
188
  }, 0);
176
- }, []);
189
+ }, [rowKey]);
177
190
  // 处理返回数据
178
191
  var handleValue = function handleValue(row) {
179
- var _formRef$current3, _formRef$current4;
180
- var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : _formRef$current3.getFieldsValue();
192
+ var _formRef$current4, _formRef$current4$get;
193
+ var formValue = (formRef === null || formRef === void 0 ? void 0 : (_formRef$current4 = formRef.current) === null || _formRef$current4 === void 0 ? void 0 : (_formRef$current4$get = _formRef$current4.getFieldsValue) === null || _formRef$current4$get === void 0 ? void 0 : _formRef$current4$get.call(_formRef$current4)) || {};
194
+ if (rowKey) {
195
+ formValue = formValue[rowKey] || {};
196
+ }
197
+ if (!formValue) return;
181
198
  var txt;
182
199
  //支持多选
183
200
  if (Array.isArray(row)) {
@@ -212,7 +229,13 @@ var InputTable = /*#__PURE__*/_react.default.forwardRef(function (prop, ref) {
212
229
  formValue[textNameProp] = txt;
213
230
  setText(txt);
214
231
  setVisible(false);
215
- (_formRef$current4 = formRef.current) === null || _formRef$current4 === void 0 ? void 0 : _formRef$current4.setFieldsValue((0, _objectSpread2.default)({}, formValue));
232
+ if (rowKey) {
233
+ var _formRef$current5, _formRef$current5$set;
234
+ formRef === null || formRef === void 0 ? void 0 : (_formRef$current5 = formRef.current) === null || _formRef$current5 === void 0 ? void 0 : (_formRef$current5$set = _formRef$current5.setFieldsValue) === null || _formRef$current5$set === void 0 ? void 0 : _formRef$current5$set.call(_formRef$current5, (0, _defineProperty2.default)({}, rowKey, formValue));
235
+ } else {
236
+ var _formRef$current6, _formRef$current6$set;
237
+ formRef === null || formRef === void 0 ? void 0 : (_formRef$current6 = formRef.current) === null || _formRef$current6 === void 0 ? void 0 : (_formRef$current6$set = _formRef$current6.setFieldsValue) === null || _formRef$current6$set === void 0 ? void 0 : _formRef$current6$set.call(_formRef$current6, (0, _objectSpread2.default)({}, formValue));
238
+ }
216
239
  onSelectChange === null || onSelectChange === void 0 ? void 0 : onSelectChange(row, formRef);
217
240
  };
218
241
  // 可输入时,回车或失去焦点调接口查询数据
@@ -242,29 +265,41 @@ var InputTable = /*#__PURE__*/_react.default.forwardRef(function (prop, ref) {
242
265
  };
243
266
  //直接输入不回车,value 和 text 为同一个值
244
267
  var onInput = function onInput(e) {
245
- var _formRef$current5;
246
- var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current5 = formRef.current) === null || _formRef$current5 === void 0 ? void 0 : _formRef$current5.getFieldsValue();
268
+ var _formRef$current7, _formRef$current7$get;
269
+ var formValue = (formRef === null || formRef === void 0 ? void 0 : (_formRef$current7 = formRef.current) === null || _formRef$current7 === void 0 ? void 0 : (_formRef$current7$get = _formRef$current7.getFieldsValue) === null || _formRef$current7$get === void 0 ? void 0 : _formRef$current7$get.call(_formRef$current7)) || {};
270
+ if (rowKey) {
271
+ formValue = formValue[rowKey] || {};
272
+ }
247
273
  var val = e.target.value;
248
274
  formValue[name] = val;
249
275
  formValue[textNameProp] = val;
250
276
  setText(val);
251
- formRef.current.setFieldsValue((0, _objectSpread2.default)({}, formValue));
277
+ if (rowKey) {
278
+ var _formRef$current8, _formRef$current8$set;
279
+ formRef === null || formRef === void 0 ? void 0 : (_formRef$current8 = formRef.current) === null || _formRef$current8 === void 0 ? void 0 : (_formRef$current8$set = _formRef$current8.setFieldsValue) === null || _formRef$current8$set === void 0 ? void 0 : _formRef$current8$set.call(_formRef$current8, (0, _defineProperty2.default)({}, rowKey, formValue));
280
+ } else {
281
+ var _formRef$current9, _formRef$current9$set;
282
+ formRef === null || formRef === void 0 ? void 0 : (_formRef$current9 = formRef.current) === null || _formRef$current9 === void 0 ? void 0 : (_formRef$current9$set = _formRef$current9.setFieldsValue) === null || _formRef$current9$set === void 0 ? void 0 : _formRef$current9$set.call(_formRef$current9, (0, _objectSpread2.default)({}, formValue));
283
+ }
252
284
  };
253
285
  // 当表单重置或点clear时,处理值
254
286
  var clearValue = function clearValue(e) {
255
287
  if (!e.target.value) {
256
- var _formRef$current6;
288
+ var _formRef$current10, _formRef$current10$ge;
257
289
  setText('');
258
- var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current6 = formRef.current) === null || _formRef$current6 === void 0 ? void 0 : _formRef$current6.getFieldsValue();
290
+ var formValue = (formRef === null || formRef === void 0 ? void 0 : (_formRef$current10 = formRef.current) === null || _formRef$current10 === void 0 ? void 0 : (_formRef$current10$ge = _formRef$current10.getFieldsValue) === null || _formRef$current10$ge === void 0 ? void 0 : _formRef$current10$ge.call(_formRef$current10)) || {};
291
+ if (rowKey) {
292
+ formValue = formValue[rowKey] || {};
293
+ }
259
294
  formValue[name] = '';
260
295
  formValue[textNameProp] = '';
261
- // 不处理,其它表单自己清空
262
- // if (fillMap) {
263
- // for (let key in fillMap) {
264
- // formValue[key] = '';
265
- // }
266
- // }
267
- formRef.current.setFieldsValue((0, _objectSpread2.default)({}, formValue));
296
+ if (rowKey) {
297
+ var _formRef$current11, _formRef$current11$se;
298
+ formRef === null || formRef === void 0 ? void 0 : (_formRef$current11 = formRef.current) === null || _formRef$current11 === void 0 ? void 0 : (_formRef$current11$se = _formRef$current11.setFieldsValue) === null || _formRef$current11$se === void 0 ? void 0 : _formRef$current11$se.call(_formRef$current11, (0, _defineProperty2.default)({}, rowKey, formValue));
299
+ } else {
300
+ var _formRef$current12, _formRef$current12$se;
301
+ formRef === null || formRef === void 0 ? void 0 : (_formRef$current12 = formRef.current) === null || _formRef$current12 === void 0 ? void 0 : (_formRef$current12$se = _formRef$current12.setFieldsValue) === null || _formRef$current12$se === void 0 ? void 0 : _formRef$current12$se.call(_formRef$current12, (0, _objectSpread2.default)({}, formValue));
302
+ }
268
303
  }
269
304
  };
270
305
  (0, _react.useEffect)(function () {
@@ -275,12 +310,18 @@ var InputTable = /*#__PURE__*/_react.default.forwardRef(function (prop, ref) {
275
310
  }
276
311
  }, [text]);
277
312
  var tableDom = /*#__PURE__*/_react.default.createElement(_lsProTable.default, (0, _extends2.default)({
313
+ className: "ls-input-table",
278
314
  columns: columns,
279
315
  request: loadData,
280
316
  manualRequest: false,
281
317
  actionRef: tableRef,
282
318
  search: {
283
- labelWidth: labelWidth
319
+ labelWidth: labelWidth,
320
+ optionRender: function optionRender(p, s, _dom) {
321
+ return _dom.filter(function (item) {
322
+ return item.key === 'submit';
323
+ });
324
+ }
284
325
  },
285
326
  options: {
286
327
  density: false,
@@ -316,7 +357,13 @@ var InputTable = /*#__PURE__*/_react.default.forwardRef(function (prop, ref) {
316
357
  }, "\u786E\u8BA4")];
317
358
  },
318
359
  headerTitle: "\u53CC\u51FB\u9009\u4E2D\u5F53\u524D\u884C\u6570\u636E"
319
- }, tableConfig));
360
+ }, tableConfig, {
361
+ cardProps: {
362
+ bodyStyle: {
363
+ padding: 0
364
+ }
365
+ }
366
+ }));
320
367
  // 处理有值时,可清空
321
368
  (0, _react.useEffect)(function () {
322
369
  if (rest.disabled || (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.disabled)) return;
@@ -349,6 +396,12 @@ var InputTable = /*#__PURE__*/_react.default.forwardRef(function (prop, ref) {
349
396
  }
350
397
  }, loadOnShow ? visible ? tableDom : null : tableDom),
351
398
  trigger: "click",
399
+ overlayInnerStyle: {
400
+ width: 'max-content'
401
+ },
402
+ overlayStyle: {
403
+ width: 'max-content'
404
+ },
352
405
  visible: rest.disabled || (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.disabled) ? false : visible,
353
406
  onVisibleChange: setVisible,
354
407
  getPopupContainer: getPopupContainer,
@@ -390,6 +443,12 @@ var InputTable = /*#__PURE__*/_react.default.forwardRef(function (prop, ref) {
390
443
  }
391
444
  }, loadOnShow ? visible ? tableDom : null : tableDom),
392
445
  trigger: "click",
446
+ overlayInnerStyle: {
447
+ width: 'max-content'
448
+ },
449
+ overlayStyle: {
450
+ width: 'max-content'
451
+ },
393
452
  visible: rest.disabled || (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.disabled) ? false : visible,
394
453
  onVisibleChange: setVisible,
395
454
  getPopupContainer: getPopupContainer,