<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('编辑商品价格')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-prodAttrPrice-edit" th:object="${prodAttrPriceVo}">
            <input id="prodId" name="prodId" th:value="*{prodId}" type="hidden">
            <input id="prodAttrId" name="prodAttrId" th:value="*{prodAttrId}" type="hidden">
            <input id="prodAttrPriceId" name="prodAttrPriceId" th:value="*{prodAttrPriceId}" type="hidden">
            <div class="col-xs-12">
                <div class="form-group">
                    <div class="select-list col-sm-12">
                        <input name="buyerId" type="hidden" th:field="*{buyerId}">
                        <input name="buyerRoleKey" type="hidden" th:field="*{buyerRoleKey}">
                        <ul>
                            <li>
                                <label>采购方：</label>
                                <input name="buyerName" class="form-control col-sm-1" type="text" th:field="*{buyerName}" readonly>
                            </li>
                            <li>
                                <label>角色：</label>
                                <input name="buyerRoleName" class="form-control col-sm-1" type="text" th:field="*{buyerRoleName}" readonly>
                            </li>
                        </ul>
                    </div>
                    <div class="select-list col-sm-12">
                        <input name="sellerId" type="hidden" th:field="*{sellerId}">
                        <input name="sellerRoleKey" type="hidden" th:field="*{sellerRoleKey}">
                        <ul>
                            <li>
                                <label>销售方：</label>
                                <input name="sellerName" class="form-control col-sm-1" type="text" th:field="*{sellerName}" readonly>
                            </li>
                            <li>
                                <label>角色：</label>
                                <input name="sellerRoleName" class="form-control col-sm-1" type="text" th:field="*{sellerRoleName}" readonly>
                            </li>
                        </ul>
                    </div>
                    <div class="select-list col-sm-12">
                        <ul>
                            <li>
                                <label>单价：</label>
                                <input name="price" class="form-control col-sm-1" type="text" th:field="*{price}">
                            </li>
                            <li>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "master/product/prodAttrPrice";

        $("#form-prodAttrPrice-edit").validate({
            rules: {
                buyerName: {
                    required: true
                },
                sellerName: {
                    required: true
                },
                price: {
                    required: true
                }
            },
            messages: {
                buyerName: icon + "请选择购买方",
                sellerName: icon + "请选择销售方",
                price: icon + "请输入单价"
            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var data = {
                    "prodAttrPriceId" : $("#prodAttrPriceId").val(),
                    "prodId" : $("#prodId").val(),
                    "prodAttrId" : $("#prodAttrId").val(),
                    "buyerId" : $("input[name='buyerId']").val(),
                    "buyerName" : $("input[name='buyerName']").val(),
                    "buyerRoleKey" : $("input[name='buyerRoleKey']").val(),
                    "buyerRoleName" : $("input[name='buyerRoleName']").val(),
                    "sellerId" : $("input[name='sellerId']").val(),
                    "sellerName" : $("input[name='sellerName']").val(),
                    "sellerRoleKey" : $("input[name='sellerRoleKey']").val(),
                    "sellerRoleName" : $("input[name='sellerRoleName']").val(),
                    "price" : $("input[name='price']").val(),
                }
                $.ajax({
                    url: prefix + "/edit",
                    contentType: 'application/json',
                    data: JSON.stringify(data),
                    type: "post",
                    processData: false,
                    success: function(result) {
                        $.operate.successCallback(result);
                    }
                });
            }
        }
    </script>
</body>
</html>
