123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- app.controller('StdReportCtl', [ '$rootScope', '$scope', '$http', '$location', '$q', '$timeout', '$sce', '$compile', function($rootScope, $scope, $http, $location, $q, $timeout, $sce, $compile) {
- $scope.nextStd = undefined;
- $scope.auto = false;//是否自动打印
- $scope.queryRet = false;//查询考生是否返回
- $scope.foot_date = "";
-
- //查询pad mac
- $rootScope.ajaxRequest({
- url : '../std/report/padmac/fresh.htm',
- data : {}
- }, function(response) {
- var macArray = response.map["padMacArray"];
- $scope.foot_date = response.map["foot_date"];
- if (macArray) {
- for (var i=0; i<macArray.length; i++) {
- var padmac = macArray[i].ipad_mac;
- var short = padmac.substring(0,4);
- $("#padDiv").append('<input type="checkbox" name="ipad_mac" value="'+ padmac +'">' + short + ' ');
- }
- $("#padDiv").append($compile('<button id="autobtn" ng-click="autoPrint();" style="height: 30px; width:150px;"><span>开始自动打印</span></button> ')($scope));
- }
- });
-
- //回车搜索查询下一个考生
- $scope.changeSearchNext = function($event) {
- if ($event.keyCode == 13) {
- $scope.searchNext();
- }
- }
-
- //查询下一个考生
- $scope.searchNext = function() {
- var macArr = document.getElementsByName('ipad_mac');
- var macStr="";
- var i;
- debugger;
- for (i=0; i<macArr.length; i++) {
- if (macArr[i].checked) {
- macStr = macStr + "'" + macArr[i].value + "',";
- }
- }
- if (macArr.length > 0){
- macStr = macStr.substr(0, macStr.length - 1);
- }
-
- debugger;
- var ret = false;
-
- //查询考生数据
- $rootScope.ajaxRequest({
- url : '../std/report/next.htm',
- data : {
- cert_id : $("#cert_id").val(),
- ipad_mac : macStr
-
- }
- }, function(response) {
- if (response.map) {
- $scope.nextStd = response.map;
- $scope.queryRet = true;
- //自动打印处理
- if($scope.auto) {
- debugger;
- //调用打印
- $scope.print();
- if (!$scope.timer) {
- //定时调用下一个
- $scope.timer = setInterval(function() {
- $scope.$apply(function() {
- $scope.searchNext();
- });
- }, 5000);
- }
- }
-
- } else {
- if ($.trim($("#cert_id").val()) == "") {
- } else {
- alert("没有找到该身份证对应的考生.");
- }
- //没找到考生,继续轮询
- $scope.searchNext();
- }
- });
-
- //检查考生数据是否返回
- /*$scope.retVal = setInterval(function() {
- $scope.$apply(function() {
- if ($scope.queryRet) {//$scope.nextStd
- $scope.queryRet = false;
- clearTimeout($scope.retVal);
- //go to print
- //自动打印处理
- if($scope.auto) {
- //debugger;
- //调用打印
- $scope.print();
- if (!$scope.timer) {
- //定时调用下一个
- $scope.timer = setInterval(function() {
- $scope.$apply(function() {
- $scope.searchNext();
- });
- }, 5000);
- }
- }
- }
- });
- }, 100);*/
- }
-
- //打印
- $scope.print = function() {
- if (!$scope.nextStd) {
- alert("请先搜索考生!");
- return;
- }
- if ($.trim($("#cert_id").val()) != "") {
- $("#cert_id").val("");
- }
- //打印窗口
- var win = window.open("print.html", null, " height=600,width=850, Left=300px,Top=20px, menubar=no,titlebar=no,scrollbar=no,toolbar=no, status=no,location=no");
- $scope.timer2 = setInterval(function() {
- $scope.$apply(function() {
- if (win.document.getElementById("div_print")) {
- clearTimeout($scope.timer2);
- win.document.getElementById("div_print").innerHTML = $("#main").html();
- win.print2();
- win.close();
- //修改打印时间
- $scope.updatePrintTime($scope.nextStd.cert_id);
- }
- });
- }, 100);
- }
-
- //自动连续打印
- $scope.autoPrint = function() {
- if(!$scope.auto) {
- $("#cert_id").val("");
- $("#autobtn").html("正在自动打印...");
- $scope.auto = true;
- $scope.searchNext();
- } else {
- if ($scope.timer) {
- clearTimeout($scope.timer);
- }
- $("#autobtn").html("开始自动打印");
- $scope.auto = false;
- }
- }
-
- //修改打印时间
- $scope.updatePrintTime = function(cert_id_val) {
- //alert("修改已打印....");
- $rootScope.ajaxRequest({
- url : '../std/report/print.htm',
- data : {
- cert_id : cert_id_val
- }
- }, function(response) {
-
- });
- }
-
- $timeout(function() {
- $('#login_name').focus();
- }, 100);
- } ]);
|