var starter=angular.module("starter",["ionic","ngResource","underscore","ngCordova","pascalprecht.translate"]);starter.run(["$ionicPlatform","$rootScope","$http","formatFilter","$q","$cordovaPreferences","$ionicLoading","$timeout","$ionicHistory","$cordovaKeyboard","$translate","global","cfg","showPopup",function(e,t,n,o,i,r,a,l,c,s,u,d,p,m){function f(e){cordova.plugins.Keyboard.isVisible=!0,l(function(){cordova.plugins.Keyboard.isVisible=!1},100)}t.commons={refresh:!1,upload_maxcount:10,bigImage:void 0,modal:void 0,goBackIsDisable:void 0,isShowPopup:void 0,fun:null},e.ready(function(){window.cordova&&window.cordova.plugins&&window.cordova.plugins.Keyboard&&(cordova.plugins.Keyboard.hideKeyboardAccessoryBar(!0),cordova.plugins.Keyboard.disableScroll(!0)),window.StatusBar&&StatusBar.styleDefault(),window.cordovaLinker&&window.cordovaLinker.loadFinished("",function(){},function(){}),void 0!==navigator.globalization&&navigator.globalization.getPreferredLanguage(function(e){var t=e.value.split("-")[0];switch("TW"==e.value.split("-")[1]&&(t=e.value),t){case"zh-TW":t="locate-zh_tw";break;case"en":t="locate-en_us";break;case"zh":default:t="locate-zh_cn"}u.use(t).then(function(e){},function(e){})})}),d.fetch_user=function(){var t=i.defer();return d.user&&d.user.token?usergot(d.user,t):"win32"==ionic.Platform.platform()||"linux"==ionic.Platform.platform()?n.post(o("{0}authcheck/",p.api),"imid=zPayHMi6s&password=123456",{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(e){usergot(e.data,t)},function(e){t.reject(e)}):e.ready(function(){r.fetch("user").success(function(e){usergot(ionic.Platform.isAndroid()?JSON.parse(e):e,t)}).error(function(e){t.reject(e)})}),t.promise},usergot=function(e,t){d.user=e,e.cfg&&(d.api=e.cfg.api),t.resolve(e)},d.fetch_user(),d.goBack=function(){void 0!=window.cordovaLinker&&(c.backView()?c.goBack():window.cordovaLinker.goBack(1,function(e){},function(e){}))},window.addEventListener("native.keyboardhide",f),e.registerBackButtonAction(function(e){l(function(){if(t.commons.isShowPopup)m.hideLoading();else{if(t.commons.goBackIsDisable)return!1;s.isVisible()?s.close():t.commons.bigImage?null==t.commons.fun?t.commons.bigImage=!1:(t.commons.fun(),t.commons.fun=null):null!=t.commons.modal?null==t.commons.fun?(t.commons.modal.hide(),t.commons.modal=null):(t.commons.fun(),t.commons.fun=null):c.backView()?null==t.commons.fun?c.goBack():(t.commons.fun(),t.commons.fun=null):d.goBack()}return!1})},201);var g;void 0!=(g=window.localStorage.getItem("global.user"))&&(d.user=JSON.parse(g))}]).config(["$stateProvider","$urlRouterProvider","$ionicConfigProvider","$httpProvider","$provide","$translateProvider","$resourceProvider","cfg",function(e,t,n,o,i,r,a,l){n.platform.ios.tabs.style("standard"),n.platform.ios.tabs.position("bottom"),n.platform.android.tabs.style("standard"),n.platform.android.tabs.position("bottom"),n.platform.ios.navBar.alignTitle("center"),n.platform.android.navBar.alignTitle("center"),n.platform.ios.backButton.previousTitleText("").icon("ion-ios-arrow-thin-left"),n.platform.android.backButton.previousTitleText("").icon("ion-android-arrow-back"),n.platform.ios.views.transition("ios"),n.platform.android.views.transition("android");var c=new RegExp(".(html|js|css|png|jpg)$","i"),s=function(e){return c.test(e)};e.state("selectmember",{url:"/selectmember",templateUrl:"/templates/common/selectmember.html",controller:"SelectMemberCtrl"}).state("selectsinglemember",{url:"/selectsinglemember",templateUrl:"/templates/common/selectsinglemember.html",controller:"SelectSingleMemberCtrl"}).state("selectdept",{url:"/selectdept/:id",templateUrl:"/templates/common/selectdept.html",controller:"SelectDeptCtrl"}).state("fieldtype",{url:"/fieldtype/:id",templateUrl:"/templates/common/fieldtype.html",controller:"FormFieldTypeCtrl"}).state("transfer",{url:"/transfer/:module/:id",templateUrl:"/templates/common/transfer.html",controller:"TransferCtrl"}).state("selectsingledept",{url:"/selectsingledept",templateUrl:"/templates/common/selectsingledept.html",controller:"SelectSingleDeptCtrl"}),t.otherwise("/index"),r.useStaticFilesLoader({prefix:"/i18n/",suffix:".json"}),o.interceptors.push(["$q","cfg","global",function(e,t,n){return{request:function(e){return s(e.url)||!n.refresh&&!n.debug||(e.url+=(-1===e.url.indexOf("?")?"?":"&")+"v="+Date.now(),n.refresh&&(n.refresh=!1)),(e.url.startsWith(t.api)||0==e.url.indexOf(n.api))&&(e.url.startsWith(t.api)&&(e.url=n.api+e.url),n.user.token&&(e.headers.authorization="Token "+n.user.token)),e.timeout=1e4,e},responseError:function(t){return e.reject(t)}}}]),a.defaults.stripTrailingSlashes=!1,a.defaults.actions.update={method:"PUT",params:{id:"@id"}},a.defaults.actions.patch={method:"PATCH"}}]).constant("cfg",{api:"/api/"}).value("global",{user:{usrid:"",token:"",usrname:"",compno:"",compname:"",deptno:"",deptname:"",roleid:"",im_usrid:"",cellphone:"",password:""},api:"",debug:!0,refresh:!1}),_.mixin({diff:function(e,t){var n={C:[],D:[],U:[]};return list_new=_.pluck(e,"id"),list_old=_.pluck(t,"id"),n.D=_.difference(list_old,list_new).join(","),n.C=_.filter(e,function(e){return void 0==e.id}),n.U=_.map(_.filter(e,function(e){return e.isModified&&void 0!=e.id}),_.clone),_.each(n.U,function(e){delete e.isModified}),_.each(n.C,function(e){delete e.isModified}),n}}),"function"!=typeof String.prototype.startsWith&&(String.prototype.startsWith=function(e){return 0===this.indexOf(e)}),starter.controller("SelectParentCtrl",["$scope","$state","Member",function(e,t,n){e.deptlst=[],e.emplst=[],e.index=0,e.isUp=!1,e.deptid=1,e.titlename=n.titlename,e.selectedemplst=n.selectedemplst,e.disabled=n.disabled,e.showall=n.showall,e.showgroup=n.showgroup,e.loading=!0,e.leftbtn=[{text:"取消",click:"cancel"},{text:"上一层",click:"up"}]}]).controller("SelectMemberCtrl",["$scope","$state","$ionicHistory","$rootScope","$ionicModal","$timeout","$controller","Dept","Member",function(e,t,n,o,i,r,a,l,c){function s(t){g(e.deptlst),c.selectedemplst=[],c.disabled||(e.selectedemplst=e.selectedemplst.concat(t),c.selectedemplst=e.selectedemplst),p()}function u(t){l.getEmp(t).then(function(n){c.member[t.toString()]=angular.copy(n),e.emplst=n,m(),e.loading=!1})}function d(t){c.member[t.toString()]?k(t):(e.loading=!0,l.getEmp(t).then(function(n){c.member[t.toString()]=angular.copy(n),k(t),e.loading=!1},function(t){e.loading=!1}))}function p(){e.selectcount=e.selectedemplst.length>0?"("+e.selectedemplst.length+")":""}function m(){_.each(e.emplst,function(t){t.selected=!1,t.disabled=!1,t.depname=w.depname,f(t,c.resourcemember,!0),f(t,c.unenabledata,!1),void 0!=_.find(e.selectedemplst,{user_id:t.user_id})&&(t.selected=!0)})}function f(e,t,n){void 0!=_.find(t,{user_id:e.user_id})&&(e.disabled=e.selected=!0,!c.disabled&&n&&(e.disabled=!1))}function g(e){_.each(e,function(e){e.isShow=h(e)})}function h(e){return!(0==l.getChildDept(e.id).length)}var v=(a("SelectParentCtrl",{$scope:e}),i.fromTemplateUrl("/templates/common/modal-selectgroup.html",{scope:e,animation:"slide-in-right"})),b=null;o.commons.goBackIsDisable=!0;e.$on("$ionicView.beforeEnter",function(){0!=c.homerenderdata.length?(e.loading=!1,_.each(c.homerenderdata,function(t){e.deptlst.push(t)}),s(c.resourcemember)):l.getDep().then(function(t){b=_.find(t,function(e){return null==e.parent}),u(b.id),t=_.filter(t,function(e){return e.parent==b.id}),e.deptlst=t,s(c.resourcemember)},function(e){})});e.changeindex=function(t,n){e.index=t,e.deptid=n},e.change=function(t){t.selected?(e.selectedemplst.push(t),c.selectedemplst=e.selectedemplst):(e.selectedemplst=_.filter(e.selectedemplst,function(e){return e.user_id!=parseInt(t.user_id)}),c.selectedemplst=e.selectedemplst),p()},e.up=function(){var t=void 0;c.homerenderdata.length>0&&(t=_.find(c.homerenderdata,function(t){return t.id==parseInt(e.deptid)})),void 0!=t?(e.deptlst=e.deptlst.concat(c.homerenderdata),e.emplst=[],e.index=0):(t=_.find(l.all(),function(t){return t.id==parseInt(e.deptid)}),d(t.parent))},e.cancel=function(){c.selectedemplst=[],c.dialogresult=0,""!=c.cancelroutename?t.go(c.cancelroutename,c.cancelrouteparams):n.goBack()};var w={};e.changedept=function(e){w=e,d(e.id)},e.ok=function(){c.dialogresult=1,c.all=0,""!=c.routename?t.go(c.routename,c.routeparams):n.goBack()},e.selectAll=function(){c.all=1,t.go(c.routename,c.routeparams)},e.back=function(){null!=o.commons.modal&&o.commons.modal.hide()},e.toselectgroup=function(){v.then(function(e){o.commons.modal=e,o.commons.modal.show()})},e.$on("$destroy",function(){o.commons.goBackIsDisable=!1,c.member={}});var k=function(t){e.deptlst=l.getChildDept(t),g(e.deptlst),e.emplst=c.member[t.toString()],m(),e.deptid=t,e.index=b&&t==b.id?0:1}}]).controller("SelectSingleMemberCtrl",["$scope","$ionicHistory","$state","$controller","Dept","Member",function(e,t,n,o,i,r){function a(t){i.getEmp(t).then(function(n){r.member[t.toString()]=angular.copy(n),e.emplst=n,c(),e.loading=!1})}function l(t){r.member[t.toString()]?m(t):(e.loading=!0,i.getEmp(t).then(function(n){r.member[t.toString()]=angular.copy(n),m(t),e.loading=!1}))}function c(){_.each(e.emplst,function(t){t.selected=!1,t.disabled=!1,t.depname=p.depname,_.each(r.resourcemember,function(e){e.user_id==parseInt(t.user_id)&&(t.disabled=!0,t.selected=!0,r.disabled||(t.disabled=!1))}),_.each(e.selectedemplst,function(e){e.user_id==t.user_id&&(t.selected=!0)})})}function s(e){_.each(e,function(e){e.isShow=u(e)})}function u(e){return 0!=i.getChildDept(e.id).length}var d=(o("SelectParentCtrl",{$scope:e}),{});e.init=function(){i.getDep().then(function(t){d=_.find(t,function(e){return null==e.parent}),a(d.id),t=_.filter(t,function(e){return e.parent==d.id}),e.deptlst=t,s(e.deptlst)})},e.changeindex=function(t,n){e.index=t,e.deptid=n},e.change=function(e){r.dialogresult=1,r.selectedemplst.push(e),""!=r.routename?n.go(r.routename,r.routeparams):t.goBack()},e.up=function(){l(_.find(i.all(),function(t){return t.id==parseInt(e.deptid)}).parent)},e.cancel=function(){r.dialogresult=0,r.selectedemplst=[],t.goBack()};var p={};e.changedept=function(e){p=e,l(e.id)},e.deptdisplay=function(){return e.deptlst.length>0};var m=function(t){e.deptlst=i.getChildDept(t),s(e.deptlst),e.emplst=r.member[t.toString()],c(),e.deptid=t,e.index=d&&t==d.id?0:1};e.$on("$destroy",function(){r.member={}})}]).controller("SelectDeptCtrl",["$scope","$state","$ionicHistory","$timeout","$controller","Dept","Member",function(e,t,n,o,i,r,a){function l(n){_.each(n,function(e){e.selected=!1,e.isdisabled=!1,e.ishide=!1,e.disableddesc="",e.isShow=u(e),3==a.datatype?null!=e.diarymobid&&t.params.id!=e.diarymobid&&(e.disableddesc="(已设置)",e.isdisabled=!0):4==a.datatype&&null!=e.workatdsetid&&t.params.id!=e.workatdsetid&&(e.disableddesc="(已设置)",e.isdisabled=!0),_.find(a.resourcemember,function(t){return t.id==e.id})&&(e.selected=!0)}),e.deptlst=n}function c(t){var n=r.getChildDept(t);n.length>0&&(d=t,t==p.id?e.index=0:e.index=1,l(n))}function s(){a.selecteddepts.length>0?e.selectcount="("+a.selecteddepts.length+")":e.selectcount=""}function u(e){return 0!=r.getChildDept(e.id).length}i("SelectParentCtrl",{$scope:e});e.id=t.params.id,e.selecteddepts=a.selecteddepts,e.selectdeptcount="",e.isallcheck=a.isallcheck,e.flag=0,e.isAll=!1;var d=1,p=null;e.isAllCheck=function(){a.dialogresult=1,e.isallcheck=!e.isallcheck,a.isallcheck=e.isallcheck,a.isallcheck&&(a.selecteddepts=[],""!=a.routename?t.go(a.routename,a.routeparams):n.goBack())},e.cancel=function(){a.dialogresult=0,a.selecteddepts=[],n.goBack()},e.ok=function(){a.dialogresult=1,a.all=0,""!=a.routename?t.go(a.routename,a.routeparams):n.goBack()},e.up=function(){0==e.index&&a.showall&&(e.showall=!0),c(_.find(r.all(),function(e){return e.id==parseInt(d)}).parent)},e.change=function(t){a.isallcheck&&(e.isallcheck=!e.isallcheck,a.isallcheck=e.isallcheck),t.selected?(e.selecteddepts.push(t),a.selecteddepts=e.selecteddepts):(e.selecteddepts=_.filter(e.selecteddepts,function(e){return e.id!=parseInt(t.id)}),a.selecteddepts=e.selecteddepts),s()},e.tochilddept=function(t){e.index==p.id&&(e.showall=!1),c(t.id)};var m=e.$on("$ionicView.beforeEnter",function(){e.loading=!0,r.getDep().then(function(t){p=_.find(t,function(e){return null==e.parent}),a.selecteddepts=a.resourcemember,e.selecteddepts=a.selecteddepts,3==a.datatype?_.each(t,function(t){null!=t.diarymobid&&e.flag++,1==t.id&&null!=t.diarymobid&&(e.isAll=!0)}):4==a.datatype&&_.each(t,function(t){null!=t.workatdsetid&&e.flag++,1==t.id&&null!=t.workatdsetid&&(e.isAll=!0)}),-1==e.id?(1==e.flag&&e.isAll?e.showall=!0:e.flag>=1&&!e.isAll&&(e.showall=!1),e.flag>=1&&e.flag+1==t.length&&!e.isAll&&(e.isAll=!0)):1==e.flag&&e.isAll?e.showall=!0:e.flag>=1&&!e.isAll&&0==a.resourcemember.length?e.showall=!0:e.flag>=1&&!e.isAll&&e.flag==a.resourcemember.length?e.showall=!0:e.flag>=1&&!e.isAll&&e.flag!=a.resourcemember.length&&(e.showall=!1),l(_.filter(t,function(e){return 1===e.level})),a.disabled||(_.each(a.resourcemember,function(t){e.selecteddepts.push(t)}),a.selecteddepts=e.selecteddepts),s()}).finally(function(){e.loading=!1})});e.$on("$destroy",function(){m=null})}]).controller("SelectSingleDeptCtrl",["$scope","$state","$ionicHistory","$timeout","Dept","Member",function(e,t,n,o,i,r){function a(t){var n=i.getChildDept(t);if(n.length>0){l=t,e.index=t==c.id?0:1;var o=_.find(n,{id:e.id});void 0!=o&&(o.selected=void 0!=o),e.deptlst=n}}e.titlename=r.titlename;var l=1,c=null;e.leftbtn=[{text:"取消",click:"cancel"},{text:"上一层",click:"up"}];var s=e.$on("$ionicView.beforeEnter",function(){e.loading=!0,i.getDep().then(function(t){c=_.find(t,{parent:null}),e.id=r.resourcemember.length>0?r.resourcemember[0].id:null,a(c.id)}).finally(function(){e.loading=!1})});e.cancel=function(){r.dialogresult=0,r.selecteddepts=[],n.goBack()},e.up=function(){a(_.find(i.all(),{id:l}).parent)},e.change=function(e){r.selecteddepts=[],e.selected&&(r.selecteddepts.push(e),""==r.routename?n.goBack():t.go(r.routename,r.routeparams))},e.tochilddept=function(e){a(e.id)},e.is_showright=function(e){return i.getChildDept(e.id).length>0},e.$on("$destroy",function(){s=null})}]).controller("TransferCtrl",["$scope","$state","$stateParams","$ionicPopup","$ionicHistory","global","Member",function(e,t,n,o,i,r,a){function l(){if(a.selectedemplst.length>0){if(e.memberlist.push(r.user.imusrid),_.each(a.selectedemplst,function(t){e.memberlist.push(t.im_usrid)}),a.selectedemplst=[],void 0!=window.cordovaLinker){var t={name:"讨论组",ids:[]};t.ids=e.memberlist,window.cordovaLinker.discuss(t,function(e){o.confirm({title:"