text: "use strict";function _defineProperty(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}layui.use(["element","table","layer","util","form","laydate"],function(){var e,t=layui.element,n=layui.table,l=layui.layer,a=layui.util,i=layui.form,r=layui.laydate,d={netErrMsg:"系统已退出登录，请登录系统重试",operatorErrMsg:{single:"请选择一条数据操作",batch:"请至少选择一条数据操作"},plants:["TB","JD","PDD","PDDDZ"],tabIndex:0,kbType:location.hash.split("?")[1]&&location.hash.split("?")[1].split("=")[1]||"TB"};function s(e){var t=f();return t.createdDateStart=t.createdDate.split("~")[0],t.createdDateEnd=t.createdDate.split("~")[1],b($.extend(t,{plant:d.plants[d.tabIndex],page:{curr:1,limit:10}})),!1}function o(e){return $(".flyer-layout-tree .flyer-layout-link[data-hash=kb_purchase]").click(),!1}function c(){var e=document.createElement("a");return e.href="/api/exportKbOrderToExcel?limit=1000&offset=1&status=1&plant="+d.plants[d.tabIndex],e.click(),!1}function u(e){var t=document.createElement("a"),a=f();return a.plant=d.plants[d.tabIndex],a.kbCompany?(t.href="/api/downloadKbOrderToExcel?limit=1000&offset=1&"+core.objectToString(a),t.click(),setTimeout(function(){b()},2e3)):l.msg("请选择导出的快递公司"),!1}function p(e){var t=document.createElement("a"),a=$("input[name=userName]").length&&$("input[name=userName]").val();return t.href=a?"/api/pddBatch?limit=1000&offset=1&plant=PDD&status=1&userName="+a:"/api/pddBatch?limit=1000&offset=1&plant=PDD&status=1",t.click(),!1}function m(e){var a=n.checkStatus("kbOrderTable").data,r=e.data.type,t=2===r?"确定标记为已扫描状态吗？":1===r?"确定标记为未扫描状态吗？":"确定标记为取消状态吗？";return 3===r&&1!==a.length?l.msg(d.operatorErrMsg.single):3===r&&2===a[0].status?l.msg("已扫描的订单不能取消！！！"):3===r&&3===a[0].status?l.msg("该订单已经是取消状态了！！！"):0<a.length?l.confirm(t,{title:"询问框",btn:["确定","取消"]},function(e,t){$.ajax({url:"/api/toggleKbOrder",type:"POST",data:{id:a.map(function(e){return e.id}),status:r,count:a[0].price,number:a[0].number,userId:a[0].userId,userName:a[0].userName},success:function(e,t,a){l.msg("操作成功"),b()},error:function(e,t,a){l.msg(d.netErrMsg)}})}):l.msg(d.operatorErrMsg.batch),!1}function f(){var e=$("#kbOrderSearchForm").serializeArray(),a={};return $.each(e,function(e,t){a[t.name]=t.value}),a.createdDateStart=a.createdDate.split("~")[0],a.createdDateEnd=a.createdDate.split("~")[1],a}function b(e){n.reload("kbOrderTable",{where:e})}function y(e){$.get("/api/readKbType?status=1&plant="+e,function(e){var t,a;t=e.data.rows,(a=$("select[name=kbCompany]")).empty(),a.append('<option value="">请选择快递类型</option>'),$.each(t,function(e,t){a.append('<option value="'+t.code+'" data-price="'+t.price+'" data-plant="'+t.plant+'">'+t.name+"</option>")}),i.render("select")},"json")}t.tabChange("manageKbOrder",d.kbType),y(d.kbType),i.render("select"),r.render({elem:"#createdDate",range:"~"}),core.getUserInfoById(function(e){e.data.rows[0].isSuper||$(".js-super").remove()}),n.render((_defineProperty(e={elem:"#kbOrderTable",url:"/api/readKbOrderPage",page:!0,where:{plant:d.kbType},cols:[[{checkbox:!0,fixed:"left"},{field:"",title:"序号",fixed:"left",templet:function(e){return e.LAY_INDEX}},{field:"userName",title:"下单用户",width:150},{field:"number",title:"订单号",width:220},{field:"kbNumber",title:"快递单号",width:220},{field:"kbCompany",title:"快递公司/平台",width:150,templet:function(e){return core.getKbTypeByCode(e.kbCompany)+"/"+core.getPlantByCode(e.plant)}},{field:"addressFrom",title:"发件人信息",width:300},{field:"addressTo",title:"收件人信息",width:300},{field:"remark",title:"备注",width:150},{field:"createdDate",title:"创建时间",width:200,templet:function(e){return a.toDateString(e.createdDate,"yyyy-MM-dd HH:mm")}},{field:"status",title:"状态",width:200,fixed:"right",align:"center",templet:function(e){return'<span class="layui-text-'+(1==e.status?"green":"pink")+'">'+["","待扫描","已扫描","已取消"][e.status]+"</span> "+(1===e.status?'<a class="layui-btn layui-btn-normal layui-btn-xs js-update-order" data-id="'+e.id+'" data-kb-weight="'+e.kbWeight+'" data-kb-from="'+e.addressFrom+'" data-kb-to="'+e.addressTo+'">修改</a>':"")}}]],limits:[10,20,50,100]},"page",{theme:"#1E9FFF",layout:["prev","page","next","skip","count","limit"]}),_defineProperty(e,"request",{pageName:"offset"}),_defineProperty(e,"response",{statusCode:!0}),_defineProperty(e,"parseData",function(e){return{code:e.success,msg:e.msg,count:e.data.total,data:e.data.rows}}),_defineProperty(e,"done",function(){$(".js-update-order").off("click").on("click",function(e){var t=$(this).data("kb-weight"),a=$(this).data("kb-from"),r=$(this).data("kb-to"),s=$(this).data("id");return l.open({content:'<form class="layui-form" name="kbOrderUpdateForm" lay-filter="kbOrderUpdateForm">\n                                    <div class="layui-form-item">\n                                        <label class="layui-form-label">发货地址</label>\n                                        <div class="layui-input-block">\n                                            <select name="addressFrom">\n                                                <option value="">请选择发货地址</option>\n                                            </select>\n                                        </div>\n                                    </div>\n                                    <div class="layui-form-item">\n                                        <label class="layui-form-label">重量(千克)</label>\n                                        <div class="layui-input-block">\n                                            <input type="text" name="kbWeight" id="kbWeight" value="'+t+'" placeholder="单位：千克" class="layui-input">\n                                        </div>\n                                    </div>\n                                    <div class="layui-form-item">\n                                        <label class="layui-form-label">收货地址</label>\n                                        <div class="layui-input-block">\n                                            <input class="layui-input" name="addressTo" value="'+r+'" placeholder="" />\n                                        </div>\n                                    </div>\n                                </form>',area:["700px","500px"],title:"空包订单信息修改",btn:["保存","取消"],yes:function(r){var e,t,a,n=core.getFormValues($("form[name=kbOrderUpdateForm]")),i=(e=n)?e.addressFrom?e.addressTo?e.kbWeight?{isPass:!0,msg:""}:{isPass:!1,msg:"请输入包裹重量"}:{isPass:!1,msg:"请输入收货地址"}:{isPass:!1,msg:"请选择发货地址"}:{isPass:!1,msg:"参数错误"};i.isPass?(n.id=s,n.addressFromPca=n.addressFrom.split(/\s/g)[0],n.addressToPca=(t=n.addressTo.split(/,|，/)[2],(a=t.split(" "))[0]+"-"+a[1]+"-"+a[2]),$.ajax({url:"/api/updateKbOrder",type:"POST",data:n,success:function(e,t,a){l.msg(e.success?"操作成功":"操作失败"+e.message),l.close(r),b()},error:function(e,t,a){l.msg(d.errorMsg)}})):l.msg(i.msg)},success:function(){var r;r=function(){i.val("kbOrderUpdateForm",{addressFrom:a})},$.get("/api/readKbAddress?status=1",function(e){var t,a;t=e.data.rows,(a=$("select[name=addressFrom]")).empty(),a.append(' <option value="">请选择发货地址</option>'),$.each(t,function(e,t){a.append('<option value="'+t.pca+" "+t.detail+'">'+t.pca+" "+t.detail+" "+t.contact+" "+t.phone+" "+t.email+"</option>")}),i.render("select"),r&&r()},"json")}}),!1})}),e)),t.on("tab(manageKbOrder)",function(e){e.index!==d.tabIndex&&(b({plant:d.plants[e.index]}),d.tabIndex=e.index,$("#pddBatchBtn").toggleClass("layui-hide",2!==e.index),y(d.plants[e.index]))}),$("#searchBtn").on("click",s),$("#resetBtn").on("click",function(){return $("#kbOrderSearchForm")[0].reset(),!1}),$("#createKbOrderBtn").on("click",o),$("#exportKbOrderBtn").on("click",c),$("#downloadKbOrderBtn").on("click",u),$("#pddBatchBtn").on("click",p),$("#cancelKbOrderBtn").on("click",{type:3},m),$("#markScanedKbOrderBtn").on("click",{type:2},m),$("#markUnScanedKbOrderBtn").on("click",{type:1},m)});