|
@@ -266,13 +266,15 @@ export default {
|
|
|
const ndata = _.cloneDeep(this.messageListCopy)
|
|
|
const nmap = []
|
|
|
const pattern = /[`~!@#$^\-&*()=|{}':;',\\\[\]\.<>\/?~!@#¥……&*()——|{}【】';:""'。,、?\s]/g
|
|
|
- ndata.map(item => {
|
|
|
+ ndata.map((item, index) => {
|
|
|
const nitem = item['sourceData'].replace(pattern, "")
|
|
|
+ const ntime = item['readTime'].replace(pattern, "")
|
|
|
item['sourceDataNew'] = nitem
|
|
|
+ item['readTimeNew'] = ntime + nitem
|
|
|
+ item['sourceDataIndex'] = index + 1
|
|
|
nmap.push(item)
|
|
|
})
|
|
|
- const narr1 = _.uniqBy([...nmap], 'sourceDataNew')
|
|
|
- //const narr2 = _.differenceBy([...nmap], [...narr1], 'ID')
|
|
|
+ const narr1 = this.uniqByMessage(nmap)
|
|
|
if (!narr1.length) {
|
|
|
this.switchs = false
|
|
|
this.$message.warning('当前报文无数据可过滤')
|
|
@@ -282,6 +284,29 @@ export default {
|
|
|
this.messageList = [...narr1]
|
|
|
}
|
|
|
}
|
|
|
+ },
|
|
|
+ uniqByMessage (arr) {
|
|
|
+ const narr = [...arr]
|
|
|
+ if (!narr.length) return narr
|
|
|
+ const nmap = {}
|
|
|
+ const [nmap1, nmap2] = [[], []]
|
|
|
+ const key = 'readTimeNew'
|
|
|
+ narr.map(item => {
|
|
|
+ if (!nmap[item['sourceDataNew']]) {
|
|
|
+ nmap[item['sourceDataNew']] = item.sourceDataNew
|
|
|
+ nmap1.push(item)
|
|
|
+ } else {
|
|
|
+ nmap2.push(item)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ const res = [...nmap1, ...nmap2].filter(
|
|
|
+ (item) =>
|
|
|
+ (
|
|
|
+ nmap1.some((p) => item[key] == p[key]) &&
|
|
|
+ nmap2.some((c) => item[key] == c[key])
|
|
|
+ )
|
|
|
+ )
|
|
|
+ return _.orderBy([...nmap1, ...res], ['sourceDataIndex'], ['asc']) || []
|
|
|
}
|
|
|
}
|
|
|
}
|