channelConfigCtrl.js 4.47 KB
(function(angular) {
	function channelConfigCtrl($scope, DTOptionsBuilder, DTColumnBuilder, systemService, $uibModal, $filter, $state,Utils) {		
		$scope.channelTypeList = [];
		systemService.getChannelTypeList(function(res){
			$scope.channelTypeList = res.data;
		});
		$scope.dtColumns = [
		    DTColumnBuilder.newColumn('channelName').withOption('width',80).withTitle('渠道名称'),
		    DTColumnBuilder.newColumn('channelType').withOption('width',80).withTitle('渠道类型').renderWith(function(e, dt, node, config){
		    	var channelTypeName = "";
		    	angular.forEach($scope.channelTypeList, function(r){
					if(r.confValue == node.channelType){
						channelTypeName = r.confName;
					}
				});
            	return channelTypeName;
            }),
		    DTColumnBuilder.newColumn('channelWebUrl').withOption('width',80).withTitle('渠道网址'),
		    DTColumnBuilder.newColumn('channelWebName').withOption('width',80).withTitle('渠道网址名称'),
		    DTColumnBuilder.newColumn('platformGroup').withOption('width',80).withTitle('平台分组'),
		    DTColumnBuilder.newColumn('platformChannelName').withOption('width',120).withTitle('平台渠道名称'),
		    DTColumnBuilder.newColumn('platformChannelCode').withOption('width',120).withTitle('平台渠道编号'),
		    DTColumnBuilder.newColumn('wechatAppid').withOption('width',90).withTitle('微信应用ID'),
		    DTColumnBuilder.newColumn('channelLogo').withOption('width',80).withTitle('渠道logo').renderWith(function(e, dt, node, config){
            	if(node.channelLogo){
            		return '<img src="' + node.channelLogo + '" style="width:100%;height:60px;">';
            	}
            	return "";
            }),
            DTColumnBuilder.newColumn('loginLogo').withOption('width',80).withTitle('登录页logo').renderWith(function(e, dt, node, config){
            	if(node.loginLogo){
            		return '<img src="' + node.loginLogo + '" style="width:100%;height:60px;">';
            	}
            	return "";
            }),
            DTColumnBuilder.newColumn('wechatLoginLogo').withOption('width',100).withTitle('微信登录页logo').renderWith(function(e, dt, node, config){
            	if(node.wechatLoginLogo){
            		return '<img src="' + node.wechatLoginLogo + '" style="width:100%;height:60px;">';
            	}
            	return "";
            }),
            DTColumnBuilder.newColumn('siteLogo').withOption('width',80).withTitle('网站内logo').renderWith(function(e, dt, node, config){
            	if(node.siteLogo){
            		return '<img src="' + node.siteLogo + '" style="width:100%;height:60px;">';
            	}
            	return "";
            }),
            DTColumnBuilder.newColumn('updatedDate').withOption('width',120).withTitle('更新时间').renderWith(function(e, dt, node, config){
            	return $filter('date')(new Date(node.updatedDate), 'yyyy-MM-dd HH:mm:ss');
            }),
            DTColumnBuilder.newColumn(null).withTitle(function(){
            	return '操作';
            }).withOption('width', 80).withClass('text-center').renderWith(function(data, type, full, oSettings) {
            	var str = '<div class="form-inline">'
	                +'<div class="form-group"><a class="btn btn-link" ng-click="addOrUpdate('+ data.id +')">修改资料</a></div>';
	            str += '</div>';
                return str;
            })
        ];
		$scope.dtOptions = DTOptionsBuilder.newOptions()
		.withOption('id','id')
		.withFixedColumns({
              rightColumns: 1
         });

		$scope.dtInstance = {
			serverData : systemService.getChannelConfigPageList
		};

		$scope.getParams =function(){
			var condition = {};
			if($scope.channelName){
				condition.channelName = $scope.channelName;
			}
			return {'condition':condition};
		}


		//查询
		$scope.submitForm = function(){
			$scope.dtInstance.query($scope.getParams());
		}
		
		$scope.addOrUpdate = function (channelId) {
	        $uibModal.open({
	            templateUrl: 'biz/system/view/channelConfigAdd.html',
	            controller: 'channelConfigAddCtrl',
	            size: 'lg',
	            resolve: {
	                params: function () {
	                    return {'channelId':channelId}
	                }
	            }
	        }).result.then(function (data) {
	        	$scope.dtInstance.query($scope.getParams());
	        },function(){
	        	$scope.dtInstance.query($scope.getParams());
	        })
	    };
	}

	angular.module('system').controller('channelConfigCtrl', channelConfigCtrl)
})(angular);