<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增活动')" />
    <th:block th:include="include :: select2-css" />
    <link rel="stylesheet" href="">
    <style>
        
        .required {
            font-style: normal;
            color: red;
        }
        .content_item {
            padding: 20px;
        }
        /* .content_item .content_title {
            display: flex;
        } */
        .content_item .content_title h3 span {
            display: inline-block;
            width: 4px;
            height: 18px;
            background: skyblue;
            margin-right: 6px;
            vertical-align: top;
        }
        .basis_data {
            display: flex;
            font-size: 14px;
            padding: 0 20px;
            margin-top: 20px;
            /* align-items: center; */
        }
        .basis_data span {
            width: 100px;
            text-align: right;
            
        }
        #startTime, #endTime {
            width: 272px;
            margin-right: 10px;
        }
        .storeList, #selectShow, .dropdown-menu, .input-group {
            width: 270px !important;
        }
        .activityStore_item {
            display: flex;
            margin-bottom: 12px;
        }
        #basis_data {
            align-items: flex-start;
        }
        .add_footer {
            width: 100%;
            height: 45px;
            line-height: 45px;
            padding-left: 60px;
        }
    </style>
</head>
<body>
<div>
    <div class="content_item">
        <div class="content_title">
            <h3><span></span>基础信息</h3>
        </div>
        <div class="basis_data">
            <span>
                <em class="required">*</em>
                选择演出：
            </span>
            <div class="input-group" style="width: 300px;">
                <input type="text" class="form-control" id="selectShow" placeholder="">
                <div class="input-group-btn">
                    <button type="button" class="btn btn-white dropdown-toggle" data-toggle="dropdown">
                        <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu dropdown-menu-right" role="menu">
                    </ul>
                </div>
                <!-- /btn-group -->
            </div>
        </div>
        <div class="basis_data">
            <span>
                <em class="required">*</em>
                有效期：
            </span>
            <input type="text" class="layui-input form-control" id="startTime" autocomplete="off" placeholder="请选择活动开始时间">
            ~  
            <input type="text" class="layui-input form-control" id="endTime"  style="margin-left: 10px;" autocomplete="off" placeholder="请选择活动结束时间">
        </div>
    </div>
    <div class="content_item">
        <div class="content_title">
            <h3><span></span>设置</h3>
        </div>
        <div class="basis_data" id="basis_data">
            <span>
                <em class="required">*</em>
                选择店铺：
            </span>
            <div class="activityStore">
                <div class="activityStore_item">
                    <div class="input-group" style="margin-right: 12px;">
                        <input type="text" class="form-control storeList item1" placeholder="搜索店铺名称">
                        <div class="input-group-btn">
                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                            </ul>
                        </div>
                        
                        <!-- /btn-group -->
                    </div>
                    <input type="text" class="layui-input form-control" id="startTime" autocomplete="off" placeholder="配置活动时间">
                    <button class="btn btn-primary" onclick="addItem()">新增</button>
                </div>
            </div>
        </div>
    </div>
    <div class="add_footer">
        <button class="btn btn-success" onclick="addItem()">保存</button>
        <button class="btn" onclick="addItem()">取消</button>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-suggest-js" />
<th:block th:include="include :: bootstrap-typeahead-js" />
<th:block th:include="include :: bootstrap-fileinput-js" />
</body>
<script th:inline="javascript">
    let count = 1;
    $(function() {
        layui.use('laydate', function(){
            var laydate = layui.laydate;
            //执行一个laydate实例
            laydate.render({
                elem: '#startTime', //指定元素
                type: 'datetime'
            });
            laydate.render({
                elem: '#endTime', //指定元素
                type: 'datetime'
            });
        });
        common ()
    })
    function common () {
        $("#selectShow").bsSuggest({
            allowNoKeyword: false, //是否允许无关键字时请求数据
            showBtn:false,
            multiWord: true, //以分隔符号分割的多关键字支持
            hideOnSelect: true,
            getDataMethod: "url", //获取数据的方式，总是从 URL 获取
            url: ctx+'kylin/base/performance/status?status=(3,6)&title=',
            /*如果从 url 获取数据，并且需要跨域，则该参数必须设置*/
            processData: function (json) { // url 获取数据时，对数据的处理，作为 getData 的回调函数
                //字符串转化为 js 对象
                return json;
            }
        });
        $(".storeList").bsSuggest({
            allowNoKeyword: false, //是否允许无关键字时请求数据
            showBtn:false,
            multiWord: true, //以分隔符号分割的多关键字支持
            hideOnSelect: true,
            getDataMethod: "url", //获取数据的方式，总是从 URL 获取
            url: ctx+'kylin/base/performance/status?status=(3,6)&title=',
            /*如果从 url 获取数据，并且需要跨域，则该参数必须设置*/
            processData: function (json) { // url 获取数据时，对数据的处理，作为 getData 的回调函数
                //字符串转化为 js 对象
                return json;
            }
        });
    }
    function addItem () {
        count++;
        let body = '';
        body+=`<div class="activityStore_item">
                <div class="input-group" style="margin-right: 12px;">
                    <input type="text" class="form-control storeList item${count}" placeholder="搜索店铺名称">
                    <div class="input-group-btn">
                        <ul class="dropdown-menu dropdown-menu-right" role="menu">
                        </ul>
                    </div>
                    
                    <!-- /btn-group -->
                </div>
                <input type="text" class="layui-input form-control startTime${count}" id="startTime" autocomplete="off" placeholder="配置活动时间">
            </div>`
        $(".activityStore").append(body)
        common ()
        layui.use('laydate', function(){
            var laydate = layui.laydate;
            //执行一个laydate实例
            laydate.render({
                elem: `.startTime${count}`, //指定元素
                type: 'datetime'
            });
        });
    }
</script>
</html>
