123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- (function ($ang) {
- 'use strict';
- $ang.module('ylmis').controller('fileTabListCtrl', function ($scope, $http, $alert, $modal, AuthUser, $state, $loading, $window,$stateParams, $timeout,$bsRouterState) {
- $scope.navList = [];
- $scope.selectTabId = '';
- $scope.fileList = [];
- $scope.treeList = [];
- $stateParams = $bsRouterState.$params($scope);
- $scope.selectData = {
- fileName : '',
- filetypeid: '',
- pageindex: 1,
- pagesize: 10,
- ptotal: 0
- };
- $scope.selectData.fileName = $stateParams.fileName;
- $scope.GetNavData = function () {
- $http({
- method: 'get',
- url: '../../api/filemgr/GetFileTypeRoot'
- }).then(function (result) {
- $scope.navList = result.data.item;
- $ang.forEach($scope.navList,function (value) {
- //默认显示下拉按钮,等点击事件后再给真实数字
- value.childCount=1;
- value.expand=false;
- value.name=value.filetypename;
- value.id=value.filetypeid;
- });
- //添加
- if ($scope.selectData.fileName != null){
- $scope.FindWord();
- }else{
- $scope.clickTreeChild($scope.navList[0]);
- }
- $scope.selectTabId = $scope.navList[0].filetypeid;
- //$scope.GetTreeData($scope.navList[0].filetypeid);
- }, function (resp) {
- });
- };
- $scope.loadTreeChild=function (item) {
- $http({
- method: 'get',
- url: '../../api/filemgr/GetFileTypesByParent',
- params: {
- parentid: item.id
- }
- }).then(function (result) {
- item.children=result.data.item;
- item.childCount=item.children?item.children.length:0;
- $ang.forEach(item.children,function (value) {
- value.childCount=0;
- value.expand=false;
- value.name=value.filetypename;
- value.id=value.filetypeid;
- });
- //如果有子节点有下一层,把类型选择默认选下一层第一个节点。
- /*
- if(item.childCount>0){
- $scope.selectData.filetypeid=item.children[0].id;
- $scope.loadData();
- }*/
- });
- };
- $scope.clickTreeChild=function(item){
- $scope.selectData.pageindex = 1;
- $scope.selectData.filetypeid=item.id;
- $scope.selectData.fileName = '';
- if(!item.children){
- $scope.loadTreeChild(item);
- }
- if(item.childCount>0){
- item.expand=!item.expand;
- }
- $scope.loadData();
- };
- $scope.searchFile = function (){
- $scope.selectData.pageindex = 1;
- $scope.FindWord();
- }
- $scope.FindWord = function () {
- if ($scope.selectData.fileName.length > 0) {
- //$window.open('http://10.160.8.64:8080/es/search.do?keyWords=' + decodeURI($scope.selectKey));
- //$bsRouterState.go('home.fileFrame', {keyWords: $scope.selectKey});
- $http({
- method: 'get',
- url: '../../api/filemgr/GetFilesByKey',
- params: $scope.selectData
- }).then(function (req) {
- //$loading.hide();
- $scope.fileList = req.data.item.list;
- $scope.selectData.ptotal = req.data.item.total;
- $scope.selectData.filetypeid = '';
- }, function (resp) {
- //$loading.hide();
- });
- } else {
- $alert({title: '提示:', content: '请输入关键字!', placement: 'top', type: 'info', show: true, duration: 3});
- }
- }
- $scope.GetTreeData = function (id) {
- $scope.treeList.splice(0, $scope.treeList.length);
- $http({
- method: 'get',
- url: '../../api/filemgr/GetFileTypesByParent',
- params: {
- parentid: id
- }
- }).then(function (result) {
- /*
- $timeout(function () {
- $ang.forEach(result.data.item, function (it) {
- $scope.treeList.push(it);
- });
- }, 1000);*/
- $scope.selectData.filetypeid = result.data.item[0].filetypeid;
- $scope.selectData.pageindex = 1;
- $scope.loadData();
- }, function (resp) {
- });
- }
- $scope.loadData = function () {
- if (!$scope.selectData.filetypeid) {
- return;
- }
- //$loading.show();
- $http({
- method: 'get',
- url: '../../api/filemgr/GetFilesByType',
- params: $scope.selectData
- }).then(function (req) {
- //$loading.hide();
- $scope.fileList = req.data.item.list;
- $scope.selectData.ptotal = req.data.item.total;
- }, function (resp) {
- //$loading.hide();
- });
- };
- //监视页数变化
- $scope.$watch("selectData.pageindex", function (newVal, oldVal) {
- if ($scope.selectData.ptotal > 0) {
- if ($scope.selectData.fileName != null && $scope.selectData.fileName != ''){
- $scope.FindWord();
- }else {
- $scope.loadData();
- }
- }
- });
- $scope.GetNavData();
- $scope.selectTab = function (id) {
- $scope.selectTabId = id;
- $scope.GetTreeData(id);
- };
- $scope.selectTree = function (id) {
- $scope.selectData.filetypeid = id;
- $scope.selectData.pageindex = 1;
- $scope.loadData();
- };
- $scope.isSelected = function (id) {
- return $scope.selectTabId == id;
- };
- $scope.isTreeSelect = function (id) {
- return $scope.selectData.filetypeid == id;
- };
-
- var fileViewModal = $modal({
- scope: $scope,
- title: '文件展现',
- templateUrl: 'filemanage/doc-show.html?' + window.sysVersion,
- controller: 'fileViewCtrl',
- show: false,
- animation: 'am-fade-and-slide-top'
- });
- $scope.viewFile = function (fileid, filename) {
- //fileViewModal.fileId=fileid;
- $scope.viewFileId = fileid;
- $scope.viewFileName = filename;
- $scope.isrc = '/api/filemgr/showDoc/' + $scope.viewFileId;
- window.open($scope.isrc,"_blank");
- //fileViewModal.$promise.then(fileViewModal.show);
- };
- $scope.downloadFile = function (fileid) {
- $window.open('/api/filemgr/downDoc/' + fileid);
- };
- }).controller('fileViewCtrl', function ($scope, $http) {
- $scope.title = $scope.$parent.$parent.viewFileName;
- $scope.fileId = $scope.$parent.$parent.viewFileId;
- $scope.isrc = '/api/filemgr/showDoc/' + $scope.fileId;
- });
- })(angular);
|