notice.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. 'use strict';
  2. /**
  3. * controller for User Profile Example
  4. */
  5. app.controller('noticeCtrl', ["$rootScope", "$scope", "$state", "$timeout", "$interval", "$modal", "SweetAlert", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_user_data", "api_login", "api_configure_data", function ($rootScope, $scope, $state, $timeout, $interval, $modal, SweetAlert, i18nService, uiGridConstants, uiGridGroupingConstants, Restangular, api_user_data, api_login, api_configure_data) {
  6. $scope.langs = i18nService.getAllLangs();
  7. $scope.lang = 'zh-cn';
  8. i18nService.setCurrentLang($scope.lang);
  9. var loginUser = $rootScope.user;
  10. $scope.xinzeng = false;
  11. $scope.shanchu = false;
  12. $scope.bianji = false;
  13. $scope.fabu = false;
  14. $scope.chehui = false;
  15. for (var i = 0; i < loginUser.menu.length; i++) {
  16. if (loginUser.menu[i].link == "gonggaoliebiao_xinzeng") {
  17. $scope.xinzeng = true
  18. }
  19. if (loginUser.menu[i].link == "gonggaoliebiao_shanchu") {
  20. $scope.shanchu = true
  21. }
  22. if (loginUser.menu[i].link == "gonggaoliebiao_bianji") {
  23. $scope.bianji = true
  24. }
  25. if (loginUser.menu[i].link == "gonggaoliebiao_fabu") {
  26. $scope.fabu = true
  27. }
  28. if (loginUser.menu[i].link == "gonggaoliebiao_chehui") {
  29. $scope.chehui = true
  30. }
  31. }
  32. $scope.gridOptions = {};
  33. $scope.gridOptions.data = 'myData';
  34. $scope.gridOptions.enableColumnResizing = true;
  35. $scope.gridOptions.enableFiltering = true;
  36. $scope.gridOptions.enableGridMenu = true;
  37. $scope.gridOptions.enableRowSelection = true;
  38. $scope.gridOptions.showGridFooter = true;
  39. $scope.gridOptions.showColumnFooter = false;
  40. $scope.gridOptions.fastWatch = true;
  41. $scope.gridOptions.useExternalFiltering = true;
  42. $scope.gridOptions.useExternalPagination = true;
  43. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  44. $scope.gridOptions.paginationPageSize = 10;
  45. $scope.gridOptions.multiSelect = true;
  46. $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.onDblClick(row.entity)\" 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>";
  47. $scope.gridOptions.rowIdentity = function (row) {
  48. return row.id;
  49. };
  50. $scope.gridOptions.getRowIdentity = function (row) {
  51. return row.id;
  52. };
  53. $scope.transferRole = function (roles) {
  54. var tempValue = "";
  55. angular.forEach(roles, function (item) {
  56. if (tempValue != "") {
  57. tempValue = tempValue + "/";
  58. }
  59. tempValue = tempValue + item.role;
  60. })
  61. return tempValue;
  62. }
  63. $scope.transferStatus = function (flag) {
  64. return (flag == 0) ? "有效" : "无效";
  65. }
  66. $scope.transfergroup = function (group) {
  67. var groupData = '';
  68. angular.forEach(group, function (item) {
  69. if (groupData == '') {
  70. groupData = item.groupName;
  71. } else {
  72. groupData = groupData + "/" + item.groupName;
  73. }
  74. })
  75. return groupData;
  76. }
  77. //remote data
  78. $scope.gridOptions.columnDefs = [{
  79. name: 'item',
  80. displayName: '序号',
  81. enableFiltering: false,
  82. width: 50
  83. },
  84. {
  85. name: 'title',
  86. displayName: '标题',
  87. width: '25%',
  88. enableFiltering: false
  89. },
  90. {
  91. name: 'createUser.name',
  92. displayName: '创建人',
  93. width: '8%',
  94. enableFiltering: false
  95. },
  96. // { name: 'areaDTO.area', displayName: '区域', width: '8%', enableFiltering: false },
  97. // { name: 'placeDTO.place', displayName: '地点', width: '8%', enableFiltering: false },
  98. {
  99. name: 'dept.dept',
  100. displayName: '发布科室',
  101. width: '10%',
  102. enableFiltering: false
  103. },
  104. {
  105. name: 'statusName',
  106. displayName: '状态',
  107. width: '10%',
  108. enableFiltering: false
  109. },
  110. {
  111. name: 'createTime',
  112. displayName: '创建时间',
  113. width: '16%',
  114. enableFiltering: false,
  115. cellTemplate: '<div>' +
  116. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center">{{grid.appScope.transferTime(row.entity.createTime)}}</div>' +
  117. '</div>'
  118. },
  119. // { name: 'content', displayName: '内容', enableFiltering: false }
  120. // '<div class="links cl-effect-1">' +
  121. // '<a ng-click="grid.appScope.selectRowFunction(row.entity)" tooltip="编辑" tooltip-placement="left"><i class="fa fa-pencil-square-o"></i></a>'+
  122. // '</div>' , width:100, enableFiltering:false}
  123. {
  124. name: '操作',
  125. enableFiltering: false,
  126. minWidth: "300",
  127. cellTemplate: '<div class="links cl-effect-1 pull-left ui-grid-cell-contents">' +
  128. '<a ng-click="grid.appScope.saveData(row.entity)" ng-show="grid.appScope.showBianji(row.entity)&&grid.appScope.bianji">编辑</a>' +
  129. '<a ng-click="grid.appScope.removeData(row.entity)" ng-show="grid.appScope.showShanchu(row.entity)&&grid.appScope.shanchu">删除</a>' +
  130. '<a ng-click="grid.appScope.seeData(row.entity)">查看</a>' +
  131. '<a ng-click="grid.appScope.release(row.entity)" ng-show="grid.appScope.showFabu(row.entity)&&grid.appScope.fabu">发布</a>' +
  132. '<a ng-click="grid.appScope.withdraw(row.entity)" ng-show="grid.appScope.showChehui(row.entity)&&grid.appScope.chehui">撤回</a>' +
  133. '</div>'
  134. },
  135. ];
  136. $scope.transferTime = function(time) {
  137. return moment(time).format('YYYY-MM-DD HH:mm');
  138. }
  139. // 查看显示隐藏
  140. $scope.showChehui = function (data) {
  141. if (data.statusName == "已发布") {
  142. return true
  143. } else {
  144. return false
  145. }
  146. }
  147. // 发布显示隐藏
  148. $scope.showFabu = function (data) {
  149. if (data.statusName == "暂存" || data.statusName == "已撤销") {
  150. return true
  151. } else {
  152. return false
  153. }
  154. }
  155. // // 查看显示隐藏
  156. // $scope.showChakan=function(data){
  157. // if(data.statusName=="已发布"){
  158. // return true
  159. // }else{
  160. // return false
  161. // }
  162. // }
  163. // 删除显示隐藏
  164. $scope.showShanchu = function (data) {
  165. if (data.statusName == "暂存" || data.statusName == "已撤销") {
  166. return true
  167. } else {
  168. return false
  169. }
  170. }
  171. // 编辑显示隐藏
  172. $scope.showBianji = function (data) {
  173. if (data.statusName == "暂存" || data.statusName == "已撤销") {
  174. return true
  175. } else {
  176. return false
  177. }
  178. }
  179. //区域地点过滤
  180. $scope.key = {};
  181. api_user_data.fetchDataList('area', {
  182. "idx": 0,
  183. "sum": 1000
  184. }).then(function (response) {
  185. if (response) {
  186. if (response.status = 200) {
  187. $scope.outarea = response.list;
  188. }
  189. }
  190. })
  191. $scope.onChangearea = function (data) {
  192. delete $scope.key.place;
  193. if ($scope.memoryfilterData.incident) {
  194. delete $scope.memoryfilterData.incident.place;
  195. }
  196. var fildata = {
  197. "idx": 0,
  198. "sum": 1000,
  199. "place": {
  200. areaId: data.area.id
  201. }
  202. };
  203. api_user_data.fetchDataList('place', fildata).then(function (response) {
  204. if (response) {
  205. if (response.status = 200) {
  206. $scope.outplace = response.list;
  207. }
  208. }
  209. })
  210. };
  211. $scope.open = function ($event) {
  212. $event.preventDefault();
  213. $event.stopPropagation();
  214. $scope.opened = !$scope.opened;
  215. };
  216. $scope.endOpen = function ($event) {
  217. $event.preventDefault();
  218. $event.stopPropagation();
  219. $scope.startOpened = false;
  220. $scope.endOpened = !$scope.endOpened;
  221. };
  222. $scope.startOpen = function ($event) {
  223. $event.preventDefault();
  224. $event.stopPropagation();
  225. $scope.endOpened = false;
  226. $scope.startOpened = !$scope.startOpened;
  227. };
  228. // 获取创建人
  229. $scope.getCreateUser = function () {
  230. api_configure_data.fetchDataList("user", {
  231. "idx": 0,
  232. "sum": 1000,
  233. "user":{
  234. "simple":true,
  235. engineer: 1,
  236. }
  237. }).then(function (res) {
  238. $scope.createUserData = res.list
  239. })
  240. }
  241. $scope.getCreateUser()
  242. //列表操作按钮-编辑
  243. $scope.saveData = function (data) {
  244. var modelData = {
  245. model: {
  246. notice: data
  247. }
  248. };
  249. $state.go('app.system.form', {
  250. formKey: 'noticeEdi',
  251. service: 'api_user_data',
  252. model: JSON.stringify(modelData),
  253. 'isNoticeEdit': "true"
  254. });
  255. };
  256. //列表操作按钮-查看
  257. // $scope.onDblClick = function(data) {
  258. // var modelfile = { model: { notice: data } };
  259. // $state.go('app.system.form_editor', { formKey: 'noticeDetail', service: 'api_user_data', model: JSON.stringify(modelfile) });
  260. // };
  261. $scope.seeData = function (data) {
  262. var modelfile = {
  263. model: {
  264. notice: data
  265. }
  266. };
  267. $state.go('app.system.form_editor', {
  268. formKey: 'noticeDetail',
  269. service: 'api_user_data',
  270. model: JSON.stringify(modelfile)
  271. });
  272. };
  273. //列表操作按钮-新增
  274. $scope.addData = function () {
  275. // console.log(loginUser)
  276. var modelData = {
  277. model: {
  278. notice: {
  279. dept: {
  280. id: loginUser.dept.id
  281. }
  282. }
  283. }
  284. };
  285. $state.go('app.system.form', {
  286. formKey: 'noticeEditor',
  287. service: 'api_user_data',
  288. model: JSON.stringify(modelData)
  289. });
  290. }
  291. // 发布
  292. $scope.release = function (data) {
  293. var modalInstance = $modal.open({
  294. templateUrl: 'assets/views/delete.html',
  295. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  296. $scope.title = '公告发布';
  297. $scope.connect = '确定要发布此公告?';
  298. $scope.ok = function () {
  299. $modalInstance.close(data);
  300. };
  301. $scope.cancel = function () {
  302. $modalInstance.dismiss('cancel');
  303. };
  304. },
  305. size: 'sm',
  306. resolve: {
  307. scope: function () {
  308. return $scope;
  309. }
  310. }
  311. });
  312. modalInstance.result.then(function (selectedItem) {
  313. if (selectedItem) {
  314. // console.log(selectedItem);
  315. selectedItem.status = 1;
  316. delete selectedItem.item;
  317. delete selectedItem.statusName;
  318. api_user_data.updData('notice', {
  319. "notice": selectedItem
  320. }).then(function (response) {
  321. if (response.data) {
  322. SweetAlert.swal({
  323. title: "发布成功!",
  324. type: "success",
  325. confirmButtonColor: "#007AFF"
  326. }, function () {
  327. $scope.myData = _.reject($scope.myData, function (o) {
  328. return _.includes(selectedItem, o.id);
  329. });
  330. $scope.gridOptions.totalItems = $scope.gridOptions.totalItems - selectedItem.length;
  331. $scope.refreshData('expand-right', $scope.jry_fileData);
  332. });
  333. } else {
  334. SweetAlert.swal({
  335. title: "操作异常!",
  336. text: "系统异常,请稍后重试,或者联系管理员!",
  337. type: "error"
  338. });
  339. }
  340. })
  341. }
  342. })
  343. }
  344. $scope.minTime = "";
  345. $scope.maxTime = "";
  346. // 搜索
  347. $scope.searchData = function () {
  348. if ($scope.minTime) {
  349. $scope.jry_fileData.notice.createTime = moment($scope.minTime).format("YYYY-MM-DD HH:mm:ss")
  350. }
  351. if ($scope.maxTime) {
  352. $scope.jry_fileData.notice.endTime = moment($scope.maxTime).format("YYYY-MM-DD HH:mm:ss")
  353. }
  354. $scope.refreshData('expand-right', $scope.jry_fileData);
  355. }
  356. // 清空
  357. $scope.clean = function () {
  358. delete $scope.jry_fileData.notice.title;
  359. delete $scope.jry_fileData.notice.createTime;
  360. $scope.minTime = "";
  361. delete $scope.jry_fileData.notice.endTime;
  362. $scope.maxTime = "";
  363. delete $scope.jry_fileData.notice.createUser;
  364. $scope.refreshData('expand-right', $scope.jry_fileData);
  365. }
  366. // 撤回
  367. $scope.withdraw = function (data) {
  368. var modalInstance = $modal.open({
  369. templateUrl: 'assets/views/delete.html',
  370. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  371. $scope.title = '公告撤回';
  372. $scope.connect = '确定要撤回此公告?';
  373. $scope.ok = function () {
  374. $modalInstance.close(data);
  375. };
  376. $scope.cancel = function () {
  377. $modalInstance.dismiss('cancel');
  378. };
  379. },
  380. size: 'sm',
  381. resolve: {
  382. scope: function () {
  383. return $scope;
  384. }
  385. }
  386. });
  387. modalInstance.result.then(function (selectedItem) {
  388. if (selectedItem) {
  389. // console.log(selectedItem);
  390. selectedItem.status = 2;
  391. delete selectedItem.item;
  392. delete selectedItem.statusName;
  393. api_user_data.updData('notice', {
  394. "notice": selectedItem
  395. }).then(function (response) {
  396. if (response.data) {
  397. SweetAlert.swal({
  398. title: "撤回成功!",
  399. type: "success",
  400. confirmButtonColor: "#007AFF"
  401. }, function () {
  402. $scope.myData = _.reject($scope.myData, function (o) {
  403. return _.includes(selectedItem, o.id);
  404. });
  405. $scope.gridOptions.totalItems = $scope.gridOptions.totalItems - selectedItem.length;
  406. $scope.refreshData('expand-right', $scope.jry_fileData);
  407. });
  408. } else {
  409. SweetAlert.swal({
  410. title: "操作异常!",
  411. text: "系统异常,请稍后重试,或者联系管理员!",
  412. type: "error"
  413. });
  414. }
  415. })
  416. }
  417. })
  418. }
  419. // 删除
  420. $scope.removeData = function (data) {
  421. var modalInstance = $modal.open({
  422. templateUrl: 'assets/views/delete.html',
  423. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  424. var rmvList = [];
  425. $scope.title = '公告删除';
  426. $scope.connect = '确定要删除此公告?';
  427. // angular.forEach(scope.selected.items, function(item) {
  428. // rmvList.push(item.id);
  429. // });
  430. rmvList.push(data.id);
  431. $scope.ok = function () {
  432. $modalInstance.close(rmvList);
  433. };
  434. $scope.cancel = function () {
  435. $modalInstance.dismiss('cancel');
  436. };
  437. },
  438. size: 'sm',
  439. resolve: {
  440. scope: function () {
  441. return $scope;
  442. }
  443. }
  444. });
  445. modalInstance.result.then(function (selectedItem) {
  446. if (selectedItem) {
  447. if (selectedItem.length > 0) {
  448. api_user_data.rmvData('notice', selectedItem).then(function (response) {
  449. if (response.data) {
  450. SweetAlert.swal({
  451. title: "删除成功!",
  452. type: "success",
  453. confirmButtonColor: "#007AFF"
  454. }, function () {
  455. $scope.myData = _.reject($scope.myData, function (o) {
  456. return _.includes(selectedItem, o.id);
  457. });
  458. $scope.selected = {
  459. items: []
  460. };
  461. $scope.gridOptions.totalItems = $scope.gridOptions.totalItems - selectedItem.length;
  462. // $scope.gridApi.grid.selection.selectedCount = 0;
  463. $scope.refreshData('expand-right', $scope.jry_fileData);
  464. });
  465. } else {
  466. SweetAlert.swal({
  467. title: "操作异常!",
  468. text: "系统异常,请稍后重试,或者联系管理员!",
  469. type: "error"
  470. });
  471. }
  472. })
  473. }
  474. }
  475. })
  476. }
  477. $scope.selected = {
  478. items: []
  479. }
  480. $scope.editted = {
  481. items: []
  482. }
  483. $scope.jry_fileData = {
  484. "idx": 0,
  485. "sum": 10,
  486. "notice": {}
  487. }
  488. $scope.gridOptions.onRegisterApi = function (gridApi) {
  489. $scope.gridApi = gridApi;
  490. // gridApi.edit.on.afterCellEdit($scope,function(rowEntity, colDef, newValue, oldValue){
  491. // // console.log(rowEntity);
  492. // });
  493. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  494. var filtersData = $scope.memoryfilterData;
  495. filtersData.idx = newPage - 1;
  496. $scope.jry_fileData.idx = newPage - 1;
  497. filtersData.sum = pageSize;
  498. $scope.jry_fileData.sum = pageSize;
  499. defaultFilterData = filtersData;
  500. $scope.refreshData('expand-right', $scope.jry_fileData);
  501. });
  502. // gridApi.selection.on.rowSelectionChanged($scope, function(scope) {
  503. // console.log("ok");
  504. // var j = 0;
  505. // for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  506. // if (scope.grid.appScope.selected.items[i] == scope.entity) {
  507. // j++;
  508. // break;
  509. // }
  510. // }
  511. // // console.log("j="+j)
  512. // if (j == 1) {
  513. // scope.grid.appScope.selected.items.splice(i, 1);
  514. // } else {
  515. // scope.grid.appScope.selected.items.push(scope.entity)
  516. // }
  517. // });
  518. // gridApi.selection.on.rowSelectionChangedBatch($scope, function(rows) {
  519. // var selectitem = [];
  520. // selectitem = angular.copy($scope.selected.items);
  521. // for (var j = 0; j < rows.length; j++) {
  522. // if (rows[j].isSelected == true) {
  523. // selectitem.push(rows[j].entity);
  524. // } else {
  525. // delete selectitem[j];
  526. // // rows.splice(j, 1);
  527. // }
  528. // }
  529. // $scope.selected.items = [];
  530. // for (var i = 0; i < selectitem.length; i++) {
  531. // if (selectitem[i]) {
  532. // $scope.selected.items.push(selectitem[i]);
  533. // }
  534. // }
  535. // });
  536. gridApi.core.on.filterChanged($scope, function () {
  537. var grid = this.grid;
  538. // var filtersData = {
  539. // idx: 0,
  540. // sum: 10
  541. // };
  542. var filtersData = $scope.memoryfilterData;
  543. angular.forEach(grid.columns, function (item) {
  544. if (item.enableFiltering) {
  545. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  546. if (angular.isUndefined(filtersData['user'])) {
  547. filtersData['notice'] = {};
  548. // filtersData['user']['flag'] = -1;
  549. filtersData['notice'][item.field] = item.filters[0].term;
  550. } else {
  551. // filtersData.user.flag = -1;
  552. filtersData.notice[item.field] = item.filters[0].term;
  553. }
  554. // filtersData['user']['flag'] = -1;
  555. // filtersData['user'][item.field] = item.filters[0].term;
  556. }
  557. }
  558. });
  559. $scope.memoryfilterData = filtersData;
  560. $scope.refreshData('expand-right', filtersData);
  561. });
  562. };
  563. var defaultFilterData = {
  564. "idx": 0,
  565. "sum": 10
  566. };
  567. $scope.memoryfilterData = {
  568. "idx": 0,
  569. "sum": 10
  570. }
  571. $scope.ldloading = {};
  572. $scope.refresh = function (style, filterData) {
  573. $scope.selected = {
  574. items: []
  575. };
  576. if ($scope.gridApi) {
  577. // $scope.gridApi.grid.options.paginationCurrentPage = 0;
  578. // $scope.gridApi.grid.selection.selectedCount = 0;
  579. }
  580. $scope.refreshData('expand-right', defaultFilterData);
  581. }
  582. //获取数据
  583. $scope.refreshData = function (style, filterData) {
  584. $scope.ldloading[style.replace('-', '_')] = true;
  585. if (angular.isUndefined(filterData)) {
  586. filterData = defaultFilterData;
  587. }
  588. if (angular.isDefined($scope.searchTypes)) {
  589. filterData['searchType'] = $scope.searchTypes;
  590. }
  591. $scope.myData = [];
  592. // filterData['flag'] = -1;
  593. // console.log("filterData=" + JSON.stringify(filterData))
  594. api_user_data.fetchDataList('notice', filterData).then(function (data) {
  595. var myData = Restangular.stripRestangular(data);
  596. $scope.gridOptions.totalItems = myData.totalNum;
  597. $scope.myData = myData.list;
  598. for (var i = 0; i < $scope.myData.length; i++) {
  599. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
  600. $scope.myData[i]['createTime'] = $scope.myData[i]['createTime'].split('.')[0];
  601. if ($scope.myData[i].status == 1) {
  602. $scope.myData[i]["statusName"] = "已发布"
  603. } else if ($scope.myData[i].status == 2) {
  604. $scope.myData[i]["statusName"] = "已撤销"
  605. } else if ($scope.myData[i].status == 3) {
  606. $scope.myData[i]["statusName"] = "暂存"
  607. }
  608. }
  609. $scope.ldloading[style.replace('-', '_')] = false;
  610. // console.log("$scope.myData="+JSON.stringify($scope.myData))
  611. }, function () {
  612. $scope.ldloading[style.replace('-', '_')] = false;
  613. });
  614. };
  615. //获取数据2
  616. $scope.refreshData2 = function (style, filterData) {
  617. $scope.ldloading[style.replace('-', '_')] = true;
  618. if (angular.isUndefined(filterData)) {
  619. filterData = defaultFilterData;
  620. }
  621. if (angular.isDefined($scope.searchTypes)) {
  622. filterData['searchType'] = $scope.searchTypes;
  623. }
  624. // filterData['flag'] = -1;
  625. // console.log("filterData=" + JSON.stringify(filterData))
  626. api_user_data.fetchDataList('notice', 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. $scope.myData[i]['createTime'] = $scope.myData[i]['createTime'].split('.')[0];
  633. if ($scope.myData[i].status == 1) {
  634. $scope.myData[i]["statusName"] = "已发布"
  635. } else if ($scope.myData[i].status == 2) {
  636. $scope.myData[i]["statusName"] = "已撤销"
  637. } else if ($scope.myData[i].status == 3) {
  638. $scope.myData[i]["statusName"] = "暂存"
  639. }
  640. }
  641. $scope.ldloading[style.replace('-', '_')] = false;
  642. // console.log("$scope.myData="+JSON.stringify($scope.myData))
  643. }, function () {
  644. $scope.ldloading[style.replace('-', '_')] = false;
  645. });
  646. };
  647. $scope.timer = $interval(function () {
  648. $scope.refreshData2('expand-right', $scope.jry_fileData);
  649. }, $rootScope.refreshTime);
  650. $scope.$on('$destroy', function () {
  651. $interval.cancel($scope.timer)
  652. })
  653. $scope.refreshData('expand-right', defaultFilterData);
  654. }]);