<!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 class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-SubStation-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">工位序号:</label>
                <div class="col-sm-8">
                    <input name="StationID" class="form-control" th:each="si:${si}" th:value="${si.StationID}" readonly="readonly">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">工位名称：</label>
                <div class="col-sm-8">
                    <input name="StationName" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">工位代码：</label>
                <div class="col-sm-8">
                    <input id="stationCode" name="StationCode" class="form-control" type="text" onchange="fillTableName()">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">工位类型：</label>
                <div class="col-sm-8">
                    <select name="StationType" class="form-control m-b">
                        <option th:each="st:${stationtype}" th:value="${st.ID}" th:text="${st.typeName}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">系统数据表：</label>
                <div class="col-sm-8">
                    <input id="tableName" name="TableName" class="form-control" readonly="readonly">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">参数个数：</label>
                <div class="col-sm-8">
                    <input name="paraCount" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">排序id：</label>
                <div class="col-sm-8">
                    <input name="OrderID" class="form-control" th:each="oi:${oi}" th:value="${oi.OrderID}" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">上下限是否显示：</label>
                <div class="col-sm-8">
                    <select name="LimitID" class="form-control m-b" th:with="type=${@dict.getType('limitshow')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">线路类型：</label>
                <div class="col-sm-8">
                    <select name="LineID" class="form-control">
                        <option th:each="st:${linename}" th:value="${st.LineID}" th:text="${st.LineTypeName}"></option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "nanjing/SubStation"
        $("#form-SubStation-add").validate({
            focusCleanup: true
        });

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

                $.ajax({
                    url: prefix + "/add",
                    type: "post",
                    dataType: "json",
                    data: $('#form-SubStation-add').serialize(),
                    beforeSend: function () {
                        $.modal.loading("正在处理中，请稍后...");
                        $.modal.disable();
                    },
                    success: function (result) {
                        // if (typeof callback == "function") {
                        //     callback(result);
                        // }
                        console.log(result.msg);
                        alert(result.msg);
                        $.operate.successCallback(result);
                    }
                });
            }
        }
        function fillTableName() {
            $('#tableName').val("T_RP_StationPara_"+$('#stationCode').val().toString().trim());
        }
    </script>
</body>
</html>