123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- angular.module('push')
- .controller('ConnSearchResultCtrl', function ($scope, $state, $timeout, $stateParams, ConnSearchService, $http, ModelService,
- UtilService, SqliteStorageService, HandleService, UserService, $sce) {
- $scope.key = $stateParams.key;
- $scope.choseTab = 0;
- $scope.showbaidu = false;
- $scope.user = UserService.user.user;
- var localfolderid = $stateParams.localfolderid;
- var folderid = $stateParams.folderid;
- var folderflg = 1;
- $scope.searchfolderflg = 0;
- //搜索本地文件夹
- var templcoalfolderlist = [];
- var searchLocalFolder = function (key) {
- // var q_sql = "select * from conninfofolder where localparentid = '" + localfolderid + "' and name like '%" + key + "%'";
- var q_sql = "select c1.*,foldercounts,infocounts from " +
- "(select * from conninfofolder where localparentid = '" + localfolderid + "' and name like '%" + key + "%') c1 " +
- "LEFT JOIN " +
- "(" +
- "select localparentid,count(1) foldercounts from " +
- "conninfofolder where localparentid in " +
- "(select localid from conninfofolder where localparentid = '" + localfolderid + "' and name like '%" + key + "%') " +
- "GROUP BY localparentid " +
- ") c2 " +
- "ON c1.localid = c2.localparentid " +
- "LEFT JOIN " +
- "(" +
- "select localclaid, count(1) infocounts " +
- "from conninfo where localclaid in " +
- "(select localid from conninfofolder where localparentid = '" + localfolderid + "' and name like '%" + key + "%') " +
- "GROUP BY localclaid " +
- ") c3" +
- " ON c1.localid = c3.localclaid";
- SqliteStorageService.queryData(q_sql).then(function (response) {
- templcoalfolderlist = response;
- angular.forEach(templcoalfolderlist, function (value, index) {
- templcoalfolderlist[index].counts = Number(value.foldercounts) + Number(value.infocounts);
- });
- $scope.searchfolderflg++;
- }, function () {
- templcoalfolderlist = [];
- $scope.searchfolderflg++;
- });
- };
- //搜索云文件夹
- var tempcloudfolderlist = [];
- var searchFolder = function (key) {
- ConnSearchService.searchCloudFolder(key, folderid).then(function (response) {
- tempcloudfolderlist = response.list;
- $scope.searchfolderflg++;
- }, function () {
- tempcloudfolderlist = [];
- $scope.searchfolderflg++;
- });
- };
- //--监听本地与云文件夹查询是否结束
- $scope.$watch("searchfolderflg", function (newValue) {
- if (newValue == folderflg) {
- $scope.folderlist = templcoalfolderlist.concat(tempcloudfolderlist);
- folderflg = 1;
- $scope.searchfolderflg = 0;
- }
- });
- var templocalconnlist = [];
- //--本地记录列表提取第一张图为列表显示图
- var extractConninfoPicture = function (conninfolist, picturelist) {
- HandleService.extractConninfoPicture(conninfolist, picturelist).then(function (response) {
- templocalconnlist = response;
- $scope.searchconnflg++;
- }, function () {
- $scope.searchconnflg++;
- })
- };
- var connflg = 1;
- $scope.searchconnflg = 0;
- //搜索本地记录
- var searchLocalConninfo = function (key) {
- var q_sql = "";
- if (localfolderid == '0') {
- q_sql = "select * from conninfo where title like '%" + key + "%'";
- } else {
- q_sql = "select * from conninfo where localclaid = '" + localfolderid + "' and title like '%" + key + "%'";
- }
- SqliteStorageService.queryData(q_sql).then(function (response) {
- if (response.length > 0) {
- //拼接记录localid
- var infoidlist = "";
- angular.forEach(response, function (value) {
- var tempstr = "'" + value.localid + "'";
- infoidlist = infoidlist + tempstr + ",";
- });
- infoidlist = infoidlist.substring(0, infoidlist.length - 1);
- //--查询图片信息
- var q_pic_sql = "select * from conninfopicture where localinfoid in (" + infoidlist + ")";
- SqliteStorageService.queryData(q_pic_sql).then(function (res) {
- if (res.length > 0) {
- extractConninfoPicture(response, res);
- } else {
- $scope.searchconnflg++;
- }
- }, function () {
- $scope.searchconnflg++;
- });
- } else {
- $scope.searchconnflg++;
- }
- }, function () {
- templocalconnlist = [];
- $scope.searchconnflg++;
- });
- };
- //搜索云记录
- var tempcloudconnlist = [];
- var searchConninfo = function (key) {
- // $scope.showLoadingToast();
- ConnSearchService.newNearchConnInfo(key, folderid).then(function (response) {
- tempcloudconnlist = response.list;
- $scope.searchconnflg++;
- }, function () {
- tempcloudconnlist = [];
- $scope.searchconnflg++;
- });
- };
- //--监听本地与云文件夹查询是否结束
- $scope.$watch("searchconnflg", function (newValue) {
- if (newValue == connflg) {
- $scope.recordList = templocalconnlist.concat(tempcloudconnlist);
- connflg = 1;
- $scope.searchconnflg = 0;
- }
- });
- //根据关键字搜索综合、用户信息
- $scope.searchResultByKey = function (key) {
- if (!UtilService.isDefined(key)) {
- return;
- }
- $scope.showbaidu = false;
- if ($scope.choseTab == 0) {
- //首页进入搜索
- if (localfolderid == '0' && folderid == 0) {
- folderflg = 2;
- searchLocalFolder(key);
- searchFolder(key);
- } else if (localfolderid != '0') {
- //本地文件夹下搜索
- searchLocalFolder(key);
- } else if (folderid != 0) {
- //云文件夹下搜索
- searchFolder(key);
- }
- } else if ($scope.choseTab == 1) {
- //首页进入搜索
- if (localfolderid == '0' && folderid == 0) {
- searchLocalConninfo(key);
- searchConninfo(key);
- } else if (localfolderid != '0') {
- //本地文件夹下搜索
- searchLocalConninfo(key);
- } else if (folderid != 0) {
- //云文件夹下搜索
- searchConninfo(key);
- }
- }
- };
- $scope.searchResultByKey($scope.key);
- //切换tab并搜索
- $scope.changeAct = function (index) {
- $scope.choseTab = index;
- $scope.searchResultByKey($scope.key);
- };
- //进入分类详情,记录列表
- $scope.queryFolder = function (folder) {
- ModelService.setCheckdeFolder(folder);
- if (UtilService.isDefined(folder.localid)) {
- //本地文件夹记录列表
- $scope.go('conninfolist', {folder: angular.toJson(folder)});
- } else {
- //云文件夹记录列表
- $scope.go('cloudFolderDetail', {folder: angular.toJson(folder)});
- }
- };
- //进入记录详情
- $scope.goDockingdetails = function (rec) {
- if (UtilService.isDefined(rec.localid)) {
- $scope.go("Dockingdetails", {infoid: rec.localid});
- } else {
- $scope.go("cloudDockingdetail", {infoid: rec.id, infocomefrom: rec.creatorcomefrom, creator: rec.creator});
- }
- };
- //清空搜索内容
- $scope.clearSearch = function () {
- $scope.key = "";
- };
- //显示热词
- $scope.showFunc = function () {
- $scope.showbaidu = true;
- };
- $scope.ttt = function (temptitle) {
- return $sce.trustAsHtml(temptitle)
- };
- $scope.gobackback = function () {
- $timeout(function () {
- $scope.goback();
- }, 310);
- };
- //监测key变化,即时匹配词库
- $scope.fixKey = function () {
- if (angular.isDefined($scope.key) && $scope.key.length > 0) {
- $scope.searchKey($scope.key);
- }
- };
- $scope.data = [];
- //百度词库
- $scope.searchKey = function (searchName) {
- var search_history = angular.element(document.getElementById("his_search"));
- if (search_history.val().length != 0) {
- var baidu = angular.element(document.getElementById("baidu_search"));
- baidu.css("display", "block");
- }
- $http({
- method: 'JSONP',
- url: 'https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=' + searchName + '&cb=JSON_CALLBACK'
- }).success(function (data) {
- $scope.data = data.s;
- });
- };
- //过滤未标记记录
- /*var filterRecord = function () {
- if ($scope.recordList.length > 0) {
- angular.forEach($scope.recordList, function (record, index) {
- for (var i = record.reclist.length - 1; i >= 0; i--) {
- if (record.reclist[i].flag == 0) {
- $scope.recordList[index].reclist.splice(i, 1);
- }
- }
- if (record.reclist.length == 0) {
- $scope.recordList.splice(index, 1);
- }
- });
- }
- if ($scope.localrecordList.length > 0) {
- angular.forEach($scope.localrecordList, function (record, index) {
- for (var i = record.reclist.length - 1; i >= 0; i--) {
- if (record.reclist[i].flag == 0) {
- $scope.localrecordList[index].reclist.splice(i, 1);
- }
- }
- if (record.reclist.length == 0) {
- $scope.localrecordList.splice(index, 1);
- }
- });
- }
- };*/
- });
|