erpMachinAcceptance.js 2.6 KB
Newer Older
doc_wei's avatar
doc_wei 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

layui.config({
	base: basePath, 
	version: skyeyeVersion
}).extend({
    window: 'js/winui.window'
}).define(['window', 'jquery', 'winui'], function (exports) {
	winui.renderColor();
	layui.use(['form'], function (form) {
		var index = parent.layer.getFrameIndex(window.name);
	    var $ = layui.$,
		    form = layui.form;
		    
		var selOption = getFileContent('tpl/template/select-option.tpl');
	    
		// 提交类型,1.工序验收;2.生成验收单
		var subType = 1;
		
		subType = parent.subType;
		
		if(subType == 1){
			$("#depotIdBox").remove();
doc_wei's avatar
doc_wei 已提交
23
		} else {
doc_wei's avatar
doc_wei 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
			erpOrderUtil.getDepotList(function (json){
				// 加载仓库数据
				$("#depotId").html(getDataUseHandlebars(selOption, json));
				form.render('select');
			});
		}
		
		var needNum = parent.needNum;
		$("#needNum").val(needNum);
		$("#acceptNum").val(needNum);
		
		$("body").on("input", "#acceptNum", function() {
			calcNum(1);
		});
		$("body").on("change", "#acceptNum", function() {
			calcNum(1);
		});
		
		$("body").on("input", "#belowNum", function() {
			calcNum(2);
		});
		$("body").on("change", "#belowNum", function() {
			calcNum(2);
		});
		
		function calcNum(type){
			var changeNum = 0;
			if(type == 1){
				changeNum = parseInt(isNull($("#acceptNum").val()) ? "0" : $("#acceptNum").val());
				$("#belowNum").val(needNum - changeNum);
doc_wei's avatar
doc_wei 已提交
54
			} else {
doc_wei's avatar
doc_wei 已提交
55 56 57 58 59 60 61 62 63 64
				changeNum = parseInt(isNull($("#belowNum").val()) ? "0" : $("#belowNum").val());
				$("#acceptNum").val(needNum - changeNum);
			}
		}
		
		matchingLanguage();
	    form.render();
	    form.on('submit(formAddBean)', function (data) {
	        if (winui.verifyForm(data.elem)) {
	        	if(parseInt(isNull($("#acceptNum").val()) ? "0" : $("#acceptNum").val()) < 0){
doc_wei's avatar
doc_wei 已提交
65
	        		winui.window.msg('合格数量不能小于0.', {icon: 2, time: 2000});
doc_wei's avatar
doc_wei 已提交
66 67 68
	        		return false;
	        	}
	        	if(parseInt(isNull($("#belowNum").val()) ? "0" : $("#belowNum").val()) < 0){
doc_wei's avatar
doc_wei 已提交
69
	        		winui.window.msg('不合格数量不能小于0.', {icon: 2, time: 2000});
doc_wei's avatar
doc_wei 已提交
70 71 72 73 74 75 76 77 78
	        		return false;
	        	}
	        	
				var params = {
			    	childId: parent.childId,
			    	acceptNum: $("#acceptNum").val(),
			    	belowNum: $("#belowNum").val(),
			    	depotId: (subType == 1) ? "" : $("#depotId").val()
			    };
doc_wei's avatar
doc_wei 已提交
79
	        	AjaxPostUtil.request({url: flowableBasePath + "erpmachin012", params: params, type: 'json', callback: function (json) {
80 81
					parent.layer.close(index);
					parent.refreshCode = '0';
doc_wei's avatar
doc_wei 已提交
82 83 84 85 86
	 	   		}});
	        }
	        return false;
	    });
	    
W
weizhiqiang 已提交
87
	    // 取消
doc_wei's avatar
doc_wei 已提交
88
	    $("body").on("click", "#cancle", function() {
doc_wei's avatar
doc_wei 已提交
89 90 91 92 93
	    	parent.layer.close(index);
	    });
	});
	    
});