123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881 |
- starter.controller('AccountManageCtrl', function ($scope, global, showPopup, CompManage) {
- var beforeEnter = $scope.$on("$ionicView.beforeEnter", function () {
- $scope.show = {
- isshow: false
- };
- global.fetch_user().then(function (data) {
- $scope.is_showcurrent = (global.user.compno != null);
- if (global.user.token != "") {
- CompManage.get_Compdata().then(function (data) {
- data = _.filter(data, function (item) {
- return item.usr_status == 2;
- });
- if (data.length > 0) {
- _.each(data, function (c) {
- c.check = false;
- if (c.id == global.user.compno) {
- $scope.currentcomp = c;
- c.check = true;
- }
- });
- }
- $scope.compdata = data;
- }, function (err) {
- $scope.is_showcurrent = false;
- alert(JSON.stringify(err))
- });
- } else {
- $scope.compdata = [];
- }
- });
- });
- $scope.change = function (comp) {
- if ($scope.compdata.length > 0) {
- if ($scope.currentcomp != comp) {
- showPopup.showLoading(1, '', false);
- var password = global.user.password;
- CompManage.post_authcheck(global.user.im_usrid, comp.id).then(function (data) {
- $scope.currentcomp = comp;
- $scope.show.isshow = false;
- _.each($scope.compdata, function (_comp) {
- if (comp.id != _comp.id) {
- _comp.check = false;
- }
- });
- global.user = data;
- global.user.password = password;
- CompManage.store_user().then(function (data) {
- console.log(data);
- showPopup.hideLoading();
- }, function (error) {
- showPopup.hideLoading();
- console.log('store error:' + JSON.stringify(error));
- });
- }, function (error) {
- showPopup.hideLoading();
- alert(JSON.stringify(error));
- });
- }
- }
- };
- $scope.goBack = function () {
- global.goBack();
- };
- $scope.showcomplist = function () {
- if ($scope.compdata.length > 0) $scope.show.isshow = !$scope.show.isshow;
- }
- })
- .controller('ManageCompCtrl', function ($scope, $state, $ionicPopup, $rootScope, $ionicHistory, $q, $location, $window, global, ImageManage, showPopup, CompManage) {
- $scope.newcompname = {
- "compname": ""
- };
- var beforeEnter = $scope.$on("$ionicView.beforeEnter", function () {
- $scope.loading = ($scope.compdata == undefined);
- global.fetch_user().then(function (data) {
- if (global.user.token != "") {
- getmycomplist();
- } else {
- $scope.compdata = [];
- $scope.loading = false;
- }
- $scope.popup = {
- isSetPopup: false
- };
- });
- });
- $scope.tocompinfo = function (compid, op) {
- $state.go('compinfo', {
- 'compid': compid,
- 'op': op
- });
- };
- $scope.showaddcompmodel = function () {
- showPopup.modalTemplate('templates/createcomp-modaltemplate.html', 'slide-in-right', $scope).then(function (modal) {
- $rootScope.commons.modal = modal;
- $rootScope.commons.modal.show();
- });
- };
- $scope.cancel = function () {
- $rootScope.commons.modal.hide();
- $scope.logourl = '../../../img/logo.png';
- };
- $scope.createcomp = function () {
- var newcompdata = {"compname": "", "cellphone": global.user.cellphone, "username": "", "imid": "", "password": global.user.password};
- newcompdata.username = global.user.usrname;
- newcompdata.compname = $scope.newcompname.compname;
- newcompdata.imid = global.user.im_usrid;
- showPopup.showLoading(1, '正在提交', true, $scope.logourl != "../../../img/logo.png" ? 20000 : 10000);
- CompManage.post_Register(newcompdata).then(function (compdata) {
- if ($scope.logourl != "../../../img/logo.png") {
- if (global.user.token == "") {
- var password = global.user.password;
- CompManage.post_authcheck(global.user.im_usrid, compdata.compid).then(function (data) {
- global.user = data;
- global.user.password = password;
- uploadcomplogo(compdata);
- CompManage.store_user().then(function () {
- }, function (error) {
- showPopup.hideLoading();
- console.log('store error:' + JSON.stringify(error));
- });
- }, function (err) {
- showPopup.hideLoading();
- alert('post_authcheck error:' + JSON.stringify(err))
- });
- } else {
- uploadcomplogo(compdata)
- }
- } else {
- get_authcheckInfo(compdata.compid);
- }
- }, function (e) {
- showPopup.hideLoading();
- if (_.has(e.data, 'msg')) showPopup.PopupWindow(0, e.data.msg, false, 2000);
- else alert(JSON.stringify(e));
- });
- };
- $scope.$on('$destroy', function () {
- if ($rootScope.commons.modal != null) {
- $rootScope.commons.modal.remove();
- }
- beforeEnter = null;
- });
- $scope.logourl = '../../../img/logo.png';
- $scope.editlogo = function () {
- $scope.popup.optionsPopup = showPopup.showSelectImgPopup(Camera, ImagePicker, $scope);
- $scope.popup.isSetPopup = true;
- };
- $scope.import = function () {
- $window.location.href = "http://" + $window.location.host + "/apps/compmanage/index.html#/index";
- // $location.url('http://192.168.1.5:8101/apps/compmanage/index.html#/index');
- };
- function uploadcomplogo(comp) {
- ImageManage.uploadImage($scope.logourl, 'comp', comp.compid, 'complogo').then(function (res) {
- $q.all(res).then(function (res1) {
- get_authcheckInfo(comp.id);
- }, function (error) {
- showPopup.hideLoading();
- alert('upload error:' + JSON.stringify(error));
- });
- }, function (err) {
- showPopup.hideLoading();
- alert('upload token error:' + JSON.stringify(err));
- });
- }
- function get_authcheckInfo(compid) {
- if (global.user.token == '') {
- var password = global.user.password;
- CompManage.post_authcheck(global.user.im_usrid, compid).then(function (data) {
- global.user = data;
- global.user.password = password;
- getmycomplist();
- CompManage.store_user().then(function (data) {
- console.log(data);
- $ionicHistory.goBack();
- showPopup.hideLoading();
- }, function (error) {
- showPopup.hideLoading();
- console.log('store error:' + JSON.stringify(error));
- });
- }, function (err) {
- showPopup.hideLoading();
- alert('post_authcheck error:' + JSON.stringify(err))
- });
- } else {
- showPopup.hideLoading();
- if ($rootScope.commons.modal != null) $rootScope.commons.modal.hide();
- getmycomplist();
- }
- }
- function getmycomplist() {
- CompManage.get_Compdata().then(function (data) {
- _.each(data, function (comp) {
- if (comp.file_thumbnail_path == null) {
- comp.file_thumbnail_path = $scope.logourl;
- }
- var admin = _.find(comp.compadmin, function (adminitem) {
- return adminitem.user_id == global.user.usrid;
- });
- comp.op = admin == undefined ? 0 : 1;
- comp.compadmins = _.pluck(comp.compadmin, 'username').join(',');
- });
- $scope.compdata = _.sortBy(data, 'op').reverse();
- $scope.loading = false;
- $scope.newcompname.compname = "";
- $scope.logourl = "../../../img/logo.png"
- }, function (err) {
- $scope.loading = false;
- alert(JSON.stringify(err));
- });
- }
- var ImagePicker = function () { //打开相册
- $scope.popup.optionsPopup.close();
- ImageManage.ImagePicker_getPictures(1).then(function (results) {
- if (results.length == 0) return;
- $q.all(results).then(function (res) {
- $scope.logourl = res[0];
- })
- });
- };
- var Camera = function () {
- $scope.popup.optionsPopup.close();
- ImageManage.Camera_getPicture(true).then(function (result) {
- $scope.logourl = result;
- });
- };
- })
- .controller('JoinCompCtrl', function ($scope, $ionicHistory, $timeout, CompManage, global, showPopup) {
- $scope.data = {
- "compid": ""
- };
- var compdata = _.pick(global.user, 'cellphone', 'password');
- compdata.username = global.user.usrname;
- compdata.imid = global.user.im_usrid;
- $scope.addedcomp = {};
- $scope.is_show_jointip = false;
- $scope.joincomp = function () {
- var complist = CompManage.getComplist();
- var comp = _.findWhere(complist, {'id': $scope.data.compid});
- compdata.compid = $scope.data.compid;
- if (comp == undefined) { //未加入过
- showPopup.showLoading(1, '正在提交', true);
- CompManage.post_Joinin(compdata).then(function (res) {
- showPopup.hideLoading();
- if (res.status == 201)
- $scope.is_show_jointip = true;
- else
- showPopup.PopupWindow(0, res.msg, false, 2000);
- $timeout(function () {
- $scope.is_show_jointip = false;
- }, 5000);
- }, function (e) {
- showPopup.hideLoading();
- if (_.has(e.data, 'msg')) showPopup.PopupWindow(0, e.data.msg, false, 2000);
- else alert(JSON.stringify(e));
- });
- } else {
- if (comp.file_thumbnail_path == "") {
- comp.file_thumbnail_path = '../../../img/logo.png'
- }
- showPopup.PopupWindow(0, '你已加入该公司!', false, 2000);
- $scope.addedcomp = comp;
- }
- };
- })
- .controller('CompInfoCtrl', function ($scope, $ionicPopup, $state, $ionicHistory, $q, showPopup, ImageManage, CompManage, global) {
- var compid = $state.params['compid'];
- $scope.op = $state.params['op'];
- var beforeEnter = $scope.$on("$ionicView.beforeEnter", function () {
- var compdata = CompManage.getComplist();
- $scope.rdata = _.find(compdata, function (comp) {
- return comp.id == $state.params['compid'];
- });
- console.log($scope.rdata);
- $scope.data = _.clone($scope.rdata);
- $scope.popup = {
- isPopup: false
- };
- });
- $scope.$on("$destroy", function () {
- beforeEnter = null;
- });
- $scope.selectphoto = function () {
- if ($scope.op == 0) {
- return;
- }
- $scope.popup.optionsPopup = showPopup.showSelectImgPopup(Camera, ImagePicker, $scope);
- $scope.popup.isPopup = true;
- };
- $scope.disbandcomp = function () {
- showPopup.confirm('确定解散公司吗?', '确定', '取消').then(function (res) {
- if (res) {
- //解散
- showPopup.showLoading(1, '', false);
- CompManage.dismiss_comp($scope.data.id).then(function () {
- CheckComp();
- // alert('dismiss_comp success')
- }, function (error) {
- showPopup.hideLoading();
- alert('error disbandcomp:' + JSON.stringify(error));
- });
- }
- })
- };
- $scope.leavecomp = function () {
- showPopup.confirm('确定退出公司吗?', '确定', '取消').then(function (res) {
- if (res) {
- if ($scope.op == 1) { //admin
- if ($scope.rdata.compadmin.length > 1) { //admin count>=2
- //退出
- showPopup.showLoading(1, '', false);
- CompManage.leave_comp($scope.data.id).then(function () {
- CheckComp();
- }, function (error) {
- showPopup.hideLoading();
- alert('error leavecomp:' + JSON.stringify(error));
- })
- } else {
- showPopup.PopupWindow(0, '你是该公司唯一的管理员不允许退出!', false);
- }
- } else {
- //退出
- showPopup.showLoading(1, '', false, 20000);
- CompManage.leave_comp($scope.data.id).then(function () {
- CheckComp();
- }, function (error) {
- showPopup.hideLoading();
- alert('error leavecomp:' + JSON.stringify(error));
- });
- }
- }
- })
- };
- $scope.showeditpopup = function () {
- if ($scope.op == 0) {
- return;
- }
- $scope.editdata = _.clone($scope.data);
- var myPopup = $ionicPopup.show({
- template: '<div class="popup-edit-comp" ><input type="text" ng-model="editdata.name" ><label ></label></div>',
- title: '<div><h5>修改公司名称</h5></div>',
- scope: $scope,
- buttons: [{
- text: '取消',
- onTap: function () {
- return false;
- }
- }, {
- text: '<b>保存</b>',
- type: 'button-positive',
- onTap: function (e) {
- if (!$scope.editdata.name) {
- e.preventDefault();
- } else {
- return true;
- }
- }
- }]
- });
- myPopup.then(function (res) {
- if (res) {
- // alert('editComp');
- if ($scope.editdata.name != $scope.data.name) {
- CompManage.editComp($scope.editdata).then(function (data) {
- $scope.data.name = $scope.editdata.name;
- // alert(1);
- }, function (err) {
- alert('Error:' + JSON.stringify(err));
- });
- }
- }
- });
- };
- $scope.image_list = [];
- var ImagePicker = function () { //打开相册
- $scope.popup.optionsPopup.close();
- ImageManage.ImagePicker_getPictures(1).then(function (results) {
- if (results.length == 0) return;
- $q.all(results).then(function (res) {
- uploadimage(res[0]);
- })
- });
- };
- var Camera = function () {
- $scope.popup.optionsPopup.close();
- ImageManage.Camera_getPicture(true).then(function (result) {
- uploadimage(result);
- });
- };
- function CheckComp() {
- var compdata = CompManage.getComplist();
- compdata.splice(_.findIndex(compdata, {'id': $scope.data.id}), 1);
- if (compdata.length > 0 && global.user.compno == $scope.data.id) { //退出/解散当前登录的公司
- var comp = compdata[0];
- var password = global.user.password;
- CompManage.post_authcheck(global.user.im_usrid, comp.id).then(function (data) {
- global.user = data;
- global.user.password = password;
- showPopup.hideLoading();
- $ionicHistory.goBack();
- CompManage.store_user().then(function (data) {
- console.log(data);
- }, function (error) {
- console.log('store error:' + JSON.stringify(error));
- });
- });
- } else if (compdata.length == 0) { //用户没有公司时
- global.user.token = "";
- global.user.compno = "";
- global.user.compname = "";
- global.user.deptno = "";
- global.user.deptname = "";
- global.user.roleid = "";
- showPopup.hideLoading();
- $ionicHistory.goBack();
- CompManage.store_user().then(function (data) {
- console.log(JSON.stringify(data));
- }, function (error) {
- console.log('store error:' + JSON.stringify(error));
- });
- } else {
- showPopup.hideLoading();
- $ionicHistory.goBack();
- }
- }
- function uploadimage(result) {
- showPopup.showLoading(1, '', false, 20000);
- ImageManage.uploadImage(result, 'comp', $scope.data.id, 'complogo').then(function (res) {
- $q.all(res).then(function (res1) {
- showPopup.hideLoading();
- $scope.data.file_thumbnail_path = JSON.parse(res1[0].response).file_thumbnail_path;
- }, function (error) {
- showPopup.hideLoading();
- alert('upload error:' + JSON.stringify(error));
- })
- }, function (error) {
- alert('get token error:' + JSON.stringify(error));
- showPopup.hideLoading();
- });
- }
- })
- .controller('ApplyCheckCtrl', function ($scope, $ionicPlatform, $cordovaPreferences, $location, global, CompManage, showPopup) {
- var compid = $location.search().compid;
- global.fetch_user().then(function (data) {
- getAuditUsers();
- }, function (error) {
- alert(JSON.stringify(error));
- });
- $scope.check = function (user, op) { //todo:y=0;n=1
- // alert(JSON.stringify($scope.audituserlst))
- showPopup.showLoading(1, '正在提交', false);
- CompManage.auditUser(user, op, compid).then(function (data) {
- showPopup.hideLoading();
- $scope.audituserlst.splice(_.indexOf($scope.audituserlst, user), 1);
- }, function (err) {
- showPopup.hideLoading();
- alert(JSON.stringify(err));
- });
- };
- $scope.doRefresh = function () {
- getAuditUsers();
- };
- $scope.goBack = function () {
- global.goBack();
- }
- function getAuditUsers() {
- if (global.user.token != "") {
- CompManage.getUserAuditstatus(1, compid).then(function (data) {
- $scope.audituserlst = data;
- }, function (err) {
- alert(JSON.stringify(err));
- }).finally(function () {
- $scope.$broadcast('scroll.refreshComplete');
- });
- }
- }
- })
- .controller('ContactsCompanylstCtrl', function ($scope, $cordovaPreferences, $ionicPlatform, $state, global, Dept, CompManage) {
- $scope.complistdata = [];
- $scope.logourl = '../../../img/logo.png';
- $scope.loading = true;
- var beforeEnter = $scope.$on('$ionicView.beforeEnter', function () {
- Dept.setdeptlst([]);
- // alert(Dept.all().length);
- });
- $scope.init = function () {
- global.fetch_user().then(function (data) {
- if (global.user.token != "") {
- CompManage.get_Compdata().then(function (data) {
- // alert(JSON.stringify(data));
- _.each(data, function (c) {
- if (c.file_thumbnail_path == null) {
- c.file_thumbnail_path = $scope.logourl;
- }
- })
- $scope.complistdata = data;
- $scope.loading = false;
- });
- } else {
- $scope.loading = false;
- }
- }, function (error) {
- $scope.loading = false;
- alert(JSON.stringify(error));
- });
- };
- $scope.goBack = function () {
- global.goBack();
- }
- $scope.tocompuser = function (compid, compname) {
- $state.go('deptlst', {
- id: -1,
- name: compname,
- compid: compid
- })
- };
- function getcompdata() {
- if (global.user.token != "") {
- CompManage.get_Compdata().then(function (data) {
- $scope.complistdata = data;
- });
- }
- }
- })
- .controller('DeptCtrl', function ($scope, $state, $http, $stateParams, Dept, $ionicViewSwitcher) {
- $scope.deptlst = [];
- $scope.emplst = [];
- $scope.titleName = '';
- $scope.checked = false;
- $scope.titleName = $stateParams.name;
- $scope.deptid = -1;
- $scope.$on('$ionicView.beforeEnter', function () {
- $scope.deptid = setdeptid();
- if (Dept.all().length == 0) {
- $scope.loading = true;
- Dept.getDep($stateParams.compid).then(function (data) {
- $scope.deptid = setdeptid();
- data = _.filter(data, function (item) {
- return item.parent == $scope.deptid;
- });
- $scope.dept_data = data;
- $scope.deptlst = data;
- getemp();
- }, function (err) {
- $scope.loading = false;
- });
- } else {
- $scope.loading = false;
- var data = Dept.getChildDept($scope.deptid);
- $scope.dept_data = data;
- $scope.deptlst = data;
- getemp();
- }
- });
- function setdeptid() {
- var deptid = parseInt($stateParams.id);
- if (Dept.all().length > 0) {
- if (deptid < 0) {
- deptid = _.find(Dept.all(), function (item) {
- return item.level == 0
- }).id;
- }
- }
- return deptid;
- }
- function getemp() {
- Dept.getEmp($scope.deptid, $stateParams.compid).then(function (data) {
- console.log('user json:' + JSON.stringify(data));
- $scope.emplst = data;
- $scope.loading = false;
- }, function (err) {
- $scope.loading = false;
- alert(JSON.stringify(err));
- });
- }
- $scope.deptdisplay = function () {
- if ($scope.deptlst.length > 0) {
- return true;
- } else {
- return false;
- }
- };
- $scope.empdisplay = function () {
- if ($scope.emplst.length > 0) {
- return true;
- } else {
- return false;
- }
- };
- $scope.search = function () {
- $state.go('search');
- };
- $scope.editDep = function () {
- $state.go('editDep', {
- id: $scope.deptid,
- compid: $stateParams.compid,
- name: $stateParams.name
- });
- $ionicViewSwitcher.nextDirection("back");
- };
- $scope.cancel = function () {
- $state.go('addGroup2');
- };
- $scope.lookMsg = function (im_id, name, cellphone) {
- var data = {
- 'im_id': im_id,
- 'name': name,
- 'cellphone': cellphone
- }
- console.log(data)
- if (window.cordovaLinker != undefined) {
- window.cordovaLinker.startChat(data, function (s) {
- console.log(s);
- }, function (err) {
- console.error(err);
- });
- }
- };
- $scope.todept = function (dept) {
- $state.go('deptlst', {id: dept.id, name: dept.depname, compid: $stateParams.compid})
- };
- })
- .controller('EditDepCtrl', function ($scope, $ionicPopup, $stateParams, $timeout, $ionicHistory, Dept, showPopup, Tool) {
- $scope.deptlst = [];
- $scope.titleName = $stateParams.name;
- var del_deptids = [];
- var dept_data = [];
- var compid = $stateParams.compid;
- var beforeenter = $scope.$on('$ionicView.beforeEnter', function () {
- $scope.deptlst = angular.copy(Dept.getChildDept($stateParams.id));
- dept_data = angular.copy($scope.deptlst);
- });
- $scope.add = function () {
- $timeout(function () {
- $scope.deptlst.push({
- depname: '',
- parent_id: $stateParams.id
- })
- })
- };
- $scope.remove = function (dept, index) {
- if (_.has(dept, 'id')) del_deptids.push(dept.id);
- $scope.deptlst.splice(index, 1);
- };
- $scope.save = function () {
- var deptlst = _.filter($scope.deptlst, function (dep) {
- return Tool.trim(dep.depname).length > 0;
- });
- if (deptlst.length > _.uniq(_.pluck(deptlst, 'depname')).length) {
- showPopup.PopupWindow(0, '名称不能重复!', false);
- return;
- }
- var depts = _.partition(deptlst, 'id');
- var up_depts = _.map(_.difference(_.map(depts[0], JSON.stringify), _.map(dept_data, JSON.stringify)), JSON.parse);
- var add_depts = depts[1];
- if (del_deptids.length > 0 || add_depts.length > 0 || up_depts.length > 0) {
- showPopup.showLoading(1, '', false);
- $scope.isdisabled_ok = true;
- Dept.save(up_depts, del_deptids, add_depts, compid).then(function (data) {
- Dept.setdeptlst([]);
- $ionicHistory.goBack();
- }, function (err) {
- console.log(err);
- }).finally(function (f) {
- showPopup.hideLoading();
- $scope.isdisabled_ok = false;
- }); //修改、删除、添加;
- }
- };
- $scope.cancel = function () {
- if (JSON.stringify($scope.deptlst) != JSON.stringify(dept_data)) {
- showPopup.confirm('是否退出编辑?', '是', '否').then(function (res) {
- if (res) {
- $ionicHistory.goBack();
- }
- });
- } else $ionicHistory.goBack();
- };
- })
- .controller('PersonInfoCtrl', function ($scope, $state, $rootScope, $ionicPopup, $ionicModal, $q, $timeout, $ionicHistory, formatFilter, Dept, showPopup, global, ImageManage, Member) {
- $scope.personinfo = {value: ''};
- $scope.selectdatas = [{
- name: '女',
- id: 0
- }, {
- name: '男',
- id: 1
- }];
- var beforeEnter = $scope.$on("$ionicView.beforeEnter", function () {
- global.fetch_user().then(function (data) {
- $scope.loading = $scope.userinfo == undefined;
- Dept.getUsrDetail().then(function (data) {
- $scope.userinfo = angular.copy(data);
- $scope.userinfo.photo = data.photo == null ? '../../../img/panda.png' : data.photo;
- $scope.userinfo.compname = global.user.compname;
- $scope.userinfo.compno = global.user.compno;
- $scope.loading = false;
- }, function (err) {
- alert(JSON.stringify(err))
- });
- });
- $scope.popup = {
- isPopup: false,
- optionsPopup: null
- };
- });
- $scope.selectimg = function () {
- $scope.popup.optionsPopup = showPopup.showSelectImgPopup(Camera, ImagePicker, $scope);
- $scope.popup.isPopup = true;
- };
- $scope.editInfo = function (title, input_type, field_name, value) {
- $scope.userinfo[field_name] = value == undefined ? '' : value;
- $scope.personinfo.value = value == undefined ? '' : value;
- var template = formatFilter('<div rj-close-back-drop><label class="item item-input"> <input type="{0}" ng-model="personinfo.value" placeholder="输入{1}"></label></div>', input_type, title);
- $scope.popup.optionsPopup = $ionicPopup.show({
- template: template,
- title: '<div><h4>' + title + '</h4></div>',
- scope: $scope,
- buttons: [{
- text: '取消',
- onTap: function () {
- return false;
- }
- }, {
- text: '<b>保存</b>',
- type: 'button-positive',
- onTap: function (e) {
- if (!$scope.personinfo.value) e.preventDefault(); else return true;
- }
- }]
- });
- $scope.popup.optionsPopup.then(function (res) {
- if (res) {
- $scope.userinfo[field_name] = $scope.personinfo.value;
- $scope.updateInfo();
- $scope.popup.optionsPopup.close();
- }
- });
- $scope.popup.isPopup = true;
- };
- var ImagePicker = function () {
- $scope.popup.optionsPopup.close();
- ImageManage.ImagePicker_getPictures(1).then(function (results) {
- if (results.length == 0) return;
- $q.all(results).then(function (res) {
- uploadimg(res);
- })
- });
- };
- var Camera = function () {
- $scope.popup.optionsPopup.close();
- ImageManage.Camera_getPicture(true).then(function (result) {
- uploadimg([result])
- });
- };
- function uploadimg(files) {
- showPopup.showLoading(1, '', true);
- ImageManage.uploadImage(files, 'user', global.user.usrid, 'userfile').then(function (ps) {
- $q.all(ps).then(function (fs) {
- $scope.userinfo.photo = JSON.parse(fs[0].response).file_thumbnail_path;
- showPopup.hideLoading();
- }, function (err) {
- showPopup.hideLoading();
- })
- }, function (err) {
- showPopup.hideLoading();
- })
- }
- $scope.updateInfo = function () {
- showPopup.showLoading(1, '', false);
- Dept.putUsrInfo($scope.userinfo).then(function (res) {
- showPopup.hideLoading();
- }, function (err) {
- showPopup.hideLoading();
- })
- };
- $scope.$on("$destroy", function () {
- beforeEnter = null;
- Member.selecteddepts = [];
- if ($rootScope.commons.modal != null) $rootScope.commons.modal.remove();
- })
- })
- .controller('EditDeptDegreeCtrl', function ($scope, $state, $rootScope, $ionicHistory, $timeout, global, Member, showPopup, Dept, Tool) {
- $scope.userinfo = {};
- var beforeEnter = $scope.$on("$ionicView.beforeEnter", function () {
- global.fetch_user().then(function (data) {
- if (Member.selecteddepts.length > 0) {
- $scope.userinfo.depname = Member.selecteddepts[0].depname;
- $scope.userinfo.dept_id = Member.selecteddepts[0].id;
- } else $scope.userinfo = Tool.getTempData('userinfo');
- });
- });
- $scope.selectdept = function () {
- Member.routename = 'editdeptdegree';
- Member.titlename = '选择部门';
- Member.resourcemember = [{'id': $scope.userinfo.dept_id, 'depname': $scope.userinfo.depname}];
- Member.selecteddepts = [];
- $state.go('selectsingledept');
- };
- $scope.ok = function () {
- showPopup.showLoading(1, '', false);
- Dept.putUsrInfo($scope.userinfo).then(function (res) {
- showPopup.hideLoading();
- $ionicHistory.goBack();
- }, function (err) {
- showPopup.hideLoading();
- alert(JSON.stringify(err));
- })
- };
- $scope.cancel = function () {
- $ionicHistory.goBack();
- };
- $scope.$on("$destroy", function () {
- beforeEnter = null;
- Member.selecteddepts = [];
- })
- })
- ;
|