88 lines
3.3 KiB
JavaScript
88 lines
3.3 KiB
JavaScript
const vue = new Vue({
|
|
el: '#VueDiv',
|
|
data: {
|
|
extenstion: model,
|
|
edit: model.id == 0,
|
|
optime:'',
|
|
historyList: []
|
|
},
|
|
created() {
|
|
this.getHistoryList();
|
|
this.extenstion.extenstionData.OldMaturityDate = this.dateFormat(this.extenstion.extenstionData.OldMaturityDate);
|
|
if (this.extenstion.id == 0) {
|
|
this.extenstion.ValueDate = '';
|
|
this.extenstion.extenstionData.NewMaturityDate = '';
|
|
} else {
|
|
this.extenstion.ValueDate = this.dateFormat(this.extenstion.ValueDate);
|
|
this.extenstion.extenstionData.NewMaturityDate = this.dateFormat(this.extenstion.extenstionData.NewMaturityDate);
|
|
}
|
|
},
|
|
methods: {
|
|
editExtention() {
|
|
this.edit = !this.edit;
|
|
},
|
|
saveExtention() {
|
|
var thisObj = this;
|
|
if (this.extenstion.ValueDate == '') {
|
|
main.message("展期日不能为空");
|
|
return;
|
|
}
|
|
if (this.extenstion.extenstionData.NewMaturityDate == '') {
|
|
main.message("新到期日不能为空");
|
|
return;
|
|
}
|
|
if (this.extenstion.extenstionData.NewMaturityDate <= this.extenstion.extenstionData.OldMaturityDate) {
|
|
main.message("新到期日应晚于原到期日");
|
|
return;
|
|
}
|
|
main.post("/swaptrade2/SaveExtension", { swap_Event: thisObj.extenstion })
|
|
.done(function (res) {
|
|
thisObj.extenstion.id = res.obj.id;
|
|
thisObj.extenstion.OptName = res.obj.OptName;
|
|
thisObj.extenstion.OptTime = res.obj.OptTime;
|
|
thisObj.edit = false;
|
|
thisObj.optime = new Date().toLocaleString() + res.msg;
|
|
thisObj.getHistoryList();
|
|
});
|
|
},
|
|
deleteExtention() {
|
|
var thisObj = this;
|
|
main.post("/swaptrade2/DeleteExtension?id=" + thisObj.extenstion.id)
|
|
.done(function (res) {
|
|
thisObj.extenstion.id = 0;
|
|
thisObj.extenstion.extenstionData.OldMaturityDate = thisObj.extenstion.extenstionData.NewMaturityDate;
|
|
thisObj.extenstion.extenstionData.NewMaturityDate = null;
|
|
thisObj.extenstion.OptName = '';
|
|
thisObj.extenstion.OptTime = null;
|
|
thisObj.edit = false;
|
|
thisObj.optime = new Date().toLocaleString() + "删除成功";
|
|
thisObj.getHistoryList();
|
|
});
|
|
},
|
|
getHistoryList() {
|
|
var thisObj = this;
|
|
main.post("/swaptrade2/GetHistoryExtensions?enid=" + enid)
|
|
.done(function (res) {
|
|
thisObj.historyList = res.obj;
|
|
|
|
});
|
|
},
|
|
dateFormat(v, f) {
|
|
if (v == null || v == '') {
|
|
return '';
|
|
}
|
|
if (!f) {
|
|
f = 'YYYY-MM-DD';
|
|
}
|
|
var m = new moment(v);
|
|
if (m.year() < 1910) {
|
|
return '';
|
|
}
|
|
return new moment(v).format(f);
|
|
}
|
|
},
|
|
components: {
|
|
'vue-datepicker': FastVue.vueDatePicker(),
|
|
}
|
|
});
|