<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="contextPath" value="${pageContext.request.contextPath}"></c:set>

<link rel="stylesheet" href="${contextPath}/static/assets/css/jquery-ui.css" />
<link rel="stylesheet" href="${contextPath}/static/assets/css/ui.jqgrid.css" />

<style>
	.hr-line-dashed {
	    background-color: #ffffff;
	    border-top: 1px dashed #e7eaec;
	    color: #ffffff;
	    height: 1px;
	    margin: 20px 0;
	}
</style>

<div class="well well-sm">
	<input type="text" class="input-sm" placeholder="搜索关键字" id="keyword"/>
	<select class="select" id="orderState">
		<option value="" selected = "selected">状态</option>
		<option value="0">发布</option>
		<option value="1">取消</option>
		<option value="2">进行中</option>
		<option value="3">已确认</option>
		<option value="4">完成</option>
		<option value="5">已过期</option>
	</select>
	<button type="button" class="btn btn-purple btn-sm" id="searchd">
		<span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
		查询
	</button>
</div>

<div class="row">
	<div class="col-xs-12">
		<table id="grid-table"></table>
		<div id="grid-pager"></div>
		<script type="text/javascript">
			var $path_base = "${contextPath}/static";//in Ace demo this will be used for editurl parameter
		</script>
		<!-- PAGE CONTENT ENDS -->
	</div><!-- /.col -->
</div><!-- /.row -->

<div id="modal-orderDetail" class="modal fade" tabindex="-1" data-backdrop="static">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header no-padding">
      			<div class="table-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
						<span class="white">&times;</span>
					</button>
					订单详情
				</div>
	      	</div>
	      	<div class="modal-body">
      			<div class="row" id="mo-row1">
      				<label class="col-sm-3 control-label" id="mo-row1-l1"></label>
      				<label class="col-sm-3 control-label text-right" id="mo-row1-l2"></label>
      				<label class="col-sm-3 control-label" id="mo-row1-l3"></label>
      				<label class="col-sm-3 control-label text-right" id="mo-row1-l4"></label>
      			</div>
      			<div class="hr-line-dashed" id="mo-line1"></div>
      			<div class="row" id="mo-row2">
      				<label class="col-sm-3 control-label" id="mo-row2-l1"></label>
      				<label class="col-sm-3 control-label text-right" id="mo-row2-l2"></label>
      				<label class="col-sm-3 control-label" id="mo-row2-l3"></label>
      				<label class="col-sm-3 control-label text-right" id="mo-row2-l4"></label>
      			</div>
      			<div class="hr-line-dashed" id="mo-line2"></div>
      			<div class="row" id="mo-row3">
      				<label class="col-sm-3 control-label" id="mo-row3-l1"></label>
      				<label class="col-sm-9 control-label text-right" id="mo-row3-l2"></label>
      			</div>
      			<div class="hr-line-dashed" id="mo-line3"></div>
      			<div class="row" id="mo-row4">
      				<label class="col-sm-3 control-label" id="mo-row4-l1"></label>
      				<label class="col-sm-9 control-label text-right" id="mo-row4-l2"></label>
      			</div>
	      	</div>
		</div>
	</div>
</div>

<div id="modal-AjhzBidds" class="modal fade" tabindex="-1" data-backdrop="static">
	<div class="modal-dialog" style="min-width: 650px;">
		<div class="modal-content">
			<div class="modal-header no-padding">
      			<div class="table-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
						<span class="white">&times;</span>
					</button>
					申请人
				</div>
	      	</div>
	      	<div class="modal-body" style="max-height: 500px;overflow-y: scroll;" id="modal-AjhzBidds-body">
      			
	      	</div>
		</div>
	</div>
</div>

<div id="modal-edit-order" class="modal fade" tabindex="-1" data-backdrop="static">
	<div class="modal-dialog" style="min-width: 400px;">
		<div class="modal-content">
			<div class="modal-header no-padding">
      			<div class="table-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
						<span class="white">&times;</span>
					</button>
					修改订单
				</div>
	      	</div>
	      	<div class="modal-body" id="modal-edit-order-body">
      			<form id="editOrderForm" class="form-horizontal">
      				<input type="hidden" name="orderId" id="mod-edit-orderId"/>
      				<div class="form-group" id="mod-edit-state-div">
			      		<label class="col-sm-2 control-label">状态:</label>
			      		<div class="col-sm-10 text-left">
			      			<select class="select form-control" id="mod-edit-state">
								<option value="0">发布</option>
								<option value="1">取消</option>
								<option value="2">进行中</option>
								<option value="3">已确认</option>
								<option value="4">完成</option>
								<option value="5">已过期</option>
							</select>
			      		</div>
			      	</div>
			      	<div class="form-group">
			      		<label class="col-sm-2 control-label">备注:</label>
			      		<div class="col-sm-10 text-left">
			      			<textarea rows="3" id="mod-edit-remark" class="form-control"></textarea>
			      		</div>
			      	</div>
      			</form>
	      	</div>
	      	<div class="modal-footer no-margin-top">
                <div class="text-center">
					<button id="modal-edit-order-submit" type="button" class="btn btn-sm btn-primary">
						<i class="ace-icon fa fa-floppy-o bigger-160"></i>
						保存
					</button>
					<button class="btn btn-sm" data-dismiss="modal">
						<i class="ace-icon fa fa-share bigger-160"></i>
						取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>

<!-- page specific plugin scripts -->
<script type="text/javascript">
	var myGrid = null;
	
	var scripts = [ null, "${contextPath}/static/assets/js/jqGrid/jquery.jqGrid.js", "${contextPath}/static/assets/js/jqGrid/i18n/grid.locale-cn.js", "${contextPath}/static/assets/js/lazyload/jquery.lazyload.js", null ];
	$('.page-content-area').ace_ajax('loadScripts', scripts, function() {
    	// inline scripts related to this page
    	jQuery(function($) {
    		var grid_selector = "#grid-table";
    		var pager_selector = "#grid-pager";

    		// resize to fit page size
    		$(window).on('resize.jqGrid', function() {
    			$(grid_selector).jqGrid('setGridWidth', $(".page-content").width());
    		})
    		// resize on sidebar collapse/expand
    		var parent_column = $(grid_selector).closest('[class*="col-"]');
    		$(document).on('settings.ace.jqGrid', function(ev, event_name, collapsed) {
    			if (event_name === 'sidebar_collapsed' || event_name === 'main_container_fixed') {
    				// setTimeout is for webkit only to give time for DOM changes and then redraw!!!
    				setTimeout(function() {
    					$(grid_selector).jqGrid('setGridWidth', parent_column.width());
    				}, 0);
    			}
    		});
    		
    		$(document).keydown(function(event) {
				var key = window.event ? event.keyCode : event.which;
				if (key == 13) {
					$("#searchd").click();
				}
			});

		/*搜索框  主要对Jquery grid进行刷新 带参数刷新    */
			$("#searchd").click(function(){
				var keyword =encodeURI(encodeURI($("#keyword").val()));
				var orderState = $("#orderState").val();
				console.log("1"+keyword)
				console.log("2"+orderState)
		    	myGrid.setGridParam({data:'json',url : '${contextPath}/ajhz/order/getOrders?keyword='+keyword+'&orderState='+orderState}).trigger('reloadGrid');
			});
			
    	    myGrid=	jQuery(grid_selector).jqGrid({
    			subGrid : false,
    			url : "${contextPath}/ajhz/order/getOrders",
    			datatype : "json",
    			height : 450,
    			colNames : ['订单号', '提交时间','地区','发起律师','发起律师电话','接案律师','接案律师电话','订单类型','订单状态 ','要保证金','平台服务费','返回积分','付款时间','过期时间','备注','操作'],
    			colModel : [{	name : 'orderId',
    				index : 'orderId',
    				width : 120,
    				editable : false,
    				//sorttype : 'date'
    			},{	name : 'createDate',
    				index : 'createDate',
    				width : 120,
    				search : false,	
    				editable : false,
    				readonly : true,
    				//sorttype : 'date'
    			},{	name : 'areaFullName',
    				index : 'areaFullName',
    				width : 80,
    				search : false,	
    				editable : false,
    			},{	name : 'lawyerA_realName',
    				index : 'lawyerA_realName',
    				width : 80,
    				editable : false
    			},{	name : 'lawyerA_mobile',
    				index : 'lawyerA_mobile',
    				width : 120,
    				editable : false
    			},{
    				name : 'lawyerB_realName',
    				index : 'lawyerB_realName',
    				width : 80,
    				editable : false,
    			},{	name : 'lawyerB_mobile',
    				index : 'lawyerB_mobile',
    				width : 120,
    				editable : false
    			},{
    				name : 'orderType',
    				index : 'orderType',
    				width : 100,
    				editable : false
    			},{
    				name : 'orderState',
    				index : 'orderState',
    				width : 80,
    				editable : false
    			}, {
    				name : 'bzj',
    				index : 'bzj',
    				width : 100,
    				editable : false
    				
    			}, {
    				name : 'fwf',
    				index : 'fwf',
    				width : 100,
    				editable : false
    				
    			}, {
    				name : 'points',
    				index : 'points',
    				width : 80,
    				editable : false
    				
    			}, {
    				name : 'paidDate',
    				index : 'paidDate',
    				width : 130,
    				editable : false
    				
    			}, {
    				name : 'expiresDate',
    				index : 'expiresDate',
    				width : 130,
    				editable : false
    				
    			}, {
    				name : 'remark',
    				index : 'remark',
    				width : 80,
    				editable : false
    				
    			},{	name : 'type',
     				index : 'type',
     				label : '操作',
     				width : 180,
     				editable : false,
     				search : false,
     				sortable : false,
       				fixed:true,
     				formatter : optionFormatter
    			}],
    			//scroll : 1, // set the scroll property to 1 to enable paging with scrollbar - virtual loading of records
    			sortname : "createDate",
    			sortorder : "desc",
    			viewrecords : true,
    			rowNum : 10,
    			rowList : [ 10, 20, 30 ],
    			pager : pager_selector,
    			altRows : true,
    			loadComplete : function() {
    				var table = this;
    				setTimeout(function(){
    					styleCheckbox(table);
    					updateActionIcons(table);
    					updatePagerIcons(table);
    					enableTooltips(table);
    				}, 0);
    			}
    			//caption : "用户管理列表",
    			//autowidth : true,
    			/**
    			grouping : true, 
    			groupingView : { 
    				 groupField : ['name'],
    				 groupDataSorted : true,
    				 plusicon : 'fa fa-chevron-down bigger-110',
    				 minusicon : 'fa fa-chevron-up bigger-110'
    			},
    			*/
    		});
    		
     		function optionFormatter(cellvalue, options, cell) {
     			var template = "<button data-toggle='modal' onclick='showdetail(\""+cell.orderId+"\")' class='btn btn-minier btn-grey'>详细</button>";
     			template += "&nbsp;|&nbsp;<button data-toggle='modal' onclick='showModifyOrder(\""+cell.orderId+"\",\""+cell.type+"\",\""+cell.remark+"\")' class='btn btn-minier btn-primary'>修改</button>";

				if(cell.orderState != "已取消" && cell.orderState != "已完成"){
					/*alert(cell.orderState);*/
					var b = true;
					if(cell.orderState > 3){
						b = checkUserDeps([dep_YFB,dep_CWB]);
					}
					if(b){
						template += "&nbsp;|&nbsp;<button data-toggle='modal' onclick='cancel_confirm(\""+cell.orderId+"\")' class='btn btn-minier btn-primary'>取消订单</button>";
					}
				}

     			return template;
     		}
     		
    		$(window).triggerHandler('resize.jqGrid');// trigger window resize to make the grid get the correct size
    		
    		// enable search/filter toolbar
    		// jQuery(grid_selector).jqGrid('filterToolbar',{defaultSearch:true,stringResult:true})
    		// jQuery(grid_selector).filterToolbar({});
    		// switch element when editing inline
    		function aceSwitch(cellvalue, options, cell) {
    			setTimeout(function() {
    				$(cell).find('input[type=checkbox]').addClass('ace ace-switch ace-switch-5').after('<span class="lbl"></span>');
    			}, 0);
    		}
    		
    		// navButtons
    		jQuery(grid_selector).jqGrid('navGrid', pager_selector,  { // navbar options
    			edit : false,
    			editicon : 'ace-icon fa fa-pencil blue',
    			add : false,
    			addicon : 'ace-icon fa fa-plus-circle purple',
    			del : false,
    			delicon : 'ace-icon fa fa-trash-o red',
    			search : false,
    			searchicon : 'ace-icon fa fa-search orange',
    			refresh : true,
    			refreshicon : 'ace-icon fa fa-refresh blue',
    			view : false,
    			viewicon : 'ace-icon fa fa-search-plus grey'
    		}, {
    			// edit record form
    			// closeAfterEdit: true,
    			// width: 700,
    			recreateForm : true,
    			beforeShowForm : function(e) {
    				var form = $(e[0]);
    				form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
    				style_edit_form(form);
    			},
				errorTextFormat: function (response) {
					var result = eval('('+response.responseText+')');
				    return result.message;
				}
    		})
    		
    		function style_edit_form(form) {
    			// form.find('input[name=statusCn]').addClass('ace ace-switch ace-switch-5').after('<span class="lbl"></span>');
    			// don't wrap inside a label element, the checkbox value won't be submitted (POST'ed)
    			// .addClass('ace ace-switch ace-switch-5').wrap('<label class="inline" />').after('<span class="lbl"></span>');

    			// update buttons classes
    			var buttons = form.next().find('.EditButton .fm-button');
    			buttons.addClass('btn btn-sm').find('[class*="-icon"]').hide();// ui-icon, s-icon
    			buttons.eq(0).addClass('btn-primary').prepend('<i class="ace-icon fa fa-check"></i>');
    			buttons.eq(1).prepend('<i class="ace-icon fa fa-times"></i>')

    			buttons = form.next().find('.navButton a');
    			buttons.find('.ui-icon').hide();
    			buttons.eq(0).append('<i class="ace-icon fa fa-chevron-left"></i>');
    			buttons.eq(1).append('<i class="ace-icon fa fa-chevron-right"></i>');
    		}



    

    		function beforeEditCallback(e) {
    			var form = $(e[0]);
    			form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
    			style_edit_form(form);
    		}

    		// it causes some flicker when reloading or navigating grid
    		// it may be possible to have some custom formatter to do this as the grid is being created to prevent this
    		// or go back to default browser checkbox styles for the grid
    		function styleCheckbox(table) {
    			/**
    			 * $(table).find('input:checkbox').addClass('ace') .wrap('<label />') .after('<span class="lbl align-top" />') $('.ui-jqgrid-labels th[id*="_cb"]:first-child')
    			 * .find('input.cbox[type=checkbox]').addClass('ace') .wrap('<label />').after('<span class="lbl align-top" />');
    			 */
    		}

    		// unlike navButtons icons, action icons in rows seem to be hard-coded
    		// you can change them like this in here if you want
    		function updateActionIcons(table) {
    			/**
    			 * var replacement = { 'ui-ace-icon fa fa-pencil' : 'ace-icon fa fa-pencil blue', 'ui-ace-icon fa fa-trash-o' : 'ace-icon fa fa-trash-o red', 'ui-icon-disk' : 'ace-icon fa fa-check green', 'ui-icon-cancel' :
    			 * 'ace-icon fa fa-times red' }; $(table).find('.ui-pg-div span.ui-icon').each(function(){ var icon = $(this); var $class = $.trim(icon.attr('class').replace('ui-icon', '')); if($class in replacement)
    			 * icon.attr('class', 'ui-icon '+replacement[$class]); })
    			 */
    		}

    		// replace icons with FontAwesome icons like above
    		function updatePagerIcons(table) {
    			var replacement = {
    				'ui-icon-seek-first' : 'ace-icon fa fa-angle-double-left bigger-140',
    				'ui-icon-seek-prev' : 'ace-icon fa fa-angle-left bigger-140',
    				'ui-icon-seek-next' : 'ace-icon fa fa-angle-right bigger-140',
    				'ui-icon-seek-end' : 'ace-icon fa fa-angle-double-right bigger-140'
    			};
    			$('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function() {
    				var icon = $(this);
    				var $class = $.trim(icon.attr('class').replace('ui-icon', ''));

    				if ($class in replacement)
    					icon.attr('class', 'ui-icon ' + replacement[$class]);
    			})
    		}

    		function enableTooltips(table) {
    			$('.navtable .ui-pg-button').tooltip({
    				container : 'body'
    			});
    			$(table).find('.ui-pg-div').tooltip({
    				container : 'body'
    			});
    		};



    		// var selr = jQuery(grid_selector).jqGrid('getGridParam','selrow');

    		$(document).one('ajaxloadstart.page', function(e) {
    			$(grid_selector).jqGrid('GridUnload');
    			$('.ui-jqdialog').remove();
    		});
    		
    		$('#modal-edit-order-submit').click(function(event) {
    			modifyOrder();
			});
    	});
    });
	
	function modifyOrder(){
		var orderId = $('#mod-edit-orderId').val();
		var state = $('#mod-edit-state').val();
		var remark = $('#mod-edit-remark').val();
		$.ajax({
			dataType : "json",
			url : "${contextPath}/ajhz/order/editOrder",
			type : "post",
			data : {
				'orderId' : orderId,
				'state' : state,
				'remark' : remark
			},
			complete : function(ret) {
				var ret = eval("(" + ret.responseText + ")");
				if(ret.success){
					alert('保存成功');
					$('#modal-edit-order').modal('toggle');
					myGrid.trigger("reloadGrid");
				}else{
					alert(ret.message);
				}
			}
		});
	}
	
	function showAjhzBidd(orderId){
		$.ajax({
			dataType : "json",
			url : "${contextPath}/ajhz/order/getAjhzBidds",
			type : "post",
			data : {
				'orderId' : orderId
			},
			complete : function(ret) {
				var ret = eval("(" + ret.responseText + ")");
				if(ret.success){
					var html = '';
					var r = null;
					for(var i=0;i<ret.rows.length;i++){
						r = ret.rows[i];
						if(i > 0){
							html += '<div class="hr-line-dashed"></div>';
						}
						html += '<div class="row">';
						html += 	'<label class="col-sm-3 control-label">姓名</label>';
						html += 	'<label class="col-sm-3 control-label text-right">' + r.lawyer_name + '</label>';
						html += 	'<label class="col-sm-3 control-label">电话</label>';
						html += 	'<label class="col-sm-3 control-label text-right">' + r.mobile + '</label>';
						html += '</div>';
						html += '<div class="row">';
						html += 	'<label class="col-sm-3 control-label">报价</label>';
						html += 	'<label class="col-sm-3 control-label text-right">' + r.fee + '</label>';
						html += 	'<label class="col-sm-3 control-label">状态</label>';
						html += 	'<label class="col-sm-3 control-label text-right">' + r.state + '</label>';
						html += '</div>';
						html += '<div class="row">';
						html += 	'<label class="col-sm-3 control-label">接单优势</label>';
						html += 	'<label class="col-sm-9 control-label text-right">' + r.odds + '</label>';
						html += '</div>';
					}
					$('#modal-AjhzBidds-body').html(html);
					$('#modal-AjhzBidds').modal('toggle');
				}else{
					alert(ret.message);
				}
			}
		});
	}
	
	function showdetail(orderId){
		$.ajax({
			dataType : "json",
			url : "${contextPath}/ajhz/order/getOrderDetail",
			type : "post",
			data : {
				'orderId' : orderId
			},
			complete : function(ret) {
				var ret = eval("(" + ret.responseText + ")");
				if(ret.success){
					var rowIds = {'mo-row1':true,'mo-row2':true,'mo-row3':true,'mo-row4':true,'mo-line1':true,'mo-line2':true,'mo-line3':true};
					switch (ret.orderType){
						case 11:
							$('#mo-row1-l1').html('案件类型');
							$('#mo-row1-l2').html(ret.caseType);
							$('#mo-row1-l3').html('标的额');
							$('#mo-row1-l4').html(ret.fee);
							$('#mo-row2-l1').html('介绍费');
							$('#mo-row2-l2').html(ret.jsf);
							$('#mo-row2-l3').html('申请律师');
							$('#mo-row2-l4').html('<a class="btn btn-minier btn-primary" href="#" onClick="showAjhzBidd(\'' + orderId + '\')">查看</a>');
							$('#mo-row4-l1').html('案情');
							$('#mo-row4-l2').html(ret.info);
							rowIds['mo-row3'] = false;
							rowIds['mo-line2'] = false;
							break;
						case 12:
							$('#mo-row1-l1').html('被执行人姓名');
							$('#mo-row1-l2').html(ret.addr);
							$('#mo-row1-l3').html('债权金额');
							$('#mo-row1-l4').html(ret.fee);
							$('#mo-row2-l1').html('代理方式');
							$('#mo-row2-l2').html(ret.dlfs);
							$('#mo-row2-l3').html('介绍费');
							$('#mo-row2-l4').html(ret.jsf);
							$('#mo-row3-l1').html('申请律师');
							$('#mo-row3-l2').html('<a class="btn btn-minier btn-primary" href="#" onClick="showAjhzBidd(\'' + orderId + '\')">查看</a>');
							$('#mo-row4-l1').html('案情');
							$('#mo-row4-l2').html(ret.info);
							break;
						case 13:
							$('#mo-row1-l1').html('地点');
							$('#mo-row1-l2').html(ret.addr);
							$('#mo-row1-l3').html('时间');
							$('#mo-row1-l4').html(ret.addrTime);
							$('#mo-row2-l1').html('代办费');
							$('#mo-row2-l2').html(ret.jsf);
							$('#mo-row2-l3').html('申请律师');
							$('#mo-row2-l4').html('<a class="btn btn-minier btn-primary" href="#" onClick="showAjhzBidd(\'' + orderId + '\')">查看</a>');
							$('#mo-row4-l1').html('备注');
							$('#mo-row4-l2').html(ret.info);
							rowIds['mo-row3'] = false;
							rowIds['mo-line2'] = false;
							break;
						case 14:
							$('#mo-row1-l1').html('案件类型');
							$('#mo-row1-l2').html(ret.caseType);
							$('#mo-row1-l3').html('地点');
							$('#mo-row1-l4').html(ret.addr);
							$('#mo-row2-l1').html('时间');
							$('#mo-row2-l2').html(ret.addrTime);
							$('#mo-row2-l3').html('代办费');
							$('#mo-row2-l4').html(ret.jsf);
							$('#mo-row3-l1').html('申请律师');
							$('#mo-row3-l2').html('<a class="btn btn-minier btn-primary" href="#" onClick="showAjhzBidd(\'' + orderId + '\')">查看</a>');
							$('#mo-row4-l1').html('案情');
							$('#mo-row4-l2').html(ret.info);
							break;
						case 15:
							$('#mo-row1-l1').html('案件类型');
							$('#mo-row1-l2').html(ret.caseType);
							$('#mo-row1-l3').html('地点');
							$('#mo-row1-l4').html(ret.addr);
							$('#mo-row2-l1').html('时间');
							$('#mo-row2-l2').html(ret.addrTime);
							$('#mo-row2-l3').html('代办费');
							$('#mo-row2-l4').html(ret.jsf);
							$('#mo-row3-l1').html('申请律师');
							$('#mo-row3-l2').html('<a class="btn btn-minier btn-primary" href="#" onClick="showAjhzBidd(\'' + orderId + '\')">查看</a>');
							$('#mo-row4-l1').html('备注');
							$('#mo-row4-l2').html(ret.info);
							break;
						case 16:
							$('#mo-row1-l1').html('案件类型');
							$('#mo-row1-l2').html(ret.caseType);
							$('#mo-row1-l3').html('代办费');
							$('#mo-row1-l4').html(ret.jsf);
							$('#mo-row3-l1').html('申请律师');
							$('#mo-row3-l2').html('<a class="btn btn-minier btn-primary" href="#" onClick="showAjhzBidd(\'' + orderId + '\')">查看</a>');
							$('#mo-row4-l1').html('备注');
							$('#mo-row4-l2').html(ret.info);
							rowIds['mo-row2'] = false;
							rowIds['mo-line1'] = false;
							break;
					}
					for(var k in rowIds){
						if(rowIds[k]){
							$('#' + k).show();
						}else{
							$('#' + k).hide();
						}
					}
					$('#modal-orderDetail').modal('toggle');
				}else{
					alert(ret.message);
				}
			}
		});
	}
	
	function showModifyOrder(orderId, type, remark){
		$('#mod-edit-orderId').val(orderId);
		$('#mod-edit-state').val(type);
		$('#mod-edit-remark').val(remark);
		$('#modal-edit-order').modal('toggle');
	}

	//取消订单
	function cancel_confirm(orderId) {
		var r = confirm("确定取消订单？")
		if (r==true) {
			cancelAjhzOrder(orderId);
		}
	}

	function cancelAjhzOrder(orderId) {

		$.ajax({
			dataType : "json",
			url : "${contextPath}/ajhz/order/cancelOrder",
			type : "post",
			data : {
				'orderId' : orderId
			},
			complete : function(ret) {
				var ret = eval("(" + ret.responseText + ")");
				if (ret.success) {
					alert('保存成功');
					myGrid.trigger("reloadGrid");
				} else {
					alert(ret.message);
				}
			}
		});
	}
</script>