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.
@@ -148,10 +148,12 @@ function ImageSelector(prop) {
148
148
  loadData(searchKey);
149
149
  }, [visible, searchKey]);
150
150
  useEffect(function () {
151
- var val = formRef.current.getFieldsValue();
151
+ var _formRef$current, _formRef$current$getF;
152
+ 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)) || {};
152
153
  var url = val === null || val === void 0 ? void 0 : val[name];
153
154
  if (!url) {
154
- url = formRef.current.getFieldValue(name);
155
+ var _formRef$current2, _formRef$current2$get;
156
+ 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);
155
157
  }
156
158
  if (url) {
157
159
  var urls = url.toString().split(',');
@@ -177,14 +179,14 @@ function ImageSelector(prop) {
177
179
  showSuccess(result.flag.retMsg);
178
180
  // 直接上传
179
181
  if (isDirect) {
180
- var _result$rows$;
182
+ var _result$rows$, _formRef$current3, _formRef$current3$get, _formRef$current4, _formRef$current4$set;
181
183
  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);
182
184
  setImgUrl(img);
183
- var formVal = formRef.current.getFieldsValue();
185
+ 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);
184
186
  var val = _objectSpread({}, formVal);
185
187
  //@ts-ignore
186
188
  val[name] = img;
187
- formRef.current.setFieldsValue(val);
189
+ 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);
188
190
  }
189
191
  } else {
190
192
  var _result$flag2;
@@ -234,7 +236,8 @@ function ImageSelector(prop) {
234
236
  }
235
237
  };
236
238
  var confirmImage = function confirmImage() {
237
- var formVal = formRef.current.getFieldsValue();
239
+ var _formRef$current5, _formRef$current5$get;
240
+ 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);
238
241
  var val = _objectSpread({}, formVal);
239
242
  //@ts-ignore
240
243
  val[name] = selectedUrl.join(',');
@@ -244,9 +247,9 @@ function ImageSelector(prop) {
244
247
  };
245
248
  var clearValue = function clearValue(e) {
246
249
  if (!e || !e.target.value) {
247
- var _formRef$current;
250
+ var _formRef$current6, _formRef$current6$get;
248
251
  setImgUrl('');
249
- var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.getFieldsValue();
252
+ 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)) || {};
250
253
  formValue[name] = '';
251
254
  formRef.current.setFieldsValue(_objectSpread({}, formValue));
252
255
  }
@@ -53,10 +53,10 @@ var InputMultiLine = /*#__PURE__*/React.forwardRef(function (prop, ref) {
53
53
  useEffect(function () {
54
54
  if (defaultValue) {
55
55
  setText(defaultValue);
56
- } else if (name) {
57
- var _formRef$current;
58
- var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.getFieldsValue();
59
- setText(formValue[name]);
56
+ } else if (name && (formRef === null || formRef === void 0 ? void 0 : formRef.current)) {
57
+ var _formRef$current, _formRef$current$getF;
58
+ 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);
59
+ setText(formValue);
60
60
  }
61
61
  }, []);
62
62
  // 显示多行输入时,赋值给多行文本框
@@ -67,10 +67,10 @@ var InputMultiLine = /*#__PURE__*/React.forwardRef(function (prop, ref) {
67
67
  }, [visible, text]);
68
68
  // 输入框值变化时,赋值给表单项
69
69
  useEffect(function () {
70
- var _formRef$current2, _formRef$current3;
71
- var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : _formRef$current2.getFieldsValue();
70
+ var _formRef$current2, _formRef$current2$get, _formRef$current3, _formRef$current3$set;
71
+ 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)) || {};
72
72
  formValue[name] = text;
73
- (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : _formRef$current3.setFieldsValue(_objectSpread({}, formValue));
73
+ 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, _objectSpread({}, formValue));
74
74
  }, [text]);
75
75
  var lineInput = function lineInput(e) {
76
76
  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为查询条件对象,可以通过此方法调整 */
@@ -6,10 +6,11 @@ import _extends from "@babel/runtime/helpers/esm/extends";
6
6
  import "antd/es/button/style";
7
7
  import _Button from "antd/es/button";
8
8
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
9
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
10
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
10
11
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
11
12
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
12
- 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"],
13
+ 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"],
13
14
  _excluded2 = ["current", "pageSize"];
14
15
  import _regeneratorRuntime from "@babel/runtime/regenerator";
15
16
  import React, { useRef, useState, useEffect, useContext, useMemo, useImperativeHandle } from 'react';
@@ -79,6 +80,7 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
79
80
  placement = _prop$placement === void 0 ? 'bottom' : _prop$placement,
80
81
  _prop$arrowPointAtCen = prop.arrowPointAtCenter,
81
82
  arrowPointAtCenter = _prop$arrowPointAtCen === void 0 ? true : _prop$arrowPointAtCen,
83
+ rowKey = prop.rowKey,
82
84
  rest = _objectWithoutProperties(prop, _excluded);
83
85
  //显示输入框绑定的name,如果不设置textName,设置为$name__text
84
86
  var textNameProp = useMemo(function () {
@@ -156,20 +158,35 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
156
158
  // 初始化数据
157
159
  useEffect(function () {
158
160
  setTimeout(function () {
159
- var _formRef$current, _formRef$current2;
160
- var txt = formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.getFieldValue(textNameProp);
161
- var val = formRef === null || formRef === void 0 ? void 0 : (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : _formRef$current2.getFieldValue(name);
161
+ var txt = '',
162
+ val = '';
163
+ if (rowKey) {
164
+ try {
165
+ var _formRef$current, _formRef$current$getF, _formRef$current$getF2;
166
+ 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];
167
+ txt = row === null || row === void 0 ? void 0 : row[textNameProp];
168
+ val = row === null || row === void 0 ? void 0 : row[name];
169
+ } catch (_unused) {}
170
+ } else {
171
+ var _formRef$current2, _formRef$current2$get, _formRef$current3, _formRef$current3$get;
172
+ 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);
173
+ 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);
174
+ }
162
175
  if (txt) {
163
176
  setText(txt);
164
177
  } else if (val) {
165
178
  setText(val);
166
179
  }
167
180
  }, 0);
168
- }, []);
181
+ }, [rowKey]);
169
182
  // 处理返回数据
170
183
  var handleValue = function handleValue(row) {
171
- var _formRef$current3, _formRef$current4;
172
- var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : _formRef$current3.getFieldsValue();
184
+ var _formRef$current4, _formRef$current4$get;
185
+ 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)) || {};
186
+ if (rowKey) {
187
+ formValue = formValue[rowKey] || {};
188
+ }
189
+ if (!formValue) return;
173
190
  var txt;
174
191
  //支持多选
175
192
  if (Array.isArray(row)) {
@@ -204,7 +221,13 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
204
221
  formValue[textNameProp] = txt;
205
222
  setText(txt);
206
223
  setVisible(false);
207
- (_formRef$current4 = formRef.current) === null || _formRef$current4 === void 0 ? void 0 : _formRef$current4.setFieldsValue(_objectSpread({}, formValue));
224
+ if (rowKey) {
225
+ var _formRef$current5, _formRef$current5$set;
226
+ 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, _defineProperty({}, rowKey, formValue));
227
+ } else {
228
+ var _formRef$current6, _formRef$current6$set;
229
+ 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, _objectSpread({}, formValue));
230
+ }
208
231
  onSelectChange === null || onSelectChange === void 0 ? void 0 : onSelectChange(row, formRef);
209
232
  };
210
233
  // 可输入时,回车或失去焦点调接口查询数据
@@ -234,29 +257,41 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
234
257
  };
235
258
  //直接输入不回车,value 和 text 为同一个值
236
259
  var onInput = function onInput(e) {
237
- var _formRef$current5;
238
- var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current5 = formRef.current) === null || _formRef$current5 === void 0 ? void 0 : _formRef$current5.getFieldsValue();
260
+ var _formRef$current7, _formRef$current7$get;
261
+ 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)) || {};
262
+ if (rowKey) {
263
+ formValue = formValue[rowKey] || {};
264
+ }
239
265
  var val = e.target.value;
240
266
  formValue[name] = val;
241
267
  formValue[textNameProp] = val;
242
268
  setText(val);
243
- formRef.current.setFieldsValue(_objectSpread({}, formValue));
269
+ if (rowKey) {
270
+ var _formRef$current8, _formRef$current8$set;
271
+ 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, _defineProperty({}, rowKey, formValue));
272
+ } else {
273
+ var _formRef$current9, _formRef$current9$set;
274
+ 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, _objectSpread({}, formValue));
275
+ }
244
276
  };
245
277
  // 当表单重置或点clear时,处理值
246
278
  var clearValue = function clearValue(e) {
247
279
  if (!e.target.value) {
248
- var _formRef$current6;
280
+ var _formRef$current10, _formRef$current10$ge;
249
281
  setText('');
250
- var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current6 = formRef.current) === null || _formRef$current6 === void 0 ? void 0 : _formRef$current6.getFieldsValue();
282
+ 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)) || {};
283
+ if (rowKey) {
284
+ formValue = formValue[rowKey] || {};
285
+ }
251
286
  formValue[name] = '';
252
287
  formValue[textNameProp] = '';
253
- // 不处理,其它表单自己清空
254
- // if (fillMap) {
255
- // for (let key in fillMap) {
256
- // formValue[key] = '';
257
- // }
258
- // }
259
- formRef.current.setFieldsValue(_objectSpread({}, formValue));
288
+ if (rowKey) {
289
+ var _formRef$current11, _formRef$current11$se;
290
+ 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, _defineProperty({}, rowKey, formValue));
291
+ } else {
292
+ var _formRef$current12, _formRef$current12$se;
293
+ 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, _objectSpread({}, formValue));
294
+ }
260
295
  }
261
296
  };
262
297
  useEffect(function () {
@@ -267,12 +302,18 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
267
302
  }
268
303
  }, [text]);
269
304
  var tableDom = /*#__PURE__*/React.createElement(ProTable, _extends({
305
+ className: "ls-input-table",
270
306
  columns: columns,
271
307
  request: loadData,
272
308
  manualRequest: false,
273
309
  actionRef: tableRef,
274
310
  search: {
275
- labelWidth: labelWidth
311
+ labelWidth: labelWidth,
312
+ optionRender: function optionRender(p, s, _dom) {
313
+ return _dom.filter(function (item) {
314
+ return item.key === 'submit';
315
+ });
316
+ }
276
317
  },
277
318
  options: {
278
319
  density: false,
@@ -308,7 +349,13 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
308
349
  }, "\u786E\u8BA4")];
309
350
  },
310
351
  headerTitle: "\u53CC\u51FB\u9009\u4E2D\u5F53\u524D\u884C\u6570\u636E"
311
- }, tableConfig));
352
+ }, tableConfig, {
353
+ cardProps: {
354
+ bodyStyle: {
355
+ padding: 0
356
+ }
357
+ }
358
+ }));
312
359
  // 处理有值时,可清空
313
360
  useEffect(function () {
314
361
  if (rest.disabled || (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.disabled)) return;
@@ -341,6 +388,12 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
341
388
  }
342
389
  }, loadOnShow ? visible ? tableDom : null : tableDom),
343
390
  trigger: "click",
391
+ overlayInnerStyle: {
392
+ width: 'max-content'
393
+ },
394
+ overlayStyle: {
395
+ width: 'max-content'
396
+ },
344
397
  visible: rest.disabled || (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.disabled) ? false : visible,
345
398
  onVisibleChange: setVisible,
346
399
  getPopupContainer: getPopupContainer,
@@ -382,6 +435,12 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
382
435
  }
383
436
  }, loadOnShow ? visible ? tableDom : null : tableDom),
384
437
  trigger: "click",
438
+ overlayInnerStyle: {
439
+ width: 'max-content'
440
+ },
441
+ overlayStyle: {
442
+ width: 'max-content'
443
+ },
385
444
  visible: rest.disabled || (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.disabled) ? false : visible,
386
445
  onVisibleChange: setVisible,
387
446
  getPopupContainer: getPopupContainer,