123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- starter.controller('CompConnectCtrl', function ($scope, $state, $ionicSlideBoxDelegate, $rootScope, $ionicHistory, $window, showPopup, global, Comp) {
- $scope.activeIndex = 0;
- $scope.titleName = ['填写序列号', '选择公司', '用户信息', '导入部门'];
- var compmodal = showPopup.modalTemplate('templates/modal-selectcomp.html', 'slide-in-up', $scope);
- global.fetch_user().then(function (res) {
- if (!global.sn)
- Comp.sn.get({"comp_id": global.user.compno}, function (data) {
- global.sn = data.sn;
- console.warn("sn: " + global.sn);
- }, function (err) {
- console.error("获取服务器的SN失败: " + JSON.stringify(err))
- });
- $scope.activecomp = {};
- });
- $scope.lockSlide = function () {
- $ionicSlideBoxDelegate.enableSlide(false);
- };
- $scope.next = function (op, serialno) {
- $ionicSlideBoxDelegate.next();
- $scope.activeIndex = $ionicSlideBoxDelegate.currentIndex();
- if (op == 1) {
- $scope.serialnumber = serialno;
- Comp.comp().query({"serialno": serialno}, function (data) {
- $scope.compdata = data;
- $scope.activecomp = data[0];
- $scope.showmodal();
- }, function (err) {
- console.log(JSON.stringify(err))
- })
- }
- };
- $scope.commit = function (r) {
- $scope.activecomp = _.extend($scope.activecomp, {"cellphone": global.user.cellphone, "imid": global.user.im_usrid, "linkerpassword": global.user.password, "linkerusername": global.user.usrname, "region": 86});
- showPopup.showLoading(1, '正在提交', false);
- console.log($scope.activecomp);
- Comp.comp("PostComp/0", $scope.serialnumber).save($scope.activecomp, function (res) {
- $ionicSlideBoxDelegate.next();
- }, function (err) {
- console.log(err);
- }).$promise.finally(function (f) {
- showPopup.hideLoading();
- })
- };
- $scope.importDept = function () {
- };
- $scope.parse = function () {
- $window.history.back();
- };
- $scope.showmodal = function () {
- compmodal.then(function (m) {
- $rootScope.commons.modal = m;
- $rootScope.commons.modal.show();
- })
- };
- $scope.closeModal = function (comp) {
- if (comp)
- $scope.activecomp = comp;
- $rootScope.commons.modal.hide();
- };
- $scope.back = function () {
- if ($scope.activeIndex != 0) {
- $ionicSlideBoxDelegate.previous();
- $scope.activeIndex = $ionicSlideBoxDelegate.currentIndex();
- } else if ($scope.activeIndex == 0) {
- $window.history.back();
- }
- };
- })
|