/* eslint no-alert: 0 */ 'use strict'; var app = angular.module('jwgl', [ 'ngRoute', 'mobile-angular-ui', 'mobile-angular-ui.gestures','ngSanitize','MassAutoComplete' ]); var $myscope=null; app.run(function($transform) { window.$transform = $transform; }); app.config(['$routeProvider','$locationProvider',function($routeProvider,$locationProvider) { $routeProvider.when('/', {templateUrl: 'login/loginform', params:{},reloadOnSearch: false}); $routeProvider.when('/document/:e_id/:flowid/:offset', {templateUrl: '/m/document/documentread/open.shtml', params:{e_id:"",flowid:"",offset:""},reloadOnSearch: false}); }]); app.controller('p2paddsave', function ($scope, $http) { $scope.formData={ e_title:"" } $scope.save = function() { formData = $scope.form; }; $scope.submitForm = function($url) { alert($url); var data=$scope.formData; console.log(JSON.stringify(data)); }; }); app.controller('MainController', function($rootScope, $scope,$sce,$http,$compile,SharedState,$location) { $myscope=$scope; $scope.select_value=""; function autocomplete_exec(term) { var q = term.toLowerCase().trim(); var select_url=$("#select_url").val(); var promise =$http({ method:'post', url:select_url, data:{key:q}, headers: {'Content-Type': 'application/x-www-form-urlencoded' }, transformRequest: function(obj) { var str = []; for (var s in obj) {str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));} return str.join("&"); } }); return promise.then(function (resut) { var data = resut.data; var results = []; if(data.success=="success"){ for (var i = 0; i < data.lists.length && results.length < 10; i++) { results.push({ label: data.lists[i].text, value: data.lists[i].text,selvalue:data.lists[i].id }); } } return results; }); } $scope.autocomplete_options = { suggest: autocomplete_exec, on_select: function (selected) { $scope.p2pdata.select_value = selected.selvalue; } }; $rootScope.searchkey = function($url) { $http({ method:'post', url:$url, data:$scope.p2pdata, headers: {'Content-Type': 'application/x-www-form-urlencoded' }, transformRequest: function(obj) { var str = []; for (var s in obj) {str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));} return str.join("&"); } }).success(function(data){ if(data.success=="success") location.href="/m?url=/m/"+data.backurl; else alert(data.msg); }); } ; $rootScope.pagego = function($url) { alert($url); }; $rootScope.getusers = function($e_deptid) { var $url="/m/sysman/infofeed/getuserformultiselect.shtml?scope="+$e_deptid; $http.get($url).success(function (data) { $scope.users = data; }); } ; $scope.p2pdata={ sendsms:0, e_fujian:'', select_value:'' } $scope.lform={ user:"", pass:'', usertype:'stu' } $rootScope.p2paddsave = function($url) { $http({ method:'post', url:$url, data:$scope.p2pdata, headers: {'Content-Type': 'application/x-www-form-urlencoded' }, transformRequest: function(obj) { var str = []; for (var s in obj) {str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));} return str.join("&"); } }).success(function(data){ alert(data.msg); try { if (typeof (data.backurl) != "undefined") { location.href="/m?url=/m/"+data.backurl; } } catch (e) { } }); } ; $scope.uploadfj = function($url,$fjfield,$fjlist) { var fd = new FormData(); var file = document.querySelector('input[type=file]').files[0]; fd.append('fujianfeed', file); $http({ method:'POST', url:$url, data: fd, headers: {'Content-Type':undefined}, transformRequest: angular.identity }) .success( function ( data ) { if(data.success=="success") { var template = angular.element('
'+data.filename+'
'); angular.element("#"+$fjlist).append($compile(template)($scope)); if($scope.p2pdata.e_fujian=="") $scope.p2pdata.e_fujian=data.fileid; else $scope.p2pdata.e_fujian=$scope.p2pdata.e_fujian+data.fileid; /*if($("#"+$fjfield).val()=="") $("#"+$fjfield).val(data.fileid); else $("#"+$fjfield).val($("#"+$fjfield).val()+","+data.fileid);*/ $rootScope.Ui.turnOff('mymodal'); } else { alert(data.msg); } }); }; $scope.swiped = function(direction) { alert('Swiped ' + direction); }; $scope.userAgent = navigator.userAgent; $rootScope.$on('$routeChangeStart', function() { $rootScope.loading = true; }); $rootScope.$on('$routeChangeSuccess', function() { $rootScope.loading = false; }); $scope.sendsms = true; $scope.login= function($url,$utype) { $http({ method:'post', url:$url+"?usertype="+$utype, data:$scope.lform, headers: {'Content-Type': 'application/x-www-form-urlencoded' }, transformRequest: function(obj) { var str = []; for (var s in obj) {str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));} return str.join("&"); } }).success(function(data){ if(data.success=="success") location.href="/m/"; else alert(data.message); }); }; });