var angular = require('angular');
require('jsUtil');
require('../modules');

var module = angular.module('flow');

module.controller('SendFlowCtrl', function($scope) {
  $scope.refreshx = false;
  $scope.disable = true;
  $scope.seconds = 5;
  $scope.hasSend = false;
  $scope.result = {};

  $scope.$watch('result.selectedItem', function(item) {
    if (item) {
      _.each($scope.data.wfoperationMap, function(name, id) {
        if($scope.data.wfoperationMap.hasOwnProperty(id)) {
          if(name === item) {
            $scope.data.wfoperateid = id;
            $scope.data.wfoperatename = name;
          }
        }
        
      });
      if($scope.disable) {
        $scope.disable = false;
      }
    }
  });

  /**
  * 监听被选中项
  **/
  $scope.selectPerson = function() {
    $scope.refreshx = true;
    $scope.hasSend = true;
    $scope.disable = true;
    
    $scope.close(false);
  };

  $scope.close = function(cancel) {
    $scope.onSelected(cancel);
  };
});
