@zgfe/modules-page 1.0.1-alpha.2 → 1.0.1-alpha.20

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 +10 -11
  6. package/dist/esm/components/detail/index.js +34 -55
  7. package/dist/esm/components/detail/index.less +1 -0
  8. package/dist/esm/components/groupModal/index.d.ts +2 -6
  9. package/dist/esm/components/groupModal/index.js +29 -25
  10. package/dist/esm/components/groupModal/index.less +17 -0
  11. package/dist/esm/components/groupModal/inputSelect.d.ts +9 -0
  12. package/dist/esm/components/groupModal/inputSelect.js +67 -0
  13. package/dist/esm/components/groupModal/pageItem.js +47 -58
  14. package/dist/esm/components/groupModal/types.d.ts +2 -2
  15. package/dist/esm/components/groupModal/utils.js +2 -8
  16. package/dist/esm/components/pageSelect/index.js +27 -21
  17. package/dist/esm/components/pageSelect/types.d.ts +0 -2
  18. package/dist/esm/components/searchPanel/index.d.ts +1 -1
  19. package/dist/esm/components/searchPanel/index.js +11 -10
  20. package/dist/esm/components/searchPanel/index.less +3 -3
  21. package/dist/esm/components/searchPanel/types.d.ts +3 -3
  22. package/dist/esm/components/searchPanel/util.d.ts +4 -4
  23. package/dist/esm/components/searchPanel/util.js +34 -28
  24. package/dist/esm/constants/api.js +1 -1
  25. package/dist/esm/modules/home/demo/index.js +25 -2
  26. package/dist/esm/modules/home/index.js +91 -50
  27. package/dist/esm/modules/home/style/index.less +10 -0
  28. package/dist/esm/modules/home/types.d.ts +8 -0
  29. package/dist/esm/modules/home/utils.d.ts +3 -3
  30. package/dist/esm/modules/home/utils.js +25 -10
  31. package/package.json +4 -3
  32. package/dist/esm/components/groupModal/mock.d.ts +0 -5
  33. package/dist/esm/components/groupModal/mock.js +0 -16
@@ -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
15
  import { BizGlobalDataContext, BizLayout } from '@zgfe/business-lib';
16
- import { Button, Spin } from 'antd';
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,54 +30,66 @@ var ModulesPage = function ModulesPage(props) {
29
30
  _useState2 = _slicedToArray(_useState, 2),
30
31
  currentType = _useState2[0],
31
32
  setCurrentType = _useState2[1];
32
- // 查询条件
33
+ // 最新查询条件
33
34
  var _useState3 = useState(),
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];
61
- // 要编辑的分组
62
- var _useState15 = useState(),
62
+ result = _useState14[0],
63
+ setResult = _useState14[1];
64
+ var _useState15 = useState(true),
63
65
  _useState16 = _slicedToArray(_useState15, 2),
64
- editGroup = _useState16[0],
65
- setEditGroup = _useState16[1];
66
- // 当前页面类型 list/detail
67
- var _useState17 = useState('list'),
66
+ loading = _useState16[0],
67
+ setLoading = _useState16[1];
68
+ var _useState17 = useState(true),
68
69
  _useState18 = _slicedToArray(_useState17, 2),
69
- pageType = _useState18[0],
70
- setPageType = _useState18[1];
71
- var _useState19 = useState(0),
70
+ pageLoading = _useState18[0],
71
+ setPageLoading = _useState18[1];
72
+ // 要编辑的分组
73
+ var _useState19 = useState(),
72
74
  _useState20 = _slicedToArray(_useState19, 2),
73
- timer = _useState20[0],
74
- setTimer = _useState20[1];
75
- //当前点击内容(用于同步查询条件中的内容)
76
- var _useState21 = useState(),
75
+ editGroup = _useState20[0],
76
+ setEditGroup = _useState20[1];
77
+ // 当前页面类型 list/detail
78
+ var _useState21 = useState('list'),
77
79
  _useState22 = _slicedToArray(_useState21, 2),
78
- currentClickPage = _useState22[0],
79
- setCurrentClickPage = _useState22[1];
80
+ pageType = _useState22[0],
81
+ setPageType = _useState22[1];
82
+ var _useState23 = useState(0),
83
+ _useState24 = _slicedToArray(_useState23, 2),
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
+ // 查询条件ref
92
+ var selectRef = useRef(null);
80
93
  var _useContext = useContext(BizGlobalDataContext),
81
94
  eventGroupList = _useContext.eventGroupList,
82
95
  currentApp = _useContext.currentApp;
@@ -95,10 +108,13 @@ var ModulesPage = function ModulesPage(props) {
95
108
  useEffect(function () {
96
109
  var param = {
97
110
  appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId,
98
- platform: (currentApp === null || currentApp === void 0 ? void 0 : currentApp.platform) || 0
111
+ platform: 3
99
112
  };
100
- getPageGroupList(param, setPageGroupList);
101
113
  getPageList(param, setPageList);
114
+ getPageGroupList(param, setPageGroupList, setPageLoading);
115
+ if (props.value) {
116
+ setSearchValue(props.value);
117
+ }
102
118
  }, []);
103
119
  useEffect(function () {
104
120
  if (!showGroup) {
@@ -108,15 +124,21 @@ var ModulesPage = function ModulesPage(props) {
108
124
  useEffect(function () {
109
125
  if (isEmpty) return;
110
126
  if (!searchValue) return;
111
- console.log('searchValue:', searchValue);
112
127
  var type = searchValue !== null && searchValue !== void 0 && searchValue.pageGroup || (searchValue === null || searchValue === void 0 ? void 0 : searchValue.pageGroup) === 0 ? 'pageGroup' : 'page';
113
128
  setCurrentType(type);
114
129
  // 选择概览时,跳到列表页
115
130
  if (type === 'page' && !(searchValue !== null && searchValue !== void 0 && searchValue.pageUrl) || type === 'pageGroup' && !(searchValue !== null && searchValue !== void 0 && searchValue.pageGroup)) {
116
131
  setPageType('list');
117
132
  }
133
+ if (type === 'pageGroup' && !(searchValue !== null && searchValue !== void 0 && searchValue.pageGroup)) return;
118
134
  if (type === 'page' || pageType === 'detail') {
119
135
  fetch();
136
+ } else if (type === 'pageGroup') {
137
+ props.onChange && props.onChange(_objectSpread({
138
+ appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId,
139
+ platform: 3,
140
+ module: 'page'
141
+ }, searchValue));
120
142
  }
121
143
  }, [searchValue]);
122
144
  // 查询结果
@@ -126,14 +148,21 @@ var ModulesPage = function ModulesPage(props) {
126
148
  }
127
149
  setLoading(true);
128
150
  setTimer(setTimeout(function () {
151
+ if (_.isEqual(originSearchValue, searchValue)) {
152
+ setLoading(false);
153
+ return;
154
+ }
155
+ setOriginSearchValue(_.cloneDeep(searchValue));
129
156
  var param = _objectSpread({
130
157
  appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId,
131
- platform: (currentApp === null || currentApp === void 0 ? void 0 : currentApp.platform) || 0
158
+ platform: 3,
159
+ module: 'page'
132
160
  }, searchValue);
161
+ props.onChange && props.onChange(param);
133
162
  getPageResult(param, setResult, setLoading);
134
163
  }, 500));
135
164
  };
136
- // 改变查询条件
165
+ // 改变查询条件/
137
166
  var onChange = function onChange(data) {
138
167
  setSearchValue(function (value) {
139
168
  if (!value) return data;
@@ -150,11 +179,12 @@ var ModulesPage = function ModulesPage(props) {
150
179
  };
151
180
  // 分组弹窗编辑回调,更新分组列表
152
181
  var onOk = function onOk() {
182
+ setShowGroup(false);
153
183
  var param = {
154
184
  appId: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId,
155
- platform: (currentApp === null || currentApp === void 0 ? void 0 : currentApp.platform) || 0
185
+ platform: 3
156
186
  };
157
- getPageGroupList(param, setPageGroupList);
187
+ getPageGroupList(param, setPageGroupList, setPageLoading);
158
188
  };
159
189
 
160
190
  // 点击表格中页面
@@ -173,6 +203,7 @@ var ModulesPage = function ModulesPage(props) {
173
203
  className: "".concat(classPrefix, "-top-render")
174
204
  }, /*#__PURE__*/React.createElement(Button, {
175
205
  type: "primary",
206
+ disabled: loading || !result || !result.length,
176
207
  onClick: props.onClickWarn
177
208
  }, "\u8BBE\u7F6E\u6D41\u5931\u9884\u8B66"));
178
209
  if (isEmpty) return /*#__PURE__*/React.createElement(EmptyPanel, null);
@@ -186,12 +217,22 @@ var ModulesPage = function ModulesPage(props) {
186
217
  }, /*#__PURE__*/React.createElement(BizLayout, {
187
218
  title: "\u9875\u9762\u5206\u6790",
188
219
  hasCollapse: true,
189
- topPanel: /*#__PURE__*/React.createElement(SearchPanel, {
220
+ topPanel: /*#__PURE__*/React.createElement(Skeleton, {
221
+ loading: pageLoading,
222
+ active: true,
223
+ paragraph: {
224
+ rows: 4
225
+ }
226
+ }, /*#__PURE__*/React.createElement(SearchPanel, {
227
+ ref: selectRef,
190
228
  value: searchValue,
191
229
  onChange: onChange
192
- }),
193
- topRender: props.onClickWarn ? render : null
194
- }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(TopContent, {
230
+ })),
231
+ topRender: props.onClickWarn ? render : null,
232
+ collapseRef: selectRef
233
+ }, /*#__PURE__*/React.createElement(Spin, {
234
+ spinning: pageLoading
235
+ }, /*#__PURE__*/React.createElement(TopContent, {
195
236
  value: searchValue === null || searchValue === void 0 ? void 0 : searchValue.time,
196
237
  type: currentType,
197
238
  disabled: !result.length,
@@ -203,9 +244,9 @@ var ModulesPage = function ModulesPage(props) {
203
244
  onDownload: function onDownload() {
204
245
  return _onDownload(searchValue, currentApp);
205
246
  }
206
- }), /*#__PURE__*/React.createElement(Spin, {
207
- spinning: loading
208
- }, pageType === 'list' ? /*#__PURE__*/React.createElement(PageContent, {
247
+ }), loading ? /*#__PURE__*/React.createElement("div", {
248
+ className: "".concat(classPrefix, "-content")
249
+ }, /*#__PURE__*/React.createElement(Spin, null)) : pageType === 'list' ? /*#__PURE__*/React.createElement(PageContent, {
209
250
  type: currentType,
210
251
  value: result,
211
252
  groupId: searchValue === null || searchValue === void 0 ? void 0 : searchValue.pageGroup,
@@ -218,7 +259,7 @@ var ModulesPage = function ModulesPage(props) {
218
259
  }) : /*#__PURE__*/React.createElement(DetailContent, {
219
260
  params: searchValue,
220
261
  result: result
221
- })), showGroup ? /*#__PURE__*/React.createElement(GroupModal, {
262
+ }), showGroup ? /*#__PURE__*/React.createElement(GroupModal, {
222
263
  value: editGroup,
223
264
  onCancel: function onCancel() {
224
265
  return setShowGroup(false);
@@ -19,4 +19,14 @@
19
19
  border: 1px solid #ecedf0;
20
20
  border-radius: 8px;
21
21
  }
22
+
23
+ &-content {
24
+ display: flex;
25
+ align-items: center;
26
+ justify-content: center;
27
+ width: 100%;
28
+ min-height: 300px;
29
+ margin-top: 60px;
30
+ background-color: #fff;
31
+ }
22
32
  }
@@ -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,6 +33,10 @@ 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[];
@@ -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) => 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) => 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: '页面概览',
@@ -36,12 +36,13 @@ export var getPageList = function getPageList(data, callback) {
36
36
  };
37
37
 
38
38
  // 获取页面分组列表
39
- export var getPageGroupList = function getPageGroupList(data, callback) {
39
+ export var getPageGroupList = function getPageGroupList(data, callback, loadingCallback) {
40
+ loadingCallback && loadingCallback(true);
40
41
  ajax(api.getPageGroup, {
41
42
  method: 'post',
42
43
  data: data
43
44
  }).then(function (res) {
44
- if (!res) {
45
+ if (!res || !res.data) {
45
46
  callback([{
46
47
  id: 0,
47
48
  name: '全部页面组'
@@ -54,6 +55,8 @@ export var getPageGroupList = function getPageGroupList(data, callback) {
54
55
  name: '全部页面组'
55
56
  });
56
57
  callback(list);
58
+ }).finally(function () {
59
+ loadingCallback && loadingCallback(false);
57
60
  });
58
61
  };
59
62
 
@@ -64,8 +67,13 @@ export var getPageResult = function getPageResult(params, callback, loadingCallb
64
67
  method: 'post',
65
68
  data: params
66
69
  }).then(function (res) {
67
- if (!res) return;
68
- callback(res.data);
70
+ var _res$data;
71
+ if (!res || !res.data) return;
72
+ callback((_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.map(function (item) {
73
+ return _objectSpread(_objectSpread({}, item), {}, {
74
+ id: "".concat(item.userGroup, "-").concat(item.pageTitle, "-").concat(item.pageUrl)
75
+ });
76
+ }));
69
77
  }).finally(function () {
70
78
  loadingCallback(false);
71
79
  });
@@ -80,14 +88,21 @@ export var getSocketSecret = function getSocketSecret() {
80
88
  };
81
89
  export var onDownload = function onDownload(params, currentApp) {
82
90
  if (!params || !currentApp) return;
91
+ var title = params.pageTitle || '页面列表';
83
92
  ajax(api.download, {
84
93
  method: 'post',
85
- data: _objectSpread({
94
+ data: _objectSpread(_objectSpread({
86
95
  appId: currentApp.appId,
87
- platform: currentApp.platform
88
- }, params),
96
+ platform: 3,
97
+ module: 'page'
98
+ }, params), {}, {
99
+ down: {
100
+ fname: base64.encode(title, false),
101
+ titles: []
102
+ }
103
+ }),
89
104
  responseType: 'blob',
90
- fileName: '页面列表',
105
+ fileName: title,
91
106
  getResponse: true
92
107
  }).then(function () {});
93
108
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/modules-page",
3
- "version": "1.0.1-alpha.2",
3
+ "version": "1.0.1-alpha.20",
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.81-page.10",
43
43
  "antd": "^4.22.6",
44
44
  "dumi": "^1.1.0",
45
45
  "father": "^4.0.0-rc.2",
@@ -49,5 +49,6 @@
49
49
  "lodash": "^4.17.21",
50
50
  "prettier": "^2.2.1",
51
51
  "yorkie": "^2.0.0"
52
- }
52
+ },
53
+ "gitHead": "ec25eecbfc957817643b49e2df5d8f03e14463e4"
53
54
  }
@@ -1,5 +0,0 @@
1
- declare const _default: {
2
- label: string;
3
- value: string;
4
- }[];
5
- export default _default;
@@ -1,16 +0,0 @@
1
- export default [{
2
- label: 'file:///C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%207.0/webapps/test/test.html',
3
- value: 'file:///C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%207.0/webapps/test/test.html'
4
- }, {
5
- label: 'file:///C:/Users/54451/Desktop/sign/signin.html',
6
- value: 'file:///C:/Users/54451/Desktop/sign/signin.html'
7
- }, {
8
- label: 'http://localhost:8080/sign/signup.html',
9
- value: 'http://localhost:8080/sign/signup.html'
10
- }, {
11
- label: 'http://www.yayibang.com/html/web/article/index.html',
12
- value: 'http://www.yayibang.com/html/web/article/index.html'
13
- }, {
14
- label: 'http://localhost:8080/#/login',
15
- value: 'http://localhost:8080/#/login'
16
- }];