260 lines
8.9 KiB
JavaScript
260 lines
8.9 KiB
JavaScript
var colModelGrid = [{
|
|
name: '', label: '操作', index: '', width: 90, formatter: showToolName, sortable: false
|
|
}, {
|
|
name: 'id', label: 'id', index: 'id', width: 1, hidden: true
|
|
}, {
|
|
name: 'EncryptId', label: 'EncryptId', index: 'EncryptId', width: 0, hidden: true
|
|
}, {
|
|
name: 'VarietyCode', label: '品种代码', index: 'VarietyCode', width: 70
|
|
}, {
|
|
name: 'ShortName', label: '简称', index: 'ShortName', width: 120
|
|
}, {
|
|
name: 'VarietyName', label: '品种名称', index: 'VarietyName', width: 120
|
|
}, {
|
|
name: 'AssetType', label: '品种类型', index: 'AssetType', width: 80
|
|
}, {
|
|
name: 'QuoteCurrency', label: '计价货币', index: 'QuoteCurrency', width: 80
|
|
}, {
|
|
name: 'MainCategoryDesc', label: '主类型', index: 'MainCategory', width: 80
|
|
}, {
|
|
name: 'TradingMarket', label: '交易市场', index: 'TradingMarket', width: 100
|
|
}, {
|
|
name: 'TradeUnit', label: '交易单位', index: 'TradeUnit', width: 70, sortable: false
|
|
}, {
|
|
name: 'QuoteUnit', label: '报价单位', index: 'QuoteUnit', width: 70
|
|
}, {
|
|
name: 'MinPriceChange', label: '最小变动价位', index: 'MinPriceChange', width: 90
|
|
}, {
|
|
name: 'UpLimit', label: 'Span涨跌幅度', index: 'UpLimit', width: 110
|
|
}, {
|
|
name: 'Margin', label: '最低预付金', index: 'Margin', width: 80, formatter: 'number'
|
|
}, {
|
|
name: 'CommissionType', label: '手续费类型', index: 'CommissionType', width: 80
|
|
}, {
|
|
name: 'CommissionExchange', label: '交易所手续费', index: 'CommissionExchange', width: 100,
|
|
formatter: function (cellValue, options, rowObject) {
|
|
return rowObject.CommissionExchangeForTenThousandth;
|
|
}
|
|
}, {
|
|
name: 'CommissionDeviation', label: '手续费偏离值', index: 'CommissionDeviation', width: 100,
|
|
formatter: function (cellValue, options, rowObject) {
|
|
return rowObject.CommissionDeviationForTenThousandth;
|
|
}
|
|
}, {
|
|
name: 'CloseTodayCommissionType', label: '平今仓手续费类型', index: 'CloseTodayCommissionType', width: 120
|
|
}, {
|
|
name: 'CloseTodayCommissionExchange', label: '交易所平今仓手续费', index: 'CloseTodayCommissionExchange', width: 125,
|
|
formatter: function (cellValue, options, rowObject) {
|
|
return rowObject.CloseTodayCommissionExchangeForTenThousandth;
|
|
}
|
|
}, {
|
|
name: 'CloseTodayCommissionDeviation', label: '平今仓手续费偏离值', index: 'CloseTodayCommissionDeviation', width: 125,
|
|
formatter: function (cellValue, options, rowObject) {
|
|
return rowObject.CloseTodayCommissionDeviationForTenThousandth;
|
|
}
|
|
}, {
|
|
name: 'CloseTodayContractRule', label: '平今仓手续费合约规则', index: 'CloseTodayContractRule', width: 120, formatter: 'number'
|
|
}, {
|
|
name: 'ContractMonth', label: '合约月份', index: 'ContractMonth', width: 150
|
|
}, {
|
|
name: 'TradeTimeSlot', label: '交易时间段', index: 'TradeTimeSlot', width: 120
|
|
}, {
|
|
name: 'DeliveryType', label: '交割类型', index: 'DeliveryType', width: 70
|
|
}, {
|
|
name: 'DeliveryPlace', label: '交割地点', index: 'DeliveryPlace', width: 130
|
|
}, {
|
|
name: 'DeliveryGrade', label: '交割等级', index: 'DeliveryGrade', width: 130
|
|
}, {
|
|
name: 'MiniDeliveryUnit', label: '最小交割单位', index: 'MiniDeliveryUnit', width: 90
|
|
}, {
|
|
name: 'HasNightMarket', label: '有无夜盘', index: 'HasNightMarket', width: 70, formatter: boolFormater
|
|
}, {
|
|
name: 'HasFieldOptions', label: '场内交易', index: 'HasFieldOptions', width: 60, formatter: boolFormater
|
|
}, {
|
|
name: 'VolatilityRate', label: 'Span波动率变动', index: 'VolatilityRate', width: 110
|
|
}
|
|
];
|
|
function boolFormater(cellValue, options, rowObject) {
|
|
var s = cellValue ? "是" : "否";
|
|
var html = "<label>{0}</label>".template(s);
|
|
return html;
|
|
}
|
|
|
|
function showToolName(cellValue, options, rowObject) {
|
|
var html = "<input type=\"button\" class=\"wentiEdit\" title='查看品种信息' onclick=\"startvarietyView('{0}')\" value=\"{1}\" />".template(rowObject.EncryptId, "查看");
|
|
return html;
|
|
}
|
|
|
|
function startAddvariety() {
|
|
var addurl = "/variety/varietyEdit/0";
|
|
main.open("新增品种信息", addurl, { area: ['1000px', '90%'] });
|
|
}
|
|
function startvarietyView(id) {
|
|
var srcurl = "/variety/varietyView/?enid=" + id;
|
|
main.open("查看品种信息", srcurl, { area: ['1000px', '90%'] });
|
|
}
|
|
|
|
function reloadvariety() {
|
|
//重新加载
|
|
SearchClick();
|
|
}
|
|
|
|
function SearchClick(isSearchclick) {
|
|
var listGrid = $('#listGrid');
|
|
listGrid.appendPostData({ VarietyCode: $("#VarietyCode").val() });
|
|
listGrid.appendPostData({ VarietyName: $("#VarietyName").val() });
|
|
listGrid.appendPostData({ AssetType: $("#AssetType").val() });
|
|
listGrid.appendPostData({ TradingMarketId: $("#TradingMarketId").val() });
|
|
|
|
if (isSearchclick) {
|
|
//点击搜索时默认第一页
|
|
listGrid.jqGrid('setGridParam', { page: 1 });
|
|
}
|
|
listGrid.trigger('reloadGrid');
|
|
}
|
|
|
|
//导入预付金参数
|
|
function importMarginParams() {
|
|
main.infopage('标的品种预付金参数导入', "/variety/MarginParams");
|
|
}
|
|
|
|
function __initJqgrid() {
|
|
var grid = jQuery('#listGrid').jqGrid({
|
|
url: '/variety/varietyQuery',
|
|
datatype: 'json',
|
|
|
|
height: 'auto',
|
|
width: '90%',
|
|
autowidth: false,
|
|
shrinkToFit: false,
|
|
viewrecords: true,
|
|
jsonReader: { repeatitems: false },
|
|
cmTemplate: { align: 'center', width: 120 },
|
|
mtype: 'POST',
|
|
//postData: null,
|
|
afterInsertRow: null,
|
|
onSelectRow: null,
|
|
ondblClickRow: null,
|
|
colModel: colModelGrid,
|
|
pager: jQuery('#pagerGrid'),
|
|
pagerpos: 'left',
|
|
rowNum: 20,
|
|
rowList: [20, 30, 50, 200, 10000],
|
|
loadComplete() {
|
|
$('.ui-jqgrid-bdiv', '#gbox_listGrid').floatingScroll();
|
|
},
|
|
onPaging: null,
|
|
footerrow: false
|
|
});
|
|
}
|
|
|
|
function importVariety() {
|
|
$("#modalFileUpload").modal('show');
|
|
uploadfileInit();
|
|
$("#Content").width("680px")
|
|
}
|
|
|
|
function uploadVariety() {
|
|
let fileName = $("#uploadfileButton").val();
|
|
if (!fileName) {
|
|
return main.alert("请选择要导入的文件!");
|
|
}
|
|
let index = fileName.lastIndexOf(".");
|
|
let fileEx = index > 0 ? fileName.substr(index).toLowerCase() : '';
|
|
if (fileEx !== '.xlsx') {
|
|
return main.alert("只能上传.xlsx类型的文件!");
|
|
}
|
|
function success(data) {
|
|
if (data.success) {
|
|
_reloadData = 'reloadData';
|
|
main.alert(!data.totalNum ? '导入成功!' : "共 {0} 条数据,导入成功 {1} 条数据!".template(data.totalNum, data.successNum));
|
|
reloadvariety()
|
|
$("#modalFileUpload").modal('hide');
|
|
} else {
|
|
main.alert("导入失败:" + data.msg);
|
|
$("#modalFileUpload").modal('hide');
|
|
}
|
|
}
|
|
main.confirm("确定导入?", UploadFile.bind(null, { inputId: 'openFile', url: '/variety/UploadVariety', success: success }));
|
|
}
|
|
|
|
function downTemplate() {
|
|
window.open("../App_Docs/导入模板/品种导入模板.xlsx");
|
|
}
|
|
|
|
function downTemplate2() {
|
|
window.open("../App_Docs/导入模板/品种手续费导入模板.xlsx");
|
|
}
|
|
|
|
function uploadChange() {
|
|
$('#uploadfileButton').val($('#uploadfile').val());
|
|
}
|
|
function UploadFile(options) {
|
|
|
|
if (!options || !options.url || !options.inputId) {
|
|
throw '[UploadFile]参数错误';
|
|
}
|
|
|
|
let file = $("#uploadfile").prop('files');
|
|
if (!file || !file[0]) return;
|
|
file = file[0];
|
|
|
|
var formData = new FormData();
|
|
formData.append("file", file, file.name);
|
|
formData.append("upload_file", true);
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: options.url,
|
|
xhr: function () {
|
|
var myXhr = $.ajaxSettings.xhr();
|
|
if (myXhr.upload) {
|
|
myXhr.upload.addEventListener('progress', options.progressFn, false);
|
|
}
|
|
return myXhr;
|
|
},
|
|
beforeSend() {
|
|
main.waitMe("show");
|
|
},
|
|
success: options.success,
|
|
error(error) {
|
|
main.alert("导入失败:" + error.statusText);
|
|
},
|
|
complete(result) {
|
|
main.waitMe("hide");
|
|
$('#' + options.inputId).val('');
|
|
},
|
|
async: true,
|
|
data: formData,
|
|
cache: false,
|
|
contentType: false,
|
|
processData: false,
|
|
timeout: 60000
|
|
});
|
|
}
|
|
|
|
$(function () {
|
|
|
|
$(".datepicker").datepicker({ changeMonth: true, changeYear: true, showButtonPanel: true, showOtherMonths: true, selectOtherMonths: true });
|
|
|
|
__initJqgrid();
|
|
|
|
document.onkeydown = function (event) {
|
|
var e = event ? event : (window.event ? window.event : null);
|
|
(e.keyCode === 13) && SearchClick(true);
|
|
};
|
|
});
|
|
|
|
function downloadExcel() {
|
|
var postData = {
|
|
VarietyCode: $("#VarietyCode").val(),
|
|
VarietyName: $("#VarietyName").val(),
|
|
AssetType: $("#AssetType").val(),
|
|
TradingMarketId: $("#TradingMarketId").val(),
|
|
}
|
|
main.post("/variety/VarietyExport", postData).done(function (res) {
|
|
window.open(res.obj);
|
|
});
|
|
}
|
|
|