<!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"/>
</head>

<body>

<div class="main-content">
    <form class="form-horizontal" id="form-deptGoodsCategory-edit" th:object="${deptGoodsCategory}">
        <input id="deptGoodsCategoryId" name="deptGoodsCategoryId" type="hidden" th:field="*{deptGoodsCategoryId}"/>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-6 control-label is-required">类目名称：</label>
                    <div class="col-sm-6">
                        <input name="goodsCategoryName" placeholder="请输入类目名称" class="form-control" type="text" maxlength="30"
                               th:field="*{goodsCategoryName}"
                               disabled>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-6 control-label is-required">一级分销扣点比例：</label>
                    <div class="col-sm-6">
                        <input name="oneRate" placeholder="请输入一级分销扣点比例" class="form-control" type="text" maxlength="12"
                               th:field="*{oneRate}"
                               required>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-6 control-label is-required">二级分销扣点比例：</label>
                    <div class="col-sm-6">
                        <input name="twoRate" placeholder="请输入二级分销扣点比例" class="form-control" type="text"
                               th:field="*{twoRate}"
                               maxlength="12" required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-6 control-label is-required">三级分销扣点比例：</label>
                    <div class="col-sm-6">
                        <input name="threeRate" placeholder="请输入三级分销扣点比例" class="form-control" type="text" maxlength="12"
                               th:field="*{threeRate}"
                               required>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-6 control-label is-required">平台扣点比例：</label>
                    <div class="col-sm-6">
                        <input name="deptRate" placeholder="请输入平台扣点比例" class="form-control" type="text"
                               th:field="*{deptRate}"
                               maxlength="12" required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-6 control-label is-required">平台固定扣金额：</label>
                    <div class="col-sm-6">
                        <input name="deptMoney" placeholder="请输入平台固定扣金额" class="form-control" type="text" maxlength="12"
                               th:field="*{deptMoney}"
                               required>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-6 control-label is-required">截留扣点：</label>
                    <div class="col-sm-6">
                        <input name="retainRate" placeholder="请输入截留扣点" class="form-control" type="text"
                               th:field="*{retainRate}"
                               maxlength="12" required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-6 control-label is-required">截留金额：</label>
                    <div class="col-sm-6">
                        <input name="retainMoney" placeholder="请输入截留金额" class="form-control" type="text" maxlength="12"
                               th:field="*{retainMoney}"
                               required>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-6 control-label is-required">显示排序：</label>
                    <div class="col-sm-6">
                        <input class="form-control" type="text" name="categorySort" th:field="*{categorySort}" required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-6 control-label">是否热门类目：</label>
                    <div class="col-sm-6">
                        <select name="isHot" class="form-control m-b" th:field="*{isHot}" th:with="type=${@dict.getType('sys_user_sex')}">
                            <option th:text="否" th:value="0"/>
                            <option th:text="是" th:value="1"/>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-6 control-label">热门名称：</label>
                    <div class="col-sm-6">
                        <input name="hotName" placeholder="请输入热门名称" class="form-control" type="text" maxlength="12"
                               th:field="*{hotName}">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-6 control-label">简称：</label>
                    <div class="col-sm-6">
                        <input name="simpleGoodsCategoryName" placeholder="请输入简称" class="form-control" type="text"
                               maxlength="12"
                               th:field="*{simpleGoodsCategoryName}">
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-6 control-label">是否需要证书：</label>
                    <div class="col-sm-6">
                        <select name="isCert" class="form-control m-b" th:field="*{isCert}"  th:with="type=${@dict.getType('sys_user_sex')}">
                            <option th:text="否" th:value="0"/>
                            <option th:text="是" th:value="1"/>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-6 control-label">是否需要保险：</label>
                    <div class="col-sm-6">
                        <select name="isSure" class="form-control m-b" th:field="*{isSure}"  th:with="type=${@dict.getType('sys_user_sex')}">
                            <option th:text="否" th:value="0"/>
                            <option th:text="是" th:value="1"/>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">热门类目图标：</label>
                <div class="col-sm-9">
                    <input type="text" name="cover" value="" hidden>
                    <input type="file" name="coverImg" id="coverImg" multiple class="file"/>
                </div>
            </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">热门类目图片：</label>
                <div class="col-sm-9">
                    <input type="text" name="categoryUrl" value="" hidden>
                    <input type="file" name="categoryUrlImg" id="categoryUrlImg" multiple class="file"/>
                </div>
            </div>
            </div>
        </div>
    </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 :: datetimepicker-js"/>

<script type="text/javascript">
    var prefix = ctx + "goods/deptcategory";

    $("#form-deptGoodsCategory-edit").validate({
        onkeyup: false,
        rules: {},
        messages: {},
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-deptGoodsCategory-edit").serializeArray();
            $.operate.saveTab(prefix + "/edit", data);
            $.modal.close();
        }
    }

    // 商品封面上传
    $('#categoryUrlImg').fileinput({
        language: 'zh',     //设置语言
        dropZoneEnabled: false,      //是否显示拖拽区域
        showPreview: false,
        uploadExtraData: {
            "name": "categoryUrlImg"
        },
        dropZoneTitle: "可以将图片拖放到这里",    //拖拽区域显示文字
        uploadUrl: ctx + 'tool/qiniu/dept/upload',  //上传路径
        allowedFileExtensions: ['jpg', 'png', 'gif', 'jpeg'],   //指定上传文件类型
        maxFileSize: 0,
        maxFileSize: 12048,   //上传文件最大值，单位kb
        uploadAsync: true,  //异步上传
        maxFileCount: 3    //上传文件最大个数。
    }).on("fileuploaded", function (event, data) { //异步上传成功后回调
        if (data.response.code === 0) {
            var imgUrl = $("input[name='categoryUrl']").val();
            if (imgUrl) {
                $("input[name='categoryUrl']").val(imgUrl + "," + data.response.url)
            } else {
                $("input[name='categoryUrl']").val(data.response.url)
            }
        } else {
            alert("上传失败!");
        }
    });

    // 商品封面上传
    $('#coverImg').fileinput({
        language: 'zh',     //设置语言
        dropZoneEnabled: false,      //是否显示拖拽区域
        showPreview: false,
        uploadExtraData: {
            "name": "coverImg"
        },
        dropZoneTitle: "可以将图片拖放到这里",    //拖拽区域显示文字
        uploadUrl: ctx + 'tool/qiniu/dept/upload',  //上传路径
        allowedFileExtensions: ['jpg', 'png', 'gif', 'jpeg'],   //指定上传文件类型
        maxFileSize: 0,
        maxFileSize: 12048,   //上传文件最大值，单位kb
        uploadAsync: true,  //异步上传
        maxFileCount: 1    //上传文件最大个数。
    }).on("fileuploaded", function (event, data) { //异步上传成功后回调
        if (data.response.code === 0) {
            var imgUrl = $("input[name='cover']").val();
            if (imgUrl) {
                $("input[name='cover']").val(imgUrl + "," + data.response.url)
            } else {
                $("input[name='cover']").val(data.response.url)
            }
        } else {
            alert("上传失败!");
        }
    });

</script>
</body>
</html>