<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8"/>
    <title>Yoho!Buy运营平台</title>
    <script src="/ufoPlatform/js/include.js"></script>
    <script src="/ufoPlatform/js/clipboard.min.js"></script>
</head>
<body class="easyui-layout">
<input type="hidden" id="buyerOrderCode">
<input type="skup" id="skup">
<div region="north" style="height:300px;">
    <script>
        document.write(addHead('鉴定中心', '列表管理'));
    </script>
    <div style="width:1280px;">
        <select id="depotNo" class="easyui-combobox" style="width:70px;">
             <option value="0">北京</option>
             <option value="1">南京</option>
        </select>
    </div>
    <div id="tt" class="easyui-tabs">
       <div id="tab_0" title="待鉴定" style="padding:20px;display:none;">
          <div>
		    <label>订单编号:</label>
            <input id="orderCode_0" type="text" class="easyui-textbox" style="width:150px">

            <label>买家UID:</label>
            <input id="buyerUid_0" type="text" class="easyui-textbox" style="width:150px"/>
            
            <label>卖家快递单号:</label>
            <input id="sellerWaybillCode_0" type="text" class="easyui-textbox" style="width:150px"/>
            
            <label>订单状态:</label>
            <select id="status_0" class="easyui-combobox" style="width:250px;" >
                <option value="">全部</option>
                <option value="2">卖家已发货</option>
                <option value="3">平台鉴定中</option>
                <option value="17">已取消(买家在卖家发货后取消订单)</option>
            </select>
            
            <br>
            
            <label>商品编码:</label>
            <input id="productId_0" type="text" class="easyui-textbox" style="width:150px"/>
            
            <label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SKU:</label>
            <input id="sku_0" type="text" class="easyui-textbox" style="width:150px"/>
            
            <label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;手机号:</label>
            <input id="mobile_0" type="text" class="easyui-textbox" style="width:150px"/>
            
            <label>&nbsp;&nbsp;&nbsp;SKU-P:</label>
            <input id="skup_0" type="text" class="easyui-textbox" style="width:150px"/>
            
            <a id="searchBtn_0" class="btn-info">查询</a>
			<a id="allBtn_0" class="btn-success">全部</a>
		</div>
       </div>
       <div id="tab_1" title="鉴定完成" style="overflow:auto;padding:20px;display:none;">
           <div>
		    <label>订单编号:</label>
            <input id="orderCode_1" type="text" class="easyui-textbox" style="width:150px">

            <label>买家UID:</label>
            <input id="buyerUid_1" type="text" class="easyui-textbox" style="width:150px"/>
            
            <label>卖家快递单号:</label>
            <input id="sellerWaybillCode_1" type="text" class="easyui-textbox" style="width:150px"/>
            
            <label>鉴定结果:</label>
            <select id="status_1" class="easyui-combobox" style="width:100px;" >
                <option value="">全部</option>
                <option value="4">鉴定通过</option>
                <option value="13">鉴定不通过</option>
            </select>
            
            <br>
            
            <label>商品编码:</label>
            <input id="productId_1" type="text" class="easyui-textbox" style="width:150px"/>
            
            <label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SKU:</label>
            <input id="sku_1" type="text" class="easyui-textbox" style="width:150px"/>
            
            <label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;手机号:</label>
            <input id="mobile_1" type="text" class="easyui-textbox" style="width:150px"/>
            
            <label>&nbsp;&nbsp;&nbsp;SKU-P:</label>
            <input id="skup_1" type="text" class="easyui-textbox" style="width:150px"/>
            
            <a id="searchBtn_1" class="btn-info">查询</a>
			<a id="allBtn_1" class="btn-success">全部</a>
		</div>
       </div>
    </div>
</div>

<div id="orderList" region="center">
	<table id="orderListTable"></table>
</div>
<script>
$(function() {
	
	//获取鉴定状态对应的记录数
	getCountByJudgeStatus();
	
	$("#depotNo").combobox({
		onChange : function(newValue, oldValue){
			getCountByJudgeStatus();
			var depotNo = $("#depotNo").combobox("getValue");
			$("#orderListTable").datagrid("reload", {
            	statusStr : "2,3,17",
                depotNo : depotNo
            });
			//$("#tt").panel('refresh');
		}
	});
	
	$("#searchBtn_0").linkbutton({
        iconCls : "icon-search",
        onClick : function() {
            $("#orderListTable").datagrid("load", {
            	statusStr : "2,3,17",
            	status : $("#status_0").myCombobox("getValue"),
                orderCode : $("#orderCode_0").val(),
                uid : $("#buyerUid_0").val(),
                productId : $("#productId_0").val(),
                storageId : $("#sku_0").val(),
                skup : $("#skup_0").val(),
                sellerWaybillCode : $("#sellerWaybillCode_0").val(),
                mobile : $("#mobile_0").val(),
                depotNo : $("#depotNo").combobox("getValue")
            });
        }
    });
	$("#searchBtn_1").linkbutton({
        iconCls : "icon-search",
        onClick : function() {
            $("#orderListTable").datagrid("load", {
            	statusStr : "4,13",
            	status : $("#status_1").myCombobox("getValue"),
                orderCode : $("#orderCode_1").val(),
                uid : $("#buyerUid_1").val(),
                productId : $("#productId_1").val(),
                storageId : $("#sku_1").val(),
                skup : $("#skup_1").val(),
                sellerWaybillCode : $("#sellerWaybillCode_1").val(),
                mobile : $("#mobile_1").val(),
                depotNo : $("#depotNo").combobox("getValue")
            });
        }
    })
    
    getToBeJudgedList();
    $("#tt").tabs({
        onSelect:function(title,index){
        	if(index == 0){
        		getToBeJudgedList();
        	}else if(index == 1){
            	getAlreadyJudgedList();
            }
        }
    }); 
    
  //全部按钮
    $("#allBtn_0").linkbutton({
        iconCls: "icon-import",
        onClick: function () {
        	$("#orderCode_0").textbox('setValue','');
        	$("#uid_0").textbox('setValue','');
        	$("#sellerWaybillCode_0").textbox('setValue','');
        	$("#status_0").combobox('setValue','');
        	$("#productId_0").textbox('setValue','');
        	$("#sku_0").textbox('setValue','');
        	$("#mobile_0").textbox('setValue','');
        	$("#skup_0").textbox('setValue','');
            $("#orderListTable").datagrid("load", {
            	statusStr: "2,3,17",
            	depotNo: $("#depotNo").combobox("getValue")
            });
        }
    });
  
    $("#allBtn_1").linkbutton({
        iconCls: "icon-import",
        onClick: function () {
        	$("#orderCode_1").textbox('setValue','');
        	$("#uid_1").textbox('setValue','');
        	$("#sellerWaybillCode_1").textbox('setValue','');
        	$("#status_1").combobox('setValue','');
        	$("#productId_1").textbox('setValue','');
        	$("#sku_1").textbox('setValue','');
        	$("#mobile_1").textbox('setValue','');
        	$("#skup_1").textbox('setValue','');
            $("#orderListTable").datagrid("load", {
            	statusStr: "4,13",
            	depotNo: $("#depotNo").combobox("getValue")
            });
        }
    });
    
});

function getToBeJudgedList(){
	$("#orderListTable").myDatagrid({
        fit: true,
        fitColumns: true,
        striped: true,
        url: contextPath + "/buyerOrder/queryOrderList",
        method: 'POST',
        queryParams: {
        	statusStr: "2,3,17",
        	depotNo: $("#depotNo").combobox("getValue")
    	},
        loadFilter: function (data) {
        	var temp = defaultLoadFilter(data);
            temp=null==temp?[]:temp;
            temp.rows = temp.list;
            return temp;
        },

        columns: [[{
            title: "卖家快递单号",
            field: "sellerWaybillCode",
            width: 30,
            align: "center"
        },  {
            title: "收货仓库",
            field: "depotNo",
            width: 12,
            align: "center",
            formatter: function (value, rowData, rowIndex) {
            	if (value == 0) {
                    return "北京";
                }else if(value == 1){
                    return "南京";
                }
            }
        }, {
            title: "件数",
            field: "productNum",
            width: 8,
            align: "center"
        }, {
            title: "SKU",
            field: "skuStr",
            width: 10,
            align: "center"
        }, {
            title: "订单编号",
            field: "orderCode",
            width: 25,
            align: "center"
        }, {
            title: "订单状态",
            field: "status",
            width: 20,
            align: "center",
            formatter: function (value, rowData, rowIndex) {
            	if(rowData.statusStr){
            	    return rowData.statusStr;
                }
                return value;
            }
        },{
            title: "货号",
            field: "productCode",
            width: 20,
            align: "center"
        },{
            title: "商品名称",
            field: "productName",
            width: 20,
            align: "center"
        },{
            title: "尺码",
            field: "sizeName",
            width: 20,
            align: "center"
        },{
            title: "下单时间",
            field: "createTimeStr",
            width: 20,
            align: "center"
        },{
            title: "操作",
            field: "asdf",
            width: 40,
            align: "center",
            formatter: function (value, rowData, rowIndex) {
            	if (rowData.status == 2) {
                    return "<a role='confirm' dataId='"+ rowData.id +"' style='margin-left:10px;background-color: #5cb85c !important;'>确认收货</a>";
                } else if (rowData.status == 3) {
                    var operateButton = "<a role='pass' dataId='"+ rowData.id + "'" + " orderCode='"+rowData.orderCode +"' style='margin-left:10px;background-color: #5cb85c !important;'>鉴定通过</a>"+
                            "<a role='reject' dataId='"+ rowData.id + "'" + " skup='"+rowData.skup +"' style='margin-left:10px;background-color: #d9534f !important;'>鉴定不通过</a>"+
                            "<a role='record' dataId='"+ rowData.id + "' order_code='" + rowData.orderCode + "' skup='"+rowData.skup +"' style='margin-left:10px;background-color: #5cb85c !important;'>录制视频</a>";
                    if (rowData.containMp4Flag) {
                        operateButton += "<a role='query' dataId='"+ rowData.id + "' order_code='" + rowData.orderCode + "' skup='"+rowData.skup +"' style='margin-left:10px;background-color: #5cb85c !important;'>查看视频</a>";
                    }
                    return operateButton;
                } else if (rowData.status == 17) {
            	    if(rowData.platformWaybillCode){
                        return "<a role='send_back_rebackAddress' dataId='"+ rowData.orderCode +"' skup='"+ rowData.skup +"' style='margin-left:10px;background-color: #5cb85c !important;'>商品寄回地址</a>"
                            +"<a role='send_back_viewExpress' dataId='"+ rowData.orderCode + "' style='margin-left:10px;background-color: #5cb85c !important;'>查看物流</a>"
                        //+"<br/><span style='color:darkred;'>已寄回 ["+rowData.platformWaybillCode+"]</span>";
                            ;
                    }else{
                        return "<a role='reback' dataId='"+ rowData.id + "'" + " skup='"+rowData.skup +"' style='margin-left:10px;background-color: #5cb85c !important;'>寄回</a>";
                    }
                }
            }
        }]],
        cache: false,
        pagination: true,
        pageSize: 10,
        idField: "id",
        singleSelect: true,
        onLoadSuccess: function (data) {
           $(this).datagrid("getPanel").find("a[role='confirm']").linkbutton({
                onClick: function () {
                	var id = $(this).attr("dataId");
                	$.messager.confirm("确认收货提醒", "是否确认收货?确认收货前请务必确定货品已到达仓库。", function(flag) {
                        if (flag) {
                            $.post(contextPath + "/buyerOrder/updateOrderStatus", {
                                id : id,
                                status : 3
                            }, function(data) {
                                if (data.code == 200) {
                                    $("#orderListTable").datagrid("reload");
                                    window.self.$.messager.show({
                                        title : "提示",
                                        msg : "确认收货成功!"
                                    });
                                }else {
                                	window.self.$.messager.alert("失败", "失败!", "error");
                                }
                            });
                        }
                    });
                }
            });
            $(this).datagrid("getPanel").find("a[role='pass']").linkbutton({
                onClick: function () {
                	var buyerOrderCode = $(this).attr("orderCode");
                	$("#buyerOrderCode").val(buyerOrderCode);
                    addPassPage($(this).attr("dataId"));
                }
            });
            
            $(this).datagrid("getPanel").find("a[role='reject']").linkbutton({
                onClick: function () {
                	var skup = $(this).attr("skup");
                	$("#skup").val(skup);
                    addRejectPage($(this).attr("dataId"));
                }
            });

            // 查看视频
            $(this).datagrid("getPanel").find("a[role='query']").linkbutton({
                onClick: function () {
                    var skup = $(this).attr("skup");
                    var order_code = $(this).attr("order_code");
                    $("#skup").val(skup);
                    addQueryPage(skup, order_code, $(this).attr("dataId"));
                }
            });

            // 录制视频
            $(this).datagrid("getPanel").find("a[role='record']").linkbutton({
                onClick: function () {
                    var skup = $(this).attr("skup");
                    var order_code = $(this).attr("order_code");
                    $("#skup").val(skup);
                    addRecordPage(skup, order_code, $(this).attr("dataId"));
                }
            });

            $(this).datagrid("getPanel").find("a[role='reback']").linkbutton({
                onClick: function () {
                    var skup = $(this).attr("skup");
                    $("#skup").val(skup);
                    addRebackPage($(this).attr("dataId"));
                }
            });


            $(this).datagrid("getPanel").find("a[role='send_back_rebackAddress']").linkbutton({
                onClick: function () {
                    var buyerOrderCode = $(this).attr("dataId");
                    $("#buyerOrderCode").val(buyerOrderCode);
                    var skup = $(this).attr("skup");
                    $("#skup").val(skup);
                    rebackAddressPage();
                }
            });

            $(this).datagrid("getPanel").find("a[role='send_back_viewExpress']").linkbutton({
                onClick: function () {
                    var buyerOrderCode = $(this).attr("dataId");
                    $("#buyerOrderCode").val(buyerOrderCode);
                    viewExpressPage(buyerOrderCode);
                }
            });
            
        }
    });
}

function getAlreadyJudgedList(){
	$("#orderListTable").myDatagrid({
        fit: true,
        fitColumns: true,
        striped: true,
        url: contextPath + "/buyerOrder/queryOrderList",
        method: 'POST',
        queryParams: {
        	statusStr: "4,13",
        	depotNo: $("#depotNo").combobox("getValue")
    	},
        loadFilter: function (data) {
        	var temp = defaultLoadFilter(data);
            temp=null==temp?[]:temp;
            temp.rows = temp.list;
            return temp;
        },

        columns: [[{
            title: "平台快递单号",
            field: "platformWaybillCode",
            width: 30,
            align: "center"
        },  {
            title: "收货仓库",
            field: "depotNo",
            width: 20,
            align: "center",
            formatter: function (value, rowData, rowIndex) {
            	if (value == 0) {
                    return "北京";
                }else if(value == 1){
                    return "南京";
                }
            }
        }, {
            title: "商品件数",
            field: "productNum",
            width: 20,
            align: "center"
        }, {
            title: "SKU-P",
            field: "skup",
            width: 20,
            align: "center"
        }, {
            title: "订单编号",
            field: "orderCode",
            width: 30,
            align: "center"
        }, {
            title: "订单状态",
            field: "status",
            width: 20,
            align: "center",
            formatter: function (value, rowData, rowIndex) {
            	if (value == 4) {
                    return "鉴定通过";
                }else if(value == 13){
                    return "鉴定不通过";
                }
            }
        },{
            title: "货号",
            field: "productCode",
            width: 20,
            align: "center"
        },{
            title: "下单时间",
            field: "createTimeStr",
            width: 20,
            align: "center"
        },{
            title: "操作",
            field: "asdf",
            width: 40,
            align: "center",
            formatter: function (value, rowData, rowIndex) {
                var operateButton = '';
            	if (rowData.status == 4) {//鉴定通过
                    operateButton += "<a role='buyerReceiveInfo' dataId='"+ rowData.orderCode +"' style='margin-left:10px;background-color: #5cb85c !important;'>买家收货地址</a>" +
                    "<a role='viewExpress' dataId='"+ rowData.orderCode +"' style='margin-left:10px;background-color: #5cb85c !important;'>查看物流</a>";
                    if (rowData.containMp4Flag) {
                        operateButton += "<a role='queryForSuccess' dataId='"+ rowData.id + "' order_code='" + rowData.orderCode + "' skup='"+rowData.skup +"' style='margin-left:10px;background-color: #5cb85c !important;'>查看视频</a>";
                    }
                } else if (rowData.status == 13) {//鉴定不通过
                    operateButton += "<a role='rebackAddress' dataId='"+ rowData.orderCode +"' skup='"+ rowData.skup +"' style='margin-left:10px;background-color: #5cb85c !important;'>商品寄回地址</a>"+
                    "<a role='viewExpress' dataId='"+ rowData.orderCode + "' style='margin-left:10px;background-color: #5cb85c !important;'>查看物流</a>";
                    if (rowData.containMp4Flag) {
                        operateButton += "<a role='queryForSuccess' dataId='"+ rowData.id + "' order_code='" + rowData.orderCode + "' skup='"+rowData.skup +"' style='margin-left:10px;background-color: #5cb85c !important;'>查看视频</a>";
                    }
                }
                return operateButton;
            }
        }]],
        cache: false,
        pagination: true,
        pageSize: 10,
        idField: "id",
        singleSelect: true,
        onLoadSuccess: function (data) {
        	$(this).datagrid("getPanel").find("a[role='buyerReceiveInfo']").linkbutton({
                onClick: function () {
                	var buyerOrderCode = $(this).attr("dataId");
                	$("#buyerOrderCode").val(buyerOrderCode);
                	buyerReceiveInfoPage();
                }
            });
        	
        	$(this).datagrid("getPanel").find("a[role='rebackAddress']").linkbutton({
                onClick: function () {
                	var buyerOrderCode = $(this).attr("dataId");
                	$("#buyerOrderCode").val(buyerOrderCode);
                	var skup = $(this).attr("skup");
                	$("#skup").val(skup);
                	rebackAddressPage();
                }
            });
        	
        	$(this).datagrid("getPanel").find("a[role='viewExpress']").linkbutton({
                onClick: function () {
                	var buyerOrderCode = $(this).attr("dataId");
                	$("#buyerOrderCode").val(buyerOrderCode);
                	viewExpressPage(buyerOrderCode);
                }
            });

            // 查看视频
            $(this).datagrid("getPanel").find("a[role='queryForSuccess']").linkbutton({
                onClick: function () {
                    var skup = $(this).attr("skup");
                    var order_code = $(this).attr("order_code");
                    $("#skup").val(skup);
                    addQueryPage(skup, order_code, $(this).attr("dataId"));
                }
            });
        }
    });
}

function buyerReceiveInfoPage() {
    var div = $("<div id='buyerReceiveInfoDiv'>").appendTo($(document.body));
    var url = contextPath + "/html/judgeCenter/buyerReceiveInfo.html";
    $(div).myDialog({
        width: "50%",
        height: "60%",
        title: "买家收货地址",
        href: url,
        modal: true,
        collapsible: true,
        cache: false,
        buttons: [{
            text: "取消",
            iconCls: "icon-cancel",
            handler: function () {
                $(div).dialog("close");
            }
        }]
    });
}

function rebackAddressPage() {
    var div = $("<div id='rebackAddressDiv'>").appendTo($(document.body));
    var url = contextPath + "/html/judgeCenter/rebackAddress.html";
    $(div).myDialog({
        width: "50%",
        height: "60%",
        title: "商品寄回地址",
        href: url,
        modal: true,
        collapsible: true,
        cache: false,
        buttons: [{
            text: "取消",
            iconCls: "icon-cancel",
            handler: function () {
                $(div).dialog("close");
            }
        }]
    });
}

function viewExpressPage() {
    var div = $("<div id='viewExpressDiv'>").appendTo($(document.body));
    var url = contextPath + "/html/judgeCenter/viewExpress.html";
    $(div).myDialog({
        width: "50%",
        height: "60%",
        title: "平台发货物流信息",
        href: url,
        modal: true,
        collapsible: true,
        cache: false,
        buttons: [{
            text: "取消",
            iconCls: "icon-cancel",
            handler: function () {
                $(div).dialog("close");
            }
        }]
    });
}

function addPassPage(id) {
    var div = $("<div id='passDiv'>").appendTo($(document.body));
    var url = contextPath + "/html/judgeCenter/pass.html";
    $(div).myDialog({
        width: "50%",
        height: "60%",
        title: "发货(鉴定通过)",
        href: url,
        modal: true,
        collapsible: true,
        cache: false,
        buttons: [{
            text: "取消",
            iconCls: "icon-cancel",
            handler: function () {
                $(div).dialog("close");
            }
        },{
            text: "发货",
            id: "saveBtn",
            iconCls: "icon-save",
            onClick: function () {
            	$('#saveBtn').linkbutton('disable');
            	deliverGoods(id);
            }
        }]
    });
}
function addRebackPage(id) {
    var div = $("<div id='rebackDiv'>").appendTo($(document.body));
    var url = contextPath + "/html/judgeCenter/reject.html";
    $(div).myDialog({
        width: "50%",
        height: "60%",
        title: "商品寄回(买家已取消订单)",
        href: url,
        modal: true,
        collapsible: true,
        cache: false,
        buttons: [{
            text: "取消",
            iconCls: "icon-cancel",
            handler: function () {
                $(div).dialog("close");
            }
        },{
            text: "寄回",
            id: "rebackBtn",
            iconCls: "icon-save",
            onClick: function () {
                $('#rebackBtn').linkbutton('disable');
                reBackGoods(id);
            }
        }]
    });
}

function addRejectPage(id) {
    var div = $("<div id='rejectDiv'>").appendTo($(document.body));
    var url = contextPath + "/html/judgeCenter/reject.html";
    $(div).myDialog({
        width: "50%",
        height: "60%",
        title: "商品寄回(鉴定不通过)",
        href: url,
        modal: true,
        collapsible: true,
        cache: false,
        buttons: [{
            text: "取消",
            iconCls: "icon-cancel",
            handler: function () {
                $(div).dialog("close");
            }
        },{
            text: "寄回",
            id: "rejectBtn",
            iconCls: "icon-save",
            onClick: function () {
            	$('#rejectBtn').linkbutton('disable');
            	sendBackGoods(id);
            }
        }]
    });
}

function addRecordPage(skup, order_code, id) {
    var div = $("<div id='recordDiv'>").appendTo($(document.body));
    var url = contextPath + "/html/judgeCenter/record.html";
    $(div).myDialog({
        width: "45%",
        height: "35%",
        title: "视频录制",
        href: url,
        modal: true,
        collapsible: true,
        cache: false,
        buttons: [{
            text: "开始录制",
            id: "recordBtn",
            iconCls: "icon-save",
            onClick: function () {
                if (!$('#startTime').val() || $('#startTime').val() == '') {
                    if ($("#cameraCode").myCombobox("getValue") == undefined || $("#cameraCode").myCombobox("getValue") == '')
                    {
                        window.self.$.messager.alert("失败", "先选择摄像头", "error");
                        return;
                    }


                	timedCount();
                    $('#recordBtn').linkbutton({text:'结束录制'});
                    $('#startTime').val(parseInt(new Date().getTime() / 1000));
                    //$("#startTime").textbox('setValue',parseInt(new Date().getTime() / 1000));
                } else if ($('#endTime').val() == '') {
                	stopCount();
                    $('#endTime').val(parseInt(new Date().getTime() / 1000));
                   // $("#endTime").textbox('setValue',parseInt(new Date().getTime() / 1000));
                    $('#recordBtn').linkbutton({text:'上传云端'});
                } else if ($('#startTime').val() != '' && $('#endTime').val() != ''){
                    $('#recordBtn').linkbutton('disable');
                    $.post(contextPath + "/live/generateMp4", {
                        id : id,
                        skup : skup,
                        orderCode : order_code,
                        cameraCode : $("#cameraCode").myCombobox("getValue"),
                        startTime : $('#startTime').val(),
                        endTime : $('#endTime').val(),
                        depotNo: $("#depotNo").combobox("getValue")
                    }, function(data) {
                        if (data.code == 200) {
                            $("#recordDiv").dialog("close");
                            $("#orderListTable").datagrid("reload");
                            window.self.$.messager.show({
                                title : "提示",
                                msg : "上传云端操作成功!"
                            });
                        }else {
                            window.self.$.messager.alert("失败", data.message, "error");
                        }
                    });
                }
                //sendBackGoods(id);
            }
        },{
            text: "取消",
            iconCls: "icon-cancel",
            handler: function () {
                $(div).dialog("close");
            }
        }]
    });
}
// 查询视频
function addQueryPage(skup, order_code, id) {
	$.post(contextPath + "/live/queryMp4Vedio", {
        skup : skup,
        orderCode : order_code
    }, function(data) {
        if (data.code == 200) {
            window.open(data.data);
        }else {
            window.self.$.messager.alert("查询失败", data.message, "error");
        }
    });
}


function deliverGoods(id){
	var expressCompanyId = $("#expressCompany").myCombobox("getValue");
	var waybillCode = $("#waybillCode").textbox("getValue");
    var mobile = $("#receiveInfo_mobile").val();
	if(expressCompanyId==''){
		alert("请选择快递公司!");
		return;
	}
	if(waybillCode == ''){
		alert("请填写快递单号!");
		return;
	}
    if(!mobile){
        alert("收货人手机号为空!");
        return;
    }
	$.post(contextPath + "/buyerOrder/updateOrderStatus", {
        id : id,
        status : 4,
        expressCompanyId : expressCompanyId,
        waybillCode : waybillCode,
        mobile:mobile,
        depotNo: $("#depotNo").combobox("getValue") 
    }, function(data) {
        if (data.code == 200) {
        	//获取鉴定状态对应的记录数
        	getCountByJudgeStatus();
        	$("#passDiv").dialog("close");
            $("#orderListTable").datagrid("reload");
            window.self.$.messager.show({
                title : "提示",
                msg : "鉴定通过操作成功!"
            });
        }else {
        	window.self.$.messager.alert("失败", data.message, "error");
        }
    });
	
}

//卖家发货,但是买家已取消,直接寄回
function reBackGoods(id){
    var expressCompanyId = $("#expressCompany").myCombobox("getValue");
    var waybillCode = $("#waybillCode").textbox("getValue");
    var mobile = $("#sendBackInfo_mobile").val();
    if(expressCompanyId==''){
        alert("请选择快递公司!");
        return;
    }
    if(waybillCode == ''){
        alert("请填写快递单号!");
        return;
    }
    if(!mobile){
        alert("收货人手机号为空!");
        return;
    }
    $.post(contextPath + "/buyerOrder/returnBackOrder", {
        id : id,
        status : 17,
        expressCompanyId : expressCompanyId,
        waybillCode : waybillCode,
        mobile:mobile,
        depotNo: $("#depotNo").combobox("getValue")
    }, function(data) {
        if (data.code == 200) {
            $("#rebackDiv").dialog("close");
            $("#orderListTable").datagrid("reload");
            window.self.$.messager.show({
                title : "提示",
                msg : "商品寄回操作成功!"
            });
        }else {
            window.self.$.messager.alert("失败", data.message, "error");
        }
    });

}

//鉴定不通过寄回
function sendBackGoods(id){
	var expressCompanyId = $("#expressCompany").myCombobox("getValue");
	var waybillCode = $("#waybillCode").textbox("getValue");
    var mobile = $("#sendBackInfo_mobile").val();
	if(expressCompanyId==''){
		alert("请选择快递公司!");
		return;
	}
	if(waybillCode == ''){
		alert("请填写快递单号!");
		return;
	}
    if(!mobile){
        alert("收货人手机号为空!");
        return;
    }
	$.post(contextPath + "/buyerOrder/updateOrderStatus", {
        id : id,
        status : 13,
        expressCompanyId : expressCompanyId,
        waybillCode : waybillCode,
        mobile:mobile,
        depotNo: $("#depotNo").combobox("getValue")
    }, function(data) {
        if (data.code == 200) {
        	//获取鉴定状态对应的记录数
        	getCountByJudgeStatus();
        	$("#rejectDiv").dialog("close");
            $("#orderListTable").datagrid("reload");
            window.self.$.messager.show({
                title : "提示",
                msg : "鉴定不通过操作成功!"
            });
        }else {
        	window.self.$.messager.alert("失败", data.message, "error");
        }
    });
	
}

function getCountByJudgeStatus(){
	var form = new FormData();
    form.append("depotNo", $("#depotNo").combobox("getValue"));
	//发送请求
	$.ajax({
	     type: "POST",
         url: contextPath + '/buyerOrder/getCountByJudgeStatus',
         data: form,
         async: false,
         cache: false,
         contentType: false,
         processData: false,
         dataType: 'json',
         success: function (result) {
             if(result.code == 200) {
            	 var tab_0 = $('#tt').tabs('getTab',0);  // 取得第一个tab
            	 $('#tt').tabs('update', {
            	     tab: tab_0,
            	     options: {
            	         title: '待鉴定('+ result.data.toBeJudgedNum + ")"
            	     }
            	 });
            	 
            	 var tab_1 = $('#tt').tabs('getTab',1);  // 取得第一个tab
            	 $('#tt').tabs('update', {
            	     tab: tab_1,
            	     options: {
            	         title: '鉴定完成('+ result.data.alreadyJudgedNum + ")"
            	     }
            	 });
            	    
             }
             else {
                 $.messager.alert("失败", result.message, "error");
             }
         }
     });      
}

</script>
</body>
</html>