<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增商城')" />
    <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-mall-add">
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">商品名称：</label>
                <div class="col-sm-8">
                    <input name="goodsName" class="form-control" type="text" maxlength="15" required>
                </div>
            </div>
        </div>
<!--        <div class="col-xs-12">-->
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label is-required" >商品条码：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="goodsCode" class="form-control" type="text" required>-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label ">商品种类：</label>
                <div class="col-sm-8">
                    <select name="goodsType" class="form-control" th:with="type=${@dict.getType('goods_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
        </div>
<!--        <div class="col-xs-12">-->
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label is-required">计量单位：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="goodsUnit" class="form-control" type="text" required>-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">时价商品：</label>
                <div class="col-sm-8">
                    <select name="goodsCurrentPrice" class="form-control" th:with="type=${@dict.getType('sys_yes_no')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">销售单价：</label>
                <div class="col-sm-8">
                    <input name="salePrice" class="form-control" type="text" maxlength="15" required>
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">建议售价：</label>
                <div class="col-sm-8">
                    <input name="suggestionPrice" class="form-control" type="text" required maxlength="15">
                </div>
            </div>
        </div>
<!--        <div class="col-xs-12">-->
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label is-required">商品库存：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="goodsInventory" class="form-control" type="text" required>-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="col-xs-12">-->
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label is-required">库存成本：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="inventoryCost" class="form-control" type="text" required>-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">商品状态：</label>
                <div class="col-sm-8">
                    <select name="goodsState" class="form-control" th:with="type=${@dict.getType('sys_normal_disable')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">商品图片：</label>
                <div class="col-sm-8">
                    <input type="hidden" name="goodsImg">
                    <div class="file-loading">
                        <input class="form-control file-upload" id="goodsImg" name="file" type="file">
                    </div>
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">商品说明：</label>
                <div class="col-sm-8">
                    <textarea name="goodsDescribe" class="form-control" type="text" maxlength="200"></textarea>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-fileinput-js"/>
<script th:inline="javascript">
    var prefix = ctx + "system/mall"
    $("#form-mall-add").validate({
        focusCleanup: true,
        rules:{
            salePrice:{
                digits:true
            },
            suggestionPrice:{
                digits:true
            },
        },
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-mall-add').serialize());
        }
    }

    $(".file-upload").fileinput({
        uploadUrl: ctx + 'common/upload',
        maxFileCount: 1,
        autoReplace: true
    }).on('fileuploaded', function (event, data, previewId, index) {
        $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
    }).on('fileremoved', function (event, id, index) {
        $("input[name='" + event.currentTarget.id + "']").val('')
    })
</script>
</body>
</html>