controllers.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. starter.controller('CompConnectCtrl', function ($scope, $state, $ionicSlideBoxDelegate, $rootScope, $ionicHistory, $window, showPopup, global, Comp) {
  2. $scope.activeIndex = 0;
  3. $scope.titleName = ['填写序列号', '选择公司', '用户信息', '导入部门'];
  4. var compmodal = showPopup.modalTemplate('templates/modal-selectcomp.html', 'slide-in-up', $scope);
  5. global.fetch_user().then(function (res) {
  6. });
  7. $scope.lockSlide = function () {
  8. $ionicSlideBoxDelegate.enableSlide(false);
  9. };
  10. $scope.next = function (op, serialno) {
  11. $ionicSlideBoxDelegate.next();
  12. $scope.activeIndex = $ionicSlideBoxDelegate.currentIndex();
  13. if (op == 1) {
  14. $scope.serialnumber = serialno;
  15. Comp.comp().query({"serialno": serialno}, function (data) {
  16. $scope.compdata = data;
  17. $scope.activecomp = data[0];
  18. $scope.showmodal();
  19. }, function (err) {
  20. console.log(JSON.stringify(err))
  21. })
  22. }
  23. };
  24. $scope.commit = function (r) {
  25. $scope.activecomp = _.extend($scope.activecomp, {"cellphone": global.user.cellphone, "imid": global.user.im_usrid, "linkerpassword": global.user.password, "linkerusername": global.user.usrname, "region": 86});
  26. showPopup.showLoading(1, '正在提交', false);
  27. console.log($scope.activecomp);
  28. Comp.comp("PostComp", $scope.serialnumber).save($scope.activecomp, function (res) {
  29. $ionicSlideBoxDelegate.next();
  30. }, function (err) {
  31. console.log(err);
  32. }).$promise.finally(function (f) {
  33. showPopup.hideLoading();
  34. })
  35. };
  36. $scope.showmodal = function () {
  37. compmodal.then(function (m) {
  38. $rootScope.commons.modal = m;
  39. $rootScope.commons.modal.show();
  40. })
  41. };
  42. $scope.closeModal = function (comp) {
  43. if (comp)
  44. $scope.activecomp = comp;
  45. $rootScope.commons.modal.hide();
  46. };
  47. $scope.back = function () {
  48. if ($scope.activeIndex != 0) {
  49. $ionicSlideBoxDelegate.previous();
  50. $scope.activeIndex = $ionicSlideBoxDelegate.currentIndex();
  51. } else if ($scope.activeIndex == 0) {
  52. $window.history.back();
  53. }
  54. };
  55. })