CapturerWindow.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /**
  2. * 高拍仪上传窗口
  3. */
  4. function CapturerWindow(){}
  5. CapturerWindow.prototype = {
  6. construct: CapturerWindow,
  7. init: function(){
  8. var self = this;
  9. var initParam = {
  10. domId : "capturerContainer",
  11. locationPath : "C:\\ycsCache\\",
  12. produceFilenameFunc : dataUtil.getGuid
  13. }
  14. var capturer = Capturer.config(initParam);
  15. this._capturer = capturer;
  16. eventProxy.on('设备切换',function(data){
  17. var scanType = data['scanType'];
  18. if(scanType == 'capturer'){
  19. self.show();
  20. }
  21. });
  22. eventProxy.on('扫描开始',function(data){
  23. var scanType = data['scanType'];
  24. if(scanType == 'capturer'){
  25. //uploadType
  26. buttonGroup.setUploadType('scan');
  27. //切换显示
  28. eventProxy.emit('设备切换',{
  29. scanType: scanType
  30. });
  31. }
  32. });
  33. eventProxy.on('扫描完成',function(data){
  34. var scanType = data['scanType'];
  35. if(scanType == 'capturer'){
  36. //关闭图片预览、打开扫描预览
  37. $('.capturerWindow #capturerPreview').hide().siblings().show();
  38. //切换按钮状态
  39. $('.capturerWindow input[name="scan"]').show();
  40. $('.capturerWindow input[name="switch"]').show();
  41. $('.capturerWindow input[name="rotate"]').show();
  42. $('.capturerWindow input[name="save"]').hide();
  43. $('.capturerWindow input[name="back"]').hide();
  44. //刷新收单资料明细
  45. var sdzlid = data['sdzlid'];
  46. if(sdzlid){
  47. eventProxy.emit('收单资料选中',{
  48. sdzlid: sdzlid,
  49. index: -1
  50. });
  51. }
  52. }
  53. });
  54. eventProxy.on('重扫开始',function(data){
  55. var scanType = data['scanType'];
  56. if(scanType == 'capturer'){
  57. //修改uploadType
  58. buttonGroup.setUploadType('rescan');
  59. //切换显示
  60. eventProxy.emit('设备切换',{
  61. scanType: scanType
  62. });
  63. }
  64. });
  65. eventProxy.on('重扫完成',function(data){
  66. var scanType = data['scanType'];
  67. if(scanType == 'capturer'){
  68. //关闭图片预览、打开扫描预览
  69. $('.capturerWindow #capturerPreview').hide().siblings().show();
  70. //切换按钮状态
  71. $('.capturerWindow input[name="scan"]').show();
  72. $('.capturerWindow input[name="switch"]').show();
  73. $('.capturerWindow input[name="rotate"]').show();
  74. $('.capturerWindow input[name="save"]').hide();
  75. $('.capturerWindow input[name="back"]').hide();
  76. //刷新收单资料明细
  77. var sdzlid = data['sdzlid'];
  78. if(sdzlid){
  79. eventProxy.emit('收单资料选中',{
  80. sdzlid: sdzlid,
  81. index: -1
  82. });
  83. }
  84. }
  85. });
  86. $('.capturerWindow input[name="scan"]').click(function(){
  87. if(capturer.rescan()){
  88. var filepathArray = capturer.getFilePath();
  89. var filepath = filepathArray[0];
  90. $('.capturerWindow #capturerPreview').show().siblings().hide();
  91. $('.capturerWindow input[name="scan"]').hide();
  92. $('.capturerWindow input[name="switch"]').hide();
  93. $('.capturerWindow input[name="rotate"]').hide();
  94. $('.capturerWindow input[name="save"]').show();
  95. $('.capturerWindow input[name="back"]').show();
  96. capturerPreview.Command("LoadPicture","0,"+filepath.split('\\').join('//'));
  97. }else{
  98. alert('扫描错误');
  99. }
  100. });
  101. //保存
  102. $('.capturerWindow input[name="save"]').click(function(){
  103. var filepathArray = capturer.getFilePath();
  104. if(!menuTree.getSelectedItem() || !menuTree.getSelectedItem()['key']){
  105. alert("请选择需要保存的资料类别");
  106. return;
  107. }
  108. var sdzlid = menuTree.getSelectedItem()['key']==null?null:menuTree.getSelectedItem()['key'];
  109. var sdzlmxid = imageSlider.getSelectedItem()==null?null:imageSlider.getSelectedItem()['key'];
  110. var uploadType = buttonGroup.getUploadType();
  111. var fileList = new Array();
  112. for(var i=0;i<filepathArray.length;i++){
  113. var filepath = filepathArray[i];
  114. //上传文件
  115. if(filepath != null && filepath != ''){
  116. var fileInfo = {
  117. 'sdzlmxid': sdzlmxid,
  118. 'filepath': filepath
  119. };
  120. fileList.push(fileInfo);
  121. }
  122. }
  123. //上传文件
  124. dataUtil.uploadFile(sdzlid,uploadType,fileList);
  125. });
  126. //切换镜头按钮
  127. $('.capturerWindow input[name="switch"]').click(function(){
  128. capturer.switchCamera();
  129. });
  130. //旋转镜头按钮
  131. $('.capturerWindow input[name="rotate"]').click(function(){
  132. capturer.rotateCamera();
  133. });
  134. //返回按钮
  135. $('.capturerWindow input[name="back"]').click(function(){
  136. $('.capturerWindow #capturerPreview').hide().siblings().show();
  137. $('.capturerWindow input[name="scan"]').show();
  138. $('.capturerWindow input[name="switch"]').show();
  139. $('.capturerWindow input[name="rotate"]').show();
  140. $('.capturerWindow input[name="save"]').hide();
  141. $('.capturerWindow input[name="back"]').hide();
  142. });
  143. },
  144. show: function(){
  145. $('.windowContainer.capturerWindow').show().siblings().hide();
  146. $('.capturerWindow #capturerPreview').hide().siblings().show();
  147. $('.capturerWindow input[name="scan"]').show();
  148. $('.capturerWindow input[name="switch"]').show();
  149. $('.capturerWindow input[name="rotate"]').show();
  150. $('.capturerWindow input[name="save"]').hide();
  151. $('.capturerWindow input[name="back"]').hide();
  152. this._capturer.initialization();
  153. }
  154. };
  155. var capturerWindow = new CapturerWindow();