$(document).ready(function() {
								
				getBeforeDate();
				$("#STime").val(getBeforeDate(0));
				$("#clgd").click(function() {
//				var teg=/^100$|^(\d|[1-9]\d)(\.\d{1,2})*$/;
		var  teg=/^([1-9]\d?|100)$|^[1-9]\d{0,1}(\.\d{1,2}){0,1}$|^200(\.0{1,2}){0,1}$/; 
					if(!teg.test($.trim($("#amount").val()))) {
						layer.confirm('红包的金额必须在1.00元到200.00元之间.', {
							icon: 2,
							btn: ['确定'] //按钮
						});
						return;
					}
					$.ajax({
						type: "post",
						url: huayi.config.callcenter_url + "WorkOrder/AddAmount",
						dataType: 'json',
						async: true,
						data: {
							woid: ID, //工单ID
							amount: $("#amount").val(), //奖励金额
							token: $.cookie("token")
						},
						success: function(data) {
							/*验证请求*/
							if(data.state == "success") {
								var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
								parent.layer.close(index); //再执行关闭
								parent.initTable();
								parent.Hiden();
								parent.layer.msg("奖励成功");
							}
						}
					});
				})
			})
			//提交
			var ID = helper.request.queryString("str");
			var Workid = helper.request.queryString("id");
			console.log(Workid);
			
			if(ID) {

				///获取详情
				$.ajax({
					type: "get",
					url: huayi.config.callcenter_url + "WorkOrder/GetWorkOrder",
					async: true,
					dataType: 'json',
					data: {
						orderid:Workid,
						"token": $.cookie("token")
					},
					success: function(data) {
						/*验证请求*/
						if(data.state == "success") {
							var con = data;
							var Str = con.data.data;
							console.log(Str);
							//数据填充
							$("#cl_gdbh").text(Str[0].WorkOrderID);
							$("#cl_khxm").text(Str[0].Customer);
							$('#cl_khdh').text(Str[0].CustomerTel);
							$("#cl_gdnr").text(Str[0].Detail);
							$("#cont").text(Str[0].Answer);
							$(".inpBoxs").text(Str[0].Unit);
							$('#Message_box').text(Str[0].InfoType);
							$("#cl_gdlx").text(GetTypeName(Str[0].Type));
							//信息审核
							var Aud=Str[0].IsAudit;
							var html=''
							if(Aud==1){
								html="无效"
							}else{
								html="有效"
							}
							$("#isAudit").text(html);
							$(' input[name="ltypes"][value="'+Str[0].InfoTypeID+'"]').prop("checked", "checked");//审核
							//图片展示
							var Files = Str[0].File;
							console.log(Files);
//							if(Files.length > 0) {
//								$(Files).each(function(i, n) {
//									$('<div class="img-box"><img src="' + n.F_FileUrl + '" alt="" class="image-item" /><div>').appendTo(".space");
//								})
//
//							}
							if(Files){
								var a ;
								var b;
								$(Files).each(function(i, n) {
									a=n.F_FileType.split("\/")[0];
									b=n.F_FileName.split(".")[1];
									console.log(a);
									if(a=='image'){
										$('<div class="img-box"><a href="+' + n.F_FileUrl + '" download="'+n.F_FileName+'"><img src="' + n.F_FileUrl + '" alt="" class="image-item"  data-preview-group="1" /><span class="">'+b+'</span></a><div>').appendTo(".space");	
									}else{
										$('<div class="img-box "><a href="+' + n.F_FileUrl + '" download="'+n.F_FileName+'"><span class="">'+b+'</span></a><div>').appendTo(".space");	
								}
									
								})
							}
						}
					}
				});
				
			}

			function getBeforeDate(n) {
				var n = n;
				var d = new Date();
				var year = d.getFullYear();
				var mon = d.getMonth() + 1;
				var day = d.getDate();
				if(day <= n) {
					if(mon > 1) {
						mon = mon - 1;
					} else {
						year = year - 1;
						mon = 12;
					}
				}
				d.setDate(d.getDate() - n);
				year = d.getFullYear();
				mon = d.getMonth() + 1;
				day = d.getDate();
				s = year + "-" + (mon < 10 ? ('0' + mon) : mon) + "-" + (day < 10 ? ('0' + day) : day);
				return s;
			}
			

			//信息分类
			$.getJSON(huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlag?flag=XXFL', {
				"token": $.cookie("token")
			}, function(result) {
				console.log(result.data);
				if(result.state.toLowerCase() == "success") {
					var html = ""
					for(var i = 0; i < result.data.length; i++) {
						html += '<label style="font-weight: normal;">' +
							'<input type="radio" value="' + result.data[i].F_DictionaryValueId + '" name="ltypes"  disabled="disabled" /> ' + result.data[i].F_Name + '' +
							'</label>'
					}
					$(html).appendTo(".Message_box");
				}
			})
			function GetTypeName(val) {
	var str = '';
	switch(val + '') {
		case '1':
			str = "咨询";
			break;
		case '2':
			str = "报修服务";
			break;
		case '3':
			str = "投诉建议";
			break;
	}
	return str;
}