customListCtrl.js 2.9 KB
(function(angular) {
	function customListCtrl($scope, reportService, $resource, DTOptionsBuilder, DTColumnBuilder) {
		//查询条件
		$scope.dateRange = { 
			startDate: moment().startOf('day').format('YYYY-MM-DD 00:00:00'),
			endDate:  moment().endOf('day').format('YYYY-MM-DD 00:00:00')
		}
		$scope.onlineOptions = [
			{id: 0, name: '全部'},
			{id: 1, name: '在线'},
			{id: 2, name: '离线'}
		];
		$scope.onlineSelected = $scope.onlineOptions[0];
		
		//获取分组列表
		$scope.groupOptions = null;
		reportService.getGroup(function(data){
			var result = data.obj;
			$scope.groupOptions = result;
			$scope.groupSelected = result[0];
		}, function(data){

		});

		//获取分类
		$scope.classOptions = null;
		$scope.classSelected = null;
		$scope.getClassByGroupId = function(groupId){
			reportService.getClass({groupId: groupId}, function(data){
				var result = data.obj;
				$scope.classOptions = result;
				$scope.classSelected = result[0];
			}, function(data){

			});
		}

		$scope.conditionOptions = [
			{id: -1, name: '请选择'},	
			{id: 0, name: '设备号'},
			{id: 1, name: '车架号'},
			{id: 2, name: '姓名'},
			{id: 3, name: '工单号'}
		];
		$scope.conditionSelected = $scope.conditionOptions[0];

		$scope.activeListForm = function(){
			$scope.dtInstance.query();
		}

		$scope.dtColumns = [
            DTColumnBuilder.newColumn('id').withOption('width',60).withTitle('工单号'),
            DTColumnBuilder.newColumn('name').withOption('width',60).withTitle('姓名'),
            DTColumnBuilder.newColumn('standno').withOption('width',160).withTitle('车架号'),
            DTColumnBuilder.newColumn('deviceNo2').withOption('width',100).withTitle('设备号'),
            DTColumnBuilder.newColumn('deviceNo2').withOption('width',100).withTitle('设备型号'),
            DTColumnBuilder.newColumn('deviceNo2').withOption('width',60).withTitle('是否在线'),
            DTColumnBuilder.newColumn('groupId').withOption('width',100).withTitle('所属分类'),
            DTColumnBuilder.newColumn('createTime').withOption('width',200).withTitle('激活时间'),
            DTColumnBuilder.newColumn('operator').withOption('width',100).withTitle('操作人')
        ]
 
		$scope.dtOptions = DTOptionsBuilder.newOptions()
		.withButtons([{
			text : '导出excel',
			className: 'btn btn-primary',
			action : function(e, dt, node, config) {
				var selectedArr = [];
				$('.selectOne:checked').each(function(){
					selectedArr.push($(this).data('id'));
				});
				console.log(selectedArr.join(','))
				
			}
		}])
		.withOption('id','id')
		.withOption('ordering',false)
		.withFixedColumns({
            leftColumns: 7,
            rightColumns: 0
        })
        .withOption('select', {
        	type: 'checkbox'
        });
        

		$scope.dtInstance = {
			serverData : reportService.getList
		};
		
	}
	
	angular.module('report').controller('customListCtrl', customListCtrl);
})(angular);