qrcode.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. 'use strict';
  2. app.directive('qrcanvas', function($modal) {
  3. return {
  4. restrict: 'EA',
  5. templateUrl: 'assets/views/means/tpl/print.html',
  6. // controller: 'meansCtrl',
  7. link: function(scope, element, attrs) {
  8. scope.stamp = function() {
  9. var modalInstance = $modal.open({
  10. templateUrl: 'assets/views/means/tpl/uuidprint.html',
  11. controller: function($scope, $modalInstance) {
  12. // $scope.stamp = function(){
  13. // $scope.uuid={};
  14. $scope.stampable = true;
  15. $scope.selected = scope.selected;
  16. // $scope.stampables=[];
  17. setInterval(function() {
  18. if ($scope.stampable) {
  19. $scope.stampable = false;
  20. angular.forEach(scope.selected.items, function(item) {
  21. function $(selector) {
  22. return document.querySelector(selector);
  23. }
  24. $scope.q = $('.qrcanvas');
  25. var canvas;
  26. var colorIn = "#191970";
  27. var colorOut = "#cd5c5c";
  28. var colorFore = "#4169e1";
  29. var colorBack = "#ffffff";
  30. var options = {
  31. cellSize: 4,
  32. foreground: [
  33. // foreground color
  34. { style: colorFore },
  35. // outer squares of the positioner
  36. { row: 0, rows: 7, col: 0, cols: 7, style: colorOut },
  37. { row: -7, rows: 7, col: 0, cols: 7, style: colorOut },
  38. { row: 0, rows: 7, col: -7, cols: 7, style: colorOut },
  39. // inner squares of the positioner
  40. { row: 2, rows: 3, col: 2, cols: 3, style: colorIn },
  41. { row: -5, rows: 3, col: 2, cols: 3, style: colorIn },
  42. { row: 2, rows: 3, col: -5, cols: 3, style: colorIn },
  43. ],
  44. background: colorBack,
  45. data: [item.uuid, item.createtime],
  46. typeNumber: 1,
  47. };
  48. var effect = 'none';
  49. if (effect !== 'none') {
  50. options.effect = { key: effect, value: 1 };
  51. if (effect === 'image') {
  52. options.background = [colorBack, effectImg];
  53. }
  54. }
  55. // {{$index}} > 0 && {{$index}} % 2 == 0 ? 'page-break-before:always' : 'background:red'
  56. // $scope.q.tital=item.uuid;
  57. // $scope.q.textContent=item.uuid;
  58. options.reuseCanvas = canvas;
  59. canvas = qrgen.canvas(options);
  60. // canvas.outerText=item.uuid;
  61. // $scope.q.innerHTML=$scope.q.innerHTML+"<div class='col-md-2'>"+item.uuid+"</div>"
  62. $scope.q.appendChild(canvas);
  63. angular.element("canvas").addClass("canvasclass")
  64. // $scope.q.innerHTML=$scope.q.innerHTML+"<div class='col-md-2'>"+item.uuid+"</div>"
  65. })
  66. } else {
  67. }
  68. }, 500);
  69. $scope.ok = function() {
  70. // window.print();
  71. $modalInstance.dismiss('cancel');
  72. };
  73. $scope.cancel = function() {
  74. $modalInstance.dismiss('cancel');
  75. };
  76. },
  77. size: 'lg'
  78. })
  79. };
  80. }
  81. }
  82. })