<!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('机种切换管理列表')" />
</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="ProductId"/>-->
                                <select name="ProductId">
                                    <option value="">全部</option>
                                    <option th:each="ls:${list}" th:value="${ls.productID}" th:text="${ls.productName}"></option>
                                </select>
                            </li>
                            <li>
                                生产负责人：
                                <input type="text" name="PersonInCharge"/>
                            </li>
<!--                            <li class="select-time">-->
<!--                                <label>开始时间：</label>-->
<!--                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginBeginTime]"/>-->
<!--                                <span>-</span>-->
<!--                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endBeginTime]"/>-->
<!--                            </li>-->
                            <li>
                                <a class="btn btn-success btn-rounded btn-sm" onclick="$.operate.add()" shiro:hasPermission="nanjing:ProductChangeInfo: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="btn-group-sm" id="toolbar" role="group">-->
<!--                -->
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="nanjing:ProductChangeInfo:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="nanjing:ProductChangeInfo:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="nanjing:ProductChangeInfo:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                </a>-->
<!--            </div>-->
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('nanjing:ProductChangeInfo:edit')}]];
        var removeFlag = [[${@permission.hasPermi('nanjing:ProductChangeInfo:remove')}]];
        var startPlan = [[${@permission.hasPermi('nanjing:ProductChangeInfo:start')}]];
        var endPlan = [[${@permission.hasPermi('nanjing:ProductChangeInfo:end')}]];
        var prefix = ctx + "nanjing/ProductChangeInfo";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                // startUrl:prefix+"/start",
                // endUrl:prefix+"/end",
                modalName: "机种切换管理",
                columns: [
                //     {
                //     checkbox: true
                // },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'tBdProductinfo.productName',
                    title: '机种型号',

                },
                {
                    field: 'personInCharge',
                    title: '生产负责人'
                },
                {
                    field: 'beginTime',
                    title: '开始时间'
                },
                {
                    field: 'endTime',
                    title: '结束时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + startPlan + '" href="javascript:void(0)" onclick="startP(\'' + row.id + '\')"><i class="fa fa-edit"></i>开始</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + endPlan + '" href="javascript:void(0)" onclick="endP(\'' + row.id + '\')"><i class="fa fa-remove"></i>结束</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function startP(id){
            var formData = new FormData();
            formData.append("id",id);
            $.ajax({
                type: "post",
                url: prefix+"/start",
                data: formData,
                contentType: false,
                processData: false,
                dataType: "json",
                success: function (res) {
                    console.log(res)
                    if (res >0)
                        $.table.refresh();
                }
            })
        }
    </script>
</body>
</html>