quotaUserList.js 5.22 KB
/**
 * 
 */
var quotaList = function(){
	return{
		
		/**转让按钮弹窗*/
		transfer : function(otcCode,otcName,quota){
			$("#transferOtcCode").val('');
			$("#transfer_otc_code").html('');
			$("#transfer_otc_name").html('');
			$("#transfer_quota").html('');
			$("#transId").val('填写会员号');
			$("#transId").css('color','grey');
			$("#transNum").val('');
			$("#transferOtcCode").val(otcCode);
			$("#transfer_otc_code").html(otcCode);
			$("#transfer_otc_name").html(otcName);
			$("#transfer_quota").html(quota);
			easyDialog.open({
				container : 'easyDialogTransfer'
			});
		},
	
		/**转让*/
		transferSure : function(otcCode){
			if($("#transNum").val() == 0){
				alert("转让数量不能为0");
				return;
			}
			$.ajax({
				url : '/user/quota/transfer',
				type : 'post',
				dataType : 'json',
				data : {otcCode:$("#transferOtcCode").val(),transId:$("#transId").val(),transNum:$("#transNum").val()},
				success : function(data){
					if(data.resultCode == '0'){
						alert(data.resultMsg);
						easyDialog.close();
						window.location.reload();
					}else if(data.resultCode == '1'){
						alert(data.resultMsg);
					}
				}
			});
		},
		
		/**托管*/
		entrust : function(otcCode){
			window.location.href = "/user/entrust?stockId="+otcCode;
		},
		
		/**转换*/
		convertIn : function(otcCode,otcName,quota,validEndDate,tradeEndDate){
			$("#convertInOtcCode").val('');
			$("#convertIn_otc_code").html('');
			$("#convertIn_otc_name").html('');
			$("#convertIn_quota").html('');
			$("#convertIn_validEndDate").html('');
			$("#convertIn_tradeEndDate").html('');
			$("#convertInNum").val('');
			$("#convertInOtcCode").val(otcCode);
			$("#convertIn_otc_code").html(otcCode);
			$("#convertIn_otc_name").html(otcName);
			$("#convertIn_quota").html(quota);
			$("#convertIn_tradeEndDate").html(validEndDate.substring(0,4)+"年"+validEndDate.substring(5,7)+"月"+validEndDate.substring(8,10)+"日");
			easyDialog.open({
				container : 'easyDialogConvertIn'
			});
		},
		
		convertInSure : function(){
			if($("#convertInNum").val() == 0){
				alert("转换数量不能为0");
				return;
			}
			if($("#convertInNum").val().length < 1){
				alert("转换数量填写不正确");
				return;
			}
			if($("#convertIn_quota").html() - $("#convertInNum").val() < 0){
				alert("转换数量不可大于额度数量");
				return;
			}
			if(confirm("确认要执行操作么?")){
				$.ajax({
					url : '/user/quota/convertIn',
					type : 'post',
					dataType : 'json',
					data : {otcCode:$("#convertInOtcCode").val(),quota:$("#convertInNum").val()},
					success : function(data){
						if(data.resultCode == '0'){
							alert(data.resultMsg);
							easyDialog.close();
							window.location.reload();
						}else if(data.resultCode == '1'){
							alert(data.resultMsg);
						}
					}
				});
			}
		},
		
		convertOut : function(otcCode,otcName,validEndDate,tradeEndDate){
			$("#convertOutOtcCode").val('');
			$("#convertOut_otc_code").html('');
			$("#convertOut_otc_name").html('');
			$("#convertOut_validEndDate").html('');
			$("#convertOut_tradeEndDate").html('');
			$("#convertOutNum").val('');
			$("#convertOut_quota").html('');
			var flag = true;
			$.ajax({
				url : "/user/quota/time",
				type: "post",
				async : false,
				dataType : "json",
				data : {'otcCode':otcCode},
				success : function(data){
					if(data.resultCode == '1'){
						alert(data.resultMsg);
						flag = false;
					}else{
						$("#convertOut_quota").html(data.quota);
					}
				}
			});
			if(!flag){
				return;
			}
			$("#convertOutOtcCode").val(otcCode);
			$("#convertOut_otc_code").html(otcCode);
			$("#convertOut_otc_name").html(otcName);
			$("#convertOut_tradeEndDate").html(validEndDate.substring(0,4)+"年"+validEndDate.substring(5,7)+"月"+validEndDate.substring(8,10)+"日");
			easyDialog.open({
				container : 'easyDialogConvertOut'
			});
		},
		
		convertOutSure : function(){
			if($("#convertOutNum").val() == 0){
				alert("转换数量不能为0");
				return;
			}
			if($("#convertOutNum").val().length < 1){
				alert("转换数量填写不正确");
				return;
			}
			if($("#convertOut_quota").html() - $("#convertOutNum").val() < 0){
				alert("转换数量不可大于持仓数量");
				return;
			}
			if(confirm("确认要执行操作么?")){
				$.ajax({
					url : '/user/quota/convertOut',
					type : 'post',
					dataType : 'json',
					data : {otcCode:$("#convertOutOtcCode").val(),quota:$("#convertOutNum").val()},
					success : function(data){
						if(data.resultCode == '0'){
							alert(data.resultMsg);
							easyDialog.close();
							window.location.reload();
						}else if(data.resultCode == '1'){
							alert(data.resultMsg);
						}
					}
				});
			}
		},
		
		getUserName : function(input){
			input.value=input.value.replace(/\D/g,'');
			if($("#transId").val().length == 8){
				$.ajax({
					url : '/user/quota/getName',
					type : 'post',
					dataType : 'json',
					data : {userId:$("#transId").val()},
					success : function(data){
						$("#clientName").html(data.clientName);
					}
				});
			}else{
				$("#clientName").html("");
			}
		},
		
		changeStr : function(){
			$("#transId").css("color","black");
			if($("#transId").val() == '填写会员号'){
				$("#transId").val("");
			}
		},
		
	}
}();