@zgfe/business-lib 1.1.53 → 1.1.55-beta.0

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.
@@ -167,7 +167,6 @@ var BizAddToPanel = function BizAddToPanel(props) {
167
167
  return /*#__PURE__*/React.createElement(BizDialog, {
168
168
  open: true,
169
169
  title: props.type === 'edit' ? '修改当前看板指标' : '向看板添加指标',
170
- width: 503,
171
170
  maskClosable: false,
172
171
  onCancel: props.onCancel,
173
172
  onOk: onAdd,
@@ -4,5 +4,6 @@ declare const DemoHeader: React.FC<{
4
4
  defaultApp?: number;
5
5
  onChangeApp?: (app: AppInfoProps) => void;
6
6
  onLoading?: (loading: boolean) => void;
7
+ onLogin?: () => void;
7
8
  }>;
8
9
  export default DemoHeader;
@@ -4,13 +4,14 @@ 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 { Select, Skeleton } from 'antd';
7
+ import { Select, Skeleton, message } from 'antd';
8
8
  import React, { useEffect, useState } from 'react';
9
9
  import request from '../utils/ajax';
10
10
  var DemoHeader = function DemoHeader(_ref) {
11
11
  var defaultApp = _ref.defaultApp,
12
12
  onChangeApp = _ref.onChangeApp,
13
- onLoading = _ref.onLoading;
13
+ onLoading = _ref.onLoading,
14
+ onLogin = _ref.onLogin;
14
15
  var _useState = useState([]),
15
16
  _useState2 = _slicedToArray(_useState, 2),
16
17
  appList = _useState2[0],
@@ -28,6 +29,11 @@ var DemoHeader = function DemoHeader(_ref) {
28
29
  function queryAppList() {
29
30
  setLoading(true);
30
31
  request('/zg/web/v2/data/v2ajaxGetDataByApp').then(function (res) {
32
+ if (!res.data) {
33
+ message.error('获取应用列表失败,请重新登录');
34
+ onLogin && onLogin();
35
+ return;
36
+ }
31
37
  setAppList(res.data.appList);
32
38
  if (defaultApp) {
33
39
  _onChange(res.data.appList.find(function (item) {
@@ -60,7 +60,10 @@ var DemoWrapper = function DemoWrapper(_ref) {
60
60
  title: /*#__PURE__*/React.createElement(DemoHeader, {
61
61
  defaultApp: defaultApp,
62
62
  onChangeApp: setApp,
63
- onLoading: setAppListLoading
63
+ onLoading: setAppListLoading,
64
+ onLogin: function onLogin() {
65
+ return setNotLogin(true);
66
+ }
64
67
  }),
65
68
  className: className,
66
69
  bodyStyle: {
@@ -0,0 +1,2 @@
1
+ declare const _default: () => JSX.Element;
2
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import BizTargetFromPanel from '..';
3
+ export default (function () {
4
+ return /*#__PURE__*/React.createElement(BizTargetFromPanel, null, /*#__PURE__*/React.createElement("div", null, "\u65E0\u64CD\u4F5C\u680F\u5C55\u793A"));
5
+ });
@@ -19,12 +19,12 @@ import Apis from '../../constants/apis';
19
19
  import { Spin, message } from 'antd';
20
20
  export var classPrefix = 'biz-layout-panel';
21
21
  var BizTargetFromPanel = function BizTargetFromPanel(props) {
22
- var _props$value$target$p;
22
+ var _props$value, _props$value10, _props$value$target$p;
23
23
  var _useState = useState([]),
24
24
  _useState2 = _slicedToArray(_useState, 2),
25
25
  options = _useState2[0],
26
26
  setOptions = _useState2[1];
27
- var _useState3 = useState(props.value.target.name || '洞察'),
27
+ var _useState3 = useState(((_props$value = props.value) === null || _props$value === void 0 ? void 0 : _props$value.target.name) || '洞察'),
28
28
  _useState4 = _slicedToArray(_useState3, 2),
29
29
  title = _useState4[0],
30
30
  setTitle = _useState4[1];
@@ -42,11 +42,14 @@ var BizTargetFromPanel = function BizTargetFromPanel(props) {
42
42
  setLoading = _useState10[1];
43
43
  var titleRef = useRef(null);
44
44
  useEffect(function () {
45
- setOptions(props.value.target.id ? panelBtn(onClick) : panelCreateBtn(onClick));
45
+ var _props$value2, _props$value3;
46
+ if (!((_props$value2 = props.value) === null || _props$value2 === void 0 ? void 0 : _props$value2.panelId)) return;
47
+ setOptions(((_props$value3 = props.value) === null || _props$value3 === void 0 ? void 0 : _props$value3.target.id) ? panelBtn(onClick) : panelCreateBtn(onClick));
46
48
  }, []);
47
49
  var onClick = function onClick(type) {
48
50
  if (type === BizOptionTitleProps.OptionTypes.CANCEL) {
49
- var param = props.value.target.id ? {
51
+ var _props$value4;
52
+ var param = ((_props$value4 = props.value) === null || _props$value4 === void 0 ? void 0 : _props$value4.target.id) ? {
50
53
  panelId: props.value.panelId,
51
54
  elementId: props.value.target.id,
52
55
  name: title
@@ -62,12 +65,13 @@ var BizTargetFromPanel = function BizTargetFromPanel(props) {
62
65
  }
63
66
  };
64
67
  var onDelete = function onDelete() {
68
+ var _props$value5, _props$value6;
65
69
  setLoading(true);
66
70
  ajax(Apis.delPanelElement, {
67
71
  method: 'post',
68
72
  data: {
69
- panelId: props.value.panelId,
70
- elementId: props.value.target.id
73
+ panelId: (_props$value5 = props.value) === null || _props$value5 === void 0 ? void 0 : _props$value5.panelId,
74
+ elementId: (_props$value6 = props.value) === null || _props$value6 === void 0 ? void 0 : _props$value6.target.id
71
75
  }
72
76
  }).then(function (res) {
73
77
  if (!res) return;
@@ -80,6 +84,7 @@ var BizTargetFromPanel = function BizTargetFromPanel(props) {
80
84
  });
81
85
  };
82
86
  var onService = function onService(value, callback) {
87
+ var _props$value7, _props$value8;
83
88
  setTitle(value);
84
89
  setBtnOptions(!value);
85
90
  if (!value) return;
@@ -87,8 +92,8 @@ var BizTargetFromPanel = function BizTargetFromPanel(props) {
87
92
  ajax(Apis.updateElementName, {
88
93
  method: 'post',
89
94
  data: {
90
- panelId: props.value.panelId,
91
- elementId: props.value.target.id,
95
+ panelId: (_props$value7 = props.value) === null || _props$value7 === void 0 ? void 0 : _props$value7.panelId,
96
+ elementId: (_props$value8 = props.value) === null || _props$value8 === void 0 ? void 0 : _props$value8.target.id,
92
97
  name: value
93
98
  }
94
99
  }).then(function (res) {
@@ -112,14 +117,18 @@ var BizTargetFromPanel = function BizTargetFromPanel(props) {
112
117
  };
113
118
  var setBtnOptions = function setBtnOptions(disabled) {
114
119
  setOptions(function (option) {
120
+ var _props$value9;
115
121
  if (!option.length) return [];
116
122
  option[option.length - 1].disabled = disabled;
117
- if (props.value.target.id) {
123
+ if ((_props$value9 = props.value) === null || _props$value9 === void 0 ? void 0 : _props$value9.target.id) {
118
124
  option[option.length - 2].disabled = disabled;
119
125
  }
120
126
  return _toConsumableArray(option);
121
127
  });
122
128
  };
129
+ if (!((_props$value10 = props.value) === null || _props$value10 === void 0 ? void 0 : _props$value10.panelId)) {
130
+ return /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
131
+ }
123
132
  return /*#__PURE__*/React.createElement(BizTargetFromPanelContext.Provider, {
124
133
  value: {
125
134
  handleSearch: setBtnOptions
@@ -2,8 +2,8 @@ import React from 'react';
2
2
  import AddToPanel from '../../addToPanel/types';
3
3
  export declare namespace BizOptionTitleProps {
4
4
  export interface Props {
5
- value: Value;
6
- styleOptions: AddToPanel.TabItem[];
5
+ value?: Value;
6
+ styleOptions?: AddToPanel.TabItem[];
7
7
  children: React.ReactNode;
8
8
  afterEditTarget?: (type: string, value?: any) => void;
9
9
  }
package/es/utils/ajax.js CHANGED
@@ -6,6 +6,7 @@ import Request, { extend } from 'umi-request';
6
6
  import { notification, message } from 'antd';
7
7
  import { globalConfig } from '../config';
8
8
  import { ResponseStatus } from './type';
9
+ import util from './util';
9
10
  var codeMessage = {
10
11
  200: '服务器成功返回请求的数据。',
11
12
  201: '新建或修改数据成功。',
@@ -44,6 +45,20 @@ var errorHandler = function errorHandler(error) {
44
45
  }
45
46
  return response;
46
47
  };
48
+ var downloadFile = function downloadFile(resData, name) {
49
+ var blob = resData.data;
50
+ var fileName = resData.response.headers.get('Filename');
51
+ if (name) {
52
+ var fileType = fileName.split('.')[1];
53
+ fileName = "".concat(name, ".").concat(fileType);
54
+ }
55
+ var href = URL.createObjectURL(blob);
56
+ var a = document.createElement('a');
57
+ a.href = href;
58
+ a.download = fileName;
59
+ a.click();
60
+ return null;
61
+ };
47
62
  export function responseErrorHandler(url, apiResult, errorTitle, notifyType) {
48
63
  if (/\.jsp/.test(url)) {
49
64
  return apiResult;
@@ -85,7 +100,7 @@ function request(_x, _x2) {
85
100
  }
86
101
  function _request() {
87
102
  _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url, options) {
88
- var _globalConfig$request, _globalConfig$request2, err, option, list, optionsWrapper, responseWrapper, params, res;
103
+ var _globalConfig$request, _globalConfig$request2, _params$options, _params$options2, err, option, list, optionsWrapper, responseWrapper, params, res;
89
104
  return _regeneratorRuntime().wrap(function _callee$(_context) {
90
105
  while (1) switch (_context.prev = _context.next) {
91
106
  case 0:
@@ -115,20 +130,35 @@ function _request() {
115
130
  url: url,
116
131
  options: options
117
132
  };
118
- _context.next = 13;
133
+ if (((_params$options = params.options) === null || _params$options === void 0 ? void 0 : _params$options.responseType) === 'blob') {
134
+ params.options.getResponse = true;
135
+ }
136
+ _context.next = 14;
119
137
  return req(params.url, params.options);
120
- case 13:
138
+ case 14:
121
139
  res = _context.sent;
140
+ if (!(((_params$options2 = params.options) === null || _params$options2 === void 0 ? void 0 : _params$options2.responseType) === 'blob')) {
141
+ _context.next = 21;
142
+ break;
143
+ }
144
+ if (!util.isBlob(res.data)) {
145
+ _context.next = 20;
146
+ break;
147
+ }
148
+ return _context.abrupt("return", downloadFile(res, params.options.fileName));
149
+ case 20:
150
+ res = res.data;
151
+ case 21:
122
152
  return _context.abrupt("return", responseWrapper ? responseWrapper(url, responseErrorHandler(url, res, options === null || options === void 0 ? void 0 : options.errorTitle, options === null || options === void 0 ? void 0 : options.notifyType)) : responseErrorHandler(url, res, options === null || options === void 0 ? void 0 : options.errorTitle, options === null || options === void 0 ? void 0 : options.notifyType));
123
- case 17:
124
- _context.prev = 17;
153
+ case 24:
154
+ _context.prev = 24;
125
155
  _context.t0 = _context["catch"](0);
126
156
  return _context.abrupt("return", null);
127
- case 20:
157
+ case 27:
128
158
  case "end":
129
159
  return _context.stop();
130
160
  }
131
- }, _callee, null, [[0, 17]]);
161
+ }, _callee, null, [[0, 24]]);
132
162
  }));
133
163
  return _request.apply(this, arguments);
134
164
  }
@@ -0,0 +1,2 @@
1
+ declare const _default: () => JSX.Element;
2
+ export default _default;
@@ -0,0 +1,24 @@
1
+ import { Button } from 'antd';
2
+ import React from 'react';
3
+ import { ajax, DemoWrapper } from '@zgfe/business-lib';
4
+ export default (function () {
5
+ var onDownload = function onDownload() {
6
+ ajax('/zg/web/v2/openapi/label/excel/export', {
7
+ method: 'post',
8
+ data: {
9
+ appId: 501648,
10
+ platform: 0,
11
+ pageNo: 1,
12
+ pageSize: 10
13
+ },
14
+ responseType: 'blob',
15
+ fileName: 'ceshi',
16
+ getResponse: true
17
+ }).then(function () {});
18
+ };
19
+ return /*#__PURE__*/React.createElement(DemoWrapper, {
20
+ needMeta: true
21
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
22
+ onClick: onDownload
23
+ }, "\u4E0B\u8F7D\u6587\u4EF6")));
24
+ });
@@ -7,6 +7,7 @@ declare let util: {
7
7
  isNumber(obj: any): boolean;
8
8
  isDate(obj: any): boolean;
9
9
  isFunction(obj: any): boolean;
10
+ isBlob(obj: any): boolean;
10
11
  isEqual(a?: {}, b?: {}): boolean;
11
12
  equal(a: any, b: any): boolean;
12
13
  random(min: number, max: number): number;
package/es/utils/util.js CHANGED
@@ -22,6 +22,9 @@ var util = {
22
22
  isFunction: function isFunction(obj) {
23
23
  return this.type(obj) === '[object Function]';
24
24
  },
25
+ isBlob: function isBlob(obj) {
26
+ return this.type(obj) === '[object Blob]';
27
+ },
25
28
  isEqual: function isEqual() {
26
29
  var a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
27
30
  var b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/business-lib",
3
- "version": "1.1.53",
3
+ "version": "1.1.55-beta.0",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -60,5 +60,5 @@
60
60
  "react": "^16.12.0 || ^17.0.0",
61
61
  "yorkie": "^2.0.0"
62
62
  },
63
- "gitHead": "8b0de5490014d6a853e82ec29c55543533f881d1"
63
+ "gitHead": "d43bbb8c72bb0da5995f873be7dc97bd009afbc3"
64
64
  }