fileTabList.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. (function ($ang) {
  2. 'use strict';
  3. $ang.module('ylmis').controller('fileTabListCtrl', function ($scope, $http, $alert, $modal, AuthUser, $state, $loading, $window,$stateParams, $timeout,$bsRouterState) {
  4. $scope.navList = [];
  5. $scope.selectTabId = '';
  6. $scope.fileList = [];
  7. $scope.treeList = [];
  8. $stateParams = $bsRouterState.$params($scope);
  9. $scope.selectData = {
  10. fileName : '',
  11. filetypeid: '',
  12. pageindex: 1,
  13. pagesize: 10,
  14. ptotal: 0
  15. };
  16. $scope.selectData.fileName = $stateParams.fileName;
  17. $scope.GetNavData = function () {
  18. $http({
  19. method: 'get',
  20. url: '../../api/filemgr/GetFileTypeRoot'
  21. }).then(function (result) {
  22. $scope.navList = result.data.item;
  23. $ang.forEach($scope.navList,function (value) {
  24. //默认显示下拉按钮,等点击事件后再给真实数字
  25. value.childCount=1;
  26. value.expand=false;
  27. value.name=value.filetypename;
  28. value.id=value.filetypeid;
  29. });
  30. //添加
  31. if ($scope.selectData.fileName != null){
  32. $scope.FindWord();
  33. }else{
  34. $scope.clickTreeChild($scope.navList[0]);
  35. }
  36. $scope.selectTabId = $scope.navList[0].filetypeid;
  37. //$scope.GetTreeData($scope.navList[0].filetypeid);
  38. }, function (resp) {
  39. });
  40. };
  41. $scope.loadTreeChild=function (item) {
  42. $http({
  43. method: 'get',
  44. url: '../../api/filemgr/GetFileTypesByParent',
  45. params: {
  46. parentid: item.id
  47. }
  48. }).then(function (result) {
  49. item.children=result.data.item;
  50. item.childCount=item.children?item.children.length:0;
  51. $ang.forEach(item.children,function (value) {
  52. value.childCount=0;
  53. value.expand=false;
  54. value.name=value.filetypename;
  55. value.id=value.filetypeid;
  56. });
  57. //如果有子节点有下一层,把类型选择默认选下一层第一个节点。
  58. /*
  59. if(item.childCount>0){
  60. $scope.selectData.filetypeid=item.children[0].id;
  61. $scope.loadData();
  62. }*/
  63. });
  64. };
  65. $scope.clickTreeChild=function(item){
  66. $scope.selectData.pageindex = 1;
  67. $scope.selectData.filetypeid=item.id;
  68. $scope.selectData.fileName = '';
  69. if(!item.children){
  70. $scope.loadTreeChild(item);
  71. }
  72. if(item.childCount>0){
  73. item.expand=!item.expand;
  74. }
  75. $scope.loadData();
  76. };
  77. $scope.searchFile = function (){
  78. $scope.selectData.pageindex = 1;
  79. $scope.FindWord();
  80. }
  81. $scope.FindWord = function () {
  82. if ($scope.selectData.fileName.length > 0) {
  83. //$window.open('http://10.160.8.64:8080/es/search.do?keyWords=' + decodeURI($scope.selectKey));
  84. //$bsRouterState.go('home.fileFrame', {keyWords: $scope.selectKey});
  85. $http({
  86. method: 'get',
  87. url: '../../api/filemgr/GetFilesByKey',
  88. params: $scope.selectData
  89. }).then(function (req) {
  90. //$loading.hide();
  91. $scope.fileList = req.data.item.list;
  92. $scope.selectData.ptotal = req.data.item.total;
  93. $scope.selectData.filetypeid = '';
  94. }, function (resp) {
  95. //$loading.hide();
  96. });
  97. } else {
  98. $alert({title: '提示:', content: '请输入关键字!', placement: 'top', type: 'info', show: true, duration: 3});
  99. }
  100. }
  101. $scope.GetTreeData = function (id) {
  102. $scope.treeList.splice(0, $scope.treeList.length);
  103. $http({
  104. method: 'get',
  105. url: '../../api/filemgr/GetFileTypesByParent',
  106. params: {
  107. parentid: id
  108. }
  109. }).then(function (result) {
  110. /*
  111. $timeout(function () {
  112. $ang.forEach(result.data.item, function (it) {
  113. $scope.treeList.push(it);
  114. });
  115. }, 1000);*/
  116. $scope.selectData.filetypeid = result.data.item[0].filetypeid;
  117. $scope.selectData.pageindex = 1;
  118. $scope.loadData();
  119. }, function (resp) {
  120. });
  121. }
  122. $scope.loadData = function () {
  123. if (!$scope.selectData.filetypeid) {
  124. return;
  125. }
  126. //$loading.show();
  127. $http({
  128. method: 'get',
  129. url: '../../api/filemgr/GetFilesByType',
  130. params: $scope.selectData
  131. }).then(function (req) {
  132. //$loading.hide();
  133. $scope.fileList = req.data.item.list;
  134. $scope.selectData.ptotal = req.data.item.total;
  135. }, function (resp) {
  136. //$loading.hide();
  137. });
  138. };
  139. //监视页数变化
  140. $scope.$watch("selectData.pageindex", function (newVal, oldVal) {
  141. if ($scope.selectData.ptotal > 0) {
  142. if ($scope.selectData.fileName != null && $scope.selectData.fileName != ''){
  143. $scope.FindWord();
  144. }else {
  145. $scope.loadData();
  146. }
  147. }
  148. });
  149. $scope.GetNavData();
  150. $scope.selectTab = function (id) {
  151. $scope.selectTabId = id;
  152. $scope.GetTreeData(id);
  153. };
  154. $scope.selectTree = function (id) {
  155. $scope.selectData.filetypeid = id;
  156. $scope.selectData.pageindex = 1;
  157. $scope.loadData();
  158. };
  159. $scope.isSelected = function (id) {
  160. return $scope.selectTabId == id;
  161. };
  162. $scope.isTreeSelect = function (id) {
  163. return $scope.selectData.filetypeid == id;
  164. };
  165. var fileViewModal = $modal({
  166. scope: $scope,
  167. title: '文件展现',
  168. templateUrl: 'filemanage/doc-show.html?' + window.sysVersion,
  169. controller: 'fileViewCtrl',
  170. show: false,
  171. animation: 'am-fade-and-slide-top'
  172. });
  173. $scope.viewFile = function (fileid, filename) {
  174. //fileViewModal.fileId=fileid;
  175. $scope.viewFileId = fileid;
  176. $scope.viewFileName = filename;
  177. $scope.isrc = '/api/filemgr/showDoc/' + $scope.viewFileId;
  178. window.open($scope.isrc,"_blank");
  179. //fileViewModal.$promise.then(fileViewModal.show);
  180. };
  181. $scope.downloadFile = function (fileid) {
  182. $window.open('/api/filemgr/downDoc/' + fileid);
  183. };
  184. }).controller('fileViewCtrl', function ($scope, $http) {
  185. $scope.title = $scope.$parent.$parent.viewFileName;
  186. $scope.fileId = $scope.$parent.$parent.viewFileId;
  187. $scope.isrc = '/api/filemgr/showDoc/' + $scope.fileId;
  188. });
  189. })(angular);