162 lines
5.3 KiB
JavaScript
162 lines
5.3 KiB
JavaScript
function marginRateListCtrl() {
|
|
$(function () {
|
|
let ctrl = main.jqGrid({
|
|
url: "/MarginRate/MarginRateQuery",
|
|
searchForm: '#form1',
|
|
colModelGrid: [{
|
|
name: '', label: '操作', width: 160, formatter: showToolName, sortable: false, hidden: !page.canEdit, optionHide: !page.canEdit
|
|
}, {
|
|
name: 'id', hidden: true, optionHide: true
|
|
}, {
|
|
name: 'EncryptId', hidden: true, optionHide: true
|
|
}, {
|
|
name: 'ClientName', label: '客户名称', index: 'ClientName'
|
|
}, {
|
|
name: 'VarietyCode', label: '品种代码', index: 'VarietyCode'
|
|
}, {
|
|
name: 'VarietyName', label: '品种名称', index: 'VarietyName'
|
|
}, {
|
|
name: 'ValueDate', label: '生效日期', index: 'ValueDate', formatter: 'date'
|
|
}, {
|
|
name: 'HighMarginRate', label: 'PFE系数', index: 'HighMarginRate', formatter: percentFormat
|
|
}, {
|
|
name: 'LowMarginRate', label: 'VR系数', index: 'LowMarginRate', formatter: percentFormat
|
|
}, {
|
|
name: 'OptName', label: '操作人', index: 'OptName'
|
|
}, {
|
|
name: 'OptDate', label: '操作时间', index: 'OptDate', width: 90, formatter: 'date'
|
|
}]
|
|
});
|
|
|
|
window.reloadData = ctrl.SearchClick;
|
|
});
|
|
|
|
function percentFormat(cellValue, options, rowObject) {
|
|
return cellValue ? (cellValue * 100).toFixed(2) + "%" : "0.00%";
|
|
}
|
|
|
|
function showToolName(cellValue, options, rowObject) {
|
|
if (page.canEdit) {
|
|
return "<input type=\"button\" class=\"wentiEdit\" title='修改预付金率' onclick=\"MarginRateEdit('{0}')\" value=\"{1}\" /><input type=\"button\" class=\"wentiEdit\" title='删除预付金率' onclick=\"MarginRateDelete('{0}')\" value=\"{2}\" />".template(rowObject.EncryptId, "修改", "删除");
|
|
}
|
|
else {
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
|
|
function MarginRateAdd() {
|
|
var url = "/MarginRate/MarginRateEdit";
|
|
main.infopage("新增预付金率", url, { area: ['550px', '700px'] });
|
|
}
|
|
|
|
function MarginRateEdit(id) {
|
|
var url = "/MarginRate/MarginRateEdit?enid=" + id;
|
|
main.infopage("修改预付金率", url, { area: ['550px', '700px'] });
|
|
}
|
|
|
|
function MarginRateDelete(id) {
|
|
var url = "/MarginRate/MarginRateDelete?enid=" + id;
|
|
main.post(url).done(function (res) {
|
|
reload();
|
|
});
|
|
}
|
|
|
|
function reload() {
|
|
window.location.replace("/MarginRate/MarginRateList");
|
|
}
|
|
|
|
function importFile() {
|
|
$("#modalFileUpload").modal('show');
|
|
uploadfileInit();
|
|
$("#Content").width("680px")
|
|
}
|
|
|
|
function downTemplate() {
|
|
window.open("../App_Docs/导入模板/预付金率导入模板.xlsx");
|
|
}
|
|
|
|
function uploadMarginRate() {
|
|
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) {
|
|
main.alert(!data.totalNum ? '导入成功!' : "共 {0} 条数据,导入成功 {1} 条数据!".template(data.totalNum, data.successNum));
|
|
window.reloadData()
|
|
} else {
|
|
main.alert("导入失败:" + data.msg);
|
|
$("#modalFileUpload").modal('hide');
|
|
window.reloadData()
|
|
}
|
|
}
|
|
main.confirm("确定导入?", UploadFile.bind(null, { inputId: 'openFile', url: '/MarginRate/ImportMagrinRate', success: success }));
|
|
}
|
|
|
|
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 SearchClick(isSearchclick) {
|
|
var listGrid = $('#listGrid');
|
|
|
|
listGrid.appendPostData({ ClientId: $("#ClientId").val() });
|
|
listGrid.appendPostData({ VarietyId: $("#VarietyId").val() });
|
|
|
|
query_data = listGrid.jqGrid('getPostData');
|
|
if (typeof isSearchclick !== "undefined" && isSearchclick) {
|
|
//点击搜索时默认第一页
|
|
listGrid.jqGrid('setGridParam',
|
|
{
|
|
page: 1
|
|
});
|
|
}
|
|
|
|
listGrid.trigger('reloadGrid');
|
|
} |