<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('店铺列表')" />
    <style>
        .layui-layer-btn0 {
            padding: 0;
        }
        .paddings {
            padding: 0 !important;
        }
        #addClassify {
            display: none;
            width: 540px;
            padding: 20px;
        }
        #addClassify .selectClassify {
            display: flex;
            align-items: center;
        }
        #addClassify .selectClassify label {
            display: flex;
            margin-right: 20px;
            align-items: center;
        }
        #addClassify .selectClassify label input {
            margin: 0;
            margin-right: 2px;
        }
        .shadeCss,.layui-layer-shade {
            background-color: rgb(0, 0, 0, 0.5) !important;
        }
        .select-list ul {
            display: flex;
            justify-content: space-between;
        }
        .selectClassifyOne {
            display: flex;
            align-items: center;
            margin: 12px 0;
        }
        .selectClassifyOne span {
            width: 45px;
        }
        .tagStore .fixed-table-toolbar {
            display: flex;
        }
        .tagStore .fixed-table-toolbar .bs-bars {
            flex: 1;
        }
        .tagStore .fixed-table-toolbar .bs-bars .btn-group-sm {
            display: flex;
            justify-content: space-between;
        }
        .leftSearchBox {
            display: flex;
            align-items: center;
        }
        .leftSearchBox input, .leftSearchBox select {
            width: 200px;
            height: 34px;
            margin-right: 12px;
        }
        .ibox-content {
            border-style: none;
            padding: 0;
        }
        .kv-hidden {
            display: none !important;
        }
    </style>
</head>
<body class="tagStore">
    <div class="container-div">
        <div class="row">
            <div class="btn-group-sm" id="toolbar">
                <div>
                    <a class="btn btn-warning" id="button-open-11">
                        <i class="fa fa-download"></i> 导出Excel
                    </a>
                </div>
            </div>
            <div class="col-sm-12 search-collapse">
                <form id="role-form">
                    <div class="select-list">
                        <ul>
                           <input type="hidden" name="marketId" value="" id="marketId">
                            <li>
                                店铺名称：<input type="text" name="roleName"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer"/>
    <script th:inline="javascript">
        var dicCouponBusiType = [[${@dict.getType('zhengzai_coupon_busi_type')}]];
        var dicCouponBindType = [[${@dict.getType('zhengzai_coupon_bind_type')}]];
        var platformUrl = [[${platformUrl}]];
        var prefix = ctx + "candy/coupon/mgt";
        var prefix2 = ctx + "local";
        var viewMgtCouponFlag = [[${@permission.hasPermi('candy:coupon:mgt:detail')}]];
        var cancelMgtCouponFlag = [[${@permission.hasPermi('candy:coupon:mgt:cancel')}]];
        var couType = [[${couType}]];
        $(function () { // promiseMethods('', 'post', data);
            let name = 'id';
            let time = 'time';
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
            var reg2 = new RegExp("(^|&)"+ time +"=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            var r2 = window.location.search.substr(1).match(reg2);
            let times = unescape(r2[2])
            console.log(times)
            if (r) {
                $("#marketId").val(unescape(r[2]));
            }
            $.ajax({
                type: 'post',
                url: '/goblin/marketing/zhengzai/store/list',
                data: {marketId:unescape(r[2])},
                success: function (res) {
                    var options = {
                        createUrl: prefix2 + "/addNewActivity",
                        detailUrl: prefix2 + "/storeDetail?id={id}&time={times}&marketId={marketId}",
                        removeUrl: prefix + "/cancel/{id}",
                        updateUrl: prefix + "/edit/{id}",
                        // exportUrl: prefix + "/export",
                        onCheck: onCheck,
                        data: res.data,
                        // onLoadSuccess: onLoadSuccess,
                        showSearch: false,
                        showRefresh: true,
                        showColumns: false,
                        showToggle: false,
                        columns: [
                            {
                                checkbox: true
                            },
                            {
                                field: 'storeName', 
                                title: '店铺'
                            },
                            {
                                field: 'spuCount',
                                title: '活动商品数量'
                            },
                            {
                                title: '操作',
                                align: 'center',
                                formatter: function (value, row, index) {
                                    return `<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="goDetail('${row.storeName}','${row.storeId}', '${times}', '${unescape(r[2])}')">查看详情</a>`
                                }
                            }]
                    };
                    $.table.init(options); 
                }
            })
            
        });
        function onCheck (row, $element) {
            console.log(row, $element)
        }
        // function onLoadSuccess (data) {
        //     console.log(data, 123)
        //     data = data.data
        //     $.table.init();
        // }
        // function responseHandler (data) {
        //     console.log(data, 1223)
        //     data = data.data
        //     $.table.init();
        // }
        function goDetail(name, storeId, time, marketId) {
            console.log(name, storeId, time, marketId, '????')
            $.modal.openTab(name, prefix2 + "/storeDetail?storeId=" + storeId + '&time=' + time + '&marketId=' + marketId)
        }
        $("#button-open-11").click(function(){
            $("button[name=refresh]").click()
	    })
        layui.use('laydate', function(){
            var laydate = layui.laydate;
            //执行一个laydate实例
            laydate.render({
                elem: '#test1', //指定元素
                type: 'datetime'
            });
        });
    </script>
</body>
</html>