1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<template>
<!-- mt报文 -->
<div v-if="styleType == 'mtstyle'">
<c-row class="m-swf-message-content-item">
<c-col :span="1">
<slot name="icon"></slot>
</c-col>
<c-col :span="3" class="m-swf-message-content-tag">
<span v-if="pattern.status === 'M'" class="m-swf-message-content-star">*</span>
<c-select v-model="pattern.tag" :clearable="false" size="small"
v-if="pattern.letter && pattern.letter.length > 0" @change="handleTagChange">
<el-option v-for="item in pattern.letter" :key="item" :label="item" :value="item"></el-option>
</c-select>
<span v-else>
{{pattern.tag}}
</span>
</c-col>
<c-col :span="4" class="m-swf-message-content-label">
{{pattern.label}}
</c-col>
<c-col :span="15">
<m-tag-content :tag="pattern.tag" :pattern="pattern" @validate="handleValidate" :seqlist="seqlist" :mty="mty">
</m-tag-content>
</c-col>
<c-col :span="1" class="m-swf-message-content-tno">
{{pattern.tno}}
</c-col>
</c-row>
</div>
<!-- fmt 报文 -->
<div v-else-if="styleType == 'fmtstyle'">
<c-row class="m-swf-message-content-item">
<c-col :span="1">
<slot name="icon"></slot>
</c-col>
<c-col :span="3" class="m-swf-message-content-tag">
<span v-if="pattern.status === 'M'" class="m-swf-message-content-star">*</span>
<c-select v-model="pattern.tag" :clearable="false" size="small"
v-if="pattern.letter && pattern.letter.length > 0" @change="handleTagChange">
<el-option v-for="item in pattern.letter" :key="item" :label="item" :value="item"></el-option>
</c-select>
<span v-else>
{{pattern.tag}}
</span>
</c-col>
<c-col :span="19">
<m-tag-content :tag="pattern.tag" :pattern="pattern" @validate="handleValidate" :seqlist="seqlist" :mty="mty">
</m-tag-content>
</c-col>
<c-col :span="1" class="m-swf-message-content-tno">
{{pattern.tno}}
</c-col>
</c-row>
</div>
</template>
<script>
import TagContent from './Tags/index.vue'
import {
TagV,
isTagValueEmpty
} from './TagValidater'
export default {
name: 'm-tag',
components: {
'm-tag-content': TagContent
},
props: {
pattern: {
type: Object,
default: () => {}
},
mty: {
type: String
},
seqlist: {
type: Array,
default: () => []
},
extra: {
type: Object,
default: () => {}
}
},
data: function () {
return {
state: {
tagValue: this.pattern.tagValue,
isEmpty: this.isEmpty(this.pattern.tagValue)
}
}
},
mounted: function () {
if (this.seqlist && !this.isEmpty(this.state.tagValue)) {
let {
countMap = {}
} = this.extra
for (let seqlbl of this.seqlist) {
let key = seqlbl.seqlist
if (!countMap[key])
countMap[key] = 1
else
countMap[key]++
}
this.extra.countMap = countMap
}
},
destroyed: function () {
if (this.seqlist) {
if (this.isEmpty(this.state.tagValue))
return
let {
countMap
} = this.extra
if (!countMap)
return
for (let seqlbl of this.seqlist) {
let key = seqlbl.seqlist
if (countMap[key])
countMap[key]--
}
}
},
computed: {
styleType () {
if (this.mty.indexOf('fmt19') !== -1 || this.mty == 'fmt985') {
// fmt19X 和 fmt985 报文的样式
return 'fmtstyle'
} else {
return 'mtstyle'
}
}
},
methods: {
handleValidate: function () {
console.log(JSON.stringify(this.pattern.tagValue))
TagV("T" + this.pattern.tag,
this.pattern.status,
this.pattern.tagValue,
this.pattern.tno,
this.mty,
this.seqlist,
this.extra.countMap)
},
isEmpty: function (tagValue) {
if (!tagValue)
return true
if (!tagValue.length || tagValue.length < 1)
return true
return isTagValueEmpty("T" + this.pattern.tag, tagValue)
},
handleTagChange: function () {
if (this.pattern.copyTagFlag && this.pattern.copyTagFlag[this.pattern.tag + '-flag']) {
this.pattern.tagFlag = this.pattern.copyTagFlag[this.pattern.tag + '-flag']
} else {
this.pattern.tagFlag = []
}
delete this.pattern.tagValue
this.$nextTick(() => {
if (this.pattern.tagValue && this.pattern.copyTagValue && this.pattern.copyTagValue[this.pattern.tag]) {
for (let keyvalue in this.pattern.copyTagValue[this.pattern.tag][0]) {
if (this.pattern.copyTagValue[this.pattern.tag][0][keyvalue]) {
this.pattern.tagValue[0][keyvalue] = this.pattern.copyTagValue[this.pattern.tag][0][keyvalue]
}
}
if (this.pattern.copyTagValue[this.pattern.tag][1]) {
this.pattern.tagValue[1] = this.pattern.copyTagValue[this.pattern.tag][1]
}
}
})
}
}
}
</script>
<style>
.m-swf-message-content-tag {
position: relative;
padding-left: 10px;
}
.m-swf-message-content-star {
color: red;
position: absolute;
left: 0;
}
.m-swf-message-content-tag .el-select {
width: 70%;
display: inline-block;
}
.m-swf-message-content-label {
font-size: 12px;
text-align: center;
padding-right: 10px;
}
.m-swf-message-content-tno {
padding-left: 5px;
font-size: 14px;
}
</style>