ls-pro-common 3.0.96 → 3.0.97

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.
@@ -6,7 +6,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
6
6
  import _regeneratorRuntime from "@babel/runtime/regenerator";
7
7
  import React, { useRef, useState, useEffect, useImperativeHandle } from 'react';
8
8
  import { httpGet } from '../http';
9
- import { getCache, setCache, treeEach, isSaasVersion, toGatewayUrl } from '../utils';
9
+ import { getCache, setCache, treeEach } from '../utils';
10
10
  var AreaCascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
11
11
  var _useState = useState([]),
12
12
  _useState2 = _slicedToArray(_useState, 2),
@@ -34,14 +34,11 @@ var AreaCascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
34
34
  return _context.abrupt("return");
35
35
  case 4:
36
36
  api = '/petrel/petrel-location-center-api/sysAdministrativeDivision/allByTree';
37
- if (isSaasVersion()) {
38
- api = toGatewayUrl('/tenant-mdm-api/sysAdministrativeDivision/allByTree');
39
- }
40
- _context.next = 8;
37
+ _context.next = 7;
41
38
  return httpGet(api, {}, false);
42
- case 8:
39
+ case 7:
43
40
  result = _context.sent;
44
- opts = (isSaasVersion() ? result.data : result.rows) || [];
41
+ opts = result.rows || [];
45
42
  treeEach(opts, function (item) {
46
43
  item.label = item.name;
47
44
  item.value = item.id;
@@ -55,7 +52,7 @@ var AreaCascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
55
52
  });
56
53
  setCache('areaOptions', opts, true);
57
54
  setOptions(opts);
58
- case 13:
55
+ case 12:
59
56
  case "end":
60
57
  return _context.stop();
61
58
  }
@@ -9,9 +9,8 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
9
9
  import _regeneratorRuntime from "@babel/runtime/regenerator";
10
10
  import React, { useRef, useState, useEffect, useImperativeHandle } from 'react';
11
11
  import { httpGet } from '../http';
12
- import { getCache, setCache, treeEach, isSaasVersion } from '../utils';
12
+ import { getCache, setCache, treeEach } from '../utils';
13
13
  import './common.less';
14
- import { toGatewayUrl } from 'ls-pro-table';
15
14
  var AreaPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
16
15
  var propsConfig = _objectSpread({
17
16
  getPopupContainer: function getPopupContainer(triggerNode) {
@@ -94,14 +93,11 @@ var AreaPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
94
93
  return _context.abrupt("return");
95
94
  case 3:
96
95
  api = '/petrel/petrel-location-center-api/sysAdministrativeDivision/allByTree';
97
- if (isSaasVersion()) {
98
- api = toGatewayUrl('/tenant-mdm-api/sysAdministrativeDivision/allByTree');
99
- }
100
- _context.next = 7;
96
+ _context.next = 6;
101
97
  return httpGet(api, {}, false);
102
- case 7:
98
+ case 6:
103
99
  result = _context.sent;
104
- opts = (isSaasVersion() ? result.data : result.rows) || [];
100
+ opts = result.rows || [];
105
101
  treeEach(opts, function (item) {
106
102
  item.label = item.name;
107
103
  item.value = item.id;
@@ -115,7 +111,7 @@ var AreaPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
115
111
  setCache('areaOptionsPanel', opts, true);
116
112
  setOptions(opts);
117
113
  setShowData(opts);
118
- case 13:
114
+ case 12:
119
115
  case "end":
120
116
  return _context.stop();
121
117
  }
@@ -5,11 +5,11 @@ import _Popover from "antd/es/popover";
5
5
  import _extends from "@babel/runtime/helpers/esm/extends";
6
6
  import "antd/es/button/style";
7
7
  import _Button from "antd/es/button";
8
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
8
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
9
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
10
10
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
11
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
11
12
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
12
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
13
13
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
14
14
  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", "method", "changeOnSelect", "record"],
15
15
  _excluded2 = ["current", "pageSize"];
@@ -39,11 +39,6 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
39
39
  text = _useState6[0],
40
40
  setText = _useState6[1];
41
41
  var inputRef = useRef();
42
- useImperativeHandle(ref, function () {
43
- return _objectSpread(_objectSpread({}, inputRef.current), {}, {
44
- clear: handleClear
45
- });
46
- });
47
42
  var columns = prop.columns,
48
43
  url = prop.url,
49
44
  textName = prop.textName,
@@ -124,6 +119,23 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
124
119
  if (col) return col.searchField || col.dataIndex;
125
120
  return textField || valueField;
126
121
  }, [columns, searchField, valueField, textField]);
122
+ var getFormValue = function getFormValue() {
123
+ var _formRef$current2, _formRef$current2$get;
124
+ if (rowKey) {
125
+ var _formRef$current, _formRef$current$getF, _formRef$current$getF2;
126
+ return 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];
127
+ }
128
+ return 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);
129
+ };
130
+ var setFormValue = function setFormValue(formValue) {
131
+ if (rowKey) {
132
+ var _formRef$current3, _formRef$current3$set;
133
+ 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, _defineProperty({}, rowKey, formValue));
134
+ } else {
135
+ var _formRef$current4, _formRef$current4$set;
136
+ 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, formValue);
137
+ }
138
+ };
127
139
  var loadData = /*#__PURE__*/function () {
128
140
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(param) {
129
141
  var current, pageSize, restParams, data, _tableRef$current, _tableRef$current$cle, result, rows, formValue, val, _selectRowRef$current, arr, pageSelectedRows;
@@ -209,40 +221,6 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
209
221
  return _ref.apply(this, arguments);
210
222
  };
211
223
  }();
212
- var getFormValue = function getFormValue() {
213
- var _formRef$current2, _formRef$current2$get;
214
- if (rowKey) {
215
- var _formRef$current, _formRef$current$getF, _formRef$current$getF2;
216
- return 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];
217
- }
218
- return 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);
219
- };
220
- var setFormValue = function setFormValue(formValue) {
221
- if (rowKey) {
222
- var _formRef$current3, _formRef$current3$set;
223
- 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, _defineProperty({}, rowKey, formValue));
224
- } else {
225
- var _formRef$current4, _formRef$current4$set;
226
- 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, formValue);
227
- }
228
- };
229
- // 初始化数据,主要设置名称
230
- useEffect(function () {
231
- var _formValue$textNamePr, _formValue$name;
232
- var formValue = getFormValue();
233
- if (!formValue) return;
234
- var txt = (_formValue$textNamePr = formValue === null || formValue === void 0 ? void 0 : formValue[textNameProp]) !== null && _formValue$textNamePr !== void 0 ? _formValue$textNamePr : record === null || record === void 0 ? void 0 : record[textNameProp];
235
- var val = (_formValue$name = formValue === null || formValue === void 0 ? void 0 : formValue[name]) !== null && _formValue$name !== void 0 ? _formValue$name : record === null || record === void 0 ? void 0 : record[name];
236
- setText(txt !== null && txt !== void 0 ? txt : val);
237
- if (val && !txt) {
238
- formValue[textNameProp] = val;
239
- setFormValue(formValue);
240
- // 多值选择或选择的初始值不在第一页时显示有问题
241
- if (textField !== valueField) {
242
- initName(val);
243
- }
244
- }
245
- }, [rowKey]);
246
224
  var initName = function initName(val) {
247
225
  var _columns$find;
248
226
  if (!val) return;
@@ -272,6 +250,23 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
272
250
  setFormValue(formValue);
273
251
  });
274
252
  };
253
+ // 初始化数据,主要设置名称
254
+ useEffect(function () {
255
+ var _formValue$textNamePr, _formValue$name;
256
+ var formValue = getFormValue();
257
+ if (!formValue) return;
258
+ var txt = (_formValue$textNamePr = formValue === null || formValue === void 0 ? void 0 : formValue[textNameProp]) !== null && _formValue$textNamePr !== void 0 ? _formValue$textNamePr : record === null || record === void 0 ? void 0 : record[textNameProp];
259
+ var val = (_formValue$name = formValue === null || formValue === void 0 ? void 0 : formValue[name]) !== null && _formValue$name !== void 0 ? _formValue$name : record === null || record === void 0 ? void 0 : record[name];
260
+ setText(txt !== null && txt !== void 0 ? txt : val);
261
+ if (val && !txt) {
262
+ formValue[textNameProp] = val;
263
+ setFormValue(formValue);
264
+ // 多值选择或选择的初始值不在第一页时显示有问题
265
+ if (textField !== valueField) {
266
+ initName(val);
267
+ }
268
+ }
269
+ }, [rowKey]);
275
270
  // 处理返回数据
276
271
  var handleValue = function handleValue(row) {
277
272
  var close = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
@@ -376,6 +371,11 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
376
371
  }
377
372
  }
378
373
  };
374
+ useImperativeHandle(ref, function () {
375
+ return _objectSpread(_objectSpread({}, inputRef.current), {}, {
376
+ clear: handleClear
377
+ });
378
+ });
379
379
  useEffect(function () {
380
380
  if (!text && multiple) {
381
381
  var _tableRef$current3, _tableRef$current3$cl;
package/es/http/index.js CHANGED
@@ -2,7 +2,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  import { extend } from 'umi-request';
5
- import { getCache, getUrlQuery, setUrlQuery, getCookie, getResourceProps, showError, httpError, toGatewayUrl, reLogin, showLoading, exitLoading, isSaasVersion } from '../utils';
5
+ import { getCache, getUrlQuery, setUrlQuery, getCookie, getResourceProps, showError, httpError, toGatewayUrl, reLogin, showLoading, exitLoading, getBrowserId } from '../utils';
6
6
  //默认超时时间为1分钟
7
7
  var request = extend({
8
8
  timeout: 60000
@@ -14,6 +14,16 @@ var httpStatus = {
14
14
  503: '请求的服务器异常',
15
15
  504: '请求服务超时'
16
16
  };
17
+ var browserId = '';
18
+ (function () {
19
+ setTimeout(function () {
20
+ try {
21
+ getBrowserId().then(function (id) {
22
+ browserId = id;
23
+ });
24
+ } catch (_unused) {}
25
+ }, 0);
26
+ })();
17
27
  /** 请求拦截器,统一添加token */
18
28
  request.interceptors.request.use(function (url, options) {
19
29
  var _options$params;
@@ -24,6 +34,11 @@ request.interceptors.request.use(function (url, options) {
24
34
  // @ts-ignore
25
35
  options.headers['token'] = token;
26
36
  }
37
+ // 处理浏览器指纹
38
+ if (browserId) {
39
+ // @ts-ignore
40
+ options.headers['browserId'] = browserId;
41
+ }
27
42
  // 处理门店
28
43
  var shopNo = getCache('shopNo', true) || getCache('shopNo');
29
44
  if (shopNo) {
@@ -289,9 +304,6 @@ export function getDict(dictCode) {
289
304
  var needGateWay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
290
305
  var timeout = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 60000;
291
306
  var api = '/lesoon-integration/sysDictDtl/listByProperties';
292
- if (isSaasVersion()) {
293
- api = '/tenant-integration-api/sysDictDtl/listByProperties';
294
- }
295
307
  var param = {
296
308
  dictCode: dictCode
297
309
  };
@@ -311,9 +311,29 @@ export declare const openPageInMain: (option: {
311
311
  data?: any;
312
312
  ifRefreshTarget?: boolean;
313
313
  }) => void;
314
+ /** 显示加载 */
314
315
  export declare const showLoading: (text?: string) => void;
316
+ /** 退出加载 */
315
317
  export declare const exitLoading: () => void;
318
+ /** 处理主题 */
316
319
  export declare const handleTheme: () => void;
320
+ /**
321
+ * 睡眠
322
+ *
323
+ * @param secord 秒
324
+ * @returns
325
+ */
317
326
  export declare const sleep: (secord: number) => Promise<unknown>;
327
+ /**
328
+ * 通用下载文件方法
329
+ *
330
+ * @param url 文件地址
331
+ * @param fileName 文件名
332
+ */
318
333
  export declare const downloadFile: (url: string, fileName?: string | undefined) => void;
319
- export declare const isSaasVersion: () => boolean;
334
+ /**
335
+ * 获取浏览器指纹 基于fingerprintjs
336
+ *
337
+ * @returns 浏览器指纹
338
+ */
339
+ export declare const getBrowserId: () => Promise<string>;
package/es/utils/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
1
2
  import "antd/es/spin/style";
2
3
  import _Spin from "antd/es/spin";
3
4
  import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
@@ -7,10 +8,12 @@ import _Modal from "antd/es/modal";
7
8
  import "antd/es/message/style";
8
9
  import _message from "antd/es/message";
9
10
  import _typeof from "@babel/runtime/helpers/esm/typeof";
11
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
10
12
  import ReactDOM from 'react-dom';
11
13
  import { QuestionCircleOutlined } from '@ant-design/icons';
12
14
  import { httpPost } from '../http';
13
15
  import React from 'react';
16
+ import FingerprintJS from '@fingerprintjs/fingerprintjs';
14
17
  export { throttle, debounce } from 'lodash';
15
18
  /**
16
19
  * 获取 url 参数
@@ -865,6 +868,7 @@ export var openPageInMain = function openPageInMain(option) {
865
868
  param: option
866
869
  });
867
870
  };
871
+ /** 显示加载 */
868
872
  export var showLoading = function showLoading() {
869
873
  var text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '处理中...';
870
874
  var loading = document.getElementById('myloading');
@@ -877,6 +881,7 @@ export var showLoading = function showLoading() {
877
881
  var pNode = getFullScreenElement() || document.body;
878
882
  pNode.appendChild(loadWrapper);
879
883
  };
884
+ /** 退出加载 */
880
885
  export var exitLoading = function exitLoading() {
881
886
  var loading = document.getElementById('myloading');
882
887
  if (loading) {
@@ -884,12 +889,19 @@ export var exitLoading = function exitLoading() {
884
889
  (_loading$parentNode = loading.parentNode) === null || _loading$parentNode === void 0 ? void 0 : _loading$parentNode.removeChild(loading);
885
890
  }
886
891
  };
892
+ /** 处理主题 */
887
893
  export var handleTheme = function handleTheme() {
888
894
  var theme = getCache('theme');
889
895
  if (theme) {
890
896
  document.body.classList.add('theme-' + theme);
891
897
  }
892
898
  };
899
+ /**
900
+ * 睡眠
901
+ *
902
+ * @param secord 秒
903
+ * @returns
904
+ */
893
905
  export var sleep = function sleep(secord) {
894
906
  return new Promise(function (resolve) {
895
907
  setTimeout(function () {
@@ -897,6 +909,12 @@ export var sleep = function sleep(secord) {
897
909
  }, secord * 1000);
898
910
  });
899
911
  };
912
+ /**
913
+ * 通用下载文件方法
914
+ *
915
+ * @param url 文件地址
916
+ * @param fileName 文件名
917
+ */
900
918
  export var downloadFile = function downloadFile(url, fileName) {
901
919
  var a = document.createElement('a');
902
920
  a.href = url;
@@ -916,6 +934,33 @@ export var downloadFile = function downloadFile(url, fileName) {
916
934
  a.click();
917
935
  document.body.removeChild(a);
918
936
  };
919
- export var isSaasVersion = function isSaasVersion() {
920
- return (getCache('TENANT') || '') === '1';
921
- };
937
+ /**
938
+ * 获取浏览器指纹 基于fingerprintjs
939
+ *
940
+ * @returns 浏览器指纹
941
+ */
942
+ export var getBrowserId = /*#__PURE__*/function () {
943
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
944
+ var fp, fingerprint;
945
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
946
+ while (1) switch (_context.prev = _context.next) {
947
+ case 0:
948
+ _context.next = 2;
949
+ return FingerprintJS.load();
950
+ case 2:
951
+ fp = _context.sent;
952
+ _context.next = 5;
953
+ return fp.get();
954
+ case 5:
955
+ fingerprint = _context.sent;
956
+ return _context.abrupt("return", fingerprint.visitorId);
957
+ case 7:
958
+ case "end":
959
+ return _context.stop();
960
+ }
961
+ }, _callee);
962
+ }));
963
+ return function getBrowserId() {
964
+ return _ref.apply(this, arguments);
965
+ };
966
+ }();
@@ -6,7 +6,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
6
6
  import _regeneratorRuntime from "@babel/runtime/regenerator";
7
7
  import React, { useRef, useState, useEffect, useImperativeHandle } from 'react';
8
8
  import { httpGet } from '../http';
9
- import { getCache, setCache, treeEach, isSaasVersion, toGatewayUrl } from '../utils';
9
+ import { getCache, setCache, treeEach } from '../utils';
10
10
  var AreaCascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
11
11
  var _useState = useState([]),
12
12
  _useState2 = _slicedToArray(_useState, 2),
@@ -34,14 +34,11 @@ var AreaCascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
34
34
  return _context.abrupt("return");
35
35
  case 4:
36
36
  api = '/petrel/petrel-location-center-api/sysAdministrativeDivision/allByTree';
37
- if (isSaasVersion()) {
38
- api = toGatewayUrl('/tenant-mdm-api/sysAdministrativeDivision/allByTree');
39
- }
40
- _context.next = 8;
37
+ _context.next = 7;
41
38
  return httpGet(api, {}, false);
42
- case 8:
39
+ case 7:
43
40
  result = _context.sent;
44
- opts = (isSaasVersion() ? result.data : result.rows) || [];
41
+ opts = result.rows || [];
45
42
  treeEach(opts, function (item) {
46
43
  item.label = item.name;
47
44
  item.value = item.id;
@@ -55,7 +52,7 @@ var AreaCascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
55
52
  });
56
53
  setCache('areaOptions', opts, true);
57
54
  setOptions(opts);
58
- case 13:
55
+ case 12:
59
56
  case "end":
60
57
  return _context.stop();
61
58
  }
@@ -9,9 +9,8 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
9
9
  import _regeneratorRuntime from "@babel/runtime/regenerator";
10
10
  import React, { useRef, useState, useEffect, useImperativeHandle } from 'react';
11
11
  import { httpGet } from '../http';
12
- import { getCache, setCache, treeEach, isSaasVersion } from '../utils';
12
+ import { getCache, setCache, treeEach } from '../utils';
13
13
  import './common.less';
14
- import { toGatewayUrl } from 'ls-pro-table';
15
14
  var AreaPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
16
15
  var propsConfig = _objectSpread({
17
16
  getPopupContainer: function getPopupContainer(triggerNode) {
@@ -94,14 +93,11 @@ var AreaPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
94
93
  return _context.abrupt("return");
95
94
  case 3:
96
95
  api = '/petrel/petrel-location-center-api/sysAdministrativeDivision/allByTree';
97
- if (isSaasVersion()) {
98
- api = toGatewayUrl('/tenant-mdm-api/sysAdministrativeDivision/allByTree');
99
- }
100
- _context.next = 7;
96
+ _context.next = 6;
101
97
  return httpGet(api, {}, false);
102
- case 7:
98
+ case 6:
103
99
  result = _context.sent;
104
- opts = (isSaasVersion() ? result.data : result.rows) || [];
100
+ opts = result.rows || [];
105
101
  treeEach(opts, function (item) {
106
102
  item.label = item.name;
107
103
  item.value = item.id;
@@ -115,7 +111,7 @@ var AreaPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
115
111
  setCache('areaOptionsPanel', opts, true);
116
112
  setOptions(opts);
117
113
  setShowData(opts);
118
- case 13:
114
+ case 12:
119
115
  case "end":
120
116
  return _context.stop();
121
117
  }
@@ -5,11 +5,11 @@ import _Popover from "antd/es/popover";
5
5
  import _extends from "@babel/runtime/helpers/esm/extends";
6
6
  import "antd/es/button/style";
7
7
  import _Button from "antd/es/button";
8
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
8
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
9
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
10
10
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
11
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
11
12
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
12
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
13
13
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
14
14
  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", "method", "changeOnSelect", "record"],
15
15
  _excluded2 = ["current", "pageSize"];
@@ -39,11 +39,6 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
39
39
  text = _useState6[0],
40
40
  setText = _useState6[1];
41
41
  var inputRef = useRef();
42
- useImperativeHandle(ref, function () {
43
- return _objectSpread(_objectSpread({}, inputRef.current), {}, {
44
- clear: handleClear
45
- });
46
- });
47
42
  var columns = prop.columns,
48
43
  url = prop.url,
49
44
  textName = prop.textName,
@@ -124,6 +119,23 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
124
119
  if (col) return col.searchField || col.dataIndex;
125
120
  return textField || valueField;
126
121
  }, [columns, searchField, valueField, textField]);
122
+ var getFormValue = function getFormValue() {
123
+ var _formRef$current2, _formRef$current2$get;
124
+ if (rowKey) {
125
+ var _formRef$current, _formRef$current$getF, _formRef$current$getF2;
126
+ return 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];
127
+ }
128
+ return 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);
129
+ };
130
+ var setFormValue = function setFormValue(formValue) {
131
+ if (rowKey) {
132
+ var _formRef$current3, _formRef$current3$set;
133
+ 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, _defineProperty({}, rowKey, formValue));
134
+ } else {
135
+ var _formRef$current4, _formRef$current4$set;
136
+ 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, formValue);
137
+ }
138
+ };
127
139
  var loadData = /*#__PURE__*/function () {
128
140
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(param) {
129
141
  var current, pageSize, restParams, data, _tableRef$current, _tableRef$current$cle, result, rows, formValue, val, _selectRowRef$current, arr, pageSelectedRows;
@@ -209,40 +221,6 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
209
221
  return _ref.apply(this, arguments);
210
222
  };
211
223
  }();
212
- var getFormValue = function getFormValue() {
213
- var _formRef$current2, _formRef$current2$get;
214
- if (rowKey) {
215
- var _formRef$current, _formRef$current$getF, _formRef$current$getF2;
216
- return 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];
217
- }
218
- return 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);
219
- };
220
- var setFormValue = function setFormValue(formValue) {
221
- if (rowKey) {
222
- var _formRef$current3, _formRef$current3$set;
223
- 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, _defineProperty({}, rowKey, formValue));
224
- } else {
225
- var _formRef$current4, _formRef$current4$set;
226
- 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, formValue);
227
- }
228
- };
229
- // 初始化数据,主要设置名称
230
- useEffect(function () {
231
- var _formValue$textNamePr, _formValue$name;
232
- var formValue = getFormValue();
233
- if (!formValue) return;
234
- var txt = (_formValue$textNamePr = formValue === null || formValue === void 0 ? void 0 : formValue[textNameProp]) !== null && _formValue$textNamePr !== void 0 ? _formValue$textNamePr : record === null || record === void 0 ? void 0 : record[textNameProp];
235
- var val = (_formValue$name = formValue === null || formValue === void 0 ? void 0 : formValue[name]) !== null && _formValue$name !== void 0 ? _formValue$name : record === null || record === void 0 ? void 0 : record[name];
236
- setText(txt !== null && txt !== void 0 ? txt : val);
237
- if (val && !txt) {
238
- formValue[textNameProp] = val;
239
- setFormValue(formValue);
240
- // 多值选择或选择的初始值不在第一页时显示有问题
241
- if (textField !== valueField) {
242
- initName(val);
243
- }
244
- }
245
- }, [rowKey]);
246
224
  var initName = function initName(val) {
247
225
  var _columns$find;
248
226
  if (!val) return;
@@ -272,6 +250,23 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
272
250
  setFormValue(formValue);
273
251
  });
274
252
  };
253
+ // 初始化数据,主要设置名称
254
+ useEffect(function () {
255
+ var _formValue$textNamePr, _formValue$name;
256
+ var formValue = getFormValue();
257
+ if (!formValue) return;
258
+ var txt = (_formValue$textNamePr = formValue === null || formValue === void 0 ? void 0 : formValue[textNameProp]) !== null && _formValue$textNamePr !== void 0 ? _formValue$textNamePr : record === null || record === void 0 ? void 0 : record[textNameProp];
259
+ var val = (_formValue$name = formValue === null || formValue === void 0 ? void 0 : formValue[name]) !== null && _formValue$name !== void 0 ? _formValue$name : record === null || record === void 0 ? void 0 : record[name];
260
+ setText(txt !== null && txt !== void 0 ? txt : val);
261
+ if (val && !txt) {
262
+ formValue[textNameProp] = val;
263
+ setFormValue(formValue);
264
+ // 多值选择或选择的初始值不在第一页时显示有问题
265
+ if (textField !== valueField) {
266
+ initName(val);
267
+ }
268
+ }
269
+ }, [rowKey]);
275
270
  // 处理返回数据
276
271
  var handleValue = function handleValue(row) {
277
272
  var close = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
@@ -376,6 +371,11 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
376
371
  }
377
372
  }
378
373
  };
374
+ useImperativeHandle(ref, function () {
375
+ return _objectSpread(_objectSpread({}, inputRef.current), {}, {
376
+ clear: handleClear
377
+ });
378
+ });
379
379
  useEffect(function () {
380
380
  if (!text && multiple) {
381
381
  var _tableRef$current3, _tableRef$current3$cl;
package/lib/http/index.js CHANGED
@@ -2,7 +2,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  import { extend } from 'umi-request';
5
- import { getCache, getUrlQuery, setUrlQuery, getCookie, getResourceProps, showError, httpError, toGatewayUrl, reLogin, showLoading, exitLoading, isSaasVersion } from '../utils';
5
+ import { getCache, getUrlQuery, setUrlQuery, getCookie, getResourceProps, showError, httpError, toGatewayUrl, reLogin, showLoading, exitLoading, getBrowserId } from '../utils';
6
6
  //默认超时时间为1分钟
7
7
  var request = extend({
8
8
  timeout: 60000
@@ -14,6 +14,16 @@ var httpStatus = {
14
14
  503: '请求的服务器异常',
15
15
  504: '请求服务超时'
16
16
  };
17
+ var browserId = '';
18
+ (function () {
19
+ setTimeout(function () {
20
+ try {
21
+ getBrowserId().then(function (id) {
22
+ browserId = id;
23
+ });
24
+ } catch (_unused) {}
25
+ }, 0);
26
+ })();
17
27
  /** 请求拦截器,统一添加token */
18
28
  request.interceptors.request.use(function (url, options) {
19
29
  var _options$params;
@@ -24,6 +34,11 @@ request.interceptors.request.use(function (url, options) {
24
34
  // @ts-ignore
25
35
  options.headers['token'] = token;
26
36
  }
37
+ // 处理浏览器指纹
38
+ if (browserId) {
39
+ // @ts-ignore
40
+ options.headers['browserId'] = browserId;
41
+ }
27
42
  // 处理门店
28
43
  var shopNo = getCache('shopNo', true) || getCache('shopNo');
29
44
  if (shopNo) {
@@ -289,9 +304,6 @@ export function getDict(dictCode) {
289
304
  var needGateWay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
290
305
  var timeout = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 60000;
291
306
  var api = '/lesoon-integration/sysDictDtl/listByProperties';
292
- if (isSaasVersion()) {
293
- api = '/tenant-integration-api/sysDictDtl/listByProperties';
294
- }
295
307
  var param = {
296
308
  dictCode: dictCode
297
309
  };
@@ -311,9 +311,29 @@ export declare const openPageInMain: (option: {
311
311
  data?: any;
312
312
  ifRefreshTarget?: boolean;
313
313
  }) => void;
314
+ /** 显示加载 */
314
315
  export declare const showLoading: (text?: string) => void;
316
+ /** 退出加载 */
315
317
  export declare const exitLoading: () => void;
318
+ /** 处理主题 */
316
319
  export declare const handleTheme: () => void;
320
+ /**
321
+ * 睡眠
322
+ *
323
+ * @param secord 秒
324
+ * @returns
325
+ */
317
326
  export declare const sleep: (secord: number) => Promise<unknown>;
327
+ /**
328
+ * 通用下载文件方法
329
+ *
330
+ * @param url 文件地址
331
+ * @param fileName 文件名
332
+ */
318
333
  export declare const downloadFile: (url: string, fileName?: string | undefined) => void;
319
- export declare const isSaasVersion: () => boolean;
334
+ /**
335
+ * 获取浏览器指纹 基于fingerprintjs
336
+ *
337
+ * @returns 浏览器指纹
338
+ */
339
+ export declare const getBrowserId: () => Promise<string>;