clarms-plugins-material.js
9.74 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
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';
Vue.use(Loading);
Vue.use(Select);
Vue.use(Option);
export default {
props: {
// 是否显示组件
insuredList: {
type: Array,
default() {
return []
}
},
cid: {
type: String,
default: ""
}
},
data() {
return {
showTips: false,
// 候选人所购买的保单可选择的类型
/**
* 1 意外医疗
* 2 疾病医疗
* 3 意外残疾
* 4 疾病残疾
* 5 意外死亡
* 6 疾病死亡
* 7 重大疾病
*/
typeCandidates: ['1', '2', '5', '6', '7'],
// 已经选择的类型,
typeSelected: [],
images: [],
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,
},
loading: false,
contactDateError: false,
// 判断是否有合法的保单
policyIllegal: true,
}
},
components: {
DatePicker,
ClarmsUpload
},
computed: {
lan() {
return this.$i18n.locale;
},
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;
return b1 || b2 || b3 || b4 || b5 || b6 || b7 || b8 || b9 || b10;
}
},
methods: {
initData() {
// console.log("this.insuredList = ", this.insuredList);
},
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(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.$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,
applyReasonList: this.typeSelected.join(","),
treatmentAmount: this.data.amount,
imageList: imageList
}
httpPost({ url: api.clarmsRegisterCase, data: params }).then(res => {
this.$emit("showModal", 2);
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) {
this.$emit("showModal", 1);
return false;
}
// console.log("insured === ", insured);
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;
}
}
this.$emit("showModal", 1);
return false;
}
},
watch: {
"data.insuredIndex": function (v, ov) {
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);
if (this.checkPolicy()) {
this.policyIllegal = false;
} else {
this.policyIllegal = true;
}
},
"data.contactDate": function () {
if (this.checkPolicy()) {
this.policyIllegal = false;
} else {
this.policyIllegal = true;
}
},
'agree': function () {
this.showTips = false;
}
},
mounted() {
this.initData();
},
created() { }
}