321 lines
10 KiB
JavaScript
321 lines
10 KiB
JavaScript
|
|
//任务报告
|
|
const reportMgr = (function () {
|
|
var _firstReport = '', _nextLoadTime = 0;
|
|
|
|
function loadFirst(force) {
|
|
if (force) {
|
|
_nextLoadTime = 0;
|
|
return;
|
|
}
|
|
let nowTime = new Date().getTime();
|
|
if (_nextLoadTime < nowTime) {
|
|
_nextLoadTime = nowTime + 300000;
|
|
main.post("/eod_trade_value/AjaxGetTaskRunReport", { firstTask: true }, { dataType: 'html', waitMe: false, suppressError: true }).done(function (resp) {
|
|
if (resp !== _firstReport) {
|
|
$('#eodtaskReportWrap').html(_firstReport = resp);
|
|
}
|
|
}).always(function () {
|
|
_nextLoadTime = new Date().getTime() + 5000;
|
|
});
|
|
}
|
|
}
|
|
function loadList() {
|
|
main.post("/eod_trade_value/AjaxGetTaskRunReport", { firstTask: false }, { dataType: 'html', waitMe: true, suppressError: true }).done(function (resp) {
|
|
$('#eodtaskReportWrap2').html(resp);
|
|
$('#modalEodTaskReport').modal('show');
|
|
});
|
|
}
|
|
|
|
function loadReport(reason) {
|
|
if (reason === 'save' || reason !== 'modal' && !$('#modalEodTaskReport').hasClass('show')) {
|
|
loadFirst(true);
|
|
} else {
|
|
loadList();
|
|
}
|
|
}
|
|
|
|
return {
|
|
init() {
|
|
setInterval(loadFirst, 1000);
|
|
},
|
|
loadReport: loadReport
|
|
};
|
|
}());
|
|
|
|
$(function () {
|
|
main.setTradeDatePicker(page.valueDate, "");
|
|
$("#startDate,#endDate").datepicker("option", "maxDate", page.valueDate)
|
|
.datepicker("option", "minDate", page.minValueDate);
|
|
$("#startDate").on("change", function () {
|
|
var startDate = $(this).val();
|
|
if (!main.isDate(startDate)) return;
|
|
if ($("#endDate").val() && $("#endDate").val() < startDate) {
|
|
$("#endDate").val(startDate);
|
|
}
|
|
});
|
|
$("#endDate").on("change", function () {
|
|
var endDate = $(this).val();
|
|
if (!main.isDate(endDate)) return;
|
|
if ($("#startDate").val() && $("#startDate").val() > endDate) {
|
|
$("#startDate").val(endDate);
|
|
}
|
|
});
|
|
|
|
checkExerciseTradeUnderly(false);
|
|
|
|
reportMgr.init();
|
|
|
|
});
|
|
|
|
//保存收盘任务
|
|
function saveEodTask(isDebug) {
|
|
let data = $('#form1').serializeObject();
|
|
if (!data.StartDate) {
|
|
return main.alert('开始日期 必须填写');
|
|
}
|
|
if (!data.EndDate) {
|
|
return main.alert('结束日期 必须填写');
|
|
}
|
|
if (!data.VolTypes || !data.VolTypes.length) {
|
|
return main.alert('波动率类型 必须填写');
|
|
}
|
|
if (!data.PriceType || !data.PriceType.length) {
|
|
return main.alert('结算价格模式 必须填写');
|
|
}
|
|
|
|
Array.isArray(data.PriceType) && (data.PriceType = data.PriceType.reduce((s, x) => s | parseInt(x), 0));
|
|
Array.isArray(data.VolTypes) && (data.VolTypes = data.VolTypes.join(","));
|
|
if (data.DividendRateTypes) {
|
|
Array.isArray(data.DividendRateTypes) && (data.DividendRateTypes = data.DividendRateTypes.join(","));
|
|
}
|
|
data.isDebug = isDebug;
|
|
data.isDelayTrade = false;
|
|
|
|
if (page.isAutoDelaySettlement) {
|
|
main.post('/eod_trade_value/AjaxCheckEodExerciseTradeUnderly?dateStart=' + data.StartDate + '&dateEnd=' + data.EndDate).done(function (res) {
|
|
if (res.obj.isHaveDelayTrade) {
|
|
main.confirm("是否自动延期结算?" + res.obj.msg, function () {
|
|
data.isDelayTrade = true;
|
|
_saveEodTask(data)
|
|
}, function () {
|
|
_saveEodTask(data)
|
|
})
|
|
} else {
|
|
_saveEodTask(data)
|
|
}
|
|
});
|
|
} else {
|
|
_saveEodTask(data)
|
|
}
|
|
}
|
|
|
|
|
|
function _saveEodTask(data) {
|
|
main.post('/eod_trade_value/AjaxSaveEodTask', data).done(function () {
|
|
main.message('收盘任务已加入到执行计划中');
|
|
}).always(function () {
|
|
reportMgr.loadReport('save');
|
|
});
|
|
}
|
|
//自动敲入敲出
|
|
function saveEodKnowInOut() {
|
|
let data = $('#form1').serializeObject();
|
|
if (!data.StartDate) {
|
|
return main.alert('开始日期 必须填写');
|
|
}
|
|
if (!data.EndDate) {
|
|
return main.alert('结束日期 必须填写');
|
|
}
|
|
main.post('/eod_trade_value/AjaxSaveEodKnowInOut', data).done(function (resp) {
|
|
|
|
});
|
|
}
|
|
|
|
//取消收盘任务
|
|
function cancelEodTask(taskId) {
|
|
main.post('/eod_trade_value/AjaxCancelEodTask', { taskId: taskId }).done(function () {
|
|
main.message('取消收盘任务');
|
|
}).always(function () {
|
|
reportMgr.loadReport('cancel');
|
|
});
|
|
}
|
|
|
|
//继续收盘任务
|
|
function restartEodTask(taskId, resetAll) {
|
|
if (page.isAutoDelaySettlement) {
|
|
main.post('/eod_trade_value/AjaxCheckRestartEodTaskTradeUnderly?taskId=' + taskId).done(function (res) {
|
|
if (res.obj.isHaveDelayTrade) {
|
|
main.confirm("是否自动延期结算?" + res.obj.msg, function () {
|
|
_restartEodTask(taskId, resetAll, true);
|
|
}, function () {
|
|
_restartEodTask(taskId, resetAll, false);
|
|
})
|
|
} else {
|
|
_restartEodTask(taskId, resetAll, false);
|
|
}
|
|
});
|
|
} else {
|
|
_restartEodTask(taskId, resetAll, false);
|
|
}
|
|
|
|
}
|
|
|
|
function _restartEodTask(taskId, resetAll, isDelayTrade) {
|
|
main.post('/eod_trade_value/AjaxRestartEodTask', { taskId: taskId, resetAll: resetAll, isDelayTrade: isDelayTrade }).done(function () {
|
|
main.message('收盘任务重新加入到执行计划中');
|
|
}).always(function () {
|
|
reportMgr.loadReport('restart');
|
|
});
|
|
}
|
|
|
|
//刷新收盘历史
|
|
function reloadEodHistory() {
|
|
main.post('/eod_trade_value/AjaxGetEodHistoryTable', null, { dataType: 'html' }).done(function (resp) {
|
|
$('#EodHistoryTableCont').html(resp);
|
|
});
|
|
}
|
|
|
|
var vueCheck = new Vue({
|
|
el: '#modalCheck',
|
|
data: {
|
|
checkDate: '',
|
|
checkResult: page.checkResult,
|
|
checkFlag: 0,
|
|
copyResultMsg: ''
|
|
},
|
|
mounted() {
|
|
let self = this;
|
|
$("#checkDate").datepicker({
|
|
changeMonth: true,
|
|
changeYear: true,
|
|
showButtonPanel: true,
|
|
showOtherMonths: true,
|
|
selectOtherMonths: true,
|
|
beforeShowDay(date) {
|
|
return moment(date).isoWeekday() > 5 ? [false] : [true];
|
|
},
|
|
onSelect(date) {
|
|
self.checkFlag = 0;
|
|
self.checkDate = moment(date).format('');
|
|
},
|
|
onClose(dateStr) {
|
|
if (self.checkDate !== dateStr) {
|
|
self.checkFlag = 0;
|
|
self.checkDate = dateStr;
|
|
}
|
|
}
|
|
});
|
|
},
|
|
methods: {
|
|
show() {
|
|
this.checkFlag = 0;
|
|
this.checkDate = $('#startDate').val();
|
|
$('#modalCheck').modal('show');
|
|
},
|
|
preDate() {
|
|
let date = moment(this.checkDate);
|
|
let weekday = date.isoWeekday();
|
|
if (weekday == 1) {
|
|
date = date.subtract(3, 'day');
|
|
} else if (weekday == 7) {
|
|
date = date.subtract(2, 'day');
|
|
}
|
|
else {
|
|
date = date.subtract(1, 'day');
|
|
}
|
|
this.checkFlag = 0;
|
|
this.checkDate = date.format('YYYY-MM-DD');
|
|
},
|
|
nextDate() {
|
|
let date = moment(this.checkDate);
|
|
let weekday = date.isoWeekday();
|
|
if (weekday == 5) {
|
|
date = date.add(3, 'day');
|
|
} else if (weekday == 6) {
|
|
date = date.add(2, 'day');
|
|
}
|
|
else {
|
|
date = date.add(1, 'day');
|
|
}
|
|
this.checkFlag = 0;
|
|
this.checkDate = date.format('YYYY-MM-DD');
|
|
},
|
|
executeCheck() {
|
|
let self = this;
|
|
this.checkFlag = 1;
|
|
this.copyResultMsg = '';
|
|
main.post("/eod_trade_value/AjaxCheckCurrencyRae", { date: this.checkDate }).done(function (resp) {
|
|
self.checkFlag = 100;
|
|
self.checkResult = resp.obj;
|
|
}).fail(function () {
|
|
self.checkFlag = 2;
|
|
});
|
|
},
|
|
copyPre() {
|
|
main.confirm("确认从上日'" + this.checkResult.PreDate + "'复制缺失汇率吗?", this.doCopyPre);
|
|
},
|
|
doCopyPre() {
|
|
let self = this;
|
|
this.checkFlag = 101;
|
|
this.copyResultMsg = '';
|
|
main.post("/eod_trade_value/AjaxCopyPreCurrencyRae", { date: this.checkDate }).done(function (resp) {
|
|
self.checkFlag = 102;
|
|
self.checkResult = resp.obj.result;
|
|
self.copyResultMsg = resp.obj.resultMsg;
|
|
}).fail(function () {
|
|
self.checkFlag = 103;
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
function checkSettlePrice() {
|
|
let data = $('#form1').serializeObject();
|
|
if (!data.StartDate && !data.EndDate) {
|
|
main.alert("请填写日期")
|
|
}
|
|
if (!data.StartDate) {
|
|
data.StartDate = data.EndDate;
|
|
}
|
|
if (!data.EndDate) {
|
|
data.EndDate = data.StartDate;
|
|
}
|
|
exportSubmit('/eod_trade_value/AjaxCheckSettlePrice?dateStart=' + data.StartDate + '&dateEnd=' + data.EndDate)
|
|
}
|
|
|
|
function exportSubmit(url) {
|
|
var $form = $('#exportForm').html('');
|
|
$form.attr("action", url)
|
|
$form.submit();
|
|
}
|
|
|
|
function exportswap() {
|
|
var srcurl = "/eod_trade_value/eodTradeSwapMannual";
|
|
main.open("互换持仓明细导入", srcurl, { area: ['500px', '500px'] });
|
|
}
|
|
|
|
function changestatus(encryptId) {
|
|
main.confirm("确认已核对收盘数据?", function () {
|
|
main.post('/eod_trade_value/UpdateCheckStatus?encryptId=' + encryptId).done(function (res) {
|
|
main.message('核对状态修改成功');
|
|
window.location.reload();
|
|
});
|
|
});
|
|
}
|
|
|
|
//检察异常标的
|
|
function checkExerciseTradeUnderly(isupdate) {
|
|
main.post('/eod_trade_value/AjaxCheckExerciseTradeUnderly?update=' + isupdate).done(function (res) {
|
|
$("#updateTradeUnderlyDate").html(res.obj.datetime);
|
|
var underlystr = $("#tradeUnderly").html(res.obj.underlystr);
|
|
var obj = document.getElementById("underlycss");
|
|
if (!_.trim(_.toString(res.obj.underlystr))) {
|
|
obj.style.cssText = "background-color:#ffffff;";
|
|
} else {
|
|
obj.style.cssText = "background-color:#fcdeb4;";
|
|
}
|
|
});
|
|
}
|
|
|