clarms-plugins-material.js
11.5 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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
import { mapState } from "vuex";
import api from '@/api/api'
import {
httpGet,
httpPost,
formdata
} from '@/api/fetch-api.js'
import DatePicker from '@/components/date-picker/date-picker.vue';
import ClarmsUpload from './clarms-plugins-upload.vue';
import Vue from 'vue';
import {
Loading
} from 'vant';
import {
Select,
Option
} from 'element-ui';
import { ddMMyyyy2yyyyMMdd } from '@utils/utils.js';
Vue.use(Loading);
Vue.use(Select);
Vue.use(Option);
export default {
props: {
// 是否显示组件
insuredList: {
type: Array,
default() {
return []
}
},
cid: {
type: String,
default: ""
}
},
data() {
return {
dataInit: false,
showTips: false,
// 候选人所购买的保单可选择的类型
/**
* 1 意外医疗
* 2 疾病医疗
* 3 意外残疾
* 4 疾病残疾
* 5 意外死亡
* 6 疾病死亡
* 7 重大疾病
*/
typeCandidates: ['1', '2', '5', '6', '7'],
// 已经选择的类型,
typeSelected: [],
agress: false,
data: {
insuredIndex: "",
amount: null,
contactDate: "",
// 必传资料
HT41: null,
HT26: null,
// 非必传资料
HT29: null,
HT34: null,
HT16: null,
// 是否正在上传
HT41Uploading: false,
HT26Uploading: false,
HT29Uploading: false,
HT34Uploading: false,
HT16Uploading: false,
policyDateLegal: false,
},
loading: false,
contactDateError: false,
// 判断是否有合法的保单
policyIllegal: true,
// 1、选择类型;2、时间选择
modelType: "1"
}
},
components: {
DatePicker,
ClarmsUpload
},
computed: {
...mapState({
userInfo: state => state.userInfo
}),
lan() {
return this.$i18n.locale;
},
locale() {
return this.$i18n.locale || 'tc';
},
i18n() {
return this.$i18n.messages && this.$i18n.locale ? this.$i18n.messages[this.$i18n.locale] : {};
},
submitBtnDisabled() {
// 受保人
let b1 = this.data.insuredIndex ? false : true;
// 申请类型
let b2 = this.typeSelected.length > 0 ? false : true;
// 申请额度
let b3 = this.data.amount > 0 ? false : true;
// 日期校验
let b4 = this.data.contactDate ? false : true;
let b5 = this.contactDateError;
// 必传资料
let b6 = this.data.HT41 && this.data.HT41.length > 0 ? false : true;
let b7 = this.data.HT26 && this.data.HT26.length > 0 ? false : true;
// 资料上传中
let b8 = this.data.HT41Uploading || this.data.HT26Uploading || this.data.HT29Uploading || this.data.HT34Uploading || this.data.HT16Uploading;
let b9 = !this.agress;
let b10 = this.policyIllegal;
// console.log("b1:", b1);
// console.log("b2:", b2);
// console.log("b3:", b3);
// console.log("b4:", b4);
// console.log("b5:", b5);
// console.log("b6:", b6);
// console.log("b7:", b7);
// console.log("b8:", b8);
// console.log("b9:", b9);
// console.log("b10:", b10);
return b1 || b2 || b3 || b4 || b5 || b6 || b7 || b8 || b9 || b10;
},
isLogin() {
if (this.userInfo && this.userInfo.name) {
return true;
}
return false;
},
},
methods: {
initData() {
sessionStorage.setItem("clarmsRequestCid", this.cid);
let typeSelectedStr = sessionStorage.getItem("clarmTypeSelect");
sessionStorage.removeItem("clarmTypeSelect");
let clarmDataFormStr = sessionStorage.getItem("clarmDataForm");
sessionStorage.removeItem("clarmDataForm");
let aggressStr = sessionStorage.getItem("clarmAggressStr");
if (clarmDataFormStr) {
try {
this.data = JSON.parse(clarmDataFormStr);
} catch (e) {
}
}
if (typeSelectedStr) {
try {
let typeSelected = JSON.parse(typeSelectedStr);
// console.log("typeSelected:", typeSelected);
this.$set(this, "typeSelected", typeSelected)
} catch (e) {
}
}
if (aggressStr && aggressStr == "true") {
this.agress = true;
}
this.data.policyDateLegal = this.checkPolicyDateLegal();
if (this.data.policyDateLegal) {
this.policyIllegal = false;
} else {
this.policyIllegal = true;
}
this.dataInit = true;
// console.log("this.insuredList = ", this.insuredList);
},
cacheData() {
sessionStorage.setItem("clarmTypeSelect", JSON.stringify(this.typeSelected));
sessionStorage.setItem("clarmDataForm", JSON.stringify(this.data));
sessionStorage.setItem("clarmAggressStr", this.agress ? "true" : "false");
this.$refs['HT41'] && this.$refs['HT41'].cacheData();
this.$refs['HT26'] && this.$refs['HT26'].cacheData();
this.$refs['HT06'] && this.$refs['HT06'].cacheData();
this.$refs['HT34'] && this.$refs['HT34'].cacheData();
this.$refs['HT03'] && this.$refs['HT03'].cacheData();
},
clearCache() {
sessionStorage.removeItem("clarmTypeSelect");
sessionStorage.removeItem("clarmDataForm");
sessionStorage.removeItem("clarmAggressStr");
this.$refs['HT41'] && this.$refs['HT41'].clearCache();
this.$refs['HT26'] && this.$refs['HT26'].clearCache();
this.$refs['HT06'] && this.$refs['HT06'].clearCache();
this.$refs['HT34'] && this.$refs['HT34'].clearCache();
this.$refs['HT03'] && this.$refs['HT03'].clearCache();
},
typeClickHandle(t) {
let index = this.typeSelected.indexOf(t);
if (index > -1) {
this.typeSelected.splice(index, 1);
} else {
this.typeSelected.push(t);
}
},
amountCheck() {
if (this.data.amount) {
if (this.data.amount < 0) {
this.data.amount = 0;
} else if (this.data.amount > 5000) {
this.data.amount = 5000;
}
}
},
uploadSuccess(data) {
console.log("uploadSuccess === ", data);
switch (data.type) {
case "HT41":
this.data.HT41Uploading = false;
this.data.HT41 = data.list;
break;
case "HT26":
this.data.HT26Uploading = false;
this.data.HT26 = data.list;
break;
case "HT29":
this.data.HT29Uploading = false;
this.data.HT29 = data.list;
break;
case "HT34":
this.data.HT34Uploading = false;
this.data.HT34 = data.list;
break;
case "HT16":
this.data.HT16Uploading = false;
this.data.HT16 = data.list;
break;
}
},
beforeUpload(data) {
// console.log(data);
switch (data.type) {
case "HT41":
this.data.HT41Uploading = true;
this.data.HT41 = [];
break;
case "HT26":
this.data.HT26Uploading = true;
this.data.HT26 = [];
break;
case "HT29":
this.data.HT29Uploading = true;
this.data.HT29 = [];
break;
case "HT34":
this.data.HT34Uploading = true;
this.data.HT34 = [];
break;
case "HT16":
this.data.HT16Uploading = true;
this.data.HT16 = [];
break;
}
},
checkDate(data) {
this.contactDateError = data.disable;
},
toContact() {
this.cacheData();
this.$router.push({
path: "/custom/service?q=m1"
});
},
submitMaterial() {
if (this.submitBtnDisabled) {
return;
}
if (this.loading) {
return;
}
let policy = this.checkPolicy();
if (!policy) {
return;
}
let insured = this.insuredList[this.data.insuredIndex - 1];
this.loading = true;
let imageList = [];
imageList = this.data.HT41 && this.data.HT41.length > 0 ? imageList.concat(this.data.HT41) : imageList;
imageList = this.data.HT26 && this.data.HT26.length > 0 ? imageList.concat(this.data.HT26) : imageList;
imageList = this.data.HT29 && this.data.HT29.length > 0 ? imageList.concat(this.data.HT29) : imageList;
imageList = this.data.HT34 && this.data.HT34.length > 0 ? imageList.concat(this.data.HT34) : imageList;
imageList = this.data.HT16 && this.data.HT16.length > 0 ? imageList.concat(this.data.HT16) : imageList;
let params = {
cid: this.cid,
insuredId: insured.insuredId,
policyId: policy.policyId,
// accidentTime: this.data.contactDate,
accidentTime: ddMMyyyy2yyyyMMdd(this.data.contactDate),
applyReasonList: this.typeSelected.join(","),
treatmentAmount: this.data.amount,
imageList: imageList
}
httpPost({
url: api.clarmsRegisterCase,
data: params
}).then(res => {
this.$emit("showModal", { action: 2, type: 1 });
this.loading = false;
this.agress = false;
}).catch(e => {
this.loading = false;
this.showTips = true;
this.agress = false;
})
},
checkPolicy() {
// 校验选择的受保人在选择的时间点内是否有保单
if (this.contactDateError) {
return false;
}
if (!this.data.contactDate || !this.data.insuredIndex) {
return false;
}
let insured = this.insuredList[this.data.insuredIndex - 1];
if (!insured.policyInfoList || insured.policyInfoList.length <= 0) {
// action1为错误提示,type标记为类型,1是选择类型;2是时间范围
this.$emit("showModal", { action: 1, type: 1 });
return false;
}
// console.log("insured === ", insured);
var time = new Date(ddMMyyyy2yyyyMMdd(this.data.contactDate).replace(/\-/g, "/") + " 00:00:00").getTime();
// var time = new Date(this.data.contactDate.replace(/\-/g, "/") + " 00:00:00").getTime();
for (let index = 0; index < insured.policyInfoList.length; index++) {
let policy = insured.policyInfoList[index];
// 有效期为生效日至满期日+60天
if (policy.activeDate <= time && policy.expireDate + 60 * 24 * 60 * 60 * 1000 >= time) {
return policy;
}
}
// 2标记为时间
this.$emit("showModal", { action: 1, type: 2 });
return false;
},
checkPolicyDateLegal() {
// 校验日期是否合法
if (this.contactDateError) {
return false;
}
if (!this.data.contactDate || !this.data.insuredIndex) {
return false;
}
let insured = this.insuredList[this.data.insuredIndex - 1];
if (!insured.policyInfoList || insured.policyInfoList.length <= 0) {
return false;
}
var time = new Date(ddMMyyyy2yyyyMMdd(this.data.contactDate).replace(/\-/g, "/") + " 00:00:00").getTime();
for (let index = 0; index < insured.policyInfoList.length; index++) {
let policy = insured.policyInfoList[index];
// 有效期为生效日至满期日+60天
if (policy.activeDate <= time && policy.expireDate + 60 * 24 * 60 * 60 * 1000 >= time) {
return true;
}
}
// 2标记为时间
return false;
},
pluginActivityHandler(data) {
if (data.type == "close") {
// this.data.policyDateLegal = ;
this.$set(this.data, 'policyDateLegal', this.checkPolicyDateLegal());
if (this.data.policyDateLegal) {
this.policyIllegal = false;
} else {
this.policyIllegal = true;
if (this.data.contactDate) {
this.$emit("showModal", { action: 1, type: 2 });
}
}
}
},
insuredChange() {
this.typeSelected = [];
let d = {
insuredIndex: this.data.insuredIndex,
amount: null,
contactDate: "",
// 必传资料
HT41: null,
HT26: null,
// 非必传资料
HT29: null,
HT34: null,
HT16: null,
// 是否正在上传
HT41Uploading: false,
HT26Uploading: false,
HT29Uploading: false,
HT34Uploading: false,
HT16Uploading: false,
};
this.$set(this, "data", d);
}
},
watch: {
// "data.contactDate": function () {
// if (this.checkPolicy()) {
// this.policyIllegal = false;
// } else {
// this.policyIllegal = true;
// }
// },
'agree': function () {
this.showTips = false;
}
},
mounted() {
this.initData();
},
created() {
try {
this.$root.eventBus.$off("_evt_to_account_information");
} catch (e) { }
this.$root.eventBus.$on("_evt_to_account_information", () => {
this.$nextTick(() => {
// console.log("ccccc:", document.getElementById("sc"));
let sc = document.getElementById("HT34");
if (sc) {
document.getElementById("HT34").scrollIntoView();
}
})
});
}
}