<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('工位管理列表')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
<!--                            <li>-->
<!--                                <label>工位代码：</label>-->
<!--                                <input type="text" name="StationCode"/>-->
<!--                            </li>-->
                            <li>
                                <label>工位类型：</label>
                                <select name="StationType">
                                    <option value="">所有</option>
                                    <option th:each="st:${stationtype}" th:value="${st.ID}" th:text="${st.typeName}"></option>
                                </select>
                            </li>
                            <li>
                                <label>工位名称：</label>
                                <input type="text" name="StationName"/>
                            </li>
                            <li>
                                <label>线路名称：</label>
                                <select name="LineID">
                                    <option value="">所有</option>
                                    <option th:each="st:${linename}" th:value="${st.LineID}" th:text="${st.LineTypeName}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-success btn-rounded btn-sm" onclick="$.operate.add()" shiro:hasPermission="nanjing:SubStation:add"><i class="fa fa-plus"></i> 新增工位</a>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;查询全部</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('nanjing:SubStation:edit')}]];
        var removeFlag = [[${@permission.hasPermi('nanjing:SubStation:remove')}]];
        var paramFlag = [[${@permission.hasPermi('nanjing:SubStation:param')}]];
        var prefix = ctx + "nanjing/SubStation";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                editParamUrl:prefix+"/editParam/{id}",
                modalName: "工位管理",
                columns: [
                    {
                        field: 'orderID',
                        title: '排序id'
                    },
                {
                    field: 'stationCode',
                    title: '工位代码'
                },
                    {
                        field: 'stationName',
                        title: '工位名称'
                    },
                {
                    field: 'stationtype.typeName',
                    title: '工位类型'
                },
                {
                    field: 'paraCount',
                    title: '参数个数'
                },
                {
                    field: 'linetype.lineTypeName',
                    title: '线路名称'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>修改</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        actions.push('<a class="btn btn-info btn-xs ' + paramFlag + '" href="javascript:void(0)" onclick="jmpParam(\'' + row.id + '\')"><i class="fa fa-anchor"></i>参数设置</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function jmpParam(id) {
            var url = table.options.editParamUrl.replace("{id}", id);
            // console.log(url);
            $.modal.open("修改工位参数", url);
        }
    </script>
</body>
</html>