|
@@ -1,16 +1,16 @@
|
|
|
-starter.controller('CompConnectCtrl', function ($scope, $state, $ionicSlideBoxDelegate, $rootScope, $ionicHistory, $window, showPopup, global, Comp) {
|
|
|
- $scope.activeIndex = 0;
|
|
|
+starter.controller('CompConnectCtrl', function ($scope, $state, $ionicSlideBoxDelegate, $rootScope, $ionicHistory, $window,$location, showPopup, global, Comp) {
|
|
|
+ $scope.activeIndex = 3;
|
|
|
$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))
|
|
|
- });
|
|
|
+ // 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 = {};
|
|
|
});
|
|
|
|
|
@@ -23,7 +23,8 @@ starter.controller('CompConnectCtrl', function ($scope, $state, $ionicSlideBoxDe
|
|
|
$scope.activeIndex = $ionicSlideBoxDelegate.currentIndex();
|
|
|
if (op == 1) {
|
|
|
$scope.serialnumber = serialno;
|
|
|
- Comp.comp().query({"serialno": serialno}, function (data) {
|
|
|
+ global.sn = $scope.serialnumber;
|
|
|
+ Comp.comp('GetComp').query(function (data) {
|
|
|
$scope.compdata = data;
|
|
|
$scope.activecomp = data[0];
|
|
|
$scope.showmodal();
|
|
@@ -35,19 +36,31 @@ starter.controller('CompConnectCtrl', function ($scope, $state, $ionicSlideBoxDe
|
|
|
|
|
|
$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});
|
|
|
+ global.sn = $scope.serialnumber;
|
|
|
showPopup.showLoading(1, '正在提交', false);
|
|
|
- console.log($scope.activecomp);
|
|
|
- Comp.comp("PostComp/0", $scope.serialnumber).save($scope.activecomp, function (res) {
|
|
|
- $ionicSlideBoxDelegate.next();
|
|
|
+ Comp.comp("PostComp").save($scope.activecomp, function (data) {
|
|
|
+ Comp.sn.save({"sn": global.sn, "comp": data.linkercompid}, function (data) {
|
|
|
+ console.log(data);
|
|
|
+ $ionicSlideBoxDelegate.next();
|
|
|
+ }, function (err) {
|
|
|
+ alert("Linker创建sn失败: " + JSON.stringify(err));
|
|
|
+ });
|
|
|
}, function (err) {
|
|
|
- console.log(err);
|
|
|
+ alert("erp与linker连接失败: " + JSON.stringify(err));
|
|
|
}).$promise.finally(function (f) {
|
|
|
showPopup.hideLoading();
|
|
|
})
|
|
|
};
|
|
|
|
|
|
$scope.importDept = function () {
|
|
|
-
|
|
|
+ showPopup.showLoading(1, '导入中', false);
|
|
|
+ Comp.dept("PostDept").save(function (data) {
|
|
|
+ $window.location.href = "http://" + $location.host() + ":8100/apps/accountMng/index.html#/contacts/-1&Linker test3&78";
|
|
|
+ }, function (err) {
|
|
|
+ alert(JSON.stringify(err))
|
|
|
+ }).$promise.finally(function (f) {
|
|
|
+ showPopup.hideLoading();
|
|
|
+ })
|
|
|
};
|
|
|
|
|
|
$scope.parse = function () {
|