@zgfe/modules-page 1.0.1-alpha.3 → 1.0.1-alpha.30

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.
Files changed (33) hide show
  1. package/dist/esm/components/content/index.d.ts +1 -1
  2. package/dist/esm/components/content/index.js +5 -1
  3. package/dist/esm/components/content/types.d.ts +1 -0
  4. package/dist/esm/components/content/utils.d.ts +4 -15
  5. package/dist/esm/components/content/utils.js +12 -12
  6. package/dist/esm/components/detail/images/percent.png +0 -0
  7. package/dist/esm/components/detail/index.js +35 -56
  8. package/dist/esm/components/detail/index.less +9 -2
  9. package/dist/esm/components/groupModal/index.d.ts +2 -6
  10. package/dist/esm/components/groupModal/index.js +16 -12
  11. package/dist/esm/components/groupModal/index.less +23 -1
  12. package/dist/esm/components/groupModal/inputSelect.js +1 -0
  13. package/dist/esm/components/groupModal/types.d.ts +2 -0
  14. package/dist/esm/components/pageSelect/index.js +48 -37
  15. package/dist/esm/components/pageSelect/types.d.ts +0 -2
  16. package/dist/esm/components/searchPanel/index.d.ts +1 -1
  17. package/dist/esm/components/searchPanel/index.js +14 -37
  18. package/dist/esm/components/searchPanel/index.less +7 -34
  19. package/dist/esm/components/searchPanel/types.d.ts +3 -3
  20. package/dist/esm/components/searchPanel/util.d.ts +4 -4
  21. package/dist/esm/components/searchPanel/util.js +35 -29
  22. package/dist/esm/components/topContent/index.less +1 -0
  23. package/dist/esm/constants/api.js +1 -1
  24. package/dist/esm/modules/empty/index.js +3 -1
  25. package/dist/esm/modules/empty/index.less +11 -6
  26. package/dist/esm/modules/home/demo/index.js +60 -2
  27. package/dist/esm/modules/home/index.js +96 -50
  28. package/dist/esm/modules/home/style/index.less +23 -0
  29. package/dist/esm/modules/home/types.d.ts +9 -1
  30. package/dist/esm/modules/home/utils.d.ts +3 -3
  31. package/dist/esm/modules/home/utils.js +33 -12
  32. package/package.json +3 -3
  33. package/dist/esm/components/detail/images/color_pallete_percent.png +0 -0
@@ -10,10 +10,10 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
10
10
  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; }
11
11
  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; } }
12
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
- import React, { useContext, useEffect, useMemo, useState } from 'react';
13
+ import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
14
14
  import EmptyPanel from "../empty";
15
- import { BizGlobalDataContext, BizLayout } from '@zgfe/business-lib';
16
- import { Button, Spin } from 'antd';
15
+ import { BizGlobalDataContext, BizLayout, BizLoading } from '@zgfe/business-lib';
16
+ import { Button, Skeleton, Spin } from 'antd';
17
17
  import "./style/index.less";
18
18
  import SearchPanel from "../../components/searchPanel";
19
19
  import TopContent from "../../components/topContent";
@@ -22,6 +22,7 @@ import { ModulesPageContext } from "./types";
22
22
  import GroupModal from "../../components/groupModal";
23
23
  import { getPageGroupList, getPageList, getPageResult, onDownload as _onDownload } from "./utils";
24
24
  import DetailContent from "../../components/detail";
25
+ import _ from 'lodash';
25
26
  var classPrefix = 'modules-page';
26
27
  var ModulesPage = function ModulesPage(props) {
27
28
  // 页面类型
@@ -29,58 +30,71 @@ var ModulesPage = function ModulesPage(props) {
29
30
  _useState2 = _slicedToArray(_useState, 2),
30
31
  currentType = _useState2[0],
31
32
  setCurrentType = _useState2[1];
32
- // 查询条件
33
- var _useState3 = useState(),
33
+ // 最新查询条件
34
+ var _useState3 = useState(props.value),
34
35
  _useState4 = _slicedToArray(_useState3, 2),
35
36
  searchValue = _useState4[0],
36
37
  setSearchValue = _useState4[1];
37
- // 是否展示分组弹窗
38
- var _useState5 = useState(false),
38
+ // 上一次查询条件
39
+ var _useState5 = useState(),
39
40
  _useState6 = _slicedToArray(_useState5, 2),
40
- showGroup = _useState6[0],
41
- setShowGroup = _useState6[1];
42
- // 页面列表
43
- var _useState7 = useState([]),
41
+ originSearchValue = _useState6[0],
42
+ setOriginSearchValue = _useState6[1];
43
+
44
+ // 是否展示分组弹窗
45
+ var _useState7 = useState(false),
44
46
  _useState8 = _slicedToArray(_useState7, 2),
45
- pageList = _useState8[0],
46
- setPageList = _useState8[1];
47
- // 页面分组列表
47
+ showGroup = _useState8[0],
48
+ setShowGroup = _useState8[1];
49
+ // 页面列表
48
50
  var _useState9 = useState([]),
49
51
  _useState10 = _slicedToArray(_useState9, 2),
50
- pageGroupList = _useState10[0],
51
- setPageGroupList = _useState10[1];
52
- // 查询结果
52
+ pageList = _useState10[0],
53
+ setPageList = _useState10[1];
54
+ // 页面分组列表
53
55
  var _useState11 = useState([]),
54
56
  _useState12 = _slicedToArray(_useState11, 2),
55
- result = _useState12[0],
56
- setResult = _useState12[1];
57
- var _useState13 = useState(true),
57
+ pageGroupList = _useState12[0],
58
+ setPageGroupList = _useState12[1];
59
+ // 查询结果
60
+ var _useState13 = useState([]),
58
61
  _useState14 = _slicedToArray(_useState13, 2),
59
- loading = _useState14[0],
60
- setLoading = _useState14[1];
62
+ result = _useState14[0],
63
+ setResult = _useState14[1];
61
64
  var _useState15 = useState(true),
62
65
  _useState16 = _slicedToArray(_useState15, 2),
63
- pageLoading = _useState16[0],
64
- setPageLoading = _useState16[1];
65
- // 要编辑的分组
66
- var _useState17 = useState(),
66
+ loading = _useState16[0],
67
+ setLoading = _useState16[1];
68
+ var _useState17 = useState(true),
67
69
  _useState18 = _slicedToArray(_useState17, 2),
68
- editGroup = _useState18[0],
69
- setEditGroup = _useState18[1];
70
- // 当前页面类型 list/detail
71
- var _useState19 = useState('list'),
70
+ pageLoading = _useState18[0],
71
+ setPageLoading = _useState18[1];
72
+ // 要编辑的分组
73
+ var _useState19 = useState(),
72
74
  _useState20 = _slicedToArray(_useState19, 2),
73
- pageType = _useState20[0],
74
- setPageType = _useState20[1];
75
- var _useState21 = useState(0),
75
+ editGroup = _useState20[0],
76
+ setEditGroup = _useState20[1];
77
+ // 当前页面类型 list/detail
78
+ var _useState21 = useState('list'),
76
79
  _useState22 = _slicedToArray(_useState21, 2),
77
- timer = _useState22[0],
78
- setTimer = _useState22[1];
79
- //当前点击内容(用于同步查询条件中的内容)
80
- var _useState23 = useState(),
80
+ pageType = _useState22[0],
81
+ setPageType = _useState22[1];
82
+ var _useState23 = useState(0),
81
83
  _useState24 = _slicedToArray(_useState23, 2),
82
- currentClickPage = _useState24[0],
83
- setCurrentClickPage = _useState24[1];
84
+ timer = _useState24[0],
85
+ setTimer = _useState24[1];
86
+ //当前点击内容(用于同步查询条件中的内容)
87
+ var _useState25 = useState(),
88
+ _useState26 = _slicedToArray(_useState25, 2),
89
+ currentClickPage = _useState26[0],
90
+ setCurrentClickPage = _useState26[1];
91
+ var _React$useState = React.useState(),
92
+ _React$useState2 = _slicedToArray(_React$useState, 2),
93
+ controller = _React$useState2[0],
94
+ setController = _React$useState2[1];
95
+
96
+ // 查询条件ref
97
+ var selectRef = useRef(null);
84
98
  var _useContext = useContext(BizGlobalDataContext),
85
99
  eventGroupList = _useContext.eventGroupList,
86
100
  currentApp = _useContext.currentApp;
@@ -112,15 +126,26 @@ var ModulesPage = function ModulesPage(props) {
112
126
  useEffect(function () {
113
127
  if (isEmpty) return;
114
128
  if (!searchValue) return;
115
- console.log('searchValue:', searchValue);
116
129
  var type = searchValue !== null && searchValue !== void 0 && searchValue.pageGroup || (searchValue === null || searchValue === void 0 ? void 0 : searchValue.pageGroup) === 0 ? 'pageGroup' : 'page';
117
130
  setCurrentType(type);
118
131
  // 选择概览时,跳到列表页
119
132
  if (type === 'page' && !(searchValue !== null && searchValue !== void 0 && searchValue.pageUrl) || type === 'pageGroup' && !(searchValue !== null && searchValue !== void 0 && searchValue.pageGroup)) {
120
133
  setPageType('list');
121
134
  }
135
+ if (type === 'pageGroup' && !(searchValue !== null && searchValue !== void 0 && searchValue.pageGroup)) return;
122
136
  if (type === 'page' || pageType === 'detail') {
137
+ if (!searchValue.pageUrl && !searchValue.pageTitle && !searchValue.pageGroup && searchValue.pageGroup != 0) return;
123
138
  fetch();
139
+ } else if (type === 'pageGroup') {
140
+ if (!searchValue.pageGroup && searchValue.pageGroup != 0) return;
141
+ props.onChange && props.onChange(_objectSpread(_objectSpread({
142
+ appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId,
143
+ platform: 3,
144
+ module: 'page'
145
+ }, searchValue), {}, {
146
+ pageUrl: undefined,
147
+ pageTitle: undefined
148
+ }));
124
149
  }
125
150
  }, [searchValue]);
126
151
  // 查询结果
@@ -132,12 +157,23 @@ var ModulesPage = function ModulesPage(props) {
132
157
  setTimer(setTimeout(function () {
133
158
  var param = _objectSpread({
134
159
  appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId,
135
- platform: 3
160
+ platform: 3,
161
+ module: 'page'
136
162
  }, searchValue);
137
- getPageResult(param, setResult, setLoading);
163
+ props.onChange && props.onChange(param);
164
+ if (_.isEqual(originSearchValue, searchValue)) {
165
+ setLoading(false);
166
+ return;
167
+ }
168
+ setOriginSearchValue(_.cloneDeep(searchValue));
169
+ var control = new AbortController();
170
+ var signal = control.signal;
171
+ controller === null || controller === void 0 ? void 0 : controller.abort();
172
+ setController(control);
173
+ getPageResult(param, setResult, setLoading, signal);
138
174
  }, 500));
139
175
  };
140
- // 改变查询条件
176
+ // 改变查询条件/
141
177
  var onChange = function onChange(data) {
142
178
  setSearchValue(function (value) {
143
179
  if (!value) return data;
@@ -178,6 +214,7 @@ var ModulesPage = function ModulesPage(props) {
178
214
  className: "".concat(classPrefix, "-top-render")
179
215
  }, /*#__PURE__*/React.createElement(Button, {
180
216
  type: "primary",
217
+ disabled: loading || !result || !result.length,
181
218
  onClick: props.onClickWarn
182
219
  }, "\u8BBE\u7F6E\u6D41\u5931\u9884\u8B66"));
183
220
  if (isEmpty) return /*#__PURE__*/React.createElement(EmptyPanel, null);
@@ -189,13 +226,22 @@ var ModulesPage = function ModulesPage(props) {
189
226
  setCurrentClickPage: setCurrentClickPage
190
227
  }
191
228
  }, /*#__PURE__*/React.createElement(BizLayout, {
229
+ className: classPrefix,
192
230
  title: "\u9875\u9762\u5206\u6790",
193
231
  hasCollapse: true,
194
- topPanel: /*#__PURE__*/React.createElement(SearchPanel, {
232
+ topPanel: /*#__PURE__*/React.createElement(Skeleton, {
233
+ loading: pageLoading,
234
+ active: true,
235
+ paragraph: {
236
+ rows: 4
237
+ }
238
+ }, /*#__PURE__*/React.createElement(SearchPanel, {
239
+ ref: selectRef,
195
240
  value: searchValue,
196
241
  onChange: onChange
197
- }),
198
- topRender: props.onClickWarn ? render : null
242
+ })),
243
+ topRender: props.onClickWarn ? render : null,
244
+ collapseRef: selectRef
199
245
  }, /*#__PURE__*/React.createElement(Spin, {
200
246
  spinning: pageLoading
201
247
  }, /*#__PURE__*/React.createElement(TopContent, {
@@ -210,9 +256,9 @@ var ModulesPage = function ModulesPage(props) {
210
256
  onDownload: function onDownload() {
211
257
  return _onDownload(searchValue, currentApp);
212
258
  }
213
- }), /*#__PURE__*/React.createElement(Spin, {
214
- spinning: loading
215
- }, pageType === 'list' ? /*#__PURE__*/React.createElement(PageContent, {
259
+ }), loading && !pageLoading ? /*#__PURE__*/React.createElement("div", {
260
+ className: "".concat(classPrefix, "-content")
261
+ }, /*#__PURE__*/React.createElement(BizLoading, null)) : pageType === 'list' ? /*#__PURE__*/React.createElement(PageContent, {
216
262
  type: currentType,
217
263
  value: result,
218
264
  groupId: searchValue === null || searchValue === void 0 ? void 0 : searchValue.pageGroup,
@@ -225,7 +271,7 @@ var ModulesPage = function ModulesPage(props) {
225
271
  }) : /*#__PURE__*/React.createElement(DetailContent, {
226
272
  params: searchValue,
227
273
  result: result
228
- })), showGroup ? /*#__PURE__*/React.createElement(GroupModal, {
274
+ }), showGroup ? /*#__PURE__*/React.createElement(GroupModal, {
229
275
  value: editGroup,
230
276
  onCancel: function onCancel() {
231
277
  return setShowGroup(false);
@@ -9,6 +9,11 @@
9
9
  padding: 4px 16px;
10
10
  }
11
11
  }
12
+ .ant-btn-primary[disabled] {
13
+ color: #fff;
14
+ background: #d0dfff;
15
+ border-color: #d0dfff;
16
+ }
12
17
 
13
18
  &-spin {
14
19
  display: flex;
@@ -19,4 +24,22 @@
19
24
  border: 1px solid #ecedf0;
20
25
  border-radius: 8px;
21
26
  }
27
+
28
+ &-content {
29
+ display: flex;
30
+ align-items: center;
31
+ justify-content: center;
32
+ width: 100%;
33
+ min-height: 300px;
34
+ margin-top: 60px;
35
+ background-color: #fff;
36
+ }
37
+ .ant-btn {
38
+ display: flex;
39
+ align-items: center;
40
+ .bsicon {
41
+ font-size: 16px !important;
42
+ line-height: 1;
43
+ }
44
+ }
22
45
  }
@@ -5,9 +5,13 @@ export declare namespace ModulesPageTypes {
5
5
  interface Props {
6
6
  value?: Value;
7
7
  onClickWarn?: () => void;
8
+ onChange?: (data: Value) => void;
8
9
  }
9
10
  interface Value extends SearchValue {
10
11
  time?: DatePickerTypes.Value;
12
+ appId?: number | string;
13
+ platform?: number;
14
+ module?: string;
11
15
  }
12
16
  interface Page {
13
17
  pageTitle?: string;
@@ -29,10 +33,14 @@ export declare namespace ModulesPageTypes {
29
33
  param?: string;
30
34
  id?: string;
31
35
  }
36
+ interface Params {
37
+ appId?: number | string;
38
+ platform: number;
39
+ }
32
40
  }
33
41
  export declare const ModulesPageContext: import("react").Context<{
34
42
  pageList: ModulesPageTypes.Page[];
35
43
  pageGroupList: ModulesPageTypes.PageGroup[];
36
- currentClickPage?: ModulesPageTypes.Page | ModulesPageTypes.PageGroup | undefined;
44
+ currentClickPage?: ModulesPageTypes.PageGroup | ModulesPageTypes.Page | undefined;
37
45
  setCurrentClickPage?: ((data: ModulesPageTypes.Page) => void) | undefined;
38
46
  }>;
@@ -1,7 +1,7 @@
1
1
  import { ModulesPageTypes } from './types';
2
2
  import { AppInfoProps } from '@zgfe/business-lib/es/context';
3
- export declare const getPageList: (data: any, callback: Function) => void;
4
- export declare const getPageGroupList: (data: any, callback: Function, loadingCallback?: Function) => void;
5
- export declare const getPageResult: (params: any, callback: Function, loadingCallback: Function) => void;
3
+ export declare const getPageList: (data: ModulesPageTypes.Params, callback: Function) => void;
4
+ export declare const getPageGroupList: (data: ModulesPageTypes.Params, callback: Function, loadingCallback?: Function) => void;
5
+ export declare const getPageResult: (params: ModulesPageTypes.Value, callback: Function, loadingCallback: Function, signal: AbortSignal) => void;
6
6
  export declare const getSocketSecret: () => string;
7
7
  export declare const onDownload: (params?: ModulesPageTypes.Value, currentApp?: AppInfoProps) => void;
@@ -4,7 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
5
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
6
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
- import { ajax, util } from '@zgfe/business-lib';
7
+ import { ajax, util, base64 } from '@zgfe/business-lib';
8
8
  import api from "../../constants/api";
9
9
  // 获取页面列表
10
10
  export var getPageList = function getPageList(data, callback) {
@@ -12,7 +12,7 @@ export var getPageList = function getPageList(data, callback) {
12
12
  method: 'post',
13
13
  data: data
14
14
  }).then(function (res) {
15
- if (!res) {
15
+ if (!res || !res.data) {
16
16
  callback([{
17
17
  id: '页面概览',
18
18
  pageTitle: '页面概览',
@@ -42,7 +42,7 @@ export var getPageGroupList = function getPageGroupList(data, callback, loadingC
42
42
  method: 'post',
43
43
  data: data
44
44
  }).then(function (res) {
45
- if (!res) {
45
+ if (!res || !res.data) {
46
46
  callback([{
47
47
  id: 0,
48
48
  name: '全部页面组'
@@ -61,16 +61,30 @@ export var getPageGroupList = function getPageGroupList(data, callback, loadingC
61
61
  };
62
62
 
63
63
  // 获取页面查询结果
64
- export var getPageResult = function getPageResult(params, callback, loadingCallback) {
64
+ export var getPageResult = function getPageResult(params, callback, loadingCallback, signal) {
65
65
  loadingCallback(true);
66
66
  ajax(api.getPageResult, {
67
67
  method: 'post',
68
- data: params
68
+ data: params,
69
+ signal: signal
69
70
  }).then(function (res) {
70
- if (!res) return;
71
- callback(res.data);
72
- }).finally(function () {
71
+ var _res$data;
73
72
  loadingCallback(false);
73
+ if (!res || !res.data) {
74
+ callback([]);
75
+ return;
76
+ }
77
+ callback((_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.map(function (item) {
78
+ return _objectSpread(_objectSpread({}, item), {}, {
79
+ id: "".concat(item.userGroup, "-").concat(item.pageTitle, "-").concat(item.pageUrl)
80
+ });
81
+ }));
82
+ }).catch(function (e) {
83
+ if (e.isCancel) {
84
+ console.log('请求被取消了');
85
+ } else {
86
+ loadingCallback(false);
87
+ }
74
88
  });
75
89
  };
76
90
  export var getSocketSecret = function getSocketSecret() {
@@ -83,14 +97,21 @@ export var getSocketSecret = function getSocketSecret() {
83
97
  };
84
98
  export var onDownload = function onDownload(params, currentApp) {
85
99
  if (!params || !currentApp) return;
100
+ var title = params.pageTitle || '页面列表';
86
101
  ajax(api.download, {
87
102
  method: 'post',
88
- data: _objectSpread({
103
+ data: _objectSpread(_objectSpread({
89
104
  appId: currentApp.appId,
90
- platform: 3
91
- }, params),
105
+ platform: 3,
106
+ module: 'page'
107
+ }, params), {}, {
108
+ down: {
109
+ fname: base64.encode(title, false),
110
+ titles: []
111
+ }
112
+ }),
92
113
  responseType: 'blob',
93
- fileName: '页面列表',
114
+ fileName: title,
94
115
  getResponse: true
95
116
  }).then(function () {});
96
117
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/modules-page",
3
- "version": "1.0.1-alpha.3",
3
+ "version": "1.0.1-alpha.30",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -39,7 +39,7 @@
39
39
  "@types/lodash": "^4.14.197",
40
40
  "@umijs/fabric": "^2.8.1",
41
41
  "@umijs/test": "^3.0.5",
42
- "@zgfe/business-lib": "1.1.76-page.0",
42
+ "@zgfe/business-lib": "1.1.84-panel.5",
43
43
  "antd": "^4.22.6",
44
44
  "dumi": "^1.1.0",
45
45
  "father": "^4.0.0-rc.2",
@@ -50,5 +50,5 @@
50
50
  "prettier": "^2.2.1",
51
51
  "yorkie": "^2.0.0"
52
52
  },
53
- "gitHead": "d0b4bcb08f0d51b7d891d84c3f0b12fd466f44a5"
53
+ "gitHead": "ab6c3654729a62e3dbeaa91a7877f808b5591a99"
54
54
  }