Files
zszq-trs/YLErpWeb/wwwroot/Scripts/app/underlying/underlyingDividendInfo.js
T
张名锐 5a51d66970 refactor(dividend): 优化除权除息计算逻辑并改进数据类型精度
- 将除权除息相关数值字段从 double 类型改为 decimal 类型以提高精度
- 重构了红利比率计算方法 GetRatio,新增 GetRatioDecimal 方法使用 decimal 计算
- 修改价格和持仓数量计算逻辑,统一使用 decimal 进行高精度运算
- 更新数据库查询逻辑,将篮子标的判断从 IsBasket() 方法改为 CommodityCode 条件
- 优化 AddDividendInfos 方法中的批量处理逻辑,增加业务键冲突检测
- 添加数据源标识字段 DataSource 和来源更新时间字段 SourceUpdatedAt
- 新增 FindExDividendByBusinessKey 和 MergeNonZeroDividendValues 辅助方法
- 更新结算服务中除权除息信息的获取方式,使用字典查找替代 LINQ JOIN
- 修复前端保存除权信息时的响应处理逻辑
- 为基金类型也开放除权功能,不仅限于股票类型
- 添加单元测试验证篮子标的查询翻译逻辑的正确性
2026-08-13 10:53:57 +08:00

157 lines
6.1 KiB
JavaScript

var ajaxOptions = $.jgrid.ajaxOptions;
function closeex_dividend_infoWindow() {
try { window.parent.layer.closeAll(); } catch (e) { }
try { window.parent.$('#modal-editex_dividend_info .close').click(); } catch (e) { }
try { window.parent.$('#modal-ex_dividend_infoEditInner .close').click(); } catch (e) { }
try { if (window.parent.location.href.indexOf("ex_dividend_infoEdit") >= 0) { window.close(); } } catch (e) { }
}
function showToolName(cellValue, options, rowObject) {
var html = "<input type='button' id='edit_{2}' class='wentiEdit' onclick=\"editInfo('{0}','{2}');\" value='{1}' />".template(rowObject.id, "修改", options.rowId);
html += "<input type='button' id='add_{2}' class='wentiEdit' style='display: none;' onclick=\"saveInfo('{0}','{2}');\" value='{1}' />".template(rowObject.id, "保存", options.rowId);
html += "<input type='button' id='del_{2}' class='wentiEdit' onclick=\"delInfo('{0}','{2}');\" value='{1}' />".template(rowObject.id, "删除", options.rowId);
return html;
}
function saveInfo(dataId, rowId) {
var data = {
id: dataId,
UnderlyingCode: underlyingCode,
ExDividendDate: $("#" + rowId + "_ExDividendDate").val(),
GiveCashAmount: $("#" + rowId + "_GiveCashAmount").val(),
GiveShareAmount: $("#" + rowId + "_GiveShareAmount").val(),
ConversionShareAmount: $("#" + rowId + "_ConversionShareAmount").val(),
RationedSharesAmount: $("#" + rowId + "_RationedSharesAmount").val(),
RationedSharesPrice: $("#" + rowId + "_RationedSharesPrice").val()
};
$.jgrid.ajaxOptions = {};
g_grid.jqGrid('saveRow', rowId,
{
successfunc: function (response) {
var result = response.responseJSON || {};
var msg = result.msg || "保存失败";
main.message(msg);
$("#systemTip").text(new Date().toLocaleString() + " " + msg);
if (!result.success) return false;
g_grid.trigger('reloadGrid');
return true;
},
"url": "/ex_dividend_info/SaveDividend",
"extraparam": data,
"restoreAfterError": true,
"mtype": "POST"
});
$.jgrid.ajaxOptions = ajaxOptions;
}
function editInfo(dataId, rowId) {
g_grid.editRow(rowId);
$("#edit_" + rowId).hide();
$("#add_" + rowId).show();
}
function delInfo(dataId, rowId) {
var data = {
id: dataId,
underlyingCode: underlyingCode,
dividendDate: g_grid.getCell(rowId, "ExDividendDate")
};
if (data.dividendDate == null || data.dividendDate == "") {
main.message("修改状态下无法删除");
return;
}
main.post("/ex_dividend_info/deleteDividend", data).done(function (res) {
try {
if (res.success) {
g_grid.delRowData(rowId);
$("#systemTip").text(new Date().toLocaleString() + " 删除成功");
}
} catch (e) { }
});
}
function gridComplete(obj) {
var rowId = 0;
var data = {
id: 0,
UnderlyingCode: underlyingCode,
ExDividendDate: null,
GiveCashAmount: 0.0,
GiveShareAmount: 0,
RationedSharesAmount: 0,
RationedSharesPrice: 0,
OptName: null,
OptDate: null
};
g_grid.jqGrid('addRowData', rowId, data, "last");
$("#del_" + rowId).prop('disabled', true);
editInfo(data.id, rowId);
$(window).off('resize.jqGrid');
$(window).on('resize.jqGrid', function () {
$("#listGrid").jqGrid('setGridWidth', $('#dividendInfo').width());
});
$("#listGrid").jqGrid('setGridWidth', $('#dividendInfo').width());
}
function GetPostData() {
var postData = {};
postData.UnderlyingCode = underlyingCode;
return postData;
}
var colModelGrid = [{
name: '', label: '操作', index: '', width: 118, formatter: showToolName, sortable: false, align: 'center'
}, {
name: 'id', label: 'id', index: 'id', width: 1, hidden: true
}, {
name: 'EncryptId', label: 'EncryptId', index: 'EncryptId', width: 0, hidden: true
}, {
name: 'ExDividendDate', label: '股权登记日', index: 'ExDividendDate', width: 90, formatter: 'date', editable: true, classes: 'datepicker', editrules: { required: true, date: true },
}, {
name: 'GiveCashAmount', label: '派息金额(10股)', index: 'GiveCashAmount', width: 100, formatter: { number: { decimalPlaces: 4, defaultValue: '0' } }, editable: true, editrules: { number: true },
}, {
name: 'GiveShareAmount', label: '送股股数(10股)', index: 'GiveShareAmount', width: 100, formatter: { number: { decimalPlaces: 4, defaultValue: '0' } }, editable: true, editrules: { number: true },
}, {
name: 'RationedSharesAmount', label: '配股股数(10股)', index: 'RationedSharesAmount', width: 100, formatter: { number: { decimalPlaces: 4, defaultValue: '0' } }, editable: true, editrules: { number: true },
}, {
name: 'RationedSharesPrice', label: '配股股价(元)', index: 'RationedSharesPrice', width: 100, formatter: { number: { decimalPlaces: 4, defaultValue: '0' } }, editable: true, editrules: { number: true },
}, {
name: 'OptName', label: '操作人名', index: 'OptName', width: 100, align: 'center'
}, {
name: 'OptDate', label: '更新日期', index: 'OptDate', width: 90, formatter: 'date', align: 'center'
}];
function formatNumber(cu) {
}
var g_grid = {};
$(function () {
var postData = GetPostData();
var obj = {
url: '/ex_dividend_info/ex_dividend_infoQuery',
datatype: 'json',
multiselect: false,
height: 'auto',
width: '95%',
autowidth: false,
shrinkToFit: false,
viewrecords: true,
jsonReader: { repeatitems: false },
caption: '',
mtype: 'POST',
postData: postData,
colModel: colModelGrid,
afterInsertRow: AfterInsertRow,
onSelectRow: rowclick,
ondblClickRow: rowdblclick,
pager: jQuery('#pagerGrid'),
pagerpos: 'left',
rowNum: 20,
rowList: [20, 30, 50, 200],
footerrow: false,
loadComplete: gridComplete,
onPaging: onJqgridPaging
};
g_grid = jQuery('#listGrid').jqGrid(obj);
});