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
<template>
<!-- 附加页面 -->
<div>
<el-form
:model="model"
ref="modelForm"
label-position="left"
label-width="70px"
size="small"
:rules="rules"
style="height:600px"
>
<!-- 页面左半部分 -->
<el-col :span="10">
<el-col :span="22">
<el-form-item label="本金" prop="prin">
<c-input-number v-model="model.prin" placeholder="请输入" :precision="4"></c-input-number>
</el-form-item>
</el-col>
</el-col>
<el-col :span="12">
<el-col :span="22">
<el-form-item label="利率" prop="intRate">
<div>
<c-input-number v-model="model.intRate" :precision="2" :max="99.99" placeholder="请输入"></c-input-number>%
</div>
</el-form-item>
</el-col>
</el-col>
<el-col :span="10">
<el-col :span="22">
<el-form-item label="起息日" prop="bgnIntDay">
<c-date-picker
v-model="model.bgnIntDay"
type="date"
placeholder="选择日期"
:picker-options="bgnIntDay"
@blur="isholiday1()"
:append-to-body="false"
></c-date-picker>
</el-form-item>
</el-col>
</el-col>
<el-col :span="12">
<el-col :span="22">
<el-form-item label="到期日" prop="dueDate">
<c-date-picker
v-model="model.dueDate"
type="date"
placeholder="选择日期"
:picker-options="dueDate"
@blur="isholiday2"
:append-to-body="false"
></c-date-picker>
</el-form-item>
</el-col>
</el-col>
<el-col :span="10">
<el-col :span="22">
<el-form-item label="周几" prop="weekday">
<c-input v-model="model.weekday1" maxlength="32" placeholder disabled></c-input>
<!-- :style="{'width':'80px', 'margin':'0px','padding' :'0px'}" -->
</el-form-item>
</el-col>
</el-col>
<el-col :span="12">
<el-col :span="22">
<el-form-item label="周几" prop="weekday">
<c-input v-model="model.weekday2" maxlength="32" placeholder disabled></c-input>
</el-form-item>
</el-col>
</el-col>
<el-col :span="10">
<el-col :span="20">
<el-form-item label="节假日" prop="holiday">
<c-input v-model="model.holiday1" maxlength="32" placeholder disabled></c-input>
</el-form-item>
</el-col>
</el-col>
<el-col :span="12">
<el-col :span="20">
<el-form-item label="节假日" prop="holiday">
<c-input v-model="model.holiday2" maxlength="32" placeholder disabled></c-input>
</el-form-item>
</el-col>
</el-col>
<el-col :span="10">
<el-col :span="22">
<el-form-item label="业务天数" prop="busiDayNum">
<c-input
v-model="model.busiDayNum"
maxlength="32"
placeholder
disabled
@blur="calculateBusinessDays()"
></c-input>
</el-form-item>
</el-col>
</el-col>
<el-col :span="12">
<el-col :span="22">
<el-form-item label="年度天数" prop="annlDayNum">
<c-input v-model="model.annlDayNum" maxlength="100" placeholder="请输入"></c-input>
</el-form-item>
</el-col>
</el-col>
<el-col :span="10">
<el-col :span="22">
<el-form-item label="付息" prop="payInt">
<c-input-number v-model="model.payInt" :precision="4" placeholder disabled></c-input-number>
</el-form-item>
</el-col>
</el-col>
<el-col :span="12">
<el-col :span="22">
<el-form-item label="应付金额" prop="payblAmt">
<c-input-number v-model="model.payblAmt" :precision="4" placeholder disabled></c-input-number>
</el-form-item>
</el-col>
</el-col>
<el-col :span="10">
<el-col :span="22">
<el-form-item label="FTP" prop="ftp">
<div>
<c-input-number v-model="model.ftp" :precision="4" :max="99.9999" placeholder="选输"></c-input-number>%
</div>
</el-form-item>
</el-col>
</el-col>
<el-col :span="12">
<el-col :span="22">
<el-form-item label="税率" prop="tax">
<div>
<c-input-number
v-model="model.tax"
placeholder="选输"
:precision="4"
:step="0.1"
:max="99.9999"
></c-input-number>%
</div>
</el-form-item>
</el-col>
</el-col>
<el-col :span="10">
<el-col :span="22">
<el-form-item label="收益点" prop="profit">
<div>
<c-input-number v-model="model.profit" :precision="4" placeholder disabled></c-input-number>%
</div>
</el-form-item>
</el-col>
</el-col>
</el-form>
</div>
</template>
<script>
import moment from "moment";
import Api from "~/service/Api";
import Calculator from "./Calculator";
export default {
data() {
return {
month: moment(new Date()).format("YYYYMMDD"),
bgnIntDay: {
// 结束日期大于开始日期
disabledDate: time => {
return time.getTime() > moment(this.model.dueDate);
}
},
dueDate: {
// 结束日期大于开始日期
disabledDate: time => {
return time.getTime() < moment(this.model.bgnIntDay);
}
},
model: new Calculator().data,
rules: {
prin: [
{
required: true,
trigger: "blur"
}
],
intRate: [
{
required: true,
message: "输入有误",
trigger: "blur"
}
],
bgnIntDay: [
{
required: true
}
],
dueDate: [
{
required: true
}
],
annlDayNum: [
{
required: true
}
]
}
};
},
methods: {
//判断起息日是否是节假日
async isholiday1() {
// this.$refs.modelForm.validate(async valid => {
// if (!valid) return;
if (this.model.bgnIntDay !== null) {
this.model.queryDate=this.model.bgnIntDay;
let rtnmsg =await Api.post("v1/pm/isholiday", this.model);
if (rtnmsg.data.isHolidayFlag=="0") {
this.model.holiday1 = "否";
} else {
this.model.holiday1 = "是";
}
this.model.weekday1 = this.getWeekNo(this.model.bgnIntDay);
if (this.model.bgnIntDay != null && this.model.dueDate != null) {
let days = this.getBusinessDay(
this.model.bgnIntDay,
this.model.dueDate
);
this.model.busiDayNum = days;
}
}
// });
},
//判断到期日是否是节假日
async isholiday2() {
// this.$refs.modelForm.validate(async valid => {
// if (valid) {
if (this.model.dueDate !== null) {
this.model.queryDate=this.model.dueDate;
let rtnmsg = await Api.post("v1/pm/isholiday", this.model);
// this.model.holiday2 = rtnmsg.data; //
if (rtnmsg.data.isHolidayFlag=="0") {
this.model.holiday2 = "否";
} else {
this.model.holiday2 = "是";
}
console.log(rtnmsg.msg);
this.model.weekday2 = this.getWeekNo(this.model.dueDate);
if (this.model.bgnIntDay != null && this.model.dueDate != null) {
let days = this.getBusinessDay(
this.model.bgnIntDay,
this.model.dueDate
);
this.model.busiDayNum = days;
}
}
// }
// });
},
//计算当前日期是周几
getWeekNo(date) {
let week = moment(date).day();
if (week === 0) {
return "7";
} else {
return week;
}
},
//计算业务天数:获取两个字符串日期的天数差
getBusinessDay(startDate, endDate) {
let days = moment(endDate).diff(moment(startDate), "days");
return days;
}
},
//计算:付息=本金x(利率/100/年度天数)x(到息日-起息日)
computed: {
payInt: function() {
if (this.model.annlDayNum !== 0) {
let time =
this.model.prin *
(this.model.intRate / 100 / this.model.annlDayNum) *
this.model.busiDayNum;
return time;
console.log(time);
}
},
//计算:应付金额=本金+付息
payblAmt: function() {
return this.model.prin + this.model.payInt;
},
//监听利率的变化,计算:收益点=利率/(1+税点)-FTP
profit: function() {
return (
(this.model.intRate / 100 / (1 + this.model.tax / 100) -
this.model.ftp / 100) *
100
);
}
},
watch: {
profit: function() {
this.model.profit = this.profit;
},
payInt: function() {
this.model.payInt = this.payInt;
},
payblAmt: function() {
this.model.payblAmt = this.payblAmt;
},
busiDayNum: function() {
this.model.busiDayNum = this.busiDayNum;
}
}
};
</script>