@cloud-app-dev/vidc 2.0.0-alpha.1 → 2.0.0-alpha.2
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.
- package/.umirc.ts +1 -2
- package/es/Api/index.d.ts +3 -4
- package/es/Api/index.js +7 -8
- package/es/AppRedirect/index.css +0 -0
- package/es/AppRedirect/index.d.ts +16 -0
- package/es/AppRedirect/index.js +38 -0
- package/es/AppRoute/Render.d.ts +23 -0
- package/es/AppRoute/Render.js +111 -0
- package/es/AppRoute/Rendered.d.ts +4 -0
- package/es/AppRoute/Rendered.js +11 -0
- package/es/AppRoute/index.css +0 -0
- package/es/AppRoute/index.d.ts +14 -0
- package/es/AppRoute/index.js +106 -0
- package/es/AppRoute/interface.d.ts +18 -0
- package/es/AppRoute/utils.d.ts +1 -0
- package/es/AppRoute/utils.js +28 -0
- package/es/Auth/index.d.ts +8 -0
- package/es/Auth/index.js +17 -0
- package/es/AutoExit/index.js +8 -5
- package/es/CheckGroupFixed/index.css +49 -0
- package/es/CheckGroupFixed/index.d.ts +17 -0
- package/es/CheckGroupFixed/index.js +146 -0
- package/es/Config/index.js +24 -3
- package/es/Config/interface.d.ts +9 -1
- package/es/Config/utils.d.ts +6 -1
- package/es/ConfigContext/index.d.ts +3 -0
- package/es/ContentBox/BetweenBox/index.css +5 -0
- package/es/ContentBox/BetweenBox/index.d.ts +12 -0
- package/es/ContentBox/BetweenBox/index.js +24 -0
- package/es/ContentBox/InfoBox/index.css +23 -0
- package/es/ContentBox/InfoBox/index.d.ts +12 -0
- package/es/ContentBox/InfoBox/index.js +26 -0
- package/es/ContentBox/TwoColumnBox/index.css +77 -0
- package/es/ContentBox/TwoColumnBox/index.d.ts +10 -0
- package/es/ContentBox/TwoColumnBox/index.js +50 -0
- package/es/ContentBox/deps/content-grid.d.ts +9 -0
- package/es/ContentBox/deps/content-grid.js +9 -0
- package/es/ContentBox/deps/grid-factory.d.ts +10 -0
- package/es/ContentBox/deps/grid-factory.js +72 -0
- package/es/ContentBox/deps/simple-grid.d.ts +9 -0
- package/es/ContentBox/deps/simple-grid.js +8 -0
- package/es/ContentBox/index.css +9 -0
- package/es/ContentBox/index.d.ts +14 -0
- package/es/ContentBox/index.js +28 -0
- package/es/DeviceIcon/icon.js +5 -5
- package/es/DeviceIcon/index.js +2 -2
- package/es/DeviceList/index.d.ts +1 -1
- package/es/DeviceList/index.js +4 -4
- package/es/DeviceSelect/index.js +2 -2
- package/es/Dict/cache.d.ts +3 -0
- package/es/Dict/cache.js +21 -0
- package/es/Dict/desc.d.ts +64 -0
- package/es/Dict/desc.js +162 -0
- package/es/Dict/device.d.ts +28 -0
- package/es/Dict/device.js +117 -0
- package/es/Dict/hook.d.ts +4 -0
- package/es/Dict/hook.js +114 -0
- package/es/Dict/index.d.ts +13 -0
- package/es/Dict/index.js +14 -0
- package/es/Dict/interface.d.ts +16 -0
- package/es/Dict/utils.d.ts +11 -0
- package/es/Dict/utils.js +51 -0
- package/es/Drag/DragAndDropItem.d.ts +4 -0
- package/es/Drag/DragAndDropItem.js +145 -0
- package/es/Drag/DropItem.d.ts +4 -0
- package/es/Drag/DropItem.js +54 -0
- package/es/Drag/index.css +0 -0
- package/es/Drag/index.d.ts +7 -0
- package/es/Drag/index.js +7 -0
- package/es/Drag/interface.d.ts +16 -0
- package/es/Drawer/Demo.d.ts +3 -0
- package/es/Drawer/Demo.js +52 -0
- package/es/Drawer/Footer.d.ts +4 -0
- package/es/Drawer/Footer.js +26 -0
- package/es/Drawer/index.css +39 -0
- package/es/Drawer/index.d.ts +12 -0
- package/es/Drawer/index.js +41 -0
- package/es/Drawer/interface.d.ts +191 -0
- package/es/DynamicDeviceList/CheckExt.js +3 -3
- package/es/DynamicDeviceList/index.js +2 -2
- package/es/DynamicDeviceList/utils.js +2 -2
- package/es/DynamicList/demo.d.ts +2 -0
- package/es/DynamicList/demo.js +71 -0
- package/es/DynamicList/index.css +7 -0
- package/es/DynamicList/index.d.ts +31 -0
- package/es/DynamicList/index.js +132 -0
- package/es/FullScreen/index.css +16 -0
- package/es/FullScreen/index.d.ts +10 -0
- package/es/FullScreen/index.js +68 -0
- package/es/HightLevel/index.css +3 -0
- package/es/HightLevel/index.d.ts +9 -0
- package/es/HightLevel/index.js +22 -0
- package/es/IconFont/index.css +0 -0
- package/es/IconFont/index.d.ts +13 -0
- package/es/IconFont/index.js +58 -0
- package/es/ImageView/index.css +6 -0
- package/es/ImageView/index.d.ts +17 -0
- package/es/ImageView/index.js +58 -0
- package/es/InitialConfig/index.js +5 -9
- package/es/InitialRequest/index.js +2 -2
- package/es/InitialRequest/utils.js +1 -1
- package/es/Input/index.css +8 -0
- package/es/Input/index.d.ts +18 -0
- package/es/Input/index.js +75 -0
- package/es/LabelValue/index.css +18 -0
- package/es/LabelValue/index.d.ts +23 -0
- package/es/LabelValue/index.js +32 -0
- package/es/List/CheckExt.d.ts +10 -0
- package/es/List/CheckExt.js +28 -0
- package/es/List/index.css +62 -6
- package/es/List/index.d.ts +73 -11
- package/es/List/index.js +162 -36
- package/es/List/renderItem.d.ts +20 -0
- package/es/List/renderItem.js +68 -0
- package/es/List/utils.d.ts +5 -0
- package/es/List/utils.js +18 -0
- package/es/ListExt/index.css +9 -0
- package/es/ListExt/index.d.ts +19 -0
- package/es/ListExt/index.js +44 -0
- package/es/LoaderScript/index.d.ts +26 -0
- package/es/LoaderScript/index.js +127 -0
- package/es/LoaderScript/interface.d.ts +26 -0
- package/es/LoaderScript/utils.d.ts +12 -0
- package/es/LoaderScript/utils.js +110 -0
- package/es/Modal/index.css +43 -0
- package/es/Modal/index.d.ts +17 -0
- package/es/Modal/index.js +34 -0
- package/es/Modal/interface.d.ts +339 -0
- package/es/Picture/component/DefaultRects/RectInfo.d.ts +7 -0
- package/es/Picture/component/DefaultRects/RectInfo.js +94 -0
- package/es/Picture/component/DefaultRects/index.css +247 -0
- package/es/Picture/component/DefaultRects/index.d.ts +12 -0
- package/es/Picture/component/DefaultRects/index.js +47 -0
- package/es/Picture/component/DefaultRects/utils.d.ts +2 -0
- package/es/Picture/component/DefaultRects/utils.js +11 -0
- package/es/Picture/component/DrawRect/index.css +8 -0
- package/es/Picture/component/DrawRect/index.d.ts +14 -0
- package/es/Picture/component/DrawRect/index.js +41 -0
- package/es/Picture/component/MoveContent/index.css +0 -0
- package/es/Picture/component/MoveContent/index.d.ts +39 -0
- package/es/Picture/component/MoveContent/index.js +240 -0
- package/es/Picture/component/MoveContent/utils.d.ts +4 -0
- package/es/Picture/component/MoveContent/utils.js +19 -0
- package/es/Picture/component/RectMenu/index.css +31 -0
- package/es/Picture/component/RectMenu/index.d.ts +13 -0
- package/es/Picture/component/RectMenu/index.js +81 -0
- package/es/Picture/component/RectMenu/utils.d.ts +12 -0
- package/es/Picture/component/RectMenu/utils.js +22 -0
- package/es/Picture/component/Tools/index.css +42 -0
- package/es/Picture/component/Tools/index.d.ts +13 -0
- package/es/Picture/component/Tools/index.js +83 -0
- package/es/Picture/component/WheelScale/index.d.ts +6 -0
- package/es/Picture/component/WheelScale/index.js +29 -0
- package/es/Picture/dragBound.d.ts +5 -0
- package/es/Picture/dragBound.js +77 -0
- package/es/Picture/index.css +12 -0
- package/es/Picture/index.d.ts +16 -0
- package/es/Picture/index.js +344 -0
- package/es/Picture/interface.d.ts +67 -0
- package/es/Picture/loadCaptureRectImage.d.ts +8 -0
- package/es/Picture/loadCaptureRectImage.js +119 -0
- package/es/Picture/useDraw.d.ts +1 -0
- package/es/Picture/useDraw.js +136 -0
- package/es/Picture/utils.d.ts +22 -0
- package/es/Picture/utils.js +90 -0
- package/es/Progress/index.css +20 -0
- package/es/Progress/index.d.ts +11 -0
- package/es/Progress/index.js +68 -0
- package/es/RefDrawer/index.js +4 -5
- package/es/RefModal/index.js +4 -5
- package/es/ScrollList/index.css +73 -0
- package/es/ScrollList/index.d.ts +24 -0
- package/es/ScrollList/index.js +261 -0
- package/es/ScrollList/utils.js +84 -0
- package/es/Service/http.js +0 -17
- package/es/TableLayout/index.css +4 -0
- package/es/TableLayout/index.d.ts +10 -0
- package/es/TableLayout/index.js +64 -0
- package/es/ThemeAntd/index.css +501 -0
- package/es/ThemeAntd/index.d.ts +7 -0
- package/es/ThemeAntd/index.js +6 -0
- package/es/ThemeAntd/style/button.css +46 -0
- package/es/ThemeAntd/style/checkbox.css +64 -0
- package/es/ThemeAntd/style/form.css +10 -0
- package/es/ThemeAntd/style/input.css +58 -0
- package/es/ThemeAntd/style/pagination.css +44 -0
- package/es/ThemeAntd/style/picker.css +86 -0
- package/es/ThemeAntd/style/popover.css +3 -0
- package/es/ThemeAntd/style/radio.css +71 -0
- package/es/ThemeAntd/style/scrollbar.css +19 -0
- package/es/ThemeAntd/style/select.css +57 -0
- package/es/ThemeAntd/style/table.css +36 -0
- package/es/ThemeAntd/style/tree.css +4 -0
- package/es/Tree/demo.d.ts +2 -0
- package/es/Tree/demo.js +69 -0
- package/es/Tree/index.css +64 -0
- package/es/Tree/index.d.ts +24 -0
- package/es/Tree/index.js +83 -0
- package/es/TreeMode/index.d.ts +1 -1
- package/es/TreeMode/index.js +6 -6
- package/es/TreeTitle/index.js +2 -2
- package/es/UserSelect/index.d.ts +3 -3
- package/es/UserSelect/index.js +13 -15
- package/es/VList/index.css +4 -0
- package/es/VList/index.d.ts +16 -0
- package/es/VList/index.js +56 -0
- package/es/VList/utils.d.ts +10 -0
- package/es/VList/utils.js +17 -0
- package/es/WorkerFlow/Form/Condition.js +6 -6
- package/es/WorkerFlow/Form/EmptyUserSet.js +2 -2
- package/es/WorkerFlow/Form/FormAuth.js +2 -2
- package/es/WorkerFlow/Form/GroupSelect.js +2 -2
- package/es/WorkerFlow/Form/GroupSelectModalContent.js +5 -5
- package/es/WorkerFlow/Form/LevelGroupSelect.js +3 -3
- package/es/WorkerFlow/Form/UserAndGroupSelect.js +2 -2
- package/es/WorkerFlow/Form/UserSelect.js +2 -2
- package/es/WorkerFlow/Form/UserSelectModalContent.js +3 -4
- package/es/WorkerFlow/Form/UserSet.js +2 -2
- package/es/WorkerFlow/Nodes/Add.js +2 -3
- package/es/WorkerFlow/Nodes/AddOption.js +2 -2
- package/es/WorkerFlow/Nodes/Approver.js +2 -2
- package/es/WorkerFlow/Nodes/Condition.js +2 -2
- package/es/WorkerFlow/Nodes/Handle.js +2 -2
- package/es/WorkerFlow/Nodes/Notifier.js +2 -2
- package/es/WorkerFlow/Nodes/TitleElement.js +5 -8
- package/es/WorkerFlow/index.js +2 -3
- package/es/core.d.ts +27 -0
- package/es/index.d.ts +30 -0
- package/es/index.js +30 -0
- package/es/useChangeEffect/index.d.ts +3 -0
- package/es/useChangeEffect/index.js +32 -0
- package/es/useDrawer/index.d.ts +14 -0
- package/es/useDrawer/index.js +90 -0
- package/es/useHistory/index.css +0 -0
- package/es/useHistory/index.d.ts +3 -0
- package/es/useHistory/index.js +14 -0
- package/es/useHttp/index.d.ts +8 -0
- package/es/useHttp/index.js +78 -0
- package/es/useModal/index.d.ts +14 -0
- package/es/useModal/index.js +92 -0
- package/es/utils.d.ts +2 -0
- package/es/utils.js +32 -0
- package/package.json +11 -5
package/es/DeviceIcon/icon.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import Dict from '../Dict';
|
|
3
2
|
/**根据设备类型和状态获取设备展示图标 */
|
|
3
|
+
|
|
4
4
|
export var getCameraTypeIcon = function getCameraTypeIcon(type, status) {
|
|
5
|
-
var _Dict$device =
|
|
5
|
+
var _Dict$device = Dict.device,
|
|
6
6
|
znxj = _Dict$device.znxj,
|
|
7
7
|
qj = _Dict$device.qj,
|
|
8
8
|
db = _Dict$device.db,
|
|
@@ -13,7 +13,7 @@ export var getCameraTypeIcon = function getCameraTypeIcon(type, status) {
|
|
|
13
13
|
xfs = _Dict$device.xfs,
|
|
14
14
|
znjg = _Dict$device.znjg,
|
|
15
15
|
qt = _Dict$device.qt;
|
|
16
|
-
var _Dict$device2 =
|
|
16
|
+
var _Dict$device2 = Dict.device,
|
|
17
17
|
ptjk = _Dict$device2.ptjk,
|
|
18
18
|
rlzp = _Dict$device2.rlzp,
|
|
19
19
|
zpj = _Dict$device2.zpj,
|
|
@@ -127,7 +127,7 @@ export var getCameraTypeIcon = function getCameraTypeIcon(type, status) {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
if (Object.keys(option).length === 0) {
|
|
130
|
-
console.debug('
|
|
130
|
+
console.debug('未获取到设备类型!,返回默认');
|
|
131
131
|
option.color = !onLine ? '#ccc' : 'rgba(255, 156, 84, 1)';
|
|
132
132
|
option.bgColor = !onLine ? '#ccc' : '#29CCCC';
|
|
133
133
|
option.icon = 'icon-S_Point_CameraSmart';
|
package/es/DeviceIcon/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import _IconFont from "@cloud-app-dev/basic-components/es/IconFont";
|
|
2
1
|
import { __rest } from "tslib";
|
|
3
2
|
import React, { useMemo } from 'react';
|
|
3
|
+
import IconFont from '../IconFont';
|
|
4
4
|
import { getCameraTypeIcon } from './icon';
|
|
5
5
|
import "./index.css";
|
|
6
6
|
|
|
@@ -27,7 +27,7 @@ function DeviceIcon(_a) {
|
|
|
27
27
|
var iconClassName = useMemo(function () {
|
|
28
28
|
return onLine ? onlineClass : offlineClass;
|
|
29
29
|
}, [offlineClass, onLine, onlineClass]);
|
|
30
|
-
return /*#__PURE__*/React.createElement(
|
|
30
|
+
return /*#__PURE__*/React.createElement(IconFont, Object.assign({
|
|
31
31
|
style: style,
|
|
32
32
|
type: options.icon,
|
|
33
33
|
className: "".concat(iconClassName, " ").concat(className ? className : '')
|
package/es/DeviceList/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { CheckListProps } from '../List';
|
|
2
3
|
import { DeviceItemType } from '../core';
|
|
3
|
-
import { CheckListProps } from '@cloud-app-dev/basic-components/es/CheckList';
|
|
4
4
|
import './index.less';
|
|
5
5
|
interface DeviceListProps extends CheckListProps<DeviceItemType> {
|
|
6
6
|
deviceList?: Array<DeviceItemType>;
|
package/es/DeviceList/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import _IconFont from "@cloud-app-dev/basic-components/es/IconFont";
|
|
2
|
-
import _CheckList from "@cloud-app-dev/basic-components/es/CheckList";
|
|
3
1
|
import { __rest } from "tslib";
|
|
4
2
|
import React, { useCallback } from 'react';
|
|
3
|
+
import List from '../List';
|
|
4
|
+
import IconFont from '../IconFont';
|
|
5
5
|
import DeviceIcon from '../DeviceIcon';
|
|
6
6
|
import TreeTitle from '../TreeTitle';
|
|
7
7
|
import "./index.css";
|
|
@@ -30,7 +30,7 @@ function DeviceList(_a) {
|
|
|
30
30
|
e.preventDefault();
|
|
31
31
|
deleteItem && deleteItem(item);
|
|
32
32
|
}, []);
|
|
33
|
-
return /*#__PURE__*/React.createElement(
|
|
33
|
+
return /*#__PURE__*/React.createElement(List, Object.assign({}, props, {
|
|
34
34
|
className: "lm-c-device-list-wrapper ".concat(className),
|
|
35
35
|
list: deviceList,
|
|
36
36
|
itemNameKey: "deviceName",
|
|
@@ -51,7 +51,7 @@ function DeviceList(_a) {
|
|
|
51
51
|
onClick: function onClick(e) {
|
|
52
52
|
return deleteItemAction(item, e);
|
|
53
53
|
}
|
|
54
|
-
}, /*#__PURE__*/React.createElement(
|
|
54
|
+
}, /*#__PURE__*/React.createElement(IconFont, {
|
|
55
55
|
type: "icon-S_Edit_LineClose",
|
|
56
56
|
title: "\u5220\u9664"
|
|
57
57
|
})) : undefined;
|
package/es/DeviceSelect/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _IconFont from "@cloud-app-dev/basic-components/es/IconFont";
|
|
2
1
|
import "antd/lib/menu/style";
|
|
3
2
|
import _Menu from "antd/lib/menu";
|
|
4
3
|
import "antd/lib/dropdown/style";
|
|
@@ -33,6 +32,7 @@ import TreeMode from '../TreeMode';
|
|
|
33
32
|
import DynamicDeviceList from '../DynamicDeviceList';
|
|
34
33
|
import DeviceList from '../DeviceList';
|
|
35
34
|
import { uniq, uniqBy } from 'lodash';
|
|
35
|
+
import IconFont from '../IconFont';
|
|
36
36
|
import "./index.css";
|
|
37
37
|
|
|
38
38
|
function DeviceSelect(_ref) {
|
|
@@ -192,7 +192,7 @@ function DeviceSelect(_ref) {
|
|
|
192
192
|
},
|
|
193
193
|
key: "Place"
|
|
194
194
|
}, "\u884C\u653F\u533A\u5212"))
|
|
195
|
-
}, /*#__PURE__*/React.createElement("span", null, state.mode === 'Place' ? '行政区划' : '设备业务树', " ", /*#__PURE__*/React.createElement(
|
|
195
|
+
}, /*#__PURE__*/React.createElement("span", null, state.mode === 'Place' ? '行政区划' : '设备业务树', " ", /*#__PURE__*/React.createElement(IconFont, {
|
|
196
196
|
style: {
|
|
197
197
|
position: 'relative',
|
|
198
198
|
top: 1
|
package/es/Dict/cache.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import produce from 'immer';
|
|
2
|
+
var dictMap = {
|
|
3
|
+
data: produce({}, function () {}),
|
|
4
|
+
updateDictMap: function updateDictMap(key, value) {
|
|
5
|
+
this.data = produce(this.data, function (draft) {
|
|
6
|
+
draft[key] = value;
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var _global = window;
|
|
11
|
+
|
|
12
|
+
var LMDict = function () {
|
|
13
|
+
if (_global._LM_DICT_) {
|
|
14
|
+
return _global._LM_DICT_;
|
|
15
|
+
} else {
|
|
16
|
+
_global._LM_DICT_ = dictMap;
|
|
17
|
+
return dictMap;
|
|
18
|
+
}
|
|
19
|
+
}();
|
|
20
|
+
|
|
21
|
+
export default LMDict;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DictItem } from './interface';
|
|
3
|
+
export declare function withDict(codes?: any[], isWebVisible?: boolean): (Component: any) => (props: any) => JSX.Element;
|
|
4
|
+
export declare function withTypeCodes(Component: any): {
|
|
5
|
+
new (props: any): {
|
|
6
|
+
componentDidMount(): void;
|
|
7
|
+
render(): JSX.Element;
|
|
8
|
+
context: any;
|
|
9
|
+
setState<K extends "typeCodes" | "isInit">(state: {
|
|
10
|
+
typeCodes: DictItem[];
|
|
11
|
+
isInit: boolean;
|
|
12
|
+
} | ((prevState: Readonly<{
|
|
13
|
+
typeCodes: DictItem[];
|
|
14
|
+
isInit: boolean;
|
|
15
|
+
}>, props: Readonly<any>) => {
|
|
16
|
+
typeCodes: DictItem[];
|
|
17
|
+
isInit: boolean;
|
|
18
|
+
} | Pick<{
|
|
19
|
+
typeCodes: DictItem[];
|
|
20
|
+
isInit: boolean;
|
|
21
|
+
}, K>) | Pick<{
|
|
22
|
+
typeCodes: DictItem[];
|
|
23
|
+
isInit: boolean;
|
|
24
|
+
}, K>, callback?: () => void): void;
|
|
25
|
+
forceUpdate(callback?: () => void): void;
|
|
26
|
+
readonly props: Readonly<any> & Readonly<{
|
|
27
|
+
children?: React.ReactNode;
|
|
28
|
+
}>;
|
|
29
|
+
state: Readonly<{
|
|
30
|
+
typeCodes: DictItem[];
|
|
31
|
+
isInit: boolean;
|
|
32
|
+
}>;
|
|
33
|
+
refs: {
|
|
34
|
+
[key: string]: React.ReactInstance;
|
|
35
|
+
};
|
|
36
|
+
shouldComponentUpdate?(nextProps: Readonly<any>, nextState: Readonly<{
|
|
37
|
+
typeCodes: DictItem[];
|
|
38
|
+
isInit: boolean;
|
|
39
|
+
}>, nextContext: any): boolean;
|
|
40
|
+
componentWillUnmount?(): void;
|
|
41
|
+
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
42
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<any>, prevState: Readonly<{
|
|
43
|
+
typeCodes: DictItem[];
|
|
44
|
+
isInit: boolean;
|
|
45
|
+
}>): any;
|
|
46
|
+
componentDidUpdate?(prevProps: Readonly<any>, prevState: Readonly<{
|
|
47
|
+
typeCodes: DictItem[];
|
|
48
|
+
isInit: boolean;
|
|
49
|
+
}>, snapshot?: any): void;
|
|
50
|
+
componentWillMount?(): void;
|
|
51
|
+
UNSAFE_componentWillMount?(): void;
|
|
52
|
+
componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void;
|
|
53
|
+
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void;
|
|
54
|
+
componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<{
|
|
55
|
+
typeCodes: DictItem[];
|
|
56
|
+
isInit: boolean;
|
|
57
|
+
}>, nextContext: any): void;
|
|
58
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<{
|
|
59
|
+
typeCodes: DictItem[];
|
|
60
|
+
isInit: boolean;
|
|
61
|
+
}>, nextContext: any): void;
|
|
62
|
+
};
|
|
63
|
+
contextType?: React.Context<any>;
|
|
64
|
+
};
|
package/es/Dict/desc.js
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
|
+
|
|
3
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
+
|
|
5
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
6
|
+
|
|
7
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
8
|
+
|
|
9
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
10
|
+
|
|
11
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
|
+
|
|
13
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
14
|
+
|
|
15
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
16
|
+
|
|
17
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
18
|
+
|
|
19
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
20
|
+
|
|
21
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
|
+
|
|
23
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
24
|
+
|
|
25
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
26
|
+
|
|
27
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
28
|
+
|
|
29
|
+
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; }
|
|
30
|
+
|
|
31
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
32
|
+
|
|
33
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
34
|
+
|
|
35
|
+
import React, { useRef, useState, useEffect } from 'react';
|
|
36
|
+
import { queryByTypeCodes, queryTypeCodes, formartItemTextExt } from './utils';
|
|
37
|
+
import LMDict from './cache';
|
|
38
|
+
export function withDict() {
|
|
39
|
+
var codes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
40
|
+
var isWebVisible = arguments.length > 1 ? arguments[1] : undefined;
|
|
41
|
+
return function (Component) {
|
|
42
|
+
return function (props) {
|
|
43
|
+
var isInitRef = useRef(false);
|
|
44
|
+
|
|
45
|
+
var _useState = useState(function () {
|
|
46
|
+
var map = {};
|
|
47
|
+
codes.forEach(function (code) {
|
|
48
|
+
if (LMDict.data[code]) {
|
|
49
|
+
map[code] = LMDict.data[code];
|
|
50
|
+
} else {
|
|
51
|
+
map[code] = [];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return map;
|
|
55
|
+
}),
|
|
56
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
57
|
+
dictMap = _useState2[0],
|
|
58
|
+
setDictMap = _useState2[1];
|
|
59
|
+
|
|
60
|
+
useEffect(function () {
|
|
61
|
+
var nocacheCodes = codes.filter(function (v) {
|
|
62
|
+
return !LMDict.data[v];
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
if (nocacheCodes.length === 0) {
|
|
66
|
+
isInitRef.current = true;
|
|
67
|
+
setDictMap(function (old) {
|
|
68
|
+
return Object.assign({}, old);
|
|
69
|
+
});
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
queryByTypeCodes(nocacheCodes, isWebVisible).then(function (res) {
|
|
74
|
+
isInitRef.current = true;
|
|
75
|
+
var data = res.data;
|
|
76
|
+
data.forEach(function (item) {
|
|
77
|
+
item.label = item.name;
|
|
78
|
+
item.value = item.code;
|
|
79
|
+
item = Object.assign(Object.assign({}, item), formartItemTextExt(item.extText));
|
|
80
|
+
});
|
|
81
|
+
setDictMap(function (old) {
|
|
82
|
+
nocacheCodes.forEach(function (code) {
|
|
83
|
+
var itemCodes = data.filter(function (v1) {
|
|
84
|
+
return +v1.typeCode === +code;
|
|
85
|
+
});
|
|
86
|
+
old[code] = itemCodes;
|
|
87
|
+
LMDict.updateDictMap(code, itemCodes);
|
|
88
|
+
});
|
|
89
|
+
return Object.assign({}, old);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}, []);
|
|
93
|
+
|
|
94
|
+
if (!isInitRef.current) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return /*#__PURE__*/React.createElement(Component, Object.assign({}, props, {
|
|
99
|
+
dictMap: dictMap
|
|
100
|
+
}));
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export function withTypeCodes(Component) {
|
|
105
|
+
return /*#__PURE__*/function (_React$Component) {
|
|
106
|
+
_inherits(withTypeCodesComponent, _React$Component);
|
|
107
|
+
|
|
108
|
+
var _super = _createSuper(withTypeCodesComponent);
|
|
109
|
+
|
|
110
|
+
function withTypeCodesComponent(props) {
|
|
111
|
+
var _this;
|
|
112
|
+
|
|
113
|
+
_classCallCheck(this, withTypeCodesComponent);
|
|
114
|
+
|
|
115
|
+
_this = _super.call(this, props);
|
|
116
|
+
_this.state = {
|
|
117
|
+
typeCodes: LMDict.data['typeCodes'] || [],
|
|
118
|
+
isInit: false
|
|
119
|
+
};
|
|
120
|
+
return _this;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
_createClass(withTypeCodesComponent, [{
|
|
124
|
+
key: "componentDidMount",
|
|
125
|
+
value: function componentDidMount() {
|
|
126
|
+
var _this2 = this;
|
|
127
|
+
|
|
128
|
+
if (!LMDict.data['typeCodes']) {
|
|
129
|
+
queryTypeCodes().then(function (res) {
|
|
130
|
+
LMDict.updateDictMap('typeCodes', res);
|
|
131
|
+
|
|
132
|
+
_this2.setState({
|
|
133
|
+
typeCodes: res,
|
|
134
|
+
isInit: true
|
|
135
|
+
});
|
|
136
|
+
}).catch(function () {
|
|
137
|
+
_this2.setState({
|
|
138
|
+
typeCodes: [],
|
|
139
|
+
isInit: true
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
} else this.setState({
|
|
143
|
+
typeCodes: LMDict.data['typeCodes'],
|
|
144
|
+
isInit: true
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}, {
|
|
148
|
+
key: "render",
|
|
149
|
+
value: function render() {
|
|
150
|
+
if (!this.state.isInit) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return /*#__PURE__*/React.createElement(Component, Object.assign({}, this.props, {
|
|
155
|
+
typeCodes: this.state.typeCodes
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
}]);
|
|
159
|
+
|
|
160
|
+
return withTypeCodesComponent;
|
|
161
|
+
}(React.Component);
|
|
162
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DictItem } from './interface';
|
|
2
|
+
export declare const ptjk: DictItem;
|
|
3
|
+
export declare const rlzp: DictItem;
|
|
4
|
+
export declare const zpj: DictItem;
|
|
5
|
+
export declare const clzpj: DictItem;
|
|
6
|
+
export declare const qmbzpj: DictItem;
|
|
7
|
+
export declare const ydjc: DictItem;
|
|
8
|
+
export declare const qtzp: DictItem;
|
|
9
|
+
export declare const znxj: DictItem;
|
|
10
|
+
export declare const qj: DictItem;
|
|
11
|
+
export declare const db: DictItem;
|
|
12
|
+
export declare const qt: DictItem;
|
|
13
|
+
export declare const dz: DictItem;
|
|
14
|
+
export declare const wgsb: DictItem;
|
|
15
|
+
export declare const xfs: DictItem;
|
|
16
|
+
export declare const znjg: DictItem;
|
|
17
|
+
export declare const wifi: DictItem;
|
|
18
|
+
export declare const mj: DictItem;
|
|
19
|
+
export declare const hw: DictItem;
|
|
20
|
+
export declare const yg: DictItem;
|
|
21
|
+
export declare const deviceStatus: DictItem[];
|
|
22
|
+
export declare const deviceLocation: DictItem[];
|
|
23
|
+
export declare const deviceLocationzWithoutAll: DictItem[];
|
|
24
|
+
export declare const cameraType: DictItem[];
|
|
25
|
+
export declare const cameraDeviceType: DictItem[];
|
|
26
|
+
export declare const cameraAndSoldierType: DictItem[];
|
|
27
|
+
export declare const deviceAndMjType: DictItem[];
|
|
28
|
+
export declare const deviceType: DictItem[];
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
var all = {
|
|
2
|
+
value: '-1',
|
|
3
|
+
label: '全部'
|
|
4
|
+
}; //摄像机状态
|
|
5
|
+
|
|
6
|
+
var on = {
|
|
7
|
+
value: '1',
|
|
8
|
+
label: '在线'
|
|
9
|
+
};
|
|
10
|
+
var off = {
|
|
11
|
+
value: '0',
|
|
12
|
+
label: '离线'
|
|
13
|
+
}; //经纬度状态
|
|
14
|
+
|
|
15
|
+
var noSet = {
|
|
16
|
+
value: '0',
|
|
17
|
+
label: '未设置'
|
|
18
|
+
};
|
|
19
|
+
var isSet = {
|
|
20
|
+
value: '1',
|
|
21
|
+
label: '已设置'
|
|
22
|
+
}; //摄像机类别
|
|
23
|
+
|
|
24
|
+
export var ptjk = {
|
|
25
|
+
value: '119651',
|
|
26
|
+
label: '普通监控'
|
|
27
|
+
};
|
|
28
|
+
export var rlzp = {
|
|
29
|
+
value: '119652',
|
|
30
|
+
label: '人脸抓拍机'
|
|
31
|
+
};
|
|
32
|
+
export var zpj = {
|
|
33
|
+
value: '119653',
|
|
34
|
+
label: '人像抓拍机'
|
|
35
|
+
};
|
|
36
|
+
export var clzpj = {
|
|
37
|
+
value: '119654',
|
|
38
|
+
label: '车辆抓拍机'
|
|
39
|
+
};
|
|
40
|
+
export var qmbzpj = {
|
|
41
|
+
value: '119655',
|
|
42
|
+
label: '全目标抓拍机'
|
|
43
|
+
};
|
|
44
|
+
export var ydjc = {
|
|
45
|
+
value: '119656',
|
|
46
|
+
label: '移动监测'
|
|
47
|
+
};
|
|
48
|
+
export var qtzp = {
|
|
49
|
+
value: '119657',
|
|
50
|
+
label: '其他'
|
|
51
|
+
}; //设备类型
|
|
52
|
+
|
|
53
|
+
export var znxj = {
|
|
54
|
+
value: '100604',
|
|
55
|
+
label: '智能枪机'
|
|
56
|
+
};
|
|
57
|
+
export var qj = {
|
|
58
|
+
value: '100602',
|
|
59
|
+
label: '球机'
|
|
60
|
+
};
|
|
61
|
+
export var db = {
|
|
62
|
+
value: '100605',
|
|
63
|
+
label: '单兵'
|
|
64
|
+
};
|
|
65
|
+
export var qt = {
|
|
66
|
+
value: '100601',
|
|
67
|
+
label: '其他摄像机'
|
|
68
|
+
};
|
|
69
|
+
export var dz = {
|
|
70
|
+
value: '100607',
|
|
71
|
+
label: '道闸'
|
|
72
|
+
};
|
|
73
|
+
export var wgsb = {
|
|
74
|
+
value: '100606',
|
|
75
|
+
label: '网关设备'
|
|
76
|
+
};
|
|
77
|
+
export var xfs = {
|
|
78
|
+
value: '100612',
|
|
79
|
+
label: '消防栓'
|
|
80
|
+
};
|
|
81
|
+
export var znjg = {
|
|
82
|
+
value: '100614',
|
|
83
|
+
label: '智能井盖'
|
|
84
|
+
}; //wifi
|
|
85
|
+
|
|
86
|
+
export var wifi = {
|
|
87
|
+
value: '100611',
|
|
88
|
+
label: 'WI-FI'
|
|
89
|
+
}; //门禁
|
|
90
|
+
|
|
91
|
+
export var mj = {
|
|
92
|
+
value: '103501,103502',
|
|
93
|
+
label: '门禁'
|
|
94
|
+
}; //闸机
|
|
95
|
+
// export const zj = {value: "103407", label: "闸机"}as DictItem
|
|
96
|
+
//红外传感器
|
|
97
|
+
|
|
98
|
+
export var hw = {
|
|
99
|
+
value: '100609',
|
|
100
|
+
label: '红外传感器'
|
|
101
|
+
}; //烟感传感器
|
|
102
|
+
|
|
103
|
+
export var yg = {
|
|
104
|
+
value: '100610',
|
|
105
|
+
label: '烟感传感器'
|
|
106
|
+
};
|
|
107
|
+
export var deviceStatus = [all, on, off];
|
|
108
|
+
export var deviceLocation = [all, noSet, isSet];
|
|
109
|
+
export var deviceLocationzWithoutAll = [noSet, isSet];
|
|
110
|
+
export var cameraType = [all, ptjk, rlzp, zpj, clzpj, qmbzpj, ydjc, qtzp];
|
|
111
|
+
export var cameraDeviceType = [all, znxj, qj, db, qt]; //摄像机+单兵
|
|
112
|
+
|
|
113
|
+
export var cameraAndSoldierType = [all, znxj, qj, db, qt]; //摄像机(无单兵)+门禁
|
|
114
|
+
|
|
115
|
+
export var deviceAndMjType = [all, znxj, qj, wifi, mj, wgsb, dz, xfs, znjg, qt]; //所有设备类型
|
|
116
|
+
|
|
117
|
+
export var deviceType = [all, znxj, qj, db, wifi, mj, wgsb, dz, xfs, znjg, qt, hw, yg];
|
package/es/Dict/hook.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
|
|
7
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
|
+
|
|
9
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
+
|
|
11
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
+
|
|
13
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14
|
+
|
|
15
|
+
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; }
|
|
16
|
+
|
|
17
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
18
|
+
|
|
19
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
|
+
|
|
21
|
+
import { useMemo, useState, useEffect } from 'react';
|
|
22
|
+
import { queryByTypeCode, queryByTypeCodes, queryTypeCodes, formartItemTextExt } from './utils';
|
|
23
|
+
import LMDict from './cache';
|
|
24
|
+
export function useDict(typeCode) {
|
|
25
|
+
var _useState = useState(LMDict.data[typeCode] || []),
|
|
26
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
27
|
+
codes = _useState2[0],
|
|
28
|
+
setCodes = _useState2[1];
|
|
29
|
+
|
|
30
|
+
useEffect(function () {
|
|
31
|
+
if (typeCode && !LMDict.data[typeCode]) {
|
|
32
|
+
queryByTypeCode(typeCode).then(function (res) {
|
|
33
|
+
var data = res.data || [];
|
|
34
|
+
data.forEach(function (item) {
|
|
35
|
+
item.label = item.name;
|
|
36
|
+
item.value = item.code;
|
|
37
|
+
item = Object.assign(Object.assign({}, item), formartItemTextExt(item.extText));
|
|
38
|
+
});
|
|
39
|
+
LMDict.updateDictMap(typeCode, data);
|
|
40
|
+
setCodes(data);
|
|
41
|
+
});
|
|
42
|
+
} else {
|
|
43
|
+
setCodes(function (old) {
|
|
44
|
+
return old.length > 0 ? old : LMDict.data[typeCode] || [];
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}, [typeCode]);
|
|
48
|
+
return codes;
|
|
49
|
+
}
|
|
50
|
+
export function useTypeCodes() {
|
|
51
|
+
var _useState3 = useState(LMDict.data['typeCodes'] || []),
|
|
52
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
53
|
+
typeCodes = _useState4[0],
|
|
54
|
+
setTypeCodes = _useState4[1];
|
|
55
|
+
|
|
56
|
+
useEffect(function () {
|
|
57
|
+
if (!LMDict.data['typeCodes']) {
|
|
58
|
+
queryTypeCodes().then(function (res) {
|
|
59
|
+
setTypeCodes(res);
|
|
60
|
+
LMDict.updateDictMap('typeCode', res);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}, []);
|
|
64
|
+
return typeCodes;
|
|
65
|
+
}
|
|
66
|
+
export function useDicts() {
|
|
67
|
+
var typeCodes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
68
|
+
var isWebVisible = arguments.length > 1 ? arguments[1] : undefined;
|
|
69
|
+
var typeStr = useMemo(function () {
|
|
70
|
+
return typeCodes.toString();
|
|
71
|
+
}, [typeCodes]);
|
|
72
|
+
|
|
73
|
+
var _useState5 = useState(function () {
|
|
74
|
+
return typeCodes.map(function (v) {
|
|
75
|
+
return LMDict.data[v] ? LMDict.data[v] : [];
|
|
76
|
+
});
|
|
77
|
+
}),
|
|
78
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
79
|
+
dicts = _useState6[0],
|
|
80
|
+
setDicts = _useState6[1];
|
|
81
|
+
|
|
82
|
+
useEffect(function () {
|
|
83
|
+
var codes = typeCodes.filter(function (v) {
|
|
84
|
+
return !LMDict.data[v];
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (codes.length === 0) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
queryByTypeCodes(codes, isWebVisible).then(function (res) {
|
|
92
|
+
var data = res.data;
|
|
93
|
+
data.forEach(function (item) {
|
|
94
|
+
item.label = item.name;
|
|
95
|
+
item.value = item.code;
|
|
96
|
+
item = Object.assign(Object.assign({}, item), formartItemTextExt(item.extText));
|
|
97
|
+
});
|
|
98
|
+
setDicts(function (old) {
|
|
99
|
+
codes.forEach(function (code) {
|
|
100
|
+
var itemCodes = data.filter(function (v1) {
|
|
101
|
+
return +v1.typeCode === +code;
|
|
102
|
+
});
|
|
103
|
+
var index = typeCodes.findIndex(function (v) {
|
|
104
|
+
return v === code;
|
|
105
|
+
});
|
|
106
|
+
old[index] = itemCodes;
|
|
107
|
+
LMDict.updateDictMap(code, itemCodes);
|
|
108
|
+
});
|
|
109
|
+
return _toConsumableArray(old);
|
|
110
|
+
});
|
|
111
|
+
}); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
112
|
+
}, [typeStr]);
|
|
113
|
+
return dicts;
|
|
114
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as device from './device';
|
|
2
|
+
import { useDict, useDicts, useTypeCodes } from './hook';
|
|
3
|
+
import { withDict, withTypeCodes } from './desc';
|
|
4
|
+
declare const Dict: {
|
|
5
|
+
useDict: typeof useDict;
|
|
6
|
+
useDicts: typeof useDicts;
|
|
7
|
+
device: typeof device;
|
|
8
|
+
cacheMap: import("./interface").CacheDictType;
|
|
9
|
+
withDict: typeof withDict;
|
|
10
|
+
useTypeCodes: typeof useTypeCodes;
|
|
11
|
+
withTypeCodes: typeof withTypeCodes;
|
|
12
|
+
};
|
|
13
|
+
export default Dict;
|
package/es/Dict/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import LMDict from './cache';
|
|
2
|
+
import * as device from './device';
|
|
3
|
+
import { useDict, useDicts, useTypeCodes } from './hook';
|
|
4
|
+
import { withDict, withTypeCodes } from './desc';
|
|
5
|
+
var Dict = {
|
|
6
|
+
useDict: useDict,
|
|
7
|
+
useDicts: useDicts,
|
|
8
|
+
device: device,
|
|
9
|
+
cacheMap: LMDict,
|
|
10
|
+
withDict: withDict,
|
|
11
|
+
useTypeCodes: useTypeCodes,
|
|
12
|
+
withTypeCodes: withTypeCodes
|
|
13
|
+
};
|
|
14
|
+
export default Dict;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface DictItem {
|
|
2
|
+
label: string;
|
|
3
|
+
code: string;
|
|
4
|
+
id: string;
|
|
5
|
+
value: any;
|
|
6
|
+
name: string;
|
|
7
|
+
extText?: string;
|
|
8
|
+
typeCode?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
icon?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface CacheDictType {
|
|
14
|
+
data: { [key: string]: DictItem[] };
|
|
15
|
+
updateDictMap: (key: any, valuse: DictItem[]) => void;
|
|
16
|
+
}
|