<!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>生效条件ID：</label>
<!--                                <input type="text" name="conditionId"/>-->
                                <select name="conditionId">
                                    <option th:each="cond:${condList}" th:selected="${condId == cond.id}" th:value="${cond.id}" th:text="${cond.id}"></option>
                                </select>
                            </li>
<!--                            <li>-->
<!--                                <label>目标类型：</label>-->
<!--                                <select name="targetType">-->
<!--                                    <option value="">所有</option>-->
<!--                                    <option value="-1">代码生成请选择字典属性</option>-->
<!--                                </select>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>灯光亮度：</label>-->
<!--                                <input type="text" name="lightingNum"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>空调温度：</label>-->
<!--                                <input type="text" name="ktwd"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>空调风速：</label>-->
<!--                                <input type="text" name="ktfs"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>动效走势：</label>-->
<!--                                <input type="text" name="dxzs"/>-->
<!--                            </li>-->
                            <li>
                                <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-success" onclick="addStrategyCondition()" shiro:hasPermission="zhny:strategytarget:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="zhny:strategytarget:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="zhny:strategytarget:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="zhny:strategytarget: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('zhny:strategytarget:edit')}]];
        var removeFlag = [[${@permission.hasPermi('zhny:strategytarget:remove')}]];
        var prefix = ctx + "zhny/strategytarget";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "目标",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                {
                    field: 'conditionId',
                    title: '生效条件ID'
                },
                {
                    field: 'targetType',
                    title: '目标类型',
                    formatter:function (value){
                        if (value == 1) {
                            return'灯光';
                        }else if (value == 2) {
                            return '空调'
                        }else {
                            return '灯光走势'
                        }
                    }
                },
                {
                    field: 'lightingNum',
                    title: '灯光亮度'
                },
                {
                    field: 'ktwd',
                    title: '空调温度'
                },
                {
                    field: 'ktfs',
                    title: '空调风速'
                },
                {
                    field: 'dxzs',
                    title: '动向走势',
                    formatter:function(value,row){

                        if (value === 1){return '日上网';}
                        else if (value === 2){return '日购电';}
                        else if (value === 3){return '放电量';}
                        else if (value === 4){return '日充电';}
                        else if (value === 5){return '日自用';}
                    }
                }]
            };
            $.table.init(options);
        });

        function addStrategyCondition(){
            let condId = [[${condId}]]
            var url = prefix+'/add/'+condId;
            $.modal.open("新增目标", url, 800, 600);
        }
    </script>
</body>
</html>