reOrder.js 6.66 KB
$(document).ready(function() {

	// // 手机号码验证
	// $.validator.addMethod('isMobile', function(value, element) {
	// alert('fasdfasdasdsadfsdf');
	// var length = value.length;
	// var mobile =
	// /^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(17[0-9]{9})|(15[0-9]{9})$/;
	// return this.optional(element) || (length == 11 &&
	// mobile.test(value));
	// }, "请输入正确的手机号");

	/** * 查询表单验证 validator 变量为全局变量 */
	globalValidator = $("#queryForm").validate({
				rules : {
					id : {
						maxlength : 19,
						minlength : 0,
						digits : true
					},
					orderId : {
						maxlength : 19,
						minlength : 0,
						digits : true
					},
					buyerMobile : {
						isPhoneno : true
					},
					// buyerName : {
					// maxlength : 19,
					// digits : true
					// },
					sellerMobile : {
						isPhoneno : true
					}
				},
				messages : {
					id : {
						maxlength : "最大允许输入19位数字!"
					},
					orderId : {
						maxlength : "最大允许输入19位数字!"
					}
				}
			});
	var getValidator = function() {
		return $("#reOrderUpdateForm").validate({
					rules : {
						auditResult : {
							required : true
						},
						auditComment : {
							required : true,
							maxlength : 100
							// jquery validate 把1个中文字符当做一个字符处理
						},
						buyerMobile : {
							isPhoneno : true
						},
						buyerName : {
							max : 19,
							digits : true
						},
						sellerMobile : {
							isPhoneno : true
						}
					},
					messages : {
						auditComment : {
							required : "必填字段",
							maxlength : "审批意见长度不能超过100个字符"
						}
					}
				});
	};

	$("#queryBtn").click(function() {
				$("#queryForm").validate();
				if ($("#queryForm").valid()) {
					XUI.form.submit();
				}
			});

	var options = {
		beforeSubmit : function() {
		},
		success : function(responseText, statusText, xhr) {
			alert(responseText.result);
			if (XUI.check.isRequestExecutedSuccess(responseText)) {
				XUI.history.goBack($("#hiddenBackUrl").val());
			}
			return;
		},
		error : function(responseText, statusText, xhr) {
			alert(responseText);
		}
	};

	$("button[name='submitAuditReOrder']").click(function() {
		var auditResult = $("input[name='auditResult']:checked").val();
		var auditResultLabel = $("input[name='auditResult']:checked")
				.next("span").text();
		if (null == auditResult || auditResult == ""
				|| $.trim(auditResult).length == 0) {
			alert("请选择审批结果!");
			return false;
		} else if (auditResultLabel.indexOf("拒绝") != -1) {
			if (null == $("#auditComment").val()
					|| $.trim($("#auditComment").val()) == ""
					|| $.trim($("#auditComment").val()).length == 0) {
				alert("请输入审批意见!");
				return false;
			}
		}
		if ($("#auditComment").val().length > 200) {
			alert("审核意见最大只能输入200个字符或者汉字!");
			return false;
		}
		$('#reOrderUpdateForm').ajaxForm(options);
		// var v1=getValidator();
		// if(v1.form()){
		XUI.window.confirm(function() {
					$("#reOrderUpdateForm").submit();
				});
			// }

			// 修改错误提示显示
			// $("i").css("position","relative");
			// $("i").css("display","");
			// $("i").css("font-style","normal");
			// $("#auditComment-error").css("top","0");
	});

	$("a[name='toAuditReOrderApply']").click(function() {
		var reOrderId = $(this).attr("data");
		window.location = domain + "/reOrder/selfSale/toAudit/" + reOrderId
				+ "?backUrl=" + base64encode(utf16to8(XUI.form.backUrl()));
	});

	$("a[name='toViewSelfSaleReOrder']").click(function() {
		var reOrderId = $(this).attr("data");
		window.location = domain + "/reOrder/selfSale/" + reOrderId
				+ "?backUrl=" + base64encode(utf16to8(XUI.form.backUrl()));
	});

	$("a[name='toViewThirdSaleReOrder']").click(function() {
		var reOrderId = $(this).attr("data");
		window.location = domain + "/reOrder/thirdSale/" + reOrderId
				+ "?backUrl=" + base64encode(utf16to8(XUI.form.backUrl()));
	});

	$("a[name='toViewOrder']").click(function() {
		var orderId = $(this).attr("data");
		window.location = domain + "/orders/" + orderId + "?backUrl="
				+ base64encode(utf16to8(window.location));
	});

	// 仲裁
	$("a[name='toAuditAgentSaleAppeal']").click(function() {
		var reOrderId = $(this).attr("data");
		window.location = domain + "/reOrder/thirdSale/appeal/toAudit/"
				+ reOrderId + "?backUrl="
				+ base64encode(utf16to8(window.location));
	});
	// 详情
	$("a[name='viewAgentSaleAppeal']").click(function() {
		var reOrderId = $(this).attr("data");
		window.location = domain + "/reOrder/thirdSale/appeal/" + reOrderId
				+ "?backUrl=" + base64encode(utf16to8(window.location));
	});

	$("form[name=appealAuditForm]").validate({
				rules : {
					appealRealPrice : {
						required : true,
						range : [0.01, 999999999999999.00],
						number : true
					},
					auditResult : {
						required : true
					},
					appealAuditComment : {
						required : true
					}
				},
				messages : {
					appealRealPrice : {
						required : "实际退款金额填写错误!",
						range : $.validator.format("实际退款金额填写错误!")
					}
				}
			});

	$(".submit-claims-process").click(function() {
				// var appealResultReason =
				// $("*[name=appealResultReason]").val();
				// if (appealResultReason.length <= 0) {
				// alert("请填入处理理由");
				// $("*[name=appealResultReason]").focus();
				// return;
				// }

				var imgSize = $(".picUrl").size();
				if (imgSize > 5) {
					alert("请上传0-5张处理凭证");
				}
				$(".picUrl").each(function(idx) {
							$(this).prop("name", "resultImgUrls[" + idx + "]");
						});
				$("#claimsProcess").validate({
							rules : {
								resultPriceBuyer : {
									isMoney : true
								},
								resultPriceSeller : {
									isMoney : true
								}
							}
						});
				if ($("#claimsProcess").valid()) {
					$("#claimsProcess").submit();
				}
			});

	$("input[name=auditResult]").click(function() {
				var value = $(this).val();
				if (value == "70") {
					$("input[name=appealRealPrice]").attr("disabled", "true");
				} else {
					$("input[name=appealRealPrice]").removeAttr("disabled");
				}
			});

	$("input[name=appealAuditComment]").change(function() {
				$("input[name=appealAuditComment]").css("width", "100%");
			});

	// 提交退款申诉仲裁
	$("a[name='submitAppealAuditBtn']").click(function() {
				$('#appealAuditForm').ajaxForm(options);
				XUI.window.confirm(function() {
							$("#appealAuditForm").submit();
							// 修改错误提示显示
							$("i").css("position", "relative");
							$("i").css("display", "");
							$("i").css("font-style", "normal");
							$("label[for=appealAuditComment]").css("top", "0");
						});
			});

});