@@ -84,15 +84,24 @@ import config from '@/config'
84
84
import axios from ' axios'
85
85
const io = require (' socket.io-client' )
86
86
const socket = io (config .socketURI )
87
- socket .on (' 5a6e2e8b_cfeb_4060_b420_6ca95184b884_created' , data => {
88
- // console.log('===d8finstance created==', data)
89
- })
90
- socket .on (' 5a6e2e8b_cfeb_4060_b420_6ca95184b884_updated' , data => {
91
- // console.log('===d6finstance updated==', data)
92
- })
93
- socket .on (' 5a6e2e8b_cfeb_4060_b420_6ca95184b884_removed' , data => {
94
- // console.log('===d6finstance removed==', data)
95
- })
87
+ // socket.on('5a6e2e8b_cfeb_4060_b420_6ca95184b884_created', data => {
88
+ // console.log('===d8finstance created==', data)
89
+ // if (data._currentStatus) {
90
+ // console.log('data._currentStatus', data._currentStatus, this.flowzList)
91
+ // let finx = _.findIndex(this.flowzList, {id: '5a6e2e8b_cfeb_4060_b420_6ca95184b884'.replace(/_/g, '-')})
92
+ // if (finx !== -1) {
93
+ // console.log('Index', finx)
94
+ // // this.flowzList[finx].count += 1
95
+ // this.flowzList[finx].processList[data._state].count++
96
+ // }
97
+ // }
98
+ // })
99
+ // socket.on('5a6e2e8b_cfeb_4060_b420_6ca95184b884_updated', data => {
100
+ // console.log('===d6finstance updated==', data)
101
+ // })
102
+ // socket.on('5a6e2e8b_cfeb_4060_b420_6ca95184b884_removed', data => {
103
+ // console.log('===d6finstance removed==', data)
104
+ // })
96
105
export default {
97
106
data () {
98
107
return {
@@ -105,6 +114,11 @@ export default {
105
114
}
106
115
},
107
116
created () {
117
+ // console.log('created', socket._callbacks)
118
+ },
119
+ beforeDestroy () {
120
+ // alert('beforeDestroy')
121
+ // console.log(socket, socket.disconnected)
108
122
},
109
123
methods: {
110
124
getByOrder (array ) {
@@ -179,6 +193,44 @@ export default {
179
193
p .count = 0
180
194
return p
181
195
})
196
+ if (socket ._callbacks [' $' + m .id .replace (/ -/ g , ' _' ) + ' _created' ] === undefined ) {
197
+ socket .on (m .id .replace (/ -/ g , ' _' ) + ' _created' , (data ) => {
198
+ // console.log('===created==', data)
199
+ if (data ._currentStatus ) {
200
+ let finx = _ .findIndex (this .flowzList , {id: m .id })
201
+ if (finx !== - 1 ) {
202
+ this .flowzList [finx].processList [data ._state ].count ++
203
+ this .flowzList [finx].count ++
204
+ }
205
+ }
206
+ })
207
+ }
208
+ if (socket ._callbacks [' $' + m .id .replace (/ -/ g , ' _' ) + ' _patched' ] === undefined ) {
209
+ socket .on (m .id .replace (/ -/ g , ' _' ) + ' _patched' , (data ) => {
210
+ // console.log('===patched==', data)
211
+ let finx = _ .findIndex (this .flowzList , {id: m .id })
212
+ if (finx !== - 1 && ! data ._currentStatus && data ._next === null ) {
213
+ if (this .flowzList [finx].processList [data ._state ].count > 0 ) {
214
+ this .flowzList [finx].processList [data ._state ].count --
215
+ }
216
+ if (this .flowzList [finx].count > 0 ) {
217
+ this .flowzList [finx].count --
218
+ }
219
+ }
220
+ })
221
+ }
222
+ if (socket ._callbacks [' $' + m .id .replace (/ -/ g , ' _' ) + ' _removed' ] === undefined ) {
223
+ socket .on (m .id .replace (/ -/ g , ' _' ) + ' _removed' , (data ) => {
224
+ // console.log('===removed==', data)
225
+ if (data ._currentStatus ) {
226
+ let finx = _ .findIndex (this .flowzList , {id: m .id })
227
+ if (finx !== - 1 ) {
228
+ this .flowzList [finx].processList [data ._state ].count --
229
+ this .flowzList [finx].count --
230
+ }
231
+ }
232
+ })
233
+ }
182
234
return m
183
235
})
184
236
this .loading = false
@@ -399,37 +451,6 @@ export default {
399
451
this .init ()
400
452
},
401
453
feathers: {
402
- ' 5a6e2e8b_cfeb_4060_b420_6ca95184b884_created' : {
403
- created (data ) {
404
- console .log (' >>>>>>>>>>' , data)
405
- }
406
- },
407
- ' dflowzdata' : {
408
- created (data ) {
409
- // console.log('created', data)
410
- // let finx = _.findIndex(this.flowzList, {id: data.fid})
411
- // if (finx !== -1) {
412
- // // this.flowzList[finx].count += 1
413
- // this.setCounters(this.flowzList[finx])
414
- // }
415
- },
416
- updated (data ) {
417
- console .log (' updated' , data)
418
- // let finx = _.findIndex(this.flowzList, {id: data.fid})
419
- // if (finx !== -1) {
420
- // // this.flowzList[finx].count += 1
421
- // this.setCounters(this.flowzList[finx])
422
- // }
423
- },
424
- removed (data ) {
425
- console .log (' removed' , data)
426
- // let finx = _.findIndex(this.flowzList, {id: data.fid})
427
- // if (finx !== -1) {
428
- // // this.flowzList[finx].count += 1
429
- // this.setCounters(this.flowzList[finx])
430
- // }
431
- }
432
- },
433
454
' flowz' : {
434
455
created (data ) {
435
456
if (this .$store .state .role === 1 ) {
0 commit comments