<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改banner')"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: datetimepicker-css"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-post-add">
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">名称：</label>
            <div class="col-sm-10">
                <input class="form-control" type="text" name="name" id="name" required th:value="${ZhengzaiAppVersionsVo.name}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">版本号：</label>
            <div class="col-sm-10">
                <input class="form-control" type="text" name="version" id="version" required th:value="${ZhengzaiAppVersionsVo.version}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">最小版本号：</label>
            <div class="col-sm-10">
                <input class="form-control" type="text" name="minVersion" id="minVersion" required th:value="${ZhengzaiAppVersionsVo.minVersion}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">类型</label>
            <div class="col-sm-10">
                <div class="radio check-box">
                    <label>
                        <input th:checked="${ZhengzaiAppVersionsVo.type==1 ? true : false}" type="radio" value="1" name="type" checked=""> IOS
                    </label>
                </div>
                <div class="radio check-box">
                    <label>
                        <input th:checked="${ZhengzaiAppVersionsVo.type==2 ? true : false}" type="radio" value="2" name="type"> Android
                    </label>
                </div>
            </div>
        </div>
        <!--<div class="form-group">
            <label class="col-sm-2 control-label">是否生产环境</label>
            <div class="col-sm-10">
                <div class="radio check-box">
                    <label>
                        <input th:checked="${ZhengzaiAppVersionsVo.isProduction==1 ? true : false}" type="radio" value="1" name="isProduction" checked=""> 是
                    </label>
                </div>
                <div class="radio check-box">
                    <label>
                        <input th:checked="${ZhengzaiAppVersionsVo.isProduction==2 ? true : false}" type="radio" value="2" name="isProduction"> 否
                    </label>
                </div>
            </div>
        </div>-->
        <div class="form-group">
            <label class="col-sm-2 control-label">是否强制升级</label>
            <div class="col-sm-10">
                <div class="radio check-box">
                    <label>
                        <input th:checked="${ZhengzaiAppVersionsVo.isForce==1 ? true : false}" type="radio" value="1" name="isForce"> 是
                    </label>
                </div>
                <div class="radio check-box">
                    <label>
                        <input th:checked="${ZhengzaiAppVersionsVo.isForce==2 ? true : false}" type="radio" value="2" name="isForce" checked=""> 否
                    </label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-2 control-label">升级描述：</label>
            <div class="col-xs-10">
                <textarea name="content" maxlength="500" class="form-control" rows="3" th:text="${ZhengzaiAppVersionsVo.content}"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="font-noraml">Android请上传apk文件</label>
            <div class="file-loading">
                <input id="fileinput-demo-1" type="file" name="files" th:value="${ZhengzaiAppVersionsVo.filePath}" data-browse-on-zone-click="true"
                       data-msg-placeholder="Select {files} for upload...">
            </div>
        </div>
        <input hidden id="filePath" name="filePath" th:value="${ZhengzaiAppVersionsVo.filePath}">

    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<th:block th:include="include :: bootstrap-suggest-js"/>
<script type="text/javascript">
    var prefix = ctx + "kylin/zhengzaiAppVersion";
    var platformUrl = "[[${platformUrl}]]";

    var filePath = "[[${ZhengzaiAppVersionsVo.filePath}]]";
    var zhengzaiAppVersionsId = "[[${ZhengzaiAppVersionsVo.zhengzaiAppVersionsId}]]";

    function submitHandler() {
        if ($.validate.form()) {
            var data = $('#form-post-add').serializeArray();
            data.push({"name": "zhengzaiAppVersionsId", "value": zhengzaiAppVersionsId});

            $.operate.save(prefix + "/update", data);
        }
    }

    $(function () {
        $("#fileinput-demo-1").fileinput({
            'theme': 'explorer-fas',
            // 'uploadUrl': "http://127.0.0.1:9003" + "/platform/basicServices/alOss/upload",
            'uploadUrl': platformUrl + "/platform/basicServices/alOss/upload",
            // 'uploadUrl': ctx + "system/user/profile/updateAvatar",
            "uploadExtraData": {
                "pathName" : "zhengzaiAppVersion",
                "buckType" : 2
            },
            overwriteInitial: false,
            initialPreviewAsData: true,
            dropZoneTitle: "请上传文件",
            autoReplace: true,
            maxFileCount: 1,
            initialPreview: [
                "https://app.zhengzai.tv/" + filePath
            ],
            initialPreviewFileType: "apk",
            initialPreviewConfig:[{"caption":filePath,"downloadUrl":"https://app.zhengzai.tv/" + filePath,"size":"","key":0}]
        });
        $("#fileinput-demo-1").on("fileuploaded", function (event, data, previewId, index) {
            $("#filePath").val(data.response.ossPath)
        });
    })
</script>
</body>
</html>