project_summary.js 19.2 KB





define(['jquery', 'bootstrap', 'backend', 'form', 'table','echarts', 'echarts-theme'], function ($, undefined, Backend, Form, Table, Echarts) {
    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: '/school/project_summary/index' + location.search,
                    import_url: "/school/project_summary/export",
                    del_url: '/school/project_summary/del',
                }
            });
            var table = $("#table");

            var projectLevelMap = {
                '0': '未评级',
                '1': '院级',
                '2': '校级',
                '3': '省级',
                '4': '国家级'
            }

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                // sortName: 'weigh',
                search: false,
                searchFormVisible: true,
                searchFormTemplate: 'search_tpl',
                columns: [
                    [
                        { checkbox: true },
                        { field: 'id', title: '序号', operate: false },
                        {
                            field: 'project_info', title: '项目名称及编号', operate: false, align: 'left', formatter: function (val, row) {
                                return row.project_name + '<br/>' + (row.project_no ? row.project_no : '编号:未设置')
                            }
                        },
                        { field: 'memberCount', title: '团队人数', operate: false },
                        { field: 'project_type_name', title: '项目分类', operate: false },
                        { field: 'college_name', title: '项目所属学院', operate: false },
                        {
                            field: 'user_info', title: '负责人姓名/学号', align: 'left', operate: false, formatter: function (val, row) {
                                return row.nickname + '<br/>' + (row.student_no || '-')
                            }
                        },
                        {
                            field: 'user_from', title: '负责人学院/专业', align: 'left', operate: false, formatter: function (val, row) {
                                return row.college_name + '<br>' + (row.major_name || '-')
                            }
                        },
                        { field: 'project_teachers', title: '指导教师', formatter: function (val) {
                                var teachersName = '';
                                for (var p in val) {
                                    teachersName += (val[p].username + '<br>')
                                }
                                return teachersName;
                            }
                        },
                        { field: 'teacher', title: '教师审核(签名)', operate: false },
                        {
                            field: 'project_level', title: '项目级别', operate: false, formatter: function (val) {
                                return projectLevelMap[val]
                            }
                        },
                        {
                            field: 'check_stage', title: '项目状态', operate: false, formatter: function (val,row) {
                                return (val > 2 && row.project_level > 0) ? '已立项' : '未立项'
                            }
                        },
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
                        buttons: [
                            {
                                name: 'projectView',
                                text: '查看项目',
                                classname: 'btn btn-xs btn-success btn-addtabs',
                                url: function (row) {
                                    return '/school/project_common.project_view/indexAll?ids=' + row.id
                                }
                            },
                            {
                                name: '_btn2',
                                text: '查看审核信息',
                                title: '查看审核信息',
                                classname: 'btn btn-xs btn-info btn-addtabs',
                                url: function (val) {
                                    return '/school/project_common/judge/verify_list?review_stage=all&register_id=' + val.id
                                }
                            }
                        ]
                        }
                    ]
                ]
            });
            //导出功能
            $(document).on("click", ".btn-export", function () {
                //以后可以添加检索条件 location.search
                top.location.href="/school/project_summary/export";
            });
            //统计查看
            $(document).on("click", "#btn-statistics", function () {
                Fast.api.open('/school/project_summary/statistics','统计',{area: ['75%', '70%'],});
            });
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        statistics: function() {
            var vm = new Vue({
                el:"#app",
                data() {
                    return {
                        statistics_val:'',
                        collegeList:[],
                        match_title:'',
                        title:[],
                    }
                },
                mounted() {
                    this.collegeList = Config.collegeList;
                    this.statistics();
                },
                methods: {
                    statistics:function() {
                        var _this = this;
                        //请求数据
                        $.ajax({
                            url:'/school/project_summary/statistics',
                            type:'post',
                            dataType:'json',
                            success:function(res){
                                if(res.code != 0) {
                                    _this.match_title = res.data.match_title;
                                    _this.title = res.data.group.title;
                                    var Group = Echarts.init(document.getElementById('group')),
                                        people = Echarts.init(document.getElementById('people')),
                                        college = Echarts.init(document.getElementById('college'));
                                    var groupOption = {
                                        title: {
                                            x:'center',
                                            text: res.data.match_title + '【各项目类型报名组数统计】',
                                        },
                                        xAxis: {
                                            type: 'category',
                                            data: res.data.group.title,
                                            axisTick: {
                                                alignWithLabel: true
                                            },
                                            axisLabel: {
                                                interval:0,
                                                rotate:40//角度顺时针计算的
                                            },
                                            max:function (value) {
                                                if (value.max < 8 ){
                                                    value.max = 8;
                                                } else {
                                                    value.max = value.max;
                                                }
                                                return value.max;
                                            },
                                        },
                                        grid: { bottom: "35%" },
                                        yAxis: {
                                            type : 'value',
                                            axisLine: {
                                                lineStyle: {
                                                    color: "#272822"
                                                }
                                            }
                                        },
                                        series: [{
                                            data:res.data.group.value,
                                            type: 'bar',
                                            itemStyle: {
                                                normal: {
                                                    label: {
                                                        show: true,  //开启显示
                                                        position: 'top',  //在上方显示
                                                        textStyle: {  //数值样式
                                                            color: '#AAAAAA',
                                                            fontSize: 12
                                                        }
                                                    }
                                                }
                                            },
                                        }]
                                    };
                                    var peopleOption = {
                                        title: {
                                            x:'center',
                                            text: res.data.match_title + '【各项目类型报名人数统计】',
                                        },
                                        xAxis: {
                                            type: 'category',
                                            data: res.data.people.title,
                                            axisTick: {
                                                alignWithLabel: true
                                            },
                                            axisLabel: {
                                                interval:0,
                                                rotate:40//角度顺时针计算的
                                            },
                                            max:function (value) {
                                                if (value.max < 8 ){
                                                    value.max = 8;
                                                } else {
                                                    value.max = value.max;
                                                }
                                                return value.max;
                                            },
                                        },
                                        grid: { bottom: "35%" },
                                        yAxis: {
                                            type : 'value',
                                            axisLine: {
                                                lineStyle: {
                                                    color: "#272822"
                                                }
                                            }
                                        },
                                        series: [{
                                            data:res.data.people.value,
                                            type: 'bar',
                                            itemStyle: {
                                                normal: {
                                                    label: {
                                                        show: true,  //开启显示
                                                        position: 'top',  //在上方显示
                                                        textStyle: {  //数值样式
                                                            color: '#AAAAAA',
                                                            fontSize: 12
                                                        }
                                                    }
                                                }
                                            },
                                        }]
                                    };
                                    var collegeOption = {
                                        title: {
                                            x:'center',
                                            text: res.data.match_title + '【各学院项目报名组统计】',
                                        },
                                        xAxis: {
                                            type: 'category',
                                            data: _this.title,
                                            axisTick: {
                                                alignWithLabel: true
                                            },
                                            axisLabel: {
                                                interval:0,
                                                rotate:40//角度顺时针计算的
                                            },
                                            max:function (value) {
                                                if (value.max < 8 ){
                                                    value.max = 8;
                                                } else {
                                                    value.max = value.max;
                                                }
                                                return value.max;
                                            },
                                        },
                                        grid: { bottom: "35%" },
                                        yAxis: {
                                            type : 'value',
                                            axisLine: {
                                                lineStyle: {
                                                    color: "#272822"
                                                }
                                            }
                                        },
                                        series: [{
                                            data:[],
                                            type: 'bar',
                                            itemStyle: {
                                                normal: {
                                                    label: {
                                                        show: true,  //开启显示
                                                        position: 'top',  //在上方显示
                                                        textStyle: {  //数值样式
                                                            color: '#AAAAAA',
                                                            fontSize: 12
                                                        }
                                                    }
                                                }
                                            },
                                        }]
                                    };
                                    Group.setOption(groupOption);
                                    people.setOption(peopleOption);
                                    college.setOption(collegeOption);
                                }
                            }
                        })
                    },
                    getData:function(val) {
                        var _this = this;
                        $.ajax({
                            url:'/school/project_summary/getCollegeData',
                            type:'post',
                            data:{college_id:val},
                            dataType:'json',
                            success:function(res){
                                if(res.code != 0) {
                                    var college = Echarts.init(document.getElementById('college'));
                                    var collegeOption = {
                                        title: {
                                            x:'center',
                                            text: _this.match_title + '【各学院项目报名组统计】',
                                            subtext: '',
                                        },
                                        xAxis: {
                                            type: 'category',
                                            data: res.data.title,
                                            axisTick: {
                                                alignWithLabel: true
                                            },
                                            axisLabel: {
                                                interval:0,
                                                rotate:40//角度顺时针计算的
                                            },
                                        },
                                        grid: { bottom: "35%" },
                                        yAxis: {
                                            type : 'value',
                                            axisLine: {
                                                lineStyle: {
                                                    color: "#272822"
                                                }
                                            }
                                        },
                                        series: [{
                                            data:res.data.val,
                                            type: 'bar',
                                            itemStyle: {
                                                normal: {
                                                    label: {
                                                        show: true,  //开启显示
                                                        position: 'top',  //在上方显示
                                                        textStyle: {  //数值样式
                                                            color: '#AAAAAA',
                                                            fontSize: 12
                                                        }
                                                    }
                                                }
                                            },
                                        }]
                                    };
                                    college.setOption(collegeOption);
                                }
                            }
                        });
                    },
                },

            })

        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            },
        }
    }

    return Controller
})