Commit 57ec29023e0a8866c5d918286d275ca5a7549fcd
1 parent
51d94662
新:切页要求重新加载
Showing
3 changed files
with
74 additions
and
62 deletions
show/src/bundle.js
No preview for this file type
source/src/bundle.js
No preview for this file type
source/src/js/components/searchAlarm.js
... | ... | @@ -9,29 +9,31 @@ import { Row, Col, DatePicker, Checkbox, Pagination, Button, Modal } from 'antd' |
9 | 9 | const { RangePicker } = DatePicker; |
10 | 10 | |
11 | 11 | let plainOptions = [] |
12 | + | |
13 | +// 20200604该需求 需要翻页删所有数据【但!获得一张图片时间过久!超过10秒,所以加以下变量】 | |
14 | +let querList0604_ = [] | |
15 | + | |
12 | 16 | class SearchAlarm extends React.Component { |
13 | 17 | constructor(props) { |
14 | 18 | super(props); |
15 | 19 | this.state={ |
16 | 20 | startTime : '', |
17 | - endTime : '', | |
18 | - | |
19 | - currentPage: 1, | |
20 | - totalPage:1, | |
21 | - defaultPageSize:28, | |
22 | - data:[], | |
23 | - | |
24 | - indeterminate: false, | |
25 | - checkAll: false, | |
26 | - checkedList: [], | |
27 | - | |
28 | - couldClick:true, | |
29 | - | |
30 | - previewVisible: false, | |
31 | - previewImage: '', | |
32 | - previewTitle: '', | |
21 | + endTime : '', | |
22 | + | |
23 | + currentPage: 1, | |
24 | + totalPage:1, | |
25 | + defaultPageSize:28, | |
26 | + data:[], | |
27 | + | |
28 | + indeterminate: false, | |
29 | + checkAll: false, | |
30 | + checkedList: [], | |
31 | + | |
32 | + previewVisible: false, | |
33 | + previewImage: '', | |
34 | + previewTitle: '' | |
33 | 35 | }; |
34 | - } | |
36 | + } | |
35 | 37 | |
36 | 38 | // 时间 |
37 | 39 | onTimeChange = (value,dateString) => { |
... | ... | @@ -48,15 +50,18 @@ class SearchAlarm extends React.Component { |
48 | 50 | onOk = (value) => { |
49 | 51 | // 开始查询【日期选择】 |
50 | 52 | let that = this |
51 | - this.setState({ | |
52 | - couldClick:false | |
53 | - },function(){ | |
54 | - that.queryImg() | |
55 | - }) | |
53 | + | |
54 | + that.setState({ | |
55 | + data:[] | |
56 | + },function(){ | |
57 | + that.queryImg() | |
58 | + }) | |
59 | + | |
56 | 60 | } |
57 | 61 | queryImg = () =>{ |
58 | - let that = this | |
62 | + let that = this | |
59 | 63 | plainOptions = [] |
64 | + querList0604_ = [] | |
60 | 65 | axios.post(global.constants.commonUrl+'/syImgMs/queryImg', |
61 | 66 | { |
62 | 67 | 'request':'queryImg', |
... | ... | @@ -69,12 +74,14 @@ class SearchAlarm extends React.Component { |
69 | 74 | }) |
70 | 75 | .then(function (response) { |
71 | 76 | var resList = response['data']['resInfo']['imgList'] |
77 | + querList0604_ = response['data']['resInfo']['imgList'] | |
78 | + | |
72 | 79 | that.setState({ |
73 | 80 | data:[], |
74 | 81 | indeterminate: false, |
75 | 82 | checkAll: false, |
76 | 83 | checkedList: [], |
77 | - totalPage: response['data']['resInfo']['totalPages'] | |
84 | + totalPage: response['data']['resInfo']['totalPages'], | |
78 | 85 | }); |
79 | 86 | that.getImgData(resList,0) |
80 | 87 | }) |
... | ... | @@ -83,13 +90,11 @@ class SearchAlarm extends React.Component { |
83 | 90 | }); |
84 | 91 | } |
85 | 92 | getImgData = (resList, currI) =>{ |
93 | + console.log(querList0604_) | |
94 | + | |
86 | 95 | var that = this |
87 | - if(currI == resList.length){ | |
88 | - that.setState({ | |
89 | - couldClick:true | |
90 | - }) | |
96 | + if(currI == resList.length) | |
91 | 97 | return; |
92 | - } | |
93 | 98 | else{ |
94 | 99 | axios.post(global.constants.commonUrl+'/syImgMs/getImgData', |
95 | 100 | { |
... | ... | @@ -99,20 +104,29 @@ class SearchAlarm extends React.Component { |
99 | 104 | } |
100 | 105 | }) |
101 | 106 | .then(function (response) { |
102 | - var nowData = response['data']['resInfo'] | |
103 | - var stateData = that.state.data | |
104 | - stateData.push({ | |
105 | - 'id': nowData['id'], | |
106 | - 'name': nowData['name'], | |
107 | - 'time': nowData['time'], | |
108 | - 'ext': nowData['ext'], | |
109 | - 'data': nowData['data'] | |
110 | - }) | |
111 | - that.setState({ | |
112 | - data:stateData | |
113 | - }); | |
114 | - plainOptions.push(nowData['id']) | |
115 | - that.getImgData(resList, currI+1) | |
107 | + console.log(querList0604_) | |
108 | + console.log(response) | |
109 | + var nowData = response['data']['resInfo'] | |
110 | + var stateData = that.state.data | |
111 | + | |
112 | + //0604防止旧查询旧数据出现 需验证querList0604_ 此次得来的图片id应该在querList0604_中,querList0604_始终保持最新查询所得的数据列表 | |
113 | + for(var i=0;i<querList0604_.length;i++){ | |
114 | + if(querList0604_[i]['id'] == nowData['id']){ | |
115 | + stateData.push({ | |
116 | + 'id': nowData['id'], | |
117 | + 'name': nowData['name'], | |
118 | + 'time': nowData['time'], | |
119 | + 'ext': nowData['ext'], | |
120 | + 'data': nowData['data'] | |
121 | + }) | |
122 | + that.setState({ | |
123 | + data:stateData | |
124 | + }); | |
125 | + plainOptions.push(nowData['id']) | |
126 | + that.getImgData(resList, currI+1) | |
127 | + break; | |
128 | + } | |
129 | + } | |
116 | 130 | }) |
117 | 131 | .catch(function (error) { |
118 | 132 | //console.log(error); |
... | ... | @@ -171,14 +185,14 @@ class SearchAlarm extends React.Component { |
171 | 185 | onPageChange = page => { |
172 | 186 | // 更新新页数据 后端交互 |
173 | 187 | let that = this |
174 | - if(that.state.couldClick){ | |
175 | - that.setState({ | |
176 | - currentPage: page | |
177 | - },function(){ | |
178 | - that.queryImg() | |
179 | - }); | |
180 | - } | |
181 | - }; | |
188 | + | |
189 | + that.setState({ | |
190 | + currentPage: page, | |
191 | + data:[] | |
192 | + },function(){ | |
193 | + that.queryImg() | |
194 | + }); | |
195 | + }; | |
182 | 196 | |
183 | 197 | |
184 | 198 | // 图片放大 |
... | ... | @@ -189,10 +203,8 @@ class SearchAlarm extends React.Component { |
189 | 203 | previewVisible: true, |
190 | 204 | previewTitle: e.target.name, |
191 | 205 | }); |
192 | - | |
193 | - | |
194 | 206 | }; |
195 | - render() { | |
207 | + render() { | |
196 | 208 | let { data, currentPage, totalPage, defaultPageSize, previewVisible, previewImage, previewTitle } = this.state |
197 | 209 | let that = this |
198 | 210 | |
... | ... | @@ -241,9 +253,9 @@ class SearchAlarm extends React.Component { |
241 | 253 | <img style={{width:'100%', height:'140px'}} |
242 | 254 | onClick = {this.handlePreview} |
243 | 255 | name = {item.name} |
244 | - src={ | |
245 | - 'data:image/' + item['ext'] + ';base64,'+ item['data'] | |
246 | - }/> | |
256 | + src={ | |
257 | + 'data:image/' + item['ext'] + ';base64,'+ item['data'] | |
258 | + }/> | |
247 | 259 | <div style={{ |
248 | 260 | height:'50px', |
249 | 261 | display:'flex', | ... | ... |