layui.use(['layer', 'form','laydate','util', 'table', 'admin', 'ax'], function () {
    var $ = layui.$;
    var layer = layui.layer;
    var form = layui.form;
    var laydate = layui.laydate;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;

    /**
     * 系统管理--消息管理
     */
    var MilitaryMedicalHis = {
        tableId: "militaryTable",    //表格id
        condition: {
            name: "",
            timeLimit: ""
        }
    };

    /**
     * 初始化表格的列
     */
    MilitaryMedicalHis.initColumn = function () {
        return [[
            // {type: 'checkbox'},
            {field: 'index_id', hide: true, sort: true, title: 'index_id'},
            {field: 'create_time', sort: true, title: '时间',width:200},
            {field: 'name', sort: true, title: '姓名'},
            {field: 'index_movement', sort: true, title: '运动指标'},
            {field: 'tong_reflect', sort: true, title: '瞳孔反射'},
            {field: 'tong_change', sort: true, title: '瞳孔变化'},
            {field: 'index_xz', sort: true, title: '血肿体积 '},
            {field: 'index_nzx', sort: true, title: '脑中线偏移距离'},
            {field: 'index_zwm', sort: true, title: '蛛网膜下腔出血'},
            {field: 'index_hckd', sort: true, title: '环池平均宽度'},
            {field: 'index_xt', sort: true, title: '血糖'},
            {field: 'index_nl', sort: true, title: '颅内压'},
            {field: 'index_dmy', sort: true, title: '动脉压脑灌'},
            {field: 'index_hx', sort: true, title: '呼吸'},
            {field: 'avgmy', sort: true, title: '平均动脉压'},
            {field: 'ngzy', sort: true, title: '脑灌注压'},
            {field: 'tw', sort: true, title: '体温'},
            {align: 'center', toolbar: '#tableBar', title: '心电图'},
            {field: 'sum_value', sort: true, title: '评分'}
        ]];
    };



    // 渲染表格
    var tableResult = table.render({
        elem: '#' + MilitaryMedicalHis.tableId,
        url: Feng.ctxPath + '/index/pageList?id='+Feng.getUrlParam("id"),
        page: true,
        height: "full-158",
        cellMinWidth: 100,
        cols: MilitaryMedicalHis.initColumn()
    });

    /**
     * 跳转心电图页面
     * @param data
     */
    MilitaryMedicalHis.openHistory = function(data){
        admin.putTempData('formOk', false);
        top.layui.admin.open({
            type: 2,
            title: '心电图',
            area: ['70%', '60%'],
            content: Feng.ctxPath + '/index/history_xd?indexId='+data.index_id,
            end: function () {
                admin.getTempData('formOk') && table.reload(MilitaryMedicalHis.tableId);
            }
        });
    };

    // 工具条点击事件
    table.on('tool(' + MilitaryMedicalHis.tableId + ')', function (obj) {
        var data = obj.data;
        var layEvent = obj.event;
        if (layEvent === 'xdHistory') {
            MilitaryMedicalHis.openHistory(data);
        }
    });

    // 导出病况数据excel
    $('#btn').click(function () {
        //location.href =  '/index/exportTechParse';
        var ajax = new $ax(Feng.ctxPath + "/index/exportTechParse?id="+Feng.getUrlParam("id"));
        var result = ajax.start();
        console.log(result.data);
        window.location.href = result.data
    });
});
