inventory.js 1.84 KB
/**
 * 网点库存
 */
var Inventory = function(){
	
	return {
		
		search : function(){
			$('#data-grid').datagrid({
				url : '/user/inventory/search',
				queryParams : App.dataGridQueryParams('search-form')
			});
		},
		
		formatStatus : function(value, row, index){
			switch (value) {
			case '0':
				return '禁用';
			case '1':
				return '可用';
			}
		},
		
		operateInventory : function(){
			var row = $("#data-grid").datagrid("getSelected");
			if(row){
				if(row.status == '1'){
					$("#id").val(row.id);
					$("#warehouseName").html(row.warehouseName);
					$("#otcCode").html(row.otcCode);
					$("#otcName").html(row.otcName);
					$("#usefulAmount").html(row.usefulAmount);
					$("#occurAmount").textbox("setValue", '');
					$("#occurAmount").textbox("setText", '');
					$("#remark").textbox('setValue', '');
					$("#remark").textbox('setText', '');
					$("input[name='type']").removeAttr("checked");
					$("#operate-inventory-dialog").dialog('open');
				} else {
					$.messager.alert("提示", "禁用的网点不可操作");
				}
			}else{
				$.messager.alert("提示", "请选择要操作的数据");
			}
		},
		
		/**网点信息提交*/
		formSubmit : function(){
			$('#operate-form').form('submit', {
				onSubmit : function(param) {
					if($("input[name='type']:checked").val() == null){
						$.messager.alert("Warning", "操作类型必选");
						return false;
					}
					return $(this).form('validate');
				},
				success : function(data) {
					var result = $.parseJSON(data);
					if(result.success == true){
						$('#operate-inventory-dialog').dialog('close');
						$('#data-grid').datagrid("reload");
					}
					$.messager.alert('操作结果', result.data);
				},
				error : function() {

				}
			});
		},
		
		export : function(){
			window.open('/user/inventory/export?' + $('#search-form').serialize());
		}
	}
	
}();