e-correspondence-head-list.js
7.16 KB
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
/**
* 组件描述:保单查询列表
*/
import api from '@/api/api';
import {
httpPost,
requestDomain
} from '@/api/fetch-api.js';
import {
mapState
} from 'vuex';
import {
formatMoney,
getInsuredPeriod,
getInsuredState,
getPolicyName
} from "@/utils/biz.js";
import Modal2Comp from '@/components/modal2-comp/modal2-comp.vue';
import FilterComp from '@/components/filter-comp/filter-comp.vue';
export default {
props: {
multiSelectable: {
type: Boolean,
default: false
},
model: {
type: String,
default: "download"
},
},
name: "LetterListHeader",
data() {
return {
originalList: [],
contentList: [],
maxShow: 2,
selectPolicyCode: "",
selectPolicyCodes: {},
hide: false,
showDownloadError: false,
filterVisible: false,
checkList: [],
filterKey: "",
// 候选值
bizNoCandidates: null,
letterTypeCandiates: null,
printTimeCandidates: null,
isReadCandiates: null
}
},
computed: {
lan() {
return this.$i18n.locale;
},
i18n() {
return this.$i18n.messages && this.$i18n.locale ? this.$i18n.messages[this.$i18n.locale] : {};
},
},
methods: {
initData() {
httpPost({
url: api.letterRecordList,
sid: true
}).then(res => {
// if (window.global.mockData) {
// res.push({ "recordId": "10", "bizNo": "P000000000000318", "letterType": "5", "printTime": "2020-05-03 16:02:21", "key": "c4ace2829737459cb6c95f523e0f5223", "isRead": "N" })
// res.push({ "recordId": "10", "bizNo": "P000000000000319", "letterType": "5", "printTime": "2020-05-04 16:02:21", "key": "c4ace2829737459cb6c95f523e0f5223", "isRead": "N" })
// res.push({ "recordId": "10", "bizNo": "P000000000000320", "letterType": "5", "printTime": "2020-05-05 16:02:21", "key": "c4ace2829737459cb6c95f523e0f5223", "isRead": "Y" })
// res.push({ "recordId": "10", "bizNo": "P000000000000321", "letterType": "5", "printTime": "2020-05-06 16:02:21", "key": "c4ace2829737459cb6c95f523e0f5223", "isRead": "Y" })
// res.push({ "recordId": "10", "bizNo": "P000000000000322", "letterType": "5", "printTime": "2020-05-07 16:02:21", "key": "c4ace2829737459cb6c95f523e0f5223", "isRead": "Y" })
// res.push({ "recordId": "10", "bizNo": "P000000000000323", "letterType": "5", "printTime": "2020-05-08 16:02:21", "key": "c4ace2829737459cb6c95f523e0f5223", "isRead": "Y" })
// }
// this.isReadCandiates = [{ "v": "N", "n": this.i18n.eCorrespondenceEnquiry.UnRead }, { "v": "Y", "n": this.i18n.eCorrespondenceEnquiry.Read }];
// 缓存,用于判断重复
for (let index = 0; index < res.length; index++) {
let letter = res[index];
if (letter.letterType == "5") {
this.originalList.push(letter);
this.contentList.push(letter);
}
}
this.initCandidates();
});
},
initCandidates() {
this.letterTypeCandiates = [{ "v": "5", "n": this.i18n.eCorrespondenceEnquiry.letterName }];
// 缓存,用于判断重复
let bizNoCache = [];
let printTimeCache = [];
let isReadCache = [];
let newBizNoCandidates = [], newPrintTimeCandidates = [], newIsReadCandiates = [];
for (let index = 0; index < this.originalList.length; index++) {
let letter = this.originalList[index];
let bizNo = letter.policyCode;
let printTime = letter.printTime.split(" ")[0];
let isRead = letter.isRead;
if (bizNoCache.indexOf(bizNo) < 0) {
bizNoCache.push(bizNo);
newBizNoCandidates.push({ "v": bizNo, "n": bizNo });
}
if (printTimeCache.indexOf(printTime) < 0) {
printTimeCache.push(printTime);
newPrintTimeCandidates.push({ "v": printTime, "n": printTime });
}
if (isReadCache.indexOf(isRead) < 0) {
isReadCache.push(isRead);
let n = isRead == "Y" ? this.i18n.eCorrespondenceEnquiry.Read : this.i18n.eCorrespondenceEnquiry.UnRead;
newIsReadCandiates.push({ v: isRead, n: n });
}
}
this.bizNoCandidates = newBizNoCandidates;
this.printTimeCandidates = newPrintTimeCandidates;
this.isReadCandiates = newIsReadCandiates;
},
onShowTipsOverHandler(event, item, index) {
let child = event.currentTarget.childNodes[0];
child.style.display = "block";
},
onShowTipsOutHandler(event, item, index) {
let child = event.currentTarget.childNodes[0];
child.style.display = "none";
},
// 过滤bizNo
handleFiltBizNo(common) {
this.doFilt('bizNo', common);
},
// 头部过滤类型
handleFiltLetterType(common) {
this.doFilt('letterType', common);
},
// 头部过滤日期
handleFiltPrintTime(common) {
this.doFilt('printTime', common);
},
// 头部过滤是否已读
handleFiltIsRead(common) {
this.doFilt('isRead', common);
},
doFilt(key, value) {
let newList = [];
for (let index in this.originalList) {
let letter = this.originalList[index];
let v = letter[key];
if (key == "printTime") {
v = v.split(" ")[0];
}
// 这里的letterType 暂时只有5
if (key == 'letterType' || value == v) {
newList.push(letter);
}
}
this.contentList = newList;
},
// 过滤筛选
onFilterHandler(key) {
if (this.originalList.length <= 0) return;
let filter = [];
this.checkList = [];
this.filterKey = key;
for (let index in this.originalList) {
let letter = this.originalList[index];
// 筛选的值
let value = letter[key];
console.log(key, value, letter);
// 显示的值
let name = "";
switch (key) {
// 通知书类型
case "letterType":
name = this.i18n.eCorrespondenceEnquiry.letterName;
break;
// 发出时间
case "printTime":
value = value.split(" ")[0];
name = value;
break;
// 状况
case "isRead":
name = value == "N" ? this.i18n.eCorrespondenceEnquiry.UnRead : this.i18n.eCorrespondenceEnquiry.Read;
break;
default:
name = value;
break;
}
// 过滤重复的值
if (filter.indexOf(value) > -1) {
continue;
}
filter.push(value);
this.checkList.push({
value: value,
label: name
});
}
// 显示模态窗
this.filterVisible = true;
},
/**
* 多选确认
*/
onCheckConfirmHandler(values) {
let newList = [];
for (let index in this.originalList) {
let letter = this.originalList[index];
let v = letter[this.filterKey];
if (this.filterKey == "printTime") {
v = v.split(" ")[0];
}
if (values.indexOf(v) > -1) {
newList.push(letter);
}
}
this.contentList = newList;
},
changeLetterType(letterNo) {
return this.i18n.eCorrespondenceEnquiry.LetterMap[letterNo];
},
toContactUs() {
this.$router.push({
path: "/custom/service",
query: {
q: "m1"
}
});
},
downloadPolicy(item) {
httpPost({
url: api.getObsDownloadPath,
sid: true,
data: {
key: item.key,
name: item.policyCode + "-" + this.i18n.eCorrespondenceEnquiry.letterName + ".pdf"
}
}).then(res => {
if (res) {
let url = requestDomain() + api.downloadPolicy + "/" + res;
window.open(url);
} else {
this.showDownloadError = true;
}
});
}
},
components: {
Modal2Comp,
FilterComp
},
mounted() {
this.initData();
this.$root.eventBus.$on("langChange", () => {
try {
this.initCandidates();
} catch (e) { }
});
},
}