<!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="deviceName"/>
                        </li>
                        <li>
                            <label>资源编号：</label>
                            <input type="text" name="resource"/>
                        </li>
                        <li>
                            <label>物料品种：</label>
                            <select name="materialType" th:with="type=${@dict.getType('material_type')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>设备状态：</label>
                            <select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.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="$.operate.add()" shiro:hasPermission="traceability:deviceinfo:add">
                <i class="fa fa-plus"></i> 新增
            </a>
            <a class="btn btn-primary" onclick="$.operate.edit()" shiro:hasPermission="traceability:deviceinfo:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-info" id="expandAllBtn">
                <i class="fa fa-exchange"></i> 展开/折叠
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-tree-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var addFlag = [[${@permission.hasPermi('traceability:deviceinfo:add')}]];
    var editFlag = [[${@permission.hasPermi('traceability:deviceinfo:edit')}]];
    var removeFlag = [[${@permission.hasPermi('traceability:deviceinfo:remove')}]];
    var statusDatas = [[${@dict.getType('sys_normal_disable')}]];
    var delFlagDatas = [[${@dict.getType('sys_yes_no')}]];
    var materialTypeDatas = [[${@dict.getType('material_type')}]];
    var prefix = ctx + "traceability/deviceinfo";

    $(function () {
        var options = {
            code: "deviceId",
            parentCode: "parentId",
            expandColumn: "2",
            uniqueId: "deviceId",
            url: prefix + "/list",
            createUrl: prefix + "/add/{id}",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove/{id}",
            modalName: "设备信息",
            expandAll: false,
            expandFirst: true,
            columns: [{
                field: 'selectItem',
                radio: true
            },
                {
                    field: 'parentId',
                    title: '父级id',
                    align: 'left',
                    visible: false
                },
                {
                    field: 'deviceName',
                    title: '设备名称',
                    align: 'left'
                },
                {
                    field: 'orderNum',
                    title: '显示顺序',
                    align: 'left',
                    visible: false
                },
                {
                    field: 'resource',
                    title: '资源编号',
                    align: 'left'
                },
                {
                    field: 'materialType',
                    title: '物料品种',
                    align: 'left',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(materialTypeDatas, value);
                    }
                },
                {
                    field: 'status',
                    title: '设备状态',
                    align: 'left',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    align: 'left',
                    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.deviceId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-info  btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="$.operate.add(\'' + row.deviceId + '\')"><i class="fa fa-plus"></i>新增</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.deviceId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.treeTable.init(options);
    });
</script>
</body>
</html>