var angular = require('angular');
require('../modules');
require('../services/ArchivesInceptService');
'use strict';

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

module.controller('ArchivesInceptGroupCtrl',
  function($state, $toast, $sinoGoBackDelegate, ArchivesInceptService) {
    var ctrl = this;

    ctrl.todos = ArchivesInceptService.todos;
    ctrl.relatedList = ArchivesInceptService.relatedList;
    ctrl.toDetail = toDetail;
    ctrl.remove = remove;

    /**
     * 查看收文单据详情。
     */
    function toDetail(item) {
      $state.go('archivesincept-archivesinceptDetail', {
        id: item.id
      });
    };

    /**
   * 删除数据。
   */
  function remove(list, item) {
    return ArchivesInceptService.remove(item.id).then(function() {
      $toast.showLongCenter('收文单删除成功。');
      list.remove(item);
    }, function() {
      $toast.showLongCenter('收文单删除失败，请检查网络连接。');
    });
  };

});
