var test = true, orderState = ""; window.onload = function (ev) { init(); //日历控件 laydate.render({ elem: '#startTime', //指定元素 type: 'datetime', // value: getFormatDate(false), max: getFormatDate(true), done: function (value, date, endDate) { $("#startTime").next().show(); } }); //日历控件 laydate.render({ elem: '#endTime', //指定元素 type: 'datetime', // value: getFormatDate(true), max: getFormatDate(true), done: function (value, date, endDate) { $("#endTime").next().show(); } }); excel(); } init = function () { var today = getFormatDate(false), // var today = '2018-10-10 00:00:00', now = getFormatDate(true), val = "", state = orderState; $("#startTime").val(today); $("#endTime").val(now); $("#startTime").next().show(); $("#endTime").next().show(); } //搜索-打印表格 searchExcel = function () { $("#loading").css({"display": "block"}); $("#warp").css({"display": "none"}); var starttime = $("#startTime")[0].value, endtime = $("#endTime")[0].value; var parameter = urlEncode(["SelectExcel", starttime, endtime]); $.ajax({ type: "post", url: "/malai/php/index.php", data: {mode: parameter}, dataType: "json", success: function (data) { if (data.length == 0 || data == -1) { $("#loading").css({"display": "none"}); $("#warp").css({"display": "table-row-group"}); $("#warp").html(""); var th = '暂无数据'; $("#warp").html(th); return; } printExcel(data); } }); } printExcel = function (data) { var warp = $("#warp"), tr, state = {1: "已付款,

等待发货

", 2: "已发货

等待收货

", 3: "已收货"}, title = "'订单详情'"; var ordernum, product_remarks, order_class, order_class_color, order_class_div, product_price, order_number, order_price, order_time, order_state, order_operation, order_operation_delivergoods, order_operation_buygood, order_operation_href, odrer_address; warp.html(""); for (var i = 0; i < data.length; i++) { order_class_div = ""; ordernum = ''; product_remarks = '' + data[i].ProductRemarks + ''; product_price = '' + Math.ceil(data[i].ProductPrice) + ''; if (data[i].ProductInfoClassId == "") { order_class_color = data[i].ProductAttributeId.split(",")[1]; order_class = '
' + order_class_color; order_number = '' + data[i].ProductNumber + ''; order_price = '' + '' + data[i].Payment + ''; } else { data[i].ProductInfoClassId = JSON.parse(unescape(data[i].ProductInfoClassId)); for (var j in data[i].ProductInfoClassId) { if (j == 0) { order_number = '' + data[i].ProductInfoClassId[0].Number + ''; order_price = '' + parseInt(data[i].ProductInfoClassId[0].Money) * parseInt(data[i].ProductInfoClassId[0].Number) + ''; } else { order_class_color = data[i].ProductInfoClassId[j].color; order_class_div += '
' + order_class_color + '
'; order_class = '' + order_class_div + ''; } } } order_time = '

' + data[i].OrderAddtime.split(" ")[0] + '

' + data[i].OrderAddtime.split(" ")[1] + '

'; order_state = '' + state[data[i].OrderState] + ''; if (data[i].OrderState == 1) { order_operation_delivergoods = '发货'; } else if (data[i].OrderState == 2) { order_operation_delivergoods = '确认买家已收货'; } else if (data[i].OrderState == 3) { order_operation_delivergoods = ""; } if (data[i].BuyGoods == 0 || !data[i].BuyGoods) { order_operation_buygood = '采购'; } else { order_operation_buygood = '已采购'; } order_operation_href = "'orderinfo.html?oid=" + data[i].OrderId + "&pid=" + data[i].ProductId + "'"; order_operation = '' + order_operation_delivergoods + order_operation_buygood + '查看订单信息' + '删除' + ''; // odrer_address = '' + data[i].ProductIntroduce + ''; odrer_address = '' + data[i].ProductIntroduce + ''; tr = $('' + ordernum + product_remarks + order_class + product_price + order_number + order_price + order_time + order_state + ''); warp.append(tr); } $("#loading").css({"display": "none"}); $("#warp").css({"display": "table-row-group"}); } excel = function () { $("#getValue").click(function () { var valArr = new Array; $("#warp :checkbox").each(function (i) { if (this.checked === true) { valArr.push($(this).val()); } }); var vals = valArr.join(','); var valsJ = JSON.stringify(vals); window.open("../php/excel.php?" + "vals=" + valsJ); // alert(vals); }); } getJsonObjLength = function (jsonObj) { var Length = 0; for (var item in jsonObj) { Length++; } return Length; } urlEncode = function (arr) { var i; //循环初始化 for (i = 0; i < arr.length; i++) { arr[i] = encodeURIComponent(encodeURIComponent(arr[i])); } return arr.join(); } getFormatDate = function (flag) { var nowDate = new Date(); var year = nowDate.getFullYear(); var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1) : nowDate.getMonth() + 1; var date = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate.getDate(); var hour = nowDate.getHours() < 10 ? "0" + nowDate.getHours() : nowDate.getHours(); var minute = nowDate.getMinutes() < 10 ? "0" + nowDate.getMinutes() : nowDate.getMinutes(); var second = nowDate.getSeconds() < 10 ? "0" + nowDate.getSeconds() : nowDate.getSeconds(); var val; if (flag == true) { val = year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second; } else if (flag == false) { val = year + "-" + month + "-" + date + " 00:00:00"; } else if (flag == -1) { val = year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second; } return val; } hideSelectClose = function (el) { $(el).hide(); $("#" + $(el).prev().attr("id")).val(""); } toogle = function (cs) { var child = $(cs); for (var i = 0; i < child.length; i++) { if (child[i].style.display == "none") { child[i].style.display = "block"; } else { child[i].style.display = "none"; } } }