<!DOCTYPE html>
<html lang="zh">
<#include "/include/header.html">
<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <#include "/include/left.html">
        <!--End 左侧导航-->
        <!--头部信息-->
        <#include "/include/topbar.html">
        <!--End 头部信息-->
        <!--页面主要内容-->
        <main class="lyear-layout-content">

            <div class="container-fluid">

                <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="panel" style="margin-bottom: auto">
                                <div class="panel-heading">
                                    <h3 class="panel-title">
                                        组合条件筛选
                                    </h3>
                                </div>
                                <!--组合条件组件-->
                                <#include "/include/table/table-query.html">
                            </div>
                            <div class="card-toolbar clearfix" style="padding: 0px 24px 0px 24px">
                                <div class="toolbar-btn-action" id="toolBar">
                                    <#include "/include/table/table-batch.html">
                                </div>
                            </div>
                            <!--快速搜索框-->
                            <div class="card-body" style="padding: 10px 15px">
                                <div class="pull-right" id="id_search_column"
                                     style="position: absolute;right: 295px;margin-top: 10px;">
                                    <input id="search-field" name="search_field" type="hidden" value="">
                                    <button aria-expanded="false" aria-haspopup="true"
                                            class="btn btn-default dropdown-toggle" data-toggle="dropdown" id="search-btn"
                                            type="button">
                                        全部 <span class="caret"></span>
                                    </button>
                                    <ul class="dropdown-menu" style="min-width: auto">
                                        <li><a data-field="" href="javascript:void(0)" tabindex="-1">全部</a></li>
                                        <#list pageTemplate.tableSearch as search>
                                        <li><a data-field="${search.key!}" href="javascript:void(0)" tabindex="-1">${search.name}</a>
                                        </li>
                                    </#list>
                                    </ul>
                                </div>
                                <!--Bootstarp Table插入-->
                                <#include "/include/table/table-data.html">

                            </div>
                        </div>

                    </div>

                </div>
            </div>

        </main>
        <!--End 页面主要内容-->
    </div>
</div>
<#include "/include/footer.html">
<#include "/include/table/table-event.html">
<#include "/include/table/table-model.html">
<!--以下为业务流程处理-->
<!--催缴记录模态框-->
<div aria-labelledby="mySmallModalLabel" class="modal fade bs-example-modal-lg" id="id_third_info_model" role="dialog"
     tabindex="-1">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button aria-label="Close" class="close" data-dismiss="modal" type="button"><span
                        aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="myLargeModalLabel">催缴记录</h4>
            </div>
            <div class="modal-body" id="id_third_info_model_body"></div>
            <div class="modal-footer">
                <button class="btn btn-default" data-dismiss="modal" type="button">关闭</button>
                <!--<button type="button" class="btn btn-primary">点击保存</button>-->
            </div>
        </div>
    </div>
</div>
<!--催缴记录列表-->
<div class="panel-group" id="record_panel" style="display: none">
    <div class="panel panel-warning">
        <div class="panel-heading" role="tab">
            <h4 class="panel-title">
                <a class="panel-text">
                    短信通知：<strong> 2022-03-15 19:47:04</strong>
                </a>
            </h4>
        </div>
        <div class="panel-collapse collapse in" id="collapseOne">
            <div class="panel-body">
                【同城急送】您的订单：D12672022315976，快递员已取件完成，待支付差价：1.00元，请尽快完成支付(超时订单将被退回)，点击查看费用详情：https://su.tcjskd.com/1NYVnz
            </div>
        </div>
    </div>
</div>
<!--发送短信模态框-->
<div aria-labelledby="exampleModalLabel" class="modal fade" id="id_send_msg_model" role="dialog" tabindex="-1" >
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button aria-label="Close" class="close" data-dismiss="modal" type="button"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="exampleModalLabel">发送催缴短信</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="input-group">
                            <div class="input-group-btn">
                                <button  class="btn btn-default dropdown-toggle" data-toggle="dropdown" type="button">
                                    <span id="id_send_msg_title">发送给：</span>
                                    <span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu">
                                    <li>
                                        <a href="#" onclick="getPhone('下单人')">下单人</a>
                                    </li>
                                    <li>
                                        <a href="#" onclick="getPhone('寄件人')">寄件人</a>
                                    </li>
                                    <li>
                                        <a href="#" onclick="getPhone('收件人')">收件人</a>
                                    </li>
                                    <li class="divider"></li>
                                    <li>
                                        <a href="#" onclick="getPhone('自定义')">自定义</a>
                                    </li>
                                </ul>
                            </div><!-- /btn-group -->
                            <input id="id_send_msg_phone" placeholder="请填写接收号码..." class="form-control" type="text" onkeyup="this.value=this.value.replace(/\D/g,'')" maxlength="11" readonly>
                        </div><!-- /input-group -->
                    </div>
                </div>
                </br>
                <div class="row">
                    <div class="col-lg-12">
                        <div class="input-group">
                            <div class="input-group-btn">
                                <button class="btn btn-default dropdown-toggle" data-toggle="dropdown" type="button">
                                    <span id="id_send_msg_txt_title">模板：</span>
                                    <span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu">
                                    <li><a href="#" onclick="getMsgTmpl('催缴模板')" >催缴模板</a></li>
                                    <li><a href="#" onclick="getMsgTmpl('通知模板')" >通知模板</a></li>
                                    <li><a href="#" onclick="getMsgTmpl('链接模板')" >链接模板</a></li>
                                    <li class="divider"></li>
                                    <li><a href="#" onclick="getMsgTmpl('自定义')" >自定义</a></li>
                                </ul>
                            </div><!-- /btn-group -->
                            <input id="id_send_msg_text" class="form-control" type="text" placeholder="请填写短信内容....">
                        </div><!-- /input-group -->
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" data-dismiss="modal" type="button">关闭</button>
                <button class="btn btn-primary" type="button" onclick="sendMsg()">发送消息</button>
            </div>
        </div>
    </div>
</div>

<script>

    function getCallRecord() {
        let clm = getTableSelectOne();
        $("#id_third_info_model_body").empty();
        for (let row of clm.callRecord) {
            let panel = $("#record_panel").clone();
            panel.css('display', 'block');
            panel.find('.panel-body').text(row["催缴详情"]);
            panel.find('.panel-text').text(row["催缴时间"] + "：" + row["催缴方式"]);
            $("#id_third_info_model_body").append(panel);
        }
        console.log(toDateFriendly("2022-03-15 19:47:04"));
        $("#id_third_info_model").modal("show");
    }

    /**
     * 获取第三方配送信息
     */
    function showOrderRecord() {
        let clm = getTableSelectOne();
        runAjax("${ctx}/order/get/third/record", "GET", {orderId: clm.orderId}, function (res) {
            let txt = "";
            res.body.forEach(function (item, index) {
                txt += "<span style='color: #007aff'>" + item.changeTime + "</span>：" + item.changeStatus + "<br>";
            });
            $("#id_third_info_model_body").html(txt);
            $("#id_third_info_model").modal("show");
        });
    }

    /**
     * 获取是第三方推送结果
     */
    function showThirdResult() {
        let clm = getTableSelectOne();
        runAjax("${ctx}/order/get/third/result", "GET", {orderNum: clm.orderNum}, function (res) {
            let detail = res.body;
            $("#id_third_info_model_body").html(detail);
            $("#id_third_info_model").modal("show");
        });
    }

    /**
     * 发送短信预览
     */
    function sendMsgView() {
        $("#id_send_msg_text").val("");
        $("#id_send_msg_phone").val("");
        $("#id_send_msg_model").modal("show");
    }

    /**
     * 选择接收短信手机号
     * @param type
     */
    function getPhone(type){
        $("#id_send_msg_phone").attr("readonly","readonly");
        let clm = getTableSelectOne();
        let phone="";
        switch (type){
            case "下单人":
                document.getElementById("js_load").style.display = "inline";
                runAjax("${ctx}/customer/get/id","GET",{"id":clm.playerPhone},function (res){
                    $("#id_send_msg_phone").val(res.body.customerPhone);
                    $("#id_send_msg_title").text(type+'：');
                    document.getElementById("js_load").style.display = "none";
                });
                return;
            case "寄件人":
                phone= clm.senderMobile;break;
            case "收件人":
                phone= clm.receiveMobile;break;
            case "自定义":
                $("#id_send_msg_phone").removeAttr("readonly");break

        }
        $("#id_send_msg_phone").val(phone);
        $("#id_send_msg_title").text(type+'：');
    }

    /**
     * 选择短信模板
     * @param type
     */
    function getMsgTmpl(type){
        let clm = getTableSelectOne();
        let txt="";
        switch (type) {
            case '催缴模板':
                txt="【同城急送】您的订单："+clm.orderNum+"，有快递费差价需要补付，请及时到客户端处理！以免影响快递时效，避免快递拦截退回。点击查看："+clm.payUrl;break;
            case '通知模板':
                txt="【同城急送】您有订单："+clm.orderNum+",未完成补付，请及时到客户端处理！以免影响快递正常配送时效。点击查看详情"+clm.payUrl;break;
            case '链接模板':
                txt="【同城急送】订单号为:"+clm.orderNum+"的快递费差价补付链接："+clm.payUrl;break;
            case '自定义':
                txt='';
        }
        $("#id_send_msg_text").val(txt);
        $("#id_send_msg_txt_title").text(type+'：');
    }

    /**
     * 发送短信
     */
    function sendMsg(){
        let phone=$("#id_send_msg_phone").val();
        let text=$("#id_send_msg_text").val();
        if (phone.length<11){
            lightyear.notify("手机号码不正确，请重新输入！", 'danger');return;
        }
        if (text.length<1){
            lightyear.notify("请输入短信内容！", 'danger');return;
        }
        document.getElementById("js_load").style.display = "inline";
        runAjax("${ctx}/order/arrears/get/send/msg","GET",
            {
                "id":getTableSelectOne().id,
                "phone":phone,
                "text":text
            },
            function (res){
            document.getElementById("js_load").style.display = "none";
            lightyear.notify("发送成功", 'info');
            $("#id_send_msg_model").modal("hide");
        });
    }

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