@zgfe/business-lib 1.2.55-plat.4 → 1.2.55-plat.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.
@@ -4,9 +4,12 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
4
4
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
5
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import React, { useState, useEffect } from 'react';
7
+ import React, { useState, useEffect, useContext } from 'react';
8
8
  import { BizSelect } from '@zgfe/business-lib';
9
9
  import './styles/index.less';
10
+ import request from '../utils/ajax';
11
+ import Apis from '../constants/apis';
12
+ import BizGlobalDataContext from '../context';
10
13
  import { platformOptionUtil } from './util';
11
14
  var BizPlatformSelector = function BizPlatformSelector(props) {
12
15
  var classPrefix = 'biz-platform-selector';
@@ -14,21 +17,52 @@ var BizPlatformSelector = function BizPlatformSelector(props) {
14
17
  _useState2 = _slicedToArray(_useState, 2),
15
18
  currentValue = _useState2[0],
16
19
  setCurrentValue = _useState2[1];
20
+ var _useContext = useContext(BizGlobalDataContext),
21
+ currentApp = _useContext.currentApp;
22
+ var _useState3 = useState([]),
23
+ _useState4 = _slicedToArray(_useState3, 2),
24
+ platformOption = _useState4[0],
25
+ setPlatformOption = _useState4[1];
17
26
  useEffect(function () {
18
27
  if (props.value) {
19
- var selectValue = platformOptionUtil.find(function (item) {
28
+ var selectValue = platformOption.find(function (item) {
20
29
  return item.key === props.value;
21
30
  });
22
- setCurrentValue(selectValue || platformOptionUtil[0]);
31
+ setCurrentValue(selectValue || platformOption[0]);
23
32
  }
24
33
  }, [props.value]);
25
- useEffect(function () {}, []);
34
+ useEffect(function () {
35
+ queryPlatformList();
36
+ }, []);
37
+ function queryPlatformList() {
38
+ request(Apis.queryPlatformList, {
39
+ method: 'get',
40
+ params: {
41
+ appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId
42
+ }
43
+ }).then(function (res) {
44
+ var _res$data;
45
+ if (res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.length) {
46
+ var list = res.data.map(function (item) {
47
+ return item.sdkPlatform;
48
+ });
49
+ var options = platformOptionUtil.map(function (item) {
50
+ if (list.includes(item.key) || item.key === 0) {
51
+ return item;
52
+ }
53
+ }).filter(function (item) {
54
+ return item;
55
+ });
56
+ setPlatformOption(options || []);
57
+ }
58
+ });
59
+ }
26
60
  return /*#__PURE__*/React.createElement("div", {
27
61
  className: classPrefix
28
62
  }, /*#__PURE__*/React.createElement(BizSelect, {
29
63
  className: "".concat(classPrefix, "-select"),
30
64
  overlayClassName: "".concat(classPrefix, "-select-overlay"),
31
- options: props.valueOption && props.valueOption.length ? props.valueOption : platformOptionUtil,
65
+ options: props.valueOption && props.valueOption.length ? props.valueOption : platformOption,
32
66
  overlayWidth: 134,
33
67
  keyField: "key",
34
68
  labelField: "value",
@@ -164,7 +164,7 @@ var CascaderOverlay = function CascaderOverlay(props) {
164
164
  pageNo: pageNo,
165
165
  pageSize: 20,
166
166
  labelName: highlightText,
167
- isOpenLayer: isOpenLayer || true
167
+ isOpenLayer: isOpenLayer
168
168
  }
169
169
  }).then(function (res) {
170
170
  if ((res === null || res === void 0 ? void 0 : res.data) && res.data.results) {
@@ -174,11 +174,6 @@ var CascaderOverlay = function CascaderOverlay(props) {
174
174
  if (item.labelGroup === currentSelect) {
175
175
  item.children = pageNo === 1 ? _toConsumableArray(result) : item.children.concat(result);
176
176
  }
177
- if (!isOpenLayer) {
178
- item.children.forEach(function (element) {
179
- element.layers = [];
180
- });
181
- }
182
177
  return _objectSpread({}, item);
183
178
  });
184
179
  });
@@ -49,6 +49,7 @@ export default (function () {
49
49
  keyFields: ['labelGroup', 'id', 'layerLabelId'],
50
50
  labelFields: ['labelGroup', 'labelName', 'layerLabelName'],
51
51
  valueFields: ['labelGroup', 'id', 'layerLabelId'],
52
+ isOpenLayer: false,
52
53
  onChange: onChange
53
54
  })));
54
55
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/business-lib",
3
- "version": "1.2.55-plat.4",
3
+ "version": "1.2.55-plat.6",
4
4
  "module": "es/index.js",
5
5
  "typings": "es/index.d.ts",
6
6
  "files": [
@@ -55,7 +55,7 @@
55
55
  "react": "^16.12.0 || ^17.0.0",
56
56
  "yorkie": "^2.0.0"
57
57
  },
58
- "gitHead": "7bda9bea59b087f73bf460a7388ce613957b9e88",
58
+ "gitHead": "9b33eda9e1e0f6839c9259951354a4261763eac9",
59
59
  "gitHooks": {
60
60
  "pre-commit": "lint-staged"
61
61
  }