<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>后台管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="shortcut icon" th:href="@{/images/logo.jpg}"/>
    <link rel="stylesheet" th:href="@{/js/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{/js/layui/css/admin.css}">
    <script type="text/javascript" th:src="@{/js/jquery-3.3.1.min.js}"></script>
    <script th:src="@{/js/layui/layui.js}" charset="utf-8"></script>
    <style>
        img {
            width: 60px;
        }

    </style>
</head>
<body>
<div class="layui-form" style="padding: 20px 0 0 0;">
    <form id="formId" onsubmit="return false;">

        <div class="layui-form-item">
            <label class="layui-form-label">订单编号</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" th:value="${obj.orderId}" disabled>
            </div>
            <label class="layui-form-label">订单状态</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" th:value="${obj.orderStateName}" disabled>
            </div>
            <label class="layui-form-label">商品总数</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" th:value="${obj.goodsNum}" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">订单总额</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" th:value="${obj.totalAmount}" disabled>
            </div>

            <label class="layui-form-label">已付金额</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" th:value="${obj.payAmount}" disabled>
            </div>

            <label class="layui-form-label">快递编号</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" th:value="${obj.trackingNum}" disabled>
            </div>
        </div>

        <div class="layui-form-item" id="leaseShow">
            <label class="layui-form-label">租赁天数</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" th:value="${obj.leaseDay}" disabled>
            </div>

            <label class="layui-form-label">租赁开始</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" th:value="${obj.leaseStartDate}" disabled>
            </div>

            <label class="layui-form-label">租赁到期</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" th:value="${obj.leaseEndDate}" disabled>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">配送方式</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" th:value="${obj.deliveryName}" disabled>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">订单商品</label>
            <div class="layui-input-inline" style="width: 810px">
                <table class="layui-table" border="1">
                    <tr>
                        <th width="300px">商品名称</th>
                        <th width="120px">规格名称</th>
                        <th width="90px">图片</th>
                        <th width="100px">单价</th>
                        <th width="100px">商品数量</th>
                        <th width="100px">合计</th>
                    </tr>
                    <tr th:each="info,infoStat:${obj.orderDetailGoodsList}">
                        <td th:text="${info.goodsName}"></td>
                        <td th:text="${info.goodsSpecName}"></td>
                        <th><img th:src="${info.goodsImg}"></th>
                        <th th:text="${info.goodsPrice/info.goodsNum}"></th>
                        <th th:text="${info.goodsNum}"></th>
                        <th th:text="${info.goodsPrice}"></th>
                    </tr>
                </table>
            </div>
        </div>

        <div class="layui-form-item" id="receiver">
            <label class="layui-form-label">收货信息</label>
            <div class="layui-input-inline" style="width: 810px">
                <input type="text" class="layui-input"
                       th:value="${obj.receiverName+'    '+obj.receiverPhone+'    '+obj.province+obj.city+obj.county+obj.receiverAddress}"
                       disabled>
            </div>
        </div>

        <div class="layui-form-item" id="take">
            <label class="layui-form-label">取货地址</label>
            <div class="layui-input-inline" style="width: 810px">
                <input type="text" class="layui-input"
                       th:value="${obj.mapCoordinateName}"
                       disabled>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">订单备注</label>
            <div class="layui-input-inline" style="width: 810px">
                <input type="text" class="layui-input" th:value="${obj.orderRemarks}" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <!--            <label class="layui-form-label">是否首单</label>-->
            <!--            <div class="layui-input-inline">-->
            <!--                <input type="text" class="layui-input"  disabled>-->
            <!--            </div>-->
            <!--            <label class="layui-form-label">赠品</label>-->
            <!--            <div class="layui-input-inline">-->
            <!--                <input type="text" class="layui-input"  disabled>-->
            <!--            </div>-->
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">下单时间</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" th:value="${obj.createTime}" disabled>
            </div>
            <label class="layui-form-label">支付时间</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" th:value="${obj.payTime}" disabled>
            </div>
            <label class="layui-form-label">发货时间</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" th:value="${obj.deliverTime}" disabled>
            </div>
        </div>
        <!--        <div class="layui-form-item">-->
        <!--            <label class="layui-form-label">物流明细</label>-->
        <!--            <div class="layui-input-inline" style="width: 810px">-->
        <!--                <table class="layui-table" border="1">-->
        <!--                    <tr>-->
        <!--                        <th width="180px">操作时间</th>-->
        <!--                        <th width="100px">订单状态</th>-->
        <!--                        <th width="200px">操作网点</th>-->
        <!--                        <th width="100px">操作城市</th>-->
        <!--                        <th width="230px">轨迹描述</th>-->
        <!--                    </tr>-->
        <!--                    <tr th:each="info,infoStat:${obj.traceList}">-->
        <!--                        <th th:text="${info.time}"></th>-->
        <!--                        <th th:text="${info.status}"></th>-->
        <!--                        <th th:text="${info.site}"></th>-->
        <!--                        <td th:text="${info.city}"></td>-->
        <!--                        <td th:text="${info.description}"></td>-->
        <!--                    </tr>-->
        <!--                </table>-->
        <!--            </div>-->
        <!--        </div>-->
        <button class="layui-btn" style="display: none;" id="saveBtn" onclick="save()"></button>
    </form>
</div>
<script>

    layui.use('form', function () {
        var form = layui.form;
        form.render();
    });


    $(function () {
        var islease = '[[${obj.isLease}]]'
        var deliveryId = '[[${obj.deliveryId}]]'
        if (islease == 0) {
            $("#leaseShow").hide();
        }
        if (deliveryId == 7) {
            $("#receiver").hide();
        } else {
            $("#take").hide();
        }
    })


    var b = true;

    function save() {
        if (!b) {
            return false;
        }
        b = false;
        var form = document.querySelector("#formId");
        var formdata = new FormData(form);
        formdata.append("orderId", '[[${obj.orderId}]]');
        $.ajax({
            url: "tracking",
            data: formdata,
            type: "POST",
            dataType: "json",
            processData: false,
            contentType: false,
            success: function (result) {
                b = true;
                if (result.code == 10001) {
                    layer.msg(result.msg, {icon: 6, time: 1000}, function () {
                        closeLayer();
                        parent.layui.table.reload('tableId');
                    });
                } else {
                    layer.msg(result.msg, {icon: 5});
                }
            }
        });
    }

    function closeLayer() {
        var index = parent.layer.getFrameIndex(window.name);
        //关闭当前frame
        parent.layer.close(index);
    }

</script>
</body>

</html>