var isOnDuty = null; var postCode = null; var userId = null; var curDateType = 1; var noticeData = null; window.onload = function () { postAjax("get_user_info", "", function (data) { $("#userIcon").attr("src", data[0]["Picture"] != "" ? data[0]["Picture"] : "images/userCenter/user.png"); $("#userName").text(data[0]["Name"]); $("#depName").text(data[0]["OrgName"]); $("#postName").text(data[0]["PostName"]); isOnDuty = data[0]["OnDuty"]; isBeOnDuty = data[0]["BeOnDuty"]; postCode = data[0]["PostCode"]; userId = data[0]["ID"]; userPostCode = postCode; $("#id_customer1").show(); $("#id_all1").hide(); mini.get() //设计 if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr") { $("#dutyState").text(isOnDuty == 1 ? (isBeOnDuty == 1 ? "(值班)接单中" : "(上班)接单中") : "未到岗"); $("#dutyState").css("color", isOnDuty == 1 ? "green" : "red"); mini.get("btnOnduty").setEnabled(isOnDuty != 1); mini.get("cmbSearchDate").setValue(1); //$("#userOnduty").css('visibility', 'visible'); //$("#id_design1").css('visibility', 'visible'); //$("#id_design2").css('visibility', 'visible'); $("#id_all1").show(); $("#id_all2").show(); $("#userOnduty").show(); $("#id_design1").show(); $("#id_design2").show(); $("#id_design3").show(); $("#id_design4").show(); getDesignerDataList(1); $("#dataDesignCount").show(); $("#dataBackCount").show(); getCenterDataList(0) } //客服 if (postCode == "CustomerService" || postCode == "Director") { $("#id_all1").show(); $("#id_all2").show(); mini.get("cmbSearchDate").setValue(1); $("#id_customer1").show(); $("#id_customer2").show(); $("#id_customer3").show(); getCustomerDataList(1); $("#dataDesignCount").show(); $("#dataOrderCount").show(); $("#dataSendCount").show(); $("#dataBackCount").show(); $("#dataRefundCount").show(); getCenterDataList(0) } //售后 if (postCode == "AfterSale" || postCode == "AfterSaleMaster") { $("#dataSendCount").show(); $("#dataRefundCount").show(); $("#dataCheckCount").show(); getCenterDataList(2) } //下单部 if (postCode == "Place" || postCode == "PlaceMr") { $("#dataOrderCount").show(); $("#dataSendCount").show(); getCenterDataList(1) } //车间 if (postCode == "Supplier") { $("#dataCheckCount").show(); getCenterDataList(5) } }); postAjax("get_center_data", "", function (data) { if (data && data.length > 0) { let info = data[0]; $("#designCountText").text(`(${info.designCount || 0})`) $("#orderCountText").text(`(${info.orderCount || 0})`) $("#sendCountText").text(`(${info.sendCount || 0})`) $("#backCountText").text(`(${info.backCount || 0})`) $("#refundCountText").text(`(${info.refundCount || 0})`) $("#checkCountText").text(`(${info.checkCount || 0})`) } }) if (noticeData != null && noticeData.length > 0) { //console.log("noticedata", noticeData); var wt = this.document.body.clientWidth; var ht = this.document.body.clientHeight; mini.open({ url: "../" + "ENotice/Notice_win.aspx?", title: "公告栏", width: wt - 100, height: ht - 200, style: "border:0px", showCloseButton: false, allowResize: true, onload: function () { //var iframe = this.getIFrameEl(); //var data = { action: "new" }; //iframe.contentWindow.SetData(data); }, ondestroy: function (action) { } }); //openWin("订单详情", "EOrder/Order_Detail.aspx?ctid=" + ctid + "&tid=" + tid + "", 1000, 500); //var ahtml = ""; //var ids = ""; //for (var item of noticeData) { // ids += item.ID; // ids += ","; // ahtml += ("
标题:" + item.Title + "
") // ahtml += ("
来自:" + item.senderName + " " + formatCommonDate(item.CreatedTime) + "
") // ahtml += ("
内容:" + item.Con + "
") //} //ahtml += ("已读通知"); //$("#notice_con").html(ahtml); //mini.get("notice_win").show(); } }; //function clickToRead(ids) { // postAjax("set_erp_readnotice", "ids=" + ids, function (data) { // mini.get("notice_win").hide(); // }); //} function getCenterDataList(order_type) { let data_grid = mini.get("data_grid"); let title = ""; switch (order_type) { case 0: title = "设计超时"; break; case 1: title = "下单超时"; break; case 2: title = "发货超时"; break; case 3: title = "打回订单"; break; case 4: title = "退款订单"; break; case 5: title = "查货超时"; break; default: break; } $("#center_data_layout .mini-panel-title").text(title); data_grid.load({ order_type }); } function userOnDuty() { mini.showMessageBox({ title: "请选择是“上班”还是“值班”", iconCls: "mini-messagebox-question", buttons: ["上班", "值班", "晚班", "取消"], message: "选择:上班,值班,晚班,取消。", callback: function (action) { if (action == "上班" || action == "值班" || action == "晚班") { postAjax("upd_user_onduty", "duty=" + action, function (data) { $("#dutyState").text("(" + action + ")接单中"); $("#dutyState").css("color", "green"); mini.get("btnOnduty").setEnabled(false); }); } } }); } function userOffDuty() { postAjax("upd_user_offduty", "", function (data) { $("#dutyState").text("未到岗"); $("#dutyState").css("color", "red"); mini.get("btnOnduty").setEnabled(true); }); } function dispatchDTRenderer(e) { var record = e.record; var html = "
" + formatCommonDate(record.WaitDesignTime) + "
"; return html; } function overtimeDTRenderer(e) { var record = e.record; var html = "
接单:" + formatCommonDate(record.WaitDesignTime) + "
"; html += "
超时:" + formatCommonDate(record.WaitDesignTime) + "
"; return html; } function isAutoDispatchRenderer(e) { var record = e.record; var html = "
" + record.IsAutoDispatch ? "是" : "否" + "
"; return html; } function getDesignerDataList(dateType) { if (dateType == 3) { postAjax("get_total_data", "", function (data) { $("#_totalCount").text(data[0]["orderCount"]); $("#_totalAmount").text(data[0]["orderAmount"]); $("#_refundCount").text(data[0]["refundCount"]); $("#_refundAmount").text(data[0]["refundAmount"]); $("#_unBeginAmount").text(data[0]["orderBeginAmount"]); $("#_unBeginCount").text(data[0]["orderBeginCount"]); $("#_unFinishAmount").text(data[0]["orderFinishAmount"]); $("#_unFinishCount").text(data[0]["orderFinishCount"]); var per = Math.floor(parseInt(data[0]["refundCount"]) / parseInt(data[0]["orderCount"]) * 100); if (parseInt(data[0]["orderCount"]) == 0) { per = 0; } $("#_refundCountPer").text(per + "%"); }); } else { postAjax("get_date_area_total_data", "timetype=" + dateType, function (data) { var strData = data.data; var dataList = strData.split(","); $("#_unBeginCount").text(dataList[2]); $("#_unBeginAmount").text(dataList[3]); $("#_unFinishCount").text(dataList[4]); $("#_unFinishAmount").text(dataList[5]); $("#_totalCount").text(dataList[0]); $("#_totalAmount").text(dataList[1]); $("#_refundCount").text(dataList[6]); $("#_refundAmount").text(dataList[7]); var per = Math.floor(parseInt(dataList[6]) / (parseInt(dataList[0])) * 100); if (parseInt(dataList[0]) == 0) { per = 0; } $("#_refundCountPer").text("率:" + per + "%"); }); } var timearr = []; if (dateType == 0) { var day = getCurDate(); timearr.push(day); timearr.push(day); } else if (dateType == 1) { timearr = getWeekStartAndEnd(); } else if (dateType == 2) { timearr = getMonthStartAndEnd(); } wait_grid = mini.get("wait_grid"); wait_grid.load({ paraFields: "ctid, WaitDesignTime,payment,IsAutoDispatch", paraOrder: "WaitDesignTime asc", paraWhere: "OrderState = 3 and DesignUserId = " + userId + " and WaitDesignTime >= '" + timearr[0] + "' and WaitDesignTime <= '" + timearr[1] + "'", paraPageSize: 1000 }); design_grid = mini.get("design_grid"); design_grid.load({ paraFields: "ctid, WaitDesignTime,payment,IsAutoDispatch", paraOrder: "WaitDesignTime asc", paraWhere: "OrderState = 4 and DesignUserId = " + userId + " and WaitDesignTime >= '" + timearr[0] + "' and WaitDesignTime <= '" + timearr[1] + "'", paraPageSize: 1000 }); unusual_grid = mini.get("unusual_grid"); unusual_grid.load({ paraFields: "ctid, WaitDesignTime,UnusualTime,payment,IsAutoDispatch", paraOrder: "WaitDesignTime asc", paraWhere: "OvertimeUserId = " + userId + " and WaitDesignTime >= '" + timearr[0] + "' and WaitDesignTime <= '" + timearr[1] + "'", paraPageSize: 1000 }); //wait_grid = mini.get("wait_grid"); //wait_grid.load({ date_type: dateType }); order_grid = mini.get("order_grid"); order_grid.load({ date_type: dateType }); amount_grid = mini.get("amount_grid"); amount_grid.load({ date_type: dateType }); refundOrder_grid = mini.get("refundOrder_grid"); refundOrder_grid.load({ date_type: dateType }); refundAmount_grid = mini.get("refundAmount_grid"); refundAmount_grid.load({ date_type: dateType }); } function getCustomerDataList(dateType) { if (dateType == 3) { postAjax("get_total_data", "", function (data) { $("#_totalCount").text(data[0]["orderCount"]); $("#_totalAmount").text(data[0]["orderAmount"]); $("#_afterCount").text(data[0]["afterCount"]); $("#_afterAmount").text(data[0]["afterAmount"]); $("#_refundCount").text(data[0]["refundCount"]); $("#_refundAmount").text(data[0]["refundAmount"]); var per = Math.floor(parseInt(data[0]["refundCount"]) / parseInt(data[0]["orderCount"]) * 100); if (parseInt(data[0]["orderCount"]) == 0) { per = 0; } $("#_refundCountPer").text(per + "%"); }); } else { postAjax("get_date_area_total_data", "timetype=" + dateType, function (data) { var strData = data.data; var dataList = strData.split(","); $("#_afterCount").text(dataList[2]); $("#_afterAmount").text(dataList[3]); $("#_totalCount").text(dataList[0]); $("#_totalAmount").text(dataList[1]); $("#_refundCount").text(dataList[4]); $("#_refundAmount").text(dataList[5]); var per = Math.floor(parseInt(dataList[4]) / (parseInt(dataList[0])) * 100); if (parseInt(dataList[0]) == 0) { per = 0; } $("#_refundCountPer").text("率:" + per + "%"); }); } } function changeDateAreaFn() { curDateType = mini.get("cmbSearchDate").getValue(); if (postCode == "Designer" || postCode == "DesignerMr") { getDesignerDataList(curDateType); } else { getCustomerDataList(curDateType); } } function openItemTab(name, parms) { if (parent != null) parent.openItemTab(name, parms); } function openOrderTab(parms) { if (parent != null) parent.openItemTab("订单列表", parms); } function openMyOrderTab(name, parms) { if (parent != null) parent.openItemTab("我的订单", parms); } function clickToMyDesignList(state) { if (parent != null) parent.openItemTab("我的设计", state); } function clickToMyRefund(tType) { if (tType == 1) { var timetype = "time=" + curDateType; if (parent != null) parent.openItemTab("退款确认", timetype); } else { if (parent != null) parent.openItemTab("退款确认", ""); } }