text: /*
  * @description: 添加海报js
  * @author: billy
  * @update: billy (2018-03-30 17:30)
  * @version: v1.0
  */
  var app = angular.module('myApp', []);
  app.controller('listController', function ($scope, $http,) {
  	$scope.but = false;
  	//post请求的地址
  	var url = window.location.href,
  	//将参数传递的方式改成form
  	postCfg = {
  		headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  		transformRequest: function (data) {
  			return $.param(data);
  		}
  	};
      var reSearch = function () {
          var postData = {
              type: 'info',
              id: $scope.id ? $scope.id : '',
          };
          $http.post(url, postData, postCfg).then(function (result) {  //正确请求成功时处理
  	        $scope.info = result.data;
              $scope.name = $scope.info.name;
              $scope.sn = $scope.info.sn;
  	        var imgurl = $scope.info.img ? $scope.info.img : THEME_PATH + 'images/upload-img.png';
  	        $("#bigImagePath").val($scope.info.img ? $scope.info.img : '');
  	        if(imgurl!=''){
                  $('#img').attr('src' , imgurl);
              }
          }).catch(function () { //捕捉错误处理
              layer.msg('请求超时！', {time: 1500});
          });
      }
      $scope.reSearch = reSearch;
      $scope.$watch('', reSearch);
      $scope.saveModel = function (type){
      	var sn = $scope.sn;
      	var name = $scope.name;
      	var bigImagePath = $("#bigImagePath").val();
      	if(!angular.isDefined($scope.name) || name==""){
      		$scope.but = false;
      		layer.msg('请输入海报名称',{icon: 5,time:1500});
      		return;
      	}
      	if(!angular.isDefined($scope.sn) || sn==""){
      		$scope.but = false;
      		layer.msg('请输入排序',{icon: 5,time:1500});
      		return;
      	}
      	if(bigImagePath==""){
      		$scope.but = false;
      		layer.msg('请上传图片',{icon: 5,time:1500});
      		return;
      	}
      	if(type=="modify"){//修改
      		var id = $scope.id;
      		if(!angular.isDefined($scope.id) || id==""){
          		$scope.but = false;
  	    		layer.msg('抱歉，您要修改的海报不存在',{icon: 5,time:1500});
  	    		return;
          	}
      		var postData = {
                      type: type,
                      id: id,
                      sn: sn ? sn : '',
              		name: name ? name : '',
              		bigImagePath: bigImagePath ? bigImagePath : ''
              };
      	}else{//添加
      		var postData = {
                      type: type,
                      sn: sn ? sn : '',
              		name: name ? name : '',
      				bigImagePath: bigImagePath ? bigImagePath : ''
              };
      	}
      	$http.post(url, postData, postCfg).then(function (result) {  //正确请求成功时处理
              if (result.data.code>0) {
                  var index = parent.layer.getFrameIndex(window.name);
                  parent.layer.close(index);
                  parent.layer.msg(result.data.message, {icon: 6, time: 1500});
                  var controllerScope = parent.$('div[ng-controller="listController"]').scope();
                  controllerScope.reSearch();
              } else {
              	$scope.but = false;
                  layer.msg(result.data.message, {time: 1500});
              }
          }).catch(function () { //捕捉错误处理
          	$scope.but = false;
              layer.msg('服务端请求错误！', {time: 1500});
          });
      }
      $scope.resetModel = function (){
      	$scope.but = false;
      	$scope.name = '';
          $scope.sn = '';
          $scope.url = '';
      	$("#bigImagePath").val('');
      }
  })
  