adminrequesterCtrl.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. // 'use strict';
  2. /**
  3. * controller for User Profile Example
  4. */
  5. app.controller('adminUserListCtrl_requ', ["$rootScope", "$scope", "$http", "$state", "FileUploader", "$timeout", "$interval", "$modal", "SweetAlert", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_user_data", function ($rootScope, $scope, $http, $state, FileUploader, $timeout, $interval, $modal, SweetAlert, i18nService, uiGridConstants, uiGridGroupingConstants, Restangular, api_user_data) {
  6. $scope.langs = i18nService.getAllLangs();
  7. $scope.lang = 'zh-cn';
  8. i18nService.setCurrentLang($scope.lang);
  9. var loginUser = $rootScope.user;
  10. //$scope.allright=false;
  11. //$scope.allrightnot=true;
  12. $scope.gridOptions = {};
  13. $scope.gridOptions.data = 'myData';
  14. $scope.gridOptions.enableColumnResizing = true;
  15. $scope.gridOptions.enableFiltering = true;
  16. $scope.gridOptions.enableGridMenu = true;
  17. $scope.gridOptions.enableRowSelection = true;
  18. $scope.gridOptions.showGridFooter = false;
  19. $scope.gridOptions.showColumnFooter = false;
  20. $scope.gridOptions.fastWatch = true;
  21. $scope.gridOptions.useExternalFiltering = true;
  22. $scope.gridOptions.useExternalPagination = true;
  23. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  24. $scope.gridOptions.paginationPageSize = 10;
  25. $scope.gridOptions.multiSelect = true;
  26. $scope.gridOptions.enableSelectionBatchEvent = true; //使用批量使用事件
  27. //$scope.gridOptions.rowTemplate= "<div ng-dblclick=\"grid.appScope.onDblClick(row)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  28. $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.onDblClick(row)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  29. $scope.gridOptions.rowIdentity = function (row) {
  30. return row.id;
  31. };
  32. $scope.gridOptions.getRowIdentity = function (row) {
  33. return row.id;
  34. };
  35. $scope.transferRole = function (roles) {
  36. var tempValue = "";
  37. angular.forEach(roles, function (item) {
  38. if (tempValue != "") {
  39. tempValue = tempValue + "/";
  40. }
  41. tempValue = tempValue + item.role;
  42. })
  43. return tempValue;
  44. }
  45. //remote data
  46. $scope.gridOptions.columnDefs = [{
  47. name: 'item',
  48. displayName: '序号',
  49. width: 50,
  50. enableFiltering: false,
  51. cellTemplate: '<div>' +
  52. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  53. '</div>'
  54. },
  55. {
  56. name: 'name',
  57. displayName: '姓名',
  58. width: '10%',
  59. enableFiltering: false
  60. },
  61. // { name: 'studentNo', displayName: '学工号', width: 120 },
  62. {
  63. name: 'account',
  64. displayName: '工号',
  65. width: '10%',
  66. enableFiltering: false
  67. },
  68. {
  69. name: 'weixin',
  70. displayName: '微信',
  71. width: '10%',
  72. minWidth: '120',
  73. enableFiltering: false
  74. },
  75. {
  76. name: 'dept.dept',
  77. displayName: '科室',
  78. width: '12%',
  79. enableFiltering: false
  80. },
  81. {
  82. name: 'requesterType.name',
  83. displayName: '职务',
  84. width: '10%',
  85. enableFiltering: false
  86. },
  87. {
  88. name: 'mphone',
  89. displayName: '电话',
  90. width: '12%',
  91. minWidth: '125',
  92. enableFiltering: false
  93. },
  94. {
  95. name: 'place.area.area',
  96. displayName: '区域',
  97. width: '10%',
  98. enableFiltering: false
  99. },
  100. {
  101. name: 'place.place',
  102. displayName: '地点',
  103. width: '12%',
  104. enableFiltering: false
  105. },
  106. {
  107. name: '操作',
  108. cellTemplate: '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left">' +
  109. // '<a ng-click="grid.appScope.saveData(row.entity)" tooltip="编辑" tooltip-placement="right">' +
  110. // '<i class="fa fa-pencil-square-o"></i></a>'+
  111. '<a ng-click="grid.appScope.saveData(row.entity)" class="bianjifont">编辑</a>' +
  112. '</div></div>',
  113. enableFiltering: false
  114. }
  115. ];
  116. //导入
  117. $scope.importopen = function () { //导入触发事件
  118. var modalInstance = $modal.open({
  119. templateUrl: 'assets/views/import.html',
  120. controller: function ($scope, $modalInstance, FileUploader) {
  121. var importUploader = $scope.importUploader = new FileUploader({
  122. url: api_user_data.jry_importData().getRequestedUrl(),
  123. });
  124. // importUploader.filters.push({
  125. // name: 'customFilter',
  126. // fn: function(item /*{File|FileLikeObject}*/ , options) {
  127. // var type = item.name.slice(item.name.lastIndexOf('.') + 1);
  128. // //var type = '|' + item.type.slice(item.type.lastIndexOf('/') + 1) + '|';
  129. // return (type == 'xlsx');
  130. // }
  131. // });
  132. importUploader.filters.push({
  133. name: 'customFilter',
  134. fn: function (item /*{File|FileLikeObject}*/ , options) {
  135. this.queue = [];
  136. return this.queue.length < 2;
  137. }
  138. });
  139. importUploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/ , filter, options) {
  140. console.info('onWhenAddingFileFailed', item, filter, options);
  141. };
  142. importUploader.onAfterAddingFile = function (fileItem) {
  143. console.info('onAfterAddingFile', fileItem);
  144. };
  145. importUploader.onAfterAddingAll = function (addedFileItems) {
  146. console.info('onAfterAddingAll', addedFileItems);
  147. };
  148. importUploader.onProgressItem = function (fileItem, progress) {
  149. console.info('onProgressItem', fileItem, progress);
  150. };
  151. importUploader.onProgressAll = function (progress) {
  152. console.info('onProgressAll', progress);
  153. };
  154. importUploader.onSuccessItem = function (fileItem, response, status, headers) {
  155. if (response.status == 200) {
  156. SweetAlert.swal({
  157. title: "导入成功!",
  158. confirmButtonColor: "#007AFF",
  159. type: "success"
  160. }, function () {
  161. // $scope.ldloading.contract_overlay = false;
  162. $rootScope.isMask = false;
  163. $scope.refreshData('expand-right', $scope.fileData);
  164. });
  165. } else {
  166. // $scope.ldloading.contract_overlay = false;
  167. $rootScope.isMask = false;
  168. SweetAlert.swal({
  169. title: "导入失败!",
  170. text: response.error,
  171. type: "error"
  172. })
  173. }
  174. console.info('onSuccessItem', fileItem, response, status, headers);
  175. };
  176. importUploader.onErrorItem = function (fileItem, response, status, headers) {
  177. console.info('onErrorItem', fileItem, response, status, headers);
  178. SweetAlert.swal({
  179. title: "系统错误!",
  180. text: "系统错误,请稍候重试!",
  181. type: "error"
  182. });
  183. };
  184. importUploader.onCancelItem = function (fileItem, response, status, headers) {
  185. console.info('onCancelItem', fileItem, response, status, headers);
  186. };
  187. importUploader.onCompleteItem = function (fileItem, response, status, headers) {
  188. console.info('onCompleteItem', fileItem, response, status, headers);
  189. };
  190. importUploader.onCompleteAll = function () {
  191. console.info('onCompleteAll');
  192. };
  193. $scope.ldloading = {};
  194. $rootScope.isMask = false;
  195. $scope.import = function (style) {
  196. // $scope.ldloading[style.replace('-', '_')] = true;
  197. $modalInstance.dismiss('cancel');
  198. $rootScope.isMask = true;
  199. importUploader.onBeforeUploadItem = function (item) {
  200. angular.extend(item.headers, $rootScope.getSession());
  201. // item.formData[0]['filename'] = item.file.name;
  202. // item.formData[0]['type'] = "requester";
  203. item.formData.push({
  204. 'fileName': item.file.name
  205. });
  206. item.formData.push({
  207. 'type': "requester"
  208. });
  209. console.info('onBeforeUploadItem', item);
  210. };
  211. importUploader.uploadAll();
  212. }
  213. $scope.cancel = function () {
  214. $modalInstance.dismiss('cancel');
  215. };
  216. },
  217. size: 'sm',
  218. resolve: {
  219. importUploader: function () {
  220. return $scope.importUploader;
  221. }
  222. }
  223. });
  224. modalInstance.result.then(function (selectedItem) {
  225. if (selectedItem) {}
  226. })
  227. }
  228. //导出
  229. $scope.openmodel = function () {
  230. var modalInstance = $modal.open({
  231. templateUrl: 'assets/views/system/tpl/getdown.html',
  232. controller: function ($scope, $modalInstance) {
  233. $scope.key = {};
  234. $scope.title = '报修人导入模版下载';
  235. $scope.lable = '下载模版版本';
  236. $scope.onChange = function (key) {
  237. $scope.key = key;
  238. }
  239. $scope.downmodel = [{
  240. id: 1,
  241. name: "EXCEL2003版(xls)"
  242. }, {
  243. id: 2,
  244. name: "EXCEL2007及以上版(xlsx)"
  245. }]
  246. $scope.ok = function () {
  247. $modalInstance.close($scope.key);
  248. };
  249. $scope.cancel = function () {
  250. $modalInstance.dismiss('cancel');
  251. };
  252. },
  253. size: 'sm',
  254. });
  255. modalInstance.result.then(function (selectedItem) {
  256. if (selectedItem) {
  257. var selectedItemId = "";
  258. if (selectedItem.id == 2) {
  259. selectedItemId = ".xlsx";
  260. }
  261. var type = "requester";
  262. var month = 0;
  263. $http({
  264. url: api_user_data.downDataModel(type, month).getRequestedUrl(),
  265. method: 'GET',
  266. headers: {
  267. 'Accept': '*/*'
  268. },
  269. responseType: 'arraybuffer'
  270. }).success(function (data, status, headers, config) {
  271. var file = new Blob([data], {
  272. // type : 'application/octet-stream'
  273. type: 'application/vnd.ms-excel'
  274. });
  275. //trick to download store a file having its URL
  276. var fileURL = URL.createObjectURL(file);
  277. var a = document.createElement('a');
  278. a.href = fileURL;
  279. a.target = '_blank';
  280. a.download = "报修人" + selectedItemId;
  281. document.body.appendChild(a);
  282. a.click();
  283. }).error(function (data, status, headers, config) {
  284. console.log(data);
  285. });
  286. }
  287. });
  288. }
  289. //修改
  290. $scope.saveData = function (data) {
  291. if (data.place) {
  292. var modelData = {
  293. model: {
  294. requester: {
  295. "id": data.id,
  296. "account": data.account,
  297. "name": data.name,
  298. "gender": data.gender,
  299. "email": data.email,
  300. "mphone": data.mphone,
  301. "deptName": data.deptName,
  302. "telephone": data.telephone,
  303. "dept": data.dept,
  304. "area": data.place.area,
  305. "place": data.place,
  306. "studentNo": data.studentNo,
  307. "houseNumber": data.houseNumber,
  308. "requesterType": data.requesterType,
  309. "weixin": data.weixin
  310. }
  311. }
  312. };
  313. } else {
  314. var modelData = {
  315. model: {
  316. requester: {
  317. "id": data.id,
  318. "account": data.account,
  319. "name": data.name,
  320. "gender": data.gender,
  321. "email": data.email,
  322. "mphone": data.mphone,
  323. "deptName": data.deptName,
  324. "telephone": data.telephone,
  325. "dept": data.dept,
  326. // "area": data.place.area,
  327. "place": data.place,
  328. "studentNo": data.studentNo,
  329. "houseNumber": data.houseNumber,
  330. "requesterTypeDTO": data.requesterTypeDTO,
  331. "weixin": data.weixin
  332. }
  333. }
  334. };
  335. }
  336. $state.go('app.system.user.requester', {
  337. formKey: 'system_edit_requester',
  338. service: 'api_user_data',
  339. model: JSON.stringify(modelData)
  340. });
  341. };
  342. // 下拉树
  343. function convertListToTree(data, treeMap) {
  344. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  345. var root = null; //Initially set our loop to null
  346. //loop over data
  347. for (var i = 0; i < data.length; i++) {
  348. var datum = data[i];
  349. //each node will have children, so let's give it a "children" poperty
  350. datum.children = [];
  351. //add an entry for this node to the map so that any future children can
  352. //lookup the parent
  353. idToNodeMap[datum.id] = datum;
  354. //Does this node have a parent?
  355. // console.log("datum="+JSON.stringify(datum))
  356. if (typeof datum.parent === "undefined" || datum.parent === null) {
  357. //Doesn't look like it, so this node is the root of the tree
  358. root = datum;
  359. treeMap[datum.id] = root;
  360. } else {
  361. //This node has a parent, so let's look it up using the id
  362. parentNode = idToNodeMap[datum.parent.id];
  363. //We don't need this property, so let's delete it.
  364. // delete datum.parent;
  365. //Let's add the current node as a child of the parent node.
  366. parentNode.children.push(datum);
  367. }
  368. }
  369. return root;
  370. }
  371. function convertParentToChildList(data) {
  372. var treeMap = {};
  373. var list = [];
  374. convertListToTree(data, treeMap);
  375. angular.forEach(treeMap, function (item) {
  376. list.push(item);
  377. });
  378. return list;
  379. }
  380. $scope.parentdata = {};
  381. $scope.try_async_load = function () {
  382. $scope.my_data = [];
  383. $scope.doing_async = true;
  384. var data = {
  385. "idx": 0,
  386. "sum": 1000
  387. };
  388. api_user_data.fetchDataList('department', data).then(function (response) {
  389. var data = response.list;
  390. var objects = [];
  391. $scope.parentdata = data;
  392. for (var i = 0; i < data.length; i++) {
  393. var object = {};
  394. object.id = data[i].id;
  395. if (angular.isDefined(data[i].parent)) {
  396. object.parent = data[i].parent;
  397. }
  398. if (angular.isDefined(data[i].hasArea)) {
  399. object.hasArea = data[i].hasArea;
  400. }
  401. if (angular.isDefined(data[i].hasSimple)) {
  402. object.hasSimple = data[i].hasSimple;
  403. }
  404. if (angular.isDefined(data[i].group)) {
  405. object.group = data[i].group;
  406. }
  407. if (angular.isDefined(data[i].priority)) {
  408. object.priority = data[i].priority;
  409. }
  410. object.label = data[i].dept;
  411. // object.actions = data[i][3]; //权限部分
  412. // object.group = "1";
  413. // object.user = "2";
  414. object.state = {
  415. "opened": true
  416. };
  417. object.typeName = "type";
  418. // if()
  419. // if (object.actions.indexOf("2") >= 0) { //知识库类型 具有增加权限--系统管理员
  420. $scope.showAddSolutionType = true;
  421. // }
  422. // if (object.actions.indexOf("5") >= 0) { //知识库类型 具有授权权限--系统管理员
  423. $scope.showReviewKnowledgeType = true;
  424. // }
  425. objects.push(object);
  426. }
  427. $scope.my_data = convertParentToChildList(objects);
  428. $scope.tree_data = angular.copy($scope.my_data);
  429. // if ($scope.my_data.length > 0) {
  430. $scope.doing_async = false;
  431. // }
  432. });
  433. };
  434. $scope.try_async_load();
  435. //新增
  436. $scope.addData = function () {
  437. $state.go('app.system.user.requester', {
  438. formKey: 'system_edit_requester',
  439. service: 'api_user_data'
  440. })
  441. }
  442. $scope.removeData = function () {
  443. var modalInstance = $modal.open({
  444. templateUrl: 'assets/views/delete.html',
  445. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  446. var rmvList = [];
  447. $scope.title = '报修人删除';
  448. $scope.connect = '确定要删除此报修人?';
  449. rmvList.push(scope.selected.items[0].id);
  450. $scope.ok = function () {
  451. $modalInstance.close(rmvList);
  452. };
  453. $scope.cancel = function () {
  454. $modalInstance.dismiss('cancel');
  455. };
  456. },
  457. size: 'sm',
  458. resolve: {
  459. scope: function () {
  460. return $scope;
  461. }
  462. }
  463. });
  464. modalInstance.result.then(function (selectedItem) {
  465. if (selectedItem) {
  466. if (selectedItem.length > 0) {
  467. api_user_data.rmvData('requester', selectedItem).then(function (response) {
  468. if (response.data) {
  469. SweetAlert.swal({
  470. title: "删除成功!",
  471. type: "success",
  472. confirmButtonColor: "#007AFF"
  473. }, function () {
  474. $scope.myData = _.reject($scope.myData, function (o) {
  475. return _.includes(selectedItem, o.id)
  476. });
  477. $scope.selected = {
  478. items: []
  479. };
  480. $scope.gridOptions.totalItems = $scope.gridOptions.totalItems - selectedItem.length
  481. $scope.gridApi.grid.selection.selectedCount = 0;
  482. });
  483. } else {
  484. SweetAlert.swal({
  485. title: "操作异常!",
  486. text: "系统异常,请稍后重试,或者联系管理员!",
  487. type: "error"
  488. });
  489. }
  490. })
  491. }
  492. }
  493. })
  494. }
  495. $scope.selected = {
  496. items: []
  497. }
  498. $scope.editted = {
  499. items: []
  500. }
  501. $scope.gridOptions.onRegisterApi = function (gridApi) {
  502. $scope.gridApi = gridApi;
  503. // gridApi.edit.on.afterCellEdit($scope,function(rowEntity, colDef, newValue, oldValue){
  504. // console.log(rowEntity);
  505. // });
  506. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  507. var filtersData = $scope.memoryfilterData;
  508. filtersData.idx = newPage - 1;
  509. filtersData.sum = pageSize;
  510. defaultFilterData = filtersData;
  511. $scope.fileData.idx = newPage - 1;
  512. $scope.fileData.sum = pageSize;
  513. $scope.refreshData('expand-right', $scope.fileData);
  514. });
  515. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  516. // data.grid.appScope.selected.items = data.entity
  517. // });
  518. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  519. if (data.isSelected) {
  520. data.grid.appScope.selected.items[0] = data.entity;
  521. } else {
  522. if (data.grid.appScope.selected.items[0].id == data.entity.id) {
  523. data.grid.appScope.selected.items = [];
  524. }
  525. }
  526. });
  527. gridApi.core.on.filterChanged($scope, function () {
  528. var grid = this.grid;
  529. var filtersData = {
  530. idx: 0,
  531. sum: 10
  532. };
  533. angular.forEach(grid.columns, function (item) {
  534. if (item.enableFiltering) {
  535. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  536. if (angular.isUndefined(filtersData['requester'])) {
  537. filtersData['requester'] = {};
  538. }
  539. filtersData['requester'][item.field] = item.filters[0].term;
  540. }
  541. }
  542. });
  543. $scope.memoryfilterData = filtersData;
  544. $scope.refreshData('expand-right', $scope.fileData);
  545. });
  546. };
  547. var defaultFilterData = {
  548. "idx": 0,
  549. "sum": 10
  550. };
  551. $scope.memoryfilterData = {
  552. "idx": 0,
  553. "sum": 10
  554. }
  555. $scope.ldloading = {};
  556. $scope.refresh = function (style, filterData) {
  557. $scope.selected = {
  558. items: []
  559. };
  560. if ($scope.gridApi) {
  561. // $scope.gridApi.grid.options.paginationCurrentPage = 0;
  562. $scope.gridApi.grid.selection.selectedCount = 0;
  563. }
  564. $scope.refreshData('expand-right', $scope.fileData);
  565. }
  566. $scope.fileData = {
  567. "idx": 0,
  568. "sum": 10,
  569. "requester": {
  570. }
  571. };
  572. // 搜索
  573. $scope.searchData = function () {
  574. $scope.refreshData('expand-right', $scope.fileData);
  575. }
  576. // 清空
  577. $scope.clean = function () {
  578. delete $scope.fileData.requester.name;
  579. delete $scope.fileData.requester.account;
  580. delete $scope.fileData.requester.dept;
  581. $scope.try_async_load();
  582. $scope.refreshData('expand-right', $scope.fileData);
  583. }
  584. $scope.onFilterCallback = function (data) {
  585. // console.log(data);
  586. $scope.fileData.requester.dept = data;
  587. }
  588. $scope.refreshData = function (style, filterData) {
  589. $scope.ldloading[style.replace('-', '_')] = true;
  590. if (angular.isUndefined(filterData)) {
  591. filterData = defaultFilterData;
  592. }
  593. if (angular.isDefined($scope.searchTypes)) {
  594. filterData['searchType'] = $scope.searchTypes;
  595. }
  596. $scope.myData = [];
  597. // if ($scope.gridApi) {
  598. // $scope.gridApi.grid.options.paginationCurrentPage = 0;
  599. // $scope.gridApi.grid.selection.selectedCount = 0;
  600. // }
  601. api_user_data.fetchDataList('requester', filterData).then(function (data) {
  602. var myData = Restangular.stripRestangular(data);
  603. $scope.gridOptions.totalItems = myData.totalNum;
  604. $scope.myData = myData.list;
  605. for (var i = 0; i < $scope.myData.length; i++) {
  606. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  607. }
  608. $scope.ldloading[style.replace('-', '_')] = false;
  609. }, function () {
  610. $scope.ldloading[style.replace('-', '_')] = false;
  611. });
  612. };
  613. $scope.refreshData2 = function (style, filterData) {
  614. $scope.ldloading[style.replace('-', '_')] = true;
  615. if (angular.isUndefined(filterData)) {
  616. filterData = defaultFilterData;
  617. }
  618. if (angular.isDefined($scope.searchTypes)) {
  619. filterData['searchType'] = $scope.searchTypes;
  620. }
  621. // $scope.myData = [];
  622. // if ($scope.gridApi) {
  623. // $scope.gridApi.grid.options.paginationCurrentPage = 0;
  624. // $scope.gridApi.grid.selection.selectedCount = 0;
  625. // }
  626. api_user_data.fetchDataList('requester', filterData).then(function (data) {
  627. var myData = Restangular.stripRestangular(data);
  628. $scope.gridOptions.totalItems = myData.totalNum;
  629. $scope.myData = myData.list;
  630. for (var i = 0; i < $scope.myData.length; i++) {
  631. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  632. }
  633. $scope.ldloading[style.replace('-', '_')] = false;
  634. }, function () {
  635. $scope.ldloading[style.replace('-', '_')] = false;
  636. });
  637. };
  638. $scope.refreshData('expand-right', $scope.fileData);
  639. $scope.timer = $interval(function () {
  640. $scope.refreshData2('expand-right', $scope.fileData);
  641. }, $rootScope.refreshTime);
  642. $scope.$on('$destroy', function () {
  643. $interval.cancel($scope.timer)
  644. });
  645. }]);