@cniot/android-pda-components 0.2.17 → 0.2.21

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 (114) hide show
  1. package/README.md +4 -21
  2. package/build/assets/index.51a8714a.css +1 -0
  3. package/build/assets/{index.8c37299c.js → index.b428d9a3.js} +29 -29
  4. package/build/assets/vendor.999402d8.js +40 -0
  5. package/build/index.html +3 -3
  6. package/change.md +7 -0
  7. package/package.json +1 -1
  8. package/packages/AppList/doc.jsx +138 -0
  9. package/packages/AppList/index.jsx +33 -0
  10. package/packages/AppList/index.less +52 -0
  11. package/packages/BaseLayout/BarcodeScan.jsx +88 -0
  12. package/packages/BaseLayout/BaseLayoutContainer.jsx +208 -0
  13. package/packages/BaseLayout/RfidOnce.jsx +106 -0
  14. package/packages/BaseLayout/RfidScan.jsx +118 -0
  15. package/packages/BaseLayout/doc.jsx +177 -0
  16. package/packages/BaseLayout/index.jsx +52 -0
  17. package/packages/BaseLayout/index.less +47 -0
  18. package/packages/Button/doc.jsx +62 -0
  19. package/packages/Button/index.jsx +27 -0
  20. package/packages/Button/index.less +62 -0
  21. package/packages/Confirm/doc.jsx +147 -0
  22. package/packages/Confirm/index.jsx +71 -0
  23. package/packages/Confirm/index.less +55 -0
  24. package/packages/Header/doc.jsx +171 -0
  25. package/packages/Header/index.jsx +191 -0
  26. package/packages/Header/index.less +71 -0
  27. package/packages/InfoCard/doc.jsx +244 -0
  28. package/packages/InfoCard/index.jsx +67 -0
  29. package/packages/InfoCard/index.less +111 -0
  30. package/packages/List/doc.jsx +89 -0
  31. package/packages/List/index.jsx +54 -0
  32. package/packages/List/index.less +43 -0
  33. package/packages/Overlay/doc.jsx +103 -0
  34. package/packages/Overlay/index.jsx +42 -0
  35. package/packages/Overlay/index.less +28 -0
  36. package/packages/PdaActionSheet/doc.jsx +193 -0
  37. package/packages/PdaActionSheet/index.jsx +44 -0
  38. package/packages/PdaActionSheet/index.less +65 -0
  39. package/packages/PdaDistanceCard/doc.jsx +62 -0
  40. package/packages/PdaDistanceCard/index.jsx +35 -0
  41. package/packages/PdaDistanceCard/index.less +42 -0
  42. package/packages/PdaFinishCard/doc.jsx +111 -0
  43. package/packages/PdaFinishCard/index.jsx +62 -0
  44. package/packages/PdaFinishCard/index.less +62 -0
  45. package/packages/PdaInfiniteScroll/doc.jsx +121 -0
  46. package/packages/PdaInfiniteScroll/index.jsx +114 -0
  47. package/packages/PdaInfiniteScroll/index.less +12 -0
  48. package/packages/PdaInfiniteScroll/utils.jsx +25 -0
  49. package/packages/PdaSteps/PdaStep/index.jsx +38 -0
  50. package/packages/PdaSteps/PdaStep/index.less +70 -0
  51. package/packages/PdaSteps/PdaSteps/index.jsx +33 -0
  52. package/packages/PdaSteps/PdaSteps/index.less +0 -0
  53. package/packages/PdaSteps/doc.jsx +131 -0
  54. package/packages/PdaSteps/index.jsx +5 -0
  55. package/packages/PdaTitle/doc.jsx +102 -0
  56. package/packages/PdaTitle/index.jsx +51 -0
  57. package/packages/Presentation/doc.jsx +72 -0
  58. package/packages/Presentation/index.jsx +25 -0
  59. package/packages/Presentation/index.less +31 -0
  60. package/packages/SelectCard/doc.jsx +57 -0
  61. package/packages/SelectCard/index.jsx +13 -0
  62. package/packages/SelectCard/index.less +30 -0
  63. package/packages/SimpleCard/doc.jsx +59 -0
  64. package/packages/SimpleCard/index.jsx +13 -0
  65. package/packages/SimpleCard/index.less +38 -0
  66. package/packages/SimpleCardBlock/doc.jsx +77 -0
  67. package/packages/SimpleCardBlock/index.jsx +43 -0
  68. package/packages/SimpleCardBlock/index.less +26 -0
  69. package/packages/SubCard/doc.jsx +63 -0
  70. package/packages/SubCard/index.jsx +28 -0
  71. package/packages/SubCard/index.less +64 -0
  72. package/packages/Tag/doc.jsx +47 -0
  73. package/packages/Tag/index.jsx +12 -0
  74. package/packages/Tag/index.less +22 -0
  75. package/packages/TaskCard/doc.jsx +151 -0
  76. package/packages/TaskCard/index.jsx +65 -0
  77. package/packages/TaskCard/index.less +101 -0
  78. package/packages/Toast/doc.jsx +112 -0
  79. package/packages/Toast/index.jsx +7 -0
  80. package/packages/Toast/index.less +23 -0
  81. package/packages/Toast/methods.jsx +77 -0
  82. package/packages/Toast/toast.jsx +96 -0
  83. package/packages/WakeKeyborard/doc.jsx +170 -0
  84. package/packages/WakeKeyborard/index.jsx +61 -0
  85. package/packages/WakeKeyborard/index.less +55 -0
  86. package/packages/WakeKeyborard/keyborard.jsx +61 -0
  87. package/packages/doc.jsx +19 -0
  88. package/packages/global.less +7 -0
  89. package/packages/index.jsx +60 -0
  90. package/packages/index.less +3 -0
  91. package/packages/pageflow-system-pages/alert/doc.jsx +70 -0
  92. package/packages/pageflow-system-pages/alert/index.jsx +22 -0
  93. package/packages/pageflow-system-pages/confirm/doc.jsx +118 -0
  94. package/packages/pageflow-system-pages/confirm/index.jsx +31 -0
  95. package/packages/pageflow-system-pages/debug/index.jsx +27 -0
  96. package/packages/pageflow-system-pages/debug/index.less +5 -0
  97. package/packages/pageflow-system-pages/index.jsx +38 -0
  98. package/packages/pageflow-system-pages/loading/index.jsx +37 -0
  99. package/packages/pageflow-system-pages/not-found/index.jsx +12 -0
  100. package/packages/pageflow-system-pages/not-found/index.less +26 -0
  101. package/packages/pageflow-system-pages/prompt/doc.jsx +95 -0
  102. package/packages/pageflow-system-pages/prompt/index.jsx +43 -0
  103. package/packages/pageflow-system-pages/prompt/index.less +44 -0
  104. package/packages/pageflow-system-pages/start/index.jsx +28 -0
  105. package/packages/pageflow-system-pages/start/index.less +12 -0
  106. package/packages/pageflow-system-pages/toast/doc.jsx +76 -0
  107. package/packages/pageflow-system-pages/toast/index.jsx +42 -0
  108. package/packages/utils/index.js +56 -0
  109. package/packages/variable.less +4 -0
  110. package/build/assets/index.b8d6d64c.css +0 -1
  111. package/build/assets/vendor.5080796b.js +0 -40
  112. package/es/index.cjs.js +0 -7
  113. package/es/index.es.js +0 -2170
  114. package/es/style.css +0 -1
@@ -0,0 +1,52 @@
1
+ .pda-app-list{
2
+ // width:480px;
3
+ // background:#000000;
4
+ .pda-app-group{
5
+ margin:25px;
6
+
7
+ .group-name{
8
+ font-size:32px;
9
+ line-height:1em;
10
+ margin:0;
11
+ font-size: 32px;
12
+ color: #FFFFFF;
13
+ font-weight:400;
14
+ opacity:0.6;
15
+ }
16
+
17
+ .group-apps{
18
+ display:flex;
19
+ flex-wrap: wrap;
20
+ justify-content: space-between;
21
+ margin-top:25px;
22
+ .app-item{
23
+ display:flex;
24
+ flex-direction:column;
25
+ justify-content:center;
26
+ align-items:center;
27
+ background-image: linear-gradient(138deg, #0091EA 0%, #095FFF 100%);
28
+ border-radius: 12px;
29
+ font-size: 32px;
30
+ color: #FFFFFF;
31
+ min-height:126px;
32
+ flex:1;
33
+ min-width:48%;
34
+ max-width:48%;
35
+ margin-bottom:25px;
36
+ cursor: pointer;
37
+
38
+ &:hover,&:active,&:focus{
39
+ background-image: linear-gradient(45deg, #0091EA 0%, #095FFF 100%);
40
+ box-shadow: 0 0 1px 2px #fff;
41
+ }
42
+
43
+ .app-name{
44
+ text-align: center;
45
+ }
46
+ .app-subname{
47
+ font-size:50%;
48
+ }
49
+ }
50
+ }
51
+ }
52
+ }
@@ -0,0 +1,88 @@
1
+ import React from "react";
2
+ import BaseLayoutContainer from './BaseLayoutContainer'
3
+ import classNames from "classnames";
4
+ import { playSound } from "../utils";
5
+
6
+ const blankFunc = () => { };
7
+
8
+ // onBarcodeScan 按下键才开始监听
9
+ // onScanBarcode 一直监听
10
+ export default class BarcodeScan extends React.Component {
11
+ constructor(props) {
12
+ super(props);
13
+ this._barcodeBeginScan = false;
14
+ this._handleBarcodeScan = e => {
15
+ const { onBarcodeScan } = this.props;
16
+ this._stopWork();
17
+ playSound('scan');
18
+ onBarcodeScan && onBarcodeScan(e.param);
19
+ }
20
+ this._startWork = e => {
21
+ document.addEventListener('BarcodeScan', this._handleBarcodeScan);
22
+ this._barcodeBeginScan = true;
23
+ }
24
+ this._stopWork = e => {
25
+ document.removeEventListener('BarcodeScan', this._handleBarcodeScan);
26
+ }
27
+ this._handleKeyDown = e => {
28
+ const { code, keyCode, key } = e; // code: F23/F24; keyCode: 0; key: uniden...
29
+ // console.log('keydown code: ', code, keyCode, key);
30
+ if (code === 'F22' || code === 'F23' || code === 'F24' || code === 'F9' || code ==='F16') {
31
+ if (!this._barcodeBeginScan) {
32
+ this._startWork();
33
+ }
34
+ }
35
+ }
36
+ this._handleKeyUp = e => {
37
+ const { code, keyCode, key } = e; // code: F23/F24; keyCode: 0; key: uniden...
38
+ if (code === 'F22' || code === 'F23' || code === 'F24' || code === 'F9' || code ==='F16') {
39
+ this._stopWork();
40
+ this._barcodeBeginScan = false;
41
+ }
42
+ }
43
+
44
+ this.onScanBarcode = this.onScanBarcode.bind(this);
45
+ }
46
+
47
+ onScanBarcode(e){
48
+ this.props.onScanBarcode && this.props.onScanBarcode(e.param);
49
+ }
50
+
51
+ componentDidMount() {
52
+ const {onBarcodeScan} = this.props;
53
+ if(onBarcodeScan){
54
+ document.addEventListener('keydown', this._handleKeyDown);
55
+ document.addEventListener('keyup', this._handleKeyUp);
56
+ }
57
+ document.addEventListener('BarcodeScan', this.onScanBarcode);
58
+ WindVane.call('WindvanePlugin', 'invoke', "{'domain': 'keyboard', 'method': 'changeScanMode', 'params': {'scanMode': 'barcode'}}", function (e) {
59
+ // alert('success ' + JSON.stringify(e));
60
+ }, function (e) {
61
+ // alert('failure ' + JSON.stringify(e));
62
+ });
63
+ }
64
+ componentWillUnmount() {
65
+ const {onBarcodeScan} = this.props;
66
+ if(onBarcodeScan){
67
+ document.removeEventListener('keydown', this._handleKeyDown);
68
+ document.removeEventListener('keyup', this._handleKeyUp);
69
+ }
70
+ document.removeEventListener('BarcodeScan', this.onScanBarcode)
71
+ }
72
+
73
+
74
+ render() {
75
+ // console.log('onBarcode render');
76
+
77
+ const props = this.props;
78
+ const { onBarcodeScan = blankFunc, ...opts } = props;
79
+
80
+ return (
81
+ <BaseLayoutContainer
82
+ {...opts}
83
+ />
84
+ )
85
+ }
86
+ }
87
+
88
+
@@ -0,0 +1,208 @@
1
+ import React from "react";
2
+ import "./index.less";
3
+ import classNames from "classnames";
4
+ import { WindVaneLog } from '../utils';
5
+
6
+ const blankFunc = () => { };
7
+
8
+ export default class BaseLayoutContainer extends React.Component {
9
+ constructor(props) {
10
+ super(props);
11
+ this.state = {
12
+ showLoading: false,
13
+ }
14
+ this._handleKeyUp = e => {
15
+ const { onScan = blankFunc, onEnter = blankFunc, onEsc = blankFunc, onDelete = blankFunc, scanMode = null } = this.props;
16
+
17
+ const { code, keyCode, key } = e; // code: F23/F24; keyCode: 0; key: uniden...
18
+ if (code === 'Enter') {
19
+ e.preventDefault();
20
+ onEnter(e);
21
+ return;
22
+ }
23
+ if (code === 'Delete') {
24
+ e.preventDefault();
25
+ onDelete(e);
26
+ return;
27
+ }
28
+ if (code === 'Esc') {
29
+ e.preventDefault();
30
+ onEsc(e);
31
+ return;
32
+ }
33
+ }
34
+ this._handleBeforeUnload = e => {
35
+ e.returnValue = ("确定离开当前页面吗?");
36
+ return true;
37
+ }
38
+ this._handleUnload = e => {
39
+ WindVane.call('WindvanePlugin', 'invoke', "{'domain': 'rfid', 'method': 'stopRfidScan', 'params':null}", function (e) {
40
+ // alert('success ' + JSON.stringify(e));
41
+ }, function (e) {
42
+ // alert('failure ' + JSON.stringify(e));
43
+ });
44
+ const stopParam = {
45
+ tag: 'stopRfid',
46
+ level: 'd',
47
+ message: 'stop rfid scan!!!'
48
+ };
49
+ WindVaneLog(stopParam);
50
+
51
+ const leaveParam = {
52
+ tag: 'leavePage',
53
+ level: 'd',
54
+ message: 'leave page: ' + window.location.href,
55
+ }
56
+ WindVaneLog(stopParam);
57
+ }
58
+ }
59
+ componentDidMount() {
60
+ // console.log('这里增加监听');
61
+ // window.onbeforeunload = this._handleBeforeUnload;
62
+ window.onunload = this._handleUnload;
63
+ document.addEventListener('keyup', this._handleKeyUp);
64
+ }
65
+ componentWillUnmount() {
66
+ // console.log('这里关闭页面了');
67
+ window.onbeforeunload = null;
68
+ window.onunload = null;
69
+ document.removeEventListener('keyup', this._handleKeyUp)
70
+ }
71
+ shouldComponentUpdate(nextProps, nextState) {
72
+ if(nextProps.loading && !this.props.loading) {
73
+ this.setState({
74
+ showLoading: true,
75
+ })
76
+ if(nextProps.loadingTimeout) {
77
+ setTimeout(() => {
78
+ this.setState({
79
+ showLoading: false,
80
+ });
81
+ }, nextProps.loadingTimeout);
82
+ }
83
+ }
84
+ if(!nextProps.loading && this.state.showLoading) {
85
+ this.setState({
86
+ showLoading: false,
87
+ })
88
+ }
89
+ return true;
90
+ }
91
+
92
+ render() {
93
+ const props = this.props;
94
+ const { style = {}, header, footer, loading } = this.props;
95
+
96
+ return (
97
+ <div
98
+ className={classNames({ 'baselayout-wrapper': true, })} style={style}
99
+ >
100
+ {
101
+ header && <div className={classNames({ 'baselayout-header': true })}>
102
+ {header}
103
+ </div>
104
+ }
105
+ <div className={classNames({ 'baselayout-container': true })}>
106
+ {props.children}
107
+ </div>
108
+ {
109
+ footer && <div className={classNames({ 'baselayout-footer': true })}>
110
+ {footer}
111
+ </div>
112
+ }
113
+ {
114
+ this.state.showLoading ? (
115
+ <div className="loading">
116
+ {/* 加载中 */}
117
+ </div>
118
+ ) : null
119
+ }
120
+
121
+ </div>
122
+ )
123
+ }
124
+ }
125
+
126
+
127
+ // export default function BaseLayout(props) {
128
+ // console.log('render baseLayout:', props);
129
+
130
+ // const { style = {}, header, footer, continuousRfidScan = false, onRfidScan = blankFunc, onScan = blankFunc, onEnter = blankFunc, onEsc = blankFunc, onDelete = blankFunc } = props;
131
+
132
+ // // const [continuousRfidScanState, setContinuousRfidScanState] = useState(continuousRfidScan)
133
+
134
+ // // 监听按键事件
135
+ // useEffect(() => {
136
+ // const handleKeyUp = e => {
137
+ // // console.log(e);
138
+ // e.preventDefault();
139
+ // const { code, keyCode, key } = e; // code: F23/F24; keyCode: 0; key: uniden...
140
+ // if (code === 'F23' || code === 'F24') {
141
+ // // console.log('scan');
142
+ // onScan(e);
143
+ // return;
144
+ // }
145
+ // if (code === 'Enter') {
146
+ // onEnter(e);
147
+ // return;
148
+ // }
149
+ // if (code === 'Delete') {
150
+ // onDelete(e);
151
+ // return;
152
+ // }
153
+ // if (code === 'Esc') {
154
+ // onEsc(e);
155
+ // return;
156
+ // }
157
+ // }
158
+ // document.addEventListener('keyup', handleKeyUp);
159
+ // return () => {
160
+ // document.removeEventListener('keyup', handleKeyUp);
161
+ // }
162
+ // }, [])
163
+
164
+ // // 监听连扫
165
+ // useEffect(() => {
166
+ // const handleContinuousRfidScan = (ev) => {
167
+ // onRfidScan(ev.param);
168
+ // }
169
+ // if(continuousRfidScan) {
170
+ // document.addEventListener('ContinuousRfidScan', handleContinuousRfidScan, false);
171
+ // WindVane.call('WindvanePlugin', 'invoke', "{'domain': 'rfid', 'method': 'startScan', 'params': null}", function (e) {
172
+ // // console.log('start success ' + JSON.stringify(e));
173
+ // }, function (e) {
174
+ // console.log('failure-1 ' + JSON.stringify(e));
175
+ // });
176
+ // }
177
+
178
+ // return () => {
179
+ // WindVane.call('WindvanePlugin', 'invoke', "{'domain': 'rfid', 'method': 'stopScan', 'params':null}", function (e) {
180
+ // // console.log('stop success ' + JSON.stringify(e));
181
+ // }, function (e) {
182
+ // console.log('failure-2 ' + JSON.stringify(e));
183
+ // });
184
+ // document.removeEventListener('ContinuousRfidScan', handleContinuousRfidScan, false)
185
+ // }
186
+ // }, [])
187
+
188
+ // return (
189
+ // <div
190
+ // className={classNames({ 'baselayout-wrapper': true, })} style={style}
191
+ // >
192
+ // {
193
+ // header && <div className={classNames({ 'baselayout-header': true })}>
194
+ // {header}
195
+ // </div>
196
+ // }
197
+ // <div className={classNames({ 'baselayout-container': true })}>
198
+ // {props.children}
199
+ // </div>
200
+ // {
201
+ // footer && <div className={classNames({ 'baselayout-footer': true })}>
202
+ // {footer}
203
+ // </div>
204
+ // }
205
+ // {/* <div className="baselayout-paddingbottom"></div> */}
206
+ // </div>
207
+ // )
208
+ // }
@@ -0,0 +1,106 @@
1
+ import React from "react";
2
+ import BaseLayoutContainer from './BaseLayoutContainer'
3
+ import classNames from "classnames";
4
+ import { playSound } from "../utils";
5
+
6
+ const blankFunc = () => { };
7
+
8
+ export default class RfidOnce extends React.Component {
9
+ constructor(props) {
10
+ super(props);
11
+ this._rfidBeginScan = false;
12
+ this._handleRfidScan = e => {
13
+ const { onRfidOnce, onRfidBoxOnce, onRfidPalletOnce } = this.props;
14
+ const data = e.param;
15
+ const isBox = data.rfidData.startsWith("0F006");
16
+ const isPallet = data.rfidData.startsWith("0F011");
17
+
18
+ playSound('single_recog');
19
+
20
+ if(isPallet) {
21
+ let rfidData = data.rfidData;
22
+ data.originData = rfidData;
23
+ data.rfidData = rfidData.substr(5, 12)
24
+ }
25
+
26
+ if(onRfidBoxOnce && isBox) {
27
+ this._stopWork();
28
+ onRfidBoxOnce(data);
29
+ } else if(onRfidPalletOnce && isPallet) {
30
+ this._stopWork();
31
+ onRfidPalletOnce(data);
32
+ }
33
+ if(onRfidOnce){
34
+ this._stopWork();
35
+ onRfidOnce(data);
36
+ }
37
+ }
38
+ this._startWork = e => {
39
+ // console.log('start work');
40
+ document.addEventListener('ContinuousRfidScan', this._handleRfidScan);
41
+ WindVane.call('WindvanePlugin', 'invoke', "{'domain': 'rfid', 'method': 'startScan', 'params': null}", function(e) {
42
+ // alert('success ' + JSON.stringify(e));
43
+ }, function(e) {
44
+ // alert('failure ' + JSON.stringify(e));
45
+ });
46
+ this._rfidBeginScan = true;
47
+ }
48
+ this._stopWork = e => {
49
+ // console.log('stop work');
50
+ document.removeEventListener('ContinuousRfidScan', this._handleRfidScan);
51
+ WindVane.call('WindvanePlugin', 'invoke', "{'domain': 'rfid', 'method': 'stopRfidScan', 'params':null}", function(e) {
52
+ }, function(e) {
53
+ });
54
+ }
55
+ this._handleKeyDown = e => {
56
+ const { code, keyCode, key } = e; // code: F23/F24; keyCode: 0; key: uniden...
57
+ if (code === 'F22' || code === 'F23' || code === 'F24' || code === 'F9' || code ==='F16') {
58
+ // console.log('keydown', this._rfidBeginScan);
59
+ if (!this._rfidBeginScan) {
60
+ this._startWork();
61
+ }
62
+ }
63
+ }
64
+ this._handleKeyUp = e => {
65
+ const { code, keyCode, key } = e; // code: F23/F24; keyCode: 0; key: uniden...
66
+ if (code === 'F22' || code === 'F23' || code === 'F24' || code === 'F9' || code ==='F16') {
67
+ // console.log('keyup stop');
68
+ this._stopWork();
69
+ this._rfidBeginScan = false;
70
+ }
71
+ }
72
+ }
73
+
74
+ componentDidMount() {
75
+ document.addEventListener('keydown', this._handleKeyDown);
76
+ document.addEventListener('keyup', this._handleKeyUp);
77
+ // document.addEventListener('ContinuousRfidScan', function (data) {
78
+ // // console.log(JSON.stringify(data));
79
+ // // console.log(data);
80
+ // }, false);
81
+
82
+ WindVane.call('WindvanePlugin', 'invoke', "{'domain': 'keyboard', 'method': 'changeScanMode', 'params': {'scanMode': 'RFID'}}", function (e) {
83
+ // alert('success ' + JSON.stringify(e));
84
+ }, function (e) {
85
+ // alert('failure ' + JSON.stringify(e));
86
+ });
87
+ }
88
+ componentWillUnmount() {
89
+ document.removeEventListener('keydown', this._handleKeyDown);
90
+ document.removeEventListener('keyup', this._handleKeyUp);
91
+ this._stopWork();
92
+ }
93
+
94
+ render() {
95
+ // console.log('onRfidOnce render');
96
+
97
+ const props = this.props;
98
+ const { onRfidOnce = blankFunc, ...opts } = props;
99
+
100
+ return (
101
+ <BaseLayoutContainer
102
+ {...opts}
103
+ />
104
+ )
105
+ }
106
+ }
@@ -0,0 +1,118 @@
1
+ import React from "react";
2
+ import BaseLayoutContainer from './BaseLayoutContainer'
3
+ import classNames from "classnames";
4
+
5
+ const blankFunc = () => { };
6
+
7
+ export default class RfidOnce extends React.Component {
8
+ static defaultProps = {
9
+ rfidReaderSleep: false,
10
+ }
11
+ constructor(props) {
12
+ super(props);
13
+ this._rfidBeginScan = false;
14
+ this._handleRfidScan = e => {
15
+ const { onRfidScan, onRfidBoxScan, onRfidPalletScan } = this.props;
16
+ const data = e.param;
17
+ const isBox = data.rfidData.startsWith("0F006");
18
+ const isPallet = data.rfidData.startsWith("0F011");
19
+ if(isPallet) {
20
+ let rfidData = data.rfidData;
21
+ data.originData = rfidData;
22
+ data.rfidData = rfidData.substr(5, 12)
23
+ }
24
+
25
+ if(isBox && onRfidBoxScan) {
26
+ onRfidBoxScan(data);
27
+ } else if(isPallet && onRfidPalletScan) {
28
+ onRfidPalletScan(data);
29
+ }
30
+ if(onRfidScan) {
31
+ onRfidScan(data);
32
+ }
33
+ }
34
+ this._startWork = e => {
35
+ document.addEventListener('ContinuousRfidScan', this._handleRfidScan);
36
+ WindVane.call('WindvanePlugin', 'invoke', "{'domain': 'rfid', 'method': 'startScan', 'params': null}", function(e) {
37
+
38
+ }, function(e) {
39
+
40
+ });
41
+ this._rfidBeginScan = true;
42
+ }
43
+ this._stopWork = e => {
44
+ document.removeEventListener('ContinuousRfidScan', this._handleRfidScan);
45
+ // WindVane.call('WindvanePlugin', 'invoke', "{'domain': 'rfid', 'method': 'stopScan', 'params':null}", function(e) {
46
+ // }, function(e) {
47
+ // });
48
+ WindVane.call('WindvanePlugin', 'invoke', "{'domain': 'rfid', 'method': 'stopRfidScan', 'params':null}", function(e) {
49
+ }, function(e) {
50
+ });
51
+ }
52
+ this._handleKeyDown = e => {
53
+ const { code, keyCode, key } = e; // code: F23/F24; keyCode: 0; key: uniden...
54
+ if (code === 'F22' || code === 'F23' || code === 'F24' || code === 'F9' || code ==='F16') {
55
+ if (!this._rfidBeginScan) {
56
+ this._startWork();
57
+ }
58
+ }
59
+ }
60
+ this._handleKeyUp = e => {
61
+ const { code, keyCode, key } = e; // code: F23/F24; keyCode: 0; key: uniden...
62
+ if (code === 'F22' || code === 'F23' || code === 'F24' || code === 'F9' || code ==='F16') {
63
+ this._stopWork();
64
+ this._rfidBeginScan = false;
65
+ }
66
+ }
67
+ }
68
+
69
+ componentDidMount() {
70
+ // console.log('Rfid Scan didMount');
71
+ const { autoRfidScan = false, rfidReaderSleep } = this.props;
72
+
73
+ WindVane.call('WindvanePlugin', 'invoke', "{'domain': 'keyboard', 'method': 'changeScanMode', 'params': {'scanMode': 'RFID'}}", function (e) {
74
+ // alert('success ' + JSON.stringify(e));
75
+ }, function (e) {
76
+ // alert('failure ' + JSON.stringify(e));
77
+ });
78
+
79
+ if(!autoRfidScan) {
80
+ document.addEventListener('keydown', this._handleKeyDown);
81
+ document.addEventListener('keyup', this._handleKeyUp);
82
+ } else {
83
+ if(!rfidReaderSleep) {
84
+ this._startWork();
85
+ }
86
+ }
87
+ }
88
+ componentWillUnmount() {
89
+ // const { autoRfidScan = false } = this.props;
90
+ document.removeEventListener('keydown', this._handleKeyDown);
91
+ document.removeEventListener('keyup', this._handleKeyUp);
92
+ this._stopWork();
93
+ }
94
+ shouldComponentUpdate(nextProps, nextState) {
95
+ if(this.props.autoRfidScan && (this.props.rfidReaderSleep !== nextProps.rfidReaderSleep) ) {
96
+ if(!nextProps.rfidReaderSleep) {
97
+ this._startWork();
98
+ } else {
99
+ this._stopWork();
100
+ }
101
+ }
102
+ return true;
103
+ }
104
+
105
+
106
+ render() {
107
+ // console.log('onRfidScan render');
108
+
109
+ const props = this.props;
110
+ const { onRfidScan = blankFunc, autoRfidScan, ...opts } = props;
111
+
112
+ return (
113
+ <BaseLayoutContainer
114
+ {...opts}
115
+ />
116
+ )
117
+ }
118
+ }