<%@ page contentType="text/html; charset=utf-8"
         pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <meta name="renderer" content="webkit">
    <!-- 移动设备 viewport -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <jsp:include page="../../../common.jsp"/>
</head>
<body>
<div class="row animated fadeInRight" style="margin: 0;">
    <div class="wrapper wrapper-content mt5 right-content ml5 mr5">
        <div class="toolbar-panel bdd">
            <div class="toolbar-box">
                <div class="toolbar-head clearfix lgraybg pt5 pl10 bdbd">
                    <!-- 顶部按钮 -->
                    <div class="fl">
                        查询条件
                    </div>
                    <div class="tools fr">
                        <a href="javascript:void(0);" class="collapse dblock f14 dgray mr5">
                            <i class="fa-2x fa fa-angle-double-up"></i>
                        </a>
                    </div>
                </div>
            </div>
            <!--搜索条件 -->
            <div class="toolbar-body">
                <form class="layui-form" id="form1" action="" style="margin-top: 10px;">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">用户ID</label>
                            <div class="layui-input-block">
                                <input type="text" name="userId" id="userId" placeholder="请输入用户ID"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">订单号</label>
                            <div class="layui-input-block">
                                <input type="text" name="orderNo" id="orderNo" placeholder="请输入订单号"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">收货人</label>
                            <div class="layui-input-block">
                                <input type="text" name="receiver" id="receiver" placeholder="请输入收货人"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">收货人手机</label>
                            <div class="layui-input-block">
                                <input type="text" name="phone" id="phone" placeholder="请输入收货人手机"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">订单状态</label>
                            <div class="layui-input-block">
                                <select id="status" name="status">
                                    <option value="">请选择</option>
                                    <option value="00">待支付</option>
                                    <option value="01">已支付</option>
                                    <option value="02">已退款</option>
                                    <option value="03">退款审核中</option>
                                    <option value="04">已完成</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">支付方式</label>
                            <div class="layui-input-block">
                                <select id="payType" name="payType">
                                    <option value="">请选择</option>
                                    <option value="aliPay">支付宝</option>
                                    <option value="wechatPay">微信</option>
                                    <option value="bank">银联</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="mb50 mt10">
        <div class="whitebg pl10 pr10">
            <table class="layui-hide" id="mercOrderNewTab" lay-filter="mercOrderNewTab"></table>
        </div>
    </div>
</div>
<script type="text/html" id="leftBar">
    <a class="layui-btn layui-btn-sm" lay-event="search">
        <i class="layui-icon layui-icon-search"></i>查询
    </a>
</script>

<script type="text/html" id="toolBar">
    <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="detail">
        <i class="layui-icon layui-icon-list"></i>详情
    </a>
    <%--    <a class="layui-btn layui-btn-xs" lay-event="edit">--%>
    <%--        <i class="layui-icon layui-icon-edit"></i>编辑--%>
    <%--    </a>--%>
    <%--    <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">--%>
    <%--        <i class="layui-icon layui-icon-delete"></i>删除--%>
    <%--    </a>--%>
</script>

<script>
    layui.use(['table', 'layer'], function () {
        var table = layui.table;
        var layer = layui.layer;

        var tableIns = table.render({
            elem: '#mercOrderNewTab'
            , url: ctx + '/mercOrderNew/page'
            , id: 'mercOrderNew'
            , response: {
                statusName: 'code' //数据状态的字段名称，默认：code
                , countName: 'count' //数据总数的字段名称，默认：count
                , dataName: 'data' //默数据列表的字段名称，认：data
                , statusCode: 200
            }
            , parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.records //解析数据列表
                };
            }
            , toolbar: '#leftBar' //开启头部工具栏，并为其绑定左侧模板
            , defaultToolbar: ['filter']
            , defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                , layEvent: 'LAYTABLE_TIPS'
                , icon: 'layui-icon-tips'
            }]
            , title: '新版订单表'
            , cols: [[
                {type: 'checkbox', fixed: 'left', hidden: true}
                , {field: 'numbers', title: '序号', fixed: 'left', unresize: true, width: 80, type: 'numbers'}
                , {field: 'userId', title: '用户ID', width: 85}
                , {field: 'orderNo', title: '订单号'}
                , {
                    field: 'orderAmt', title: '订单金额', width: 90, templet: function (d) {
                        return d.orderAmt.toFixed(2);
                    }
                }
                , {
                    field: 'discountAmt', title: '优惠金额', width: 90, templet: function (d) {
                        return d.discountAmt.toFixed(2);
                    }
                }
                , {
                    field: 'postage', title: '邮费', width: 90, templet: function (d) {
                        return d.postage.toFixed(2);
                    }
                }
                , {
                    field: 'actualAmt', title: '实付金额', width: 90, templet: function (d) {
                        return d.actualAmt.toFixed(2);
                    }
                }
                , {field: 'receiver', title: '收货人', width: 100}
                , {field: 'phone', title: '收货人手机', width: 130}
                , {
                    field: 'payType', title: '支付方式', templet: function (d) {
                        return d.payType === "aliPay" ? "支付宝" : d.payType === "wechatPay" ? "微信" : "银联";
                    }
                }
                , {
                    field: 'status', title: '支付状态', templet: function (d) {
                        if (d.status == "00") {
                            return "待支付";
                        }
                        if (d.status == "01") {
                            return "<span style='color: green'>已支付</span>";
                        }
                        if (d.status == "02") {
                            return "<span style='color: red'>已退款</span>";
                        }
                        if (d.status == "03") {
                            return "<span style='color: #f36b22'>退款审核中</span>";
                        }
                        if (d.status == "04") {
                            return "<span style='color: blue'>已完成</span>";
                        }
                    }
                }
                , {
                    field: 'transDt',
                    title: '支付时间',
                    templet: "<div>{{layui.util.toDateString(d.transDt,'yyyy-MM-dd HH:mm')}}</div>"
                }
                , {
                    field: 'createTime',
                    title: '创建时间',
                    templet: "<div>{{layui.util.toDateString(d.createTime,'yyyy-MM-dd HH:mm')}}</div>"
                }
                , {fixed: 'right', title: '操作', width: 100, toolbar: '#toolBar'}
            ]]
            , request: {
                pageName: 'current' //页码的参数名称，默认：page
                , limitName: 'size' //每页数据量的参数名，默认：limit
            }
            , page: true
        });
        table.on('tool(mercOrderNewTab)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            if (layEvent === 'detail') { //详情
                let url = ctx + '/mercOrderDetail/index?orderNo=' + data.orderNo;
                let index = layer.open({
                    type: 2,
                    title: '订单详情',
                    shade: 0.5,
                    maxmin: true,
                    area: ['90%', '90%'],
                    content: url
                });
            }
        });
        //监听头工具栏事件
        table.on('toolbar(mercOrderNewTab)', function (obj) {
            switch (obj.event) {
                case 'search':
                    var params = serialize($('#form1'));
                    table.reload('mercOrderNew', {
                        where: params
                        , page: {
                            size: 10
                            , current: 1
                        }
                    });
                    break;
            }
        });
    });
</script>
</body>
</html>
