HGCG003A.js 2.19 KB
Newer Older
宋祥 committed
1 2 3 4
$(function () {
	IPLATUI.EFGrid = {
		"result": {
			columns: [],
5 6 7
			onRowClick: function (e){
				setBcReceiveQty();
			},
宋祥 committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
			loadComplete: function (grid) {
			}
		}
	}

	$("#ef_form_head").hide();

	// 查询
	$("#QUERY").on("click", query);

	// 确认
	$("#CONFIRM").on("click", confirm);

	downKeyUp();
});

/**
 * 页面加载时执行
 */
$(window).load(function () {
	// 勾选事件
	resultCheckClick();
	// 初始化查询
	query();
});

/**
 * 勾选事件
 */
let resultCheckClick = function (){
	resultGrid.element.on("click", "input.check-one,input.check-all", function (e) {
		let action = $(this).prop("checked");
		if (action != true) {
			return;
		}
43
		setBcReceiveQty();
宋祥 committed
44 45 46
	});
}

47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
/**
 * 设置本次送货量
 */
let setBcReceiveQty = function (){
	let checkRows = resultGrid.getCheckedRows();
	let checkRowIndexs = resultGrid.getCheckedRowsIndex();
	for (let rowNo = 0; rowNo < checkRowIndexs.length; rowNo++) {
		let index = checkRowIndexs[rowNo];
		let bcReceiveQty = checkRows[rowNo]["bcReceiveQty"];
		let bcMaxReceiveQty = checkRows[rowNo]["bcMaxReceiveQty"];
		if (isBlank(bcReceiveQty) || bcReceiveQty == 0) {
			resultGrid.setCellValue(index, "bcReceiveQty", bcMaxReceiveQty);
		}
	}
}

宋祥 committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
/**
 * 查询
 */
var query = function (e) {
	resultGrid.dataSource.page(1);
};

/**
 * 选择
 */
let confirm = function () {
	let rows = resultGrid.getCheckedRows();
	if (rows.length < 1) {
		message("请选择数据")
		return;
	}
	for (let i = 0; i < rows.length; i++) {
		let bcReceiveQty = rows[i]['bcReceiveQty'];
		let bcMaxReceiveQty = rows[i]['bcMaxReceiveQty'];
		if (!isPositiveNumber(bcReceiveQty)) {
			message("勾选的第" + (i + 1) + "行本次收货数量必须大于0");
			return;
		}
		if (parseFloat(bcReceiveQty) > parseFloat(bcMaxReceiveQty)) {
			message("勾选的第" + (i + 1) + "行本次收货数量不能大于本次最大收货数量");
			return;
		}
	}
	JSUtils.confirm("确定对勾选的[" + rows.length + "]条数据生成\"采购收货\"吗? ", {
		ok: function () {
			JSUtils.submitGridsData("result", "HGCG003A", "confirm",
				true, function (e) {
					var status = e.getStatus();
					if (status !== -1) {
						parent.JSColorbox.setValueCallback();
					}
				}
			);
		}
	});
}