<!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('创建活动')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
    <style>
        .create_activity_box {
            padding: 20px;
        }
        .items {
            /* border: 1px dashed #ccc; */
            border-radius: 10px;
            padding: 12px;
            margin-bottom: 10px;
        }
        label {
            width: 80px;
            text-align: right;
        }
        input {
            width: 200px;
            height: 30px;
        }
        .footer_btn {
            margin-top: 20px;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        select {
            height: 30px;
            width: 200px;
        }
    </style>
</head>
<body>
    <div class="create_activity_box">
        <div class="items">
            <label><span style="color: red;">*</span> 活动名称：</label>
            <input type="text" id="activityName" />
        </div>
        <!-- <div class="items">
            关联演出：
            <select name="tagType">
                <option value="">全部</option>
                <option>1</option>
                <option>1</option>
                <option>1</option>
                <option>1</option>
            </select>
        </div> -->
        <div class="items">
            <label><span style="color: red;">*</span> 券数量：</label>
            <input type="text" id="ticketNum" />
        </div>
        <div class="footer_btn">
            <button type="button" class="btn btn-success" onclick="save()">保存</button>
        </div>
    </div>
    <th:block th:include="include :: footer"/>
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <th:block th:include="include :: bootstrap-suggest-js" />
    <script th:inline="javascript">
        var prefix2 = ctx + "local";
        var platformUrl = [[${platformUrl}]];
        let count = 0;
        let compilationsId = '';
        let createTime = '';
        let cubeId = '';
        let mid = '';
        let updateTime = '';
        
        function save () {
            let activityName = $("#activityName").val();
            let ticketNum = $("#ticketNum").val();
            if (!activityName || !ticketNum) {
                layer.msg('请将表单填写完整！')
            }
            let data = {
                "activeId": "",
                "activeName": activityName,
                "delTag": 0,
                "mid": 0,
                "number": ticketNum,
                "performanceId": ""
            }
            
            promiseMethods('/kylin-acitve/add', 'post', JSON.stringify(data), 'application/json').then((res) => {
                layer.msg("保存成功！")
                $("#activityName").val('')
                $("#ticketNum").val('')
                $.operate.successCallback(res);
            })
        }
        function promiseMethods(url,type,data,contentType) {
            return new Promise((resolve,reject)=>{
                $.ajax({
                    url,
                    type,
                    data,
                    contentType,
                    success:function(res) {
                        resolve(res);
                    }
                })
            })
        }
    </script>
</body>
</html>
