<!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="name"/>
                        </li>
                        <li>
                            <label>证件：</label>
                            <input type="text" name="idcardnum"/>
                        </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-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:xx: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('system:xx:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:xx:remove')}]];
    var prefix = ctx + "system/xx";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            detailUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "献血者信息",
            columns: [
                {
                    field: 'id',
                    title: '主键ID',
                    visible: false
                },
                {
                    field: 'cdBatch',
                    title: '批次号',
                    visible: false
                },
                {
                    field: 'cdOperation',
                    title: '标志位',
                    visible: false
                },
                {
                    field: 'cdSource',
                    title: '数据来源',
                    visible: false
                },
                {
                    field: 'name',
                    title: '姓名'
                },
                {
                    field: 'idcardnum',
                    title: '证件'
                },
                {
                    field: 'sexid',
                    title: '性别',
                    formatter: function (value, row, index) {
                        return sexTools(row);
                    }
                },
                {
                    field: 'birthday',
                    title: '出生日期',
                    visible: false
                },
                {
                    field: 'address',
                    title: '地址'
                },
                {
                    field: 'fmname',
                    title: '父母姓名',
                    visible: false
                },
                {
                    field: 'chname',
                    title: '子女姓名',
                    visible: false
                },
                {
                    field: 'donkind',
                    title: '献血类型',
                    formatter: function (value, row, index) {
                        return donkind(row);
                    }
                },
                {
                    field: 'doncode',
                    title: '献血码',
                    visible: false
                },
                {
                    field: 'volume',
                    title: '体积'
                },
                {
                    field: 'abo',
                    title: 'ABO血型',
                    visible: false
                },
                {
                    field: 'rhd',
                    title: 'RhD血型',
                    visible: false
                },
                {
                    field: 'collectdate',
                    title: '采血日期'
                },
                {
                    field: 'collectplace',
                    title: '采血地点'
                },
                {
                    field: 'organname',
                    title: '机构名称',
                    visible: false
                },
                {
                    field: 'organtel',
                    title: '机构电话',
                    visible: false
                },
                {
                    field: 'createTime',
                    title: '数据归集时间',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            var time = new Date(value);
                            var year = time.getFullYear();
                            var month = time.getMonth() + 1;
                            var date = time.getDate();
                            var hours = time.getHours();
                            if (hours == '') {
                                hours = "00"
                            }
                            var minute = time.getMinutes();
                            if (minute == '') {
                                minute = "00"
                            }
                            var second = time.getSeconds();
                            if (second == '') {
                                second = "00"
                            }
                            // return year + '-' + month + '-' + date + ' ' + hours + ":" + minute + ":" + second;
                            return year + '-' + month + '-' + date;
                        }
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-warning btn-xs  ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\''
                            + row.id + '\')"><i class="fa fa-search"></i>详细</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    /* 用户状态显示 */
    function sexTools(row) {
        if (row.status == 2) {
            return '女 ';
        } else {
            return '男 ';
        }
    }

    function donkind(row) {
        if (row.status == 0) {
            return '全血 ';
        } else {
            return '单采 ';
        }
    }

</script>
</body>
</html>