<!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 id="form-goods-add" class="form-horizontal">
        <h4 class="form-header h4">基本信息</h4>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">主订单已发布更新提示音：</label>
                    <div class="col-sm-8">
                        <input name="orderMasterHaveReleasedUrl" id="orderMasterHaveReleasedUrl" placeholder="主订单已发布更新提示音" class="form-control" type="text"
                               required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">主订单新订单更新提示音：</label>
                    <div class="col-sm-8">
                        <input name="orderMasterNewOrderUrl" id="orderMasterNewOrderUrl" placeholder="主订单新订单更新提示音" class="form-control" type="text"
                               required>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">子订单售后更新提示音：</label>
                    <div class="col-sm-8">
                        <input name="orderDetailsAfterUrl" id="orderDetailsAfterUrl" placeholder="子订单售后更新提示音" class="form-control" type="text"
                               required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">子订单售后纠纷更新提示音：</label>
                    <div class="col-sm-8">
                        <input name="orderDetailsAfterSalesDisputeUrl" id="orderDetailsAfterSalesDisputeUrl" placeholder="子订单售后纠纷更新提示音" class="form-control" type="text"
                               required>
                    </div>
                </div>
            </div>
        </div>
        <a class="btn btn-primary btn-rounded btn-sm" onclick="tijiao()">提交</a>
    </form>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>

<script>
    var prefix = ctx + "goods/goods";

    var id = "";
    var name = "";
    var sort = "";
    var describe = "";
    var type = "";
    var dataType = "";
    var configUnit = "";

    //请求接口加载页面输入框值
    function globalConfiginit(){
        $.ajax({
            type: "GET",
            dataType:"json",
            url: "/config/globalConfig/search/type/1001",
            data: { },
            success: function (data) {
                id = data.data.id;
                name = data.data.name;
                sort = data.data.sort;
                describe = data.data.describe;
                type = data.data.type;
                dataType = data.data.dataType;
                configUnit = data.data.configUnit;
                //alert(data.data.content);
                var response = JSON.parse(data.data.content);
                $('#orderMasterHaveReleasedUrl').val(response.orderMasterHaveReleasedUrl);
                $('#orderMasterNewOrderUrl').val(response.orderMasterNewOrderUrl);
                $('#orderDetailsAfterUrl').val(response.orderDetailsAfterUrl);
                $('#orderDetailsAfterSalesDisputeUrl').val(response.orderDetailsAfterSalesDisputeUrl);

            }
        })
    }

    //页面加载
    window.onload = function () {
        //请求接口加载页面输入框值
        globalConfiginit();
    }

    //提交按钮
    function tijiao(){
        $.ajax({
            type: "PUT",
            dataType:"json",
            contentType: 'application/json',
            url: "/config/globalConfig/update",
            data: JSON.stringify({
                id: id,
                name: name,
                content: JSON.stringify({
                    "orderMasterHaveReleasedUrl":$('#orderMasterHaveReleasedUrl').val(),
                    "orderMasterNewOrderUrl":$('#orderMasterNewOrderUrl').val(),
                    "orderDetailsAfterUrl":$('#orderDetailsAfterUrl').val(),
                    "orderDetailsAfterSalesDisputeUrl":$('#orderDetailsAfterSalesDisputeUrl').val()
                }),
                sort: sort,
                describe: describe,
                type: type,
                dataType: dataType,
                unit: configUnit
            }),
            success: function (data) {
                if(data.code == 0){
                    //请求接口加载页面输入框值
                    globalConfiginit();
                    alert("成功");
                }else {
                    alert("失败");
                }
            }
        })
    }



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