<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增任务')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-task-add">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">任务id：</label>
            <div class="col-sm-8">
                <input name="taskId" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">短剧：</label>
            <div class="col-sm-8">
                <select id="itemId" name="itemId" class="form-control m-b" required>
                    <option th:each="playletItem:${playletItems}" th:value="${playletItem.id}" th:text="${playletItem.videoName}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">平台：</label>
            <div class="col-sm-8">
                <label th:each="sourceType:${sourceTypes}" class="check-box">
                    <input name="sourceType" type="checkbox" th:value="${sourceType.dictValue}" th:text="${sourceType.dictLabel}">
                </label>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">任务名称：</label>
            <div class="col-sm-8">
                <input name="name" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">任务开始时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <input name="startTime" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">任务结束时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <input name="endTime" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">参与人数：</label>
            <div class="col-sm-8">
                <textarea name="peopleNumber" class="form-control" required></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">提成比例：</label>
            <div class="col-sm-8">
                <textarea name="commissionRate" class="form-control" required></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">任务链接：</label>
            <div class="col-sm-8">
                <textarea name="taskUrl" class="form-control" required></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">任务网盘链接：</label>
            <div class="col-sm-8">
                <textarea name="taskDiskUrl" class="form-control" required></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">基础佣金：</label>
            <div class="col-sm-8">
                <textarea name="baseBonus" class="form-control" required></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">总佣金：</label>
            <div class="col-sm-8">
                <input name="totalBonus" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">任务介绍：</label>
            <div class="col-sm-8">
                <input name="taskContent" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <input name="remark" class="form-control" type="text">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
    var prefix = ctx + "system/playlet/task"
    $("#form-task-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-task-add").serializeArray();
            var sourceTypeIds = $.form.selectCheckeds("sourceType");
            data.push({"name": "sourceTypeIds", "value": sourceTypeIds});
            $.operate.save(prefix + "/add", data);
        }
    }

    $("input[name='startTime']").datetimepicker({
        format: 'yyyy-mm-dd hh:ii',
        todayBtn:  true,
        dateFormat: 'yyyy-mm-dd',//日期显示格式
        timeFormat: 'HH:mm:ss',//时间显示格式
        autoclose: true,
    });

    $("input[name='endTime']").datetimepicker({
        format: 'yyyy-mm-dd hh:ii',
        todayBtn:  true,
        dateFormat: 'yyyy-mm-dd',//日期显示格式
        timeFormat: 'HH:mm:ss',//时间显示格式
        autoclose: true,
    });

    laydate.render({
        elem: '#startTime',
        type: 'datetime',
        trigger: 'click'
    });
</script>
</body>
</html>