policy-change-information.js
3.96 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
import api from '@/api/api'
import {
httpGet,
httpPost
} from '@/api/fetch-api.js'
import Auth from '@components/auth/auth.vue';
import PolicyHeadList from "./policy-head-list.vue";
import DatePicker from '@/components/date-picker/date-picker.vue'
import modalComp from '@/components/modal-comp/modal-comp.vue';
import modalUploadCardComp from '@/components/modal-upload-card-comp/modal-upload-card-comp.vue';
export default {
data() {
return {
loading: false,
showForm: false,
key: 'value',
isOwner: true,
checked: false,
modalUploadCardVisiable: false,
selectedPolicies: [],
data: null,
// 保单信息
policy: null,
// 模态窗
modalSimpleVisiable: false,
modalVisiable: false,
targetPath: "",
modalIcon: "succ",
modalContent: "",
}
},
components: {
modalUploadCardComp,
PolicyHeadList,
Auth,
DatePicker,
modalComp
},
computed: {
locale() {
return this.$i18n.locale || 'tc';
},
i18n() {
return this.$i18n.messages && this.$i18n.locale ? this.$i18n.messages[this.$i18n.locale] : {};
},
sexCandidates() {
let i18n = this.$i18n.messages[this.$i18n.locale];
return i18n.infomationImprove.candidates.sex;
},
idTypeCandidates() {
let i18n = this.$i18n.messages[this.$i18n.locale];
return i18n.infomationImprove.candidates.idType;
},
},
methods: {
showModal(content, icon) {
icon = !icon || typeof icon === "undefined" ? "succ" : icon;
this.modalIcon = icon;
this.modalContent = content;
this.modalVisiable = true;
},
modalCallback() {
this.modalVisiable = false;
},
loadData() {
if (this.loading) {
return;
}
this.loading = true;
this.data = null;
let param = {
policyId: this.selectedPolicies[0].id,
policyCode: this.selectedPolicies[0].code
};
httpPost({
url: api.policyDetail,
data: param,
sid: true
}).then(response => {
this.loading = false;
if (response) {
this.policy = response;
this.initData();
}
}).catch(res => {
this.loading = false;
if (res.code == "404") {
this.$refs.auth.noAuth();
}
});
},
initData() {
let res = this.policy;
let name = "";
let isOwner = this.isOwner;
if (isOwner) {
name = res.clientNameCn ? res.clientNameCn : res.clientNameEn;
} else {
name = res.insuredNameCn ? res.insuredNameCn : res.insuredNameEn;
}
let data = {
name: name,
idType: isOwner ? res.clientIdType : res.insuredIdType,
idNumber: isOwner ? res.clientIdNumber : res.insuredIdNumber,
idExpireAt: isOwner ? res.clientExpireAt : res.insurantExpireAt,
nature: isOwner ? res.clientNationality : res.insurantNationality,
company: isOwner ? res.clientCompany : res.insurantCompany,
marriage: isOwner ? res.clientMarriage : res.insurantMarriage,
sex: isOwner ? res.clientSex : res.insuredSex,
birthday: isOwner ? res.clientBirthday : res.insuredBirthday
};
data.sex = data.sex ? data.sex : "M";
console.log("data ===", data);
this.$set(this, 'data', data);
},
handlePolicySelect(data) {
this.selectedPolicies = data;
this.loadData();
},
updatePolicyInfo() {
console.log(1, this.loading);
if (this.loading) {
return;
}
this.loading = true;
let param = JSON.parse(JSON.stringify(this.data));
delete param.birthday;
delete param.sex;
param.modifyObj = this.isOwner ? 1 : 2;
param.policyId = this.selectedPolicies[0].id;
param.policyCode = this.selectedPolicies[0].code;
console.log("2,", param);
httpPost({ url: api.updatePolicyInfo, data: param, sid: true }).then(res => {
console.log("3,", res);
this.loading = false;
this.showModal(this.i18n.policyChangeInformation.success);
}).catch(err => {
this.loading = false;
if (err.code == 404) {
this.$refs.auth.noAuth();
}
});
},
userLogout() {
this.showForm = false;
},
userLogin(data) {
this.showForm = true;
}
},
mounted() {
this.isOwner = this.$route.query.u == 1 ? true : false;
},
created() { }
}