<!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"/>
    <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 th:value="${#strings.defaultString(entitie.enterName, '')}" class="form-control" type="text" name="enterName" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">证件类型</label>
            <div class="col-sm-10">
                <select required class="form-control" name="enterType" th:with="type=${@dict.getType('zhengzai_certificate_type')}">
                    <option value="">--请选择证件类型--</option>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"
                            th:field="*{entitie.enterType}">
                    </option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">证件号</label>
            <div class="col-sm-10">
                <input th:value="${#strings.defaultString(entitie.enterIdCode, '')}" class="form-control" type="text" name="enterIdCode" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">备注原因</label>
            <div class="col-sm-10">
                <textarea rows="3" name="remark" placeholder="" class="form-control" required></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">上传凭证</label>
            <div class="col-sm-10">
                <div class="file-loading">
                    <input id="fileinput-1" type="file" name="file" data-max-file-count="2" multiple>
                </div>
            </div>
        </div>
        <input hidden id="images" name="images">
        <input hidden id="orderTicketEntitiesId" name="orderTicketEntitiesId" th:value="${entitie.orderTicketEntitiesId}">
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-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/order";
    var platformUrl = "[[${platformUrl}]]";

    function submitHandler() {
        if ($.validate.form()) {
            var data = $('#form-post-add').serializeArray();
            var images = $('#images').val();
            if (!images) {
                layer.msg("请上传图片,请勿忘记点击上传按钮");
                return false;
            }
            $.operate.save(prefix + "/enterEdit", data);
        }
    }

    $(function () {
        let uploadedFilePaths = [];
        $("#fileinput-1").fileinput({
            'theme': 'explorer-fas',
            layoutTemplates: {
              actionUpload: '',
            },
            'uploadUrl': platformUrl + "/platform/basicServices/alOss/upload",
            "uploadExtraData": {
                "pathName" : "kylinOrderEnter",
                "buckType" : 1
            },
            showClose: false,
            browseOnZoneClick: false,
        }).on("fileuploaded", function (event, data, previewId, index) {
            // 将上传的文件路径添加到数组中
            uploadedFilePaths.push(data.response.data.ossPath);
            // 更新隐藏输入字段的值
            $("#images").val(uploadedFilePaths.join(','));
        });
    })
</script>
</body>
</html>